[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/resources/ -> resources.class.php (source)

   1  <?php /* $Id: resources.class.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/resources/resources.class.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  // Copyright 2004, Adam Donnison <adam@saki.com.au>
   7  // Released under GNU General Public License version 2 or later
   8  
   9  require_once $AppUI->getSystemClass('w2p');
  10  require_once $AppUI->getSystemClass('query');
  11  
  12  class CResource extends CW2pObject {
  13      var $resource_id = null;
  14      var $resource_key = null;
  15      var $resource_name = null;
  16      var $resource_type = null;
  17      var $resource_max_allocation = null;
  18      var $resource_note = null;
  19  
  20  	function CResource() {
  21          parent::CW2pObject('resources', 'resource_id');
  22      }
  23  
  24      function &loadTypes() {
  25          // If we have loaded the resource types before then we don't need to
  26          // load them again.
  27          if (isset($_SESSION['resource_type_list'])) {
  28              $typelist = &$_SESSION['resource_type_list'];
  29          } else {
  30              $this->_query->clear();
  31              $this->_query->addTable('resource_types');
  32              $this->_query->addQuery('resource_type_id, resource_type_name');
  33              $this->_query->addOrder('resource_type_name');
  34  
  35              $res = &$this->_query->exec(ADODB_FETCH_ASSOC);
  36              $typelist = array();
  37              $typelist[0] = array('resource_type_id' => 0, 'resource_type_name' => 'All Resources');
  38              while ($row = $this->_query->fetchRow()) {
  39                  $typelist[] = $row;
  40              }
  41              $this->_query->clear();
  42              $_SESSION['resource_type_list'] = &$typelist;
  43          }
  44          return $typelist;
  45      }
  46  
  47  	function typeSelect() {
  48          $typelist = &$this->loadTypes();
  49          $result = array();
  50          foreach ($typelist as $type) {
  51              $result[$type['resource_type_id']] = $type['resource_type_name'];
  52          }
  53          return $result;
  54      }
  55  
  56  	function getTypeName() {
  57          $result = 'All Resources';
  58          $this->_query->clear();
  59          $this->_query->addTable('resource_types');
  60          $this->_query->addWhere('resource_type_id = ' . (int)$this->resource_type);
  61          $res = &$this->_query->exec(ADODB_FETCH_ASSOC);
  62          if ($row = $this->_query->fetchRow()) {
  63              $result = $row['resource_type_name'];
  64          }
  65          $this->_query->clear();
  66          return $result;
  67      }
  68  }
  69  ?>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7