[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/infolog/inc/ -> class.datasource_infolog.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_infolog.inc.php 20601 2006-03-17 20:57:23Z ralfbecker $ */
  14  
  15  include_once (EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
  16  
  17  /**
  18   * DataSource for InfoLog
  19   *
  20   * The InfoLog datasource set's only real start- and endtimes, plus planned and used time and 
  21   * the responsible user as resources (not always the owner too!).
  22   * The read method of the extended datasource class sets the planned start- and endtime:
  23   *  - planned start from the end of a start constrain
  24   *  - planned end from the planned time and a start-time
  25   *  - planned start and end from the "real" values
  26   *
  27   * @package infolog
  28   * @author RalfBecker-AT-outdoor-training.de
  29   * @copyright (c) 2005 by RalfBecker-AT-outdoor-training.de
  30   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  31   */
  32  class datasource_infolog extends datasource
  33  {
  34      /**
  35       * Constructor
  36       */
  37  	function datasource_infolog()
  38      {
  39          $this->datasource('infolog');
  40          
  41          $this->valid = PM_COMPLETION|PM_PLANNED_START|PM_PLANNED_END|PM_REAL_END|PM_PLANNED_TIME|PM_USED_TIME|PM_RESOURCES;
  42      }
  43      
  44      /**
  45       * get an entry from the underlaying app (if not given) and convert it into a datasource array
  46       * 
  47       * @param mixed $data_id id as used in the link-class for that app, or complete entry as array
  48       * @return array/boolean array with the data supported by that source or false on error (eg. not found, not availible)
  49       */
  50  	function get($data_id)
  51      {
  52          // we use $GLOBALS['boinfolog'] as an already running instance might be availible there
  53          if (!is_object($GLOBALS['boinfolog']))
  54          {
  55              include_once (EGW_INCLUDE_ROOT.'/infolog/inc/class.boinfolog.inc.php');
  56              $GLOBALS['boinfolog'] =& new boinfolog();
  57          }
  58          if (!is_array($data_id))
  59          {
  60              $data =& $GLOBALS['boinfolog']->read((int) $data_id);
  61              
  62              if (!is_array($data)) return false;
  63          }
  64          else
  65          {
  66              $data =& $data_id;
  67          }
  68          return array(
  69              'pe_title'        => $GLOBALS['boinfolog']->link_title($data),
  70              'pe_completion'   => $data['info_percent'],
  71              'pe_planned_start'=> $data['info_startdate'] ? $data['info_startdate'] : null,
  72              'pe_planned_end'  => $data['info_enddate'] ? $data['info_enddate'] : null,
  73              'pe_real_end'     => $data['info_datecompleted'] ? $data['info_datecompleted'] : null,
  74              'pe_planned_time' => $data['info_planned_time'],
  75              'pe_used_time'    => $data['info_used_time'],
  76              'pe_resources'    => count($data['info_responsible']) ? $data['info_responsible'] : array($data['info_owner']),
  77              'pe_details'      => $data['info_des'] ? nl2br($data['info_des']) : '',
  78              'pl_id'           => $data['pl_id'],
  79              'pe_unitprice'    => $data['info_price'],
  80              'pe_planned_quantity' => $data['info_planned_time'] / 60,
  81              'pe_planned_budget'   => $data['info_planned_time'] / 60 * $data['info_price'],
  82              'pe_used_quantity'    => $data['info_used_time'] / 60,
  83              'pe_used_budget'      => $data['info_used_time'] / 60 * $data['info_price'],
  84          );
  85      }
  86      
  87      /**
  88       * Copy the datasource of a projectelement (InfoLog entry) and re-link it with project $target
  89       *
  90       * @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id
  91       * @param int $target target project id
  92       * @param array $target_data=null data of target-project, atm not used by the infolog datasource
  93       * @return array/boolean array(info_id,link_id) on success, false otherwise
  94       */
  95  	function copy($element,$target,$extra=null)
  96      {
  97          if (!is_object($GLOBALS['boinfolog']))
  98          {
  99              include_once (EGW_INCLUDE_ROOT.'/infolog/inc/class.boinfolog.inc.php');
 100              $GLOBALS['boinfolog'] =& new boinfolog();
 101          }
 102          $info =& $GLOBALS['boinfolog']->read((int) $element['pe_app_id']);
 103          
 104          if (!is_array($info)) return false;
 105          
 106          // unsetting info_link_id and evtl. info_from
 107          if ($info['info_link_id'])
 108          {
 109              $GLOBALS['boinfolog']->link_id2from($info);        // unsets info_from and sets info_link_target
 110              unset($info['info_link_id']);
 111          }
 112          // we need to unset a view fields, to get a new entry
 113          foreach(array('info_id','info_owner','info_modified','info_modifierer') as $key)
 114          {
 115              unset($info[$key]);
 116          }
 117          if(!($info['info_id'] = $GLOBALS['boinfolog']->write($info))) return false;
 118          
 119          // link the new infolog against the project and setting info_link_id and evtl. info_from
 120          $info['info_link_id'] = $GLOBALS['boinfolog']->link->link('projectmanager',$target,'infolog',$info['info_id'],$element['pe_remark'],0,0,1);
 121          if (!$info['info_from'])
 122          {
 123              $info['info_from'] = $GLOBALS['boinfolog']->link->title('projectmanager',$target);
 124          }
 125          $GLOBALS['boinfolog']->write($info);
 126          
 127          // creating again all links, beside the one to the source-project
 128          foreach($GLOBALS['boinfolog']->link->get_links('infolog',$element['pe_app_id']) as $link)
 129          {
 130              if ($link['app'] == 'projectmanager' && $link['id'] == $element['pm_id'] ||        // ignoring the source project
 131                  $link['app'] == $GLOBALS['boinfolog']->link->vfs_appname)                    // ignoring files attachments for now
 132              {
 133                  continue;
 134              }
 135              $GLOBALS['boinfolog']->link->link('infolog',$info['info_id'],$link['app'],$link['id'],$link['remark']);
 136          }
 137          return array($info['info_id'],$info['info_link_id']);
 138      }
 139  }


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