Esempio n. 1
0
 /**
  * List blubber in a course
  *
  * @get /course/:course_id/blubber
  *
  * @param string $course_id   id of the course
  *
  * @return Array   the blubber as array('collection' => array(...), 'pagination' => array())
  */
 public function getCourseBlubber($course_id)
 {
     if (!$GLOBALS['perm']->have_studip_perm("autor", $course_id)) {
         $this->error(401);
     }
     $stream = \BlubberStream::getCourseStream($course_id);
     return $this->getStreamBlubberRestResource($stream, compact("course_id"));
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * Needed function to return notification-objects.
  * @param string $course_id
  * @param int $since
  * @param string $user_id
  * @return array of type ContentElement
  */
 public function getNotificationObjects($course_id, $since, $user_id)
 {
     $blubber = BlubberStream::getCourseStream($course_id)->fetchNewPostings($since);
     $contents = array();
     foreach ($blubber as $blubb) {
         $contents[] = new ContentElement($blubb['name'], $blubb['name'], $blubb['description'], $blubb['user_id'], get_fullname($blubb['user_id']), PluginEngine::getURL($this, array(), 'streams/thread/' . $blubb['root_id']), $blubb['mkdate']);
     }
     return $contents;
 }