[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Admin config * 4 * Written by Miles Lott <milos@groupwhere.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 /* $Id: class.uiconfig.inc.php 20976 2006-04-06 10:51:04Z ralfbecker $ */ 14 15 class uiconfig 16 { 17 var $public_functions = array('index' => True); 18 19 function index() 20 { 21 if ($GLOBALS['egw']->acl->check('site_config_access',1,'admin')) 22 { 23 $GLOBALS['egw']->redirect_link('/index.php'); 24 } 25 $referer = $_POST['submit'] || $_POST['cancel'] ? $_POST['referer'] : $_SERVER['HTTP_REFERER']; 26 if (!$referer) $referer = $GLOBALS['egw']->link('/admin/index.php'); 27 list(,$show_app) = explode($GLOBALS['egw_info']['server']['webserver_url'],$referer); 28 list(,$show_app) = explode('/',$show_app); 29 if (!$show_app) $show_app = 'admin'; 30 31 // load the translations of the app we show too, so they dont need to be in admin! 32 if ($_GET['appname'] != 'admin') 33 { 34 $GLOBALS['egw']->translation->add_app($_GET['appname']); 35 } 36 37 if(get_magic_quotes_gpc() && is_array($_POST['newsettings'])) 38 { 39 $_POST['newsettings'] = array_map("stripslashes", $_POST['newsettings']); 40 } 41 42 switch($_GET['appname']) 43 { 44 case 'admin': 45 case 'addressbook': 46 case 'calendar': 47 case 'email': 48 case 'nntp': 49 /* 50 Other special apps can go here for now, e.g.: 51 case 'bogusappname': 52 */ 53 $appname = $_GET['appname']; 54 $config_appname = 'phpgwapi'; 55 break; 56 case 'phpgwapi': 57 case '': 58 /* This keeps the admin from getting into what is a setup-only config */ 59 $GLOBALS['egw']->redirect_link('/admin/index.php'); 60 break; 61 default: 62 $appname = $_GET['appname']; 63 $config_appname = $appname; 64 break; 65 } 66 $t =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir($appname)); 67 $t->set_unknowns('keep'); 68 $t->set_file(array('config' => 'config.tpl')); 69 $t->set_block('config','header','header'); 70 $t->set_block('config','body','body'); 71 $t->set_block('config','footer','footer'); 72 73 $c =& CreateObject('phpgwapi.config',$config_appname); 74 $c->read_repository(); 75 76 if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['egw']->acl->check('site_config_access',2,'admin')) 77 { 78 $GLOBALS['egw']->redirect($referer); 79 } 80 81 if ($_POST['submit']) 82 { 83 /* Load hook file with functions to validate each config (one/none/all) */ 84 $GLOBALS['egw']->hooks->single('config_validate',$appname); 85 86 foreach($_POST['newsettings'] as $key => $config) 87 { 88 if ($config) 89 { 90 $c->config_data[$key] = $config; 91 if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists($key)) 92 { 93 call_user_func($key,$config); 94 if($GLOBALS['config_error']) 95 { 96 $errors .= lang($GLOBALS['config_error']) . ' '; 97 $GLOBALS['config_error'] = False; 98 } 99 } 100 } 101 /* don't erase passwords, since we also don't print them */ 102 elseif(!ereg('passwd',$key) && !ereg('password',$key) && !ereg('root_pw',$key)) 103 { 104 unset($c->config_data[$key]); 105 } 106 } 107 if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists('final_validation')) 108 { 109 final_validation($_POST['newsettings']); 110 if($GLOBALS['config_error']) 111 { 112 $errors .= lang($GLOBALS['config_error']) . ' '; 113 $GLOBALS['config_error'] = False; 114 } 115 unset($GLOBALS['egw_info']['server']['found_validation_hook']); 116 } 117 118 $c->save_repository(); 119 120 if(!$errors) 121 { 122 $GLOBALS['egw']->redirect($referer); 123 } 124 } 125 126 if($errors) 127 { 128 $t->set_var('error',lang('Error') . ': ' . $errors); 129 $t->set_var('th_err','#FF8888'); 130 unset($errors); 131 unset($GLOBALS['config_error']); 132 } 133 else 134 { 135 $t->set_var('error',''); 136 $t->set_var('th_err',$GLOBALS['egw_info']['theme']['th_bg']); 137 } 138 139 if(!@is_object($GLOBALS['egw']->js)) 140 { 141 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 142 } 143 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 144 145 // set currentapp to our calling app, to show the right sidebox-menu 146 $GLOBALS['egw_info']['flags']['currentapp'] = $show_app; 147 $GLOBALS['egw']->common->egw_header(); 148 echo parse_navbar(); 149 150 $t->set_var('title',lang('Site Configuration')); 151 $t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); 152 $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); 153 $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); 154 $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); 155 $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); 156 $t->set_var('hidden_vars','<input type="hidden" name="referer" value="'.$referer.'">'); 157 $t->pparse('out','header'); 158 159 $vars = $t->get_undefined('body'); 160 161 if ($GLOBALS['egw']->hooks->single('config',$appname)) // reload the config-values, they might have changed 162 { 163 $c->read_repository(); 164 } 165 foreach($vars as $value) 166 { 167 $valarray = explode('_',$value); 168 $type = array_shift($valarray); 169 $newval = implode(' ',$valarray); 170 171 switch ($type) 172 { 173 case 'lang': 174 $t->set_var($value,lang($newval)); 175 break; 176 case 'value': 177 $newval = str_replace(' ','_',$newval); 178 /* Don't show passwords in the form */ 179 if(ereg('passwd',$value) || ereg('password',$value) || ereg('root_pw',$value)) 180 { 181 $t->set_var($value,''); 182 } 183 else 184 { 185 $t->set_var($value,$c->config_data[$newval]); 186 } 187 break; 188 /* 189 case 'checked': 190 $newval = str_replace(' ','_',$newval); 191 if ($c->config_data[$newval]) 192 { 193 $t->set_var($value,' checked'); 194 } 195 else 196 { 197 $t->set_var($value,''); 198 } 199 break; 200 */ 201 case 'selected': 202 $configs = array(); 203 $config = ''; 204 $newvals = explode(' ',$newval); 205 $setting = end($newvals); 206 for ($i=0;$i<(count($newvals) - 1); $i++) 207 { 208 $configs[] = $newvals[$i]; 209 } 210 $config = implode('_',$configs); 211 /* echo $config . '=' . $c->config_data[$config]; */ 212 if ($c->config_data[$config] == $setting) 213 { 214 $t->set_var($value,' selected'); 215 } 216 else 217 { 218 $t->set_var($value,''); 219 } 220 break; 221 case 'hook': 222 $newval = str_replace(' ','_',$newval); 223 if(function_exists($newval)) 224 { 225 $t->set_var($value,$newval($c->config_data)); 226 } 227 else 228 { 229 $t->set_var($value,''); 230 } 231 break; 232 default: 233 $t->set_var($value,''); 234 break; 235 } 236 } 237 238 $t->pfp('out','body'); 239 240 $t->set_var('lang_submit', $GLOBALS['egw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save')); 241 $t->set_var('lang_cancel', lang('Cancel')); 242 $t->pfp('out','footer'); 243 } 244 } 245 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |