Example #1
0
 /**
  * Determines if a vote should show its result
  *
  * @param StudipVote $vote the vote to check
  * @return boolean true if result should be shown
  */
 public function showResult($vote)
 {
     if (Request::submitted('change') && $vote->changeable) {
         return false;
     }
     return $vote->userVoted() || in_array($vote->id, Request::getArray('preview'));
 }
Example #2
0
 public function overview_action()
 {
     Navigation::activateItem("/admin/locations/sem_classes");
     if (count($_POST) && Request::submitted('delete') && Request::get("delete_sem_class")) {
         $sem_class = $GLOBALS['SEM_CLASS'][Request::get("delete_sem_class")];
         if ($sem_class->delete()) {
             PageLayout::postMessage(MessageBox::success(_("Veranstaltungskategorie wurde gelöscht.")));
             $GLOBALS['SEM_CLASS'] = SemClass::refreshClasses();
         }
     }
     if (count($_POST) && Request::get("add_name")) {
         $statement = DBManager::get()->prepare("SELECT 1 FROM sem_classes WHERE name = :name");
         $statement->execute(array('name' => Request::get("add_name")));
         $duplicate = $statement->fetchColumn();
         if ($duplicate) {
             $message = sprintf(_("Es existiert bereits eine Veranstaltungskategorie mit dem Namen \"%s\""), Request::get("add_name"));
             PageLayout::postMessage(MessageBox::error($message));
             $this->redirect('admin/sem_classes/overview');
         } else {
             $statement = DBManager::get()->prepare("INSERT INTO sem_classes SET name = :name, mkdate = UNIX_TIMESTAMP(), chdate = UNIX_TIMESTAMP() " . "");
             $statement->execute(array('name' => Request::get("add_name")));
             $id = DBManager::get()->lastInsertId();
             if (Request::get("add_like")) {
                 $sem_class = clone $GLOBALS['SEM_CLASS'][Request::get("add_like")];
                 $sem_class->set('name', Request::get("add_name"));
                 $sem_class->set('id', $id);
                 $sem_class->store();
             }
             $this->redirect(URLHelper::getURL($this->url_for('admin/sem_classes/details'), array('id' => $id)));
             PageLayout::postMessage(MessageBox::success(_("Veranstaltungskategorie wurde erstellt.")));
             $GLOBALS['SEM_CLASS'] = SemClass::refreshClasses();
         }
     }
 }
Example #3
0
 public function add_new_host_action()
 {
     PageLayout::setTitle(_("Neue Lernmaterialien einstellen"));
     if (Request::submitted("nothanx")) {
         $_SESSION['Lernmarktplatz_no_thanx'] = true;
         $this->redirect("admin/hosts");
     } elseif (Request::isPost()) {
         $host = LernmarktplatzHost::findOneByUrl(trim(Request::get("url")));
         if (!$host) {
             $host = new LernmarktplatzHost();
             $host['url'] = trim(Request::get("url"));
             $host['last_updated'] = time();
             $host->fetchPublicKey();
             if ($host['public_key']) {
                 $host->store();
                 PageLayout::postMessage(MessageBox::success(_("Server wurde gefunden und hinzugefügt.")));
             } else {
                 PageLayout::postMessage(MessageBox::error(_("Server ist nicht erreichbar oder hat die Anfrage abgelehnt.")));
             }
         } else {
             $host->fetchPublicKey();
             PageLayout::postMessage(MessageBox::info(_("Server ist schon in Liste.")));
         }
         $this->redirect("admin/hosts");
     }
 }
Example #4
0
 /**
  * show and search log events
  */
 function show_action()
 {
     $this->action_id = Request::option('action_id');
     $this->object_id = Request::option('object_id');
     $this->log_actions = $this->event_log->get_used_log_actions();
     $this->types = $this->event_log->get_object_types();
     // restrict log events to object scope
     if (Request::get('search') && Request::get('search') != '') {
         $this->type = Request::get('type');
         $this->search = Request::get('search');
         $objects = $this->event_log->find_objects($this->type, $this->search, $this->action_id);
         if (count($objects) > 0) {
             $this->objects = $objects;
         } else {
             $this->error_msg = _('Kein passendes Objekt gefunden.');
         }
     }
     // find all matching log events
     if (Request::get('search') === '' || isset($this->object_id)) {
         $this->start = (int) Request::int('start');
         $this->format = Request::quoted('format');
         $this->num_entries = $this->event_log->count_log_events($this->action_id, $this->object_id);
         if (Request::get('back') || Request::submitted('back')) {
             $this->start = max(0, $this->start - 50);
         } else {
             if (Request::get('forward') || Request::submitted('forward')) {
                 $this->start = min($this->num_entries, $this->start + 50);
             }
         }
         $this->log_events = $this->event_log->get_log_events($this->action_id, $this->object_id, $this->start);
     }
 }
Example #5
0
 /**
  * Index displays and updates
  */
 function index_action()
 {
     /*
      * Updaterequest
      */
     if (Request::submitted('save')) {
         if ($rule = Request::get('aux_data')) {
             $this->course->aux_lock_rule = $rule;
             $this->course->aux_lock_rule_forced = Request::get('forced') ?: 0;
         } else {
             // If no rule is set we cant force it
             $this->course->aux_lock_rule = null;
             $this->course->aux_lock_rule_forced = 0;
         }
         // purge data
         if (Request::submitted('delete')) {
             $stmt = DBManager::get()->prepare('DELETE FROM datafields_entries WHERE sec_range_id = ?');
             $stmt->execute(array($this->course->id));
         }
         $this->course->store();
     }
     // Fetch data
     $stmt = DBManager::get()->prepare('SELECT COUNT(*) FROM datafields_entries WHERE sec_range_id = ?');
     $stmt->execute(array($this->course->id));
     $this->count = $stmt->fetchColumn();
     $this->list = AuxLockRule::findBySQL('1=1');
 }
 /**
  * Initialize a new instance of the plugin.
  */
 function __construct()
 {
     parent::__construct();
     if (Config::get()->WYSIWYG && is_object($GLOBALS['user'])) {
         if (strpos($_SERVER['REQUEST_URI'], 'dispatch.php/settings/general') !== false) {
             if (Request::submitted('forced_language')) {
                 $GLOBALS['user']->cfg->store('WYSIWYG_DISABLE', Request::submitted('wysiwyg_user_config'));
             }
             $snippet = '
             <tr>
                 <td>
                     <label for="wysiwyg_user_config">
                         WYSIWYG Editor ausschalten<br>
                         <dfn id="cookie_auth_token_description">
                             Mit dieser Einstellung können Sie den Stud.IP WYSIWYG Editor ausschalten. Dadurch müssen Sie ggf. Texte in HTML schreiben.
                         </dfn>
                     </label>
                 </td>
                 <td>
                     <input type="checkbox" value="1" aria-describedby="wysiwyg_user_config" id="wysiwyg_user_config" name="wysiwyg_user_config" ' . ($GLOBALS['user']->cfg->WYSIWYG_DISABLE ? 'checked' : '') . '>
                 </td>
             </tr>';
             $snippet = jsready($snippet, 'script-double');
             PageLayout::addHeadElement('script', array('type' => 'text/javascript'), "jQuery(function (\$) {\$('#main_content tbody tr').first().after('{$snippet}');});");
         }
         if (!(Config::get()->WYSIWYG = !$GLOBALS['user']->cfg->WYSIWYG_DISABLE)) {
             $old_packages = array_flip(PageLayout::getSqueezePackages());
             unset($old_packages['wysiwyg']);
             call_user_func_array('PageLayout::setSqueezePackages', array_values(array_flip($old_packages)));
         }
     }
 }
Example #7
0
 public function edit_action($material_id = null)
 {
     $this->material = new LernmarktplatzMaterial($material_id);
     Pagelayout::setTitle($this->material->isNew() ? _("Neues Material hochladen") : _("Material bearbeiten"));
     if ($this->material['user_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) {
         throw new AccessDeniedException();
     }
     if (Request::submitted("delete") && Request::isPost()) {
         $this->material->pushDataToIndexServers("delete");
         $this->material->delete();
         PageLayout::postMessage(MessageBox::success(_("Ihr Material wurde gelöscht.")));
         $this->redirect("market/overview");
     } elseif (Request::isPost()) {
         $was_new = $this->material->setData(Request::getArray("data"));
         $this->material['user_id'] = $GLOBALS['user']->id;
         $this->material['host_id'] = null;
         $this->material['license'] = "CC BY 4.0";
         if ($_FILES['file']['tmp_name']) {
             $this->material['content_type'] = $_FILES['file']['type'];
             if (in_array($this->material['content_type'], array("application/x-zip-compressed", "application/zip", "application/x-zip"))) {
                 $tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_folder_" . md5(uniqid());
                 mkdir($tmp_folder);
                 unzip_file($_FILES['file']['tmp_name'], $tmp_folder);
                 $this->material['structure'] = $this->getFolderStructure($tmp_folder);
                 rmdirr($tmp_folder);
             } else {
                 $this->material['structure'] = null;
             }
             $this->material['filename'] = $_FILES['file']['name'];
             move_uploaded_file($_FILES['file']['tmp_name'], $this->material->getFilePath());
         }
         if ($_FILES['image']['tmp_name']) {
             $this->material['front_image_content_type'] = $_FILES['image']['type'];
             move_uploaded_file($_FILES['image']['tmp_name'], $this->material->getFrontImageFilePath());
         }
         if (Request::get("delete_front_image")) {
             $this->material['front_image_content_type'] = null;
         }
         $this->material->store();
         //Topics:
         $topics = Request::getArray("tags");
         foreach ($topics as $key => $topic) {
             if (!trim($topic)) {
                 unset($topics[$key]);
             }
         }
         $this->material->setTopics($topics);
         $this->material->pushDataToIndexServers();
         PageLayout::postMessage(MessageBox::success(_("Lernmaterial erfolgreich gespeichert.")));
         $this->redirect("market/details/" . $this->material->getId());
     }
 }
Example #8
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     # URL: /cliqr/poll/:range_id
     $range_id = self::ensureMD5($action);
     # check activation of this plugin in range_id
     if (!$this->plugin->isActivated($range_id)) {
         throw new Trails_Exception(404);
     }
     # transform params
     # $action -> show/update, $args -> [range_id]
     $action = Request::method() === 'POST' && !Request::submitted('login_ticket') ? 'update' : 'show';
     $args = array($range_id);
 }
 /**
  *
  **/
 public function extractConsumerFromRequest($key)
 {
     $key = Request::option('consumer_key', $key);
     $consumer = self::load($key);
     if (Request::submitted('store')) {
         $consumer['requester_email'] = trim(Request::get('requester_email'));
         $consumer['requester_name'] = trim(Request::get('requester_name'));
         $consumer['callback_uri'] = Request::get('callback_uri');
         $consumer['application_uri'] = Request::get('application_uri');
         $consumer['application_title'] = Request::get('application_title');
         $consumer['application_descr'] = Request::get('application_descr');
         $consumer['application_notes'] = Request::get('application_notes');
         $consumer['application_type'] = Request::option('application_type');
         $consumer['application_commercial'] = Request::int('application_commercial');
     }
     return $consumer;
 }
Example #10
0
 public function edit_action($process_id = null)
 {
     $this->process = new FleximportProcess($process_id);
     if (Request::isPost()) {
         if (Request::submitted("delete_process")) {
             $this->process->delete();
             PageLayout::postMessage(MessageBox::success(_("Prozess wurde gelöscht.")));
             $processes = FleximportProcess::findBySQL("1=1 ORDER BY name ASC");
             $this->redirect("import/overview" . (count($processes) ? "/" . $processes[0]['process_id'] : ""));
         } else {
             $this->process->setData(Request::getArray("data"));
             $this->process->store();
             PageLayout::postMessage(MessageBox::success(_("Prozess wurde gespeichert")));
             $this->redirect("import/overview/" . $this->process->getId());
         }
     }
 }
Example #11
0
 /**
  * Displays a pageable and sortable overview of all studygoups combined with
  * a search form to query for specific studygroup
  *
  * @param $page
  * @param $sort
  */
 function browse_action($page = 1, $sort = "founded_asc")
 {
     $this->sort = preg_replace('/\\W/', '', $sort);
     $this->page = intval($page);
     $this->userid = $GLOBALS['auth']->auth['uid'];
     $this->search = Request::get("searchtext");
     $reset = false;
     if (Request::get('action') == 'deny') {
         unset($this->flash['searchterm']);
         unset($this->flash['info']);
         $this->page = 1;
         $this->sort = "founded_asc";
         $reset = true;
     }
     $this->lower_bound = ($this->page - 1) * get_config('ENTRIES_PER_PAGE');
     list($this->sort_type, $this->sort_order) = explode('_', $this->sort);
     if (empty($this->search) && isset($this->flash['searchterm'])) {
         $this->search = $this->flash['searchterm'];
     }
     if (!empty($this->search)) {
         $groups = StudygroupModel::getAllGroups($this->sort, $this->lower_bound, get_config('ENTRIES_PER_PAGE'), $this->search);
         $this->flash['searchterm'] = $this->search;
         $this->flash->keep('searchterm');
         $this->anzahl = StudygroupModel::countGroups($this->search);
         $this->groups = $groups;
     }
     // let the user know that there is no studygroup for the searchterm
     if (empty($groups)) {
         if (!$reset) {
             if (Request::submitted('searchtext') && empty($this->search)) {
                 $this->flash['info'] = _("Der Suchbegriff ist zu kurz.");
                 unset($this->flash['searchterm']);
             } elseif (isset($this->flash['searchterm'])) {
                 $this->flash['info'] = _("Es wurden keine Studiengruppen für den Suchbegriff gefunden");
             }
         }
         $this->anzahl = StudygroupModel::countGroups();
         $this->groups = StudygroupModel::getAllGroups($this->sort, $this->lower_bound, get_config('ENTRIES_PER_PAGE'));
     } elseif (!$check || $this->groups) {
         unset($this->flash['info']);
         if ($this->page < 1 || $this->page > ceil($this->anzahl / get_config('ENTRIES_PER_PAGE'))) {
             $this->page = 1;
         }
     }
 }
Example #12
0
 public function index_action($verify_action = null)
 {
     if (Request::submitted('store')) {
         $this->check_ticket();
         if (Request::get('new_smsforward_rec')) {
             $this->user->smsforward_rec = get_userid(Request::get('new_smsforward_rec'));
             $this->user->smsforward_copy = 1;
         } else {
             if (Request::int('smsforward_copy') && !$this->user->smsforward_copy) {
                 $this->user->smsforward_copy = 1;
             } else {
                 if (!Request::int('smsforward_copy') && $this->user->smsforward_copy) {
                     $this->user->smsforward_copy = 0;
                 }
             }
         }
         $this->user->email_forward = Request::int('send_as_email');
         $this->user->store();
         // write to user config table
         $this->config->store('ONLINE_NAME_FORMAT', Request::option('online_format'));
         $this->config->store('MAIL_AS_HTML', Request::int('mail_format'));
         $settings = $this->settings;
         $settings['sms_sig'] = Request::get('sms_sig');
         $settings['logout_markreaded'] = Request::int('logout_markreaded');
         $settings['save_snd'] = Request::int('save_snd', 2);
         $settings['request_mail_forward'] = Request::int('request_mail_forward', 0);
         $this->config->store('MESSAGING_SETTINGS', $settings);
         $this->reportSuccess(_('Ihre Einstellungen wurden erfolgreich gespeichert.'));
         $this->redirect('settings/messaging');
     }
     if (!$this->user->smsforward_rec && Request::submitted('gosearch')) {
         $vis_query = get_vis_query('auth_user_md5');
         $query = "SELECT user_id, username, {$GLOBALS['_fullname_sql']['full_rev']} AS fullname, perms\n                      FROM auth_user_md5\n                      LEFT JOIN user_info USING (user_id)\n                      WHERE (username LIKE CONCAT('%', :needle, '%') OR\n                             Vorname LIKE CONCAT('%', :needle, '%') OR\n                             Nachname LIKE CONCAT('%', :needle, '%'))\n                        AND user_id != :user_id AND {$vis_query}\n                      ORDER BY Nachname ASC";
         $statement = DBManager::get()->prepare($query);
         $statement->bindValue(':needle', Request::get('search_exp'));
         $statement->bindValue(':user_id', $this->user->user_id);
         $statement->execute();
         $matches = $statement->fetchAll(PDO::FETCH_ASSOC);
     } else {
         $matches = false;
     }
     $this->matches = $matches;
     $this->verify_action = $verify_action;
 }
Example #13
0
 /**
  *
  **/
 public function authorize_action()
 {
     global $user, $auth;
     $auth_plugin = Config::get()->API_OAUTH_AUTH_PLUGIN;
     if ($GLOBALS['user']->id === 'nobody' && $auth_plugin !== 'Standard' && !Request::option('sso')) {
         $params = $_GET;
         $params['sso'] = $auth_plugin;
         $this->redirect($this->url_for('api/oauth/authorize?' . http_build_query($params)));
         return;
     } else {
         $auth->login_if($user->id === 'nobody');
     }
     $user_id = RESTAPI\Consumer\OAuth::getOAuthId($GLOBALS['user']->id);
     try {
         $consumer = RESTAPI\Consumer\Base::detectConsumer('oauth', 'request');
         if (Request::submitted('allow')) {
             $result = $consumer->grantAccess($GLOBALS['user']->id);
             $redirect_uri = Request::get('oauth_callback', $consumer->callback);
             if ($redirect_uri) {
                 $this->redirect($redirect_uri);
             } else {
                 // No oauth_callback, show the user the result of the authorization
                 // ** your code here **
                 PageLayout::postMessage(MessageBox::success(_('Sie haben der Applikation Zugriff auf Ihre Daten gewährt.')));
                 $this->redirect('api/authorizations#' . $consumer->auth_key);
             }
             return;
         }
     } catch (OAuthException $e) {
         // No token to be verified in the request, show a page where the user can enter the token to be verified
         // **your code here**
         die('invalid');
     }
     PageLayout::disableHeader();
     PageLayout::setTitle(sprintf(_('"%s" bittet um Zugriff'), $consumer->title));
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base.php'));
     $this->consumer = $consumer;
     $this->token = Request::option('oauth_token');
     $this->oauth_callback = Request::get('oauth_callback');
 }
Example #14
0
 /**
  * Edit or create a rule
  *
  * @param md5 $edit_id
  */
 function edit_action($id = null)
 {
     //get data
     $user_field = 'user';
     $semdata_field = 'usersemdata';
     $this->semFields = AuxLockRules::getSemFields();
     $this->entries_user = DataField::getDataFields($user_field);
     $this->entries_semdata = DataField::getDataFields($semdata_field);
     $this->rule = is_null($id) ? false : AuxLockRules::getLockRuleByID($id);
     if ($GLOBALS['perm']->have_perm('root') && count($this->entries_semdata) == 0) {
         $this->flash['info'] = sprintf(_('Sie müssen zuerst im Bereich %sDatenfelder%s in der Kategorie ' . '<i>Datenfelder für Personenzusatzangaben in Veranstaltungen</i> einen neuen Eintrag erstellen.'), '<a href="' . URLHelper::getLink('dispatch.php/admin/datafields') . '">', '</a>');
     }
     // save action
     if (Request::submitted('erstellen') || Request::submitted('uebernehmen')) {
         //checking for errors
         $errors = array();
         if (!Request::get('rulename')) {
             array_push($errors, _("Bitte geben Sie der Regel mindestens einen Namen!"));
         }
         if (!AuxLockRules::checkLockRule(Request::getArray('fields'))) {
             array_push($errors, _('Bitte wählen Sie mindestens ein Feld aus der Kategorie "Zusatzinformationen" aus!'));
         }
         if (!empty($errors)) {
             $this->flash['error'] = _("Ihre Eingaben sind ungültig.");
             $this->flash['error_detail'] = $errors;
             // save
         } else {
             //new
             if (is_null($id)) {
                 AuxLockRules::createLockRule(Request::get('rulename'), Request::get('description'), Request::getArray('fields'), Request::getArray('order'));
                 //edit
             } else {
                 AuxLockRules::updateLockRule($id, Request::get('rulename'), Request::get('description'), Request::getArray('fields'), Request::getArray('order'));
             }
             $this->flash['success'] = sprintf(_('Die Regel "%s" wurde erfolgreich gespeichert!'), htmlReady(Request::get('rulename')));
             $this->redirect('admin/specification');
         }
     }
 }
Example #15
0
 /**
  * Displays the deputy information of a user.
  */
 public function index_action()
 {
     if (Request::submitted('add_deputy') && ($deputy_id = Request::option('deputy_id'))) {
         $this->check_ticket();
         if (isDeputy($deputy_id, $this->user->user_id)) {
             $this->reportError(_('%s ist bereits als Vertretung eingetragen.'), get_fullname($deputy_id, 'full'));
         } else {
             if ($deputy_id == $this->user->user_id) {
                 $this->reportError(_('Sie können sich nicht als Ihre eigene Vertretung eintragen!'));
             } else {
                 if (addDeputy($deputy_id, $this->user->user_id)) {
                     $this->reportSuccess(_('%s wurde als Vertretung eingetragen.'), get_fullname($deputy_id, 'full'));
                 } else {
                     $this->reportError(_('Fehler beim Eintragen der Vertretung!'));
                 }
             }
         }
         $this->redirect('settings/deputies');
         return;
     }
     $deputies = getDeputies($this->user->user_id, true);
     $exclude_users = array($this->user->user_id);
     if (is_array($deputies)) {
         $exclude_users = array_merge($exclude_users, array_map(function ($d) {
             return $d['user_id'];
         }, $deputies));
     }
     $this->deputies = $deputies;
     $this->search = new PermissionSearch('user', _('Vor-, Nach- oder Benutzername'), 'user_id', array('permission' => getValidDeputyPerms(), 'exclude_user' => $exclude_users));
     $sidebar = Sidebar::Get();
     $sidebar->setTitle(PageLayout::getTitle());
     $actions = new ActionsWidget();
     // add "add dozent" to infobox
     $mp = MultiPersonSearch::get('settings_add_deputy')->setLinkText(_('Neue Standardvertretung festlegen'))->setDefaultSelectedUser(array_keys($this->deputies))->setLinkIconPath('')->setTitle(_('Neue Standardvertretung festlegen'))->setExecuteURL(URLHelper::getLink('dispatch.php/settings/deputies/add_member'))->setSearchObject($this->search)->setNavigationItem('/links/settings/deputies')->render();
     $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
     $actions->addElement($element);
     Sidebar::Get()->addWidget($actions);
 }
Example #16
0
 /**
  * Upload a new avatar or removes the current avatar.
  * Upon Sends an information email to the user if the action was not invoked
  * by himself.
  */
 public function upload_action()
 {
     $this->check_ticket();
     if (Request::submitted('reset')) {
         Avatar::getAvatar($this->user->user_id)->reset();
         Visibility::removePrivacySetting('picture', $this->user->user_id);
         $this->reportSuccess(_('Bild gelöscht.'));
     } elseif (Request::submitted('upload')) {
         try {
             Avatar::getAvatar($this->user->user_id)->createFromUpload('imgfile');
             NotificationCenter::postNotification('AvatarDidUpload', $this->user->user_id);
             $message = _('Die Bilddatei wurde erfolgreich hochgeladen. ' . 'Eventuell sehen Sie das neue Bild erst, nachdem Sie diese Seite ' . 'neu geladen haben (in den meisten Browsern F5 drücken).');
             $this->reportSuccess($message);
             setTempLanguage($this->user->user_id);
             $this->postPrivateMessage(_("Ein neues Bild wurde hochgeladen.\n"));
             restoreLanguage();
             Visibility::addPrivacySetting(_('Eigenes Bild'), 'picture', 'commondata', 1, $this->user->user_id);
         } catch (Exception $e) {
             $this->reportError($e->getMessage());
         }
     }
     $this->redirect('settings/avatar');
 }
Example #17
0
 public function process_action($process_id)
 {
     if (Request::isPost()) {
         if (Request::submitted("start")) {
             $protocol = array();
             $starttime = time();
             $this->process = FleximportProcess::find($process_id);
             $this->tables = $this->process->tables;
             foreach ($this->tables as $table) {
                 $table->fetchData();
             }
             foreach ($this->tables as $table) {
                 $table->doImport();
             }
             $duration = time() - $starttime;
             if ($duration >= 60) {
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Import wurde durchgeführt und dauerte %s Minuten"), floor($duration / 60)), $protocol));
             } else {
                 PageLayout::postMessage(MessageBox::success(_("Import wurde durchgeführt"), $protocol));
             }
         } elseif ($_FILES['tableupload']) {
             foreach ($_FILES['tableupload']['tmp_name'] as $table_id => $tmp_name) {
                 if ($tmp_name) {
                     $table = new FleximportTable($table_id);
                     $output = $this->plugin->getCSVDataFromFile($tmp_name);
                     if ($table['tabledata']['source_encoding'] === "utf8") {
                         $output = studip_utf8decode($output);
                     }
                     $headline = array_shift($output);
                     $table->createTable($headline, $output);
                 }
             }
             PageLayout::postMessage(MessageBox::success(_("CSV-Datei hochgeladen")));
         }
     }
     $this->redirect("import/overview/" . $process_id);
 }
Example #18
0
    if (!$_SESSION['resources_data']['sem_schedule_semester_id']){
        $_SESSION['resources_data']['sem_schedule_semester_id'] = $_SESSION['_default_sem'];
        $_SESSION['resources_data']['sem_schedule_timespan'] = 'course_time';
        $_SESSION['resources_data']["schedule_mode"] = "graphical";
        $_SESSION['resources_data']["show_repeat_mode"] = 'all';
    }
    if (!isset($_SESSION['resources_data']['actual_room_group'])){
        $_SESSION['resources_data']['actual_room_group'] = 0;
        $_SESSION['resources_data']["schedule_mode"] = "graphical";
        $_SESSION['resources_data']["show_repeat_mode"] = 'all';
        $_SESSION['resources_data']['group_schedule_dow'] = 1;
    }
    $_SESSION['_default_sem'] = $_SESSION['resources_data']['sem_schedule_semester_id'];
}

if (Request::option('show_repeat_mode') && Request::submitted('send_schedule_repeat_mode')) {
    $_SESSION['resources_data']["show_repeat_mode"] = Request::option('show_repeat_mode');
}

if (Request::get('time_range')) {
    if (Request::get('time_range') == "FALSE")
        $_SESSION['resources_data']["schedule_time_range"] = '';
    else
        $_SESSION['resources_data']["schedule_time_range"] = Request::int('time_range');
}

/*****************************************************************************
some other stuff ;-)
/*****************************************************************************/

//display perminvalid window
            $errors .= $error_msg . "<br>";
        }
    }
    echo EvalEdit::createSite($errors . $back_button, " ");
    include_once 'lib/include/html_end.inc.php';
    page_close();
    exit;
}
# ======================================== end: Print Error MSG and end Site #
/* Do first all actions for templates -------------------------------------- */
$templateSite = (include EVAL_FILE_TEMPLATE);
/* --------------------------------- end: do first all actions for templates */
# Creating the Tree ======================================================== #
$EditTree = new EvaluationTreeEditView($itemID, $evalID);
# Send messages to the tree ================================================ #
if (Request::submitted('newButton')) {
    $EditTree->msg["root"] = "msg§" . _("Erstellen Sie nun eine Evaluation.<br> Der erste Gruppierungsblock ist bereits angelegt worden. Wenn Sie ihn öffnen, können Sie dort weitere Gruppierungsblöcke oder Fragenblöcke anlegen.");
}
# ============================================ end: Send messages to the tree #
/* Next do all actions for evaluations ------------------------------------- */
$editSite = $EditTree->showEvalTree($itemID, 1);
/* ------------------------------------- end: Do all actions for evaluations */
/* Create content ---------------------------------------------------------- */
echo EvalEdit::createSite($editSite, $templateSite);
/* ----------------------------------------------------- end: create content */
// debug-infos
/*
$debug .= "\n<b><font color=\"##3366FF\">postVars</font></b>";
foreach ($_POST as $key=>$item ) {
    if (is_array($item)){
        $debug .= "\n->$key [Array]:";
Example #20
0
<? endif; ?>

<?php 
$sidebar = Sidebar::get();
$sidebar->setImage('sidebar/mail-sidebar.png');
$actions = new ActionsWidget();
$actions->addLink(_("Neue Nachricht schreiben"), $controller->url_for('messages/write'), Icon::create('mail+add', 'clickable'), array('data-dialog' => 'width=650;height=600'));
if (Navigation::getItem('/messaging/messages/inbox')->isActive() && $messages) {
    $actions->addLink(_('Alle als gelesen markieren'), $controller->url_for('messages/overview', array('read_all' => 1)), Icon::create('accept', 'clickable'));
}
$actions->addLink(_('Ausgewählte Nachrichten löschen'), "#", Icon::create('trash', 'clickable'), array('onclick' => "if (window.confirm('Wirklich %s Nachrichten löschen?'.toLocaleString().replace('%s', jQuery('#bulk tbody :checked').length))) { jQuery('#bulk').submit(); } return false;"));
$sidebar->addWidget($actions);
$search = new SearchWidget(URLHelper::getLink('?'));
$search->addNeedle(_('Nachrichten durchsuchen'), 'search', true);
$search->addFilter(_('Betreff'), 'search_subject');
$search->addFilter(_('Inhalt'), 'search_content');
$search->addFilter(_('Autor/-in'), 'search_autor');
$sidebar->addWidget($search);
$folderwidget = new ViewsWidget();
$folderwidget->forceRendering();
$folderwidget->title = _('Schlagworte');
$folderwidget->id = 'messages-tags';
$folderwidget->addLink(_("Alle Nachrichten"), URLHelper::getURL("?"), null, array('class' => "tag"))->setActive(!Request::submitted("tag"));
if (empty($tags)) {
    $folderwidget->style = 'display:none';
} else {
    foreach ($tags as $tag) {
        $folderwidget->addLink(ucfirst($tag), URLHelper::getURL("?", array('tag' => $tag)), null, array('class' => "tag"))->setActive(Request::get("tag") === $tag);
    }
}
$sidebar->addWidget($folderwidget);
 /**
 * creates the html for the question-input
 *
 * @access   private
 * @return   string the html
 */
 function createQuestionForm()
 {
     $qgroup =& $this->tree->getGroupObject($this->itemID);
     $questions = $qgroup->getChildren();
     $templateID = $qgroup->getTemplateID();
     $table = new HTML("table");
     $table->addAttr("border", "0");
     $table->addAttr("align", "center");
     $table->addAttr("cellspacing", "0");
     $table->addAttr("cellpadding", "2");
     $table->addAttr("width", "98%");
     $tr = new HTML("tr");
     $td = new HTML("td");
     $td->addAttr("align", "center");
     $table2 = new HTML("table");
     $table2->addAttr("border", "0");
     $table2->addAttr("class", "blank");
     $table2->addAttr("cellspacing", "0");
     $table2->addAttr("cellpadding", "0");
     $table2->addAttr("width", "100%");
     // captions
     $tr2 = new HTML("tr");
     $showclass = "table_row_odd";
     $td2 = new HTML("td");
     $td2->addAttr("class", $showclass);
     $td2->addAttr("align", "center");
     $td2->addAttr("width", "15");
     $b = new HTML("b");
     $b->addContent("#");
     $td2->addContent($b);
     $tr2->addContent($td2);
     $td2 = new HTML("td");
     $td2->addAttr("class", $showclass);
     $b = new HTML("b");
     $b->addContent(_("Frage"));
     $td2->addContent($b);
     $tr2->addContent($td2);
     $td2 = new HTML("td");
     $td2->addAttr("class", $showclass);
     if (count($questions) > 1) {
         $b = new HTML("b");
         $b->addContent(_("Position"));
         $td2->addContent($b);
     } else {
         $td2->addContent("");
     }
     $tr2->addContent($td2);
     $td2 = new HTML("td");
     $td2->addAttr("class", $showclass);
     $b = new HTML("b");
     $b->addContent(_("Löschen"));
     $td2->addContent($b);
     $tr2->addContent($td2);
     // only if template is NO_TEMPLATE_GROUP
     if ($templateID == NULL) {
         $td2 = new HTML("td");
         $td2->addAttr("class", $showclass);
         $b = new HTML("b");
         $b->addContent(_("Antworten"));
         $td2->addContent($b);
         $tr2->addContent($td2);
     }
     $table2->addContent($tr2);
     $i = 0;
     foreach ($questions as $question) {
         $tr2 = new HTML("tr");
         // brrr :)
         // extract the questionID from the command
         foreach ($_REQUEST as $key => $value) {
             if (preg_match("/template_(.*)_button?/", $key, $command)) {
                 break;
             }
         }
         if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) {
             $questionID = $command_parts[2];
         } else {
             $questionID = Request::submitted('template_save2_button') ? "" : Request::get("template_id");
         }
         if ($question->getObjectID() == $questionID) {
             $tr2->addAttr("class", "eval_highlight");
         } else {
             $tr2->addAttr("class", $i % 2 == 1 ? "table_row_odd" : "table_row_even");
         }
         $td2 = new HTML("td");
         $td2->addAttr("align", "center");
         $font = new HTML("font");
         $font->addAttr("size", "-1");
         $font->addContent($i + 1 . ".");
         $td2->addContent($font);
         $tr2->addContent($td2);
         $td2 = new HTML("td");
         $td2->addAttr("align", "left");
         $input = new HTMLempty("input");
         $input->addAttr("type", "tex");
         $input->addAttr("size", "70");
         $input->addAttr("name", "questions[{$i}][text]");
         $input->addAttr("value", $question->getText());
         $input->addAttr("tabindex", 3 + $i);
         $td2->addContent($input);
         #   $td2->addHTMLContent ("POST: -".$question->getPosition()."-!");
         $input = new HTMLempty("input");
         $input->addAttr("type", "hidden");
         $input->addAttr("name", "questions[{$i}][questionID]");
         $input->addAttr("value", $question->getObjectID());
         $td2->addContent($input);
         $input = new HTMLempty("input");
         $input->addAttr("type", "hidden");
         $input->addAttr("name", "questions[{$i}][position]");
         $input->addAttr("value", $question->getPosition());
         $td2->addContent($input);
         $input = new HTMLempty("input");
         $input->addAttr("type", "hidden");
         $input->addAttr("name", "questions[{$i}][counter]");
         $input->addAttr("value", $question->getPosition());
         $td2->addContent($input);
         $tr2->addContent($td2);
         // move-up/down arrows and counter
         if (count($questions) > 1) {
             $numberchildren = $qgroup->getNumberChildren();
             if ($question->getPosition() == 0) {
                 $tooltipup = _("Diese Frage mit der letzten Frage vertauschen.");
             } else {
                 $tooltipup = _("Diese Frage eine Position nach oben verschieben.");
             }
             if ($question->getPosition() == $numberchildren - 1) {
                 $tooltipdown = _("Diese Frage mit der ersten Frage vertauschen.");
             } else {
                 $tooltipdown = _("Diese Frage eine Position nach unten verschieben.");
             }
             $td2 = new HTML("td");
             $td2->addAttr("align", "center");
             $button = new HTMLempty("input");
             $button->addAttr("type", "image");
             $button->addAttr("name", "cmd_MoveQuestionUp_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button");
             $button->addAttr("style", "vertical-align:middle;");
             $button->addAttr("border", "0");
             $button->addAttr("src", EVAL_PIC_MOVE_UP);
             $button->addString(Tooltip($tooltipup));
             $td2->addContent($button);
             $button = new HTMLempty("input");
             $button->addAttr("type", "image");
             $button->addAttr("name", "cmd_MoveQuestionDown_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button");
             $button->addAttr("style", "vertical-align:middle;");
             $button->addAttr("border", "0");
             $button->addAttr("src", EVAL_PIC_MOVE_DOWN);
             $button->addString(Tooltip($tooltipdown));
             $td2->addContent($button);
         } else {
             $td2 = new HTML("td");
             $td2->addAttr("align", "center");
             $td2->addContent(" ");
         }
         $tr2->addContent($td2);
         $td2 = new HTML("td");
         $td2->addAttr("align", "center");
         $input = new HTMLempty("input");
         $input->addAttr("type", "checkbox");
         $input->addAttr("id", "deleteCheckboxes");
         $input->addAttr("name", "DeleteQuestions[" . $question->getPosition() . "]");
         $td2->addContent($input);
         $tr2->addContent($td2);
         // if template is NO_TEMPLATE_GROUP
         if ($templateID == NULL) {
             // hat noch keine antworten
             if ($question->getChildren() == NULL) {
                 $image = EVAL_PIC_CREATE_ANSWERS;
                 $text = _("Dieser Frage wurden noch keine Antwortenmöglichkeiten zugewiesen. Drücken Sie auf den Doppelfpeil, um dies jetzt zu tun.");
                 $tooltip = tooltip(_("Dieser Frage Antwortenmöglichkeiten zuweisen."));
             } else {
                 $image = EVAL_PIC_EDIT_ANSWERS;
                 $text = _("Dieser Frage wurden bereits folgende Antwortenmöglichkeiten zugewiesen:") . " ";
                 $tooltip = tooltip(_("Die zugewiesenen Antwortenmöglichkeiten bearbeiten."));
                 $text .= "\n";
                 while ($answer = $question->getNextChild()) {
                     $text .= "\"" . $answer->getText() . "\"\n ";
                 }
                 $text .= "";
             }
             $td2 = new HTML("td");
             $td2->addAttr("align", "center");
             $td2->addAttr("valign", "middle");
             $td2->addHTMLContent($this->createImage(EVAL_PIC_HELP, $text));
             $questionID = $question->getObjectID();
             $button = new HTMLempty("input");
             $button->addAttr("type", "image");
             $button->addAttr("name", "template_create_question_answers_#" . $questionID . "_button");
             $button->addAttr("style", "vertical-align:middle;");
             $button->addAttr("border", "0");
             $button->addAttr("src", $image);
             $button->addString($tooltip);
             $td2->addContent($button);
             $tr2->addContent($td2);
         }
         $table2->addContent($tr2);
         $i++;
     }
     if (sizeof($questions) == 0) {
         $tr2 = new HTML("tr");
         $td2->addAttr("class", "table_row_even");
         $td2 = new HTML("td");
         $td2->addAttr("align", "center");
         $td2->addContent(" ");
         $tr2->addContent($td2);
         $td2 = new HTML("td");
         $td2->addContent(_("Dieser Block besitzt keine Fragen."));
         $tr2->addContent($td2);
         $td2 = new HTML("td");
         $td2->addContent(" ");
         $tr2->addContent($td2);
         $td2 = new HTML("td");
         $td2->addContent(" ");
         $tr2->addContent($td2);
         $table2->addContent($tr2);
     }
     $td->addContent($table2);
     // the new questions und delete questions buttons
     $table2 = new HTML("table");
     $table2->addAttr("width", "100%");
     $table2->addAttr("border", "0");
     $table2->addAttr("class", $i % 2 == 6 ? "content_body" : "content_body");
     $table2->addAttr("cellspacing", "0");
     $table2->addAttr("cellpadding", "2");
     // buttons
     $tr2 = new HTML("tr");
     $td2 = new HTML("td");
     $td2->addAttr("align", "left");
     $select = new HTML("select");
     $select->addAttr("style", "vertical-align:middle;");
     $select->addAttr("name", "newQuestionFields");
     $select->addAttr("size", "1");
     for ($i = 1; $i <= 10; $i++) {
         $option = new HTML("option");
         $option->addAttr("value", $i);
         $option->addContent($i);
         $select->addContent($option);
     }
     $td2->addContent($select);
     $td2->addContent(_("Frage/en"));
     $td2->addContent(" ");
     $td2->addHTMLContent(Button::create(_('Hinzufügen'), 'cmd[AddQuestions]', array('title' => _('Fragen hinzufügen'))));
     $tr2->addContent($td2);
     $td2 = new HTML("td");
     $td2->addAttr("align", "right");
     $font = new HTML("font");
     $font->addAttr("size", "-1");
     $font->addContent(_("markierte Fragen "));
     $td2->addContent($font);
     $td2->addHTMLContent(Button::create(_('Löschen'), 'cmd[DeleteQuestions]', array('title' => _('Markierte Fragen löschen'))));
     $tr2->addContent($td2);
     $table2->addContent($tr2);
     $td->addContent($table2);
     $tr->addContent($td);
     $table->addContent($tr);
     return $table->createContent();
 }
Example #22
0
 function vcard_action($group = null)
 {
     // Set constants for export
     $charset = 'utf-8';
     $filename = _('Kontakte');
     // Set layout
     $this->set_layout(null);
     // If we got an array of user
     if (Request::submitted('user')) {
         $user = User::findManyByUsername(Request::getArray('user'));
     }
     // If we got a group
     if ($group) {
         $user = User::findMany(Statusgruppen::find($group)->members->pluck('user_id'));
     }
     // Fallback to all contacts if we got nothing
     if (!$user) {
         $user = User::findCurrent()->contacts;
     }
     header("Content-type: text/x-vCard;charset=" . $charset);
     //application/octet-stream MIME
     header("Content-disposition: attachment; filename=" . $filename . ".vcf");
     header("Pragma: private");
     $this->vCard = vCard::export($user);
 }
Example #23
0
 /**
  * save tour data
  * 
  * @param String $tour_id    tour id
  */
 function save_action($tour_id = '')
 {
     // check permission
     $GLOBALS['perm']->check('root');
     // initialize
     Navigation::activateItem('/admin/config/tour');
     $this->tour = new HelpTour($tour_id);
     if ($tour_id and $this->tour->isNew()) {
         throw new AccessDeniedException(_('Die Tour mit der angegebenen ID existiert nicht.'));
     }
     if (Request::submitted('save_tour_details')) {
         CSRFProtection::verifySecurityToken();
         $this->tour->name = trim(Request::get('tour_name'));
         $this->tour->description = trim(Request::get('tour_description'));
         if (Request::option('tour_language')) {
             $this->tour->language = Request::option('tour_language');
         }
         $this->tour->type = Request::option('tour_type');
         $this->tour->settings->access = Request::option('tour_access');
         $this->tour->roles = implode(',', Request::getArray('tour_roles'));
         if ($this->tour->isNew()) {
             $this->tour->global_tour_id = md5(uniqid('help_tours', 1));
             $this->tour->settings->active = 0;
         }
         $this->tour->author_email = $GLOBALS['user']->Email;
         $this->tour->studip_version = $GLOBALS['SOFTWARE_VERSION'];
         if ($this->tour->validate()) {
             $this->tour->store();
             if (!count($this->tour->steps)) {
                 $step_data = array('title' => '', 'tip' => _('(Neue Tour)'), 'interactive' => 0, 'route' => trim(Request::get('tour_startpage')), 'css_selector' => '', 'action_prev' => '', 'action_next' => '', 'orientation' => '', 'mkdate' => time(), 'author_email' => $GLOBALS['user']->Email);
                 $this->tour->addStep($step_data, 1);
                 $this->tour_startpage = trim(Request::get('tour_startpage'));
             }
             PageLayout::postMessage(MessageBox::success(_('Die Angaben wurden gespeichert.')));
         } else {
             $roles = '';
             if (count(Request::getArray('tour_roles'))) {
                 foreach (Request::getArray('tour_roles') as $role) {
                     $roles .= '&tour_roles[]=' . $role;
                 }
             }
             $this->redirect('tour/admin_details?tour_name=' . Request::get('tour_name') . '&tour_language=' . Request::get('tour_language') . '&tour_description=' . Request::get('tour_description') . '&tour_type=' . Request::get('tour_type') . '&tour_access=' . Request::get('tour_access') . '&tour_startpage=' . Request::get('tour_startpage') . $roles);
         }
     }
     $this->redirect('tour/admin_details/' . $this->tour->tour_id);
 }
Example #24
0
File: scm.php Project: ratbird/hope
 /**
  * Edits or creates a page.
  *
  * @param mixed $id Id of the page to edit; a new page will be created if
  *                  this parameter is omitted.
  */
 public function edit_action($id = null)
 {
     if (Request::submitted('submit')) {
         CSRFProtection::verifyUnsafeRequest();
         $scm = new StudipScmEntry($id);
         $scm->tab_name = Request::get('tab_name_template') ?: Request::get('tab_name');
         $scm->content = Studip\Markup::purifyHtml(Request::get('content'));
         $scm->user_id = $GLOBALS['user']->id;
         $scm->range_id = $GLOBALS['SessSemName'][1];
         if ($scm->isNew()) {
             $temp = StudipScmEntry::findByRange_id($GLOBALS['SessSemName'][1], 'ORDER BY position ASC');
             $scms = SimpleORMapCollection::createFromArray($temp);
             $max = max($scms->pluck('position'));
             $scm->position = $max + 1;
         }
         if ($scm->store() !== false) {
             $message = MessageBox::success(_('Die Änderungen wurden übernommen.'));
             PageLayout::postMessage($message);
         }
         $this->redirect('course/scm/' . $scm->id);
     }
     $this->scm = new StudipScmEntry($id);
     $this->set_title(_('Informationsseite bearbeiten') . ': ' . $this->scm->tab_name);
     Navigation::activateItem('/course/scm/' . $this->scm->id);
 }
Example #25
0
 private function setType()
 {
     $_SESSION['SessionSeminar'] = Request::option('admin_inst_id') ?: $_SESSION['SessionSeminar'];
     if (get_object_type($_SESSION['SessionSeminar'], array('inst', 'fak'))) {
         $type = 'inst';
     }
     $types = $this->types();
     if (!$type || Request::submitted('type') && $type != Request::get('type')) {
         $types[Request::get('type', 'inst')]['redirect']();
     } else {
         $this->type = $types[$type];
     }
 }
Example #26
0
 /**
  * Deletes the given entry from step registry.
  * @param $id ID of the entry to delete
  */
 public function delete_action($id)
 {
     CSRFProtection::verifyUnsafeRequest();
     if (Request::submitted('delete')) {
         $step = CourseWizardStepRegistry::find($id);
         if ($step) {
             $name = $step->name;
             if (CourseWizardStepRegistry::unregisterStep($id)) {
                 PageLayout::postMessage(MessageBox::success(sprintf(_('Der Schritt "%s" wurde gelöscht.'), $name)));
             } else {
                 PageLayout::postMessage(MessageBox::error(sprintf(_('Der Schritt %s konnte nicht gelöscht werden.'), $name)));
             }
         }
     }
     $this->redirect($this->url_for('admin/coursewizardsteps'));
 }
Example #27
0
         throw new AccessDeniedException(_('Sie haben keine Berechtigung, Seiten zu editieren!'));
     }
     // set lock
     setWikiLock(null, $user->id, $SessSemName[1], $keyword);
     wikiEdit($keyword, NULL, $user->id, Request::quoted('lastpage'));
 } else {
     // Default action: Display WikiPage (+ logic for submission)
     //
     if (empty($keyword)) {
         $keyword = 'WikiWikiWeb';
         // display Start page as default
     }
     releaseLocks($keyword);
     // kill old locks
     $special = "";
     if (Request::submitted('submit')) {
         //
         // Page was edited and submitted
         //
         submitWikiPage($keyword, $version, Studip\Markup::purifyHtml(Request::get('body')), $user->id, $SessSemName[1]);
         $version = "";
         // $version="" means: get latest
     } else {
         if ($cmd == "abortedit") {
             // Editieren abgebrochen
             //
             // Editing page was aborted
             //
             releasePageLocks($keyword, $user->id);
             // kill lock (set when starting to edit)
             if (Request::quoted('lastpage')) {
Example #28
0
 public function testSubmitted()
 {
     $this->assertFalse(Request::submitted('null'));
     $this->assertTrue(Request::submitted('s'));
     $this->assertTrue(Request::submitted('v1'));
 }
Example #29
0
 public function register_for_pluginnews_action($plugin_id)
 {
     $this->marketplugin = MarketPlugin::find($plugin_id);
     if (Request::isPost()) {
         if (Request::submitted("follow")) {
             $following = new MarketPluginFollower();
             $following['plugin_id'] = $plugin_id;
             $following['user_id'] = $GLOBALS['user']->id;
             $following->store();
             PageLayout::postMessage(MessageBox::success(_("Sie bekommen nun Informationen zu Updates dieses Plugins zugeschickt.")));
         } elseif (Request::submitted("unfollow")) {
             $following = MarketPluginFollower::findByUserAndPlugin($GLOBALS['user']->id, $plugin_id);
             $following->delete();
             PageLayout::postMessage(MessageBox::success(_("Sie werden jetzt keine weiteren Neuigkeiten über dieses Plugin als Stud.IP Nachricht bekommen.")));
         }
     }
     if (Request::isXhr()) {
         $this->response->add_header('X-Title', _("Plugin abonnieren"));
         $this->set_layout(null);
         $this->set_content_type('text/html;charset=windows-1252');
     }
 }
Example #30
0
/**
 * generates proper text for confirmation question and removes range_id from news
 *
 *
 * @param $remove_array array with $news_id as key and array of range_ids as value
 * @param string $range_id
 * @return string text for confirmation question or empty string after removal
 */
function remove_news($remove_array)
{
    $confirmed = false;
    $question_text = array();
    if (!is_array($remove_array)) {
        return false;
    }
    if (Request::submitted('yes') and Request::isPost()) {
        CSRFProtection::verifySecurityToken();
        $confirmed = true;
    }
    foreach ($remove_array as $news_id => $ranges) {
        $remove_news = new StudipNews($news_id);
        $remove_news_title = $remove_news->getValue('topic');
        if (!is_array($ranges)) {
            $ranges = array($ranges);
        }
        // should we delete news completely
        if (count($ranges) == count($remove_news->getRanges())) {
            $text = delete_news($news_id);
            if ($text) {
                $question_text[] = $text;
            }
            // or just remove range_id(s)?
        } else {
            $text = '';
            if ($confirmed and !$remove_news->isNew() and count($ranges)) {
                foreach ($ranges as $key => $range_id) {
                    if ($remove_news->havePermission('unassign', $range_id)) {
                        $remove_news->deleteRange($range_id);
                    } else {
                        unset($ranges[$key]);
                        PageLayout::postMessage(MessageBox::error(sprintf(_('Keine Berechtigung zum Entfernen der Ankündigung "%s" aus diesem Bereich.'), htmlReady($remove_news->getValue('topic')))));
                    }
                    if (count($ranges)) {
                        if (count($ranges) == 1) {
                            PageLayout::postMessage(MessageBox::success(sprintf(_('Ankündigung "%s" wurde aus dem Bereich entfernt.'), htmlReady($remove_news->getValue('topic')))));
                        } else {
                            PageLayout::postMessage(MessageBox::success(sprintf(_('Ankündigung "%s" wurde aus %s Bereichen entfernt.'), htmlReady($remove_news->getValue('topic')), count($ranges))));
                        }
                        $remove_news->store();
                    }
                }
            } elseif (!$confirmed) {
                if (count($ranges) == 1) {
                    $text = sprintf(_('- Die Ankündigung "%s" wird aus dem aktiven Bereich entfernt. ' . 'Sie wird dadurch nicht endgültig gelöscht. Es wird nur die Zuordnung entfernt.'), $remove_news_title) . "\n";
                } elseif (count($ranges) > 1) {
                    $text = sprintf(_('- Die Ankündigung "%s" wird aus den %s gewählten Bereichen entfernt. ' . 'Sie wird dadurch nicht endgültig gelöscht. Es werden nur die Zuordnungen entfernt.'), $remove_news_title, count($ranges)) . "\n";
                }
            }
            if ($text) {
                $question_text[] = $text;
            }
        }
    }
    if (count($question_text) > 1) {
        return _('Wollen Sie die folgenden Aktionen jetzt ausführen?') . "\n" . implode($question_text);
    } elseif (count($question_text) == 1) {
        return _('Wollen Sie diese Aktion jetzt ausführen?') . "\n" . implode($question_text);
    }
}