-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.php
72 lines (65 loc) · 2.16 KB
/
config.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
<?php
/**
* Description of plugin
* @author Alexey Berezuev <[email protected]>
* @license http://opensource.org/licenses/MIT
* @version 0.1
*/
require_once(INCLUDE_DIR.'/class.plugin.php');
require_once(INCLUDE_DIR.'/class.forms.php');
class SpreaderConfig extends PluginConfig{
function getStaffList() {
$staff = array();
$sql = "SELECT `staff_id` AS `id`, CONCAT_WS(' ', `firstname`, `lastname`) AS `fullname` FROM ".TABLE_PREFIX."staff";
$result = db_query($sql);
while($row = db_fetch_array($result)) {
$staff[$row['id']] = $row['fullname'];
}
return $staff;
}
function getCategoriesList() {
$category = array();
$sql = "SELECT `topic_id` AS `id`, `topic` FROM ".TABLE_PREFIX."help_topic";
$result = db_query($sql);
while($row = db_fetch_array($result)) {
$category[$row['id']] = $row['topic'];
}
return $category;
}
function getOptions() {
$options = array();
$options['staff_title'] = new SectionBreakField(
array(
'label' => 'Staff',
)
);
foreach ($this->getStaffList() as $id => $staff) {
$options['spreader_staff_id_'.$id] = new BooleanField(
array(
'id' => "spreader_staff_id_".$id,
'label' => $staff,
)
);
}
$options['category_title'] = new SectionBreakField(
array(
'label' => 'Categories',
)
);
foreach ($this->getCategoriesList() as $id => $category) {
$options['spreader_category_id_'.$id] = new BooleanField(
array(
'id' => "spreader_category_id_".$id,
'label' => $category,
)
);
}
return $options;
}
function pre_save(&$config, &$errors) {
global $msg;
if (!$errors)
$msg = 'Configuration updated successfully';
return true;
}
}