Example #1
0
 /**
  * Returns table name
  * @see CActiveRecord::tableName()
  * @return string
  */
 public function tableName()
 {
     if (!$this->_tableName) {
         $this->_tableName = parent::tableName();
     }
     return $this->_tableName;
 }
Example #2
0
 protected function beforeDelete()
 {
     $currentRoles = Yii::app()->authManager->getAuthItems(CAuthItem::TYPE_ROLE, $this->id_user);
     foreach ($currentRoles as $role) {
         Yii::app()->authManager->revoke($role->name, $this->id_user);
     }
     return parent::beforeDelete();
 }
Example #3
0
File: Npf.php Project: Cranky4/npfs
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->date_create = time();
     }
     $this->date_update = time();
     return parent::beforeSave();
 }
Example #4
0
 protected function beforeDelete()
 {
     $all = $this->getTree();
     $sm = $all->getById($this->id_photogallery);
     if ($sm->deleteChildGallery()) {
         return parent::beforeDelete();
     }
     return false;
 }
Example #5
0
 protected function beforeSave()
 {
     if (HU::get(self::URL_PARAM_OBJECT) != null) {
         $this->id_photogallery_object = HU::get(self::URL_PARAM_OBJECT);
     }
     if (HU::get(self::URL_PARAM_INSTANCE) != null) {
         $this->id_photogallery_instance = HU::get(self::URL_PARAM_INSTANCE);
     }
     return parent::beforeSave();
 }
Example #6
0
 public function __call($name, $parameters)
 {
     $object = $this->getPluginObject();
     if ($object !== null) {
         if (method_exists($object, $name)) {
             // методы делегата
             return call_user_func_array(array($object, $name), $parameters);
         }
     }
     return parent::__call($name, $parameters);
 }
Example #7
0
 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         $idOldReference = $this->getPkBeforeSave();
         if ($this->id_reference != $idOldReference) {
             ReferenceElement::model()->updateAll(array('id_reference' => $this->id_reference), 'id_reference=:id', array(':id' => $idOldReference));
             ObjectParameter::model()->updateAll(array('add_parameter' => $this->id_reference), 'id_parameter_type=6 AND add_parameter=:id', array(':id' => $idOldReference));
         }
     }
     return parent::afterSave();
 }
Example #8
0
 protected function beforeSave()
 {
     return parent::beforeSave();
     /*if ($this->id_default_page == null) {
           //Создать страницу по умолчанию для домена
           $i = new Menu();
           $i->setName("Главная страница");
           //$i->setIdDomainInstance($instance->getIdInstance()); // TODO
           $i->save();
     
           $id = $i->getIdInstance();
           if (!is_null($id)) $instance->addValue("idDefaultPage", $id);
         }*/
 }
Example #9
0
 protected function afterSave()
 {
     parent::afterSave();
     if ($this->isNewRecord) {
         foreach ($this->offerProducts as $offerProduct) {
             $offerProduct->id_offer = $this->getPrimaryKey();
             $offerProduct->save(false);
         }
     }
     //Если нужно произвести списание остатка товара
     if ($this->getNeedDebitProducts()) {
         $this->debitProducts();
     }
     //Если нужно вернуть остаток товара на склад
     if ($this->getNeedCreaditProducts()) {
         $this->creditProducts();
     }
 }
Example #10
0
 protected function beforeDelete()
 {
     self::model()->updateAll(array('id_parent' => null), 'id_parent = :ID_PARENT', array(':ID_PARENT' => $this->primaryKey));
     return parent::beforeDelete();
 }
Example #11
0
 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         $idOldPhpScript = $this->getPkBeforeSave();
         if ($this->id_php_script_type != $idOldPhpScript) {
             PhpScriptInstance::model()->updateAll(array('id_php_script_type' => $this->id_php_script_type), 'id_php_script_type=:id', array(':id' => $idOldPhpScript));
             DaObjectViewColumn::model()->updateAll(array('handler' => $this->id_php_script_type), 'handler=:id', array(':id' => $idOldPhpScript));
         }
     }
     return parent::afterSave();
 }
Example #12
0
 protected function afterDelete()
 {
     $this->sqlChange($this, 'delete');
     return parent::afterDelete();
 }
 public function getCaption()
 {
     return $this->model->getAttributeLabel($this->attributeName);
 }
Example #14
0
 /**
  * @param DaObjectView $view
  * @param DaActiveRecord $model
  * @return CActiveDataProvider
  */
 public function buildDataProvider(DaObjectView $view, DaActiveRecord $model)
 {
     $pk = $model->getInstanceKeyName();
     $criteria = new CDbCriteria();
     $criteria->condition = $view->getWhere();
     $dataProvider = new CActiveDataProvider($model, array('criteria' => $criteria, 'keyAttribute' => $pk));
     $event = new ConfigureDataProviderEvent(Yii::app()->controller, $view->id_object, $dataProvider);
     Yii::app()->controller->raiseEvent(DefaultController::EVENT_ON_CONFIGURE_DATA_PROVIDER, $event);
     $dataProvider = $event->dataProvider;
     /***Ограничение по условию, сформированным программистом в классе***/
     $event = new PermissionWhereEvent(Yii::app()->controller, $view->id_object, '');
     $event->criteria = $criteria;
     Yii::app()->controller->raiseEvent(DefaultController::EVENT_ON_PROCESS_PERMISSION_WHERE, $event);
     $where = $event->where;
     if ($where != '') {
         $criteria->addCondition($where);
     }
     $criteria->params = array_merge($criteria->params, $event->params);
     return $dataProvider;
 }
Example #15
0
 protected function afterDelete()
 {
     parent::afterDelete();
     $module = Yii::app()->getModule('comments');
     $module->onDeleteComment($this);
 }
Example #16
0
 public function loadModelOr404($modelClass, $pk, $notFoundMessage = 'Запрашиваемая страница не найдена.')
 {
     $model = DaActiveRecord::model($modelClass)->findByPk($pk);
     return $this->throw404IfNull($model, $notFoundMessage);
 }
Example #17
0
 protected function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     if ($this->getIsNewRecord()) {
         if (empty($this->id_instance)) {
             if (empty($this->event_message)) {
                 throw new CException('Не указан текст уведомления');
             }
         } else {
             if ($this->event_message === '') {
                 $this->event_message = null;
             }
         }
         $this->_recipientsEmails = $this->getRecipientsEmails();
         if (empty($this->_recipientsEmails)) {
             return;
         }
         $this->event_create = time();
     }
     return true;
 }
Example #18
0
 public function init()
 {
     parent::init();
     $this->date = time();
     $this->ip = HU::getUserIp();
 }
Example #19
0
 protected function beforeDelete()
 {
     if (!$this->isRemovable()) {
         throw new ErrorException('Раздел нельзя удалить, так как он не отмечен как удаляемый');
     }
     $all = self::getAll();
     $sm = $all->getById($this->id);
     if ($sm->deleteChildMenu()) {
         return parent::beforeDelete();
     }
     return false;
 }
Example #20
0
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         $site = $this->link;
         $site = str_replace(array("http://", "www."), "", $site);
         $site = str_replace("/", "_", $site);
         $site = HText::translit($site) . "_" . rand(10, 1000);
         $site = str_replace("__", "_", $site);
         $this->unique_name = $site;
     }
     return parent::beforeSave();
 }
Example #21
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return Review the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Example #22
0
 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         $idOldView = $this->getPkBeforeSave();
         if ($this->id_object_view != $idOldView) {
             DaObjectViewColumn::model()->updateAll(array('id_object_view' => $this->id_object_view), 'id_object_view=:view', array(':view' => $idOldView));
         }
     }
     return parent::afterSave();
 }
Example #23
0
 public static function replaceIndex(DaActiveRecord $instance, $idLang = 1)
 {
     $data = $instance->getDataForSearch();
     self::replaceData($instance->getIdObject(), $instance->getIdInstance(), $idLang, $data);
 }
Example #24
0
 protected function beforeSave()
 {
     if (!$this->isNewRecord) {
         $idObject = $this->id_object;
         //echo 'id='.$idObject;HU::dump($this);exit;
         $objectCurrent = DaObject::getById($idObject);
         if ($objectCurrent != null && $objectCurrent->object_type == self::OBJECT_TYPE_TABLE && $objectCurrent->table_name != null) {
             $tableNotExists = Yii::app()->db->createCommand('SHOW TABLES LIKE :t')->queryScalar(array(':t' => $objectCurrent->table_name)) == null;
             if ($tableNotExists) {
                 if (Yii::app()->isBackend) {
                     Yii::app()->addMessage('Таблица ' . $objectCurrent->table_name . ' не существует, невозможно выполнить переименование в базе данных', BackendApplication::MESSAGE_TYPE_ERROR, true);
                 }
             } else {
                 $report = '';
                 if ($objectCurrent->table_name != "" && $objectCurrent->table_name != $this->table_name) {
                     $sql = 'RENAME TABLE `' . $objectCurrent->table_name . '` TO `' . $this->table_name . '`';
                     Yii::app()->db->createCommand($sql)->execute();
                     $report = $sql . '<br>';
                 }
                 if ($objectCurrent->name != "" && $objectCurrent->name != $this->name) {
                     $sql = 'ALTER TABLE `' . $this->table_name . '` COMMENT=' . $this->dbConnection->quoteValue($this->name);
                     Yii::app()->db->createCommand($sql)->execute();
                     $report .= $sql;
                 }
                 if (Yii::app()->isBackend) {
                     Yii::app()->addMessage('Выполнено ' . $report, BackendApplication::MESSAGE_TYPE_SUCCESS, true);
                 }
             }
         }
     }
     return parent::beforeSave();
 }
Example #25
0
 protected function beforeSave()
 {
     if (empty($this->id_file_type)) {
         $this->id_file_type = FileExtension::getTypeByExt($this->getExtension());
     }
     $this->resizeImage();
     return parent::beforeSave();
 }