-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFavoritecourcesPlugin.class.php
58 lines (50 loc) · 1.91 KB
/
FavoritecourcesPlugin.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require 'bootstrap.php';
/**
* FavoritecourcesPlugin.class.php
*
* ...
*
* @author David Siegfried <[email protected]>
* @version 0.1a
*/
class FavoritecourcesPlugin extends StudIPPlugin implements SystemPlugin
{
public function __construct()
{
parent::__construct();
if ($GLOBALS['perm']->have_perm('admin')) {
return;
}
$this->start_page = UserConfig::get($GLOBALS['user']->id)->FAVORITE_COURSES_START_PAGE;
if ($this->start_page == '' && match_route('dispatch.php/my_courses')) {
$msg = array(sprintf('<a href="%s">%s</a>', PluginEngine::getLink($this, array('really' => true), 'show/set_startpage'), _('Ja')));
$msg[] = sprintf('<a href="%s">%s</a>', PluginEngine::getLink($this, array('cancel' => true), 'show/set_startpage'), _('Nein'));
PageLayout::postMessage(MessageBox::info(_('Wollen Sie die Favoritenliste (Reiter "Meiner Favoriten") als Startseite einstellen?'), $msg));
}
if (Navigation::hasItem('/browse')) {
$navigation = new Navigation($this->getName());
$navigation->setURL(PluginEngine::GetURL($this, array(), 'show/index'));
if ($this->start_page == 'yes') {
Navigation::insertItem('/browse/fav_courses', $navigation, 'my_courses');
Navigation::getItem('/browse')->setURL($navigation->getURL());
} else {
Navigation::addItem('/browse/fav_courses', $navigation);
}
}
}
public function getName()
{
return _('Meine Favoriten');
}
public function perform($unconsumed_path)
{
$dispatcher = new Trails_Dispatcher(
$this->getPluginPath(),
rtrim(PluginEngine::getLink($this, array(), null), '/'),
'show'
);
$dispatcher->plugin = $this;
$dispatcher->dispatch($unconsumed_path);
}
}