-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathListOfAttendeesPlugin.inc.php
140 lines (123 loc) · 3.37 KB
/
ListOfAttendeesPlugin.inc.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* @file ListOfAttendeesPlugin.inc.php
*
* Copyright (c) 2013 Péter Fankhauser
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @package plugins.generic.listOfAttendees
* @class ListOfAttendeesPlugin
*
* ListOfAttendeesPlugin class
*
*/
import('classes.plugins.GenericPlugin');
class ListOfAttendeesPlugin extends GenericPlugin {
function getName() {
return 'ListOfAttendeesPlugin';
}
function getDisplayName() {
return __('plugins.generic.listOfAttendees.displayName');
}
function getDescription() {
return __('plugins.generic.listOfAttendees.description');
}
/**
* Register the plugin, attaching to hooks as necessary.
* @param $category string
* @param $path string
* @return boolean
*/
function register($category, $path) {
if (parent::register($category, $path)) {
$this->addLocaleData();
if ($this->getEnabled()) {
$this->import('ListOfAttendeesDAO');
if (checkPhpVersion('5.0.0')) { // WARNING: see http://pkp.sfu.ca/wiki/index.php/Information_for_Developers#Use_of_.24this_in_the_constructur
$listOfAttendeesDAO = new ListOfAttendeesDAO();
} else {
$listOfAttendeesDAO =& new ListOfAttendeesDAO();
}
$returner =& DAORegistry::registerDAO('ListOfAttendeesDAO', $listOfAttendeesDAO);
HookRegistry::register('LoadHandler', array(&$this, 'callbackHandleContent'));
}
return true;
}
return false;
}
/**
* Determine whether or not this plugin is enabled.
*/
function getEnabled() {
$conference =& Request::getConference();
$conferenceId = $conference?$conference->getId():0;
return $this->getSetting($conferenceId, 0, 'enabled');
}
/**
* Set the enabled/disabled state of this plugin
*/
function setEnabled($enabled) {
$conference =& Request::getConference();
$conferenceId = $conference?$conference->getId():0;
$this->updateSetting($conferenceId, 0, 'enabled', $enabled);
return true;
}
/**
* Display verbs for the management interface.
*/
function getManagementVerbs() {
$verbs = array();
if ($this->getEnabled()) {
$verbs[] = array(
'disable',
__('manager.plugins.disable')
);
} else {
$verbs[] = array(
'enable',
__('manager.plugins.enable')
);
}
return $verbs;
}
/**
* Declare the handler function to process the actual page PATH
*/
function callbackHandleContent($hookName, $args) {
$page =& $args[0];
if ( $page == 'attendees' ) {
define('HANDLER_CLASS', 'ListOfAttendeesHandler');
$this->import('ListOfAttendeesHandler');
return true;
}
return false;
}
/*
* Execute a management verb on this plugin
* @param $verb string
* @param $args array
* @param $message string Location for the plugin to put a result msg
* @return boolean
*/
function manage($verb, $args, &$message) {
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$conference =& Request::getConference();
$returner = true;
switch ($verb) {
case 'enable':
$this->setEnabled(true);
$returner = false;
$message = __('plugins.generic.listOfAttendees.enabled');
break;
case 'disable':
$this->setEnabled(false);
$returner = false;
$message = __('plugins.generic.listOfAttendees.disabled'); break;
default:
Request::redirect(null, null, 'manager');
}
return $returner;
}
}
?>