Пример #1
0
 /**
  *
  * @SWG\Api(
  *   path="/projects/{project_uuid}/history/",
  *   description="API for project actions",
  * @SWG\Operation(
  *    method="GET",
  *    nickname="Project History",
  *    type="ProjectHistory",
  *    summary="Returns the history of a project",
  * @SWG\Parameter(
  *     name="project_uuid",
  *     description="The unique ID of the project",
  *     paramType="path",
  *     required=true,
  *     type="string"
  *     )
  *   )
  * )
  */
 private function get_project_history($uuid)
 {
     validate_team_read(get_team_id());
     $project = validate_project_uuid($uuid);
     $project_history = $this->Project_Statistic->get_project_history($project->id);
     $this->response($project_history);
 }
Пример #2
0
 /**
  *
  * @SWG\Api(
  *   path="/",
  *   description="API for meeting actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="Meeting",
  *    summary="Schedule a new meeting",
  * @SWG\Parameter(
  *     name="notes",
  *     description="Notes/Description of the meeting",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="project_uuid",
  *     description="The UUID of the project that this meeting is attached to",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="name",
  *     description="Name of the meeting",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="date",
  *     description="Date of the meeting (in the user's timezone) YYYY-MM-DD",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="time",
  *     description="Time of the meeting (in the user's timezone) 24-hour format (HH:MM)",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="attendees",
  *     description="A Comma-Separated List of UUIDs of individuals who should be invited to the meeting (Example: '123,232,443'). If this is null, all members of the project will be invited",
  *     paramType="form",
  *     required=false,
  *     type="array[string]"
  *     )
  *   )
  * )
  *
  * Creates a new meeting and attaches project members to it.
  */
 public function index_post()
 {
     $this->load->library('form_validation');
     $this->load->helper('notification');
     $this->form_validation->set_rules('notes', 'Notes', 'trim|xss_clean');
     $this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean');
     $this->form_validation->set_rules('date', 'Date', 'trim|required|xss_clean');
     $this->form_validation->set_rules('time', 'Time', 'trim|required|xss_clean');
     $this->form_validation->set_rules('attendees', 'Attendees', 'trim|required|xss_clean');
     $this->form_validation->set_rules('project_uuid', 'Project UUID', 'trim|required|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
     } else {
         $project = validate_project_uuid($this->post('project_uuid', TRUE));
         $datetime = server_datetime($this->post('date', TRUE), $this->post('time', TRUE));
         $data = array('project_id' => $project->id, 'date' => $datetime->format('Y-m-d'), 'time' => $datetime->format('H:i'), 'notes' => $this->post('notes', TRUE), 'name' => $this->post('name', TRUE), 'pin' => random_string('numeric', 7), 'moderator_pin' => random_string('numeric', 7), 'creator_id' => get_user_id(), 'moderator_id' => get_user_id());
         $meeting_id = $this->Meeting->add($data);
         /* Allow the attendees to be optional, if it isn't specified, all people on the project are invited */
         $attendees = $this->post('attendees', TRUE);
         if (!$attendees) {
             $users = $this->User->get_for_project($project->id);
             foreach ($users as $user) {
                 $existing = $this->Meeting->get_meeting_user($meeting_id, $user->id);
                 if (!$existing) {
                     $this->Meeting->add_meeting_user($meeting_id, $user->id);
                 }
             }
         } else {
             $attendees = explode(",", $attendees);
             foreach ($attendees as $attendee) {
                 $user = $this->User->load_by_uuid($attendee);
                 $existing = $this->Meeting->get_meeting_user($meeting_id, $user->id);
                 if (!$existing) {
                     $this->Meeting->add_meeting_user($meeting_id, $user->id);
                 }
             }
         }
         $meeting = $this->Meeting->load($meeting_id);
         activity_add_meeting($meeting_id);
         notify_new_meeting($meeting_id, get_user_id());
         $this->response($this->decorate_object($meeting));
     }
 }
Пример #3
0
 /**
  *
  * @SWG\Api(
  *   path="/project/{project_uuid}",
  *   description="API for activity actions",
  * @SWG\Operation(
  *    method="GET",
  *    type="array[Activity]",
  *    summary="Returns a list of the current activities that belong to the project in descending chronological order",
  *    @SWG\Parameter(
  *       name="page",
  *       description="The starting page # of the activities (defaults to 0)",
  *       paramType="query",
  *       required=false,
  *       type="integer"
  *     ),
  *    @SWG\Parameter(
  *       name="limit",
  *       description="The number of results to return per page (defaults to 20)",
  *       paramType="query",
  *       required=false,
  *       type="integer"
  *     ),
  *    @SWG\Parameter(
  *       name="project_uuid",
  *       description="The UUID of the project that this activity is attached to",
  *       paramType="path",
  *       required=true,
  *       type="string"
  *     ),
  *   )
  * )
  */
 public function project_get($uuid = '')
 {
     $project = validate_project_uuid($uuid);
     validate_team_read(get_team_id());
     $activities = $this->Activity->get_for_project($project->id, $this->get('page', TRUE), $this->get('limit', TRUE));
     $this->response($this->decorate_objects($activities));
 }
Пример #4
0
 public function project_post($project_uuid = '')
 {
     $project = validate_project_uuid($project_uuid);
     $screen = null;
     if (isset($_FILES['file'])) {
         $screen = $this->add_screen_upload($project);
     } else {
         if ($this->post('url')) {
             $screen = $this->add_screen_url($project);
         }
     }
     if (!$screen) {
         json_error('You must provide either a url or uploaded file for the screenshot.');
         exit;
     }
     if ($screen) {
         /* Add the activity item to indicate that a screen was added */
         activity_add_screen($screen->id, get_user_id());
     }
     /* Handle the download situation */
     $this->response($this->decorate_object($screen));
 }
Пример #5
0
 public function project_post($project_uuid = '')
 {
     $project = validate_project_uuid($project_uuid);
     $video = null;
     if (isset($_FILES['file'])) {
         $video = $this->add_video_upload($project);
     } else {
         if ($this->post('url')) {
             $video = $this->add_video_url($project);
         }
     }
     if (!$video) {
         json_error('You must provide either a url or uploaded file for the video.');
         exit;
     }
     /* Handle the download situation */
     $this->response($video);
 }
Пример #6
0
 /**
  *
  * @SWG\Api(
  *   path="/",
  *   description="API for message actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="Message",
  *    summary="Create a new message for the current user (user must be logged in)",
  * @SWG\Parameter(
  *     name="content",
  *     description="Content of the message",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="project_uuid",
  *     description="The UUID of the project that this message is attached to",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="parent_uuid",
  *     description="The UUID of the message that is the parent of this one (if it is a reply -- leave it null if it is a new message)",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="recipients",
  *     description="A Comma-Separated List of UUIDs of individuals who should be recipients of the message (Example: '123,232,443').  If this is null, the message will be sent to all users on the project.  This will also be ignored if there is a parent_uuid set since we will default to the parent email for recipients",
  *     paramType="form",
  *     required=false,
  *     type="array[string]"
  *     )
  *   )
  * )
  *
  * Creates a new message and attaches project members to it.
  */
 public function index_post()
 {
     /* Validate add */
     $this->load->library('form_validation');
     $this->load->helper('notification');
     $this->form_validation->set_rules('content', 'Content', 'trim|required|xss_clean');
     $this->form_validation->set_rules('project_uuid', 'Project UUID', 'trim|xss_clean');
     $this->form_validation->set_rules('parent_uuid', 'Parent UUID', 'trim|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
     } else {
         $project_uuid = $this->post('project_uuid', TRUE);
         $parent_uuid = $this->post('parent_uuid', TRUE);
         if ($project_uuid) {
             $project = validate_project_uuid($this->post('project_uuid', TRUE));
         } else {
             if ($parent_uuid) {
                 $parent_message = $this->Message->load_by_uuid($parent_uuid);
                 $project = validate_project_uuid($this->Project->get_uuid($parent_message->project_id));
             } else {
                 json_error('There as was a problem with your submission.  Either project_uuid or parent_uuid are required');
                 exit;
             }
         }
         $data = array('content' => $this->post('content', TRUE), 'project_id' => $project->id, 'sender_id' => get_user_id());
         if ($parent_message) {
             /* Prevent messages that are replies to replies so we don't have to deal with a multi-level hierarchy */
             if ($parent_message->parent_id) {
                 json_error('The parent uuid provided belongs to a reply.  You cannot reply to a reply but only to the parent message.');
             } else {
                 $data['parent_id'] = $parent_message->id;
             }
         }
         $message = $this->Message->load($this->Message->add($data));
         /* Set the recipients on the message if it doesn't have a parent */
         /* Allow the recipients to be optional, if it isn't specified, all people on the project are marked as recipients */
         if (!$message->parent_id) {
             $recipients = $this->post('recipients', TRUE);
             if (!$recipients) {
                 $users = $this->User->get_for_project($project->id);
                 foreach ($users as $user) {
                     $existing = $this->Message->get_message_user($message->id, $user->id);
                     if (!$existing) {
                         $this->Message->add_message_user($message->id, $user->id);
                     }
                 }
             } else {
                 $recipients = explode(",", $recipients);
                 foreach ($recipients as $recipient) {
                     $user = $this->User->load_by_uuid($recipient);
                     $existing = $this->Message->get_message_user($message->id, $user->id);
                     if (!$existing) {
                         $this->Message->add_message_user($message->id, $user->id);
                     }
                 }
             }
             /* This is a new message, so store the add activity */
             activity_add_message($message->id);
             notify_new_message($message->id, get_user_id());
         } else {
             /* Update the updated date on the parent message */
             $this->Message->update($message->parent_id, array('updated' => timestamp_to_mysqldatetime(now())));
             /* This is a new message, so store the add activity */
             activity_reply_message($message->id);
             notify_new_message($message->id, get_user_id(), $message->parent_id);
         }
         $this->response($this->decorate_object($message));
     }
 }