KTUserAssistancePlugin.php
3.96 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
require_once(KT_LIB_DIR . '/dispatcher.inc.php');
require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
require_once(KT_LIB_DIR . '/dashboard/dashlet.inc.php');
require_once(KT_LIB_DIR . '/dashboard/DashletDisables.inc.php');
require_once(KT_LIB_DIR . "/templating/templating.inc.php");
require_once(KT_LIB_DIR . "/dashboard/Notification.inc.php");
require_once(KT_LIB_DIR . "/security/Permission.inc");
class KTUserAssistance extends KTPlugin {
var $sNamespace = 'ktcore.userassistance';
function setup() {
//$this->registerDashlet('KTUserTutorialDashlet', 'ktcore.dashlet.usertutorial', __FILE__);
//$this->registerDashlet('KTAdminTutorialDashlet', 'ktcore.dashlet.admintutorial', __FILE__);
$this->registerPage('kt3b1-what-is-a-beta', 'KTUserAssistB1WhatIs', __FILE__);
$this->registerPage('kt-bug-reporting-guide', 'KTUserAssistBugReportingGUide', __FILE__);
$this->registerPage('admin-quickguide', 'KTUserAssistAdminQuickguide', __FILE__);
$this->registerPage('admin-guide-whats-new-in-kt3', 'KTUserAssistAdminGuideWhatsNew', __FILE__);
}
}
$oRegistry =& KTPluginRegistry::getSingleton();
$oRegistry->registerPlugin('KTUserAssistance', 'ktcore.userassistance', __FILE__);
// ultra simple skeleton for the user tutorial
// FIXME do we want to store the namespace inside the dashlet?
class KTUserTutorialDashlet extends KTBaseDashlet {
function is_active($oUser) {
$namespace = 'ktcore.dashlet.usertutorial';
$disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace);
if (!empty($disables)) {
return false;
} else {
return true;
}
}
function render() {
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/usertutorial");
$aTemplateData = array(
);
return $oTemplate->render($aTemplateData);
}
}
// ultra simple skeleton for the admin tutorial
class KTAdminTutorialDashlet extends KTBaseDashlet {
function is_active($oUser) {
$namespace = 'ktcore.dashlet.admintutorial';
if (!Permission::userIsSystemAdministrator($oUser->getId())) {
return false; // quickest disable.
}
$disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace);
if (!empty($disables)) {
return false;
} else {
return true;
}
}
function render() {
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/admintutorial");
$aTemplateData = array(
);
return $oTemplate->render($aTemplateData);
}
}
class KTUserAssistBasePage extends KTStandardDispatcher {
var $sSection = 'help';
var $aBreadcrumbs = array(
array('action' => 'dashboard', 'name' => 'Dashboard'),
array('name' => 'User Assistance')
);
var $pagefile = 'base';
var $title = 'User Assistance';
function do_main() {
$this->oPage->setBreadcrumbDetails($this->title);
$contents = @file_get_contents(dirname(__FILE__) . '/docs/' . $this->pagefile);
if ($contents === false) {
$contents = '<div class="ktError"><p>Unable to find requested documentation.</p></div>';
}
$this->oPage->setTitle($this->title);
$this->oPage->setShowPortlets(false);
return $contents;
}
// hide the dashlet from the user (e.g. don't show it again) and redirect back to the dashboard.
}
class KTUserAssistB1WhatIs extends KTUserAssistBasePage { var $pagefile = 'kt3b1-what-is-a-beta'; var $title = 'What is a Beta?'; }
class KTUserAssistBugReportingGUide extends KTUserAssistBasePage { var $pagefile = 'kt-bug-reporting-guide'; var $title = 'Help! Something went wrong'; }
class KTUserAssistAdminQuickguide extends KTUserAssistBasePage { var $pagefile = 'admin-quickguide'; var $title = 'Quickstart Guide for Administrators'; }
class KTUserAssistAdminGuideWhatsNew extends KTUserAssistBasePage { var $pagefile = 'admin-guide-whats-new-in-kt3'; var $title = 'What\'s new in KT3 for Administrators'; }
?>