protected function _update() { parent::_update(); }
protected function _update() { // Hash password if being updated if (!empty($this->_modifiedFields['password'])) { if (empty($user->salt)) { $this->salt = (string) rand(1000000, 9999999); } $this->password = md5(Engine_Api::_()->getApi('settings', 'core')->getSetting('core.secret', 'staticSalt') . $this->password . $this->salt); } // Call parent parent::_update(); }
protected function _update() { if (empty($this->forum_id)) { throw new Forum_Model_Exception('Cannot have a topic without a forum'); } if (empty($this->user_id)) { throw new Forum_Model_Exception('Cannot have a topic without a user'); } if (!empty($this->_modifiedFields['forum_id'])) { $originalForumIdentity = $this->getTable()->select()->from($this->getTable()->info('name'), 'forum_id')->where('topic_id = ?', $this->getIdentity())->limit(1)->query()->fetchColumn(0); if ($originalForumIdentity != $this->forum_id) { $postsTable = Engine_Api::_()->getItemTable('forum_post'); $topicLastPost = $this->getLastCreatedPost(); $oldForum = Engine_Api::_()->getItem('forum', $originalForumIdentity); $newForum = Engine_Api::_()->getItem('forum', $this->forum_id); $oldForumLastPost = $oldForum->getLastCreatedPost(); $newForumLastPost = $newForum->getLastCreatedPost(); // Update old forum $oldForum->topic_count = new Zend_Db_Expr('topic_count - 1'); $oldForum->post_count = new Zend_Db_Expr(sprintf('post_count - %d', $this->post_count)); if (!$oldForumLastPost || $oldForumLastPost->topic_id == $this->getIdentity()) { // Update old forum last post $oldForumNewLastPost = $postsTable->select()->from($postsTable->info('name'), array('post_id', 'user_id'))->where('forum_id = ?', $originalForumIdentity)->where('topic_id != ?', $this->getIdentity())->order('post_id DESC')->limit(1)->query()->fetch(); if ($oldForumNewLastPost) { $oldForum->lastpost_id = $oldForumNewLastPost['post_id']; $oldForum->lastposter_id = $oldForumNewLastPost['user_id']; } else { $oldForum->lastpost_id = 0; $oldForum->lastposter_id = 0; } } $oldForum->save(); // Update new forum $newForum->topic_count = new Zend_Db_Expr('topic_count + 1'); $newForum->post_count = new Zend_Db_Expr(sprintf('post_count + %d', $this->post_count)); if (!$newForumLastPost || strtotime($topicLastPost->creation_date) > strtotime($newForumLastPost->creation_date)) { // Update new forum last post $newForum->lastpost_id = $topicLastPost->post_id; $newForum->lastposter_id = $topicLastPost->user_id; } if (strtotime($topicLastPost->creation_date) > strtotime($newForum->modified_date)) { $newForum->modified_date = $topicLastPost->creation_date; } $newForum->save(); // Update posts $postsTable = Engine_Api::_()->getItemTable('forum_post'); $postsTable->update(array('forum_id' => $this->forum_id), array('topic_id = ?' => $this->getIdentity())); } } parent::_update(); }
protected function _update() { $settings = Engine_Api::_()->getApi('settings', 'core'); // Hash password if being updated if (!empty($this->_modifiedFields['password'])) { if (empty($this->salt)) { $this->salt = (string) rand(1000000, 9999999); } $this->password = md5($settings->getSetting('core.secret', 'staticSalt') . $this->password . $this->salt); } // Update enabled, hook will set to false if necessary if (!empty($this->_modifiedFields['approved']) || !empty($this->_modifiedFields['verified']) || !empty($this->_modifiedFields['enabled'])) { if (2 === (int) $settings->getSetting('user.signup.verifyemail', 0)) { $this->enabled = $this->approved && $this->verified; } else { $this->enabled = (bool) $this->approved; } } // Call parent parent::_update(); }
protected function _update() { if (empty($this->topic_id)) { throw new Forum_Model_Exception('Cannot have a post without a topic'); } if (empty($this->user_id)) { throw new Forum_Model_Exception('Cannot have a post without a user'); } $this->modified_date = date('Y-m-d H:i:s'); parent::_update(); }