/**
  * Display the results of a user search
  * @return string
  */
 function userSearchResults()
 {
     global $DB, $Controller;
     if ($_REQUEST['keyword']) {
         $results = array_merge($DB->asList($DB->userinfo->search($_REQUEST['keyword'], 'val', 'id')), $DB->asList($DB->users->like($_REQUEST['keyword'], 'username', 'id')));
         if (count($results) == 0) {
             return __('No results');
         } else {
             $results = $Controller->get(array_unique($results));
             propsort($results, 'Name');
             $r = '';
             $r .= '<h4>' . __('Search results') . '</h4>';
             $r .= '<ul class="flul">';
             $i = 0;
             foreach ($results as $user) {
                 if ($user) {
                     $r .= '<li class="' . ($i % 2 ? 'even' : 'odd') . '">' . icon('small/add', __('Add privileges for this user'), url(array('nP' => $user->ID), array('with', 'edit', 'referrer', 'filter', 'popup', 'keyword'))) . $user . '</li>';
                     $i++;
                 }
             }
             $r .= '</ul>';
             return $r;
         }
     } else {
         return "";
     }
 }
Example #2
0
 function attendanceList()
 {
     global $Controller;
     $attending = $this->getAttendance();
     $objects = $Controller->get(array_keys($attending), OVERRIDE);
     $groupsort = array();
     $nogroup = $attending;
     global $CONFIG, $Controller;
     if (!is_array($ig = $CONFIG->matrikel->interesting_groups)) {
         $ig = array();
     }
     $groups = $Controller->get($ig);
     foreach ($attending as $id => $a) {
         foreach ($ig as $gid) {
             if ($groups[$gid]->isMember($id)) {
                 $groupsort[$groups[$gid]->Name] = $a;
                 unset($nogroup[$id]);
                 break;
             }
         }
     }
     foreach ($groupsort as &$group) {
         propsort($group, 'Name');
     }
     ksort($groupsort);
     propsort($nogroup, 'Name');
     $r = array(new Tableheader(__('Name'), __('Group'), __('Attending'), __('Comment')));
     //FIXME: Stämma
     foreach ($groupsort as $groupname => $group) {
         foreach ($group as $user) {
             $u = $object[$user['attendee']];
             $r[] = new Tablerow($u->Name, $group, $user['attending'], $user['comment']);
         }
     }
     foreach ($nogroup as $user) {
         $u = $objects[$user['attendee']];
         $r[] = new Tablerow($u->Name, '', $user['attending'], $user['comment']);
     }
     return new Table($r);
 }
 function editTab()
 {
     $_REQUEST->addType('view', 'string');
     $_REQUEST->addType('lang', 'string');
     $_REQUEST->setType('ch', 'numeric');
     global $Controller, $CONFIG, $DB, $USER;
     $this->setContent('header', __('Editing user') . ': ' . $this->that);
     $form = new Form('editUser');
     /**
      * User settings
      */
     global $SITE;
     $settingsform = $this->that->settings->getFormElements('usersettings');
     /**
      * Load voluntary groups
      * @var groups
      */
     $volkeys = $DB->{'spine,metadata'}->asList(array('spine.class' => 'Group', 'metadata.field' => 'GroupType', 'metadata.value' => array('vol', 'volpre')), 'spine.id');
     $volgroups = $Controller->get($volkeys, OVERRIDE);
     propsort($volgroups, 'Name');
     /**
      * Group membership page
      */
     $groups = $this->that->groups();
     $gTypes = array('vol' => array(), 'assigned' => array());
     foreach ($groups as $group) {
         if (!$group->isMember($this->that)) {
             continue;
         }
         switch ($group->GroupType) {
             case 'vol':
             case 'volpre':
                 $gTypes['vol'][] = $group->ID;
                 break;
             default:
                 $gTypes['assigned']['g' . $group->ID] = $group;
                 break;
         }
     }
     $checked = array();
     foreach ($volgroups as $vg) {
         if (in_array($vg->ID, $gTypes['vol'])) {
             $checked[] = $vg->ID;
         }
     }
     asort($gTypes['assigned']);
     return array(@$this->that->password !== 'LDAP' ? new Formsection(__('Login information'), new Input(__('Username'), 'username', @$this->that->username), new Password(__('Password'), 'password1'), new Password(__('Password again'), 'password2')) : null, new Formsection(__('Presentation'), new HTMLField(false, 'presentation', $this->that->getContent('presentation'))), $settingsform ? new Formsection(__('User settings'), $settingsform) : null, @UInfoFields::edit($id, 'Tab'), new Formsection(__('Group membership'), new Fieldset(__('Assigned groups'), listify(arrayExtract($gTypes['assigned'], 'link', false, true))), empty($volgroups) ? null : new checkset(__('Voluntary groups'), 'volgroups', $volgroups, $checked)));
 }
 /**
  * Displays the page form member administration of a group
  * @param integer $group The group which to edit
  * @return string
  */
 private function memberTab()
 {
     global $DB, $Controller, $USER;
     $r = '';
     $volpre = $this->that->GroupType == 'volpre';
     if (!$this->that) {
         return;
     }
     $_REQUEST->setType('nGM', 'anything');
     $_REQUEST->setType('keyword', 'string');
     $_REQUEST->setType('group_action', '#(copy|reset)_members#');
     $_REQUEST->setType('gid', 'numeric');
     $_REQUEST->setType('copy_to_group', 'numeric');
     $gform = new Form('nGM', url(null, array('edit', 'with', 'adm')), false);
     $groups = $DB->{'spine,metadata'}->asList(array('spine.class' => 'Group', 'metadata.field' => 'Name', 'metadata.metameta' => $USER->settings['language'], 'spine.id!' => array_merge(array($this->that->ID), $this->that->groups(false, 1))), 'spine.id,metadata.value', false, true, 'metadata.value');
     $uform = new Form('findUser', url(null, array('edit', 'with', 'adm')), false);
     $i = 0;
     $mem = array('', '');
     $count = array(0, 0);
     $res = $DB->group_members->get(array('group' => $this->that->ID));
     while ($row = $DB->fetchAssoc($res)) {
         $o = $Controller->{$row['user']};
         ++$count[is_a($o, 'Group')];
         $mem[is_a($o, 'Group')] .= '<li class="' . ($i % 2 ? 'odd' : 'even') . '"><span class="fixed-width">' . $o . '</span><div class="tools">' . ($volpre ? icon('small/add', __('Add user to group'), url(array('add' => $row['user']), array('edit', 'with'))) : icon('small/delete', __('Remove user from group'), url(array('rem' => $row['user']), array('edit', 'with')))) . '</div></li>';
         $i++;
     }
     if ($volpre) {
         $r .= '<h1>' . __('Note!') . '</h1>' . __('Non-members are displayed for preselected groups!');
     }
     if (!empty($mem[0])) {
         $r .= '<h2>' . ($volpre ? __('Non-member users') : __('Member users')) . ' (' . $count[0] . ')' . '</h2><ul class="list">' . $mem[0] . '</ul>';
     }
     if (!empty($mem[1])) {
         $r .= '<h2>' . __('Subgroups') . ' (' . $count[1] . ')' . '</h2><ul class="list">' . $mem[1] . '</ul>';
     }
     $gp = $this->that->groups(true);
     if (!empty($gp)) {
         $r .= '<p><h3>' . __('Additionally, this group is a subgroup to the following groups: ') . '</h3>' . join(', ', $gp) . '</p>';
     }
     $group_actions = '';
     if (!empty($mem[0]) || !empty($mem[1])) {
         $available_groups = $Controller->getClass('Group');
         propsort($available_groups, 'Name');
         $group_actions = new Formsection(__('Group actions'), Form::quick(url(false, array('edit', 'with')), __('Copy members'), new Hidden('group_action', 'copy_members'), new Li(new Select(__('Copy to group'), 'copy_to_group', $available_groups, false, false, __('Choose group')))), Form::quick(url(false, array('edit', 'with')), __('Reset all memberships'), '<h3>Reset membership</h3>', new Hidden('group_action', 'reset_members')));
     }
     return array($r, new Accordion(__('Users'), $uform->collection(new Set(new Li(new Input(__('Find user'), 'keyword', $_REQUEST['keyword']), new Submit(__('Search'))))) . $this->userSearchResults($volpre), __('Groups'), $gform->collection(new Set(new Li(new Select(__('Choose group'), 'add', $groups, false, false, __('Choose group')), new Submit($volpre ? __('Remove') : __('Add')))))), $group_actions);
 }