[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare - Admin config * |
---|
| 4 | * Written by Miles Lott <milosch@phpwhere.org> * |
---|
| 5 | * http://www.egroupware.org * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | class uiconfig |
---|
| 15 | { |
---|
| 16 | var $public_functions = array('index' => True); |
---|
| 17 | |
---|
| 18 | function index() |
---|
| 19 | { |
---|
| 20 | if ($GLOBALS['phpgw']->acl->check('site_config_access',1,'admin')) |
---|
| 21 | { |
---|
| 22 | $GLOBALS['phpgw']->redirect_link('/index.php'); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | if(get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
---|
| 26 | { |
---|
| 27 | $_POST['newsettings'] = array_map("stripslashes", $_POST['newsettings']); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | switch($_GET['appname']) |
---|
| 31 | { |
---|
| 32 | case 'admin': |
---|
| 33 | case 'addressbook': |
---|
| 34 | case 'calendar': |
---|
| 35 | case 'email': |
---|
| 36 | case 'instant_messenger': |
---|
[382] | 37 | case 'jabberit_messenger': |
---|
[2] | 38 | case 'nntp': |
---|
| 39 | /* |
---|
| 40 | Other special apps can go here for now, e.g.: |
---|
| 41 | case 'bogusappname': |
---|
| 42 | */ |
---|
| 43 | $appname = $_GET['appname']; |
---|
| 44 | $config_appname = 'phpgwapi'; |
---|
| 45 | break; |
---|
| 46 | case 'phpgwapi': |
---|
| 47 | case '': |
---|
| 48 | /* This keeps the admin from getting into what is a setup-only config */ |
---|
| 49 | $GLOBALS['phpgw']->redirect_link('/admin/index.php'); |
---|
| 50 | break; |
---|
| 51 | default: |
---|
| 52 | $appname = $_GET['appname']; |
---|
| 53 | $config_appname = $appname; |
---|
| 54 | break; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir($appname)); |
---|
| 58 | $t->set_unknowns('keep'); |
---|
| 59 | $t->set_file(array('config' => 'config.tpl')); |
---|
| 60 | $t->set_block('config','header','header'); |
---|
| 61 | $t->set_block('config','body','body'); |
---|
| 62 | $t->set_block('config','footer','footer'); |
---|
| 63 | |
---|
| 64 | $c = CreateObject('phpgwapi.config',$config_appname); |
---|
| 65 | $c->read_repository(); |
---|
| 66 | |
---|
| 67 | if ($c->config_data) |
---|
| 68 | { |
---|
| 69 | $current_config = $c->config_data; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin')) |
---|
| 73 | { |
---|
| 74 | $GLOBALS['phpgw']->redirect_link('/admin/index.php'); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | if ($_POST['submit']) |
---|
| 78 | { |
---|
| 79 | /* Load hook file with functions to validate each config (one/none/all) */ |
---|
| 80 | $GLOBALS['phpgw']->hooks->single('config_validate',$appname); |
---|
| 81 | |
---|
| 82 | foreach($_POST['newsettings'] as $key => $config) |
---|
| 83 | { |
---|
| 84 | if ($config) |
---|
| 85 | { |
---|
| 86 | if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists($key)) |
---|
| 87 | { |
---|
| 88 | call_user_func($key,$config); |
---|
| 89 | if($GLOBALS['config_error']) |
---|
| 90 | { |
---|
| 91 | $errors .= lang($GLOBALS['config_error']) . ' '; |
---|
| 92 | $GLOBALS['config_error'] = False; |
---|
| 93 | } |
---|
| 94 | else |
---|
| 95 | { |
---|
| 96 | $c->config_data[$key] = $config; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | $c->config_data[$key] = $config; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | else |
---|
| 105 | { |
---|
| 106 | /* don't erase passwords, since we also don't print them */ |
---|
| 107 | if(!ereg('passwd',$key) && !ereg('password',$key) && !ereg('root_pw',$key)) |
---|
| 108 | { |
---|
| 109 | unset($c->config_data[$key]); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists('final_validation')) |
---|
| 114 | { |
---|
| 115 | final_validation($newsettings); |
---|
| 116 | if($GLOBALS['config_error']) |
---|
| 117 | { |
---|
| 118 | $errors .= lang($GLOBALS['config_error']) . ' '; |
---|
| 119 | $GLOBALS['config_error'] = False; |
---|
| 120 | } |
---|
| 121 | unset($GLOBALS['phpgw_info']['server']['found_validation_hook']); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | $c->save_repository(); |
---|
| 125 | |
---|
| 126 | if(!$errors) |
---|
| 127 | { |
---|
| 128 | $GLOBALS['phpgw']->redirect_link('/admin/index.php'); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | if($errors) |
---|
| 133 | { |
---|
| 134 | $t->set_var('error',lang('Error') . ': ' . $errors); |
---|
| 135 | $t->set_var('th_err','#FF8888'); |
---|
| 136 | unset($errors); |
---|
| 137 | unset($GLOBALS['config_error']); |
---|
| 138 | } |
---|
| 139 | else |
---|
| 140 | { |
---|
| 141 | $t->set_var('error',''); |
---|
| 142 | $t->set_var('th_err',$GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 146 | { |
---|
| 147 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 148 | } |
---|
| 149 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
| 150 | |
---|
| 151 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 152 | echo parse_navbar(); |
---|
| 153 | |
---|
[540] | 154 | if($appname=="expressoAdmin1_2") { |
---|
| 155 | /* Varre a pasta inc do admin do expresso procurando scripts de geração de login automático |
---|
| 156 | (classes com nomes iniciados pela string 'login', procedida da string '_' mais o nome |
---|
| 157 | do algoritmo. |
---|
| 158 | */ |
---|
[597] | 159 | |
---|
[540] | 160 | $dir = $GLOBALS['phpgw']->common->get_app_dir($appname) . "/inc"; |
---|
| 161 | $options = ' '; |
---|
[608] | 162 | if (is_dir($dir)) |
---|
| 163 | { |
---|
| 164 | if ($dh = opendir($dir)) |
---|
| 165 | { |
---|
| 166 | while (($file = readdir($dh)) !== false) |
---|
| 167 | { |
---|
[540] | 168 | $temp = explode(".",$file); |
---|
[608] | 169 | if( (substr($temp[1],0,5) =='login') && ($temp[0] == 'class') ) |
---|
| 170 | { |
---|
[540] | 171 | $options .= "<option value='".$temp[1]."'"; |
---|
| 172 | if($current_config['expressoAdmin_loginGenScript'] == $temp[1]) |
---|
| 173 | $options .= " selected"; |
---|
| 174 | $options .= ">" . ucwords(str_replace("_"," ",substr($temp[1],6))) . "</option>"; |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | closedir($dh); |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | $t->set_var('rows_login_generator',$options); |
---|
| 182 | } |
---|
[547] | 183 | |
---|
| 184 | |
---|
[597] | 185 | if($appname=="admin") { |
---|
| 186 | /* |
---|
[608] | 187 | * FCK editor to agree term |
---|
[597] | 188 | */ |
---|
| 189 | include_once("news_admin/inc/fckeditor.php"); |
---|
| 190 | $oFCKeditor = new FCKeditor('newsettings[agree_term]');//CreateObject('news_admin.fckeditor','newsettings[agree_term]'); |
---|
[1325] | 191 | $oFCKeditor->BasePath = 'news_admin/templates/default/fckeditor/'; |
---|
[597] | 192 | $oFCKeditor->ToolbarSet = 'Basic'; |
---|
[608] | 193 | $oFCKeditor->Value = isset($GLOBALS['phpgw_info']['server']['agree_term']) ? $GLOBALS['phpgw_info']['server']['agree_term'] : ''; |
---|
[597] | 194 | $t->set_var('agree_term_input',$oFCKeditor->Create()); |
---|
| 195 | } |
---|
[2] | 196 | $t->set_var('title',lang('Site Configuration')); |
---|
| 197 | $t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); |
---|
| 198 | $t->set_var('th_bg', $GLOBALS['phpgw_info']['theme']['th_bg']); |
---|
| 199 | $t->set_var('th_text', $GLOBALS['phpgw_info']['theme']['th_text']); |
---|
| 200 | $t->set_var('row_on', $GLOBALS['phpgw_info']['theme']['row_on']); |
---|
| 201 | $t->set_var('row_off', $GLOBALS['phpgw_info']['theme']['row_off']); |
---|
[3018] | 202 | $t->set_var('php_upload_limit',str_replace('M','',ini_get('upload_max_filesize'))); |
---|
[2] | 203 | $t->pparse('out','header'); |
---|
| 204 | |
---|
| 205 | $vars = $t->get_undefined('body'); |
---|
| 206 | |
---|
| 207 | $GLOBALS['phpgw']->hooks->single('config',$appname); |
---|
| 208 | |
---|
| 209 | foreach($vars as $value) |
---|
| 210 | { |
---|
| 211 | $valarray = explode('_',$value); |
---|
| 212 | $type = array_shift($valarray); |
---|
| 213 | $newval = implode(' ',$valarray); |
---|
| 214 | switch ($type) |
---|
| 215 | { |
---|
| 216 | case 'lang': |
---|
| 217 | $t->set_var($value,lang($newval)); |
---|
| 218 | break; |
---|
| 219 | case 'value': |
---|
| 220 | $newval = str_replace(' ','_',$newval); |
---|
| 221 | /* Don't show passwords in the form */ |
---|
| 222 | if(ereg('passwd',$value) || ereg('password',$value) || ereg('root_pw',$value)) |
---|
| 223 | { |
---|
| 224 | $t->set_var($value,''); |
---|
| 225 | } |
---|
| 226 | else |
---|
| 227 | { |
---|
[1085] | 228 | $t->set_var($value,htmlspecialchars($current_config[$newval])); |
---|
[2] | 229 | } |
---|
| 230 | break; |
---|
| 231 | /* |
---|
| 232 | case 'checked': |
---|
| 233 | $newval = str_replace(' ','_',$newval); |
---|
| 234 | if ($current_config[$newval]) |
---|
| 235 | { |
---|
| 236 | $t->set_var($value,' checked'); |
---|
| 237 | } |
---|
| 238 | else |
---|
| 239 | { |
---|
| 240 | $t->set_var($value,''); |
---|
| 241 | } |
---|
| 242 | break; |
---|
| 243 | */ |
---|
| 244 | case 'selected': |
---|
| 245 | $configs = array(); |
---|
| 246 | $config = ''; |
---|
| 247 | $newvals = explode(' ',$newval); |
---|
| 248 | $setting = end($newvals); |
---|
| 249 | for ($i=0;$i<(count($newvals) - 1); $i++) |
---|
| 250 | { |
---|
| 251 | $configs[] = $newvals[$i]; |
---|
| 252 | } |
---|
| 253 | $config = implode('_',$configs); |
---|
| 254 | /* echo $config . '=' . $current_config[$config]; */ |
---|
| 255 | if ($current_config[$config] == $setting) |
---|
| 256 | { |
---|
| 257 | $t->set_var($value,' selected'); |
---|
| 258 | } |
---|
| 259 | else |
---|
| 260 | { |
---|
| 261 | $t->set_var($value,''); |
---|
| 262 | } |
---|
| 263 | break; |
---|
| 264 | case 'hook': |
---|
| 265 | $newval = str_replace(' ','_',$newval); |
---|
| 266 | if(function_exists($newval)) |
---|
| 267 | { |
---|
| 268 | $t->set_var($value,$newval($current_config)); |
---|
| 269 | } |
---|
| 270 | else |
---|
| 271 | { |
---|
| 272 | $t->set_var($value,''); |
---|
| 273 | } |
---|
| 274 | break; |
---|
| 275 | default: |
---|
| 276 | $t->set_var($value,''); |
---|
| 277 | break; |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | $t->pfp('out','body'); |
---|
| 282 | |
---|
| 283 | $t->set_var('lang_submit', $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save')); |
---|
| 284 | $t->set_var('lang_cancel', lang('Cancel')); |
---|
| 285 | $t->pfp('out','footer'); |
---|
| 286 | } |
---|
| 287 | } |
---|
| 288 | ?> |
---|