Esempio n. 1
0
 /**
  * Create a new comment
  *
  * @param  array           $input
  * @param  \Project        $project
  * @param  \Project\Issue  $issue
  * @return Comment
  */
 public static function create_comment($input, $project, $issue)
 {
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'issue_id' => $issue->id, 'comment' => $input['comment']);
     $comment = new static();
     $comment->fill($fill);
     $comment->save();
     /* Add to user's activity log */
     \User\Activity::add(2, $project->id, $issue->id, $comment->id);
     /* Add attachments to issue */
     \DB::table('projects_issues_attachments')->where('upload_token', '=', $input['token'])->where('uploaded_by', '=', \Auth::user()->id)->update(array('issue_id' => $issue->id, 'comment_id' => $comment->id));
     /* Update the project */
     $issue->updated_at = date('Y-m-d H:i:s');
     $issue->updated_by = \Auth::user()->id;
     $issue->save();
     return $comment;
 }
Esempio n. 2
0
    /**
     * Create a new comment
     *
     * @param  array           $input
     * @param  \Project        $project
     * @param  \Project\Issue  $issue
     * @return Comment
     */
    public static function create_comment($input, $project, $issue)
    {
        $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'issue_id' => $issue->id, 'comment' => $input['comment']);
        $comment = new static();
        $comment->fill($fill);
        $comment->save();
        /* Add to user's activity log */
        \User\Activity::add(2, $project->id, $issue->id, $comment->id);
        /* Add attachments to issue */
        $query = '
			UPDATE `projects_issues_attachments`
			SET issue_id = ?, comment_id = ?
			WHERE upload_token = ? AND uploaded_by = ?';
        \DB::query($query, array($issue->id, $comment->id, $input['token'], \Auth::user()->id));
        /* Update the project */
        $issue->updated_at = \DB::raw('NOW()');
        $issue->updated_by = \Auth::user()->id;
        $issue->save();
        return $comment;
    }
Esempio n. 3
0
 /**
  * Create a new comment
  *
  * @param  array           $input
  * @param  \Project        $project
  * @param  \Project\Issue  $issue
  * @return Comment
  */
 public static function create_comment($input, $project, $issue)
 {
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'issue_id' => $issue->id, 'comment' => $input['comment']);
     $comment = new static();
     $comment->fill($fill);
     $comment->save();
     /* Add to user's activity log */
     \User\Activity::add(2, $project->id, $issue->id, $comment->id);
     /* Add attachments to issue */
     \DB::table('projects_issues_attachments')->where('upload_token', '=', $input['token'])->where('uploaded_by', '=', \Auth::user()->id)->update(array('issue_id' => $issue->id, 'comment_id' => $comment->id));
     /* Update the project */
     $issue->updated_at = date('Y-m-d H:i:s');
     $issue->updated_by = \Auth::user()->id;
     $issue->save();
     /* Notify the person to whom the issue is currently assigned, unless that person is the one making the comment */
     if ($issue->assigned_to && $issue->assigned_to != \Auth::user()->id) {
         $project = \Project::current();
         //$subject = 'Issue "' . $issue->title . '" in "' . $project->name . '" project has a new comment';
         $subject = sprintf(__('email.new_comment'), $issue->title, $project->name);
         $text = \View::make('email.commented_issue', array('actor' => \Auth::user()->firstname . ' ' . \Auth::user()->lastname, 'project' => $project, 'issue' => $issue, 'comment' => $comment->comment));
         \Mail::send_email($text, $issue->assigned->email, $subject);
     }
     return $comment;
 }