/** * Fetches all new postings (threads and comments) that appear in the stream * and are newer than $since (as a unix timestamp). * @param integer $since : unix-timestamp * @return array of \BlubberPosting */ public function fetchNewPostings($since) { list($sql, $parameters) = $this->getNewPostingsSql($since); $statement = DBManager::get()->prepare($sql); $statement->execute($parameters); $posting_data = $statement->fetchAll(PDO::FETCH_ASSOC); $postings = array(); foreach ($posting_data as $data) { $posting = new BlubberPosting(); $posting->setData($data); $posting->setNew(false); $postings[] = $posting; } return $postings; }
<? $last_visit = object_get_visit($_SESSION['SessionSeminar'], "forum"); BlubberPosting::$course_hashes = ($thread['context_type'] === "course" ? $thread['Seminar_id'] : false); $related_users = $thread['context_type'] === "private" ? $thread->getRelatedUsers() : array(); $author = $thread->getUser(); $author_name = $author->getName(); $author_url = $author->getURL(); $commentable = $GLOBALS['perm']->have_perm("autor") ? true : (bool) $commentable; ?> <li id="posting_<?php echo htmlReady($thread->getId()); ?> " data-mkdate="<?php echo htmlReady($thread['discussion_time']); ?> " data-discussion_time="<?php echo htmlReady($thread['discussion_time']); ?> " class="thread posting<?php echo $last_visit < $thread['mkdate'] ? " new" : ""; ?> <?php echo $thread['context_type']; ?> " data-autor="<?php echo htmlReady($thread['user_id']); ?> "> <? $thread['discussion_time'] ?> <div class="hiddeninfo"> <input type="hidden" name="context" value="<?php
/** * Edits the content of a blubber. Sends a message of the change to the author, if the editing user is not * the author of the blubber, to inform him/her about the change. * If the content is empty the blubber is going to be deleted, because we don't want empty * blubber in the system. * * @put /blubber/posting/:blubber_id * @put /blubber/comment/:blubber_id * * @param string $blubber_id * * @param string content new content for the blubber */ public function editBlubberPosting($blubber_id) { if (!strlen(trim($this->data['content']))) { $this->error(400, 'No content provided'); } $blubber = new \BlubberPosting($blubber_id); $this->requireWriteAccessTo($blubber); if ($this->requestedRouteMatches('/posting/') xor $blubber->isThread()) { $this->notFound(); } $old_content = $blubber['description']; \BlubberPosting::$mention_posting_id = $blubber->getId(); \StudipTransformFormat::addStudipMarkup("mention1", '@\\"[^\\n\\"]*\\"', "", "\\BlubberPosting::mention"); \StudipTransformFormat::addStudipMarkup("mention2", '@[^\\s]*[\\d\\w_]+', "", "\\BlubberPosting::mention"); $content = \transformBeforeSave($this->data['content']); $blubber['name'] = $blubber['description'] = $content; $blubber->store(); if ($blubber['user_id'] !== $GLOBALS['user']->id) { $this->sendEditMail($blubber, sprintf(_("%s hat als Moderator gerade Ihren Beitrag im Blubberforum editiert.\n\nDie alte Version des Beitrags lautete:\n\n%s\n\nDie neue lautet:\n\n%s\n"), get_fullname(), $old_content, $blubber['description']), _("Änderungen an Ihrem Posting.")); } $this->status(204); }
/** * Displays a single thread. * @param string $thread_id */ public function thread_action($thread_id) { $this->thread = new BlubberPosting($thread_id); if ($this->thread['context_type'] === "private") { if (!in_array($GLOBALS['user']->id, $this->thread->getRelatedUsers())) { throw new AccessDeniedException("Kein Zugriff auf diesen Blubb."); } } elseif ($this->thread['context_type'] === "course") { if (!$GLOBALS['perm']->have_studip_perm("user", $this->thread['Seminar_id'])) { throw new AccessDeniedException("Kein Zugriff auf diesen Blubb."); } } if ($this->thread['context_type'] === "course") { PageLayout::setTitle($GLOBALS['SessSemName']["header_line"] . " - " . $this->plugin->getDisplayTitle()); } elseif ($this->thread['context_type'] === "public") { PageLayout::setTitle(get_fullname($this->thread['user_id']) . " - Blubber"); } elseif ($this->thread['context_type'] === "private") { PageLayout::setTitle(_("Privater Blubber")); } if ($this->thread['context_type'] === "course") { Navigation::getItem("/course/blubberforum")->setImage(Icon::create('blubber', 'info')); Navigation::activateItem('/course/blubberforum'); } elseif ($this->thread['context_type'] === "public") { if (Navigation::hasItem('/profile')) { Navigation::activateItem('/profile/blubber'); } } else { if (Navigation::hasItem('/community/blubber')) { Navigation::activateItem('/community/blubber'); } } $this->course_id = $_SESSION['SessionSeminar']; $this->single_thread = true; BlubberPosting::$course_hashes = $this->thread['user_id'] !== $this->thread['Seminar_id'] ? $this->thread['Seminar_id'] : false; }
<?php echo Icon::create('seminar', 'info')->asImg(32, ['class' => "text-bottom"]); ?> <br> <?php echo _("Veranstaltung"); ?> </label> </td> <td> <label> <?php echo _("In Veranstaltung"); ?> <select name="context"> <? foreach (BlubberPosting::getMyBlubberCourses() as $course_id) : ?> <? $seminar = new Seminar($course_id) ?> <option value="<?php echo htmlReady($course_id); ?> "><?php echo htmlReady($seminar->getName()); ?> </option> <? endforeach ?> </select> </label> </td> <td style="width: 15%"> <?php echo Icon::create('checkbox-checked', 'info')->asImg(['class' => "text-bottom check"]);
/** * Undo a reshare of a user. Do nothing if there was no reshare. * @param string|null $user_id : md5 user_id of the not anymore resharing user. * @param int $external_user : is the user an external user? * @return boolean : true if successfully deleted, false if nothing to do. */ public function unreshare($user_id = null, $external_user = 0) { $user_id or $user_id = $GLOBALS['user']->id; $unshare = DBManager::get()->prepare("DELETE FROM blubber_reshares " . "WHERE topic_id = :topic_id " . "AND user_id = :user_id ", "AND external_contact = :external_contact " . ""); $success = $unshare->execute(array('topic_id' => $this['root_id'], 'user_id' => $user_id, 'external_contact' => $external_user)); if ($success) { $thread = $this->isThread() ? $this : BlubberPosting::find($this['root_id']); $thread['chdate'] = time(); $thread->store(); } return $success; }
/** * Constructor of Plugin : adds Navigation and collects information for javascript-update. */ public function __construct() { parent::__construct(); if (UpdateInformation::isCollecting()) { $data = Request::getArray("page_info"); if (stripos(Request::get("page"), "plugins.php/blubber") !== false && isset($data['Blubber'])) { $output = array(); switch ($data['Blubber']['stream']) { case "global": $stream = BlubberStream::getGlobalStream(); break; case "course": $stream = BlubberStream::getCourseStream($data['Blubber']['context_id']); break; case "profile": $stream = BlubberStream::getProfileStream($data['Blubber']['context_id']); break; case "thread": $stream = BlubberStream::getThreadStream($data['Blubber']['context_id']); break; case "custom": $stream = new BlubberStream($data['Blubber']['context_id']); break; } $last_check = $data['Blubber']['last_check'] ? $data['Blubber']['last_check'] : time() - 5 * 60; $new_postings = $stream->fetchNewPostings($last_check); $factory = new Flexi_TemplateFactory($this->getPluginPath() . "/views"); foreach ($new_postings as $new_posting) { if ($new_posting['root_id'] === $new_posting['topic_id']) { $thread = $new_posting; $template = $factory->open("streams/thread.php"); $template->set_attribute('thread', $new_posting); } else { $thread = new BlubberPosting($new_posting['root_id']); $template = $factory->open("streams/comment.php"); $template->set_attribute('posting', $new_posting); } BlubberPosting::$course_hashes = $thread['user_id'] !== $thread['Seminar_id'] ? $thread['Seminar_id'] : false; $template->set_attribute("course_id", $data['Blubber']['seminar_id']); $output['postings'][] = array('posting_id' => $new_posting['topic_id'], 'discussion_time' => $new_posting['discussion_time'], 'mkdate' => $new_posting['mkdate'], 'root_id' => $new_posting['root_id'], 'content' => $template->render()); } UpdateInformation::setInformation("Blubber.getNewPosts", $output); //Events-Queue: $db = DBManager::get(); $events = $db->query("SELECT event_type, item_id " . "FROM blubber_events_queue " . "WHERE mkdate >= " . $db->quote($last_check) . " " . "ORDER BY mkdate ASC " . "")->fetchAll(PDO::FETCH_ASSOC); UpdateInformation::setInformation("Blubber.blubberEvents", $events); $db->exec("DELETE FROM blubber_events_queue " . "WHERE mkdate < UNIX_TIMESTAMP() - 60 * 60 * 6 " . ""); } } if (Navigation::hasItem("/community")) { $nav = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "streams/global")); $nav->addSubNavigation("global", new AutoNavigation(_("Globaler Stream"), PluginEngine::getURL($this, array(), "streams/global"))); foreach (BlubberStream::findMine() as $stream) { $url = PluginEngine::getURL($this, array(), "streams/custom/" . $stream->getId()); $nav->addSubNavigation($stream->getId(), new AutoNavigation($stream['name'], $url)); if ($stream['defaultstream']) { $nav->setURL($url); } } $nav->addSubNavigation("add", new AutoNavigation(_("Neuen Stream erstellen"), PluginEngine::getURL($this, array(), "streams/edit"))); Navigation::insertItem("/community/blubber", $nav, "online"); Navigation::getItem("/community")->setURL($nav->getURL()); } if (Navigation::hasItem("/profile") && $this->isActivated(get_userid(Request::username('username', $GLOBALS['auth']->auth['uname'])), 'user')) { $nav = new AutoNavigation(_("Blubber"), PluginEngine::getURL($this, array('user_id' => get_userid(Request::get("username"))), "streams/profile")); Navigation::addItem("/profile/blubber", $nav); } }