private function generateCommentsHTML()
 {
     $comments = $this->article->getComments();
     $this->commentHTML = "";
     if (getStyle()->doCommentHTML()) {
         try {
             $this->commentHTML = getStyle()->getCommentsHTML($comments);
         } catch (Exception $e) {
             $msgbox = new MessageBox("The style didn't generate the HTML code for the comments, therefore the default generator was used. <br /><br />To hide this message open <br />" . getStyle()->getStylePath() . "info.xml<br /> and set <strong>own_comment_html</strong> to <strong>false</strong>.");
             $msgbox->bindException($e);
             getDisplay()->addObject($msgbox);
             foreach ($comments as $comment) {
                 $this->commentHTML .= $comment->toHTML();
             }
         }
     } else {
         foreach ($comments as $comment) {
             $this->commentHTML .= $comment->toHTML();
         }
     }
     $LCID = 0;
     if (count($comments) != 0) {
         $LCID = $comments[0]->getID();
     }
     $ajaxPC = new CommentPoster($this->article->getID());
     $ajaxPC->start();
     $ajaxLC = new CommentLoader($this->article->getID(), $LCID, count($comments));
     $ajaxLC->start();
 }
 public function main($args)
 {
     if (!isset($args['error_code'])) {
         $msgbox = new MessageBox("Can't render error frontend: missing argument 'error_code'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     if (!is_numeric($args['error_code'])) {
         $msgbox = new MessageBox("Can't render article frontend: wrong argument 'error_code'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     $this->errorCode = $args['error_code'];
 }
 public function main($args)
 {
     if (!isset($args['page'])) {
         $msgbox = new MessageBox("Can't render page frontend: missing argument 'page'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     if ($args['page'] instanceof Page == false) {
         $msgbox = new MessageBox("Can't render page frontend: wrong argument 'page'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     $this->page = $args['page'];
 }
Esempio n. 4
0
 public function index_action()
 {
     if (Request::isPost() && Request::option("termin_id") && Request::get("topic_title")) {
         $date = new CourseDate(Request::option("termin_id"));
         $seminar_id = $date['range_id'];
         $title = Request::get("topic_title");
         $topic = CourseTopic::findByTitle($seminar_id, $title);
         if (!$topic) {
             $topic = new CourseTopic();
             $topic['title'] = $title;
             $topic['seminar_id'] = $seminar_id;
             $topic['author_id'] = $GLOBALS['user']->id;
             $topic['description'] = "";
             $topic->store();
         }
         $success = $date->addTopic($topic);
         if ($success) {
             PageLayout::postMessage(MessageBox::success(_("Thema wurde hinzugefügt.")));
         } else {
             PageLayout::postMessage(MessageBox::info(_("Thema war schon mit dem Termin verknüpft.")));
         }
     }
     Navigation::activateItem('/course/schedule/dates');
     object_set_visit_module("schedule");
     $this->last_visitdate = object_get_visit(Course::findCurrent()->id, 'schedule');
     $this->dates = Course::findCurrent()->getDatesWithExdates();
     $this->lecturer_count = Course::findCurrent()->countMembersWithStatus('dozent');
 }
 protected function _validPerform($request, $response)
 {
     $mail_data = $this->dataspace->export();
     if (isset($mail_data['sender_name'])) {
         $sender_name = $mail_data['sender_name'];
     } else {
         $sender_name = $mail_data['sender_firstname'] . ' ' . $mail_data['sender_lastname'];
     }
     $body = sprintf(Strings::get('body_template', 'feedback'), $sender_name, $mail_data['sender_email'], $mail_data['body']);
     $body = str_replace('<br>', "\n", $body);
     $subject = $this->_getMailSubject();
     $recipient_email = $this->_getEmail();
     $mailer = $this->_getMailer();
     $headers['From'] = $mail_data['sender_email'];
     $headers['To'] = $recipient_email;
     $headers['Subject'] = $subject;
     if (!$recipient_email || !$mailer->send($recipient_email, $headers, $body)) {
         MessageBox::writeNotice(Strings::get('mail_not_sent', 'feedback'));
         $request->setStatus(Request::STATUS_FAILUER);
         return;
     }
     MessageBox::writeNotice(Strings::get('message_was_sent', 'feedback'));
     $request->setStatus(Request::STATUS_FORM_SUBMITTED);
     $response->redirect($_SERVER['PHP_SELF']);
 }
Esempio n. 6
0
 public function fetchData()
 {
     if ($this->already_fetched) {
         return;
     }
     $this->already_fetched = true;
     try {
         if (!$this->customImportEnabled()) {
             if (in_array($this['source'], array("csv_upload", "extern"))) {
                 return;
             } elseif ($this['source'] === "database") {
                 $this->fetchDataFromDatabase();
                 return;
             } elseif ($this['source'] === "csv_weblink") {
                 $this->fetchDataFromWeblink();
                 return;
             } elseif ($this['source'] === "csv_studipfile") {
                 $output = $this->getCSVDataFromFile(get_upload_file_path($this['tabledata']['weblink']['file_id']), ";");
                 $headline = array_shift($output);
                 $this->createTable($headline, $output);
                 return;
             }
         } else {
             $this->getPlugin()->fetchData();
         }
     } catch (Exception $e) {
         PageLayout::postMessage(MessageBox::error(sprintf(_("Konnte Tabelle '%s' nicht mit Daten befüllen."), $this['name'])));
     }
 }
Esempio n. 7
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     // Lock context to user id
     $this->owner = $GLOBALS['user'];
     $this->context_id = $this->owner->id;
     $this->full_access = true;
     if (Config::get()->PERSONALDOCUMENT_OPEN_ACCESS) {
         $username = Request::username('username', $GLOBALS['user']->username);
         $user = User::findByUsername($username);
         if ($user && $user->id !== $GLOBALS['user']->id) {
             $this->owner = $user;
             $this->context_id = $user->id;
             $this->full_access = Config::get()->PERSONALDOCUMENT_OPEN_ACCESS_ROOT_PRIVILEDGED && $GLOBALS['user']->perms === 'root';
             URLHelper::bindLinkParam('username', $username);
         }
     }
     $this->limit = $GLOBALS['user']->cfg->PERSONAL_FILES_ENTRIES_PER_PAGE ?: Config::get()->ENTRIES_PER_PAGE;
     $this->userConfig = DocUsergroupConfig::getUserConfig($GLOBALS['user']->id);
     if ($this->userConfig['area_close'] == 1) {
         $this->redirect('document/closed/index');
     }
     if (Request::isPost()) {
         CSRFProtection::verifySecurityToken();
     }
     if (($ticket = Request::get('studip-ticket')) && !check_ticket($ticket)) {
         $message = _('Bei der Verarbeitung Ihrer Anfrage ist ein Fehler aufgetreten.') . "\n" . _('Bitte versuchen Sie es erneut.');
         PageLayout::postMessage(MessageBox::error($message));
         $this->redirect('document/files/index');
     }
 }
Esempio n. 8
0
 function index_action()
 {
     $form_fields['comment'] = array('caption' => _("Kommentar"), 'type' => 'textarea', 'attributes' => array('rows' => 4, 'style' => 'width:100%'));
     $form_fields['snd_message'] = array('caption' => _("Benachrichtigung über ausfallende Termine an alle Teilnehmer verschicken"), 'type' => 'checkbox', 'attributes' => array('style' => 'vertical-align:middle'));
     $form_buttons['save_close'] = array('caption' => _('OK'), 'info' => _("Termine absagen und Dialog schließen"));
     $form = new StudipForm($form_fields, $form_buttons, 'cancel_dates', false);
     if ($form->isClicked('save_close')) {
         $sem = Seminar::getInstance($this->course_id);
         $comment = $form->getFormFieldValue('comment');
         foreach ($this->dates as $date) {
             $sem->cancelSingleDate($date->getTerminId(), $date->getMetadateId());
             $date->setComment($comment);
             $date->setExTermin(true);
             $date->store();
         }
         if ($form->getFormFieldValue('snd_message') && count($this->dates)) {
             $snd_messages = raumzeit_send_cancel_message($comment, $this->dates);
             if ($snd_messages) {
                 $msg = sprintf(_("Es wurden %s Benachrichtigungen gesendet."), $snd_messages);
             }
         }
         PageLayout::postMessage(MessageBox::success(_("Folgende Termine wurden abgesagt") . ($msg ? ' (' . $msg . '):' : ':'), array_map(function ($d) {
             return $d->toString();
         }, $this->dates)));
         $this->redirect($this->url_for('course/dates'));
     }
     $this->form = $form;
 }
Esempio n. 9
0
 /**
  * create an object outbox for a user and with some stragegies
  *
  * @param int $userId user identification
  * @param SelectorStrategy $messageStrategy strategy to apply 
  */
 public function __construct($userId = NULL, $messageStrategy = NULL)
 {
     if (is_null($messageStrategy)) {
         $messageStrategy = new OutBoxStrategy();
     }
     parent::__construct($messageStrategy, $userId);
 }
 protected function _validPerform($request, $response)
 {
     $data = $this->dataspace->export();
     $request->setStatus(Request::STATUS_FAILURE);
     if ($request->hasAttribute('popup')) {
         $response->write(closePopupResponse($request));
     }
     if (!isset($data['ids']) || !is_array($data['ids'])) {
         return;
     }
     $objects = $this->_getObjectsToDelete(array_keys($data['ids']));
     foreach ($objects as $id => $item) {
         if ($item['delete_status'] !== 0) {
             continue;
         }
         $site_object = wrapWithSiteObject($item);
         try {
             $site_object->delete();
         } catch (LimbException $e) {
             MessageBox::writeNotice("object {$id} - {$item['title']} couldn't be deleted!");
             $request->setStatus(Request::STATUS_FAILURE);
             throw $e;
         }
     }
     $request->setStatus(Request::STATUS_SUCCESS);
     $response->write(closePopupResponse($request));
 }
 function _applyAccessPolicy($object, $action)
 {
     $access_policy = new AccessPolicy();
     $access_policy->applyAccessTemplates($object, $action);
     if (catch_error('LimbException', $e)) {
     }
     MessageBox::writeNotice("Access template of " . get_class($object) . " for action '{$action}' not defined!!!");
 }
 public function __construct($type = "", $message = "", $sfUser = null)
 {
     $this->type = $type;
     $this->message = $message;
     if ($sfUser != null) {
         MessageBox::pushToSession($sfUser);
     }
 }
Esempio n. 13
0
 public function tabularasa_action($timestamp = null)
 {
     $institutes = MyRealmModel::getMyInstitutes();
     foreach ($institutes as $index => $institut) {
         MyRealmModel::setObjectVisits($institutes[$index], $institut['institut_id'], $GLOBALS['user']->id, $timestamp);
     }
     PageLayout::postMessage(MessageBox::success(_('Alles als gelesen markiert!')));
     $this->redirect('my_institutes/index');
 }
 protected function _applyAccessPolicy($object, $action)
 {
     try {
         $access_policy = new AccessPolicy();
         $access_policy->applyAccessTemplates($object, $action);
     } catch (LimbException $e) {
         MessageBox::writeNotice("Access template of " . get_class($object) . " for action '{$action}' not defined!!!");
     }
 }
 public function perform($request, $response)
 {
     $object = Limb::toolkit()->createSiteObject('UserObject');
     if (!$object->activatePassword()) {
         MessageBox::writeNotice('Password activation failed!');
         $request->setStatus(Request::STATUS_FAILED);
         $response->redirect('/');
     }
 }
Esempio n. 16
0
 /**
  * This method is called to remove an avatar for a course.
  *
  * @return void
  */
 function delete_action()
 {
     CourseAvatar::getAvatar($this->course_id)->reset();
     PageLayout::postMessage(MessageBox::success(_("Veranstaltungsbild gelöscht.")));
     if ($this->studygroup_mode) {
         $this->redirect(URLHelper::getUrl('dispatch.php/course/studygroup/edit/' . $this->course_id));
     } else {
         $this->redirect(URLHelper::getUrl('dispatch.php/course/avatar/update/' . $this->course_id));
     }
 }
Esempio n. 17
0
 public function ask_for_hosts_action($host_id)
 {
     $host = new LernmarktplatzHost($host_id);
     $added = $this->askForHosts($host);
     if ($added > 0) {
         PageLayout::postMessage(MessageBox::success(sprintf(_("%s neue Server hinzugefügt."), $added)));
     } else {
         PageLayout::postMessage(MessageBox::info(_("Keine neuen Server gefunden.")));
     }
     $this->redirect("admin/hosts");
 }
 protected function _updateObjectOperation()
 {
     $this->object->set('files_data', $_FILES[$this->name]);
     try {
         $this->object->updateVariations();
     } catch (SQLException $e) {
         throw $e;
     } catch (LimbException $e) {
         MessageBox::writeNotice('Some variations were not resized');
     }
 }
 function _updateObjectOperation()
 {
     $this->object->set('files_data', $_FILES[$this->name]);
     $this->object->updateVariations();
     if (catch_error('SQLException', $e)) {
         return throw_error($e);
     } elseif (catch_error('LimbException', $e)) {
         MessageBox::writeNotice('Some variations were not resized');
     } elseif (catch_error('LimbException', $e)) {
         return throw_error($e);
     }
 }
 protected function _validPerform($request, $response)
 {
     $object = Limb::toolkit()->createSiteObject('PollContainer');
     $data = $this->dataspace->export();
     $request->setStatus(Request::STATUS_FAILURE);
     if (!isset($data['answer'])) {
         MessageBox::writeNotice(Strings::get('no_answer', 'poll'));
         return;
     }
     $object->registerAnswer($data['answer']);
     $request->setStatus(Request::STATUS_FORM_SUBMITTED);
 }
Esempio n. 21
0
 public function edit_action($material_id = null)
 {
     $this->material = new LernmarktplatzMaterial($material_id);
     Pagelayout::setTitle($this->material->isNew() ? _("Neues Material hochladen") : _("Material bearbeiten"));
     if ($this->material['user_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) {
         throw new AccessDeniedException();
     }
     if (Request::submitted("delete") && Request::isPost()) {
         $this->material->pushDataToIndexServers("delete");
         $this->material->delete();
         PageLayout::postMessage(MessageBox::success(_("Ihr Material wurde gelöscht.")));
         $this->redirect("market/overview");
     } elseif (Request::isPost()) {
         $was_new = $this->material->setData(Request::getArray("data"));
         $this->material['user_id'] = $GLOBALS['user']->id;
         $this->material['host_id'] = null;
         $this->material['license'] = "CC BY 4.0";
         if ($_FILES['file']['tmp_name']) {
             $this->material['content_type'] = $_FILES['file']['type'];
             if (in_array($this->material['content_type'], array("application/x-zip-compressed", "application/zip", "application/x-zip"))) {
                 $tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_folder_" . md5(uniqid());
                 mkdir($tmp_folder);
                 unzip_file($_FILES['file']['tmp_name'], $tmp_folder);
                 $this->material['structure'] = $this->getFolderStructure($tmp_folder);
                 rmdirr($tmp_folder);
             } else {
                 $this->material['structure'] = null;
             }
             $this->material['filename'] = $_FILES['file']['name'];
             move_uploaded_file($_FILES['file']['tmp_name'], $this->material->getFilePath());
         }
         if ($_FILES['image']['tmp_name']) {
             $this->material['front_image_content_type'] = $_FILES['image']['type'];
             move_uploaded_file($_FILES['image']['tmp_name'], $this->material->getFrontImageFilePath());
         }
         if (Request::get("delete_front_image")) {
             $this->material['front_image_content_type'] = null;
         }
         $this->material->store();
         //Topics:
         $topics = Request::getArray("tags");
         foreach ($topics as $key => $topic) {
             if (!trim($topic)) {
                 unset($topics[$key]);
             }
         }
         $this->material->setTopics($topics);
         $this->material->pushDataToIndexServers();
         PageLayout::postMessage(MessageBox::success(_("Lernmaterial erfolgreich gespeichert.")));
         $this->redirect("market/details/" . $this->material->getId());
     }
 }
 protected function _createObjectOperation()
 {
     if (isset($_FILES[$this->name]['tmp_name']['file'])) {
         if ($_FILES[$this->name]['size']['file'] > ini_get('upload_max_filesize') * 1024 * 1024) {
             MessageBox::writeWarning('uploaded file size exceeds limit');
             return false;
         }
         $this->object->set('tmp_file_path', $_FILES[$this->name]['tmp_name']['file']);
         $this->object->set('file_name', $_FILES[$this->name]['name']['file']);
         $this->object->set('mime_type', $_FILES[$this->name]['type']['file']);
     }
     return parent::_createObjectOperation();
 }
 private function generateArticleHTML()
 {
     if ($this->articles == null) {
         return;
     }
     if (getStyle()->doArticleHTML()) {
         try {
             $this->articleHTML = getStyle()->getArticlesHTML($this->articles);
         } catch (Exception $e) {
             $msgbox = new MessageBox("The style didn't generate the HTML code for the articles, therefore the default generator was used. <br /><br />To hide this message open <br />" . $style->getStylePath() . "info.xml<br /> and set <strong>own_article_html</strong> to <strong>false</strong>.");
             $msgbox->bindException($e);
             getDisplay()->addObject($msgbox);
             foreach ($this->articles as $article) {
                 $this->articleHTML .= $article->toShortHTML();
             }
         }
     } else {
         foreach ($this->articles as $article) {
             $this->articleHTML .= $article->toShortHTML();
         }
     }
 }
 public function main($args)
 {
     getDisplay()->setTemplateDir(ROOT . "/orongo-admin/theme/");
     if (!isset($args['page_title'])) {
         $msgbox = new MessageBox("Can't render admin frontend: missing argument 'page_title'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     if (!isset($args['page_template'])) {
         $msgbox = new MessageBox("Can't render admin frontend: missing argument 'page_template!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     if (!is_string($args['page_template'])) {
         $msgbox = new MessageBox("Can't render admin frontend: wrong argument 'page_template'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     if (!is_string($args['page_title'])) {
         $msgbox = new MessageBox("Can't render admin frontend: wrong argument 'page_title'!");
         die($msgbox->getImports() . $msgbox->toHTML());
     }
     $this->pageTemplate = $args['page_template'];
     $this->objects = array();
     $this->pageTitle = l($args['page_title']);
 }
 private function generateArticlesHTML()
 {
     $articles = array();
     $q = "action=fetch&object=article&max=5&order=article.id,desc";
     try {
         $articles = orongo_query($q);
     } catch (Exception $e) {
         $msgbox = new MessageBox();
         $msgbox->bindException($e);
         getDisplay()->addObject($msgbox);
     }
     if (count($articles) < 1) {
         try {
             $article = Article::createArticle("Hello World!");
             $article->setContent("<p>Thank you for installing OrongoCMS!</p><p>To edit this simply delete it and create a new article or change this article.</p><br /><p>The OrongoCMS team</p>");
             $articles[0] = $article;
         } catch (Exception $e) {
         }
     }
     if (getStyle()->doArticleHTML()) {
         try {
             $this->articleHTML = getStyle()->getArticlesHTML($articles);
         } catch (Exception $e) {
             $msgbox = new MessageBox("The style didn't generate the HTML code for the articles, therefore the default generator was used. <br /><br />To hide this message open <br />" . $style->getStylePath() . "info.xml<br /> and set <strong>own_article_html</strong> to <strong>false</strong>.");
             $msgbox->bindException($e);
             getDisplay()->addObject($msgbox);
             foreach ($articles as $article) {
                 $this->articleHTML .= $article->toShortHTML();
             }
         }
     } else {
         foreach ($articles as $article) {
             $this->articleHTML .= $article->toShortHTML();
         }
     }
 }
 protected function _validPerform($request, $response)
 {
     $user_object = Limb::toolkit()->createSiteObject('UserObject');
     $data = $this->dataspace->export();
     try {
         $user_object->changeOwnPassword($data['password']);
     } catch (SQLException $e) {
         throw $e;
     } catch (LimbException $e) {
         $request->setStatus(Request::STATUS_FAILED);
     }
     $request->setStatus(Request::STATUS_FORM_SUBMITTED);
     Limb::toolkit()->getUser()->logout();
     MessageBox::writeWarning(Strings::get('need_relogin', 'user'));
 }
 function _validPerform(&$request, &$response)
 {
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['parent_path'] = $this->dataspace->get('parent_path');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $toolkit =& Limb::toolkit();
     $object =& $toolkit->createSiteObject($params['Class']);
     $datasource =& $toolkit->getDatasource('SingleObjectDatasource');
     $datasource->setPath($params['parent_path']);
     $is_root = false;
     if (!($parent_data = $datasource->fetch())) {
         if ($params['parent_path'] == '/') {
             $is_root = true;
         } else {
             MessageBox::writeNotice('parent wasn\'t retrieved by path ' . $params['parent_path']);
             $request->setStatus(Request::STATUS_FAILURE);
             return;
         }
     }
     if (!$is_root) {
         $params['parent_node_id'] = $parent_data['node_id'];
     } else {
         $params['parent_node_id'] = 0;
     }
     $object->merge($params);
     $object->create($is_root);
     if (catch_error($e, 'LimbException')) {
         MessageBox::writeNotice('object wasn\'t registered!');
         $request->setStatus(Request::STATUS_FAILURE);
         return;
     } elseif (catch_error($e, 'LimbException')) {
         return throw_error($e);
     }
     if (!$is_root) {
         $parent_object =& $toolkit->createSiteObject($parent_data['ClassName']);
         $parent_object->merge($parent_data);
         $controller =& $parent_object->getController();
         $action = $controller->determineAction();
         $access_policy = new AccessPolicy();
         $access_policy->saveNewObjectAccess($object, $parent_object, $action);
     }
     $request->setStatus(Request::STATUS_FORM_SUBMITTED);
     if ($request->hasAttribute('popup')) {
         $response->write(closePopupResponse($request));
     }
 }
 public function _validPerform($request, $response)
 {
     parent::_validPerform($request, $response);
     if ($this->_changingOwnPassword()) {
         Limb::toolkit()->getUser()->logout();
         MessageBox::writeWarning(Strings::get('need_relogin', 'user'));
     } else {
         $object_data = $this->_loadObjectData();
         Limb::toolkit()->getSession()->storageDestroyUser($object_data['id']);
     }
     if ($request->getStatus() == Request::STATUS_SUCCESS) {
         if ($request->hasAttribute('popup')) {
             $response->write(closePopupResponse($request, '/'));
         }
     }
 }
 public function executeIndex(HTTPRequest $request)
 {
     $this->init();
     if ($request->postExists('connect')) {
         $login = htmlspecialchars($request->postData('login'));
         $password = htmlspecialchars($request->postData('password'));
         $this->_user = $this->_userManager->authenticate($login, $password);
         if (!is_null($this->_user) && $this->_user->getRoleId() >= Role::ROLE_ADMINISTRATEUR && $this->_user->getIsActive()) {
             $this->app->user()->setAdminAuthenticated(true);
             $this->app->user()->setAttribute('admin-id', $this->_user->id());
             $this->authenticationRedirection();
         } else {
             $message = MessageBox::Error('L\'authentification a échoué !');
             $this->page->smarty()->assign('connexionMessage', $message);
         }
     }
 }
 private function displayInfoMessage()
 {
     $message = '';
     if ($this->app->user()->hasFlash()) {
         switch ($this->app->user()->getFlash()) {
             case 'opinion-deleted':
                 $message = 'Témoignage supprimé !';
                 $message = MessageBox::Success($message);
                 break;
             case 'opinion-published':
                 $message = 'Témoignage publié !';
                 $message = MessageBox::Success($message);
                 break;
         }
     }
     $this->page->smarty()->assign('message', $message);
 }