forked from osTicket/osTicket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helptopics.php
163 lines (151 loc) · 7 KB
/
helptopics.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
/*********************************************************************
helptopics.php
Help Topics.
Peter Rotich <[email protected]>
Copyright (c) 2006-2013 osTicket
https://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require('admin.inc.php');
include_once(INCLUDE_DIR.'class.topic.php');
include_once(INCLUDE_DIR.'class.faq.php');
require_once(INCLUDE_DIR.'class.dynamic_forms.php');
$topic=null;
if($_REQUEST['id'] && !($topic=Topic::lookup($_REQUEST['id'])))
$errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('help topic'));
if($_POST){
switch(strtolower($_POST['do'])){
case 'update':
if(!$topic){
$errors['err']=sprintf(__('%s: Unknown or invalid'), __('help topic'));
}elseif($topic->update($_POST,$errors)){
$msg=sprintf(__('Successfully updated %s.'),
__('this help topic'));
}elseif(!$errors['err']){
$errors['err'] = sprintf('%s %s',
sprintf(__('Unable to update %s.'), __('this help topic')),
__('Correct any errors below and try again.'));
}
break;
case 'create':
$_topic = Topic::create();
if ($_topic->update($_POST, $errors)) {
$topic = $_topic;
$msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['topic']));
$_REQUEST['a']=null;
}elseif(!$errors['err']){
$errors['err']=sprintf('%s %s',
sprintf(__('Unable to add %s.'), __('this help topic')),
__('Correct any errors below and try again.'));
}
break;
case 'mass_process':
switch(strtolower($_POST['a'])) {
case 'sort':
// Pass
break;
default:
if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids']))
$errors['err'] = sprintf(__('You must select at least %s.'),
__('one help topic'));
}
if (!$errors) {
$count=count($_POST['ids']);
switch(strtolower($_POST['a'])) {
case 'enable':
$num = Topic::objects()->filter(array(
'topic_id__in' => $_POST['ids'],
))->update(array(
'isactive' => true,
));
if ($num > 0) {
if($num==$count)
$msg = sprintf(__('Successfully enabled %s'),
_N('selected help topic', 'selected help topics', $count));
else
$warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count,
_N('selected help topic', 'selected help topics', $count));
} else {
$errors['err'] = sprintf(__('Unable to enable %s'),
_N('selected help topic', 'selected help topics', $count));
}
break;
case 'disable':
$num = Topic::objects()->filter(array(
'topic_id__in'=>$_POST['ids'],
))->exclude(array(
'topic_id'=>$cfg->getDefaultTopicId(),
))->update(array(
'isactive' => false,
));
if ($num > 0) {
if($num==$count)
$msg = sprintf(__('Successfully disabled %s'),
_N('selected help topic', 'selected help topics', $count));
else
$warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count,
_N('selected help topic', 'selected help topics', $count));
} else {
$errors['err'] = sprintf(__('Unable to disable %s'),
_N('selected help topic', 'selected help topics', $count));
}
break;
case 'delete':
$i = Topic::objects()->filter(array(
'topic_id__in'=>$_POST['ids']
))->delete();
if($i && $i==$count)
$msg = sprintf(__('Successfully deleted %s.'),
_N('selected help topic', 'selected help topics', $count));
elseif($i>0)
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count,
_N('selected help topic', 'selected help topics', $count));
elseif(!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s.'),
_N('selected help topic', 'selected help topics', $count));
break;
case 'sort':
try {
$cfg->setTopicSortMode($_POST['help_topic_sort_mode']);
if ($cfg->getTopicSortMode() == 'm') {
foreach ($_POST as $k=>$v) {
if (strpos($k, 'sort-') === 0
&& is_numeric($v)
&& ($t = Topic::lookup(substr($k, 5))))
$t->setSortOrder($v);
}
}
$msg = __('Successfully set sorting configuration');
}
catch (Exception $ex) {
$errors['err'] = __('Unable to set sorting mode');
}
break;
default:
$errors['err']=__('Unknown action - get technical help.');
}
}
break;
default:
$errors['err']=__('Unknown action');
break;
}
if ($id or $topic) {
if (!$id) $id=$topic->getId();
}
}
$page='helptopics.inc.php';
$tip_namespace = 'manage.helptopic';
if($topic || ($_REQUEST['a'] && !strcasecmp($_REQUEST['a'],'add'))) {
$page='helptopic.inc.php';
}
$nav->setTabActive('manage');
$ost->addExtraHeader('<meta name="tip-namespace" content="' . $tip_namespace . '" />',
"$('#content').data('tipNamespace', '".$tip_namespace."');");
require(STAFFINC_DIR.'header.inc.php');
require(STAFFINC_DIR.$page);
include(STAFFINC_DIR.'footer.inc.php');
?>