function __construct()
 {
     parent::__construct();
     if (is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm('admin')) {
         $navigation = new Navigation(_("Veranstaltungs-Vervielfältiger"), PluginEngine::getUrl($this, array(), 'index'));
         Navigation::insertItem('/start/replicator', $navigation, 'search');
     }
 }
 /**
  * Setzt das Hauptmenü des Plugins
  *
  * @deprecated
  */
 function setTopnavigation(StudipPluginNavigation $navigation)
 {
     $this->topnavigation = $navigation;
     if ($navigation instanceof PluginNavigation) {
         $this->topnavigation->setPlugin($this);
     }
     Navigation::insertItem('/start/' . $this->getPluginclassname(), $navigation, 'search');
 }
 /**
  * define where the plugin will be visible (toolbar and/or start page)
  *
  * @deprecated
  */
 function setDisplayType($display_type)
 {
     $changes = $this->display_type ^ $display_type;
     $this->display_type = $display_type;
     if ($this->hasNavigation()) {
         if ($changes & SYSTEM_PLUGIN_TOOLBAR) {
             if ($this->getDisplayType(SYSTEM_PLUGIN_TOOLBAR)) {
                 Navigation::addItem('/' . $this->getPluginclassname(), $this->getNavigation());
             } else {
                 Navigation::removeItem('/' . $this->getPluginclassname());
             }
         }
         if ($changes & SYSTEM_PLUGIN_STARTPAGE) {
             if ($this->getDisplayType(SYSTEM_PLUGIN_STARTPAGE)) {
                 Navigation::insertItem('/start/' . $this->getPluginclassname(), $this->getNavigation(), 'search');
             } else {
                 Navigation::removeItem('/start/' . $this->getPluginclassname());
             }
         }
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     global $perm;
     parent::__construct();
     if (UpdateInformation::isCollecting()) {
         $data = Request::getArray("page_info");
         if (stripos(Request::get("page"), "plugins.php/blubber") !== false) {
             $output = array();
             $context_id = $data['Blubber']['context_id'];
             $stream = $data['Blubber']['stream'];
             $last_check = $data['Blubber']['last_check'] ? $data['Blubber']['last_check'] : time() - 5 * 60;
             $parameter = array('since' => $last_check);
             if ($stream === "thread") {
                 $parameter['thread'] = $context_id;
             }
             if ($stream === "course") {
                 $parameter['seminar_id'] = $context_id;
             }
             if ($stream === "profile") {
                 $parameter['user_id'] = $context_id;
             }
             if ($data['Blubber']['search']) {
                 $parameter['search'] = $data['Blubber']['search'];
             }
             $new_postings = ForumPosting::getPostings($parameter);
             $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("forum/thread.php");
                     $template->set_attribute('thread', $new_posting);
                 } else {
                     $thread = new ForumPosting($new_posting['root_id']);
                     $template = $factory->open("forum/comment.php");
                     $template->set_attribute('posting', $new_posting);
                 }
                 ForumPosting::$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'], '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("/course") && $this->isActivated() && version_compare($GLOBALS['SOFTWARE_VERSION'], "2.4") <= 0) {
         $tab = new AutoNavigation($this->getDisplayTitle(), PluginEngine::getLink($this, array(), "forum/forum"));
         $tab->setImage($this->getPluginURL() . "/assets/images/blubber_white.png");
         Navigation::addItem("/course/blubberforum", $tab);
     }
     if (Navigation::hasItem("/community")) {
         $nav = new AutoNavigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "forum/globalstream"));
         Navigation::insertItem("/community/blubber", $nav, "online");
         Navigation::getItem("/community")->setURL(PluginEngine::getURL($this, array(), "forum/globalstream"));
     }
     if (Navigation::hasItem("/profile")) {
         $nav = new AutoNavigation(_("Blubber"), PluginEngine::getURL($this, array('user_id' => get_userid(Request::get("username"))), "forum/profile"));
         Navigation::addItem("/profile/blubber", $nav);
     }
 }
Exemplo n.º 5
0
 public function testNavigationTree()
 {
     $navigation = new Navigation('test');
     $nav1 = new Navigation('foo', NULL);
     $nav2 = new Navigation('bar', 'bar.php');
     $nav3 = new Navigation('baz', 'baz.php');
     $nav4 = new Navigation('egg', 'egg.php');
     $this->assertFalse(Navigation::hasItem('/test/a2'));
     Navigation::addItem('/test', $navigation);
     Navigation::addItem('/test/a1', $nav1);
     Navigation::addItem('/test/a2', $nav2);
     Navigation::addItem('/test/a3', $nav3);
     Navigation::addItem('/test/a2/b1', $nav4);
     $this->assertTrue(Navigation::hasItem('/test/a2'));
     $this->assertFalse(Navigation::getItem('/test')->isActive());
     $this->assertEquals('bar.php', Navigation::getItem('/test')->getURL());
     $this->assertEquals(array('a1' => $nav1, 'a2' => $nav2, 'a3' => $nav3), Navigation::getItem('/test')->getSubNavigation());
     Navigation::activateItem('/test/a2/b1');
     $this->assertTrue(Navigation::getItem('/test')->isActive());
     $this->assertTrue(Navigation::getItem('/test/a2')->isActive());
     $this->assertTrue(Navigation::getItem('/test/a2/b1')->isActive());
     Navigation::removeItem('/test/a3');
     Navigation::insertItem('/test/a3', $nav3, 'a2');
     Navigation::removeItem('/test/a1');
     Navigation::insertItem('/test/a2/a1', $nav1, '');
     $this->assertEquals('baz.php', Navigation::getItem('/test')->getURL());
     $this->assertEquals(array('a3' => $nav3, 'a2' => $nav2), Navigation::getItem('/test')->getSubNavigation());
     $this->assertEquals(array('b1' => $nav4, 'a1' => $nav1), Navigation::getItem('/test/a2')->getSubNavigation());
 }
Exemplo n.º 6
0
 /**
  * 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);
     }
 }