/** * Post a comment to a issue * * @return Redirect */ public function post_index() { if (!Input::get('comment')) { return Redirect::to(Project\Issue::current()->to() . '#new-comment')->with('notice-error', 'You did not put in a comment!'); } $comment = \Project\Issue\Comment::create_comment(Input::all(), Project::current(), Project\Issue::current()); return Redirect::to(Project\Issue::current()->to() . '#comment' . $comment->id)->with('notice', 'Your comment has been added!'); }
/** * Edit a issue * * @return View */ public function get_edit() { Asset::add('tag-it-js', '/app/assets/js/tag-it.min.js', array('jquery', 'jquery-ui')); Asset::add('tag-it-css-base', '/app/assets/css/jquery.tagit.css'); Asset::add('tag-it-css-zendesk', '/app/assets/css/tagit.ui-zendesk.css'); /* Get tags as string */ $issue_tags = ''; foreach (Project\Issue::current()->tags as $tag) { $issue_tags .= (!empty($issue_tags) ? ',' : '') . $tag->tag; } return $this->layout->nest('content', 'project.issue.edit', array('issue' => Project\Issue::current(), 'issue_tags' => $issue_tags, 'project' => Project::current())); }
/** * Check to see if current user has permission to see project * * @param int $project_id * @return bool */ public function project_permission($project_id = null) { if (is_null($project_id)) { $project_id = Project::current()->id; } if ($this->permission('project-all')) { return true; } if (Project\User::check_assign($this->id, $project_id)) { return true; } return false; }
public function post_edit() { /* Delete the project */ if (Input::get('delete')) { Project::delete_project(Project::current()); return Redirect::to('projects')->with('notice', __('tinyissue.project_has_been_deleted')); } /* Update the project */ $update = Project::update_project(Input::all(), Project::current()); if ($update['success']) { return Redirect::to(Project::current()->to('edit'))->with('notice', __('tinyissue.project_has_been_updated')); } return Redirect::to(Project::current()->to('edit'))->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors')); }
public function post_edit() { /* Delete the project */ if (Input::get('delete')) { Project::delete_project(Project::current()); return Redirect::to('projects')->with('notice', 'The project has been deleted.'); } /* Update the project */ $update = Project::update_project(Input::all(), Project::current()); if ($update['success']) { return Redirect::to(Project::current()->to('edit'))->with('notice', 'Project has been updated!'); } return Redirect::to(Project::current()->to('edit'))->with_errors($update['errors'])->with('notice-error', 'Whoops, we have some errors below.'); }
/** * 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; }
<td> <input id="upload" type="file" name="file_upload" /> <ul id="uploaded-attachments"></ul> </td> </tr> <tr> <th></th> <td><input type="submit" value="<?php echo __('tinyissue.create_issue'); ?> " class="button primary" /></td> </tr> </table> <?php echo Form::hidden('session', Crypter::encrypt(Auth::user()->id)); ?> <?php echo Form::hidden('project_id', Project::current()->id); ?> <?php echo Form::hidden('token', md5(Project::current()->id . time() . \Auth::user()->id . rand(1, 100))); ?> <?php echo Form::token(); ?> </form> </div>
?> <a href="javascript:void(0);" onclick="remove_project_user(<?php echo $row->id; ?> , <?php echo Project::current()->id; ?> );" class="delete">Remove</a> <?php } ?> <?php echo $row->firstname . ' ' . $row->lastname; ?> </li> <?php } ?> </ul> <?php if (Auth::user()->permission('project-modify')) { ?> <input type="text" id="add-user-project" placeholder="Assign a user" onmouseover="init_sidebar_autocomplete(<?php echo Project::current()->id; ?> );" /> <?php }
Session::put('return', URI::current()); return Redirect::to('login'); } }); Route::filter('ajax', function () { if (!Request::ajax()) { return Response::error('404'); } }); Route::filter('project', function () { // find project id from issue object if (Request::route()->parameters[0] == 0) { return; } Project::load_project(Request::route()->parameters[0]); if (!Project::current()) { return Response::error('404'); } }); Route::filter('issue', function () { Project\Issue::load_issue(Request::route()->parameters[1]); if (!Project\Issue::current()) { return Response::error('404'); } // load project if (Request::route()->parameters[0] == 0) { Request::route()->parameters = array(Project\Issue::current()->project_id, Project\Issue::current()->id); Project::load_project(Request::route()->parameters[0]); } }); Route::filter('permission', function ($permission) {
/** * 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); }
?> <div class="dropdown"> <ul> <li class="unassigned"><a href="javascript:void(0);" onclick="issue_assign_change(0, <?php echo Project\Issue::current()->id; ?> );" class="user0<?php echo !Project\Issue::current()->assigned ? ' assigned' : ''; ?> "><?php echo __('tinyissue.no_one'); ?> </a></li> <?php foreach (Project::current()->users()->get() as $row) { ?> <li><a href="javascript:void(0);" onclick="issue_assign_change(<?php echo $row->id; ?> , <?php echo Project\Issue::current()->id; ?> );" class="user<?php echo $row->id; echo Project\Issue::current()->assigned && $row->id == Project\Issue::current()->assigned->id ? ' assigned' : ''; ?> "><?php echo $row->firstname . ' ' . $row->lastname; ?> </a></li>
> <a href="<?php echo Project::current()->to('issues'); ?> ?tags=status:closed"> <?php echo $closed_count == 1 ? '1 ' . __('tinyissue.closed_issue') : $closed_count . ' ' . __('tinyissue.closed_issues'); ?> </a> </li> <li <?php echo $active == 'assigned' ? 'class="active"' : ''; ?> > <a href="<?php echo Project::current()->to('issues'); ?> ?tags=status:open&assigned_to=<?php echo Auth::user()->id; ?> "> <?php echo $assigned_count == 1 ? '1 ' . __('tinyissue.issue_assigned_to_you') : $assigned_count . ' ' . __('tinyissue.issues_assigned_to_you'); ?> </a> </li> </ul> <div class="inside-tabs"> <?php echo $page;
> <a href="<?php echo Project::current()->to('issues'); ?> ?status=0"> <?php echo $closed_count == 1 ? '1 ' . __('tinyissue.closed_issue') : $closed_count . ' ' . __('tinyissue.closed_issues'); ?> </a> </li> <li <?php echo $active == 'assigned' ? 'class="active"' : ''; ?> > <a href="<?php echo Project::current()->to('assigned'); ?> ?status=1"> <?php echo $assigned_count == 1 ? '1 ' . __('tinyissue.issue_assigned_to_you') : $assigned_count . ' ' . __('tinyissue.issues_assigned_to_you'); ?> </a> </li> </ul> <div class="inside-tabs"> <?php echo $page; ?> </div>
> <a href="<?php echo Project::current()->to('issues'); ?> ?status=0"> <?php echo $closed_count == 1 ? '1 Closed Issue' : $closed_count . ' Closed Issues'; ?> </a> </li> <li <?php echo $active == 'assigned' ? 'class="active"' : ''; ?> > <a href="<?php echo Project::current()->to('issues/assigned'); ?> ?status=1"> <?php echo $assigned_count == 1 ? '1 Issue Assigned to you' : $assigned_count . ' Issues assigned to you'; ?> </a> </li> </ul> <div class="inside-tabs"> <?php echo $page; ?> </div>
/** * Edit a issue * * @return View */ public function get_edit() { return $this->layout->nest('content', 'project.issue.edit', array('issue' => Project\Issue::current(), 'project' => Project::current())); }
<table class="form" style="width: 80%;"> <tr> <th style="width: 10%;">Name</th> <td><input type="text" style="width: 98%;" name="name" value="<?php echo Input::old('name', Project::current()->name); ?> " /></td> </tr> <tr> <th>Status</th> <td><?php echo Form::select('status', array(1 => 'Open', 0 => 'Archived'), Project::current()->status); ?> </td> </tr> <tr> <th></th> <td> <input type="submit" value="Update" /> <input type="submit" name="delete" value="Delete <?php echo Project::current()->name; ?> " onclick="return confirm('Are you sure you want to delete this project? There is no going back!');" /> </td> </tr> </table> </form> </div>
public function post_edit() { /* Delete the project */ if (Input::get('delete')) { Project::delete_project(Project::current()); return Redirect::to('projects')->with('notice', __('tinyissue.project_has_been_deleted')); } $image = ''; if (\Laravel\Input::has_file('image')) { $img = \Laravel\Input::file('image'); if ($img['size'] > 100000) { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_sizes_errors')); } $arr_size = getimagesize($img['tmp_name']); if ($arr_size[0] > 200 && $arr_size[1] > 200) { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_size_errors')); } $destination = "../uploads/project/"; $extensions = array('image/png', 'image/jpg', 'image/jpeg'); if (in_array($img['type'], $extensions)) { $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']); \Laravel\Input::upload('image', $destination, $name); $image = 'uploads/project/' . $name; } else { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_type_errors')); } } /* Update the project */ $update = Project::update_project(Input::all(), Project::current(), $image); if ($update['success']) { return Redirect::to(Project::current()->to('edit'))->with('notice', __('tinyissue.project_has_been_updated')); } return Redirect::to(Project::current()->to('edit'))->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors')); }