<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } ?> <div class="table" style="padding-bottom: 15px"> <?php if (isset($form_title)) { echo '<h3 style="float: left">' . $form_title . '</h3>'; } ?> <span style="float: right; padding: 5px"> <div class="smartsearch"> <?php echo form_open(); echo form_input(array('name' => 'search', 'placeholder' => _('To search, write and hit enter'))); echo form_close(); ?> </div> </span> <hr class="clear"/> <div style="padding-right: 10px"> <?php echo buttoner(); echo $table; ?> </div> </div>
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); if ($ask_upgrade) { echo _("There's a newer version of the database available. Just update it by clicking on the update button."); echo '<br/>'; echo sprintf(_("In case you're using a very large installation of FoOlSlide, to avoid timeouts while updating the database, you can use the command line, and enter this: %s"), '<br/><b><code>'.$CLI_code.'</code></b>'); echo '<br/><br/>'; echo buttoner(array( 'text' => _("Upgrade"), 'href' => site_url('/admin/database/do_upgrade'), 'plug' => _("Do you really want to upgrade your database?") )); }
function teams($stub = "") { if ($stub == "") { $this->viewdata["function_title"] = "Team list"; $teams = new Team(); $teams->order_by('name', 'ASC')->get_iterated(); $rows = array(); foreach ($teams as $team) { $rows[] = array('title' => '<a href="' . site_url('admin/members/teams/' . $team->stub) . '">' . $team->name . '</a>'); } $data['list'] = lister($rows); $this->viewdata["main_content_view"] = $this->load->view('admin/members/users', $data, TRUE); $this->load->view("admin/default", $this->viewdata); } else { $team = new Team(); $team->where('stub', $stub)->get(); if ($this->tank_auth->is_admin() || $this->tank_auth->is_group('mod')) $can_edit = true; else $can_edit = false; if ($this->tank_auth->is_team_leader($team->id) && !$can_edit) $can_edit_limited = true; else $can_edit_limited = false; if (($post = $this->input->post()) && ($can_edit || $can_edit_limited)) { $team = new Team(); $team->where('stub', $stub)->get(); $post["id"] = $team->id; if ($can_edit_limited) { unset($post['name']); } $team->update_team($post, TRUE); set_notice('notice', _('Saved.')); } $this->viewdata["function_title"] = "Team"; $this->viewdata["extra_title"][] = $team->name; if ($can_edit_limited) $team->validation['name']['disabled'] = 'true'; $result = ormer($team); $result = tabler($result, TRUE, ($can_edit || $can_edit_limited)); $data['table'] = $result; $data['team'] = $team; $members = new Membership(); $users = $members->get_members($team->id); $users_arr = array(); foreach ($users->all as $key => $item) { $users_arr[$key][] = '<a href="' . site_url('/admin/members/member/' . $item->id) . '">' . $item->username . '</a>'; if ($can_edit) $users_arr[$key][] = $item->email; $users_arr[$key][] = $item->last_login; $users_arr[$key][] = ($item->is_leader) ? _('Leader') : _('Member'); if ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed()) { $buttoner = array(); $buttoner = array( 'text' => _("Remove member"), 'href' => site_url('/admin/members/reject_application/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to remove this team member?') ); } $users_arr[$key][] = (isset($buttoner) && !empty($buttoner)) ? buttoner($buttoner) : ''; if (!$item->is_leader && ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed())) { $buttoner = array(); $buttoner = array( 'text' => _("Make leader"), 'href' => site_url('/admin/members/make_team_leader/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to make this user a team leader?') ); } if ($item->is_leader && ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed())) { $buttoner = array(); $buttoner = array( 'text' => _("Remove leader"), 'href' => site_url('/admin/members/remove_team_leader/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to remove this user from the team leadership?') ); } $users_arr[$key][] = (isset($buttoner) && !empty($buttoner)) ? buttoner($buttoner) : ''; } // Spawn the form for adding a team leader $data["no_leader"] = FALSE; if ($this->tank_auth->is_allowed()) $data["no_leader"] = TRUE; $data['members'] = tabler($users_arr, TRUE, FALSE); $this->viewdata["main_content_view"] = $this->load->view('admin/members/team', $data, TRUE); $this->load->view("admin/default", $this->viewdata); } }
function form_buttoner($column) { return buttoner($column); }
function teams($stub = "") { // no team selected if ($stub == "") { // set subtitle $this->viewdata["function_title"] = _('Teams'); // we can use get_iterated on teams $teams = new Team(); // support filtering via search if ($this->input->post()) { $teams->ilike('name', $this->input->post('search')); $this->viewdata['extra_title'][] = _('Searching') . " : " . $this->input->post('search'); } $teams->order_by('name', 'ASC')->get_iterated(); $rows = array(); // produce links for each team foreach ($teams as $team) { $rows[] = array('title' => '<a href="' . site_url('admin/members/teams/' . $team->stub) . '">' . $team->name . '</a>'); } // put in a list the teams $data['form_title'] = _('Teams'); $data['table'] = lister($rows); // print out $this->viewdata["main_content_view"] = $this->load->view('admin/members/users', $data, TRUE); $this->load->view("admin/default", $this->viewdata); } else { // team was selected, let's grab it and create a form for it $team = new Team(); $team->where('stub', $stub)->get(); // if the team was not found return 404 if ($team->result_count() != 1) { show_404(); } // if admin or mod allow full editing rights if ($this->tank_auth->is_allowed()) { $can_edit = true; } else { $can_edit = false; } // if it's a team leader, but not admin or mod, allow him to change data but not the team name if ($this->tank_auth->is_team_leader($team->id) && !$can_edit) { $can_edit_limited = true; } else { $can_edit_limited = false; } // if allowed in any way to edit, if (($post = $this->input->post()) && ($can_edit || $can_edit_limited)) { $post["id"] = $team->id; // save the stub in case it's changed $old_stub = $team->stub; // don't allow editing of name for team leaders if ($can_edit_limited) { unset($post['name']); } // send the data to database $team->update_team($post); // green box to tell data is saved set_notice('notice', _('Saved.')); if ($team->stub != $old_stub) { flash_notice('notice', _('Saved.')); redirect('admin/members/teams/' . $team->stub); } } // subtitle $this->viewdata["function_title"] = '<a href="' . site_url("admin/members/teams") . '">' . _('Teams') . '</a>'; // subsubtitle! $this->viewdata["extra_title"][] = $team->name; // gray out the name field for team leaders by editing directly the validation array if ($can_edit_limited) { $team->validation['name']['disabled'] = 'true'; } // convert the team information to an array $result = ormer($team); // convert the array to a form $result = tabler($result, TRUE, $can_edit || $can_edit_limited); $data['table'] = $result; $data['team'] = $team; // get the team's members $members = new Membership(); $users = $members->get_members($team->id); // the team members' array needs lots of buttons and links $users_arr = array(); foreach ($users->all as $key => $item) { $users_arr[$key][] = '<a href="' . site_url('/admin/members/member/' . $item->id) . '">' . $item->username . '</a>'; // show the email only to admins and mods if ($can_edit) { $users_arr[$key][] = $item->email; } $users_arr[$key][] = $item->last_login; // leader of normal member? $users_arr[$key][] = $item->is_leader ? _('Leader') : _('Member'); if ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed()) { $buttoner = array(); $buttoner = array('text' => _("Remove member"), 'href' => site_url('/admin/members/reject_application/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to remove this team member?')); } // add button to array or stay silent if there's no button $users_arr[$key]['action'] = isset($buttoner) && !empty($buttoner) ? buttoner($buttoner) : ''; if (!$item->is_leader && ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed())) { $buttoner = array(); $buttoner = array('text' => _("Make leader"), 'href' => site_url('/admin/members/make_team_leader/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to make this user a team leader?')); } if ($item->is_leader && ($this->tank_auth->is_team_leader($team->id) || $this->tank_auth->is_allowed())) { $buttoner = array(); $buttoner = array('text' => _("Remove leader"), 'href' => site_url('/admin/members/remove_team_leader/' . $team->id . '/' . $item->id), 'plug' => _('Do you want to remove this user from the team leadership?')); } // add button to array or stay silent if there's no button $users_arr[$key]['action'] .= isset($buttoner) && !empty($buttoner) ? buttoner($buttoner) : ''; } // Spawn the form for adding a team leader $data["no_leader"] = FALSE; if ($this->tank_auth->is_allowed()) { $data["no_leader"] = TRUE; } // make a form out of the array of members $data['members'] = tabler($users_arr, TRUE, FALSE); // print out $this->viewdata["main_content_view"] = $this->load->view('admin/members/team', $data, TRUE); $this->load->view("admin/default", $this->viewdata); } }