protected function _update(Default_Model_Comment $comment) { $db = $this->getWriteAdapter(); $oldComment = $this->getCommentById($comment->getCommentId()); $data = array(); if ($oldComment->getText() != $comment->getText()) { $data['text'] = $comment->getText(false); $oldData['text'] = $oldComment->getText(); } if ($oldComment->getPrivate() != $comment->getPrivate()) { $data['private'] = $comment->getPrivate() ? 1 : 0; $oldData['private'] = $oldComment->getPrivate() ? 1 : 0; } if ($oldComment->isDeleted() != $comment->isDeleted()) { $data['deleted'] = $comment->getDeleted() ? 1 : 0; $oldData['deleted'] = $oldComment->getDeleted() ? 1 : 0; } if (!count($data)) { return true; } // save audit trail foreach ($data as $field => $newValue) { $this->auditTrail($comment, 'update', $field, $oldData[$field], $newValue); } return $db->update('comment', $data, array('comment_id = ?' => $comment->getCommentId())); }
public function setDefaultValues(Default_Model_Comment $comment) { $this->getElement('text')->setValue($comment->getText(false)); $this->getSubform('permissions')->getElement('private')->setChecked($comment->isPrivate()); $roles = Zend_Registry::get('Default_DiContainer')->getAclService()->getRolesForResource('comment', $comment->getCommentId()); $roleIds = array(); foreach ($roles as $role) { $roleIds[] = $role->getRoleId(); } $this->getSubform('permissions')->getElement('roles')->setValue($roleIds); }