コード例 #1
0
ファイル: userdomains.php プロジェクト: ratbird/hope
 /**
  * Stores the user domain settings of a user.
  */
 public function store_action()
 {
     $this->check_ticket();
     $any_change = false;
     $userdomain_delete = Request::optionArray('userdomain_delete');
     if (count($userdomain_delete) > 0) {
         foreach ($userdomain_delete as $id) {
             $domain = new UserDomain($id);
             $domain->removeUser($this->user->user_id);
         }
         $any_change = true;
     }
     $new_userdomain = Request::option('new_userdomain');
     if ($new_userdomain && $new_userdomain != 'none') {
         $domain = new UserDomain($new_userdomain);
         $domain->addUser($this->user->user_id);
         $any_change = true;
     }
     if ($any_change) {
         $this->reportSuccess(_('Die Zuordnung zu Nutzerdomänen wurde geändert.'));
         setTempLanguage($this->user->user_id);
         $this->postPrivateMessage(_("Die Zuordnung zu Nutzerdomänen wurde geändert!\n"));
         restoreLanguage();
     }
     $this->redirect('settings/userdomains');
 }
コード例 #2
0
 /**
  * Extract plugin part from request
  *
  * @param string $step
  * @param array  $errors
  **/
 private function extract($step, &$errors = array())
 {
     $steps = array('manifest' => words('pluginname author origin studipMinVersion studipMaxVersion pluginclassname version interfaces'), 'details' => words('description homepage updateURL tab'), 'assets' => words('migration environment dbscheme dbscheme_content uninstalldbscheme uninstalldbscheme_content ' . 'css css_content js js_content assets'), 'navigation' => words('navigation'), 'icon' => words('sprite'), 'polyfill' => words('polyfills'));
     if (!isset($steps[$step])) {
         throw new Exception('Invalid step "' . $step . '" invoked');
     }
     $result = array();
     $errors = array();
     $request = Request::getInstance();
     foreach ($steps[$step] as $variable) {
         $result[$variable] = $request[$variable];
     }
     if ($step === 'manifest') {
         $result['interfaces'] = Request::optionArray('interfaces');
         if (!$result['pluginname']) {
             $errors['pluginname'] = _('Pluginname nicht angegeben');
         }
         if (!$result['author']) {
             $errors['author'] = _('Kein Autor angegeben');
         }
         if (!$result['origin']) {
             $errors['origin'] = _('Keine Herkunft angegeben');
         }
         if (!$result['pluginclassname']) {
             $errors['pluginclassname'] = _('Kein Klassenname für das Plugin angegeben');
         }
         if (!$result['version']) {
             $errors['version'] = _('Keine Version angegeben');
         }
         if (!$result['studipMinVersion']) {
             $errors['studipMinVersion'] = _('Keine minimale Stud.IP-Version angegeben');
         }
         if (empty($result['interfaces'])) {
             $errors['interfaces'] = _('Kein Interface ausgewählt');
         }
     } else {
         if ($step === 'navigation') {
             $result['navigation'] = Request::getArray('navigation');
         } else {
             if ($step === 'icon' and !empty($_FILES['file']['name'])) {
                 $tmp_icon = $GLOBALS['TMP_PATH'] . '/' . md5(uniqid('plugin-icon', true));
                 if (strpos($_FILES['file']['type'], 'image/') !== 0) {
                     $errors['file'] = sprintf(_('Ungültiger Dateityp "%s"'), $_FILES['file']['type']);
                 } else {
                     if ($_FILES['file']['error'] !== 0 or !move_uploaded_file($_FILES['file']['tmp_name'], $tmp_icon)) {
                         $errors['file'] = _('Fehler bei der Datenübertragung');
                     } else {
                         $content = file_get_contents($tmp_icon);
                         unlink($tmp_icon);
                         $result['file'] = $content;
                     }
                 }
             }
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: QuickSelection.php プロジェクト: ratbird/hope
 public function save_action()
 {
     if (get_config('QUICK_SELECTION') === NULL) {
         Config::get()->create('QUICK_SELECTION', array('range' => 'user', 'type' => 'array', 'description' => 'Einstellungen des QuickSelection-Widgets'));
     }
     $names = Request::optionArray('add_removes');
     WidgetHelper::addWidgetUserConfig($GLOBALS['user']->id, 'QUICK_SELECTION', $names);
     $template_factory = new Flexi_TemplateFactory(__DIR__ . '/templates');
     $template = $template_factory->open('list');
     $template->navigation = $this->getFilteredNavigation($names);
     header('X-Dialog-Close: 1');
     header('X-Dialog-Execute: STUDIP.QuickSelection.update');
     echo studip_utf8encode($template->render());
 }
コード例 #4
0
ファイル: news.php プロジェクト: ratbird/hope
 /**
  * Show administration page for user's news
  *
  * @param string $area_type         area filter
  */
 function admin_news_action($area_type = '')
 {
     // check permission
     if (!$GLOBALS['auth']->is_authenticated() || $GLOBALS['user']->id === 'nobody') {
         throw new AccessDeniedException();
     }
     $GLOBALS['perm']->check('user');
     // initialize
     $news_result = array();
     $limit = 100;
     if (Request::get('news_filter') == 'set') {
         $this->news_searchterm = Request::option('news_filter_term');
         $this->news_startdate = Request::int('news_filter_start');
         $this->news_enddate = Request::int('news_filter_end');
     } else {
         $this->news_startdate = time();
     }
     if (is_array($this->area_structure[$area_type])) {
         $this->area_type = $area_type;
     }
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     PageLayout::setTitle(_('Meine Ankündigungen'));
     PageLayout::setHelpKeyword('Basis.News');
     Navigation::activateItem('/tools/news');
     if (Request::submitted('reset_filter')) {
         $area_type = 'all';
         $this->news_searchterm = '';
         $this->news_startdate = '';
         $this->news_enddate = '';
     }
     // delete news
     if (Request::submitted('remove_marked_news')) {
         $remove_ranges = array();
         foreach (Request::optionArray('mark_news') as $mark_id) {
             list($news_id, $range_id) = explode('_', $mark_id);
             $remove_ranges[$news_id][] = $range_id;
         }
         $this->flash['question_text'] = remove_news($remove_ranges);
         $this->flash['question_param'] = array('mark_news' => Request::optionArray('mark_news'), 'remove_marked_news' => 1);
     }
     // apply filter
     if (Request::submitted('apply_news_filter')) {
         $this->news_isvisible['basic'] = $this->news_isvisible['basic'] ? false : true;
         if (Request::get('news_searchterm') and strlen(trim(Request::get('news_searchterm'))) < 3) {
             PageLayout::postMessage(MessageBox::error(_('Der Suchbegriff muss mindestens 3 Zeichen lang sein.')));
         } elseif (Request::get('news_startdate') and !$this->getTimeStamp(Request::get('news_startdate'), 'start') or Request::get('news_enddate') and !$this->getTimeStamp(Request::get('news_enddate'), 'end')) {
             PageLayout::postMessage(MessageBox::error(_('Ungültige Datumsangabe. Bitte geben Sie ein Datum im Format TT.MM.JJJJ ein.')));
         } elseif (Request::get('news_enddate') and Request::get('news_enddate') and $this->getTimeStamp(Request::get('news_startdate'), 'start') > $this->getTimeStamp(Request::get('news_enddate'), 'end')) {
             PageLayout::postMessage(MessageBox::error(_('Das Startdatum muss vor dem Enddatum liegen.')));
         }
         if (strlen(trim(Request::get('news_searchterm'))) >= 3) {
             $this->news_searchterm = Request::get('news_searchterm');
         }
         $this->news_startdate = $this->getTimeStamp(Request::get('news_startdate'), 'start');
         $this->news_enddate = $this->getTimeStamp(Request::get('news_enddate'), 'end');
     }
     // fetch news list
     $this->news_items = StudipNews::getNewsRangesByFilter($GLOBALS["auth"]->auth["uid"], $this->area_type, $this->news_searchterm, $this->news_startdate, $this->news_enddate, true, $limit + 1);
     // build area and filter description
     if ($this->news_searchterm and $this->area_type and $this->area_type != 'all') {
         if ($this->news_startdate and $this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s" zum Suchbegriff "%s", die zwischen dem %s und dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], $this->news_searchterm, date('d.m.Y', $this->news_startdate), date('d.m.Y', $this->news_enddate));
         } elseif ($this->news_startdate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s" zum Suchbegriff "%s", die ab dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], $this->news_searchterm, date('d.m.Y', $this->news_startdate));
         } elseif ($this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s" zum Suchbegriff "%s", die vor dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], $this->news_searchterm, date('d.m.Y', $this->news_enddate));
         } else {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s" zum Suchbegriff "%s".'), $this->area_structure[$this->area_type]['title'], $this->news_searchterm);
         }
     } elseif ($this->area_type and $this->area_type != 'all') {
         if ($this->news_startdate and $this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s", die zwischen dem %s und dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], date('d.m.Y', $this->news_startdate), date('d.m.Y', $this->news_enddate));
         } elseif ($this->news_startdate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s", die ab dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], date('d.m.Y', $this->news_startdate));
         } elseif ($this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s", die vor dem %s sichtbar sind.'), $this->area_structure[$this->area_type]['title'], date('d.m.Y', $this->news_enddate));
         } else {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen im Bereich "%s".'), $this->area_structure[$this->area_type]['title']);
         }
     } elseif ($this->news_searchterm) {
         if ($this->news_startdate and $this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen zum Suchbegriff "%s", die zwischen dem %s und dem %s sichtbar sind.'), $this->news_searchterm, date('d.m.Y', $this->news_startdate), date('d.m.Y', $this->news_enddate));
         } elseif ($this->news_startdate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen zum Suchbegriff "%s", die ab dem %s sichtbar sind.'), $this->news_searchterm, date('d.m.Y', $this->news_startdate));
         } elseif ($this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen zum Suchbegriff "%s", die vor dem %s sichtbar sind.'), $this->news_searchterm, date('d.m.Y', $this->news_enddate));
         } else {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen zum Suchbegriff "%s".'), $this->news_searchterm);
         }
     } elseif ($this->news_startdate or $this->news_enddate) {
         if ($this->news_startdate and $this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen, die zwischen dem %s und dem %s sichtbar sind.'), date('d.m.Y', $this->news_startdate), date('d.m.Y', $this->news_enddate));
         } elseif ($this->news_startdate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen, die ab dem %s sichtbar sind.'), date('d.m.Y', $this->news_startdate));
         } elseif ($this->news_enddate) {
             $this->filter_text = sprintf(_('Angezeigt werden Ankündigungen, die vor dem %s sichtbar sind.'), date('d.m.Y', $this->news_enddate));
         }
     }
     // check for delete-buttons and news limit
     foreach ($this->area_structure as $type => $area_data) {
         if (is_array($this->news_items[$type])) {
             foreach ($this->news_items[$type] as $key => $news) {
                 // has trash icon been clicked?
                 if (Request::submitted('news_remove_' . $news['object']->news_id . '_' . $news['range_id']) and Request::isPost()) {
                     $this->flash['question_text'] = remove_news(array($news['object']->news_id => $news['range_id']));
                     $this->flash['question_param'] = array('mark_news' => array($news['object']->news_id . '_' . $news['range_id']), 'remove_marked_news' => 1);
                 }
                 // check if result set too big
                 $counter++;
                 if ($counter == $limit + 1) {
                     PageLayout::postMessage(MessageBox::info(sprintf(_('Es werden nur die ersten %s Ankündigungen angezeigt.'), $limit)));
                     unset($this->news_items[$type][$key]);
                 }
             }
         }
     }
     // sort grouped list by title
     foreach ($this->area_structure as $type => $area_data) {
         if (count($this->news_groups[$type])) {
             ksort($this->news_groups[$type]);
         }
     }
     $this->sidebar = Sidebar::get();
     $this->sidebar->setImage('sidebar/news-sidebar.png');
     if ($GLOBALS['perm']->have_perm('tutor')) {
         $widget = new ViewsWidget();
         $widget->addLink(_('Alle Ankündigungen'), URLHelper::getURL('dispatch.php/news/admin_news/all'))->setActive(!$this->area_type);
         if ($GLOBALS['perm']->have_perm('root')) {
             $widget->addLink(_('System'), URLHelper::getURL('dispatch.php/news/admin_news/global'))->setActive($this->area_type === 'global');
         }
         if ($GLOBALS['perm']->have_perm('dozent')) {
             $widget->addLink(_('Einrichtungen'), URLHelper::getURL('dispatch.php/news/admin_news/inst'))->setActive($this->area_type === 'inst');
         }
         $widget->addLink(_('Veranstaltungen'), URLHelper::getURL('dispatch.php/news/admin_news/sem'))->setActive($this->area_type === 'sem');
         $widget->addLink(_('Profil'), URLHelper::getURL('dispatch.php/news/admin_news/user'))->setActive($this->area_type === 'user');
         $this->sidebar->addWidget($widget);
     }
     $widget = new ActionsWidget();
     $widget->addLink(_('Ankündigung erstellen'), URLHelper::getLink('dispatch.php/news/edit_news/new'), Icon::create('news+add', 'clickable'), array('rel' => 'get_dialog', 'target' => '_blank'));
     $this->sidebar->addWidget($widget);
 }
コード例 #5
0
 /**
  * Update the Question content
  *
  * @access  private
  * @param   boolean  $no_delete  YES/NO (optional)
  * @return  string   the udpatemessage
  */
 function execCommandUpdateQuestions($no_delete = false)
 {
     $questions = Request::getArray('questions');
     $deleteQuestions = Request::getArray('DeleteQuestions');
     // remove any empty questions
     $deletecount = 0;
     $qgroup =& $this->tree->getGroupObject($this->itemID);
     $questionsDB = $qgroup->getChildren();
     $cmd = Request::optionArray('cmd');
     if (!empty($cmd)) {
         if (key($cmd) == "UpdateItem") {
             $delete_empty_questions = 1;
         }
     }
     for ($i = 0; $i < count($questions); $i++) {
         if (!isset($deleteQuestions[$i])) {
             $question = new EvaluationQuestion($questions[$i]['questionID'], NULL, EVAL_LOAD_FIRST_CHILDREN);
             // remove any empty questions
             if (empty($questions[$i]['text']) && $delete_empty_questions) {
                 $question->delete();
                 $deletecount++;
                 // upadate the questiontext to the db
             } else {
                 $question->setText($questions[$i]['text']);
                 $question->save();
             }
         }
     }
     $msg = NULL;
     if ($deletecount == 1) {
         $msg = _("Es wurde eine leere Frage entfernt.");
     } elseif ($deletecount > 1) {
         $msg = sprintf(_("Es wurden %s leere Fragen entfernt."), $deletecount);
     }
     return $msg;
 }
コード例 #6
0
ファイル: studies.php プロジェクト: ratbird/hope
 /**
  * Stores the study information of a user (institute-wise).
  */
 public function store_in_action()
 {
     $this->check_ticket();
     $inst_delete = Request::optionArray('inst_delete');
     if (count($inst_delete) > 0) {
         $query = "DELETE FROM user_inst WHERE user_id = ? AND Institut_id = ?";
         $statement = DBManager::get()->prepare($query);
         foreach ($inst_delete as $institute_id) {
             $statement->execute(array($this->user->user_id, $institute_id));
             if ($statement->rowCount() > 0) {
                 log_event('INST_USER_DEL', $institute_id, $this->user->user_id);
                 $delete = true;
             }
         }
     }
     $new_inst = Request::option('new_inst');
     if ($new_inst) {
         $query = "INSERT IGNORE INTO user_inst\n                        (user_id, Institut_id, inst_perms)\n                      VALUES (?, ?, 'user')";
         $statement = DBManager::get()->prepare($query);
         $statement->execute(array($this->user->user_id, $new_inst));
         if ($statement->rowCount() > 0) {
             log_event('INST_USER_ADD', $new_inst, $this->user->user_id, 'user');
             $new = true;
         }
     }
     if ($delete || $new) {
         $this->reportSuccess(_('Die Zuordnung zu Einrichtungen wurde geändert.'));
         setTempLanguage($this->user->user_id);
         $this->postPrivateMessage(_("Die Zuordnung zu Einrichtungen wurde geändert!\n"));
         restoreLanguage();
     }
     $this->redirect('settings/studies');
 }
コード例 #7
0
ファイル: logs.php プロジェクト: ratbird/hope
    /**
     * Performs a bulk operation on a set of log entries. The only supported
     * operation at the moment is deleting.
     *
     * @param int    $page Return to this page afterwarsd (optional)
     */
    public function bulk_action($page = 1)
    {
        $action = Request::option('action');
        $ids    = Request::optionArray('ids');
        $logs   = CronjobLog::findMany($ids);

        if ($action === 'delete') {
            foreach ($logs as $log) {
                $log->delete();
            }

            $n = count($logs);
            $message = sprintf(ngettext('%u Logeintrag wurde gelöscht.', '%u Logeinträge wurden gelöscht.', $n), $n);
            PageLayout::postMessage(MessageBox::success($message));
        }

        $this->redirect('admin/cronjobs/logs/index/' . $page);
    }
コード例 #8
0
ファイル: plugin.php プロジェクト: ratbird/hope
 /**
  * Change the default activation for this plugin.
  */
 public function save_default_activation_action($plugin_id)
 {
     $plugin_manager = PluginManager::getInstance();
     $selected_inst = Request::optionArray('selected_inst');
     $this->check_ticket();
     // save selected institutes (if any)
     $plugin_manager->setDefaultActivations($plugin_id, $selected_inst);
     if (count($selected_inst) == 0) {
         $this->flash['message'] = _('Die Default-Aktivierung wurde ausgeschaltet.');
     } else {
         $this->flash['message'] = ngettext('Für die ausgewählte Einrichtung wurde das Plugin standardmäßig aktiviert.', 'Für die ausgewählten Einrichtungen wurde das Plugin standardmäßig aktiviert.', count($selected_inst));
     }
     $this->redirect('admin/plugin/default_activation/' . $plugin_id);
 }
コード例 #9
0
ファイル: basicdata.php プロジェクト: ratbird/hope
 /**
  * Ändert alle Grunddaten der Veranstaltung (bis auf Personal) und leitet
  * danach weiter auf View.
  */
 public function set_action($course_id)
 {
     global $perm;
     $sem = Seminar::getInstance($course_id);
     $this->msg = array();
     $old_settings = $sem->getSettings();
     //Seminar-Daten:
     if ($perm->have_studip_perm("tutor", $sem->getId())) {
         $changemade = false;
         foreach (Request::getInstance() as $req_name => $req_value) {
             if (substr($req_name, 0, 7) === "course_") {
                 $varname = substr($req_name, 7);
                 if ($varname === "name" && !$req_value) {
                     $this->msg[] = array("error", _("Name der Veranstaltung darf nicht leer sein."));
                 } elseif ($sem->{$varname} != $req_value) {
                     $sem->{$varname} = $req_value;
                     $changemade = true;
                 }
             }
         }
         //seminar_inst:
         if (!LockRules::Check($course_id, 'seminar_inst') && $sem->setInstitutes(Request::optionArray('related_institutes'))) {
             $changemade = true;
         }
         //Datenfelder:
         $invalid_datafields = array();
         $all_fields_types = DataFieldEntry::getDataFieldEntries($sem->id, 'sem', $sem->status);
         foreach (Request::getArray('datafields') as $datafield_id => $datafield_value) {
             $datafield = $all_fields_types[$datafield_id];
             $valueBefore = $datafield->getValue();
             $datafield->setValueFromSubmit($datafield_value);
             if ($valueBefore != $datafield->getValue()) {
                 if ($datafield->isValid()) {
                     $datafield->store();
                     $changemade = true;
                 } else {
                     $invalid_datafields[] = $datafield->getName();
                 }
             }
         }
         if (count($invalid_datafields)) {
             $message = ngettext('%s der Veranstaltung wurde falsch angegeben', '%s der Veranstaltung wurden falsch angegeben', count($invalid_datafields));
             $message .= ', ' . _('bitte korrigieren Sie dies unter "Beschreibungen"') . '.';
             $message = sprintf($message, join(', ', array_map('htmlReady', $invalid_datafields)));
             $this->msg[] = array('error', $message);
         }
         $sem->store();
         // Logging
         $before = array_diff_assoc($old_settings, $sem->getSettings());
         $after = array_diff_assoc($sem->getSettings(), $old_settings);
         //update admission, if turnout was raised
         if ($after['admission_turnout'] > $before['admission_turnout'] && $sem->isAdmissionEnabled()) {
             update_admission($sem->getId());
         }
         if (sizeof($before) && sizeof($after)) {
             foreach ($before as $k => $v) {
                 $log_message .= "{$k}: {$v} => " . $after[$k] . " \n";
             }
             log_event('CHANGE_BASIC_DATA', $sem->getId(), " ", $log_message);
         }
         // end of logging
         if ($changemade) {
             $this->msg[] = array("msg", _("Die Grunddaten der Veranstaltung wurden verändert."));
         }
     } else {
         $this->msg[] = array("error", _("Sie haben keine Berechtigung diese Veranstaltung zu verändern."));
     }
     //Labels/Funktionen für Dozenten und Tutoren
     if ($perm->have_studip_perm("dozent", $sem->getId())) {
         foreach (Request::getArray("label") as $user_id => $label) {
             $sem->setLabel($user_id, $label);
         }
     }
     foreach ($sem->getStackedMessages() as $key => $messages) {
         foreach ($messages['details'] as $message) {
             $this->msg[] = array($key !== "success" ? $key : "msg", $message);
         }
     }
     $this->flash['msg'] = $this->msg;
     $this->flash['open'] = Request::get("open");
     $this->redirect($this->url_for('course/basicdata/view/' . $sem->getId()));
 }
コード例 #10
0
ファイル: schedules.php プロジェクト: ratbird/hope
 /**
  * Performs a bulk operation on a set of schedules. Operation can be
  * either activating, deactivating or canceling/deleting.
  *
  * @param int    $page Return to this page afterwarsd (optional)
  */
 public function bulk_action($page = 1)
 {
     $action = Request::option('action');
     $ids = Request::optionArray('ids');
     $schedules = CronjobSchedule::findMany($ids);
     if ($action === 'activate') {
         $schedules = array_filter($schedules, function ($item) {
             return !$item->active;
         });
         $failed = 0;
         foreach ($schedules as $schedule) {
             if ($schedule->task->active) {
                 $schedule->activate();
             } else {
                 $failed += 1;
             }
         }
         if ($failed > 0) {
             $message = ngettext('%u Cronjob konnte nicht aktiviert werden, da die entsprechende Aufgabe deaktiviert ist.', '%u Cronjob(s) konnte(n) nicht aktiviert werden, da die entsprechende Aufgabe deaktiviert ist.', $failed);
             $message = sprintf($message, $failed);
             PageLayout::postMessage(MessageBox::info($message));
         }
         $n = count($schedules) - $failed;
         $message = sprintf(ngettext('%u Cronjob wurde aktiviert.', '%u Cronjobs wurden aktiviert.', $n), $n);
         PageLayout::postMessage(MessageBox::success($message));
     } else {
         if ($action === 'deactivate') {
             $schedules = array_filter($schedules, function ($item) {
                 return $item->active;
             });
             foreach ($schedules as $schedule) {
                 $schedule->deactivate();
             }
             $n = count($schedules);
             $message = sprintf(ngettext('%u Cronjob wurde deaktiviert.', '%u Cronjobs wurden deaktiviert.', $n), $n);
             PageLayout::postMessage(MessageBox::success($message));
         } else {
             if ($action === 'cancel') {
                 foreach ($schedules as $schedule) {
                     $schedule->delete();
                 }
                 $n = count($schedules);
                 $message = sprintf(ngettext('%u Cronjob wurde gelöscht.', '%u Cronjobs wurden gelöscht.', $n), $n);
                 PageLayout::postMessage(MessageBox::success($message));
             }
         }
     }
     $this->redirect('admin/cronjobs/schedules/index/' . $page);
 }
コード例 #11
0
ファイル: role.php プロジェクト: ratbird/hope
 /**
  *
  */
 private function getPlugins($role_id, $plugin_id)
 {
     // From form
     if (Request::getInstance()->offsetExists('ids')) {
         return Request::optionArray('ids');
     }
     // From url
     return array($plugin_id);
 }
コード例 #12
0
ファイル: single.php プロジェクト: ratbird/hope
 public function add_users_action($range_id = null)
 {
     $this->range_id = $range_id ?: $this->range_id;
     $this->calendar = new SingleCalendar($this->range_id);
     if (Request::isXhr()) {
         $added_users = Request::optionArray('added_users');
     } else {
         $mps = MultiPersonSearch::load('calendar-manage_access');
         $added_users = $mps->getAddedUsers();
         $mps->clearSession();
     }
     $added = 0;
     foreach ($added_users as $user_id) {
         $user_to_add = User::find($user_id);
         if ($user_to_add) {
             $calendar_user = new CalendarUser(array($this->calendar->getRangeId(), $user_to_add->id));
             if ($calendar_user->isNew()) {
                 $calendar_user->permission = Calendar::PERMISSION_READABLE;
                 $added += $calendar_user->store();
             }
         }
     }
     if ($added) {
         PageLayout::postMessage(MessageBox::success(sprintf(ngettext('Eine Person wurde mit der Berechtigung zum Lesen des Kalenders hinzugefügt.', '%s Personen wurden mit der Berechtigung zum Lesen des Kalenders hinzugefügt.', $added), $added)));
     }
     if (Request::isXhr()) {
         $this->response->add_header('X-Dialog-Close', 1);
         $this->response->set_status(200);
         $this->render_nothing();
     } else {
         $this->redirect($this->url_for('calendar/single/manage_access/' . $this->calendar->getRangeId()));
     }
 }
コード例 #13
0
ファイル: semester.php プロジェクト: ratbird/hope
 /**
  * This method deletes a semester or a bundle of semesters.
  *
  * @param string $id Id of the semester (or 'bulk' for a bulk operation)
  */
 public function delete_action($id)
 {
     $ids = $id === 'bulk' ? Request::optionArray('ids') : array($id);
     if (count($ids)) {
         $errors = array();
         $deleted = 0;
         $semesters = Semester::findMany($ids);
         foreach ($semesters as $semester) {
             if ($semester->absolute_seminars_count > 0) {
                 $errors[] = sprintf(_('Das Semester "%s" hat noch Veranstaltungen und kann daher nicht gelöscht werden.'), $semester->name);
             } elseif (!$semester->delete()) {
                 $errors[] = sprintf(_('Fehler beim Löschen des Semesters "%s".'), $semester->name);
             } else {
                 $deleted += 1;
             }
         }
         if (count($errors) === 1) {
             PageLayout::postMessage(MessageBox::error($errors[0]));
         } elseif (!empty($errors)) {
             $message = _('Beim Löschen der Semester sind folgende Fehler aufgetreten.');
             PageLayout::postMessage(MessageBox::error($message, $errors));
         }
         if ($deleted > 0) {
             $message = sprintf(_('%u Semester wurde(n) erfolgreich gelöscht.'), $deleted);
             PageLayout::postMessage(MessageBox::success($message));
         }
     }
     $this->redirect('admin/semester');
 }
コード例 #14
0
}
if (Request::option('_anker_id')) {
    $_SESSION['_anker_id'] = Request::option('_anker_id');
}
if (Request::optionArray('_open')) {
    $_SESSION['_open'] = Request::optionArray('_open');
}
if (Request::quotedArray('_lit_data')) {
    $_SESSION['_lit_data'] = Request::quotedArray('_lit_data');
}
if (Request::option('_lit_data_id')) {
    $_SESSION['_lit_data_id'] = Request::option('_lit_data_id');
}
$_check_list = Request::optionArray('_check_list');
if (!empty($_check_list)) {
    $_SESSION['_check_list'] = Request::optionArray('_check_list');
}
if (Request::option('_check_plugin')) {
    $_SESSION['_check_plugin'] = Request::option('_check_plugin');
}
$_semester = new SemesterData();
$element = new StudipLitCatElement();
if (Request::option('cmd') == 'check' && !isset($_check_list)) {
    Request::set('_check_list', array());
}
//my_session_var(array('_semester_id','_inst_id','_anker_id','_open','_lit_data','_lit_data_id','_check_list','_check_plugin'));
if (Request::quoted('send')) {
    $_SESSION['_anker_id'] = null;
    $_SESSION['_open'] = null;
    $_SESSION['_lit_data'] = null;
    $_SESSION['_lit_data_id'] = null;
コード例 #15
0
ファイル: helpers.php プロジェクト: ratbird/hope
 function bookable_rooms_action()
 {
     if (!getGlobalPerms($GLOBALS['user']->id) == 'admin') {
         $resList = new ResourcesUserRoomsList($GLOBALS['user']->id, false, false, false);
         if (!$resList->roomsExist()) {
             throw new AccessDeniedException();
         }
     }
     $select_options = Request::optionArray('rooms');
     $rooms = array_filter($select_options, function ($v) {
         return strlen($v) === 32;
     });
     $events = array();
     $dates = array();
     $timestamps = array();
     if (count(Request::getArray('new_date'))) {
         $new_date = array();
         foreach (Request::getArray('new_date') as $one) {
             if ($one['name'] == 'startDate') {
                 $dmy = explode('.', $one['value']);
                 $new_date['day'] = (int) $dmy[0];
                 $new_date['month'] = (int) $dmy[1];
                 $new_date['year'] = (int) $dmy[2];
             }
             $new_date[$one['name']] = (int) $one['value'];
         }
         if (check_singledate($new_date['day'], $new_date['month'], $new_date['year'], $new_date['start_stunde'], $new_date['start_minute'], $new_date['end_stunde'], $new_date['end_minute'])) {
             $start = mktime($new_date['start_stunde'], $new_date['start_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']);
             $ende = mktime($new_date['end_stunde'], $new_date['end_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']);
             $timestamps[] = $start;
             $timestamps[] = $ende;
             $event = new AssignEvent('new_date', $start, $ende, null, null, '');
             $events[$event->getId()] = $event;
         }
     }
     foreach (Request::optionArray('selected_dates') as $one) {
         $date = new SingleDate($one);
         if ($date->getStartTime()) {
             $timestamps[] = $date->getStartTime();
             $timestamps[] = $date->getEndTime();
             $event = new AssignEvent($date->getTerminID(), $date->getStartTime(), $date->getEndTime(), null, null, '');
             $events[$event->getId()] = $event;
             $dates[$date->getTerminID()] = $date;
         }
     }
     if (count($events)) {
         $result = array();
         $checker = new CheckMultipleOverlaps();
         $checker->setTimeRange(min($timestamps), max($timestamps));
         foreach ($rooms as $room) {
             $checker->addResource($room);
         }
         $checker->checkOverlap($events, $result, "assign_id");
         foreach ((array) $result as $room_id => $details) {
             foreach ($details as $termin_id => $conflicts) {
                 if ($termin_id == 'new_date' && Request::option('singleDateID')) {
                     $assign_id = SingleDateDB::getAssignID(Request::option('singleDateID'));
                 } else {
                     $assign_id = SingleDateDB::getAssignID($termin_id);
                 }
                 $filter = function ($a) use($assign_id) {
                     if ($a['assign_id'] && $a['assign_id'] == $assign_id) {
                         return false;
                     }
                     return true;
                 };
                 if (!count(array_filter($conflicts, $filter))) {
                     unset($result[$room_id][$termin_id]);
                 }
             }
         }
         $result = array_filter($result);
         $this->render_json(array_keys($result));
         return;
     }
     $this->render_nothing();
 }
コード例 #16
0
ファイル: multipersonsearch.php プロジェクト: ratbird/hope
 /**
  * Action which is used for handling all submits for no-JavaScript
  * users:
  * * searching,
  * * adding a person,
  * * removing a person,
  * * selcting a quickfilter,
  * * aborting,
  * * saving.
  *
  * This needs to be done in one single action to provider a similar
  * usability for no-JavaScript users as for JavaScript users.
  */
 public function no_js_form_action()
 {
     if (!empty($_POST)) {
         CSRFProtection::verifyUnsafeRequest();
     }
     $this->name = Request::get("name");
     $mp = MultiPersonSearch::load($this->name);
     $this->selectableUsers = array();
     $this->selectedUsers = array();
     $this->search = Request::get("freesearch");
     $this->additionHTML = $mp->getAdditionHTML();
     $previousSelectableUsers = unserialize(studip_utf8decode(Request::get('search_persons_selectable_hidden')));
     $previousSelectedUsers = unserialize(studip_utf8decode(Request::get('search_persons_selected_hidden')));
     // restore quickfilter
     $this->quickfilterIDs = $mp->getQuickfilterIds();
     foreach ($this->quickfilterIDs as $title => $array) {
         $this->quickfilter[] = $title;
     }
     // abort
     if (Request::submitted('abort')) {
         $this->redirect($_SESSION['multipersonsearch'][$this->name]['pageURL']);
     } elseif (Request::submitted('submit_search')) {
         // evaluate search
         $this->selectedUsers = User::findMany($previousSelectedUsers);
         $searchterm = Request::get('freesearch');
         $searchObject = $mp->getSearchObject();
         $result = array_map(function ($r) {
             return $r['user_id'];
         }, $searchObject->getResults($searchterm, array(), 50));
         $this->selectableUsers = User::findMany($result);
         // remove already selected users
         foreach ($this->selectableUsers as $key => $user) {
             if (in_array($user->id, $previousSelectedUsers) || in_array($user->id, $mp->getDefaultSelectedUsersIDs())) {
                 unset($this->selectableUsers[$key]);
                 $this->alreadyMemberUsers[$key] = $user;
             }
         }
     } elseif (Request::submitted('submit_search_preset')) {
         $this->selectedUsers = User::findMany($previousSelectedUsers);
         $this->selectableUsers = User::findMany($this->quickfilterIDs[Request::get('search_preset')]);
         // remove already selected users
         foreach ($this->selectableUsers as $key => $user) {
             if (in_array($user->id, $previousSelectedUsers) || in_array($user->id, $mp->getDefaultSelectedUsersIDs())) {
                 unset($this->selectableUsers[$key]);
             }
         }
     } elseif (Request::submitted('search_persons_add')) {
         // add users
         foreach (Request::optionArray('search_persons_selectable') as $userID) {
             if (($key = array_search($userID, $previousSelectableUsers)) !== false) {
                 unset($previousSelectableUsers[$key]);
             }
             $previousSelectedUsers[] = $userID;
         }
         $this->selectedUsers = User::findMany($previousSelectedUsers);
         $this->selectableUsers = User::findMany($previousSelectableUsers);
     } elseif (Request::submitted('search_persons_remove')) {
         // remove users
         foreach (Request::optionArray('search_persons_selected') as $userID) {
             if (($key = array_search($userID, $previousSelectedUsers)) !== false) {
                 unset($previousSelectedUsers[$key]);
             }
             $previousSelectableUsers[] = $userID;
         }
         $this->selectedUsers = User::findMany($previousSelectedUsers);
         $this->selectableUsers = User::findMany($previousSelectableUsers);
     } elseif (Request::submitted('save')) {
         // find added users
         $addedUsers = array();
         $defaultSelectedUsersIDs = $searchObject = $mp->getDefaultSelectedUsersIDs();
         foreach ($previousSelectedUsers as $selected) {
             if (!in_array($selected, $defaultSelectedUsersIDs)) {
                 $addedUsers[] = $selected;
             }
         }
         // find removed users
         $removedUsers = array();
         foreach ($defaultSelectedUsersIDs as $default) {
             if (!in_array($default, $previousSelectedUsers)) {
                 $removedUsers[] = $default;
             }
         }
         $_SESSION['multipersonsearch'][$this->name]['selected'] = $previousSelectedUsers;
         $_SESSION['multipersonsearch'][$this->name]['added'] = $addedUsers;
         $_SESSION['multipersonsearch'][$this->name]['removed'] = $removedUsers;
         // redirect to action which handles the form data
         $this->redirect($mp->getExecuteURL());
     } else {
         // get selected and selectable users from SESSION
         $this->defaultSelectableUsersIDs = $mp->getDefaultSelectableUsersIDs();
         $this->defaultSelectedUsersIDs = $mp->getDefaultSelectedUsersIDs();
         $this->selectableUsers = User::findMany($this->defaultSelectableUsersIDs);
         $this->selectedUsers = array();
     }
     // save selected/selectable users in hidden form fields
     $this->selectableUsers = new SimpleCollection($this->selectableUsers);
     $this->selectableUsers->orderBy("nachname asc, vorname asc");
     $this->selectableUsersHidden = $this->selectableUsers->pluck('id');
     $this->selectedUsers = new SimpleCollection($this->selectedUsers);
     $this->selectedUsers->orderBy("nachname asc, vorname asc");
     $this->selectedUsersHidden = $this->selectedUsers->pluck('id');
     $this->selectableUsers->orderBy('nachname, vorname');
     $this->selectedUsers->orderBy('nachname, vorname');
     // set layout data
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     $this->title = $mp->getTitle();
     $this->description = $mp->getDescription();
     $this->pageURL = $mp->getPageURL();
     if ($mp->getNavigationItem() != "") {
         Navigation::activateItem($mp->getNavigationItem());
     }
 }
コード例 #17
0
ファイル: folder.php プロジェクト: ratbird/hope
    if (count($download_ids) > 0) {
        $files_to_delete = array_map(function($f) {return htmlReady(StudipDocument::find($f)->filename) . '<input type="hidden" name="download_ids[]" value="' . $f . '">';}, $download_ids);
        $template = $template_factory->open('usermanagement/question_form.php');
        $template->set_attribute('question', _('Möchten Sie die ausgewählten Dateien wirklich löschen?'));
        $template->set_attribute('elements', array('<ul><li>' . join('</li><li>', $files_to_delete) . '</li></ul>'));
        $template->set_attribute('approvalbutton', Button::createAccept(_('JA!'), 'delete'));
        $template->set_attribute('disapprovalbutton', Button::createCancel(_('NEIN!')));
        $template->set_attribute('action', URLHelper::getLink());
        $question = $template->render();
    }
}

if ($rechte && Request::submitted('delete') && count(Request::optionArray('download_ids'))) {
    CSRFProtection::verifyUnsafeRequest();
    $deleted = 0;
    foreach (Request::optionArray('download_ids') as $one) {
        $deleted += delete_document($one);
    }
    if ($deleted) {
        $msg .= "msg§" . sprintf(_("Es wurden %s Dateien gelöscht."), $deleted) . '§';
    }

}


///////////////////////////////////////////////////////////
//Ajax-Funktionen
///////////////////////////////////////////////////////////
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    ob_end_clean();
    ob_start();
コード例 #18
0
 /**
  * saves the removed persons to $_SESSION.
  */
 public function saveRemovedUsersToSession()
 {
     $removedUsers = array();
     foreach ($this->defaultSelectedUsersIDs as $default) {
         if (!in_array($default, Request::optionArray($this->name . '_selectbox'))) {
             $removedUsers[] = $default;
         }
     }
     $_SESSION['multipersonsearch'][$this->name]['removed'] = $removedUsers;
 }
コード例 #19
0
 function callSafeguard($evalAction, $evalID = "", $showrangeID = NULL, $search = NULL, $referer = NULL)
 {
     global $perm, $auth, $user;
     if (!($evalAction || $evalAction == "search")) {
         return " ";
     }
     if (!$perm->have_studip_perm("tutor", $showrangeID) && $user->id != $showrangeID && !(isDeputyEditAboutActivated() && isDeputy($user->id, $showrangeID, true))) {
         return $this->createSafeguard("ausruf", sprintf(_("Sie haben keinen Zugriff auf diesen Bereich.")));
     }
     $evalDB = new EvaluationDB();
     $evalChanged = NULL;
     $safeguard = " ";
     /* Actions without any permissions ---------------------------------- */
     switch ($evalAction) {
         case "search_template":
             $search = trim($search);
             $templates = $evalDB->getPublicTemplateIDs($search);
             if (strlen($search) < EVAL_MIN_SEARCHLEN) {
                 $report = EvalCommon::createReportMessage(sprintf(_("Bitte einen Suchbegriff mit mindestens %d Buchstaben eingeben."), EVAL_MIN_SEARCHLEN), EVAL_PIC_ERROR, EVAL_CSS_ERROR);
             } elseif (count($templates) == 0) {
                 $report = EvalCommon::createReportMessage(_("Es wurden keine passenden öffentlichen Evaluationsvorlagen gefunden."), EVAL_PIC_ERROR, EVAL_CSS_ERROR);
             } else {
                 $report = EvalCommon::createReportMessage(sprintf(_("Es wurde(n) %d passende öffentliche Evaluationsvorlagen gefunden."), count($templates)), EVAL_PIC_SUCCESS, EVAL_CSS_SUCCESS);
             }
             $safeguard .= $report->createContent();
             return $safeguard;
         case "export_request":
             /* Check permissions ------------------------------------------- */
             $haveNoPerm = YES;
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
             $haveNoPerm = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
             if ($haveNoPerm == YES) {
                 $report = EvalCommon::createReportMessage(_("Sie haben nicht die Berechtigung diese Evaluation zu exportieren."), EVAL_PIC_ERROR, EVAL_CSS_ERROR);
                 return $report->createContent();
             }
             /* -------------------------------------- end: check permissions */
             /* Export evaluation ------------------------------------------- */
             $exportManager = new EvaluationExportManagerCSV($evalID);
             $exportManager->export();
             /* -------------------------------------- end: export evaluation */
             /* Create link ------------------------------------------------- */
             $link = new HTML("a");
             $link->addAttr('href', GetDownloadLink($exportManager->getTempFilename(), $exportManager->getFilename(), 2));
             $link->addHTMLContent(GetFileIcon('csv')->asImg());
             $link->addContent(_("auf diese Verknüpfung"));
             /* -------------------------------------------- end: create link */
             /* Create report ----------------------------------------------- */
             if ($exportManager->isError()) {
                 $report = EvalCommon::createErrorReport($exportManager, _("Fehler beim Exportieren"));
             } else {
                 $report = EvalCommon::createReportMessage(_("Die Daten wurden erfolgreich exportiert. Sie können die Ausgabedatei jetzt herunterladen."), EVAL_PIC_SUCCESS, EVAL_CSS_SUCCESS);
                 $report = $report->createContent();
                 $report .= sprintf(_("Bitte klicken Sie %s um die Datei herunter zu laden.") . "<br><br>", $link->createContent());
             }
             $safeguard .= $report;
             /* ------------------------------------------ end: create report */
             return $safeguard;
     }
     /* ----------------------------------- end: actions without permissions */
     $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
     $evalName = htmlready($eval->getTitle());
     /* Check for errors while loading ------------------------------------- */
     if ($eval->isError()) {
         EvalCommon::createErrorReport($eval);
         return $this->createSafeguard("", EvalCommon::createErrorReport($eval));
     }
     /* -------------------------------------- end: errorcheck while loading */
     /* Check for permissions in all ranges of the evaluation -------------- */
     if (!$eval->isTemplate() && $user->id != $eval->getAuthorID()) {
         $no_permisson = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
         if ($no_permisson > 0) {
             if ($no_permisson == 1) {
                 $no_permission_msg .= sprintf(_("Die Evaluation <b>%s</b> ist einem Bereich zugeordnet, für den Sie keine Veränderungsrechte besitzen."), $evalName);
             } else {
                 $no_permission_msg .= sprintf(_("Die Evaluation <b>%s</b> ist %s Bereichen zugeordnet, für die Sie keine Veränderungsrechte besitzen."), $evalName, $no_permisson);
             }
             if ($evalAction != "save") {
                 $no_permission_msg .= " " . _("Der Besitzer wurde durch eine systeminterne Nachricht informiert.");
                 $sms = new messaging();
                 $sms->insert_message(sprintf(_("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrer Evaluation **%s** vorzunehmen."), get_username($auth->auth["uid"]), $eval->getTitle()), get_username($eval->getAuthorID()), "____%system%____", FALSE, FALSE, "1", FALSE, _("Versuchte Änderung an Ihrer Evaluation"));
             }
         }
     } else {
         if ($eval->isTemplate() && $user->id != $eval->getAuthorID() && $evalAction != "copy_public_template" && $evalAction != "search_showrange") {
             $sms = new messaging();
             $sms->insert_message(sprintf(_("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrem Template **%s** vorzunehmen."), get_username($auth->auth["uid"]), $eval->getTitle()), get_username($eval->getAuthorID()), "____%system%____", FALSE, FALSE, "1", FALSE, _("Versuchte Änderung an Ihrem Template"));
             return $this->createSafeguard("ausruf", sprintf(_("Sie besitzen keine Rechte für das Tempate <b>%s</b>. Der Besitzer wurde durch eine systeminterne Nachricht informiert."), $evalName));
         }
     }
     /* ----------------------------------------- end: check for permissions */
     switch ($evalAction) {
         case "share_template":
             if ($eval->isShared()) {
                 $eval->setShared(NO);
                 $eval->save();
                 if ($eval->isError()) {
                     $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                     return $safeguard;
                 }
                 $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage <b>%s</b> kann jetzt nicht mehr von anderen Benutzern gefunden werden."), $evalName));
             } else {
                 $eval->setShared(YES);
                 $eval->save();
                 if ($eval->isError()) {
                     $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                     return $safeguard;
                 }
                 $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage <b>%s</b> kann jetzt von anderen Benutzern gefunden werden."), $evalName));
             }
             break;
         case "copy_public_template":
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $newEval = $eval->duplicate();
             $newEval->setAuthorID($auth->auth["uid"]);
             $newEval->setShared(NO);
             $newEval->setStartdate(NULL);
             $newEval->setStopdate(NULL);
             $newEval->setTimespan(NULL);
             $newEval->removeRangeIDs();
             $newEval->save();
             if ($newEval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die öffentliche Evaluationsvorlage <b>%s</b> wurde zu den eigenen Evaluationsvorlagen kopiert."), $evalName));
             break;
         case "start":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gestartet."));
             }
             $eval->setStartdate(time() - 500);
             $eval->save();
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde gestartet."), $evalName));
             $evalChanged = YES;
             break;
         case "stop":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht beendet."));
             }
             $eval->setStopdate(time());
             $eval->save();
             if ($eval->isError()) {
                 EvalCommon::createErrorReport($eval);
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde beendet."), $evalName));
             $evalChanged = YES;
             break;
         case "continue":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht fortgesetzt."));
             }
             $eval->setStopdate(NULL);
             $eval->setStartdate(time() - 500);
             $eval->save();
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde fortgesetzt."), $evalName));
             $evalChanged = YES;
             break;
         case "restart_request":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen."));
             }
             $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Die Evaluation <b>%s</b> wirklich zurücksetzen? Dabei werden alle bisher abgegebenen Antworten gelöscht!"), $evalName), "restart_request", $evalID, $showrangeID, $referer);
             break;
         case "restart_confirmed":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen."));
             }
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $eval->resetAnswers();
             $evalDB->removeUser($eval->getObjectID());
             $eval->setStartdate(NULL);
             $eval->setStopdate(NULL);
             $eval->save();
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde zurückgesetzt."), $evalName));
             $evalChanged = YES;
             break;
         case "restart_aborted":
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde nicht zurückgesetzt."), $evalName), "", "", "", $referer);
             break;
         case "copy_own_template":
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $newEval = $eval->duplicate();
             $newEval->setShared(NO);
             $newEval->save();
             if ($newEval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage <b>%s</b> wurde kopiert."), $evalName));
             break;
         case "delete_request":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht."));
             }
             $text = $eval->isTemplate() ? sprintf(_("Die Evaluationsvorlage <b>%s </b>wirklich löschen?"), $evalName) : sprintf(_("Die Evaluation <b>%s </b>wirklich löschen?"), $evalName);
             $safeguard .= $this->createSafeguard("ausruf", $text, "delete_request", $evalID, $showrangeID, $referer);
             break;
         case "delete_confirmed":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht."));
             }
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $eval->delete();
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $text = $eval->isTemplate() ? _("Die Evaluationsvorlage <b>%s</b> wurde gelöscht.") : _("Die Evaluation <b>%s</b> wurde gelöscht.");
             $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
             $evalChanged = YES;
             break;
         case "delete_aborted":
             $text = $eval->isTemplate() ? _("Die Evaluationsvorlage <b>%s</b> wurde nicht gelöscht.") : _("Die Evaluation <b>%s</b> wurde nicht gelöscht.");
             $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
             break;
         case "unlink_delete_aborted":
             $text = _("Die Evaluation <b>%s</b> wurde nicht verändert.");
             $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
             break;
         case "unlink_and_move":
             if ($no_permission_msg) {
                 return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht ausgehängt und zu den eigenen Evaluationsvorlagen verschoben."));
             }
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $eval->removeRangeIDs();
             $eval->setAuthorID($auth->auth["uid"]);
             $eval->resetAnswers();
             $evalDB->removeUser($eval->getObjectID());
             $eval->setStartdate(NULL);
             $eval->setStopdate(NULL);
             $eval->save();
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $text = _("Die Evaluation <b>%s</b> wurde aus allen Bereichen ausgehängt und zu den eigenen Evaluationsvorlagen verschoben.");
             $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
             break;
         case "created":
             $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation <b>%s</b> wurde angelegt."), $evalName));
             break;
         case "save2":
         case "save":
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $update_message = sprintf(_("Die Evaluation <b>%s</b> wurde mit den Veränderungen gespeichert."), $evalName);
             /* Timesettings ---------------------------------------------------- */
             if (Request::option("startMode")) {
                 switch (Request::option("startMode")) {
                     case "manual":
                         $startDate = NULL;
                         break;
                     case "timeBased":
                         $startDate = EvalCommon::date2timestamp(Request::int("startDay"), Request::int("startMonth"), Request::int("startYear"), Request::int("startHour"), Request::int("startMinute"));
                         break;
                     case "immediate":
                         $startDate = time() - 1;
                         break;
                 }
                 if ($no_permission_msg && $eval->getStartdate != $startDate) {
                     $time_msg = $no_permission_msg . "<br>" . _("Die Einstellungen zur Startzeit wurden nicht verändert.");
                 }
             }
             if (Request::option("stopMode")) {
                 switch (Request::option("stopMode")) {
                     case "manual":
                         $stopDate = NULL;
                         $timeSpan = NULL;
                         break;
                     case "timeBased":
                         $stopDate = EvalCommon::date2timestamp(Request::int("stopDay"), Request::int("stopMonth"), Request::int("stopYear"), Request::int("stopHour"), Request::int("stopMinute"));
                         $timeSpan = NULL;
                         break;
                     case "timeSpanBased":
                         $stopDate = NULL;
                         $timeSpan = Request::get("timeSpan");
                         break;
                 }
                 if ($no_permission_msg && ($eval->getStopdate != $stopDate && $eval->getTimespan != $timeSpan)) {
                     $time_msg = $time_msg ? $time_msg . "<br>" : $no_permission_msg;
                     $time_msg .= _("Die Einstellungen zur Endzeit wurden nicht verändert.");
                 }
             }
             /* ----------------------------------------------- end: timesettings */
             /* link eval to ranges --------------------------------------------- */
             $link_range_Array = Request::optionArray("link_range");
             if ($link_range_Array) {
                 $isTemplate = $eval->isTemplate();
                 if ($isTemplate) {
                     $newEval = $eval->duplicate();
                     if ($newEval->isError()) {
                         $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
                         return $safeguard;
                     }
                     $update_message = sprintf(_("Die Evaluationsvorlage <b>%s</b> wurde als Evaluation angelegt."), $evalName);
                     $newEval->setStartdate($startDate);
                     $newEval->setStopdate($stopDate);
                     $newEval->setTimespan($timeSpan);
                     $newEval->setShared(NO);
                 } else {
                     $newEval =& $eval;
                 }
                 $counter_linked = 0;
                 foreach ($link_range_Array as $link_rangeID => $v) {
                     if ($userid = get_userid($link_rangeID)) {
                         $link_rangeID = $userid;
                     }
                     $newEval->addRangeID($link_rangeID);
                     $counter_linked++;
                 }
                 if ($isTemplate) {
                     $newEval->save();
                 }
                 if ($newEval->isError()) {
                     $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Einhängen von Bereichen.") . EvalCommon::createErrorReport($newEval));
                     return $safeguard;
                 }
                 $message .= $message ? "<br>" : " ";
                 $message .= $counter_linked > 1 ? sprintf(_("Die Evaluation wurde in %s Bereiche eingehängt."), $counter_linked) : sprintf(_("Die Evaluation wurde in einen Bereich eingehängt."), $counter_linked);
             }
             /* ---------------------------------------- end: link eval to ranges */
             /* copy eval to ranges --------------------------------------------- */
             $copy_range_Array = Request::optionArray("copy_range");
             if (!empty($copy_range_Array)) {
                 $counter_copy = 0;
                 foreach ($copy_range_Array as $copy_rangeID => $v) {
                     if ($userid = get_userid($copy_rangeID)) {
                         $copy_rangeID = $userid;
                     }
                     $newEval = $eval->duplicate();
                     if (Request::option("startMode")) {
                         $newEval->setStartdate($startDate);
                     }
                     if (Request::get("stopMode")) {
                         $newEval->setStopdate($stopDate);
                         $newEval->setTimespan($timeSpan);
                     }
                     $newEval->setShared(NO);
                     $newEval->removeRangeIDs();
                     $evalDB->removeUser($newEval->getObjectID());
                     $newEval->addRangeID($copy_rangeID);
                     $newEval->save();
                     $counter_copy++;
                     if ($newEval->isError()) {
                         $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval));
                         return $safeguard;
                     }
                 }
                 $message .= $message ? "<br>" : " ";
                 $message .= $counter_copy > 1 ? sprintf(_("Die Evaluation wurde in %s Bereiche kopiert."), $counter_copy) : sprintf(_("Die Evaluation wurde in einen Bereich kopiert."), $counter_copy);
             }
             /* ------------------------------------------- end: copy eval to ranges */
             /* unlink ranges ------------------------------------------------------- */
             $remove_range_Array = Request::optionArray("remove_range");
             if (!empty($remove_range_Array)) {
                 /* if all rangeIDs will be removed, so ask if it should be deleted -- */
                 if (sizeof($remove_range_Array) == $eval->getNumberRanges()) {
                     $text = _("Sie wollen die Evaluation <b>%s</b> aus allen ihr zugeordneten Bereichen aushängen.<br>Soll die Evaluation gelöscht oder zu Ihren eigenen Evaluationsvorlagen verschoben werden?");
                     $safeguard .= $this->createSafeguard("ausruf", sprintf($text, $evalName), "unlink_delete_request", $evalID, $showrangeID, $referer);
                     $update_message = NULL;
                     return $safeguard;
                 }
                 /* -------------------------------- end: ask if it should be deleted */
                 $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval, YES);
                 $counter_no_permisson = 0;
                 if (is_array($no_permission_ranges)) {
                     foreach ($remove_range_Array as $remove_rangeID => $v) {
                         if ($userid = get_userid($remove_rangeID)) {
                             $remove_rangeID = $userid;
                         }
                         // no permisson to unlink this range
                         if (in_array($remove_rangeID, $no_permission_ranges)) {
                             $counter_no_permisson++;
                         }
                     }
                 }
                 // if there are no_permisson_ranges to unlink, return
                 if ($counter_no_permisson > 0) {
                     if ($counter_no_permisson == 1) {
                         $safeguard .= $this->createSafeguard("ausruf", _("Sie wollen die Evaluation aus einem Bereich aushängen, für den Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt."));
                     } else {
                         $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Sie wollen die Evaluation aus %d Bereichen aushängen, für die Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt."), $counter_no_permisson));
                     }
                     return $safeguard;
                 }
                 reset($remove_range_Array);
                 $counter_copy = 0;
                 foreach ($remove_range_Array as $remove_rangeID => $v) {
                     if ($userid = get_userid($remove_rangeID)) {
                         $remove_rangeID = $userid;
                     }
                     // the current range will be removed
                     if ($showrangeID == $remove_rangeID) {
                         $current_range_removed = 1;
                     }
                     $eval->removeRangeID($remove_rangeID);
                     $counter_copy++;
                 }
                 if ($eval->isError()) {
                     $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Aushängen von Bereichen.") . EvalCommon::createErrorReport($eval));
                     return $safeguard;
                 }
                 $message .= $message ? "<br>" : " ";
                 $message .= $counter_copy > 1 ? sprintf(_("Die Evaluation wurde aus %s Bereichen ausgehängt."), $counter_copy) : sprintf(_("Die Evaluation wurde aus einem Bereich ausgehängt."), $counter_copy);
                 if ($eval->getNumberRanges() == 0) {
                     $message .= $message ? "<br>" : "";
                     $message .= _("Sie ist nun keinem Bereich mehr zugeordnet und wurde zu den eigenen Evaluationsvorlagen verschoben.");
                     $eval->setStartdate(NULL);
                     $eval->setStopdate(NULL);
                     $evalDB->removeUser($eval->getObjectID());
                     if ($eval->isError()) {
                         $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval));
                         return $safeguard;
                     }
                 } else {
                     $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
                     $number_of_ranges = $eval->getNumberRanges();
                     if ($number_of_ranges == $no_permission_ranges) {
                         $return["msg"] = $this->createSafeguard("ausruf", $message . "<br>" . sprintf(_("Sie haben die Evaluation <b>%s</b> aus allen ihren Bereichen ausgehängt."), $evalName));
                         $return["option"] = DISCARD_OPENID;
                         $eval->save();
                         if ($eval->isError()) {
                             $safeguard = $this->createSafeguard("ausruf", _("Fehler beim Aushängen einer Evaluationen aus allen Bereichen auf die Sie Zugriff haben.") . EvalCommon::createErrorReport($newEval));
                             return $safeguard;
                         }
                         return $return;
                     }
                 }
             }
             if ($eval->isTemplate()) {
                 if (empty($link_range) && empty($copy_range) && empty($remove_range)) {
                     $update_message = sprintf(_("Es wurden keine Veränderungen an der Evaluationsvorlage <b>%s</b> gespeichert."), $evalName);
                 }
             } else {
                 // nothing changed
                 if (!Request::option('startMode') && !Request::option('stopMode') && empty($link_range) && empty($copy_range) && empty($remove_range)) {
                     $update_message = _("Es wurden keine Veränderungen gespeichert.");
                 }
                 // set new start date
                 if (Request::option("startMode") && !$time_msg) {
                     $eval->setStartDate($startDate);
                     if ($startDate != NULL && $startDate <= time() - 1) {
                         $message .= $message ? "<br>" : " ";
                         $message .= _("Die Evaluation wurde gestartet.");
                     }
                 }
                 // set new stop date
                 if (Request::get("stopMode") && !$time_msg) {
                     $eval->setStopDate($stopDate);
                     $eval->setTimeSpan($timeSpan);
                     if ($stopDate != NULL && $stopDate <= time() - 1 || $timeSpan != NULL && $eval->getStartdate() != NULL && $eval->getStartdate() + $timeSpan <= time() - 1) {
                         $message .= $message ? "<br>" : " ";
                         $message .= _("Die Evaluation wurde beendet.");
                     }
                 }
                 if ($eval->isError()) {
                     $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                     return $safeguard;
                 }
                 $eval->save();
             }
             $evalChanged = YES;
             // start/endtime aren't saved, because of ranges with no permisson
             if ($time_msg) {
                 $safeguard .= $this->createSafeguard("ausruf", $time_msg);
             }
             // everything is just fine so print the all messages
             if ($update_message && !$time_msg) {
                 $safeguard .= $this->createSafeguard("ok", $update_message . "<br>" . $message);
             } elseif ($time_msg && $message) {
                 $safeguard .= $this->createSafeguard("ok", $message);
             }
             break;
         case "search_showrange":
         case "search_range":
             $search = Request::get("search");
             if (EvaluationObjectDB::getGlobalPerm(YES) < 31) {
                 $safeguard = $this->createSafeguard("ausruf", _("Sie besitzen keine Berechtigung eine Suche durchzuführen."));
                 return $safeguard;
             }
             $results = $evalDB->search_range($search);
             if (empty($search)) {
                 $safeguard .= $this->createSafeguard("ausruf", _("Bitte einen Suchbegriff eingeben."), $search);
             } elseif (sizeof($results) == 0) {
                 $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Es wurde kein Bereich gefunden, der den Suchbegriff <b>%s</b> enthält."), htmlReady($search)), $search);
             } else {
                 $safeguard .= $this->createSafeguard("ok", sprintf(_("Es wurden %s Bereiche gefunden, die den Suchbegriff <b>%s</b> enthalten."), sizeof($results), htmlReady($search)), $search);
             }
             break;
         case "check_abort_creation":
             # check if the evaluation is new and not yet edited
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
             $abort_creation = false;
             if ($eval->getTitle() == _("Neue Evaluation") && $eval->getText() == "") {
                 # the evaluationen may be not edited yet ... so continue checking
                 $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
                 $number_of_childs = $eval->getNumberChildren();
                 $child = $eval->getNextChild();
                 if ($number_of_childs == 1 && $child && $child->getTitle() == _("Erster Gruppierungsblock") && $child->getChildren() == NULL && $child->getText() == "") {
                     $abort_creation = true;
                 }
             }
             if ($abort_creation != true) {
                 break;
             }
             # continue abort_creation
         # continue abort_creation
         case "abort_creation":
             $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
             $eval->delete();
             // error_ausgabe
             if ($eval->isError()) {
                 $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
                 return $safeguard;
             }
             $safeguard .= $this->createSafeguard("ok", _("Die Erstellung einer Evaluation wurde abgebrochen."), "", "", "", $referer);
             break;
         case "nothing":
             break;
         default:
             $safeguard .= $this->createSafeguard("ausruf", _("Fehler! Es wurde versucht, eine nicht vorhandene Aktion auszuführen."));
             break;
     }
     /* Send SMS when eval has been modified by admin/root ----------------- */
     if ($evalChanged && $eval->getAuthorID() != $auth->auth["uid"]) {
         $sms = new messaging();
         $sms->insert_message(sprintf(_("An Ihrer Evaluation \"%s\" wurden von %s Änderungen vorgenommen."), $eval->getTitle(), get_username($auth->auth["uid"])), get_username($eval->getAuthorID()), "____%system%____", FALSE, FALSE, "1");
     }
     /* ------------------------------------------------------ end: send SMS */
     // the current range has been removed from the eval
     if ($current_range_removed) {
         $return["msg"] = $safeguard;
         $return["option"] = DISCARD_OPENID;
         return $return;
     } else {
         return $safeguard;
     }
 }
コード例 #20
0
ファイル: tasks.php プロジェクト: ratbird/hope
    /**
     * Performs a bulk operation on a set of tasks. Operation can be either
     * activating, deactivating or deleting.
     *
     * @param int    $page Return to this page afterwarsd (optional)
     */
    public function bulk_action($page = 1)
    {
        $action = Request::option('action');
        $ids    = Request::optionArray('ids');
        $tasks  = CronjobTask::findMany($ids);

        if ($action === 'activate') {
            $tasks = array_filter($tasks, function ($item) { return !$item->active; });
            foreach ($tasks as $task) {
                $task->active = 1;
                $task->store();
            }

            $n = count($tasks);
            $message = sprintf(ngettext('%u Aufgabe wurde aktiviert.', '%u Aufgaben wurden aktiviert.', $n), $n);
            PageLayout::postMessage(MessageBox::success($message));
        } else if ($action === 'deactivate') {
            $tasks = array_filter($tasks, function ($item) { return $item->active; });
            foreach ($tasks as $task) {
                $task->active = 0;
                $task->store();
            }

            $n = count($tasks);
            $message = sprintf(ngettext('%u Aufgabe wurde deaktiviert.', '%u Aufgaben wurden deaktiviert.', $n), $n);
            PageLayout::postMessage(MessageBox::success($message));
        } else if ($action === 'delete') {
            foreach ($tasks as $task) {
                $task->delete();
            }

            $n = count($tasks);
            $message = sprintf(ngettext('%u Aufgabe wurde gelöscht.', '%u Aufgaben wurden gelöscht.', $n), $n);
            PageLayout::postMessage(MessageBox::success($message));
        }

        $this->redirect('admin/cronjobs/tasks/index/' . $page);
    }
コード例 #21
0
ファイル: deputies.php プロジェクト: ratbird/hope
 /**
  * Stores the deputy settings of a user.
  */
 public function store_action()
 {
     $this->check_ticket();
     $delete = Request::optionArray('delete');
     if (count($delete) > 0) {
         $deleted = deleteDeputy($delete, $this->user->user_id);
         if ($deleted) {
             $this->reportSuccess($deleted == 1 ? _('Die Vertretung wurde entfernt.') : _('Es wurden %s Vertretungen entfernt.'), $deleted);
         } else {
             $this->reportError(_('Fehler beim Entfernen der Vertretung(en).'));
         }
     }
     if ($this->edit_about_enabled) {
         $deputies = getDeputies($this->user->user_id, true);
         $changes = Request::intArray('edit_about');
         $success = true;
         $changed = 0;
         foreach ($changes as $id => $state) {
             if (!in_array($id, $deleted) && $state != $deputies[$id]['edit_about']) {
                 $success = $success and setDeputyHomepageRights($id, $this->user->user_id, $state) > 0;
                 $changed += 1;
             }
         }
         if ($success && $changed > 0) {
             $this->reportSuccess(_('Die Einstellungen wurden gespeichert.'));
         } else {
             if ($changed > 0) {
                 $this->reportError(_('Fehler beim Speichern der Einstellungen.'));
             }
         }
     }
     $this->redirect('settings/deputies');
 }
コード例 #22
0
ファイル: holidays.php プロジェクト: ratbird/hope
 /**
  * This method deletes a holiday or a bundle of holidays.
  *
  * @param string $id Id of the holiday (or 'bulk' for a bulk operation)
  */
 public function delete_action($id)
 {
     $ids = $id === 'bulk' ? Request::optionArray('ids') : array($id);
     if (count($ids)) {
         $holidays = SemesterHoliday::findMany($ids);
         foreach ($holidays as $holiday) {
             $holiday->delete();
         }
         PageLayout::postMessage(MessageBox::success(_('Die Ferien wurden erfolgreich gelöscht')));
     }
     $this->redirect('admin/holidays');
 }
コード例 #23
0
ファイル: files.php プロジェクト: ratbird/hope
 /**
  * General handler for bulk actions. Support the following actions:
  *
  * - Download
  * - Move
  * - Copy
  * - Delete
  *
  * @param String $folder_id Directory entry id of the origin folder
  */
 public function bulk_action($folder_id, $page = 1)
 {
     $ids = Request::optionArray('ids');
     FileHelper::checkAccess($ids);
     if (empty($ids)) {
         $this->redirect('document/files/index/' . $folder_id . '/' . $page);
     } else {
         if (Request::submitted('download')) {
             $this->flash['ids'] = $ids;
             $this->redirect('document/download/flashed');
         } else {
             if (Request::submitted('move')) {
                 $this->flash['move-ids'] = $ids;
                 $this->redirect('document/files/move/flashed/' . $folder_id);
             } else {
                 if (Request::submitted('copy')) {
                     $this->flash['copy-ids'] = $ids;
                     $this->redirect('document/files/copy/flashed/' . $folder_id);
                 } else {
                     if (Request::submitted('delete')) {
                         if (Request::submitted('yes')) {
                             if ($folder_id === $this->context_id) {
                                 $dir = new RootDirectory($this->context_id);
                             } else {
                                 $entry = new DirectoryEntry($folder_id);
                                 $dir = $entry->file;
                             }
                             foreach ($ids as $id) {
                                 $entry = new DirectoryEntry($id);
                                 $dir->unlink($entry->name);
                             }
                             PageLayout::postMessage(MessageBox::success(_('Die Dateien wurden erfolgreich gelöscht.')));
                         } elseif (!Request::submitted('no')) {
                             $question = createQuestion2(_('Sollen die markierten Dateien wirklich gelöscht werden?'), array('delete' => 'true', 'ids' => $ids), array(), $this->url_for('document/files/bulk/' . $folder_id));
                             $this->flash['question'] = $question;
                             $this->flash['marked-ids'] = $ids;
                         }
                         $this->redirect('document/files/index/' . $folder_id . '/' . $page);
                     }
                 }
             }
         }
     }
 }
コード例 #24
0
ファイル: studygroup.php プロジェクト: ratbird/hope
 /**
  * updates studygroups with respect to the corresponding form data
  *
  * @param string id of a studygroup
  *
  * @return void
  */
 function update_action($id)
 {
     global $perm;
     // if we are permitted to edit the studygroup get some data...
     if ($perm->have_studip_perm('dozent', $id)) {
         $errors = array();
         $admin = $perm->have_studip_perm('admin', $id);
         $founders = StudygroupModel::getFounders($id);
         $sem = new Seminar($id);
         $sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$sem->status]['class']];
         CSRFProtection::verifyUnsafeRequest();
         if (Request::get('abort_deactivate')) {
             // let's do nothing and go back to the studygroup
             return $this->redirect('course/studygroup/edit/' . $id);
         } else {
             if (Request::get('really_deactivate')) {
                 $modules = Request::optionArray('deactivate_modules');
                 $plugins = Request::optionArray('deactivate_plugins');
                 // really deactive modules
                 // 1. Modules
                 if (is_array($modules)) {
                     $mods = new Modules();
                     $admin_mods = new AdminModules();
                     $bitmask = $sem->modules;
                     foreach ($modules as $key) {
                         $module_name = $sem_class->getSlotModule($key);
                         if ($module_name && ($sem_class->isModuleMandatory($module_name) || !$sem_class->isModuleAllowed($module_name))) {
                             continue;
                         }
                         $mods->clearBit($bitmask, $mods->registered_modules[$key]["id"]);
                         $methodDeactivate = "module" . ucfirst($key) . "Deactivate";
                         if (method_exists($admin_mods, $methodDeactivate)) {
                             $admin_mods->{$methodDeactivate}($sem->id);
                             $studip_module = $sem_class->getModule($key);
                             if (is_a($studip_module, "StandardPlugin")) {
                                 PluginManager::getInstance()->setPluginActivated($studip_module->getPluginId(), $id, false);
                             }
                         }
                     }
                     $sem->modules = $bitmask;
                     $sem->store();
                 }
                 // 2. Plugins
                 if (is_array($plugins)) {
                     $plugin_manager = PluginManager::getInstance();
                     $available_plugins = StudygroupModel::getInstalledPlugins();
                     foreach ($plugins as $class) {
                         $plugin = $plugin_manager->getPlugin($class);
                         // Deaktiviere Plugin
                         if ($available_plugins[$class] && !$sem_class->isModuleMandatory($class) && !$sem_class->isSlotModule($class)) {
                             $plugin_manager->setPluginActivated($plugin->getPluginId(), $id, false);
                         }
                     }
                 }
                 // Success message
                 $this->flash['success'] .= _("Inhaltselement(e) erfolgreich deaktiviert.");
                 return $this->redirect('course/studygroup/edit/' . $id);
             } else {
                 if (Request::submitted('replace_founder')) {
                     // retrieve old founder
                     $old_dozent = current(StudygroupModel::getFounder($id));
                     // remove old founder
                     StudygroupModel::promote_user($old_dozent['uname'], $id, 'tutor');
                     // add new founder
                     $new_founder = Request::option('choose_founder');
                     StudygroupModel::promote_user(get_username($new_founder), $id, 'dozent');
                     //checks
                 } else {
                     // test whether we have a group name...
                     if (!Request::get('groupname')) {
                         $errors[] = _("Bitte Gruppennamen angeben");
                         //... if so, test if this is not taken by another group
                     } else {
                         $query = "SELECT 1 FROM seminare WHERE name = ? AND Seminar_id != ?";
                         $statement = DBManager::get()->prepare($query);
                         $statement->execute(array(Request::get('groupname'), $id));
                         if ($statement->fetchColumn()) {
                             $errors[] = _("Eine Veranstaltung/Studiengruppe mit diesem Namen existiert bereits. Bitte wählen Sie einen anderen Namen");
                         }
                     }
                     if (count($errors)) {
                         $this->flash['errors'] = $errors;
                         $this->flash['edit'] = true;
                         // Everything seems fine, let's update the studygroup
                     } else {
                         $sem->name = Request::get('groupname');
                         // seminar-class quotes itself
                         $sem->description = Request::get('groupdescription');
                         // seminar-class quotes itself
                         $sem->read_level = 1;
                         $sem->write_level = 1;
                         $sem->visible = 1;
                         if (Request::get('groupaccess') == 'all') {
                             $sem->admission_prelim = 0;
                         } else {
                             $sem->admission_prelim = 1;
                             if (Config::get()->STUDYGROUPS_INVISIBLE_ALLOWED && Request::get('groupaccess') == 'invisible') {
                                 $sem->visible = 0;
                             }
                             $sem->admission_prelim_txt = _("Die ModeratorInnen der Studiengruppe können Ihren Aufnahmewunsch bestätigen oder ablehnen. Erst nach Bestätigung erhalten Sie vollen Zugriff auf die Gruppe.");
                         }
                         // get the current bitmask
                         $mods = new Modules();
                         $admin_mods = new AdminModules();
                         $bitmask = $sem->modules;
                         // de-/activate modules
                         $available_modules = StudygroupModel::getInstalledModules();
                         $orig_modules = $mods->getLocalModules($sem->id, "sem");
                         $active_plugins = Request::getArray("groupplugin");
                         $deactivate_modules = array();
                         foreach (array_keys($available_modules) as $key) {
                             $module_name = $sem_class->getSlotModule($key);
                             if (!$module_name || $module_name && ($sem_class->isModuleMandatory($module_name) || !$sem_class->isModuleAllowed($module_name))) {
                                 continue;
                             }
                             if (!$module_name) {
                                 $module_name = $key;
                             }
                             if ($active_plugins[$module_name]) {
                                 // activate modules
                                 $mods->setBit($bitmask, $mods->registered_modules[$key]["id"]);
                                 if (!$orig_modules[$key]) {
                                     $methodActivate = "module" . ucfirst($key) . "Activate";
                                     if (method_exists($admin_mods, $methodActivate)) {
                                         $admin_mods->{$methodActivate}($sem->id);
                                         $studip_module = $sem_class->getModule($key);
                                         if (is_a($studip_module, "StandardPlugin")) {
                                             PluginManager::getInstance()->setPluginActivated($studip_module->getPluginId(), $id, true);
                                         }
                                     }
                                 }
                             } else {
                                 // prepare for deactivation
                                 // (user will have to confirm)
                                 if ($orig_modules[$key]) {
                                     $deactivate_modules[] = $key;
                                 }
                             }
                         }
                         $this->flash['deactivate_modules'] = $deactivate_modules;
                         $sem->modules = $bitmask;
                         $sem->store();
                         // de-/activate plugins
                         $available_plugins = StudygroupModel::getInstalledPlugins();
                         $plugin_manager = PluginManager::getInstance();
                         $deactivate_plugins = array();
                         foreach ($available_plugins as $key => $name) {
                             $plugin = $plugin_manager->getPlugin($key);
                             $plugin_id = $plugin->getPluginId();
                             if ($active_plugins[$key] && $name && $sem_class->isModuleAllowed($key)) {
                                 $plugin_manager->setPluginActivated($plugin_id, $id, true);
                             } else {
                                 if ($plugin_manager->isPluginActivated($plugin_id, $id) && !$sem_class->isSlotModule($key)) {
                                     $deactivate_plugins[$plugin_id] = $key;
                                 }
                             }
                         }
                         $this->flash['deactivate_plugins'] = $deactivate_plugins;
                     }
                 }
             }
         }
     }
     if (!$this->flash['errors'] && !$deactivate_modules && !$deactivate_plugins) {
         // Everything seems fine
         $this->flash['success'] = _("Die Änderungen wurden erfolgreich übernommen.");
     }
     // let's go to the studygroup
     $this->redirect('course/studygroup/edit/' . $id);
 }
コード例 #25
0
ファイル: profilemodules.php プロジェクト: ratbird/hope
 /**
  * Updates the activation status of user's homepage plugins.
  */
 public function update_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     $manager = PluginManager::getInstance();
     $modules = Request::optionArray('modules');
     $success = null;
     // Plugins
     foreach ($this->plugins as $plugin) {
         // Check local activation status.
         $id = $plugin->getPluginId();
         $state_before = $manager->isPluginActivatedForUser($id, $this->user_id);
         $state_after = in_array($id, $modules);
         if ($state_before !== $state_after) {
             $updated = $manager->setPluginActivated($id, $this->user_id, $state_after, 'user');
             $success = $success || $updated;
         }
     }
     if ($success === true) {
         $message = MessageBox::success(_('Ihre Änderungen wurden gespeichert.'));
     } elseif ($success === false) {
         $message = MessageBox::error(_('Ihre Änderungen konnten nicht gespeichert werden.'));
     }
     if ($message) {
         PageLayout::postMessage($message);
     }
     $this->redirect($this->url_for('profilemodules/index', array('username' => $this->username)));
 }
コード例 #26
0
ファイル: RequestTest.php プロジェクト: ratbird/hope
 public function testOptionArrayParam()
 {
     $this->assertSame(Request::optionArray('null'), array());
     $this->assertSame(Request::optionArray('a'), array());
     $this->assertSame(Request::optionArray('v1'), array('1'));
     $this->assertSame(Request::optionArray('v2'), array(1 => 'two', 2 => 'thr33'));
 }
コード例 #27
0
ファイル: index.php プロジェクト: ratbird/hope
 /**
  * the main action for the forum. May be called with a topic_id to be displayed
  * and optionally the page to display
  * 
  * @param type $topic_id the topic to display, defaults to the main
  *                       view of the current seminar
  * @param type $page the page to be displayed (for thread-view)
  */
 function index_action($topic_id = null, $page = null)
 {
     $nav = Navigation::getItem('course/forum2');
     $nav->setImage(Icon::create('forum', 'info'));
     Navigation::activateItem('course/forum2/index');
     // check, if the root entry is present
     ForumEntry::checkRootEntry($this->getId());
     /* * * * * * * * * * * * * * * * * * *
      * V A R I A B L E N   F U E L L E N *
      * * * * * * * * * * * * * * * * * * */
     $this->section = 'index';
     $this->topic_id = $topic_id ? $topic_id : $this->getId();
     $this->constraint = ForumEntry::getConstraints($this->topic_id);
     // check if there has been submitted an invalid id and use seminar_id in case
     if (!$this->constraint) {
         $this->topic_id = $this->getId();
         $this->constraint = ForumEntry::getConstraints($this->topic_id);
     }
     $this->highlight_topic = Request::option('highlight_topic', null);
     // set page to which we shall jump
     if ($page) {
         ForumHelpers::setPage($page);
     }
     // we do not crawl deeper than level 2, we show a page chooser instead
     if ($this->constraint['depth'] > 2) {
         ForumHelpers::setPage(ForumEntry::getPostingPage($this->topic_id, $this->constraint));
         $path = ForumEntry::getPathToPosting($this->topic_id);
         array_shift($path);
         array_shift($path);
         $path_element = array_shift($path);
         $this->child_topic = $this->topic_id;
         $this->topic_id = $path_element['id'];
         $this->constraint = ForumEntry::getConstraints($this->topic_id);
     }
     // check if the topic_id matches the currently selected seminar
     ForumPerm::checkTopicId($this->getId(), $this->topic_id);
     /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
      * B E R E I C H E / T H R E A D S / P O S T I N G S   L A D E N *
      * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
     // load list of areas for use in thread-movement
     if (ForumPerm::has('move_thread', $this->getId())) {
         $this->areas = ForumEntry::getList('flat', $this->getId());
     }
     if ($this->constraint['depth'] > 1) {
         // POSTINGS
         $list = ForumEntry::getList('postings', $this->topic_id);
         if (!empty($list['list'])) {
             $this->postings = $list['list'];
             $this->number_of_entries = $list['count'];
         }
     } else {
         if ($this->constraint['depth'] == 0) {
             // BEREICHE
             $list = ForumEntry::getList('area', $this->topic_id);
         } else {
             $list = ForumEntry::getList('list', $this->topic_id);
         }
         if ($this->constraint['depth'] == 0) {
             // BEREICHE
             $new_list = array();
             // iterate over all categories and add the belonging areas to them
             foreach ($categories = ForumCat::getListWithAreas($this->getId(), false) as $category) {
                 if ($category['topic_id']) {
                     $new_list[$category['category_id']][$category['topic_id']] = $list['list'][$category['topic_id']];
                     unset($list['list'][$category['topic_id']]);
                 } else {
                     if (ForumPerm::has('add_area', $this->seminar_id)) {
                         $new_list[$category['category_id']] = array();
                     }
                 }
                 $this->categories[$category['category_id']] = $category['entry_name'];
             }
             if (!empty($list['list'])) {
                 // append the remaining entries to the standard category
                 $new_list[$this->getId()] = array_merge((array) $new_list[$this->getId()], $list['list']);
             }
             // check, if there are any orphaned entries
             foreach ($new_list as $key1 => $list_item) {
                 foreach ($list_item as $key2 => $contents) {
                     if (empty($contents)) {
                         // remove the orphaned entry from the list and from the database
                         unset($new_list[$key1][$key2]);
                         ForumCat::removeArea($key2);
                     }
                 }
             }
             $this->list = $new_list;
         } else {
             if ($this->constraint['depth'] == 1) {
                 // THREADS
                 if (!empty($list['list'])) {
                     $this->list = array($list['list']);
                 }
             }
         }
         $this->number_of_entries = $list['count'];
     }
     // set the visit-date and get the stored last_visitdate
     $this->visitdate = ForumVisit::getLastVisit($this->getId());
     $this->seminar_id = $this->getId();
     // highlight text if passed some words to highlight
     if (Request::getArray('highlight')) {
         $this->highlight = Request::optionArray('highlight');
     }
     if (($this->edit_posting = Request::get('edit_posting', null)) && !ForumPerm::hasEditPerms($this->edit_posting)) {
         $this->edit_posting = null;
     }
 }
コード例 #28
0
ファイル: evaluate_values.php プロジェクト: ratbird/hope
        if (is_array($db_requests)) foreach ($db_requests as $val) {
            $_SESSION['resources_data']["requests_working_on"][] = array("request_id" => $val['request_id'], "closed" => FALSE);
            $_SESSION['resources_data']["requests_open"][$val['request_id']] = TRUE;
        }

    }
    if (is_array($_SESSION['resources_data']['requests_open']) && count($_SESSION['resources_data']['requests_open'])){
        $_SESSION['resources_data']["view"] = "edit_request";
        $view = $_SESSION['resources_data']["view"];
        $new_session_started = TRUE;
    } else {
        $_SESSION['resources_data']["view"] = $view = "requests_start";
        $msg->addMsg(41);
    }
}
$selected_resource_id = Request::optionArray('selected_resource_id');
if (is_array($selected_resource_id)) {
    foreach ($selected_resource_id as $key=>$val) {
        $_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["selected_resources"][$key] = $val;
    }
}

// save the assigments in db
if (Request::submitted('save_state')) {
    require_once ($RELATIVE_PATH_RESOURCES."/lib/RoomRequest.class.php");
    require_once ($RELATIVE_PATH_RESOURCES."/lib/VeranstaltungResourcesAssign.class.php");
    require_once ("lib/classes/Seminar.class.php");

    $reqObj = new RoomRequest($_SESSION['resources_data']["requests_working_on"][$_SESSION['resources_data']["requests_working_pos"]]["request_id"]);
    $semObj = Seminar::GetInstance($reqObj->getSeminarId());
    $semResAssign = new VeranstaltungResourcesAssign($semObj->getId());
コード例 #29
0
ファイル: calendar.php プロジェクト: ratbird/hope
 protected function storeEventData(CalendarEvent $event, SingleCalendar $calendar)
 {
     if (Request::int('isdayevent')) {
         $dt_string = Request::get('start_date') . ' 00:00:00';
     } else {
         $dt_string = Request::get('start_date') . ' ' . Request::int('start_hour') . ':' . Request::int('start_minute');
     }
     $event->setStart($this->parseDateTime($dt_string));
     if (Request::int('isdayevent')) {
         $dt_string = Request::get('end_date') . ' 23:59:59';
     } else {
         $dt_string = Request::get('end_date') . ' ' . Request::int('end_hour') . ':' . Request::int('end_minute');
     }
     $event->setEnd($this->parseDateTime($dt_string));
     if ($event->getStart() > $event->getEnd()) {
         $messages[] = _('Die Startzeit muss vor der Endzeit liegen.');
     }
     if (Request::isXhr()) {
         $event->setTitle(studip_utf8decode(Request::get('summary', '')));
         $event->event->description = studip_utf8decode(Request::get('description', ''));
         $event->setUserDefinedCategories(studip_utf8decode(Request::get('categories', '')));
         $event->event->location = studip_utf8decode(Request::get('location', ''));
     } else {
         $event->setTitle(Request::get('summary'));
         $event->event->description = Request::get('description', '');
         $event->setUserDefinedCategories(Request::get('categories', ''));
         $event->event->location = Request::get('location', '');
     }
     $event->event->category_intern = Request::int('category_intern', 1);
     $event->setAccessibility(Request::option('accessibility', 'PRIVATE'));
     $event->setPriority(Request::int('priority', 0));
     if (!$event->getTitle()) {
         $messages[] = _('Es muss eine Zusammenfassung angegeben werden.');
     }
     $rec_type = Request::option('recurrence', 'single');
     $expire = Request::option('exp_c', 'never');
     $rrule = array('linterval' => null, 'sinterval' => null, 'wdays' => null, 'month' => null, 'day' => null, 'rtype' => 'SINGLE', 'count' => null, 'expire' => null);
     if ($expire == 'count') {
         $rrule['count'] = Request::int('exp_count', 10);
     } else {
         if ($expire == 'date') {
             if (Request::isXhr()) {
                 $exp_date = studip_utf8decode(Request::get('exp_date'));
             } else {
                 $exp_date = Request::get('exp_date');
             }
             $exp_date = $exp_date ?: strftime('%x', time());
             $rrule['expire'] = $this->parseDateTime($exp_date . ' 12:00');
         }
     }
     switch ($rec_type) {
         case 'daily':
             if (Request::option('type_daily', 'day') == 'day') {
                 $rrule['linterval'] = Request::int('linterval_d', 1);
                 $rrule['rtype'] = 'DAILY';
             } else {
                 $rrule['linterval'] = 1;
                 $rrule['wdays'] = '12345';
                 $rrule['rtype'] = 'WEEKLY';
             }
             break;
         case 'weekly':
             $rrule['linterval'] = Request::int('linterval_w', 1);
             $rrule['wdays'] = implode('', Request::intArray('wdays', array(strftime('%u', $event->getStart()))));
             $rrule['rtype'] = 'WEEKLY';
             break;
         case 'monthly':
             if (Request::option('type_m', 'day') == 'day') {
                 $rrule['linterval'] = Request::int('linterval_m1', 1);
                 $rrule['day'] = Request::int('day_m', strftime('%e', $event->getStart()));
                 $rrule['rtype'] = 'MONTHLY';
             } else {
                 $rrule['linterval'] = Request::int('linterval_m2', 1);
                 $rrule['sinterval'] = Request::int('sinterval_m', 1);
                 $rrule['wdays'] = Request::int('wday_m', strftime('%u', $event->getStart()));
                 $rrule['rtype'] = 'MONTHLY';
             }
             break;
         case 'yearly':
             if (Request::option('type_y', 'day') == 'day') {
                 $rrule['linterval'] = 1;
                 $rrule['day'] = Request::int('day_y', strftime('%e', $event->getStart()));
                 $rrule['month'] = Request::int('month_y1', date('n', $event->getStart()));
                 $rrule['rtype'] = 'YEARLY';
             } else {
                 $rrule['linterval'] = 1;
                 $rrule['sinterval'] = Request::int('sinterval_y', 1);
                 $rrule['wdays'] = Request::int('wday_y', strftime('%u', $event->getStart()));
                 $rrule['month'] = Request::int('month_y2', date('n', $event->getStart()));
                 $rrule['rtype'] = 'YEARLY';
             }
             break;
     }
     if (sizeof($messages)) {
         PageLayout::postMessage(MessageBox::error(_('Bitte Eingaben korrigieren'), $messages));
         return false;
     } else {
         $event->setRecurrence($rrule);
         $exceptions = array_diff(Request::getArray('exc_dates'), Request::getArray('del_exc_dates'));
         $event->setExceptions($this->parseExceptions($exceptions));
         // if this is a group event, store event in the calendars of each attendee
         if (get_config('CALENDAR_GROUP_ENABLE')) {
             $attendee_ids = Request::optionArray('attendees');
             return $calendar->storeEvent($event, $attendee_ids);
         } else {
             return $calendar->storeEvent($event);
         }
     }
 }