Exemple #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;
 }
Exemple #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;
    }
Exemple #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;
 }
Exemple #4
0
 /**
  * Create a new issue
  *
  * @param  array    $input
  * @param  \Project  $project
  * @return Issue
  */
 public static function create_issue($input, $project)
 {
     $rules = array('title' => 'required|max:200', 'body' => 'required');
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'title' => $input['title'], 'body' => $input['body']);
     if (\Auth::user()->permission('issue-modify')) {
         $fill['assigned_to'] = $input['assigned_to'];
     }
     $issue = new static();
     $issue->fill($fill);
     $issue->save();
     /* Add to user's activity log */
     \User\Activity::add(1, $project->id, $issue->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));
     /* Return success and issue object */
     return array('success' => true, 'issue' => $issue);
 }
Exemple #5
0
    /**
     * Create a new issue
     *
     * @param  array    $input
     * @param  \Project  $project
     * @return Issue
     */
    public static function create_issue($input, $project)
    {
        $rules = array('title' => 'required|max:200', 'body' => 'required');
        $validator = \Validator::make($input, $rules);
        if ($validator->invalid()) {
            return array('success' => false, 'errors' => $validator);
        }
        $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'title' => $input['title'], 'body' => $input['body']);
        if (\Auth::user()->permission('issue-modify')) {
            $fill['assigned_to'] = $input['assigned_to'];
        }
        $issue = new static();
        $issue->fill($fill);
        $issue->save();
        /* Add to user's activity log */
        \User\Activity::add(1, $project->id, $issue->id);
        /* Add attachments to issue */
        $query = '
			UPDATE `projects_issues_attachments`
			SET issue_id = ?
			WHERE upload_token = ? AND uploaded_by = ?';
        \DB::query($query, array($issue->id, $input['token'], \Auth::user()->id));
        /* Return success and issue object */
        return array('success' => true, 'issue' => $issue);
    }
Exemple #6
0
 /**
  * Create a new issue
  *
  * @param  array    $input
  * @param  \Project  $project
  * @return Issue
  */
 public static function create_issue($input, $project)
 {
     $rules = array('title' => 'required|max:200', 'body' => 'required');
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'title' => $input['title'], 'body' => $input['body'], 'status' => 1);
     if (\Auth::user()->permission('issue-modify')) {
         $fill['assigned_to'] = $input['assigned_to'];
     }
     $issue = new static();
     $issue->fill($fill);
     $issue->save();
     /* Create tags */
     $issue->set_tags('create');
     /* Add to user's activity log */
     \User\Activity::add(1, $project->id, $issue->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));
     /* Notify the person being assigned to. */
     /* If no one is assigned, notify all users who are assigned to this project and who have permission to modify the issue. */
     /* Do not notify the person creating the issue. */
     if ($issue->assigned_to) {
         if ($issue->assigned_to != \Auth::user()->id) {
             $project = \Project::current();
             //$subject = 'New issue "' . $issue->title . '" was submitted to "' . $project->name . '" project and assigned to you';
             $subject = sprintf(__('email.assignment'), $issue->title, $project->name);
             $text = \View::make('email.new_assigned_issue', array('project' => $project, 'issue' => $issue));
             \Mail::send_email($text, $issue->assigned->email, $subject);
         }
     } else {
         $project = \Project::current();
         foreach ($project->users()->get() as $row) {
             if ($row->id != \Auth::user()->id && $row->permission('project-modify')) {
                 //$subject = 'New issue "' . $issue->title . '" was submitted to "' . $project->name . '" project';
                 $subject = sprintf(__('email.new_issue'), $issue->title, $project->name);
                 $text = \View::make('email.new_issue', array('project' => $project, 'issue' => $issue));
                 \Mail::send_email($text, $row->email, $subject);
             }
         }
     }
     /* Return success and issue object */
     return array('success' => true, 'issue' => $issue);
 }