Пример #1
0
 function request($team_stub, $user_id)
 {
     $this->viewdata["navbar"] = "";
     $team = new Team();
     $team->where('stub', $team_stub)->get();
     $user = new User($user_id);
     if ($team->result_count() != 1 || $user->result_count() != 1) {
         show_404();
     }
     if ($this->input->post('action')) {
         $member = new Membership();
         if ($this->input->post('action') == 'accept') {
             if (!$member->accept_application($team->id, $user->id)) {
                 return show_404();
             }
         }
         if ($this->input->post('action') == 'reject') {
             if (!$member->reject_application($team->id, $user->id)) {
                 return show_404();
             }
         }
         redirect('/account/teams/');
     }
     $this->viewdata["function_title"] = _("Accept request");
     $data["team_name"] = $team->name;
     $data["user_name"] = $user->username;
     $data["show_accept"] = $this->tank_auth->is_team_leader($team->id);
     $this->viewdata["main_content_view"] = $this->load->view('account/profile/request', $data, TRUE);
     $this->load->view("account/default.php", $this->viewdata);
 }
Пример #2
0
	function accept_application($team_id, $user_id = NULL) {
		if (!isAjax()) {
			return false;
		}

		$this->viewdata["function_title"] = _("Accepting into team...");
		$member = new Membership();
		if (!$member->accept_application($team_id, $user_id)) {
			return FALSE;
		}
		flash_notice('notice', _('User accepted into the team.'));
		$team = new Team($team_id);
		echo json_encode(array('href' => site_url('/admin/members/teams/' . $team->stub)));
	}