/** * Displays more postings in the same stream (global, forum oder profile-stream). * This action is used by infinity-scroll and displays a maximum of * $this->max_threads threads. * @throws AccessDeniedException */ public function more_postings_action() { $context_id = Request::option("context_id"); switch (Request::get("stream")) { case "global": $stream = BlubberStream::getGlobalStream(); break; case "course": $stream = BlubberStream::getCourseStream($context_id); break; case "profile": $stream = BlubberStream::getProfileStream($context_id); break; case "custom": $stream = new BlubberStream($context_id); break; } $output = array(); $offset = $this->max_threads * Request::int("offset"); $limit = $this->max_threads + 1; $stream_time = Request::int("stream_time"); $threads = $stream->fetchThreads($offset, $limit, $stream_time); $output['more'] = count($threads) > $this->max_threads; if ($output['more']) { $threads = array_slice($threads, 0, $this->max_threads); } $output['threads'] = array(); $factory = new Flexi_TemplateFactory($this->plugin->getPluginPath() . "/views"); foreach ($threads as $posting) { $template = $factory->open("streams/_blubber.php"); $template->set_attribute('thread', $posting); $template->set_attribute('course_id', $_SESSION['SessionSeminar']); $template->set_attribute('controller', $this); $output['threads'][] = array('content' => $template->render(), 'discussion_time' => $posting['discussion_time'], 'mkdate' => $posting['mkdate'], 'posting_id' => $posting->getId()); } $this->render_json($output); }
/** * List blubber in a custom stream * * @get /blubber/stream/:stream_id * * @param string $stream_id id of the stream or "global" if you want to access the global stream. * * @return array the collection as array('collection' => array(...), 'pagination' => array()) */ public function getCustomStreamBlubber($stream_id) { if ($stream_id === "global") { $stream = \BlubberStream::getGlobalStream(); } else { $stream = new \BlubberStream($stream_id); if ($stream['user_id'] !== $GLOBALS['user']->id) { $this->error(401); } } return $this->getStreamBlubberRestResource($stream, array('user_id' => $stream['user_id'], 'stream_id' => $stream_id)); }
/** * 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); } }