-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.php
More file actions
157 lines (139 loc) · 4.73 KB
/
Copy pathconfigure.php
File metadata and controls
157 lines (139 loc) · 4.73 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
<?php
/* This file will write a php config file to be included during execution of
* all Project designer files which require the configuration options. */
global $m;
// Deny all but system admins
if (getDenyEdit('system')) {
$AppUI->redirect( "m=public&a=access_denied" );
}
@include_once( "./functions/admin_func.php" );
$CONFIG_FILE = "./modules/projectdesigner/config.php";
$AppUI->savePlace();
//define user type list
$user_types = arrayMerge( $utypes, array( '9' => $AppUI->_('None') ) );
$config_options = array(
"heading1" => $AppUI->_('General Options'),
"show_task_descriptions" => array(
"description" => $AppUI->_('Show Full Task Description Column'),
"value" => '1',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"chars_task_descriptions" => array(
"description" => $AppUI->_('Description Length on Tooltip'),
"value" => '200',
'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 'longtext':
$val = isset($_POST[$key])?$_POST[$key]:"";
break;
case 'select':
$val = isset($_POST[$key])?$_POST[$key]:"0";
break;
case 'radio':
$val = $_POST[$key];
break;
default:
break;
}
fwrite($handle, "\$PROJDESIGN_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 );
}
} elseif(dPgetParam( $_POST, $AppUI->_('Cancel'), '' )!=''){
$AppUI->redirect("m=system&a=viewmods");
}
//$PROJDESIGN_CONFIG = array();
include( $CONFIG_FILE );
//Read the current config values from the config file and update the array.
foreach ($config_options as $key=>$value){
if(isset($PROJDESIGN_CONFIG[$key])){
$config_options[$key]['value']=$PROJDESIGN_CONFIG[$key];
}
}
// setup the title block
$titleBlock = new CTitleBlock( 'Project Designer Module Configuration', 'projectdesigner.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=system", "System Admin" );
$titleBlock->addCrumb( "?m=system&a=viewmods", "Modules" );
$titleBlock->show();
?>
<form method="post">
<table class="std">
<?php
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?>" style="<?php echo $value['style']?>" value="<?php echo $value['value']?>">
<?php
break;
case 'longtext': ?>
<input type="text" size="70" name="<?php echo $key?>" style="<?php echo $value['style']?>" value="<?php echo $value['value']?>">
<?php
break;
case 'select':
print arraySelect( $value["list"], $key, 'class="text" size="1" id="' . $key . '" ' . $value["events"], $value["value"] );
break;
case 'radio':
foreach ($value['buttons'] as $v => $n) {?>
<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>