energine
[ class tree: energine ] [ index: energine ] [ all elements ]

Source for file ProductStatusEditor.class.php

Documentation is available at ProductStatusEditor.class.php

  1. <?php
  2.  
  3. /**
  4.  * Содержит класс ProductStatusEditor
  5.  *
  6.  * @package energine
  7.  * @subpackage shop
  8.  * @author dr.Pavka
  9.  * @copyright ColoCall 2007
  10.  * @version $Id$
  11.  */
  12.  
  13. //require_once('core/modules/share/components/Grid.class.php');
  14.  
  15. /**
  16.  * Редактор статусов продуктов
  17.  *
  18.  * @package energine
  19.  * @subpackage shop
  20.  * @author dr.Pavka
  21.  */
  22. class ProductStatusEditor extends Grid {
  23.     /**
  24.      * Конструктор класса
  25.      *
  26.      * @param string $name 
  27.      * @param string $module 
  28.      * @param Document $document 
  29.      * @param array $params 
  30.      * @access public
  31.      */
  32.     public function __construct($name$moduleDocument $documentarray $params null{
  33.         parent::__construct($name$module$document$params);
  34.         $this->setTableName('shop_product_statuses');
  35.     }
  36.  
  37.     /**
  38.      * Дизейблится дефолтное значение
  39.      *
  40.      * @return void 
  41.      * @access protected
  42.      */
  43.  
  44.     protected function edit({
  45.         parent::edit();
  46.         if($this->getData()->getFieldByName('ps_is_default')->getRowData(0=== true{
  47.             $this->getDataDescription()->getFieldDescriptionByName('ps_is_default')->setMode(FieldDescription::FIELD_MODE_READ);
  48.         }
  49.     }
  50.     /**
  51.      * При добавлении віставляем уровень прав в минимально возможный видимый
  52.      *
  53.      * @return void 
  54.      * @access protected
  55.      */
  56.  
  57.      protected function add({
  58.         parent::add();
  59.         $this->getData()->getFieldByName('right_id')->setData(FieldDescription::FIELD_MODE_READ);
  60.      }
  61.  
  62.     /**
  63.       * Снимаем признак дефолтного значения
  64.       *
  65.       * @return mixed 
  66.       * @access protected
  67.       */
  68.  
  69.     protected function saveData({
  70.         if (isset($_POST[$this->getTableName()]['ps_is_default']&& $_POST[$this->getTableName()]['ps_is_default']{
  71.             $this->dbh->modify(QAL::UPDATE$this->getTableName()array('ps_is_default'=>0)array('ps_is_default'=>1));
  72.         }
  73.         parent::saveData();
  74.     }
  75.  
  76.     /**
  77.      * Не даем удалить дефолтную запись
  78.      *
  79.      * @return void 
  80.      * @access protected
  81.      */
  82.  
  83.     protected function deleteData($id{
  84.         if ($this->dbh->select($this->getTableName()array('ps_id')array('ps_is_default'=>1'ps_id'=>$id)) !== true{
  85.             throw new SystemException('ERR_DEFAULT_STATUS'SystemException::ERR_CRITICAL);
  86.         }
  87.         parent::deleteData($id);
  88.     }
  89.  
  90.     /**
  91.      * Возвращает перечень статусов товаров видимых для пользователя  с заданным уровнем прав
  92.      *
  93.      * @param int уровень прав
  94.      * @return array 
  95.      * @access public
  96.      * @static
  97.      */
  98.  
  99.     static public function getVisibleStatuses($rightsLevel{
  100.         return simplifyDBResult(DBWorker::$dbhInstance->select('shop_product_statuses''ps_id''right_id <= '.$rightsLevel),'ps_id');
  101.     }
  102.  
  103.     /**
  104.      * Возвращает идентификатор дефолтного статуса
  105.      *
  106.      * @return int 
  107.      * @access public
  108.      * @static
  109.      */
  110.  
  111.     static public function getDefaultStatus({
  112.         return simplifyDBResult(DBWorker::$dbhInstance->select('shop_product_statuses''ps_id'array('ps_is_default'=>1))'ps_id'true);
  113.     }
  114. }
В создании документации нам помог: phpDocumentor