Example #1
0
 public static function display()
 {
     if (!is_numeric($_GET['id'])) {
         cc_redirect(Admin::link('users'));
     }
     if ($_POST['cc_form'] == 'edit-group') {
         $id = $_GET['id'];
         $previous = (array) unserialize(urldecode($_POST['previous']));
         $group = $_POST['group'];
         $permissions = (array) $_POST['permissions'];
         $new = array_merge($previous, $permissions);
         foreach ($new as $k => $v) {
             if ($v == "1") {
                 $new[$k] = true;
             }
             if (!array_key_exists($k, $permissions)) {
                 $new[$k] = false;
             }
         }
         if (DB::update('users', array('name', 'data'), array($group, serialize(filter('admin_edit_group_data', array('permissions' => $new)))), array('users_id = ?', $id))) {
             $message = Message::success(__('admin', 'group-information-updated'));
         } else {
             $message = Message::error(__('admin', 'database-error'));
         }
     }
     $p = Permissions::getAll();
     $g = new Group((int) $_GET['id']);
     $p_form = new Form('');
     $p_form->setCC_Form('edit-group');
     $p_form->startFieldset(__('admin', 'group-information'));
     $p_form->addInput(__('admin', 'group-name'), 'text', 'group', $g->getName());
     $p_form->endFieldset();
     $p_form->addHTML(sprintf("<h3>%s</h3>", __('admin', 'permissions')));
     $p_table = new Table('permissions');
     $p_table->addHeader(array('Name', 'Allowed'));
     foreach ($p as $k => $v) {
         $previous[$v['name']] = $g->isAllowed($v['name']);
         $p_table->addRow(array(__('permissions', $v['name']), sprintf('<input type="checkbox" name="permissions[%s]"%svalue="1"/>', $v['name'], $g->isAllowed($v['name']) ? ' checked="checked"' : '')));
     }
     $p_form->addHidden('previous', urlencode(serialize($previous)));
     $p_form->addHTML($p_table->html());
     $p_form->addSubmit('', 'save-permissions', __('admin', 'save-changes'));
     return array(sprintf('%s: %s', __('admin', 'edit-group'), $g->getName()), $message . $p_form->html());
 }
Example #2
0
 public static function display()
 {
     $users = Database::select('users', '*', array('type = ?', 'user'), array('name', 'ASC'));
     $groups = Database::select('users', '*', array('type = ?', 'group'), array('name', 'ASC'));
     $groups_array = array();
     $groups_table = new Table("groups", array('', 'actions'));
     $groups_table->addHeader(array(__('admin', "group-name"), __('admin', "actions")));
     foreach ($groups->fetchAll(PDO::FETCH_ASSOC) as $key => $value) {
         $group_array[$value['users_id']] = $value['name'];
         $groups_table->addRow(array($value['name'], icon('group_edit', Admin::link('users/edit-group', array('id' => $value['users_id'])), false, array('rel' => 'tooltip', 'title' => StringUtils::escapeForHTMLAttr(sprintf(__('admin', 'edit-specific'), $value['name'])))) . icon('group_delete', Admin::link('users/delete', array('id' => $value['users_id'], 'type' => 'group')), false, array('class' => 'delete-link', 'rel' => 'tooltip', 'title' => StringUtils::escapeForHTMLAttr(sprintf(__('admin', 'delete-specific'), $value['name']))))));
     }
     $groups_table = $groups_table->html();
     $users_table = new Table("users", array('', '', 'actions'));
     $users_table->addHeader(array(__('admin', 'name'), __('admin', 'group'), __('admin', 'actions')));
     foreach ($users->fetchAll(PDO::FETCH_ASSOC) as $key => $value) {
         $users_table->addRow(array($value['name'], $group_array[$value['group']], icon('user_edit', Admin::link('users/edit-user', array('id' => $value['users_id'])), false, array('rel' => 'tooltip', 'title' => StringUtils::escapeForHTMLAttr(sprintf(__('admin', 'edit-specific'), $value['name'])))) . icon('user_delete', Admin::link('users/delete', array('id' => $value['users_id'], 'type' => 'user')), false, array('class' => 'delete-link', 'rel' => 'tooltip', 'title' => StringUtils::escapeForHTMLAttr(sprintf(__('admin', 'delete-specific'), $value['name']))))));
     }
     $r = "<h3>" . __('admin', 'users') . "</h3>" . $users_table->html() . "<h3>" . __('admin', 'groups') . "</h3>" . $groups_table;
     return array(__('admin', 'user-management'), $r);
 }
Example #3
0
$event_view->addClass('table-bordered');
$event_view->setIndent('        ');
$event_view->sort(true);
$event_view->pager(true);
$event_view->sticky(true);
$thead = array();
if ($user->inGroup(1)) {
    $thead['selectAll'] = Table::addTHeadCell('<input type="checkbox" id="selectAll" />', false);
}
$thead['ID'] = Table::addTHeadCell('ID');
$thead['Name'] = Table::addTHeadCell('Time');
$thead['Username'] = Table::addTHeadCell('User');
$thead['Email'] = Table::addTHeadCell('<abbr title="Client IP Address">IP</abbr>');
$thead['En'] = Table::addTHeadCell('<abbr title="Requested URI">URI</abbr>');
$thead['Act'] = Table::addTHeadCell('Event');
$event_view->addHeader($thead);
$event_query = $mySQL['r']->prepare("SELECT `id`, `time`,`uri`,`user_id`,`user_ip`,`event` FROM `evt_log` ORDER BY `time` DESC LIMIT ?, ?");
$event_query->bind_param('ii', $_GET['s'], $_GET['n']);
$event_query->bind_result($event_id, $time, $uri, $user_id, $user_ip, $event);
$event_query->execute();
$event_query->store_result();
$user_id = '';
$user_query = $mySQL['r']->prepare("SELECT `name` FROM `core_users` WHERE `id`=?");
$user_query->bind_param('i', $user_id);
while ($event_query->fetch()) {
    $user_query->bind_result($username);
    $user_query->execute();
    $user_query->store_result();
    $user_query->fetch();
    $user_query->free_result();
    if ($user->inGroup(1)) {
 function format($type = 'all')
 {
     switch ($type) {
         case 'all':
             $variables['meetID'] = $this->ID;
             $variables['meetTitle'] = $this->title;
             $variables['meetDate'] = $this->date['long'];
             $variables['meetEntryDate'] = $this->date['entry'];
             // Parse Info template
             $info = '';
             $this->parent->parent->debug($this::name_space . ': Parsing info template...');
             if ($this->location !== false) {
                 $variables['meetLocationID'] = $this->location->ID;
                 $variables['meetLocationName'] = $this->location->name;
                 $variables['meetLocationCity'] = $this->location->address['city'];
                 if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-info.htm')) {
                     $info = $text;
                 }
             } else {
                 if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-info_noLoc.htm')) {
                     $info = $text;
                 }
             }
             // Parse Notes template
             $notes = '';
             if ($this->show['notes'] == true) {
                 $this->parent->parent->debug($this::name_space . ': Parsing notes template...');
                 foreach ($this->notes as $type => $content) {
                     if ($content != '') {
                         $variables['noteType'] = ucfirst($type);
                         $variables['noteContent'] = $content;
                         if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-note.htm')) {
                             $notes .= $text;
                         }
                     }
                 }
                 unset($variables['noteType'], $variables['noteContent']);
             }
             $docs = '';
             // Parse results service template
             $res = '';
             if ($this->res['enable'] == true && $this->res['text'] != '') {
                 $this->parent->parent->debug($this::name_space . ': Parsing results service template...');
                 $variables['resServText'] = $this->res['text'];
                 $variables['resServMeet'] = $this->res['meet'];
                 $variables['resServSeries'] = $this->res['series'];
                 $variables['resServer'] = $this->parent->parent->config->getOption('comp_resServer');
                 if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-resServ.htm')) {
                     $res = $text;
                 }
             }
             // Parse schedule template
             $schedule = $sessions = '';
             if ($this->show['schedule'] == true) {
                 $defSessionTable = new Table($this->parent, 'schedule');
                 $defSessionTable->setIndent(16);
                 $defSessionTable->addClass('table-striped');
                 $defSessionTable->addClass('table-bordered');
                 $defSessionTable->addClass('table-condensed');
                 $defSessionTable->addClass('table-hover');
                 $defSessionTable->sort(true);
                 $defSessionTable->pager(false);
                 $defSessionTable->addHeader(array(Table::addTHeadCell('Event #'), Table::addTHeadCell('Gender'), Table::addTHeadCell('Age Group'), Table::addTHeadCell('Distance'), Table::addTHeadCell('Stroke'), Table::addTHeadCell('Round')));
                 $this->parent->parent->debug($this::name_space . ': Parsing event schedule...');
                 foreach ($this->data['S'] as $sNum => $session) {
                     $sessionTable = clone $defSessionTable;
                     $sessionTable->setID('m_' . $this->ID . '_sch_s_' . $sNum);
                     // Parse session times template
                     $sessionTimes = $this->parent->getPlugin('table', array('m_' . $this->ID . '_time_s_' . $sNum));
                     $sessionTimes->setIndent(16);
                     $sessionTimes->addClass('table-condensed');
                     $this->parent->parent->debug($this::name_space . ': Parsing session times...');
                     $cols = array();
                     foreach ($session['t'] as $type => $time) {
                         $type = $this->options['times'][$type];
                         $cols[] = Table::addCell('<b>' . $type . '</b>');
                         $cols[] = Table::addCell($time);
                     }
                     $sessionTimes->addRow($cols);
                     $sessionTimes->build();
                     $sessionTimes = $sessionTimes->getTable();
                     unset($variables['type'], $variables['time'], $text);
                     // Parse event template
                     $this->parent->parent->debug($this::name_space . ': Parsing events template...');
                     foreach ($session['E'] as $event) {
                         $eventNumber = $event['prefix'] == 1 ? $sNum . $event['num'] : $event['num'];
                         $event = $this->parseEvent($event, true);
                         $sessionTable->addRow(array(Table::addCell($eventNumber), Table::addCell($event['gender']), Table::addCell($event['age']), Table::addCell($event['distance']), Table::addCell($event['stroke']), Table::addCell($event['round'])));
                     }
                     $sessionTable->build();
                     // Parse session template
                     $variables['sessionNumber'] = $session['number'];
                     $variables['sessionDate'] = $session['date'];
                     $variables['sessionTimes'] = $sessionTimes;
                     $variables['events'] = $sessionTable->getTable();
                     if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-session.htm')) {
                         $sessions .= $text;
                     }
                 }
                 // End Session foreach
                 unset($variables['sessionNumber'], $variables['sessionDate'], $variables['sessionTimes'], $sessionTable);
                 $this->parent->parent->debug($this::name_space . ': Parsing schedule template...');
                 $variables['sessions'] = $sessions;
                 if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp-schedule.htm')) {
                     $schedule = $text;
                 }
             }
             $accordion = $this->parent->getPlugin('accordion');
             $accordion->setID('acc_' . $this->ID);
             $accordion->addPage('_info', 'Information', $info);
             if ($res != '') {
                 $accordion->addPage('_results', 'Results Service', $res);
             }
             if ($notes != '') {
                 $accordion->addPage('_notes', 'Notes', $notes);
             }
             if ($docs != '') {
                 $accordion->addPage('_documents', 'Documents', $docs);
             }
             if ($schedule != '') {
                 $accordion->addPage('_schedule', 'Schedule', $schedule);
             }
             $accordion->setOpen(0);
             $accordion->create();
             $variables['meet'] = $accordion->getAccordion();
             if ($text = $this->parseTemplate($variables, dirname(__FILE__) . '/templates/full_comp.htm')) {
                 return $text;
             }
             break;
     }
 }