/** * * @SWG\Api( * path="/team/{team_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 team 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="team_uuid", * description="The UUID of the team that this activity is attached to. If not provided, will use the current active team", * paramType="path", * required=false, * type="string" * ), * ) * ) */ public function team_get($uuid = '') { if ($uuid) { $team = validate_team_uuid($uuid); } else { $team = $this->Team->load(get_team_id()); } validate_team_read($team->id); $activities = $this->Activity->get_for_team($team->id, $this->get('page', TRUE), $this->get('limit', TRUE)); $this->response($this->decorate_objects($activities)); }
/** * * @SWG\Api( * path="/team/{uuid}/invite", * description="API for team actions", * @SWG\Operation( * method="POST", * type="Response", * summary="Invite a user to a team. You can only invite people who are not already on your team.", * @SWG\Parameter( * name="uuid", * description="UUID of the team", * paramType="path", * required=true, * type="string" * ), * @SWG\Parameter( * name="email", * description="The email address of the user you would like to invite", * paramType="form", * required=true, * type="string" * ) * ) * ) * * Invites a user to a team * @param string $uuid */ private function team_invite($uuid = '') { $this->load->library('form_validation'); $this->load->helper('notification'); /* Only the team owner can invite people */ $team = validate_team_uuid($uuid, true); validate_team_read($team->id); /* Validate that they are the team owner */ validate_team_owner($team->id, get_user_id()); /* Validate that they have a valid subscription and can add a team */ validate_user_add(get_user_id()); $this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|valid_email'); if ($this->form_validation->run() == FALSE) { json_error('There was a problem with your submission: ' . validation_errors(' ', ' ')); } else { $email = $this->post('email', TRUE); /* Look to see if there is an existing invite and resend it */ $invite = $this->Team_Invite->get_for_email_team($email, $team->id); $invite_id = 0; if ($invite && !$invite->user_id) { $invite_id = $invite->id; $key = $invite->key; } else { $key = random_string('unique'); $invite_id = $this->Team_Invite->add(array('email' => $email, 'team_id' => $team->id, 'key' => $key)); } notify_team_invite($invite_id, get_user_id()); json_success("User invited successfully", array('invite_id' => $invite_id, 'email' => $email, 'key' => $key)); } }