[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/calendar/inc/ -> class.datasource_calendar.inc.php (source)

   1  <?php
   2  /**************************************************************************\
   3  * eGroupWare - ProjectManager - DataSource for InfoLog                     *
   4  * http://www.egroupware.org                                                *
   5  * Written and (c) 2005 by Ralf Becker <RalfBecker@outdoor-training.de>     *
   6  * --------------------------------------------                             *
   7  *  This program is free software; you can redistribute it and/or modify it *
   8  *  under the terms of the GNU General Public License as published by the   *
   9  *  Free Software Foundation; either version 2 of the License, or (at your  *
  10  *  option) any later version.                                              *
  11  \**************************************************************************/
  12  
  13  /* $Id: class.datasource_calendar.inc.php 21266 2006-04-08 06:21:54Z ralfbecker $ */
  14  
  15  include_once (EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
  16  
  17  /**
  18   * DataSource for the Calendar
  19   *
  20   * @package calendar
  21   * @author RalfBecker-AT-outdoor-training.de
  22   * @copyright (c) 2005 by RalfBecker-AT-outdoor-training.de
  23   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  24   */
  25  class datasource_calendar extends datasource
  26  {
  27      /**
  28       * Constructor
  29       */
  30  	function datasource_calendar()
  31      {
  32          $this->datasource('calendar');
  33          
  34          $this->valid = PM_PLANNED_START|PM_PLANNED_END|PM_PLANNED_TIME|PM_RESOURCES;
  35      }
  36      
  37      /**
  38       * get an entry from the underlaying app (if not given) and convert it into a datasource array
  39       * 
  40       * @param mixed $data_id id as used in the link-class for that app, or complete entry as array
  41       * @return array/boolean array with the data supported by that source or false on error (eg. not found, not availible)
  42       */
  43  	function get($data_id)
  44      {
  45          // we use $GLOBALS['bocal'] as an already running instance is availible there
  46          if (!is_object($GLOBALS['bocal']))
  47          {
  48              include_once (EGW_INCLUDE_ROOT.'/calendar/inc/class.bocal.inc.php');
  49              $GLOBALS['bocal'] =& new bocal();
  50          }
  51          if (!is_array($data_id))
  52          {
  53              if (!(int) $data_id || !($data = $GLOBALS['bocal']->read((int) $data_id)))
  54              {
  55                  return false;
  56              }
  57          }
  58          else
  59          {
  60              $data =& $data_id;
  61          }
  62          $ds = array(
  63              'pe_title' => $GLOBALS['bocal']->link_title($data),
  64              'pe_planned_start' => $GLOBALS['bocal']->date2ts($data['start']),
  65              'pe_planned_end'   => $GLOBALS['bocal']->date2ts($data['end']),
  66              'pe_resources'     => array(),
  67              'pe_details'       => $data['description'] ? nl2br($data['description']) : '',
  68          );
  69          // calculation of the time
  70          $ds['pe_planned_time'] = (int) (($ds['pe_planned_end'] - $ds['pe_planned_start'])/60);    // time is in minutes
  71  
  72          // if the event spans multiple days, we have to substract the nights (24h - daily working time specified in PM)
  73          if (date('Y-m-d',$ds['pe_planned_end']) != date('Y-m-d',$ds['pe_planned_start']))
  74          {
  75              foreach(array('start','end') as $name)
  76              {
  77                  $$name = $GLOBALS['bocal']->date2array($ds['pe_planned_'.$name]);
  78                  ${$name}['hour'] = 12;
  79                  ${$name}['minute'] = ${$name}['second'] = 0;
  80                  unset(${$name}['raw']);
  81                  $$name = $GLOBALS['bocal']->date2ts($$name);
  82              }
  83              $nights = round(($end - $start) / DAY_s);
  84              
  85              if (!is_array($this->pm_config))
  86              {
  87                  $c =& CreateObject('phpgwapi.config','projectmanager');
  88                  $c->read_repository();
  89                  $this->pm_config = $c->config_data;
  90                  unset($c);
  91                  if (!$this->pm_config['hours_per_workday']) $this->pm_config['hours_per_workday'] = 8;
  92              }
  93              $ds['pe_planned_time'] -= $nights * 60 * (24 - $this->pm_config['hours_per_workday']);
  94          }
  95          foreach($data['participants'] as $uid => $status)
  96          {
  97              if ($status != 'R' && is_numeric($uid))    // only users for now
  98              {
  99                  $ds['pe_resources'][] = $uid;
 100              }
 101          }
 102          // if we have multiple participants we have to multiply the time by the number of participants to get the total time
 103          $ds['pe_planned_time'] *= count($ds['pe_resources']);
 104  
 105  /*
 106          // ToDO: this does not change automatically after the event is over, 
 107          // maybe we need a flag for that in egw_pm_elements
 108          if ($data['end']['raw'] <= time()+$GLOBALS['egw']->datetime->tz_offset)
 109          {
 110              $ds['pe_used_time'] = $ds['pe_planned_time'];
 111          }
 112  */
 113          if ($this->debug)
 114          {
 115              echo "datasource_calendar($data_id) data="; _debug_array($data);
 116              echo "datasource="; _debug_array($ds);
 117          }
 118          return $ds;
 119      }
 120  }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7