本文整理汇总了PHP中Core_Model_Item_Abstract::_update方法的典型用法代码示例。如果您正苦于以下问题:PHP Core_Model_Item_Abstract::_update方法的具体用法?PHP Core_Model_Item_Abstract::_update怎么用?PHP Core_Model_Item_Abstract::_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core_Model_Item_Abstract
的用法示例。
在下文中一共展示了Core_Model_Item_Abstract::_update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _update
protected function _update()
{
parent::_update();
}
示例2: _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();
}
示例3: _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();
}
示例4: _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();
}
示例5: _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();
}