public function createFromForm($form, $issueId, $userId = null) { $acl = Zend_Registry::get('Default_DiContainer')->getAclService(); if (!$acl->isAllowed('issue', 'comment')) { return false; } $identity = Zend_Registry::get('Default_DiContainer')->getUserService()->getIdentity(); if ($userId === null) { $userId = $identity->getUserId(); } $permissions = $form->getValue('permissions'); $comment = new Default_Model_Comment(); $comment->setCreatedBy($identity)->setIssue($issueId)->setText($form->getValue('text'))->setPrivate($permissions['private'] ? true : false); $return = $this->_mapper->save($comment); if ($permissions['private']) { Zend_Registry::get('Default_DiContainer')->getAclService()->addResourceRecord($permissions['roles'], 'comment', $return); } return $return; }
public function auditTrail($issue, array $changes) { $user = Zend_Registry::get('Default_DiContainer')->getUserService()->getIdentity(); $comment = new Default_Model_Comment(); $comment->setCreatedBy($user)->setIssue($issue)->setPrivate(false)->setSystem(true)->setText(json_encode($changes)); Zend_Registry::get('Default_DiContainer')->getCommentService()->save($comment); }