/** * {@inheritdoc} */ public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true) { Profile::start('Renderer', 'Generate HTML'); $templateName = $viewName . '.' . static::$templateFileExtension; $dwoo = new Dwoo($this->compiledPath, $this->cachePath); $dwoo->getLoader()->addDirectory($this->functionsPath); Profile::start('Renderer', 'Create template file.'); $template = new Dwoo_Template_File($templateName); $template->setIncludePath($this->getTemplatesPath()); Profile::stop(); Profile::start('Renderer', 'Render'); $dwooData = new Dwoo_Data(); $dwooData->setData($model->getData()); $dwooData->assign('errorMessages', $notificationCenter->getErrors()); $dwooData->assign('successMessages', $notificationCenter->getSuccesses()); $this->setHeader('Content-type: text/html', $output); // I do never output directly from dwoo to have the possibility to show an error page if there was a render error. $result = $rendered = $dwoo->get($template, $dwooData, null, false); if ($output) { echo $result; } Profile::stop(); Profile::stop(); return $output ? null : $rendered; }
public function __construct() { parent::__construct(); $top = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array('view' => 'tiles'), "presenting/overview")); $top->setImage(Icon::create($this->getPluginURL() . "/assets/topicon.svg")); $overview = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview")); $top->addSubNavigation("presenting", $overview); $overview->addSubNavigation("overview", new AutoNavigation(_('Übersicht'), PluginEngine::getURL($this, array(), "presenting/overview"))); $overview->addSubNavigation("all", new AutoNavigation(_('Alle Plugins'), PluginEngine::getURL($this, array(), "presenting/all"))); $overview->addSubNavigation("tools", new AutoNavigation(_('Tools'), PluginEngine::getURL($this, array(), "tools/sidebar_graphics_generator"))); if ($GLOBALS['perm']->have_perm("autor")) { $top->addSubNavigation("myplugins", new Navigation(_("Meine Plugins"), PluginEngine::getURL($this, array(), "myplugins/overview"))); } if ($GLOBALS['perm']->have_perm("user")) { $last_visit = UserConfig::get($GLOBALS['user']->id)->getValue("last_pluginmarket_visit"); if ($last_visit) { $badge_number = MarketPlugin::countBySql("publiclyvisible = 1 AND approved = 1 AND published > ?", array($last_visit)); if ($badge_number > 0) { $top->setBadgeNumber($badge_number); } } } if ($GLOBALS['perm']->have_perm("root")) { $approving = new Navigation(_("Qualitätssicherung"), PluginEngine::getURL($this, array(), "approving/overview")); $top->addSubNavigation("approving", $approving); } Navigation::addItem("/pluginmarket", $top); $loginlink = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview")); $loginlink->setDescription(_("Laden Sie hier Plugins für Ihr Stud.IP herunter")); Navigation::addItem("/login/pluginmarket", $loginlink); NotificationCenter::addObserver($this, "triggerFollowingStudips", "PluginReleaseDidUpdateCode"); }
public function installFile() { $hash = md5(uniqid()); $tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash; mkdir($tmp_folder); $file = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash . ".zip"; if ($this['repository_download_url']) { file_put_contents($file, file_get_contents($this['repository_download_url'])); } elseif ($_FILES['release_file']['tmp_name']) { move_uploaded_file($_FILES['release_file']['tmp_name'], $file); } else { return false; } unzip_file($file, $tmp_folder); $objects = scandir($tmp_folder); if (count($objects) === 3) { foreach ($objects as $object) { if ($object != "." && $object != "..") { $plugin_dir = $tmp_folder . "/" . $object; } } } else { $plugin_dir = $tmp_folder; } $this->installFromDirectory($plugin_dir, $file); rmdirr($tmp_folder); unlink($file); $this['chdate'] = time(); NotificationCenter::postNotification("PluginReleaseDidUpdateCode", $this); }
/** * Returns the process’s default notification center. * * @return NotificationCenter */ public static function defaultCenter() { if (!self::$defaultCenter) { self::$defaultCenter = new self(); } return self::$defaultCenter; }
public function __construct($topicId = null, $center = null) { $this->id = $topicId ?: uniqid(); $this->center = $center ?: NotificationCenter::getInstance(); $this->encoder = $this->center->getEncoder(); $this->requester = $this->center->createRequester(); }
public function isAnswerable() { if (!$this->isViewable()) { return false; } if ($this->isEditable()) { return true; } $this->answerable = true; NotificationCenter::postNotification("QuestionnaireWillAllowToAnswer", $this); return $this->answerable; }
/** * {@inheritdoc} */ public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true) { Profile::start('Renderer', 'Generate JSON'); if (strpos($viewName, 'errors/') === 0) { $data = array('error' => substr($viewName, strlen('errors/'))); } else { $c = $model->getData(Model::PUBLISHABLE); $data = array('content' => count($c) === 0 ? null : $c); } if (count($notificationCenter->getErrors())) { $data['errorMessages'] = $notificationCenter->getErrors(); } if (count($notificationCenter->getSuccesses())) { $data['successMessages'] = $notificationCenter->getSuccesses(); } $json = json_encode($data); $this->setHeader('Content-type: application/json', $output); if ($output) { echo $json; } Profile::stop(); return $output ? null : $json; }
function page_close() { try { NotificationCenter::postNotification('PageCloseWillExecute', null); } catch (NotificationVetoException $e) { return; } if (is_object($GLOBALS['sess'])) { @session_write_close(); } if (is_object($GLOBALS['user'])) { $GLOBALS['user']->set_last_action(); } NotificationCenter::postNotification('PageCloseDidExecute', null); }
/** * 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'); }
/** * store new value for existing config entry in database * posts notification ConfigValueChanged if entry is changed * @param string $field * @param string $data * @throws InvalidArgumentException * @return boolean */ function store($field, $data) { if (!is_array($data) || !isset($data['value'])) { $values['value'] = $data; } else { $values = $data; } switch ($this->metadata[$field]['type']) { case 'boolean': $values['value'] = (bool) $values['value']; break; case 'integer': $values['value'] = (int) $values['value']; break; case 'array': $values['value'] = json_encode(studip_utf8encode($values['value'])); break; default: $values['value'] = (string) $values['value']; } $entries = ConfigEntry::findByField($field); if (count($entries) === 0) { throw new InvalidArgumentException($field . " not found in config table"); } if (isset($values['value'])) { if (count($entries) == 1 && $entries[0]->is_default == 1) { $entries[1] = clone $entries[0]; $entries[1]->setId($entries[1]->getNewId()); $entries[1]->setNew(true); $entries[1]->is_default = 0; } $value_entry = $entries[0]->is_default == 1 ? $entries[1] : $entries[0]; $old_value = $value_entry->value; $value_entry->value = $values['value']; } foreach ($entries as $entry) { if (isset($values['section'])) { $entry->section = $values['section']; } if (isset($values['comment'])) { $entry->comment = $values['comment']; } // store the default-type for the modified entry $entry->type = $this->metadata[$field]['type']; if (count($entries) > 1 && !$entry->is_default && $entry->value == $entries[0]->value) { $ret += $entry->delete(); } else { $ret += $entry->store(); } } if ($ret) { $this->fetchData(); if (isset($value_entry)) { NotificationCenter::postNotification('ConfigValueDidChange', $this, array('field' => $field, 'old_value' => $old_value, 'new_value' => $value_entry->value)); } } return $ret > 0; }
/** * delete an entry and all his descendants from the mptt-table * * @param type $topic_id the id of the entry to delete * * @return void */ function delete($topic_id) { NotificationCenter::postNotification('ForumBeforeDelete', $topic_id); $constraints = ForumEntry::getConstraints($topic_id); $parent = ForumEntry::getConstraints(ForumEntry::getParentTopicId($topic_id)); // #TODO: Zusammenfassen in eine Transaktion!!! // get all entry-ids to delete them from the category-reference-table $stmt = DBManager::get()->prepare("SELECT topic_id FROM forum_entries\n WHERE seminar_id = ? AND lft >= ? AND rgt <= ? AND depth = 1"); $stmt->execute(array($constraints['seminar_id'], $constraints['lft'], $constraints['rgt'])); $ids = $stmt->fetchAll(PDO::FETCH_COLUMN); if ($ids != false && !is_array($ids)) { $ids = array($ids); } if (!empty($ids)) { $stmt = DBManager::get()->prepare("DELETE FROM forum_categories_entries\n WHERE topic_id IN (:ids)"); $stmt->bindParam(':ids', $ids, StudipPDO::PARAM_ARRAY); $stmt->execute(); } // delete all entries $stmt = DBManager::get()->prepare("DELETE FROM forum_entries\n WHERE seminar_id = ? AND lft >= ? AND rgt <= ?"); $stmt->execute(array($constraints['seminar_id'], $constraints['lft'], $constraints['rgt'])); // update lft and rgt $diff = $constraints['rgt'] - $constraints['lft'] + 1; $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - {$diff}\n WHERE lft > ? AND seminar_id = ?"); $stmt->execute(array($constraints['rgt'], $constraints['seminar_id'])); $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - {$diff}\n WHERE rgt > ? AND seminar_id = ?"); $stmt->execute(array($constraints['rgt'], $constraints['seminar_id'])); // set the latest_chdate to the latest child's chdate $stmt = DBManager::get()->prepare("SELECT chdate FROM forum_entries\n WHERE lft > ? AND rgt < ? AND seminar_id = ?\n ORDER BY chdate DESC LIMIT 1"); $stmt->execute(array($parent['lft'], $parent['rgt'], $parent['seminar_id'])); $chdate = $stmt->fetchColumn(); $stmt_insert = DBManager::get()->prepare("UPDATE forum_entries\n SET chdate = ? WHERE topic_id = ?"); if ($chdate) { $stmt_insert->execute(array($chdate, $parent['topic_id'])); } else { $stmt_insert->execute(array($parent['chdate'], $parent['topic_id'])); } }
/** * TODO */ function stop() { $this->executeStop(); $ok = !$this->isError(); if ($ok) { \NotificationCenter::postNotification('QuestionDidStop', $this); } return $ok; }
/** * Merge an user ($old_id) to another user ($new_id). This is a part of the * old numit-plugin. * * @param string $old_user * @param string $new_user * @param boolean $identity merge identity (if true) * * @return array() messages to display after migration */ public static function convert($old_id, $new_id, $identity = false) { NotificationCenter::postNotification('UserWillMigrate', $old_id, $new_id); $messages = array(); //Identitätsrelevante Daten migrieren if ($identity) { // Veranstaltungseintragungen self::removeDoubles('seminar_user', 'Seminar_id', $new_id, $old_id); $query = "UPDATE IGNORE seminar_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); self::removeDoubles('admission_seminar_user', 'seminar_id', $new_id, $old_id); $query = "UPDATE IGNORE admission_seminar_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Persönliche Infos $query = "DELETE FROM user_info WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id)); $query = "UPDATE IGNORE user_info SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Studiengänge self::removeDoubles('user_studiengang', 'studiengang_id', $new_id, $old_id); $query = "UPDATE IGNORE user_studiengang SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Eigene Kategorien $query = "UPDATE IGNORE kategorien SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Institute self::removeDoubles('user_inst', 'Institut_id', $new_id, $old_id); $query = "UPDATE IGNORE user_inst SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Generische Datenfelder zusammenführen (bestehende Einträge des // "neuen" Nutzers werden dabei nicht überschrieben) $old_user = User::find($old_id); $query = "INSERT INTO datafields_entries\n (datafield_id, range_id, sec_range_id, content, mkdate, chdate)\n VALUES (:datafield_id, :range_id, :sec_range_id, :content,\n UNIX_TIMESTAMP(), UNIX_TIMESTAMP())\n ON DUPLICATE KEY\n UPDATE content = IF(content IN ('', 'default_value'), VALUES(content), content),\n chdate = UNIX_TIMESTAMP()"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':range_id', $new_id); $old_user->datafields->each(function ($field) use($new_id, $statement) { $statement->bindValue(':datafield_id', $field->datafield_id); $statement->bindValue(':sec_range_id', $field->sec_range_id); $statement->bindValue(':content', $field->content); $statement->execute(); }); # Datenfelder des alten Nutzers leeren $old_user->datafields = array(); $old_user->store(); //Buddys $query = "UPDATE IGNORE contact SET owner_id = ? WHERE owner_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Avatar $old_avatar = Avatar::getAvatar($old_id); $new_avatar = Avatar::getAvatar($new_id); if ($old_avatar->is_customized()) { if (!$new_avatar->is_customized()) { $avatar_file = $old_avatar->getFilename(AVATAR::ORIGINAL); if (!file_exists($avatar_file)) { $avatar_file = $old_avatar->getFilename(AVATAR::NORMAL); } $new_avatar->createFrom($avatar_file); } $old_avatar->reset(); } $messages[] = _('Identitätsrelevante Daten wurden migriert.'); } // Restliche Daten übertragen // ForumsModule migrieren foreach (PluginEngine::getPlugins('ForumModule') as $plugin) { $plugin->migrateUser($old_id, $new_id); } // Dateieintragungen und Ordner // TODO (mlunzena) should post a notification $query = "UPDATE IGNORE dokumente SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE folder SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Kalender $query = "UPDATE IGNORE calendar_event SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE calendar_user SET owner_id = ? WHERE owner_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE calendar_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE event_data SET author_id = ? WHERE author_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE event_data SET editor_id = ? WHERE editor_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Archiv self::removeDoubles('archiv_user', 'seminar_id', $new_id, $old_id); $query = "UPDATE IGNORE archiv_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Evaluationen $query = "UPDATE IGNORE eval SET author_id = ? WHERE author_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); self::removeDoubles('eval_user', 'eval_id', $new_id, $old_id); $query = "UPDATE IGNORE eval_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE evalanswer_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Kategorien $query = "UPDATE IGNORE kategorien SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Literatur $query = "UPDATE IGNORE lit_catalog SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE lit_list SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Nachrichten (Interne) $query = "UPDATE IGNORE message SET autor_id = ? WHERE autor_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); self::removeDoubles('message_user', 'message_id', $new_id, $old_id); $query = "UPDATE IGNORE message_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // News $query = "UPDATE IGNORE news SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE news_range SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Informationsseiten $query = "UPDATE IGNORE scm SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Statusgruppeneinträge self::removeDoubles('statusgruppe_user', 'statusgruppe_id', $new_id, $old_id); $query = "UPDATE IGNORE statusgruppe_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); // Termine $query = "UPDATE IGNORE termine SET autor_id = ? WHERE autor_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Votings $query = "UPDATE IGNORE vote SET author_id = ? WHERE author_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE vote SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); self::removeDoubles('vote_user', 'vote_id', $new_id, $old_id); $query = "UPDATE IGNORE vote_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); self::removeDoubles('voteanswers_user', 'answer_id', $new_id, $old_id); $query = "UPDATE IGNORE voteanswers_user SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Wiki $query = "UPDATE IGNORE wiki SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE wiki_locks SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Adressbucheinträge $query = "UPDATE IGNORE contact SET owner_id = ? WHERE owner_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); //Blubber $query = "UPDATE IGNORE blubber SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE blubber_follower SET studip_user_id = ? WHERE studip_user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE blubber_mentions SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE blubber_reshares SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); $query = "UPDATE IGNORE blubber_streams SET user_id = ? WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($new_id, $old_id)); NotificationCenter::postNotification('UserDidMigrate', $old_id, $new_id); $messages[] = _('Dateien, Termine, Adressbuch, Nachrichten und weitere Daten wurden migriert.'); return $messages; }
<?php //Uncomment these lines for debugging purposes //ini_set('error_reporting', E_ALL); //ini_set('display_errors', 'On'); //inlude the notification center class require_once 'ttw.notification.center.php'; //create an instance of the notification center $notifications = new NotificationCenter(); //process each command switch ($_GET['command']) { case 'save': return $notifications->save_notification($_GET, false); break; case 'get': return $notifications->get($_GET['category'], $_GET['read_status']); break; case 'get_new': return $notifications->get_new(); break; case 'delete': // return $notifications->delete_notification($_GET['id']); break; default: break; }
/** * creates a new studygroup with respect to given form data * * Triggers a StudygroupDidCreate notification using the ID of the * new studygroup as subject. * * @return void */ function create_action() { global $perm; $admin = $perm->have_perm('admin'); $errors = array(); CSRFProtection::verifyUnsafeRequest(); foreach ($GLOBALS['SEM_CLASS'] as $key => $class) { if ($class['studygroup_mode']) { $sem_class = $class; break; } } if (Request::getArray('founders')) { $founders = Request::optionArray('founders'); $this->flash['founders'] = $founders; } // search for founder if ($admin && Request::submitted('search_founder')) { $search_for_founder = Request::get('search_for_founder'); // do not allow to search with the empty string if ($search_for_founder) { // search for the user $query = "SELECT user_id, {$GLOBALS['_fullname_sql']['full_rev']} AS fullname, username, perms\n FROM auth_user_md5\n LEFT JOIN user_info USING (user_id)\n WHERE perms NOT IN ('root', 'admin')\n AND (username LIKE CONCAT('%', :needle, '%')\n OR Vorname LIKE CONCAT('%', :needle, '%')\n OR Nachname LIKE CONCAT('%', :needle, '%'))\n LIMIT 500"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':needle', $search_for_founder); $statement->execute(); $results_founders = $statement->fetchGrouped(PDO::FETCH_ASSOC); } if (is_array($results_founders)) { $this->flash['success'] = sizeof($results_founders) == 1 ? sprintf(_("Es wurde %s Person gefunden:"), sizeof($results_founders)) : sprintf(_("Es wurden %s Personen gefunden:"), sizeof($results_founders)); } else { $this->flash['info'] = _("Es wurden kein Personen gefunden."); } $this->flash['create'] = true; $this->flash['results_choose_founders'] = $results_founders; $this->flash['request'] = Request::getInstance(); // go to the form again $this->redirect('course/studygroup/new/'); } else { if ($admin && Request::submitted('add_founder')) { $founders = array(Request::option('choose_founder')); $this->flash['founders'] = $founders; $this->flash['create'] = true; $this->flash['request'] = Request::getInstance(); $this->redirect('course/studygroup/new/'); } else { if ($admin && Request::submitted('remove_founder')) { unset($founders); $this->flash['founders'] = $founders; $this->flash['create'] = true; $this->flash['request'] = Request::getInstance(); $this->redirect('course/studygroup/new/'); } else { if ($admin && Request::submitted('new_search')) { $this->flash['create'] = true; $this->flash['request'] = Request::getInstance(); $this->redirect('course/studygroup/new/'); } else { if (!Request::get('groupname')) { $errors[] = _("Bitte Gruppennamen angeben"); } else { $query = "SELECT 1 FROM seminare WHERE name = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array(Request::get('groupname'))); if ($statement->fetchColumn()) { $errors[] = _("Eine Veranstaltung/Studiengruppe mit diesem Namen existiert bereits. Bitte wählen Sie einen anderen Namen"); } } if (!Request::get('grouptermsofuse_ok')) { $errors[] = _("Sie müssen die Nutzungsbedingungen durch Setzen des Häkchens bei 'Einverstanden' akzeptieren."); } if ($admin && (!is_array($founders) || !sizeof($founders))) { $errors[] = _("Sie müssen mindestens einen Gruppengründer eintragen!"); } if (count($errors)) { $this->flash['errors'] = $errors; $this->flash['create'] = true; $this->flash['request'] = Request::getInstance(); $this->redirect('course/studygroup/new/'); } else { // Everything seems fine, let's create a studygroup $sem_types = studygroup_sem_types(); $sem = new Seminar(); $sem->name = Request::get('groupname'); // seminar-class quotes itself $sem->description = Request::get('groupdescription'); // seminar-class quotes itself $sem->status = $sem_types[0]; $sem->read_level = 1; $sem->write_level = 1; $sem->institut_id = Config::Get()->STUDYGROUP_DEFAULT_INST; $mods = new Modules(); $bitmask = 0; $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."); } $sem->admission_binding = 0; $semdata = new SemesterData(); $this_semester = $semdata->getSemesterDataByDate(time()); $sem->semester_start_time = $this_semester['beginn']; $sem->semester_duration_time = -1; if ($admin) { // insert founder(s) foreach ($founders as $user_id) { $stmt = DBManager::get()->prepare("INSERT INTO seminar_user\n (seminar_id, user_id, status, gruppe)\n VALUES (?, ?, 'dozent', 8)"); $stmt->execute(array($sem->id, $user_id)); } $this->founders = null; $this->flash['founders'] = null; } else { $user_id = $GLOBALS['auth']->auth['uid']; // insert dozent $query = "INSERT INTO seminar_user (seminar_id, user_id, status, gruppe)\n VALUES (?, ?, 'dozent', 8)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($sem->id, $user_id)); } // de-/activate modules $mods = new Modules(); $admin_mods = new AdminModules(); $bitmask = 0; $available_modules = StudygroupModel::getInstalledModules(); $active_plugins = Request::getArray('groupplugin'); foreach ($available_modules as $key => $enable) { $module_name = $sem_class->getSlotModule($key); if ($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"]); $methodActivate = "module" . ucfirst($key) . "Activate"; if (method_exists($admin_mods, $methodActivate)) { $admin_mods->{$methodActivate}($sem->id); } } } // always activate participants list $mods->setBit($bitmask, $mods->registered_modules["participants"]["id"]); $sem->modules = $bitmask; $sem->store(); // de-/activate plugins $available_plugins = StudygroupModel::getInstalledPlugins(); $plugin_manager = PluginManager::getInstance(); foreach ($available_plugins as $key => $name) { if (!$sem_class->isModuleAllowed($key)) { continue; } $plugin = $plugin_manager->getPlugin($key); $plugin_id = $plugin->getPluginId(); if ($active_plugins[$key] && $name) { $plugin_manager->setPluginActivated($plugin_id, $sem->id, true); } else { $plugin_manager->setPluginActivated($plugin_id, $sem->id, false); } } NotificationCenter::postNotification('StudygroupDidCreate', $sem->id); // the work is done. let's visit the brand new studygroup. $this->redirect(URLHelper::getURL('seminar_main.php?auswahl=' . $sem->id)); } } } } } }
/** * returns matching "old-style" DataFieldEntry object * * @return DataFieldEntry */ public function getTypedDatafield() { $range_id = $this->sec_range_id ? array($this->range_id, $this->sec_range_id) : $this->range_id; $df = DataFieldEntry::createDataFieldEntry($this->datafield, $range_id, $this->getValue('content')); $self = $this; $observer = function ($event, $object, $user_data) use($self) { if ($user_data['changed']) { $self->restore(); } }; NotificationCenter::addObserver($observer, '__invoke', 'DatafieldDidUpdate', $df); return $df; }
<?php /** * ForumIssue.php - Manage issues linked to postings * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * @author Till Glöggler <*****@*****.**> * @license http://www.gnu.org/licenses/gpl-3.0.html GPL version 3 * @category Stud.IP */ NotificationCenter::addObserver('ForumIssue', 'unlinkIssue', 'ForumBeforeDelete'); class ForumIssue { /** * Get the id of the topic linked to the issue denoted by the passed id. * * @param string $issue_id * @return string the id of the linked topic */ static function getThreadIdForIssue($issue_id) { $stmt = DBManager::get()->prepare("SELECT topic_id FROM forum_entries_issues\n WHERE issue_id = ?"); $stmt->execute(array($issue_id)); return $stmt->fetchColumn(); } /** * Create/Update the linked posting for the passed issue_id
public function setLabel($user_id, $label) { if ($GLOBALS['perm']->have_studip_perm('tutor', $this->getId(), $user_id)) { $statement = DBManager::get()->prepare( "UPDATE seminar_user " . "SET label = :label " . "WHERE user_id = :user_id " . "AND Seminar_id = :seminar_id " . ""); $statement->execute(array( 'user_id' => $user_id, 'seminar_id' => $this->getId(), 'label' => $label )); NotificationCenter::postNotification("CourseDidChangeMemberLabel", $this); } }
/** * This function updates an admission procedure * * The function checks, if user could be insert to the seminar. * The User gets a message, if he is inserted to the seminar * * @param string seminar_id the seminar_id of the seminar to calculate * @param boolean send_message should a system-message be send? * */ function normal_update_admission($seminar_id, $send_message = TRUE) { $messaging=new messaging; //Daten holen / Abfrage ob ueberhaupt begrenzt $seminar = Seminar::GetInstance($seminar_id); if($seminar->isAdmissionEnabled()){ $sem_preliminary = ($seminar->admission_prelim == 1); $cs = $seminar->getCourseSet(); //Veranstaltung einfach auffuellen (nach Lostermin und Ende der Kontingentierung) if (!$seminar->admission_disable_waitlist_move && $cs->hasAlgorithmRun()) { //anzahl der freien Plaetze holen $count = (int)$seminar->getFreeAdmissionSeats(); //Studis auswaehlen, die jetzt aufsteigen koennen $query = "SELECT user_id, username FROM admission_seminar_user LEFT JOIN auth_user_md5 USING (user_id) WHERE seminar_id = ? AND status = 'awaiting' ORDER BY position LIMIT " . (int)$count; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar->getId())); $temp = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($temp as $row) { //ok, here ist the "colored-group" meant (for grouping on meine_seminare), not the grouped seminars as above! $group = select_group($seminar->getSemesterStartTime()); if (!$sem_preliminary) { $query = "INSERT INTO seminar_user (user_id, Seminar_id, status, gruppe, mkdate) VALUES (?, ?, 'autor', ?, UNIX_TIMESTAMP())"; $statement = DBManager::get()->prepare($query); $statement->execute(array( $row['user_id'], $seminar->getId(), $group )); $affected = $statement->rowCount(); NotificationCenter::postNotification('UserDidEnterCourse', $seminar->getId(), $row['user_id']); } else { $query = "UPDATE admission_seminar_user SET status = 'accepted' WHERE user_id = ? AND seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array( $row['user_id'], $seminar->getId() )); $affected = $statement->rowCount(); } if ($affected > 0) { $log_message = 'Wurde automatisch aus der Warteliste in die Veranstaltung eingetragen.'; StudipLog::log('SEM_USER_ADD', $seminar->getId(), $row['user_id'], $sem_preliminary ? 'accepted' : 'autor', $log_message); if (!$sem_preliminary) { $query = "DELETE FROM admission_seminar_user WHERE user_id = ? AND seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array( $row['user_id'], $seminar->getId() )); $affected = $statement->rowCount(); } else { $affected = 0; } //User benachrichtigen if (($sem_preliminary || $affected > 0) && $send_message) { setTempLanguage($row['user_id']); if (!$sem_preliminary) { $message = sprintf (_('Sie sind in die Veranstaltung **%s (%s)** eingetragen worden, da für Sie ein Platz frei geworden ist. Ab sofort finden Sie die Veranstaltung in der Übersicht Ihrer Veranstaltungen. Damit sind Sie auch für die Präsenzveranstaltung zugelassen.'), $seminar->getName(), $seminar->getFormattedTurnus(true)); } else { $message = sprintf (_('Sie haben den Status vorläufig akzeptiert in der Veranstaltung **%s (%s)** erhalten, da für Sie ein Platz freigeworden ist.'), $seminar->getName(), $seminar->getFormattedTurnus(true)); } $subject = sprintf(_("Teilnahme an der Veranstaltung %s"),$seminar->getName()); restoreLanguage(); $messaging->insert_message($message, $row['username'], '____%system%____', FALSE, FALSE, '1', FALSE, $subject, true); } } } //Warteposition der restlichen User neu eintragen renumber_admission($seminar_id, FALSE); } $seminar->restore(); } }
/** * Current user is going to follow (add as buddy) the given user, who could * also be an external contact. */ public function follow_user_action() { if (!$GLOBALS['perm']->have_perm("autor")) { throw new AccessDeniedException(); } if (Request::get("external_contact")) { $user = BlubberExternalContact::find(Request::option("user_id")); } else { $user = new BlubberUser(Request::option("user_id")); } if (!$user->isNew()) { if (is_a($user, "BlubberExternalContact")) { $statement = DBManager::get()->prepare("INSERT IGNORE INTO blubber_follower " . "SET studip_user_id = :user_id, " . "external_contact_id = :contact_id, " . "left_follows_right = '1' " . ""); $success = $statement->execute(array('user_id' => $GLOBALS['user']->id, 'contact_id' => $user->getId())); if ($success) { NotificationCenter::postNotification('BlubberExternalContactDidAdd', $user); } } else { Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => $user->id))->store(); } } $this->render_json(array('success' => 1, 'message' => (string) MessageBox::success(_("Kontakt hinzugefügt")))); }
/** * This action remove a user from course * @param $course_id */ public function decline_action($course_id, $waiting = null) { $current_seminar = Seminar::getInstance($course_id); $ticket_check = Seminar_Session::check_ticket(Request::option('studipticket')); if (LockRules::Check($course_id, 'participants')) { $lockdata = LockRules::getObjectRule($course_id); PageLayout::postMessage(MessageBox::error(sprintf(_("Sie können sich nicht von der Veranstaltung <b>%s</b> abmelden."), htmlReady($current_seminar->name)))); if ($lockdata['description']) { PageLayout::postMessage(MessageBox::info(formatLinks($lockdata['description']))); } $this->redirect('my_courses/index'); return; } if (Request::option('cmd') == 'back') { $this->redirect('my_courses/index'); return; } if (Request::option('cmd') != 'kill' && Request::option('cmd') != 'kill_admission') { if ($current_seminar->admission_binding && Request::get('cmd') != 'suppose_to_kill_admission' && !LockRules::Check($current_seminar->getId(), 'participants')) { PageLayout::postMessage(MessageBox::error(sprintf(_("Die Veranstaltung <b>%s</b> ist als <b>bindend</b> angelegt.\n Wenn Sie sich abmelden wollen, müssen Sie sich an die Lehrende der Veranstaltung wenden."), htmlReady($current_seminar->name)))); $this->redirect('my_courses/index'); return; } if (Request::get('cmd') == 'suppose_to_kill') { // check course admission list(, $admission_end_time) = @array_values($current_seminar->getAdmissionTimeFrame()); $admission_enabled = $current_seminar->isAdmissionEnabled(); $admission_locked = $current_seminar->isAdmissionLocked(); if ($admission_enabled || $admission_locked || (int) $current_seminar->admission_prelim == 1) { $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die Berechtigung für die Veranstaltung und müssen sich ggf. neu anmelden!'), $current_seminar->name); } else { if (isset($admission_end_time) && $admission_end_time < time()) { $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Der Anmeldzeitraum ist abgelaufen und Sie können sich nicht wieder anmelden!'), $current_seminar->name); } else { $message = sprintf(_('Wollen Sie sich von der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name); } } $this->flash['cmd'] = 'kill'; } else { if (admission_seminar_user_get_position($GLOBALS['user']->id, $course_id) === false) { $message = sprintf(_('Wollen Sie sich von der Anmeldeliste der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name); } else { $message = sprintf(_('Wollen Sie sich von der Warteliste der Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die bereits erreichte Position und müssen sich ggf. neu anmelden!'), $current_seminar->name); } $this->flash['cmd'] = 'kill_admission'; } $this->flash['decline_course'] = true; $this->flash['course_id'] = $course_id; $this->flash['message'] = $message; $this->flash['studipticket'] = Seminar_Session::get_ticket(); $this->redirect('my_courses/index'); return; } else { if (!LockRules::Check($course_id, 'participants') && $ticket_check && Request::option('cmd') != 'back' && Request::get('cmd') != 'kill_admission') { $query = "DELETE FROM seminar_user WHERE user_id = ? AND Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($GLOBALS['user']->id, $course_id)); if ($statement->rowCount() == 0) { PageLayout::postMessage(MessageBox::error(_('In der ausgewählten Veranstaltung wurde die gesuchten Personen nicht gefunden und konnte daher nicht ausgetragen werden.'))); } else { // LOGGING StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst ausgetragen'); // enable others to do something after the user has been deleted NotificationCenter::postNotification('UserDidLeaveCourse', $course_id, $GLOBALS['user']->id); // Delete from statusgroups RemovePersonStatusgruppeComplete(get_username(), $course_id); // Are successor available update_admission($course_id); PageLayout::postMessage(MessageBox::success(sprintf(_("Erfolgreich von Veranstaltung <b>%s</b> abgemeldet."), htmlReady($current_seminar->name)))); } } else { // LOGGING StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst aus der Warteliste ausgetragen'); if ($current_seminar->isAdmissionEnabled()) { $prio_delete = AdmissionPriority::unsetPriority($current_seminar->getCourseSet()->getId(), $GLOBALS['user']->id, $course_id); } $query = "DELETE FROM admission_seminar_user WHERE user_id = ? AND seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($GLOBALS['user']->id, $course_id)); if ($statement->rowCount() || $prio_delete) { //Warteliste neu sortieren renumber_admission($course_id); //Pruefen, ob es Nachruecker gibt update_admission($course_id); PageLayout::postMessage(MessageBox::success(sprintf(_("Der Eintrag in der Anmelde- bzw. Warteliste der Veranstaltung <b>%s</b> wurde aufgehoben.\n Wenn Sie an der Veranstaltung teilnehmen wollen, müssen Sie sich erneut bewerben."), htmlReady($current_seminar->name)))); } } $this->redirect('my_courses/index'); return; } }
function observeNotifications() { \NotificationCenter::addObserver($this, 'onQuestionStarted', 'QuestionDidStart'); \NotificationCenter::addObserver($this, 'onQuestionStopped', 'QuestionDidStop'); }
function assertMatchingNotification($matcher, $subject) { // register observer $observer = $this->getMock("Observer"); NotificationCenter::addObserver($observer, 'update', 'SomeNotification', $matcher); // expect notication $observer->expects($this->once())->method('update')->with('SomeNotification', $subject); // fire! NotificationCenter::postNotification('SomeNotification', $subject); // remove observer NotificationCenter::removeObserver($observer); }
public function indexing_action() { if (!$GLOBALS['perm']->have_perm("root")) { throw new AccessDeniedException("Kein Zugriff"); } //indexiert Veranstaltungen: $db = DBManager::get(); $count = 0; $seminare = $db->query("SELECT * FROM seminare " . ""); $index = Globalsearch::get(); while ($seminar = $seminare->fetch(PDO::FETCH_ASSOC)) { $searchtext = $seminar['VeranstaltungsNummer'] . " " . $seminar['Name'] . " " . $seminar['Untertitel'] . " " . $seminar['Beschreibung'] . " " . $seminar['Sonstiges'] . " " . $seminar['Ort']; $sem_tree_ids = $db->query("SELECT sem_tree_id FROM seminar_sem_tree WHERE seminar_id = " . $db->quote($seminar['Seminar_id']))->fetchAll(PDO::FETCH_COLUMN, 0); $searchtext .= GlobalSearchPlugin::getStudyareaSearchstring($sem_tree_ids); $index->setEntry($seminar['Name'], "seminar", "details.php?cid=" . $seminar['Seminar_id'], $seminar['visible'] ? null : $seminar['Seminar_id'], $searchtext, CourseAvatar::getAvatar($seminar['Seminar_id'])->getImageTag(Avatar::SMALL) . " " . htmlReady($seminar['Name']), $seminar['Seminar_id']); $count++; } $users = $db->query("SELECT * FROM auth_user_md5 " . ""); while ($user = $users->fetch(PDO::FETCH_ASSOC)) { $searchtext = $user['Vorname'] . " " . $user['Nachname']; $index->setEntry($user['Vorname'] . " " . $user['Nachname'], "user", "about.php?username="******"never" ? null : $user['user_id'], $searchtext, Avatar::getAvatar($user['user_id'])->getImageTag(Avatar::SMALL) . " " . htmlReady($user['Vorname']) . " " . htmlReady($user['Nachname']), $user['user_id']); $count++; } $documents = $db->query("SELECT * FROM dokumente " . ""); while ($document = $documents->fetch(PDO::FETCH_ASSOC)) { $seminar_name = $db->query("SELECT Name FROM seminare WHERE Seminar_id = " . $db->quote($document['seminar_id']) . " ")->fetch(PDO::FETCH_COLUMN, 0); $searchtext = $document['name'] . " " . $document['description'] . " " . $document['filename']; $sem_tree_ids = $db->query("SELECT sem_tree_id FROM seminar_sem_tree WHERE seminar_id = " . $db->quote($document['seminar_id']))->fetchAll(PDO::FETCH_COLUMN, 0); $searchtext .= GlobalSearchPlugin::getStudyareaSearchstring($sem_tree_ids); $index->setEntry($document['name'] . ($seminar_name ? " in " . $seminar_name : ""), "document", "folder.php?cid=" . $document['seminar_id'] . "&cmd=all&open=" . $document['dokument_id'] . "#anker", $document['seminar_id'], $searchtext, "<strong>" . htmlReady($document['filename']) . "</strong>: " . htmlReady($document['description']), $document['dokument_id']); $count++; } $resources = $db->query("SELECT * FROM resources_objects WHERE category_id != '' " . ""); while ($object = $resources->fetch(PDO::FETCH_ASSOC)) { $index->setEntry($object['name'], "resource", "resources.php?show_object=" . $object['resource_id'] . "&view=view_schedule", null, $object['name'] . " " . $object['description'], htmlReady($object['description']), $object['resource_id']); $count++; } $postings = $db->query("SELECT * FROM px_topics "); while ($posting = $postings->fetchAll(PDO::FETCH_ASSOC)) { $posting_content = preg_replace("/\\[quote([=\\d\\w\\s]*)\\]([\\d\\w\\s]*)\\[\\/quote\\]/", "", $posting['description']); $posting_content = strip_tags(formatReady(str_replace("\n", " ", $posting_content))); $searchtext = get_fullname($posting['user_id']) . " " . $posting_content; $sem_tree_ids = $db->query("SELECT sem_tree_id FROM seminar_sem_tree WHERE seminar_id = " . $db->quote($posting['Seminar_id']))->fetchAll(PDO::FETCH_COLUMN, 0); $searchtext .= GlobalSearchPlugin::getStudyareaSearchstring($sem_tree_ids); $index->setEntry($posting['name'], "posting", "forum.php?cid=" . $posting['Seminar_id'] . "&view=tree&open=" . $posting['topic_id'] . "#anker", $posting['Seminar_id'], $searchtext, $posting_content, $posting['topic_id']); $count++; } $result_object = new stdClass(); $result_object->count = 0; NotificationCenter::postNotification("indexing_plugin_items", $result_object); $count += $result_object->count; if ($GLOBALS['IS_CLI']) { echo "Index ersellt mit " . $count . " Einträgen."; } else { $template = $this->getTemplate("indexing.php"); $template->set_attribute("count", $count); $template->set_attribute("plugin", $this); echo $template->render(); } }
/** * Renders the sidebar. * The sidebar will only be rendered if it actually contains any widgets. * It will use the template "sidebar.php" located at "templates/sidebar". * A notification is dispatched before and after the actual rendering * process. * * @return String The HTML code of the rendered sidebar. */ public function render() { $content = ''; if ($this->context_avatar === null) { $breadcrumbs = $this->getBreadCrumbs(); $keys = array_keys($breadcrumbs); if (reset($keys) === 'course') { $course = Course::findCurrent(); if ($course) { if ($course->getSemClass()->offsetGet('studygroup_mode')) { $avatar = StudygroupAvatar::getAvatar($course->id); } else { $avatar = CourseAvatar::getAvatar($course->id); } } else { $institute = Institute::findCurrent(); $avatar = InstituteAvatar::getAvatar($institute->id); } $this->setContextAvatar($avatar); } } NotificationCenter::postNotification('SidebarWillRender', $this); if ($this->hasWidgets()) { $template = $GLOBALS['template_factory']->open('sidebar/sidebar'); $template->widgets = $this->widgets; $template->image = $this->getImage(); $template->title = $this->getTitle(); $template->avatar = $this->context_avatar; $content = $template->render(); } NotificationCenter::postNotification('SidebarDidRender', $this); return $content; }
/** * default callback used to map specific callbacks to NotificationCenter * * @param string $cb_type callback type * @return boolean */ protected function cbNotificationMapper($cb_type) { if (isset($this->notification_map[$cb_type])) { try { foreach (words($this->notification_map[$cb_type]) as $notification) { NotificationCenter::postNotification($notification, $this); } } catch (NotificationVetoException $e) { return false; } } }
function in_archiv ($sem_id) { global $SEM_CLASS,$SEM_TYPE, $ARCHIV_PATH, $TMP_PATH, $ZIP_PATH, $ZIP_OPTIONS, $_fullname_sql; NotificationCenter::postNotification('CourseWillArchive', $sem_id); //Besorgen der Grunddaten des Seminars $query = "SELECT Seminar_id, Name, Untertitel, Beschreibung, start_time, Institut_id, status FROM seminare WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($sem_id)); $row = $statement->fetch(PDO::FETCH_ASSOC); $seminar_id = $row['Seminar_id']; $name = $row['Name']; $untertitel = $row['Untertitel']; $beschreibung = $row['Beschreibung']; $start_time = $row['start_time']; $heimat_inst_id = $row['Institut_id']; //Besorgen von einzelnen Daten zu dem Seminar $semester = new SemesterData; $all_semester = $semester->getAllSemesterData(); foreach ($all_semester as $sem) { if (($start_time >= $sem['beginn']) && ($start_time <= $sem['ende'])) { $semester_tmp = $sem['name']; } } //Studienbereiche if ($SEM_CLASS[$SEM_TYPE[$row['status']]['class']]['bereiche']) { $sem_path = get_sem_tree_path($seminar_id); if (is_array($sem_path)) { $studienbereiche = join(', ', $sem_path); } } // das Heimatinstitut als erstes $query = "SELECT Name FROM Institute WHERE Institut_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($heimat_inst_id)); $institute = $statement->fetchColumn(); // jetzt den Rest $query = "SELECT Name FROM Institute LEFT JOIN seminar_inst USING (institut_id) WHERE seminar_id = ? AND Institute.Institut_id != ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id, $heimat_inst_id)); while ($temp = $statement->fetchColumn()) { $institute .= ', ' . $temp; } $query = "SELECT GROUP_CONCAT({$_fullname_sql['full']} SEPARATOR ', ') FROM seminar_user LEFT JOIN auth_user_md5 USING (user_id) LEFT JOIN user_info USING (user_id) WHERE seminar_id = ? AND seminar_user.status = 'dozent'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id)); $dozenten = $statement->fetchColumn(); $query = "SELECT fakultaets_id FROM seminare LEFT JOIN Institute USING (Institut_id) WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id)); $fakultaet_id = $statement->fetchColumn(); $query = "SELECT GROUP_CONCAT(DISTINCT c.Name SEPARATOR ' | ') FROM seminar_inst AS a LEFT JOIN Institute AS b USING (Institut_id) LEFT JOIN Institute AS c ON (c.Institut_id = b.fakultaets_id) WHERE a.seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id)); $fakultaet = $statement->fetchColumn(); setTempLanguage(); // use $DEFAULT_LANGUAGE for archiv-dumps //Dump holen $dump = dump_sem($sem_id, 'nobody'); //Forumdump holen foreach (PluginEngine::getPlugins('ForumModule', $sem_id) as $plugin) { $forumdump .= $plugin->getDump($sem_id); } // Wikidump holen $wikidump = getAllWikiPages($sem_id, $name, FALSE); restoreLanguage(); //OK, naechster Schritt: Kopieren der Personendaten aus seminar_user in archiv_user $query = "INSERT INTO archiv_user (seminar_id, user_id, status) SELECT Seminar_id, user_id, status FROM seminar_user WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id)); // Eventuelle Vertretungen in der Veranstaltung haben weiterhin Zugriff mit Dozentenrechten if (get_config('DEPUTIES_ENABLE')) { $deputies = getDeputies($seminar_id); // Eintragen ins Archiv mit Zugriffsberechtigung "dozent" $query = "INSERT IGNORE INTO archiv_user SET seminar_id = ?, user_id = ?, status = 'dozent'"; $statement = DBManager::get()->prepare($query); foreach ($deputies as $deputy) { $statement->execute(array($seminar_id, $deputy['user_id'])); } } $Modules = new Modules; $Modules = $Modules->getLocalModules($sem_id); $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $sem_id,'entity_type' => 'sem')); if ($Modules['documents_folder_permissions'] || StudipDocumentTree::ExistsGroupFolders($sem_id)) { $unreadable_folders = $folder_tree->getUnReadableFolders('nobody'); } $query = "SELECT COUNT(dokument_id) FROM dokumente WHERE seminar_id = ? AND url = ''"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id)); $count = $statement->fetchColumn(); if ($count) { $hash_secret = "frauen"; $archiv_file_id = md5(uniqid($hash_secret,1)); //temporaeres Verzeichnis anlegen $tmp_full_path = "$TMP_PATH/$archiv_file_id"; mkdir($tmp_full_path, 0700); if($folder_tree->getNumKids('root')) { $list = $folder_tree->getKids('root'); } if (is_array($list) && count($list) > 0) { $query = "SELECT folder_id, name FROM folder WHERE range_id IN (?) ORDER BY name"; $statement = DBManager::get()->prepare($query); $statement->execute(array($list)); $folder = 0; while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $folder += 1; $temp_folder = $tmp_full_path . "/[$folder]_" . prepareFilename($row['name'], FALSE); mkdir($temp_folder, 0700); createTempFolder($row['folder_id'], $temp_folder, $seminar_id, 'nobody'); } //zip all the stuff $archiv_full_path = "$ARCHIV_PATH/$archiv_file_id"; create_zip_from_directory($tmp_full_path, $tmp_full_path); @rename($tmp_full_path . '.zip', $archiv_full_path); } rmdirr($tmp_full_path); if (is_array($unreadable_folders)) { $query = "SELECT dokument_id FROM dokumente WHERE seminar_id = ? AND url = '' AND range_id IN (?)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id, $unreadable_folders)); $archiv_protected_file_id = createSelectedZip($statement->fetchAll(PDO::FETCH_COLUMN), false, false); @rename("$TMP_PATH/$archiv_protected_file_id", "$ARCHIV_PATH/$archiv_protected_file_id"); } } else { $archiv_file_id = ''; } //Reinschreiben von diversem Klumpatsch in die Datenbank $query = "INSERT INTO archiv (seminar_id, name, untertitel, beschreibung, start_time, semester, heimat_inst_id, institute, dozenten, fakultaet, dump, archiv_file_id,archiv_protected_file_id, forumdump, wikidump, studienbereiche, mkdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP())"; $statement = DBManager::get()->prepare($query); $success = $statement->execute(array( $seminar_id, $name ?: '', $untertitel ?: '', $beschreibung ?: '', $start_time, $semester_tmp ?: '', $heimat_inst_id, $institute ?: '', $dozenten ?: '', $fakultaet ?: '', $dump ?: '', $archiv_file_id ?: '', $archiv_protected_file_id ?: '', $forumdump ?: '', $wikidump ?: '', $studienbereiche ?: '', )); if ($success) { NotificationCenter::postNotification('CourseDidArchive', $seminar_id); } }
/** * Saves a cycle */ public function saveCycle_action() { CSRFProtection::verifyRequest(); $start = strtotime(Request::get('start_time')); $end = strtotime(Request::get('end_time')); if (date('H', $start) > date('H', $end)) { $this->storeRequest(); PageLayout::postMessage(MessageBox::error(_('Die Zeitangaben sind nicht korrekt. Bitte überprüfen Sie diese!'))); $this->redirect('course/timesrooms/createCycle'); return; } $cycle = new SeminarCycleDate(); $cycle->seminar_id = $this->course->id; $cycle->weekday = Request::int('day'); $cycle->description = Request::get('description'); $cycle->sws = round(Request::float('teacher_sws'), 1); $cycle->cycle = Request::int('cycle'); $cycle->week_offset = Request::int('startWeek'); $cycle->end_offset = Request::int('endWeek') ?: null; $cycle->start_time = date('H:i:00', $start); $cycle->end_time = date('H:i:00', $end); if ($cycle->store()) { $cycle_info = $cycle->toString(); NotificationCenter::postNotification('CourseDidChangeSchedule', $this); $this->course->createMessage(sprintf(_('Die regelmäßige Veranstaltungszeit %s wurde hinzugefügt!'), $cycle_info)); $this->displayMessages(); if (Request::get('fromDialog') == 'true') { $this->redirect('course/timesrooms/index'); } else { $this->relocate('course/timesrooms/index'); } } else { $this->storeRequest(); $this->course->createError(_('Die regelmäßige Veranstaltungszeit konnte nicht hinzugefügt werden! Bitte überprüfen Sie Ihre Eingabe.')); $this->displayMessages(); $this->redirect('course/timesrooms/createCycle'); } }
/** * Mark the navigation item at the given path as active. * This is just a shortcut for doing: * * Navigation::getItem($path)->setActive(true) * * @param string $path path of navigation item */ public static function activateItem($path) { self::getItem($path)->setActive(true); NotificationCenter::postNotification('NavigationDidActivateItem', $path); }
/** * @return number of courses that this filter would return */ public function countCourses() { NotificationCenter::postNotification("AdminCourseFilterWillQuery", $this); if (empty($this->settings['query']['where'])) { return 0; } return DBManager::get()->fetchColumn($this->createQuery(true), $this->settings['parameter']); }