function index_get() { $requested_data = $this->get("filter"); $filters = $requested_data['filters']; $limit = $this->get('limit') ? $this->get('limit') : 50; $offset = $this->get('offset') ? $this->get('offset') : null; $users = new User(null, $this->entity); $users->limit($limit, $offset); if (isset($filters)) { foreach ($filters as $f) { $users->where($f['field'], $f['value']); } } $users->get_iterated(); foreach ($users as $user) { $data[] = array('id' => intval($user->id), 'username' => $user->username, 'password' => $user->password, 'status' => boolval($user->status), 'created_at' => $user->created_at, 'updated_at' => $user->updated_at); } $users->flush_cache(); if (isset($filters)) { foreach ($filters as $f) { $users->where($f['field'], $f['value']); } } $users->get_iterated(); if ($users->result_count() > 0) { $this->response(array('results' => $data, 'count' => $users->result_count()), 200); } else { $this->response(array('results' => $data, 'count' => $users->result_count()), 200); } }
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); }
function make_team_leader_username($team_id) { if (!$this->tank_auth->is_team_leader($team_id) && !$this->tank_auth->is_allowed()) return false; $team = new Team($team_id); $user = new User(); $user->where('username', $this->input->post('username'))->get(); if ($user->result_count() != 1) { flash_notice('error', _('User not found.')); redirect('/admin/members/teams/' . $team->stub); } $this->viewdata["function_title"] = "Making team leader..."; $member = new Membership(); $member->make_team_leader($team_id, $user->id); flash_notice('notice', _('You have made the user a team leader.')); redirect('/admin/members/teams/' . $team->stub); }