Esempio n. 1
0
 public function afterSave()
 {
     if ($this->isNewRecord) {
         $this->createTheme('site');
     }
     return parent::afterSave();
 }
Esempio n. 2
0
 public function afterSave()
 {
     parent::afterSave();
     $sql = "UPDATE p_nfy_subscription_categories " . "set category = 'role_{$this->role_name}.' " . "where category = 'role_{$this->oldName}.';";
     Yii::app()->db->createCommand($sql)->execute();
     return true;
 }
 /**
  * After save event
  */
 public function afterSave()
 {
     // Update Topic
     PersonalMessageTopic::model()->updateByPk($this->topic_id, array('last_reply_created_at' => $this->created_at, 'last_reply_author_id' => $this->user_id));
     // Send notifications
     PersonalMessageTopic::model()->sendNotifications($this->topic_id, $this->id);
     return parent::afterSave();
 }
Esempio n. 4
0
 /**
  * @return boolean
  */
 public function afterSave()
 {
     $this->order->updateTotalPrice();
     $this->order->updateDeliveryPrice();
     if ($this->isNewRecord) {
         $product = ShopProduct::model()->findByPk($this->product_id);
         $product->decreaseQuantity();
     }
     return parent::afterSave();
 }
Esempio n. 5
0
 public function afterSave()
 {
     //Yii::app()->cache->delete(Yii::app()->currency->cacheKey);
     if ($this->default) {
         ShopCurrency::model()->updateAll(array('default' => 0), 'id != :id', array(':id' => $this->id));
     }
     if ($this->main) {
         ShopCurrency::model()->updateAll(array('main' => 0), 'id != :id', array(':id' => $this->id));
     }
     parent::afterSave();
 }
Esempio n. 6
0
 public function afterSave()
 {
     // Leave only one default language
     /* if ($this->default)
        {
        self::model()->updateAll(array(
        'default'=>0,
        ), 'id != '.$this->id);
        } */
     return parent::afterSave();
 }
Esempio n. 7
0
 public function afterSave()
 {
     if ($this->getIsNewRecord()) {
         $this->addMessageCopies();
         if (empty($this->conversation_id)) {
             $this->conversation_id = $this->id;
             $this->setIsNewRecord(FALSE);
             $this->save(FALSE);
         }
     }
     return parent::afterSave();
 }
Esempio n. 8
0
 public function afterSave()
 {
     parent::afterSave();
     if (count($this->data) == 0) {
         foreach (Sector::model()->findAll() as $sector) {
             $data = new Data();
             $data->metric_id = $this->id;
             $data->sector_id = $sector->id;
             $data->save();
         }
     }
 }
Esempio n. 9
0
 protected function afterSave()
 {
     if ($this->protected_ip) {
         $this->protected_ip = json_decode($this->protected_ip, TRUE);
     }
     parent::afterSave();
 }
Esempio n. 10
0
	protected function afterSave() 
	{
		if(parent::afterSave()) {
			return true;
		} else {
			return false;
		}
	}
Esempio n. 11
0
 public function afterSave()
 {
     // Process related products
     if ($this->_related !== null) {
         $this->clearRelatedProducts();
         foreach ($this->_related as $id) {
             $related = new ShopRelatedProduct();
             $related->product_id = $this->id;
             $related->related_id = $id;
             $related->save(false, false);
         }
     }
     // Save configurable attributes
     if ($this->_configurable_attribute_changed === true) {
         // Clear
         Yii::app()->db->createCommand()->delete('{{shop_product_configurable_attributes}}', 'product_id = :id', array(':id' => $this->id));
         foreach ($this->_configurable_attributes as $attr_id) {
             Yii::app()->db->createCommand()->insert('{{shop_product_configurable_attributes}}', array('product_id' => $this->id, 'attribute_id' => $attr_id));
         }
     }
     // Process min and max price for configurable product
     if ($this->use_configurations) {
         $this->updatePrices($this);
     } else {
         // Check if product is configuration
         $query = Yii::app()->db->createCommand()->from('{{shop_product_configurations}} t')->where(array('in', 't.configurable_id', array($this->id)))->queryAll();
         foreach ($query as $row) {
             $model = ShopProduct::model()->findByPk($row['product_id']);
             if ($model) {
                 $this->updatePrices($model);
             }
         }
     }
     //  $this->date_update = date('Y-m-d H:i:s');
     return parent::afterSave();
 }
Esempio n. 12
0
 protected function afterSave()
 {
     if ($this->isNewRecord) {
         $model = new UserProfiles();
         $model->balance = UserProfiles::DEFAULT_BALANCE;
         $model->user_id = $this->getPrimaryKey();
         $model->save(FALSE);
     }
     parent::afterSave();
 }
Esempio n. 13
0
 public function afterSave()
 {
     $this->clearRouteCache();
     return parent::afterSave();
 }
Esempio n. 14
0
 public function afterSave()
 {
     if (parent::afterSave()) {
         Yii::app()->cache->flush('languages');
     }
 }
Esempio n. 15
0
 public function afterSave()
 {
     parent::afterSave();
     return true;
 }
Esempio n. 16
0
 public function afterSave()
 {
     return parent::afterSave();
 }
 /**
  * After save operations
  */
 public function afterSave()
 {
     // Add message to the reply table
     $reply = new PersonalMessageReply();
     $reply->topic_id = $this->id;
     $reply->message = $this->message;
     $reply->save();
     // Update Topic
     PersonalMessageTopic::model()->updateByPk($this->id, array('first_post' => $reply->id, 'last_reply_created_at' => $reply->created_at, 'last_reply_author_id' => $reply->user_id));
     // Add current user
     $participant = new PersonalMessageParticipant();
     $participant->topic_id = $this->id;
     $participant->user_id = Yii::app()->user->id;
     $participant->save();
     // Add recipients to the particiapnts table
     foreach ($this->to as $userid) {
         $participant = new PersonalMessageParticipant();
         $participant->topic_id = $this->id;
         $participant->user_id = $userid;
         $participant->save();
     }
     // Add the notifications for all the participants
     $this->sendNotifications(null, $reply->id);
     return parent::afterSave();
 }
Esempio n. 18
0
 /**
  * After save event
  */
 public function afterSave()
 {
     // Assign role to user
     $auth = Yii::app()->authManager;
     if (!$auth->isAssigned($this->role, $this->id)) {
         if ($auth->assign($this->role, $this->id)) {
             Yii::app()->authManager->save();
         }
     }
     return parent::afterSave();
 }
Esempio n. 19
0
 /**
  * after save method
  */
 public function afterSave()
 {
     Yii::app()->urlManager->clearCache();
     return parent::afterSave();
 }
Esempio n. 20
0
 public function afterSave()
 {
     if ($this->scenario === self::SCENARIO_UPDATE) {
         $this->updateDeptUser();
         Dept::model()->updateContactPerson($this->dept_id, $this->id);
     }
     return parent::afterSave();
 }
Esempio n. 21
0
 public function afterSave()
 {
     // автоматическое добавление льготы
     if ($this->CoursedpID > 0) {
         $ben = Personbenefits::model()->find("PersonID = {$this->PersonID} and BenefitID = 41");
         if (empty($ben)) {
             $ben = new Personbenefits("CONVERT");
             $ben->PersonID = $this->PersonID;
             $ben->BenefitID = 41;
             $ben->save();
         }
         if (!in_array($ben->idPersonBenefits, $this->benefits)) {
             $this->benefits[] = $ben->idPersonBenefits;
         }
     } else {
     }
     // Сохраняем массив льгот привязанных к специальности
     Personspecialitybenefits::model()->deleteAll("PersonSpecialityID = {$this->idPersonSpeciality}");
     if (!empty($this->benefits) && is_array($this->benefits)) {
         foreach ($this->benefits as $val) {
             $item = Personspecialitybenefits::model()->findByPk(array("PersonBenefitID" => $val, 'PersonSpecialityID' => $this->idPersonSpeciality));
             if (count($item) == 0) {
                 $item = new Personspecialitybenefits();
             }
             $item->PersonBenefitID = $val;
             $item->PersonSpecialityID = $this->idPersonSpeciality;
             $item->save();
         }
     }
     return parent::afterSave();
 }
Esempio n. 22
0
 function afterSave()
 {
     parent::afterSave();
     Hook::run('model.NodeField_afterSave', $this);
 }
Esempio n. 23
0
 /**
  * Save the languages after save of this model.
  * 
  * @var bool $wasNew True if the model was new before saving
  * @return boolean 
  */
 protected function afterSave($wasNew)
 {
     $lColName = $this->languageIdColumnName;
     $lColValue = $this->languageValueColumnName;
     $relationModelInstance = $this->_getRelationModelInstance();
     $languageRelationArray = $this->_getRelationArray();
     $activeLanguages = $this->activeLanguages();
     while ($lang = $activeLanguages->fetch()) {
         foreach ($this->multilingualAttributes as $mLAttribute) {
             $completeAttributeName = $mLAttribute . '_' . $lang->id;
             if (!empty($this->_mlAttr[$completeAttributeName])) {
                 $l = $relationModelInstance->findByPk(array($languageRelationArray['field'] => $this->id, $lColName => $lang->id));
                 if (!$l) {
                     $l = new $relationModelInstance();
                     $l->{$languageRelationArray}['field'] = $this->id;
                     $l->{$lColName} = $lang->id;
                 }
                 $l->{$lColValue} = $this->_mlAttr[$completeAttributeName];
                 $l->save();
             }
         }
     }
     return parent::afterSave($wasNew);
 }
Esempio n. 24
0
 /**
  * After save event
  */
 public function afterSave()
 {
     $this->clearRelations();
     // Process manufacturers
     if (!empty($this->_manufacturers)) {
         foreach ($this->_manufacturers as $id) {
             Yii::app()->db->createCommand()->insert('{{shop_discount_manufacturer}}', array('discount_id' => $this->id, 'manufacturer_id' => $id));
         }
     }
     // Process categories
     if (!empty($this->_categories)) {
         foreach ($this->_categories as $id) {
             Yii::app()->db->createCommand()->insert('{{shop_discount_category}}', array('discount_id' => $this->id, 'category_id' => $id));
         }
     }
     return parent::afterSave();
 }
Esempio n. 25
0
 public function afterSave()
 {
     $this->checkDir();
     McBridge::get()->serverCmd($this->id, 'refresh', $null);
     if ($this->prevDaemon && $this->prevDaemon != $this->daemon_id) {
         McBridge::get()->cmd($this->prevDaemon, 'server ' . $this->id . ':refresh');
         $this->prevDaemon = $this->daemon_id;
     }
     return parent::afterSave();
 }
Esempio n. 26
0
 /**
  * After save event
  */
 public function afterSave()
 {
     // Clear payment relations
     ShopDeliveryPayment::model()->deleteAllByAttributes(array('delivery_id' => $this->id));
     foreach ($this->payment_methods as $pid) {
         $model = new ShopDeliveryPayment();
         $model->delivery_id = $this->id;
         $model->payment_id = $pid;
         $model->save(false);
     }
     return parent::afterSave();
 }
Esempio n. 27
0
 public function afterSave()
 {
     $name = $this->name;
     if (@strlen($this->prevName) && $this->prevName != $name) {
         $name = $this->prevName;
     }
     $ftpUser = FtpUser::model()->findByAttributes(array('name' => $name));
     if ($ftpUser) {
         $ftpUser->syncWithUser($this);
         $ftpUser->save();
     }
     if ($this->sendData && $this->_sendPassword !== false) {
         $msg = new YiiMailMessage();
         $msg->setFrom(array(Yii::app()->params['admin_email'] => Yii::app()->params['admin_name']));
         $msg->setTo(array($this->email => $this->name));
         if ($this->isNewRecord) {
             $msg->view = 'welcome';
         } else {
             $msg->view = 'password';
         }
         $msg->setBody(array('password' => $this->_sendPassword, 'id' => $this->id, 'name' => $this->name, 'email' => $this->email, 'host' => Yii::app()->request->getHostInfo(), 'panel' => Yii::app()->request->getBaseUrl(true)));
         Yii::log('Seding welcome email to ' . $this->email);
         if (!Yii::app()->mail->send($msg)) {
             Yii::log('Error sending welcome email to ' . $this->email);
         } else {
             $this->_sendPassword = false;
             $this->sendData = false;
         }
     }
     return parent::afterSave();
 }
Esempio n. 28
0
 public function afterSave()
 {
     $this->updateSectionsRels();
     return parent::afterSave();
 }
Esempio n. 29
0
	public function afterSave()
	{
		parent::afterSave();
		if ($this->isNewRecord && $this->type == 'page' && $this->page == null) {
			$page = new Page;
			$page->text = 'Пока здесь ничего не написано';
			$page->category_id = $this->pk;
			if(!$page->save())
				throw new Exception('Не получилось создать страницу. Повторите действие еще раз.');
		}
	}