/** * Allows a team leader or user to accept applications * * @author Woxxy */ function _apply() { $this->form_validation->set_rules('team_name', _('Team name'), 'required|trim|xss_clean'); if ($this->form_validation->run()) { $team = new Team(); $team->where('name', $this->form_validation->set_value('team_name'))->get(); if ($team->result_count() != 1) { return _("Team does not exist"); } $member = new Membership(); if (!$member->apply($team->id)) { return show_404(); } return TRUE; } }
function apply_team($team_id) { if (!isAjax()) { return false; } $this->viewdata["function_title"] = "Applying to team..."; $team = new Team($team_id); if ($team->result_count() != 1) return false; $member = new Membership(); $member->apply($team->id, $this->tank_auth->get_user_id()); flash_notice('notice', _('You have applied for membership in this team. Come later to check the status of your application.')); echo json_encode(array('href' => site_url('/admin/members/teams/' . $team->stub))); }