Ejemplo n.º 1
0
 /**
  * Transition an issue to the outgoing step, based on request data if available
  * 
  * @param \thebuggenie\core\entities\Issue $issue
  * @param \thebuggenie\core\framework\Request $request 
  */
 public function transitionIssueToOutgoingStepFromRequest(\thebuggenie\core\entities\Issue $issue, $request = null)
 {
     $request = $request !== null ? $request : $this->_request;
     $this->getOutgoingStep()->applyToIssue($issue);
     if (!empty($this->_validation_errors)) {
         return false;
     }
     foreach ($this->getActions() as $action) {
         $action->perform($issue, $request);
     }
     foreach ($this->getPostValidationRules() as $rule) {
         if (!$rule->isValid($request)) {
             $this->_validation_errors[$rule->getRule()] = true;
         }
     }
     if (!empty($this->_validation_errors)) {
         return false;
     }
     if ($request->hasParameter('comment_body') && trim($request['comment_body'] != '')) {
         $comment = new \thebuggenie\core\entities\Comment();
         $comment->setContent($request->getParameter('comment_body', null, false));
         $comment->setPostedBy(framework\Context::getUser()->getID());
         $comment->setTargetID($issue->getID());
         $comment->setTargetType(Comment::TYPE_ISSUE);
         $comment->setModuleName('core');
         $comment->setIsPublic(true);
         $comment->setSystemComment(false);
         $comment->save();
         $issue->setSaveComment($comment);
     }
     $issue->save();
 }
Ejemplo n.º 2
0
 /**
  * Attach a file to the issue
  *
  * @param \thebuggenie\core\entities\File $file The file to attach
  */
 public function attachFile(\thebuggenie\core\entities\File $file, $file_comment = '', $file_description = '')
 {
     $existed = !tables\IssueFiles::getTable()->addByIssueIDandFileID($this->getID(), $file->getID());
     if (!$existed) {
         $comment = new \thebuggenie\core\entities\Comment();
         $comment->setPostedBy(framework\Context::getUser()->getID());
         $comment->setTargetID($this->getID());
         $comment->setTargetType(Comment::TYPE_ISSUE);
         if ($file_comment) {
             $comment->setContent(framework\Context::getI18n()->__('A file was uploaded. %link_to_file This comment was attached: %comment', array('%comment' => "\n\n" . $file_comment, '%link_to_file' => "[[File:{$file->getRealFilename()}|thumb|{$file_description}]]")));
         } else {
             $comment->setContent(framework\Context::getI18n()->__('A file was uploaded. %link_to_file', array('%link_to_file' => "[[File:{$file->getRealFilename()}|thumb|{$file_description}]]")));
         }
         $comment->save();
         if ($this->_files !== null) {
             $this->_files[$file->getID()] = $file;
         }
     }
 }