/** * Display the list of lock rules */ function index_action() { $actions = new ActionsWidget(); $actions->addLink(_('Neue Sperrebene anlegen'), $this->url_for('admin/lockrules/new'), Icon::create('add', 'clickable')); $this->sidebar->addWidget($actions); if ($GLOBALS['perm']->have_perm('root')) { $list = new SelectWidget(_('Bereichsauswahl'), $this->url_for('admin/lockrules'), 'lock_rule_type'); foreach (array('sem' => _('Veranstaltung'), 'inst' => _('Einrichtung'), 'user' => _('Nutzer')) as $type => $desc) { $list->addElement(new SelectElement($type, $desc, Request::get('lock_rule_type') == $type), 'lock_rule_type-' . $type); } $this->sidebar->addWidget($list); } if ($this->lock_rule_type == 'sem') { $this->lock_rules = LockRules::getAdministrableSeminarRules($GLOBALS['user']->id); } else { $this->lock_rules = LockRule::findAllByType($this->lock_rule_type); } }
/** * returns a list of lockrules that can be applied to a course * with the given user id * * @param string $user_id id of user * @return array of LockRule objects */ public static function getAvailableSeminarRules($user_id) { $filter = create_function('$lr', 'return ' . (int) ($GLOBALS['perm']->get_perm($user_id) == 'root') . ' || (!in_array($lr->permission, array("root","admin")));'); return array_filter(LockRule::findAllByType('sem'), $filter); }
echo htmlReady($title); ?> </option> <? endforeach; ?> </select> </label> <? endif; ?> <? if ($GLOBALS['perm']->have_perm('root')): // Select lockrule to apply ?> <label> <?php echo _('Sperrebene'); ?> <select id="lock_rule" name="lock_rule"> <option value=""> </option> <? foreach (LockRule::findAllByType('inst') as $rule): ?> <option value="<?php echo $rule->getId(); ?> " <?php echo $rule->getId() == Request::option('lock_rule', $institute->lock_rule) ? 'selected' : ''; ?> > <?php echo htmlReady($rule->name); ?> </option> <? endforeach;?> </select> </label> <? endif; ?>
/** * Show all courses with more options */ public function index_action() { $this->sem_create_perm = in_array(Config::get()->SEM_CREATE_PERM, array('root', 'admin', 'dozent')) ? Config::get()->SEM_CREATE_PERM : 'dozent'; // get courses only if institutes available $this->actions = $this->getActions(); $config_my_course_type_filter = $GLOBALS['user']->cfg->MY_COURSES_TYPE_FILTER; // Get the view filter $this->view_filter = $this->getFilterConfig(); if (Request::get('sortFlag')) { $GLOBALS['user']->cfg->store('MEINE_SEMINARE_SORT_FLAG', Request::get('sortFlag') == 'asc' ? 'DESC' : 'ASC'); } if (Request::option('sortby')) { $GLOBALS['user']->cfg->store('MEINE_SEMINARE_SORT', Request::option('sortby')); } $this->selected_action = $GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA; if (is_null($this->selected_action)) { $this->selected_action = 1; } $this->sortby = $GLOBALS['user']->cfg->MEINE_SEMINARE_SORT; $this->sortFlag = $GLOBALS['user']->cfg->MEINE_SEMINARE_SORT_FLAG ?: 'ASC'; $this->courses = $this->getCourses(array('sortby' => $this->sortby, 'sortFlag' => $this->sortFlag, 'view_filter' => $this->view_filter, 'typeFilter' => $config_my_course_type_filter)); if (in_array('contents', $this->view_filter)) { $this->nav_elements = MyRealmModel::calc_nav_elements(array($this->courses)); } // get all available teacher for infobox-filter // filter by selected teacher $_SESSION['MY_COURSES_LIST'] = array_map(function ($c, $id) { return array('Name' => $c['Name'], 'Seminar_id' => $id); }, array_values($this->courses), array_keys($this->courses)); $this->all_lock_rules = new SimpleCollection(array_merge(array(array('name' => '--' . _("keine Sperrebene") . '--', 'lock_id' => 'none')), LockRule::findAllByType('sem'))); $this->aux_lock_rules = array_merge(array(array('name' => '--' . _("keine Zusatzangaben") . '--', 'lock_id' => 'none')), AuxLockRules::getAllLockRules()); $sidebar = Sidebar::get(); $sidebar->setImage("sidebar/seminar-sidebar.png"); $this->setSearchWiget(); $this->setInstSelector(); $this->setSemesterSelector(); $this->setTeacherWidget(); $this->setCourseTypeWidget($config_my_course_type_filter); $this->setActionsWidget($this->selected_action); if ($this->sem_create_perm) { $actions = new ActionsWidget(); $actions->addLink(_('Neue Veranstaltung anlegen'), URLHelper::getLink('dispatch.php/course/wizard'), Icon::create('seminar+add', 'clickable'))->asDialog('size=50%'); $sidebar->addWidget($actions, 'links'); } $this->setViewWidget($this->view_filter); if ($this->sem_create_perm) { $params = array(); if ($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT) { $params['search'] = $GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT; } $export = new ExportWidget(); $export->addLink(_('Als Excel exportieren'), URLHelper::getLink('dispatch.php/admin/courses/export_csv', $params), Icon::create('file-excel', 'clickable')); $sidebar->addWidget($export); } }
</tr> <tr> <td> <label for="lock_rule"><?php echo _('Sperrebene'); ?> </label> </td> <td colspan="2"> <select name="lock_rule" id="lock_rule"> <option value="none"> <?php echo _('-- Bitte Sperrebene auswählen --'); ?> </option> <? foreach (LockRule::findAllByType('user') as $rule) : ?> <option value="<?php echo $rule->getId(); ?> " <? if ($user['lock_rule'] == $rule->getId()) echo 'selected'; ?>> <?php echo htmlReady($rule->name); ?> </option> <? endforeach; ?> </select> </td> </tr> </tbody> <? endif ?>
/** * shows the lock rules * * @return void */ public function lock_action() { Navigation::activateItem('course/admin/main'); PageLayout::setTitle(_('Sperrebene ändern')); $course = Course::findCurrent(); if (!$course) { $this->redirect($this->url_for('/index')); return; } $this->all_lock_rules = array_merge(array(array('name' => ' -- ' . _("keine Sperrebene") . ' -- ', 'lock_id' => 'none')), LockRule::findAllByType('sem')); $this->current_lock_rule = LockRule::find($course->lock_rule); }