-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.php
More file actions
478 lines (455 loc) · 15 KB
/
Copy pathconfigure.php
File metadata and controls
478 lines (455 loc) · 15 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<?php
/* This file will write a php config file to be included during execution of
* all helpdesk files which require the configuration options. */
if (!defined('DP_BASE_DIR')){
die('You should not access this file directly.');
}
// Deny all but system admins
if (getDenyEdit('system')) {
$AppUI->redirect( "m=public&a=access_denied" );
}
@include_once( "./functions/admin_func.php" );
$CONFIG_FILE = "./modules/helpdesk/config.php";
$AppUI->savePlace();
// setup the title block
$titleBlock = new CTitleBlock( 'Configure Issue Module', 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=system", "System Admin" );
$titleBlock->addCrumb( "?m=system&a=viewmods", "Modules" );
$titleBlock->show();
// Get a list of statuses
$statuses = dPgetSysVal( 'HelpDeskStatus' );
$project_statuses = dPgetSysVal( 'ProjectStatus' );
// Get a list of companies
$q = new DBQuery;
$q->addQuery('company_id, company_name');
$q->addTable('companies');
$q->addOrder('company_name');
$res = $q->loadList();
$q->clear();
// Add "No Company"
$companies['-1'] = '';
foreach ($res as $row) {
$companies[$row['company_id']] = $row['company_name'];
}
$activeUsers=getAllowedUsers(0,1);
$assignUsers=arrayMerge( array(-1=>'', 0 => $AppUI->_('Current User') ), $activeUsers);
//define user type list
$user_types = arrayMerge( $utypes, array( '9' => $AppUI->_('None') ) );
/* All config options, their descriptions and their default values are defined
* here. Add new config options here. Type can be "checkbox", "text", "radio" or
* "select". If the type is "radio," it must include a set of buttons. If it's
* "select" then be sure to include a 'list' entry with the options. if the key
* starts with headingXXX then it will just display the contents on the value.
* This is used for grouping.
*/
$config_options = array(
"heading1" => $AppUI->_('Helpdesk System Options'),
"items_per_page" => array(
'description' => $AppUI->_('Helpdesk Items Per Page'),
'value' => '30',
'type' => 'text'
),
"status_log_items_per_page" => array(
'description' => $AppUI->_('Helpdesk Logs Per Page'),
'value' => '15',
'type' => 'text'
),
"pages_per_side" => array(
'description' => $AppUI->_('Helpdesk Pages Per Side'),
'value' => '5',
'type' => 'text'
),
"notification_deadline_format" => array(
'description' => $AppUI->_('Date Format for Notifications'),
'value' => 'l\, F jS Y',
'type' => 'text'
),
"notification_cron_url" => array(
'description' => $AppUI->_('URL for Deadline Notifications'),
'value' => $dPconfig['base_url'],
'type' => 'text'
),
"closed_status_id" => array(
'description' => $AppUI->_('Helpdesk Item Closed Status Map'),
'value' => '2',
'type' => 'select',
'list' => $statuses
),
"assigned_status_id" => array(
'description' => $AppUI->_('Helpdesk Item Assigned Status Map'),
'value' => '1',
'type' => 'select',
'list' => $statuses
),
"archived_project_status_id" => array(
'description' => $AppUI->_('Archived Project Status Map'),
'value' => '7',
'type' => 'select',
'list' => $project_statuses
),
"heading2" => $AppUI->_('Permission Options'),
"the_company" => array(
'description' => $AppUI->_('Helpdesk Host Company'),
'value' => '1',
'type' => 'select',
'list' => $companies
),
"no_company_editable" => array(
'description' => $AppUI->_('Allow Helpdesk Items without Company'),
'value' => '1',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"use_project_perms" => array(
'description' => $AppUI->_("Filter Projects list by users permissions"),
'value' => '0',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"system_admin_role" => array(
'description' => $AppUI->_('User role for System Administrators Map'),
'value' => '1',
'type' => 'select',
'list' => @$user_types
),
"helpdesk_manager_role" => array(
'description' => $AppUI->_('User role for Help Desk Managers Map'),
'value' => '4',
'type' => 'select',
'list' => @$user_types
),
"heading3" => $AppUI->_('New Item Default Selections'),
"new_hd_item_title_prefix" => array(
'description' => $AppUI->_('Default item title prefix'),
'value' => 'HD-%05d',
'type' => 'text'
),
"default_assigned_to" => array(
'description' => $AppUI->_('Default Assigned To'),
'value' => '-1',
'type' => 'select',
'list' => $assignUsers
//'value' => 1,
//'type' => 'radio',
//'buttons' => array (1 => $AppUI->_('Yes'),
// 0 => $AppUI->_('No'))
),
"default_company_current_company" => array(
'description' => $AppUI->_('Default Company'),
'value' => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Current users company'),
0 => $AppUI->_('None'))
),
"default_watcher" => array(
'description' => $AppUI->_('Use Default Watcher(s)'),
'value' => 0,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"default_watcher_list" => array(
'description' => $AppUI->_('Default Watchers'),
'value' => 0,
'type' => 'multiselect',
'list' => $activeUsers
),
"heading4" => $AppUI->_('Search Fields On Item List'),
"search_criteria_search" => array(
'description' => $AppUI->_('Title/Summary Search'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_call_type" => array(
'description' => $AppUI->_('Issue Type'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_company" => array(
'description' => $AppUI->_('Company'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_status" => array(
'description' => $AppUI->_('Status'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_call_source" => array(
'description' => $AppUI->_('Issue Source'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_project" => array(
'description' => $AppUI->_('Project'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_assigned_to" => array(
'description' => $AppUI->_('Assigned To'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_priority" => array(
'description' => $AppUI->_('Priority'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_application" => array(
'description' => $AppUI->_('Application'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_requestor" => array(
'description' => $AppUI->_('Requestor'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_severity" => array(
'description' => $AppUI->_('Severity'),
'value' => 1,
'type' => 'checkbox'
),
"search_criteria_os" => array(
'description' => $AppUI->_('Operating System'),
'value' => 1,
'type' => 'checkbox'
),
// Configurable fields for email notification
"heading5" => $AppUI->_('Notification Email Options'),
"default_notify_by_email" => array(
'description' => $AppUI->_('Email notification as default for new item'),
'value' => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"task_watchers_notification" => array(
'description' => $AppUI->_('Watchers notification'),
'value' => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"task_requestor_notification" => array(
'description' => $AppUI->_('Requestor notification'),
'value' => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"notify_mask_user_name" => array(
'description' => $AppUI->_('Use system e-mail prefix to mask current').'<br />'.$AppUI->_('user name for notification e-mails'),
'value' => 1,
'type' => 'checkbox'
),
"notity_email_address" => array(
'description' => $AppUI->_('Default "From:" notification address'),
'value' => $defaultAdminEmail,
'type' => 'text'
),
"email_subject" => array(
'description' => $AppUI->_('Email subject (trailed by ticket number)'),
'value' => 'The Company registered your recent request',
'type' => 'text'
),
"email_header" => array(
'description' => $AppUI->_('Email header (enter "NONE" to remove)'),
'value' => 'The Company Ticket Management Registry',
'type' => 'text'
)
);
//if this is a submitted page, overwrite the config file.
if(dPgetParam( $_POST, "Save", '' )!=''){
if (is_writable($CONFIG_FILE)) {
if (!$handle = fopen($CONFIG_FILE, 'w')) {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('cannot be opened'), UI_MSG_ERROR );
exit;
}
if (fwrite($handle, "<?php //Do not edit this file by hand, it will be overwritten by the configuration utility. \n") === FALSE) {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('cannot be written to'), UI_MSG_ERROR );
exit;
} else {
foreach ($config_options as $key=>$value){
if(substr($key,0,7)=='heading') continue;
$val="";
switch($value['type']){
case 'checkbox':
$val = isset($_POST[$key])?"1":"0";
break;
case 'text':
$val = isset($_POST[$key])?$_POST[$key]:"";
break;
case 'select':
$val = isset($_POST[$key])?$_POST[$key]:"0";
break;
case 'multiselect':
if(isset($_POST[$key])){
foreach ($_POST[$key] as $idx=>$watcher){
$val .= $watcher.",";
}
$val=trim($val,',');
} else {
$val=0;
}
break;
case 'radio':
$val = $_POST[$key];
break;
default:
break;
}
fwrite($handle, "\$HELPDESK_CONFIG['".$key."'] = '".$val."';\n");
}
fwrite($handle, "?>\n");
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('has been successfully updated'), UI_MSG_OK );
fclose($handle);
require( $CONFIG_FILE );
}
} else {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('is not writable'), UI_MSG_ERROR );
}
} else if(dPgetParam( $_POST, $AppUI->_('cancel'), '' )!=''){
$AppUI->redirect("m=system&a=viewmods");
}
//$HELPDESK_CONFIG = array();
if (file_exists($CONFIG_FILE)) {
$isSetup = file_get_contents('./modules/helpdesk/config.php');
if ($isSetup == "CONFIGURE_ME") {
$isSetup = false;
} else {
$isSetup = true;
require_once( $CONFIG_FILE );
}
}
//Read the current config values from the config file and update the array.
foreach ($config_options as $key=>$value){
if(isset($HELPDESK_CONFIG[$key])){
$config_options[$key]['value']=$HELPDESK_CONFIG[$key];
}
}
// Check the notify email address. If blank fill with a default value based
// on either the user type of administrator, or the first user in the system
if (!$HELPDESK_CONFIG['notity_email_address']['value']) {
// Get administrator user type
$adminType = '';
$usertypes = dPgetSysVal( 'UserType' );
foreach ($usertypes as $key => $val) {
if (stripos(' '.$val, $AppUI->_('Admin'))>=1) {
$adminType = $key;
}
}
// Find admin or first user email address
$q = new DBQuery;
$q->addQuery('c.contact_email');
$q->addTable('users','u');
$q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id');
if (intval($adminType) >= 1) {
$q->addWhere('u.user_type = '.$adminType);
}
$q->addOrder('u.user_id');
$defaultAdminEmail = $q->loadResult();
$q->clear();
$config_options['notity_email_address']['value']=$defaultAdminEmail;
}
?>
<script language = 'javascript' type='text/javascript'>
function enableWatcherList(show){
var useDefWatcher=document.getElementById('default_watcher');
var WatcherList=document.getElementById('default_watcher_list[]');
if(show){
document.getElementById('default_watcher_list[]').disabled=false;
document.getElementById('default_watcher_list[]').className='text';
}
else{
document.getElementById('default_watcher_list[]').disabled=true;
document.getElementById('default_watcher_list[]').className='disabledText';
}
}
</script>
<form method="post">
<table class="std">
<?php
/*echo "<pre>";
print_r($config_options);
echo "<pre>";*/
$useDefWatcher=0;
foreach ($config_options as $key=>$value){
?>
<tr>
<?php
// the key starts with hr, then just display the value
if(substr($key,0,7)=='heading'){ ?>
<th align="center" colspan="2"><?php echo $value?></th>
<?php } else { ?>
<td align="right"><?php echo $value['description']?></td>
<td><?php
switch($value['type']){
case 'checkbox': ?>
<input type="checkbox" name="<?php echo $key?>" <?php echo $value['value']?"checked=\"checked\"":""?>>
<?php
break;
case 'text': ?>
<input type="text" name="<?php echo $key?>" value="<?php echo $value['value']?>" size=32>
<?php
break;
case 'select':
print arraySelect( $value["list"], $key, 'class="text" size="1" id="' . $key . '" ' . $value["events"], $value['value'] );
break;
case 'multiselect':
//print arraySelect( $value["list"], $key.'[]', 'class="text" multiple size="5" id="' . $key. '[]" ' . $value["events"], $value['value'] );
?>
<select name=<?php echo $key.'[]';
if($useDefWatcher)
echo " class='text'";
else
echo " class='disabledText' Disabled ";
?>
multiple="multiple" size="5" bgcolor=#ddd id=<?php echo $key.'[]'; ?>>
<?php
// organize string '118,72,2,68' into array
$selected=explode(',',$value['value']);
foreach ( $value["list"] as $k => $v ) {
echo "\n\t<option value=\"".$k."\"".(in_array($k, $selected) ? " selected=\"selected\"" : '').">" . $v . "</option>";
//echo "\n\t<option value=\"".$k."\"".($k == $selected ? " selected=\"selected\"" : '').">" . $v . "</option>";
}
?>
</select>
<?php
break;
case 'radio':
if($value['value']) $useDefWatcher=1;
else $useDefWatcher=0;
foreach ($value['buttons'] as $v => $n) {
if($key=='default_watcher'){ ?>
<label><input type="radio" name="<?php echo $key; ?>" id="<?php echo $key; ?>"
value=<?php echo $v;
/*if($v) $useDefWatcher=1;
else $useDefWatcher=0;*/
?>
<?php echo (($value['value'] == $v)?"checked":""); ?> <?php echo $value['events']; ?> onClick=enableWatcherList(<?php echo $v; ?>)> <?php echo $n;?></label>
<?php }
else {?>
<label><input type="radio" name="<?php echo $key; ?>" id="<?php echo $key; ?>" value=<?php echo $v; ?> <?php echo (($value['value'] == $v)?"checked":""); ?> <?php echo $value['events']; ?>> <?php echo $n;?></label>
<?php }
}
break;
default:
break;
}
?></td>
<?php
}
?>
</tr>
<?php
}
?>
<tr>
<td colspan="2" align="right"><input type="Submit" name="Cancel" value="<?php echo $AppUI->_('back')?>">
<input type="Submit" name="Save" value="<?php echo $AppUI->_('save')?>"></td>
</tr>
</table>
</form>