Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
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="">&nbsp;</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; ?>
Esempio n. 3
0
 function delete_action($lock_rule_id)
 {
     $this->lock_rule = LockRule::find($lock_rule_id);
     if (!(!$this->lock_rule->isNew() && ($GLOBALS['perm']->have_perm('root') || $this->lock_rule->user_id == $GLOBALS['user']->id))) {
         throw new Trails_Exception(403);
     }
     CSRFProtection::verifyUnsafeRequest();
     if ($this->lock_rule->delete()) {
         PageLayout::postMessage(MessageBox::success(_('Die Sperrebene wurde gelöscht.')));
     }
     $this->redirect($this->url_for('admin/lockrules'));
 }
Esempio n. 4
0
 /**
  * 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);
     }
 }
Esempio n. 5
0
    </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 ?>
Esempio n. 6
0
 /**
  * set the lock rule
  *
  * @return void
  */
 public function set_lock_rule_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     if (!$GLOBALS['perm']->have_studip_perm('admin', $GLOBALS['SessionSeminar'])) {
         throw new AccessDeniedException();
     }
     $course = Course::findCurrent();
     if ($course) {
         $rule_id = Request::get('lock_sem') != 'none' ? Request::get('lock_sem') : null;
         $course->lock_rule = $rule_id;
         if ($course->store()) {
             if (!is_null($rule_id)) {
                 $lock_rule = LockRule::find($rule_id);
                 $msg = sprintf(_('Die Sperrebene %s wurde erfolgreich übernommen!'), $lock_rule->name);
             } else {
                 $msg = _('Die Sperrebene wurde erfolgreich zurückgesetzt!');
             }
             PageLayout::postMessage(MessageBox::success($msg));
         }
     }
     $this->relocate($this->url_for('/index'));
 }