Example #1
0
 public function afterSave($created)
 {
     parent::afterSave($created);
     Cache::delete('blog_archives');
     Cache::delete('blog_categories');
     Cache::delete('blog_tags');
 }
Example #2
0
 function afterSave($created)
 {
     $results = parent::afterSave($created);
     $acts = array();
     $minRange = 0;
     App::import('Lib', 'SetMulti');
     foreach ($this->updateActions as $name => $act) {
         if (SetMulti::testCond($act['event'], $this)) {
             $acts[$name] = $act;
             $minRange = max($minRange, $act['range']);
         }
     }
     //debug($acts);
     //debug($minRange);
     if (!empty($acts)) {
         $pos = $this->getPos();
         //debug($pos);
         $this->updateTilesRect($pos['x'] - $minRange * 2, $pos['y'] - $minRange * 2, $pos['zone_id'], $minRange * 4 + 1, $minRange * 4 + 1, $acts);
         //return false;
     }
     if ($created) {
         if (empty($pos)) {
             $pos = $this->getPos();
         }
         $this->checkChunkUpdater($pos['x'], $pos['y'], $pos['zone_id']);
     }
     return $results;
 }
 function afterSave($created)
 {
     parent::afterSave($created);
     $barra_lateral = null;
     $posicao_menu = null;
     $tamanho = 'grande';
     //        die($this->data['Configuracao']['pin']);
     if ($this->data['Configuracao']['pin'] == 'usa_barra_lateral') {
         $barra_lateral = $this->data['Configuracao']['conteudo'];
         $registro = $this->find('first', array('conditions' => array('pin' => 'posicao_menu')));
         $posicao_menu = $registro['Configuracao']['conteudo'];
     } elseif ($this->data['Configuracao']['pin'] == 'posicao_menu') {
         $posicao_menu = $this->data['Configuracao']['conteudo'];
         $registro = $this->find('first', array('conditions' => array('pin' => 'usa_barra_lateral')));
         $barra_lateral = $registro['Configuracao']['conteudo'];
     }
     //        die($barra_lateral . ' --- ' . $posicao_menu);
     if (!is_null($posicao_menu) && !is_null($barra_lateral)) {
         if ($posicao_menu == 1 && $barra_lateral || $posicao_menu == 2 && !$barra_lateral) {
             $tamanho = 'medio';
         } elseif ($posicao_menu == 2 && $barra_lateral) {
             $tamanho = 'pequeno';
         }
         $tamanho_centro = $this->find('first', array('conditions' => array('pin' => 'tamanho_centro')));
         //            die($tamanho);
         $tamanho_centro['Configuracao']['conteudo'] = $tamanho;
         $this->save($tamanho_centro);
     }
     return true;
 }
Example #4
0
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     if (isset($this->data["Combination"]['Combination'][0])) {
         $x = $this->Combination->find("first", array("conditions" => array("Combination.id" => $this->data["Combination"]['Combination'][0])));
         $x2 = $this->Combination->find("all", array("contain" => false, "conditions" => array("Combination.reviewkey" => $x['Combination']['reviewkey']), "fields" => array("id")));
         foreach ($x2 as $v) {
             App::uses("CombinationsReview", "Model");
             $a = new CombinationsReview();
             $a->create();
             if (!$a->hasAny(array("CombinationsReview.combination_id" => $v['Combination']['id'], "CombinationsReview.review_id" => $this->getLastInsertID()))) {
                 $a->save(array("CombinationsReview" => array('combination_id' => $v['Combination']['id'], 'review_id' => $this->getLastInsertID())));
             }
         }
     } elseif ($this->data["Review"]['combination_reviewkey']) {
         $x2 = $this->Combination->find("all", array("contain" => false, "conditions" => array("Combination.reviewkey" => $this->data["Review"]['combination_reviewkey']), "fields" => array("id")));
         foreach ($x2 as $v) {
             App::uses("CombinationsReview", "Model");
             $a = new CombinationsReview();
             $a->create();
             if (!$a->hasAny(array("CombinationsReview.combination_id" => $v['Combination']['id'], "CombinationsReview.review_id" => $this->getLastInsertID()))) {
                 $a->save(array("CombinationsReview" => array('combination_id' => $v['Combination']['id'], 'review_id' => $this->getLastInsertID())));
             }
         }
     }
 }
Example #5
0
 function afterSave($created)
 {
     parent::afterSave($created);
     if ($created) {
         $this->updatePathing();
     }
 }
Example #6
0
 public function afterSave($created)
 {
     parent::afterSave($created);
     if ($this->id) {
         Cache::delete('getPracticeTitleById' . $this->id);
     }
 }
Example #7
0
 public function afterSave($created)
 {
     $question_id = $this->getLastInsertID() ? $this->getLastInsertID() : $this->id;
     if (isset($this->data['SaveAnswer']['content']) && !empty($this->data['SaveAnswer']['content'])) {
         //delete old answer
         $this->Answer->deleteAll(array('Answer.question_id' => $question_id));
         $rightAnswer_Index = Set::extract("/right_answer", $this->data['SaveAnswer']);
         //
         $answerData = null;
         $right_answer = null;
         $idx = 0;
         foreach ($this->data['SaveAnswer']['content'] as $answer) {
             if (!$answer) {
                 continue;
             }
             $this->data['Answer']['question_id'] = $question_id;
             $this->data['Answer']['content'] = $answer;
             $this->Answer->save($this->data['Answer']);
             if (in_array($idx, $this->data['SaveAnswer']['right_answer'])) {
                 $right_answer = $this->Answer->getLastInsertID() ? $this->Answer->getLastInsertID() : $this->Answer->id;
             }
             $this->Answer->id = false;
             $idx++;
         }
         $question['Question']['id'] = $question_id;
         $question['Question']['right_answer'] = $right_answer;
         $this->saveAll($question['Question'], array('validate' => false));
     }
     parent::afterSave($created);
 }
Example #8
0
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     if (AuthComponent::user()) {
         App::uses('CakeSession', 'Model/Datasource');
         CakeSession::write('Auth', $this->findById(AuthComponent::user('id')));
     }
     return true;
 }
Example #9
0
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     if (!empty($this->data[$this->alias]['movefile'])) {
         $path = $this->data[$this->alias]['movefile']['tmp_name'];
         $destination = "files/splash/" . $this->data[$this->alias]['movefile']['name'];
         move_uploaded_file($path, $destination);
     }
 }
Example #10
0
 public function afterSave($created)
 {
     if ($created) {
         $this->data['Subscription']['id'] = $this->id;
         $this->Feed->id = $this->data['Subscription']['feed_id'];
         $this->Feed->updateSubscribersCount();
     }
     parent::afterSave($created);
 }
Example #11
0
 public function afterSave($options = null)
 {
     parent::afterSave($options);
     switch ($this->alias) {
         case "Feed":
             $this->save_feeds_authors($this->data);
             break;
     }
     return true;
 }
Example #12
0
 public function afterSave($created)
 {
     $id = $this->id;
     $_SERVER['FORCEMASTER'] = true;
     $post = $this->returnPost(array("Dailyop.id" => $id), true, true);
     //make the keywords
     $s = $this->extractSearchValues($post);
     $SearchItem = ClassRegistry::init("SearchItem");
     $SearchItem->insertItem($s);
     return parent::afterSave();
 }
Example #13
0
 function afterSave($created)
 {
     $results = parent::afterSave($created);
     if (!in_array($this->data['Event']['event_type_id'], array(15, 22))) {
         $eventType = $created ? 22 : 15;
         $eventOption = array('name' => $eventType, 'aros' => $this->data['Event']['aro_id'], 'acos' => $this->data['Event']['aco_id'], 'bindedEvent' => $this->unserialize($this->data), 'phase' => 2, 'strict' => false);
         //debug($eventOption);
         $this->dispatchEvent($eventOption);
     }
     return $results;
 }
Example #14
0
File: event.php Project: vad/taolin
 function afterSave($created)
 {
     if (!empty($this->data) && $created) {
         // if the event is created, NOT merely updated!
         $event = $this->data['Event'];
         $e_id = $this->id;
         if (array_key_exists('summary', $event) && !empty($event['summary'])) {
             $this->addtotimeline(array('summary' => $event['summary'], 'uid' => $event['uid'], 'start_time' => $event['start_time'], 'end_time' => $event['end_time']), null, 'timelineevent-newevent', null, 'Event', $e_id);
         }
     }
     parent::afterSave($created);
 }
Example #15
0
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     if ($this->data[$this->alias]['id'] == AuthComponent::user('id')) {
         if (isset($this->data[$this->alias]['password'])) {
             unset($this->data[$this->alias]['password']);
         }
         $newData = array_merge(AuthComponent::user(), $this->data[$this->alias]);
         App::uses('SessionComponent', 'Controller/Component');
         CakeSession::write(AuthComponent::$sessionKey, $newData);
     }
     if ($created) {
         $event = new CakeEvent('Model.User.add', $this);
         $this->getEventManager()->dispatch($event);
     }
 }
Example #16
0
 function afterSave($arg)
 {
     parent::afterSave($arg);
     // Update root pages cache
     WildflowerRootPagesCache::update($this->findAllRoot());
 }
Example #17
0
 /**
  * Called after each successful save operation.
  *
  * @param boolean $created True if this save created a new record
  * @param array   $options Options passed from Model::save().
  *
  * @return void
  * @see  Model::save()
  */
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created);
     $action = $this->request->params['action'];
     if ($action == 'admin_add' || $action == 'admin_edit') {
         $path = $this->getPath($this->id);
         $path_num = count($path) - 1;
         if ($path_num > 0) {
             $under = "";
             for ($i = 0; $i < $path_num; $i++) {
                 $under .= "_";
             }
             $path_field = $under . $this->data['Category']['name'];
         } elseif ($path_num == 0) {
             $path_field = $this->data['Category']['name'];
         }
         $this->updateAll(array('Category.path' => "'{$path_field}'"), array('Category.id' => $this->id));
     }
     if ($action == 'admin_process') {
         $path = $this->getPath($this->id);
         $path_num = count($path) - 1;
         $category = $this->findById($this->id);
         if ($path_num > 0) {
             $under = "";
             for ($i = 0; $i < $path_num; $i++) {
                 $under .= "_";
             }
             $path_field = $under . $category['Category']['name'];
         } elseif ($path_num == 0) {
             $path_field = $category['Category']['name'];
         }
         $this->updateAll(array('Category.path' => "'{$path_field}'"), array('Category.id' => $this->id));
     }
 }
Example #18
0
 /**
  * after Save callback
  *
  * @param boolean $created
  * @return void
  * @access public
  */
 public function afterSave($created)
 {
     parent::afterSave($created);
     $this->clearCache();
 }
Example #19
0
 /**
  * Clears cache files after saving
  *
  */
 public function afterSave($created)
 {
     parent::afterSave($created);
     Cache::delete($this->_cacheKey);
 }
Example #20
0
 /**
  * After Save
  *
  * @param bool $created
  * @param array $options
  * @return void
  */
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     $this->deleteAssocCache($this->data);
     if ($this->updatingSystemData) {
         $this->updateSystemData($this->data);
     }
     if ($this->updatingRelated) {
         // ゴミ箱から戻す場合、 type の定義がないが問題なし
         if (!empty($this->data['Content']['type']) && $this->data['Content']['type'] == 'ContentFolder') {
             $this->updateChildren($this->data['Content']['id']);
         }
         $this->updateRelateSubSiteContent($this->data);
         if (!empty($this->data['Content']['parent_id']) && $this->beforeSaveParentId != $this->data['Content']['parent_id']) {
             $SiteConfig = ClassRegistry::init('SiteConfig');
             $SiteConfig->updateContentsSortLastModified();
             $this->beforeSaveParentId = null;
         }
     }
 }
Example #21
0
 function afterSave($created)
 {
     parent::afterSave($created);
     # Reload is needed in order to get the right status
     if ($created) {
         $id = $this->getLastInsertID();
     } else {
         $id = $this->id;
     }
     $issue = $this->find('first', array('conditions' => array('Issue.id' => $id)));
     # Update start/due dates of following issues
     $IssueRelation =& ClassRegistry::init('IssueRelation');
     $relations = $IssueRelation->find('list', array('conditions' => array('issue_from_id' => $issue['Issue']['id']), 'fields' => array('id', 'id')));
     foreach ($relations as $relation_id) {
         $IssueRelation->read(null, $relation_id);
         $IssueRelation->set_issue_to_dates();
     }
     # Close duplicates if the issue was closed
     if (!empty($this->issue_before_change['Status']) && !$this->issue_before_change['Status']['is_closed'] && $issue['Status']['is_closed']) {
         foreach ($this->duplicates($issue) as $duplicate) {
             $Duplicate =& ClassRegistry::init('Issue');
             # Reload is need in case the duplicate was updated by a previous duplicate
             $Duplicate->read(null, $duplicate['IssueFrom']['id']);
             # Don't re-close it if it's already closed
             if ($Duplicate->is_closed()) {
                 continue;
             }
             # Same user and notes
             $Duplicate->init_journal($Duplicate->data, $this->current_journal_user, $this->current_journal_notes);
             $Duplicate->saveField('status_id', $issue['Issue']['status_id']);
         }
     }
 }
Example #22
0
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created, $options);
     if (isset($this->data[$this->alias]['point_remain'])) {
         // update remain point into user/advisor profile table
         $this->updateRemainPoint($this->data[$this->alias]['point_remain']);
     }
 }
Example #23
0
 function afterSave()
 {
     parent::afterSave();
     return true;
 }
Example #24
0
 /**
  * afterSave
  * 
  * @param boolean $created 
  */
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created);
     if ($created && !empty($this->UserGroup)) {
         $this->applyDefaultFavorites($this->getLastInsertID(), $this->data[$this->alias]['user_group_id']);
     }
 }
Example #25
0
File: User.php Project: hurad/hurad
 /**
  * Called after each successful save operation.
  *
  * @param boolean $created True if this save created a new record
  * @param array   $options Options passed from Model::save().
  *
  * @return void
  * @see Model::save()
  */
 public function afterSave($created, $options = array())
 {
     parent::afterSave($created);
     if ($created) {
         $userMetaData['UserMeta'] = ['nickname' => $this->data['User']['username'], 'display_name' => $this->data['User']['username']];
         $this->UserMeta->user_id = $this->id;
         $this->UserMeta->saveData($userMetaData);
     }
 }
 /**
  * Save availability to redis after save
  *
  * @param bool $created
  * @param array $options
  */
 public function afterSave($created, $options = [])
 {
     parent::afterSave($created, $options);
     if (defined('REDIS_ENABLE')) {
         $item_id = $this->data['ItemAvailabilityTimes']['item_id'];
         if (!empty($item_id)) {
             $now = new DateTime();
             $item = $this->Item->find('first', ['fields' => ['Item.sku'], 'conditions' => ['Item.id' => $item_id]]);
             $sku = $item['Item']['sku'];
             $ns_warehouse_id = $this->data['ItemAvailabilityTimes']['ns_warehouse_id'];
             /**
              * Save Redis Availability
              */
             if ((is_null($this->data['ItemAvailabilityTimes']['end_date']) || $this->data['ItemAvailabilityTimes']['end_date'] > $now->format('Y-m-d h:i:s')) && $this->data['ItemAvailabilityTimes']['start_date'] < $now->format('Y-m-d h:i:s')) {
                 $redis_key = "item_id_cache_" . $item_id . "_" . $ns_warehouse_id;
                 $this->Redis->saveToRedis($redis_key, $this->data);
             }
             $this->saveRedisAvailability($sku, $ns_warehouse_id);
             $this->saveRedisBackorder($sku, $ns_warehouse_id);
             $this->saveRedisUnorderable($sku, $ns_warehouse_id);
             /**
              * Save Redis Availability multiple warehouse
              */
             $ns_warehouse_id = $this->NsWarehouse->multipleWarehouse($ns_warehouse_id);
             if (is_array($ns_warehouse_id)) {
                 $this->saveRedisAvailability($sku, $ns_warehouse_id);
                 $this->saveRedisBackorder($sku, $ns_warehouse_id);
                 $this->saveRedisUnorderable($sku, $ns_warehouse_id);
             }
         }
     }
 }
Example #27
0
 /**
  * afterSave callback
  *
  * @param boolean $created
  * @return void
  * @access public
  */
 public function afterSave($created)
 {
     parent::afterSave($created);
     if ($created) {
         $this->createToken('email');
     }
 }
Example #28
0
 function afterSave($created)
 {
     parent::afterSave($created);
     $this->__clearCache();
     return true;
 }
Example #29
0
 /**
  * After Save
  *
  * @param bool $created
  * @param array $options
  */
 public function afterSave($created, $options = [])
 {
     parent::afterSave($created, $options);
     App::uses('AuthComponent', 'Controller/Component');
     $user = AuthComponent::user();
     $ContentFolder = ClassRegistry::init('ContentFolder');
     if ($created) {
         $ContentFolder->saveSiteRoot(null, ['site_id' => $this->id, 'name' => $this->data['Site']['alias'] ? $this->data['Site']['alias'] : $this->data['Site']['name'], 'parent_id' => 1, 'title' => $this->data['Site']['title'], 'self_status' => $this->data['Site']['status'], 'author_id' => $user['id'], 'site_root' => true, 'layout_template' => 'default']);
     } else {
         $ContentFolder->saveSiteRoot($this->id, ['name' => $this->data['Site']['alias'] ? $this->data['Site']['alias'] : $this->data['Site']['name'], 'title' => $this->data['Site']['title'], 'self_status' => $this->data['Site']['status']]);
     }
     if (!empty($this->data['Site']['main'])) {
         $data = $this->find('first', ['conditions' => ['Site.main' => true, 'Site.id <>' => $this->id], 'recursive' => -1]);
         if ($data) {
             $data['Site']['main'] = false;
             $this->save($data, array('validate' => false, 'callbacks' => false));
         }
     }
 }
Example #30
0
 function afterSave($created)
 {
     parent::afterSave($created);
     if ($created) {
         $defaultFavorites = $this->UserGroup->field('default_favorites', array('UserGroup.id' => $this->data['User']['user_group_id']));
         if ($defaultFavorites) {
             $defaultFavorites = unserialize($defaultFavorites);
             if ($defaultFavorites) {
                 $userId = $this->getLastInsertID();
                 foreach ($defaultFavorites as $favorites) {
                     $favorites['user_id'] = $userId;
                     $favorites['sort'] = $this->Favorite->getMax('sort') + 1;
                     $this->Favorite->create($favorites);
                     $this->Favorite->save();
                 }
             }
         }
     }
 }