| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - administration * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: class.uiapplications.inc.php 20967 2006-04-06 07:54:39Z ralfbecker $ */ 13 14 class uiapplications 15 { 16 var $public_functions = array( 17 'get_list' => True, 18 'add' => True, 19 'edit' => True, 20 'delete' => True, 21 'register_all_hooks' => True 22 ); 23 24 var $bo; 25 var $nextmatchs; 26 27 function uiapplications() 28 { 29 $this->bo =& CreateObject('admin.boapplications'); 30 $this->nextmatchs =& CreateObject('phpgwapi.nextmatchs'); 31 } 32 33 function get_list() 34 { 35 if ($GLOBALS['egw']->acl->check('applications_access',1,'admin')) 36 { 37 $GLOBALS['egw']->redirect_link('/index.php'); 38 } 39 $can_add = !$GLOBALS['egw']->acl->check('applications_access',2,'admin'); 40 $can_edit = !$GLOBALS['egw']->acl->check('applications_access',4,'admin'); 41 $can_delete = !$GLOBALS['egw']->acl->check('applications_access',8,'admin'); 42 43 $GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Installed applications'); 44 if(!@is_object($GLOBALS['egw']->js)) 45 { 46 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 47 } 48 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 49 $GLOBALS['egw']->common->egw_header(); 50 echo parse_navbar(); 51 52 $GLOBALS['egw']->template->set_file(array('applications' => 'applications.tpl')); 53 $GLOBALS['egw']->template->set_block('applications','list','list'); 54 $GLOBALS['egw']->template->set_block('applications','row','row'); 55 $GLOBALS['egw']->template->set_block('applications','add','add'); 56 57 $start = get_var('start',array('POST','GET')); 58 $sort = $_GET['sort']; 59 $order = $_GET['order']; 60 $offset = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; 61 62 $apps = $this->bo->get_list(); 63 $total = count($apps); 64 65 $sort = $sort ? $sort : 'ASC'; 66 67 uasort($apps,create_function('$a,$b','return strcasecmp($a[\'title\'],$b[\'title\'])'.($sort != 'ASC' ? '* -1' : '').';')); 68 69 if ($start && $offset) 70 { 71 $limit = $start + $offset; 72 } 73 elseif ($start && !$offset) 74 { 75 $limit = $start; 76 } 77 elseif(!$start && !$offset) 78 { 79 $limit = $total; 80 } 81 else 82 { 83 $start = 0; 84 $limit = $offset; 85 } 86 87 if ($limit > $total) 88 { 89 $limit = $total; 90 } 91 92 $i = 0; 93 $applications = array(); 94 while(list($app,$data) = @each($apps)) 95 { 96 if($i >= $start && $i< $limit) 97 { 98 $applications[$app] = $data; 99 } 100 $i++; 101 } 102 103 $GLOBALS['egw']->template->set_var('bg_color',$GLOBALS['egw_info']['theme']['bg_color']); 104 $GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']); 105 106 $GLOBALS['egw']->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),'&menuaction=admin.uiapplications.get_list')); 107 $GLOBALS['egw']->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start)); 108 $GLOBALS['egw']->template->set_var('left',$this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiapplications.get_list')); 109 $GLOBALS['egw']->template->set_var('right',$this->nextmatchs->right('index.php',$start,$total,'menuaction=admin.uiapplications.get_list')); 110 111 $GLOBALS['egw']->template->set_var('lang_edit',lang('Edit')); 112 $GLOBALS['egw']->template->set_var('lang_delete',lang('Delete')); 113 $GLOBALS['egw']->template->set_var('lang_enabled',lang('Enabled')); 114 115 $GLOBALS['egw']->template->set_var('new_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.add')); 116 $GLOBALS['egw']->template->set_var('lang_note',lang('(To install new applications use<br><a href="setup/" target="setup">Setup</a> [Manage Applications] !!!)')); 117 $GLOBALS['egw']->template->set_var('lang_add',lang('add')); 118 119 foreach($applications as $app) 120 { 121 $tr_color = $this->nextmatchs->alternate_row_color($tr_color); 122 123 $GLOBALS['egw']->template->set_var('tr_color',$tr_color); 124 $GLOBALS['egw']->template->set_var('name',$app['title']); 125 126 $GLOBALS['egw']->template->set_var('edit',$can_edit ? '<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.edit&app_name=' . urlencode($app['name'])) . '&start='.$start.'"> ' . lang('Edit') . ' </a>' : ' '); 127 $GLOBALS['egw']->template->set_var('delete',$can_delete ? '<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.delete&app_name=' . urlencode($app['name'])) . '&start='.$start.'"> ' . lang('Delete') . ' </a>' : ' '); 128 129 if ($app['status']) 130 { 131 $status = lang('Yes'); 132 } 133 else 134 { 135 $status = '<b>' . lang('No') . '</b>'; 136 } 137 $GLOBALS['egw']->template->set_var('status',$status); 138 139 $GLOBALS['egw']->template->parse('rows','row',True); 140 } 141 if ($can_add) 142 { 143 $GLOBALS['egw']->template->parse('addbutton','add'); 144 } 145 else 146 { 147 $GLOBALS['egw']->template->set_var('addbutton',''); 148 } 149 150 $GLOBALS['egw']->template->pparse('out','list'); 151 } 152 153 function display_row($label, $value) 154 { 155 $GLOBALS['egw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color()); 156 $GLOBALS['egw']->template->set_var('label',$label); 157 $GLOBALS['egw']->template->set_var('value',$value); 158 $GLOBALS['egw']->template->parse('rows','row',True); 159 } 160 161 function add() 162 { 163 if ($GLOBALS['egw']->acl->check('applications_access',2,'admin')) 164 { 165 $GLOBALS['egw']->redirect_link('/index.php'); 166 } 167 $start = get_var('start',array('POST','GET')); 168 169 $GLOBALS['egw']->template->set_file(array('application' => 'application_form.tpl')); 170 $GLOBALS['egw']->template->set_block('application','form','form'); 171 $GLOBALS['egw']->template->set_block('application','row','row'); 172 $GLOBALS['egw']->template->set_block('form','delete_button'); 173 $GLOBALS['egw']->template->set_var('delete_button',''); 174 175 if ($_POST['cancel']) 176 { 177 $GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start); 178 } 179 180 if ($_POST['save']) 181 { 182 $totalerrors = 0; 183 184 $app_order = $_POST['app_order'] ? $_POST['app_order'] : 0; 185 $n_app_name = chop($_POST['n_app_name']); 186 $n_app_status = $_POST['n_app_status']; 187 188 if ($this->bo->exists($n_app_name)) 189 { 190 $error[$totalerrors++] = lang('That application name already exists.'); 191 } 192 if (preg_match("/\D/",$app_order)) 193 { 194 $error[$totalerrors++] = lang('That application order must be a number.'); 195 } 196 if (!$n_app_name) 197 { 198 $error[$totalerrors++] = lang('You must enter an application name.'); 199 } 200 201 if (!$totalerrors) 202 { 203 $this->bo->add(array( 204 'n_app_name' => $n_app_name, 205 'n_app_status' => $n_app_status, 206 'app_order' => $app_order 207 )); 208 209 $GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start); 210 $GLOBALS['egw']->common->egw_exit(); 211 } 212 else 213 { 214 $GLOBALS['egw']->template->set_var('error','<p><center>' . $GLOBALS['egw']->common->error_list($error) . '</center><br>'); 215 } 216 } 217 else 218 { // else submit 219 $GLOBALS['egw']->template->set_var('error',''); 220 } 221 222 $GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Add new application'); 223 if(!@is_object($GLOBALS['egw']->js)) 224 { 225 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 226 } 227 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 228 $GLOBALS['egw']->common->egw_header(); 229 echo parse_navbar(); 230 231 $GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']); 232 233 $GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="start" value="'.$start.'">'); 234 $GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.add')); 235 236 $this->display_row(lang('application name'),'<input name="n_app_name" value="' . $n_app_name . '">'); 237 238 if(!isset($n_app_status)) 239 { 240 $n_app_status = 1; 241 } 242 243 $selected[$n_app_status] = ' selected'; 244 $status_html = '<option value="0"' . $selected[0] . '>' . lang('Disabled') . '</option>' 245 . '<option value="1"' . $selected[1] . '>' . lang('Enabled') . '</option>' 246 . '<option value="2"' . $selected[2] . '>' . lang('Enabled - Hidden from navbar') . '</option>' 247 . '<option value="4"' . $selected[4] . '>' . lang('Enabled - Popup Window') . '</option>'; 248 $this->display_row(lang('Status'),'<select name="n_app_status">' . $status_html . '</select>'); 249 250 if (!$app_order) 251 { 252 $app_order = $this->bo->app_order(); 253 } 254 255 $this->display_row(lang('Select which location this app should appear on the navbar, lowest (left) to highest (right)'),'<input name="app_order" value="' . $app_order . '">'); 256 257 $GLOBALS['egw']->template->set_var('lang_save_button',lang('Add')); 258 $GLOBALS['egw']->template->set_var('lang_cancel_button',lang('Cancel')); 259 $GLOBALS['egw']->template->pparse('phpgw_body','form'); 260 } 261 262 function edit() 263 { 264 if ($GLOBALS['egw']->acl->check('applications_access',4,'admin')) 265 { 266 $GLOBALS['egw']->redirect_link('/index.php'); 267 } 268 $app_name = get_var('app_name',array('POST','GET')); 269 $start = get_var('start',array('POST','GET')); 270 271 $GLOBALS['egw']->template->set_file(array('application' => 'application_form.tpl')); 272 $GLOBALS['egw']->template->set_block('application','form','form'); 273 $GLOBALS['egw']->template->set_block('application','row','row'); 274 275 if ($_POST['cancel']) 276 { 277 $GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start); 278 } 279 280 if ($_POST['delete']) 281 { 282 return $this->delete(); 283 } 284 285 if ($_POST['save']) 286 { 287 $totalerrors = 0; 288 289 $app_order = $_POST['app_order'] ? $_POST['app_order'] : 0; 290 $n_app_status = $_POST['n_app_status']; 291 292 if (! $totalerrors) 293 { 294 $this->bo->save(array( 295 'n_app_status' => $n_app_status, 296 'app_order' => $app_order, 297 'app_name' => urldecode($app_name) 298 )); 299 300 $GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start); 301 } 302 } 303 304 $GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit application'); 305 if(!@is_object($GLOBALS['egw']->js)) 306 { 307 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 308 } 309 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 310 $GLOBALS['egw']->common->egw_header(); 311 echo parse_navbar(); 312 313 if ($totalerrors) 314 { 315 $GLOBALS['egw']->template->set_var('error','<p><center>' . $GLOBALS['egw']->common->error_list($error) . '</center><br>'); 316 } 317 else 318 { 319 $GLOBALS['egw']->template->set_var('error',''); 320 list($n_app_name,$n_app_title,$n_app_status,$old_app_name,$app_order) = $this->bo->read($app_name); 321 } 322 $GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="start" value="'.$start.'">'. 323 '<input type="hidden" name="app_name" value="' . $app_name . '">'); 324 $GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']); 325 $GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.edit')); 326 327 $this->display_row(lang('application name'), $n_app_name ); 328 329 $GLOBALS['egw']->template->set_var('lang_status',lang('Status')); 330 $GLOBALS['egw']->template->set_var('lang_save_button',lang('Save')); 331 $GLOBALS['egw']->template->set_var('lang_cancel_button',lang('Cancel')); 332 $GLOBALS['egw']->template->set_var('lang_delete_button',lang('Delete')); 333 334 $selected[$n_app_status] = ' selected'; 335 $status_html = '<option value="0"' . $selected[0] . '>' . lang('Disabled') . '</option>' 336 . '<option value="1"' . $selected[1] . '>' . lang('Enabled') . '</option>' 337 . '<option value="2"' . $selected[2] . '>' . lang('Enabled - Hidden from navbar') . '</option>' 338 . '<option value="4"' . $selected[4] . '>' . lang('Enabled - Popup Window') . '</option>'; 339 340 $this->display_row(lang("Status"),'<select name="n_app_status">' . $status_html . '</select>'); 341 $this->display_row(lang("Select which location this app should appear on the navbar, lowest (left) to highest (right)"),'<input name="app_order" value="' . $app_order . '">'); 342 343 $GLOBALS['egw']->template->set_var('select_status',$status_html); 344 $GLOBALS['egw']->template->pparse('phpgw_body','form'); 345 } 346 347 function delete() 348 { 349 if ($GLOBALS['egw']->acl->check('applications_access',8,'admin')) 350 { 351 $GLOBALS['egw']->redirect_link('/index.php'); 352 } 353 $app_name = get_var('app_name',array('POST','GET')); 354 $start = get_var('start',array('POST','GET')); 355 356 if (!$app_name || $_POST['no'] || $_POST['yes']) 357 { 358 if ($_POST['yes']) 359 { 360 $this->bo->delete($app_name); 361 } 362 $GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start); 363 } 364 365 $GLOBALS['egw']->template->set_file(array('body' => 'delete_common.tpl')); 366 367 if(!@is_object($GLOBALS['egw']->js)) 368 { 369 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 370 } 371 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 372 $GLOBALS['egw']->common->egw_header(); 373 echo parse_navbar(); 374 375 $GLOBALS['egw']->template->set_var('messages',lang('Are you sure you want to delete the application %1 ?',$GLOBALS['egw_info']['apps'][$app_name]['title'])); 376 $GLOBALS['egw']->template->set_var('no',lang('No')); 377 $GLOBALS['egw']->template->set_var('yes',lang('Yes')); 378 $GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.delete')); 379 $GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="start" value="'.$start.'">'. 380 '<input type="hidden" name="app_name" value="'. urlencode($app_name) . '">'); 381 $GLOBALS['egw']->template->pparse('phpgw_body','body'); 382 } 383 384 function register_all_hooks() 385 { 386 if ($GLOBALS['egw']->acl->check('applications_access',16,'admin')) 387 { 388 $GLOBALS['egw']->redirect_link('/index.php'); 389 } 390 if (!is_object($GLOBALS['egw']->hooks)) 391 { 392 $GLOBALS['egw']->hooks =& CreateObject('phpgwapi.hooks'); 393 } 394 $GLOBALS['egw']->hooks->register_all_hooks(); 395 396 if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited 397 { 398 $GLOBALS['egw']->invalidate_session_cache(); // in case with cache the egw_info array in the session 399 } 400 $GLOBALS['egw']->redirect_link('/admin/index.php'); 401 } 402 } 403 ?>
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 |