[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/resources/inc/ -> class.so_resources.inc.php (source)

   1  <?php
   2  /**
   3   * eGroupWare - resources
   4   *
   5   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
   6   * @package resources
   7   * @link http://www.egroupware.org
   8   * @author Cornelius Weiss <egw@von-und-zu-weiss.de>
   9   * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
  10   * @version $Id: class.so_resources.inc.php 19821 2005-11-14 18:16:56Z nelius_weiss $
  11   */
  12  
  13  
  14  include_once (EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
  15  
  16  /**
  17   * General storage object for resources
  18   *
  19   * @author Cornelius Weiss <egw@von-und-zu-weiss.de>
  20   * @package resources
  21   */
  22  class so_resources extends so_sql
  23  {
  24  	function so_resources()
  25      {
  26          $this->so_sql('resources','egw_resources');
  27          
  28          $custom =& CreateObject('admin.customfields',$contact_app);
  29          $this->customfields = $custom->get_customfields();
  30          $this->soextra =& CreateObject('etemplate.so_sql');
  31          $this->soextra->so_sql('resources','egw_resources_extra');
  32      }
  33  
  34      /**
  35       * gets the value of $key from resource of $res_id
  36       *
  37       * @param string $key key of value to get
  38       * @param int $res_id resource id
  39       * @return mixed value of key and resource, false if key or id not found.
  40       */
  41  	function get_value($key,$res_id)
  42      {
  43          if($this->db->select($this->table_name,$key,array('res_id' => $res_id),__LINE__,__FILE__))
  44          {
  45              $value = $this->db->row(row);
  46              return $value[$key];
  47          }
  48          return false;
  49      }
  50      
  51      /**
  52       * reads resource including custom fields
  53       *
  54       * @param interger $res_id res_id
  55       * @return array/boolean data if row could be retrived else False
  56       */
  57  	function read($res_id)
  58      {
  59          // read main data
  60          $resource = parent::read($res_id);
  61          
  62          // read customfields
  63          $keys = array(
  64              'extra_id' => $res_id,
  65              'extra_owner' => -1,
  66          );
  67          $customfields = $this->soextra->search($keys,false);
  68          foreach ((array)$customfields as $field)
  69          {
  70              $resource['#'.$field['extra_name']] = $field['extra_value'];
  71          }
  72          return $resource;
  73      }
  74  
  75      /**
  76       * saves a resource including extra fields
  77       *
  78       * @param array $resource key => value 
  79       * @return mixed id of resource if all right, false if fale
  80       */
  81  	function save($resource)
  82      {
  83          $this->data = $resource;
  84          if(parent::save() != 0) return false;
  85          $res_id = $this->data['res_id'];
  86          
  87          // save customfields
  88          foreach ($this->customfields as $field => $options)
  89          {
  90              $value = $resource['#'.$field];
  91              $data = array(
  92                  'extra_id' => $res_id,
  93                  'extra_name' => $field,
  94                  'extra_owner' => -1,
  95                  'extra_value' => $value,
  96              );
  97              $this->soextra->data = $data;
  98              $error_nr = $this->soextra->save();
  99              if($error_nr) return false;
 100          }
 101          return $res_id;
 102      }
 103      
 104  }


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