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); }
public function isAnswerable() { if (!$this->isViewable()) { return false; } if ($this->isEditable()) { return true; } $this->answerable = true; NotificationCenter::postNotification("QuestionnaireWillAllowToAnswer", $this); return $this->answerable; }
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'); }
/** * 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'); } }
/** * Stores this datafield entry * * @return int representing the number of changed entries */ public function store() { $entry = new DatafieldEntryModel(array($this->model->id, (string) $this->getRangeID(), (string) $this->getSecondRangeID())); $old_value = $entry->content; $entry->content = $this->getValue(); if ($this->isEmpty()) { $result = $entry->delete(); } else { $result = $entry->store(); } if ($result) { NotificationCenter::postNotification('DatafieldDidUpdate', $this, array('changed' => $result, 'old_value' => $old_value)); } return $result; }
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); } }
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); }
/** * 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; }
/** * TODO */ function stop() { $this->executeStop(); $ok = !$this->isError(); if ($ok) { \NotificationCenter::postNotification('QuestionDidStop', $this); } return $ok; }
// This also binds the global $_SESSION['SessionSeminar'] // variable to the URL parameter 'cid' for all generated links. if (isset($course_id)) { selectSem($course_id) || selectInst($course_id); unset($course_id); } if (Request::get("sober") && ($GLOBALS['user']->id === "nobody" || $GLOBALS['perm']->have_perm("root"))) { //deactivate non-core-plugins: URLHelper::bindLinkParam("sober", $sober); PluginManager::$sober = true; } // load the default set of plugins PluginEngine::loadPlugins(); // add navigation item: add modules if ((Navigation::hasItem('/course/admin') || $GLOBALS['perm']->have_perm('admin')) && ($perm->have_studip_perm('tutor', $SessSemName[1]) && $SessSemName['class'] == 'sem') && ($SessSemName['class'] != 'sem' || !$GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$SessSemName['art_num']]['class']]['studygroup_mode'])) { $plus_nav = new Navigation(_('Mehr …'), 'dispatch.php/course/plus/index'); $plus_nav->setDescription(_("Mehr Stud.IP-Funktionen für Ihre Veranstaltung")); Navigation::addItem('/course/modules', $plus_nav); } // add navigation item for profile: add modules if (Navigation::hasItem('/profile/edit')) { $plus_nav = new Navigation(_('Mehr …'), 'dispatch.php/profilemodules/index'); $plus_nav->setDescription(_("Mehr Stud.IP-Funktionen für Ihr Profil")); Navigation::addItem('/profile/modules', $plus_nav); } if ($user_did_login) { NotificationCenter::postNotification('UserDidLogin', $user->id); } if ($seminar_open_redirected) { startpage_redirect(UserConfig::get($user->id)->PERSONAL_STARTPAGE); }
/** * Create a new document using the given file and metadata. * This method makes sure that there are no inconsistencies between a real * file and its database entry. Only if the file were copied/moved to the * documents folder, the database entry is written. If this fails too, the * file will be unlinked again. * The first parameter can either be an uploaded file or the path to an * already existing one. This file will either be moved using * move_uploaded_file or it will be copied. * The destination is determined this way: If the second parameter $data * already contains a "dokument_id", this will be used as the file's * destination. This is usually the case when refreshing a file. * If there is no such parameter, a new "dokument_id" is generated as usual * and is used as the file's destination. * * Before a document (and its file) is created, the notification * "DocumentWillCreate" will be posted. * If the document was created successfuly, the notification * "DocumentDidCreate" will be posted. * It the document was updated rather than created (see above), the * notifications will be "DocumentWillUpdate" and "DocumentDidUpdate". * The subject of the notification will always be that document. * * @param $file string full path to a file (either uploaded or already existing) * @param $data array an array containing the metadata of the document; * just use the same way as StudipDocument::setData * @return StudipDocument|null if successful the created document, null otherwise */ static function createWithFile($file, $data) { $doc = new StudipDocument(@$data['dokument_id']); $doc->setData($data); // create new ID (and thus path) if (!$doc->getId()) { $doc->setId($doc->getNewId()); } $notifications = !isset($data['dokument_id']) ? array('DocumentWillCreate', 'DocumentDidCreate') : array('DocumentWillUpdate', 'DocumentDidUpdate'); // send DocumentWill(Create|Update) notification NotificationCenter::postNotification($notifications[0], $doc); if (!$doc->attachFile($file) || !$doc->safeStore()) { return null; } // send DocumentDid(Create|Update) notification NotificationCenter::postNotification($notifications[1], $doc); return $doc; }
/** * Lets the user compose a message and send it. */ public function write_action() { PageLayout::setTitle(_("Neue Nachricht schreiben")); //collect possible default adressees $this->to = array(); $this->default_message = new Message(); if (Request::username("rec_uname")) { $user = new MessageUser(); $user->setData(array('user_id' => get_userid(Request::username("rec_uname")), 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } if (Request::getArray("rec_uname")) { foreach (Request::usernameArray("rec_uname") as $username) { $user = new MessageUser(); $user->setData(array('user_id' => get_userid($username), 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } } if (Request::option("group_id")) { $this->default_message->receivers = array(); $group = Statusgruppen::find(Request::option("group_id")); if ($group['range_id'] === $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm("autor", $group['range_id'])) { foreach ($group->members as $member) { $user = new MessageUser(); $user->setData(array('user_id' => $member['user_id'], 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; } } } if (Request::get('inst_id') && $GLOBALS['perm']->have_perm('admin')) { $query = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms != 'user'"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('inst_id')), 'MessageUser::build'); } if (Request::get("filter") && Request::option("course_id")) { $course = new Course(Request::option('course_id')); if ($GLOBALS['perm']->have_studip_perm("tutor", Request::option('course_id')) || $course->getSemClass()['studygroup_mode']) { $this->default_message->receivers = array(); if (Request::get("filter") === 'claiming') { $cs = CourseSet::getSetForCourse(Request::option("course_id")); if (is_object($cs) && !$cs->hasAlgorithmRun()) { foreach (AdmissionPriority::getPrioritiesByCourse($cs->getId(), Request::option("course_id")) as $user_id => $p) { $this->default_message->receivers[] = MessageUser::build(array('user_id' => $user_id, 'snd_rec' => 'rec')); } } } else { $params = array(Request::option('course_id'), Request::option('who')); switch (Request::get("filter")) { case 'send_sms_to_all': $query = "SELECT b.user_id,'rec' as snd_rec FROM seminar_user a, auth_user_md5 b WHERE a.Seminar_id = ? AND a.user_id = b.user_id AND a.status = ? ORDER BY Nachname, Vorname"; break; case 'all': $query = "SELECT user_id,'rec' as snd_rec FROM seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE Seminar_id = ? ORDER BY Nachname, Vorname"; break; case 'prelim': $query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='accepted' ORDER BY Nachname, Vorname"; break; case 'awaiting': $query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='awaiting' ORDER BY Nachname, Vorname"; break; case 'inst_status': $query = "SELECT b.user_id,'rec' as snd_rec FROM user_inst a, auth_user_md5 b WHERE a.Institut_id = ? AND a.user_id = b.user_id AND a.inst_perms = ? ORDER BY Nachname, Vorname"; break; } $this->default_message->receivers = DBManager::get()->fetchAll($query, $params, 'MessageUser::build'); } } } if (Request::option('prof_id') && Request::option('deg_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ? AND abschluss_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('prof_id'), Request::option('deg_id')), 'MessageUser::build'); } if (Request::option('sd_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE abschluss_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sd_id')), 'MessageUser::build'); } if (Request::option('sp_id') && $GLOBALS['perm']->have_perm('root')) { $query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ?"; $this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sp_id')), 'MessageUser::build'); } if (!$this->default_message->receivers->count() && is_array($_SESSION['sms_data']['p_rec'])) { $this->default_message->receivers = DBManager::get()->fetchAll("SELECT user_id,'rec' as snd_rec FROM auth_user_md5 WHERE username IN(?) ORDER BY Nachname,Vorname", array($_SESSION['sms_data']['p_rec']), 'MessageUser::build'); unset($_SESSION['sms_data']); } if (Request::option("answer_to")) { $this->default_message->receivers = array(); $old_message = new Message(Request::option("answer_to")); if (!$old_message->permissionToRead()) { throw new AccessDeniedException("Message is not for you."); } if (!Request::get('forward')) { if (Request::option("quote") === $old_message->getId()) { if (Studip\Markup::isHtml($old_message['message'])) { $this->default_message['message'] = "<div>[quote]\n" . $old_message['message'] . "\n[/quote]</div>"; } else { $this->default_message['message'] = "[quote]\n" . $old_message['message'] . "\n[/quote]"; } } $this->default_message['subject'] = substr($old_message['subject'], 0, 4) === "RE: " ? $old_message['subject'] : "RE: " . $old_message['subject']; $user = new MessageUser(); $user->setData(array('user_id' => $old_message['autor_id'], 'snd_rec' => "rec")); $this->default_message->receivers[] = $user; $this->answer_to = $old_message->id; } else { $messagesubject = 'FWD: ' . $old_message['subject']; $message = _("-_-_ Weitergeleitete Nachricht _-_-"); $message .= "\n" . _("Betreff") . ": " . $old_message['subject']; $message .= "\n" . _("Datum") . ": " . strftime('%x %X', $old_message['mkdate']); $message .= "\n" . _("Von") . ": " . get_fullname($old_message['autor_id']); $num_recipients = $old_message->getNumRecipients(); if ($GLOBALS['user']->id == $old_message->autor_id) { $message .= "\n" . _("An") . ": " . ($num_recipients == 1 ? _('Eine Person') : sprintf(_('%s Personen'), $num_recipients)); } else { $message .= "\n" . _("An") . ": " . $GLOBALS['user']->getFullname() . ($num_recipients > 1 ? ' ' . sprintf(_('(und %d weitere)'), $num_recipients) : ''); } $message .= "\n\n"; if (Studip\Markup::isHtml($old_message['message'])) { $message = '<div>' . htmlReady($message, false, true) . '</div>' . $old_message['message']; } else { $message .= $old_message['message']; } if (count($old_message->attachments)) { Request::set('message_id', $old_message->getNewId()); foreach ($old_message->attachments as $attachment) { $attachment->range_id = 'provisional'; $attachment->seminar_id = $GLOBALS['user']->id; $attachment->autor_host = $_SERVER['REMOTE_ADDR']; $attachment->user_id = $GLOBALS['user']->id; $attachment->description = Request::option('message_id'); $new_attachment = $attachment->toArray(array('range_id', 'user_id', 'seminar_id', 'name', 'description', 'filename', 'filesize')); $new_attachment = StudipDocument::createWithFile(get_upload_file_path($attachment->getId()), $new_attachment); $this->default_attachments[] = array('icon' => GetFileIcon(getFileExtension($new_attachment['filename']))->asImg(['class' => "text-bottom"]), 'name' => $new_attachment['filename'], 'document_id' => $new_attachment->id, 'size' => relsize($new_attachment['filesize'], false)); } } $this->default_message['subject'] = $messagesubject; $this->default_message['message'] = $message; } } if (Request::get("default_body")) { $this->default_message['message'] = Request::get("default_body"); } if (Request::get("default_subject")) { $this->default_message['subject'] = Request::get("default_subject"); } $settings = UserConfig::get($GLOBALS['user']->id)->MESSAGING_SETTINGS; $this->mailforwarding = Request::get('emailrequest') ? true : $settings['request_mail_forward']; if (trim($settings['sms_sig'])) { if (Studip\Markup::isHtml($this->default_message['message']) || Studip\Markup::isHtml($settings['sms_sig'])) { if (!Studip\Markup::isHtml($this->default_message['message'])) { $this->default_message['message'] = '<div>' . nl2br($this->default_message['message']) . '</div>'; } $this->default_message['message'] .= '<br><br>--<br>'; if (Studip\Markup::isHtml($settings['sms_sig'])) { $this->default_message['message'] .= $settings['sms_sig']; } else { $this->default_message['message'] .= formatReady($settings['sms_sig']); } } else { $this->default_message['message'] .= "\n\n--\n" . $settings['sms_sig']; } } NotificationCenter::postNotification("DefaultMessageForComposerCreated", $this->default_message); }
public function store() { NotificationCenter::postNotification("PostingWillSave", $this); $success = parent::store(); if ($success) { NotificationCenter::postNotification("PostingHasSaved", $this); } return $success; }
/** * Renders the help bar. * The helpbar will only be rendered if it actually contains any widgets. * It will use the template "helpbar.php" located at "templates/helpbar". * A notification is dispatched before and after the actual rendering * process. * * @return String The HTML code of the rendered helpbar. */ public function render() { $this->loadContent(); // add tour links if (Config::get()->TOURS_ENABLE) { $widget = new HelpbarTourWidget(); if ($widget->hasElements()) { $this->addWidget($widget); } $tour_data = $widget->tour_data; } // add wiki link and remove it from navigation $this->addLink(_('Weiterführende Hilfe'), format_help_url(PageLayout::getHelpKeyword()), Icon::create('link-extern', 'info_alt'), '_blank'); $content = ''; NotificationCenter::postNotification('HelpbarWillRender', $this); if ($this->should_render && $this->hasWidgets()) { $template = $GLOBALS['template_factory']->open('helpbar/helpbar'); $template->widgets = $this->widgets; $template->open = $this->open; $template->tour_data = $tour_data; $content = $template->render(); } NotificationCenter::postNotification('HelpbarDidRender', $this); return $content; }
/** * @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']); }
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(); } }
/** * 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; } } }
/** * 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; }
/** * 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")))); }
/** * 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'])); } }
/** * 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(); } }
/** * 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; } }
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); } }
/** * 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)); } } } } } }
/** * 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; }
/** * 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); }
/** * Delete WikiPage version and adjust backlinks. * * @param string WikiPage name * @param string WikiPage version * @param string ID of seminar/einrichtung * * @return string WikiPage name to display next * **/ function deleteWikiPage($keyword, $version, $range_id) { global $perm, $SessSemName, $dellatest; if (!$perm->have_studip_perm("tutor", $SessSemName[1])) { throw new AccessDeniedException(_('Sie haben keine Berechtigung, Seiten zu löschen.')); } $lv=getLatestVersion($keyword, $SessSemName[1]); if ($lv["version"] != $version) { throw new InvalidArgumentException(_('Die Version, die Sie löschen wollen, ist nicht die aktuellste. Überprüfen Sie, ob inzwischen eine aktuellere Version erstellt wurde.')); } NotificationCenter::postNotification('WikiPageWillDelete', array($range_id, $keyword)); $query = "DELETE FROM wiki WHERE keyword = ? AND version = ? AND range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($keyword, $version, $range_id)); NotificationCenter::postNotification('WikiPageDidDelete', array($range_id, $keyword)); if (!keywordExists($keyword)) { // all versions have gone $addmsg = '<br>' . sprintf(_("Damit ist die Seite %s mit allen Versionen gelöscht."),'<b>'.htmlReady($keyword).'</b>'); $newkeyword = "WikiWikiWeb"; } else { $newkeyword = $keyword; $addmsg = ""; } $message = MessageBox::info(sprintf(_('Version %s der Seite %s gelöscht.'), htmlReady($version), '<b>'.htmlReady($keyword).'</b>') . $addmsg); PageLayout::postMessage($message); if ($dellatest) { $lv=getLatestVersion($keyword, $SessSemName[1]); if ($lv) { $body=""; } else { $body=$lv["body"]; } refreshBacklinks($keyword, $body); } return $newkeyword; }