[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - ProjectManager: Admin-, Preferences- and SideboxMenu-Hooks * 4 * http://www.eGroupWare.org * 5 * Written and (c) 2005 by Ralf Becker <RalfBecker@outdoor-training.de> * 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.pm_admin_prefs_sidebox_hooks.inc.php 20971 2006-04-06 08:03:01Z ralfbecker $ */ 14 15 class pm_admin_prefs_sidebox_hooks 16 { 17 var $public_functions = array( 18 // 'check_set_default_prefs' => true, 19 ); 20 var $weekdays = array( 21 1 => 'monday', 22 2 => 'tuesday', 23 3 => 'wednesday', 24 4 => 'thursday', 25 5 => 'friday', 26 6 => 'saturday', 27 0 => 'sunday', 28 ); 29 var $config = array(); 30 31 function pm_admin_prefs_sidebox_hooks() 32 { 33 $config =& CreateObject('phpgwapi.config','projectmanager'); 34 $config->read_repository(); 35 $this->config =& $config->config_data; 36 unset($config); 37 } 38 39 /** 40 * hooks to build projectmanager's sidebox-menu plus the admin and preferences sections 41 * 42 * @param string/array $args hook args 43 */ 44 function all_hooks($args) 45 { 46 $appname = 'projectmanager'; 47 $location = is_array($args) ? $args['location'] : $args; 48 //echo "<p>ranking_admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n"; 49 50 if ($location == 'sidebox_menu') 51 { 52 // project-dropdown in sidebox menu 53 if (!is_object($GLOBALS['egw']->html)) 54 { 55 $GLOBALS['egw']->html =& CreateObject('phpgwapi.html'); 56 } 57 if (!is_object($GLOBALS['boprojectmanager'])) 58 { 59 // dont assign it to $GLOBALS['boprojectmanager'], as the constructor does it!!! 60 CreateObject('projectmanager.uiprojectmanager'); 61 } 62 if (isset($_REQUEST['pm_id'])) 63 { 64 $GLOBALS['egw']->session->appsession('pm_id','projectmanager',$pm_id = (int) $_REQUEST['pm_id']); 65 } 66 else 67 { 68 $pm_id = (int) $GLOBALS['egw']->session->appsession('pm_id','projectmanager'); 69 } 70 // include the filter of the projectlist into the tree, eg. if you watch the list of templates, include them in the tree 71 $filter = array('pm_status' => 'active'); 72 $list_filter = $GLOBALS['egw']->session->appsession('project_list','projectmanager'); 73 if ($_GET['menuaction'] == 'projectmanager.uiprojectmanager.index' && isset($_POST['exec']['nm']['filter2'])) 74 { 75 //echo "<p align=right>set pm_status={$_POST['exec']['nm']['filter2']}</p>\n"; 76 $list_filter['pm_status'] = $_POST['exec']['nm']['filter2']; // necessary as uiprojectmanager::get_rows is not yet executed 77 } 78 if(in_array($list_filter['filter2'],array('nonactive','archive','template'))) 79 { 80 $filter['pm_status'] = array('active',$list_filter['filter2']); 81 } 82 $selected_project = false; 83 $projects = array(); 84 foreach($GLOBALS['boprojectmanager']->get_project_tree($filter) as $project) 85 { 86 $projects[$project['path']] = array( 87 'label' => $project['pm_number'], 88 'title' => $project['pm_title'], 89 ); 90 if (!$selected_project && $pm_id == $project['pm_id']) $selected_project = $project['path']; 91 } 92 if ($_GET['menuaction'] == 'projectmanager.uipricelist.index') 93 { 94 $projects['general'] = array( 95 'label' => lang('General pricelist'), 96 'image' => 'kfm_home.png', 97 ); 98 if (!$pm_id) $selected_project = 'general'; 99 } 100 switch($_GET['menuaction']) 101 { 102 case 'projectmanager.ganttchart.show': 103 case 'projectmanager.uipricelist.index': 104 $selbox_action = $_GET['menuaction']; 105 break; 106 default: 107 $selbox_action = 'projectmanager.uiprojectelements.index'; 108 break; 109 } 110 $select_link = $GLOBALS['egw']->link('/index.php',array('menuaction' => $selbox_action)).'&pm_id='; 111 112 $file = array( 113 'Projectlist' => $GLOBALS['egw']->link('/index.php',array( 114 'menuaction' => 'projectmanager.uiprojectmanager.index' )), 115 array( 116 'text' => 'Elementlist', 117 'link' => $pm_id ? $GLOBALS['egw']->link('/index.php',array( 118 'menuaction' => 'projectmanager.uiprojectelements.index', 119 )) : False, 120 ), 121 array( 122 'text' => 'Ganttchart', 123 'link' => $pm_id ? $GLOBALS['egw']->link('/index.php',array( 124 'menuaction' => 'projectmanager.ganttchart.show', 125 )) : False, 126 ), 127 ); 128 // show pricelist menuitem only if we use pricelists 129 if (!$this->config['accounting_types'] || in_array('pricelist',explode(',',$this->config['accounting_types']))) 130 { 131 // menuitem links to project-spezific priclist only if user has rights and it is used 132 // to not always instanciate the priclist class, this code dublicats bopricelist::check_acl(EGW_ACL_READ), 133 // specialy the always existing READ right for the general pricelist!!! 134 $file['Pricelist'] = $GLOBALS['egw']->link('/index.php',array( 135 'menuaction' => 'projectmanager.uipricelist.index', 136 'pm_id' => $pm_id && $GLOBALS['boprojectmanager']->check_acl(EGW_ACL_BUDGET,$pm_id) && 137 $GLOBALS['boprojectmanager']->data['pm_accounting_type'] == 'pricelist' ? $pm_id : 0, 138 )); 139 } 140 if ($projects) // show project-tree only if it's not empty 141 { 142 $file[] = array( 143 'text' => "<script>function load_project(_nodeId) { location.href='$select_link'+_nodeId.substr(_nodeId.lastIndexOf('/')+1,99); }</script>\n". 144 $GLOBALS['egw']->html->tree($projects,$selected_project,false,'load_project'), 145 'no_lang' => True, 146 'link' => False, 147 'icon' => False, 148 ); 149 } 150 display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file); 151 } 152 153 if ($GLOBALS['egw_info']['user']['apps']['preferences'] && $location != 'admin') 154 { 155 $file = array( 156 'Preferences' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname='.$appname), 157 'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), 158 'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') 159 ); 160 if (!$this->config['allow_change_workingtimes'] && !$GLOBALS['egw_info']['user']['apps']['admin']) 161 { 162 unset($file['Preferences']); // atm. prefs are only working times 163 } 164 if ($location == 'preferences') 165 { 166 display_section($appname,$file); 167 } 168 else 169 { 170 display_sidebox($appname,lang('Preferences'),$file); 171 } 172 } 173 174 if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences') 175 { 176 $file = Array( 177 'Site configuration' => $GLOBALS['egw']->link('/index.php','menuaction=projectmanager.admin.config'), 178 'Custom fields' => $GLOBALS['egw']->link('/index.php','menuaction=admin.customfields.edit&appname=projectmanager'), 179 'Global Categories' => $GLOBALS['egw']->link('/index.php',array( 180 'menuaction' => 'admin.uicategories.index', 181 'appname' => $appname, 182 'global_cats'=> True)), 183 ); 184 if ($location == 'admin') 185 { 186 display_section($appname,$file); 187 } 188 else 189 { 190 display_sidebox($appname,lang('Admin'),$file); 191 } 192 } 193 } 194 195 /** 196 * populates $GLOBALS['settings'] for the preferences 197 */ 198 function settings() 199 { 200 $this->check_set_default_prefs(); 201 202 $start = array(); 203 for($i = 0; $i < 24*60; $i += 30) 204 { 205 if ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12) 206 { 207 if (!($hour = ($i / 60) % 12)) 208 { 209 $hour = 12; 210 } 211 $start[$i] = sprintf('%01d:%02d %s',$hour,$i % 60,$i < 12*60 ? 'am' : 'pm'); 212 } 213 else 214 { 215 $start[$i] = sprintf('%01d:%02d',$i/60,$i % 60); 216 } 217 } 218 $duration = array(0 => lang('not working')); 219 for($i = 30; $i <= 24*60; $i += 30) 220 { 221 $duration[$i] = sprintf('%3.1lf',$i / 60.0).' '.lang('hours'); 222 } 223 foreach($this->weekdays as $day => $label) 224 { 225 $GLOBALS['settings']['duration_'.$day] = array( 226 'type' => 'select', 227 'label' => lang('Working duration on %1',lang($label)), 228 'run_lang' => -1, 229 'name' => 'duration_'.$day, 230 'values' => $duration, 231 'help' => 'How long do you work on the given day.', 232 'xmlrpc' => True, 233 'admin' => !$this->config['allow_change_workingtimes'], 234 ); 235 $GLOBALS['settings']['start_'.$day] = array( 236 'type' => 'select', 237 'label' => lang('Start working on %1',lang($label)), 238 'run_lang' => -1, 239 'name' => 'start_'.$day, 240 'values' => $start, 241 'help' => 'At which time do you start working on the given day.', 242 'xmlrpc' => True, 243 'admin' => !$this->config['allow_change_workingtimes'], 244 ); 245 } 246 $GLOBALS['settings']['show_custom_app_icons'] = array( 247 'type' => 'check', 248 'label' => 'Show status icons of the datasources', 249 'name' => 'show_custom_app_icons', 250 'help' => 'Should Projectmanager display the status icons of the datasource (eg. InfoLog) or just a progressbar with the numerical status (faster).', 251 'xmlrpc' => True, 252 'admin' => False, 253 ); 254 return true; // otherwise prefs say it cant find the file ;-) 255 } 256 257 /** 258 * Check if reasonable default preferences are set and set them if not 259 * 260 * It sets a flag in the app-session-data to be called only once per session 261 */ 262 function check_set_default_prefs() 263 { 264 if ($GLOBALS['egw']->session->appsession('default_prefs_set','projectmanager')) 265 { 266 return; 267 } 268 $GLOBALS['egw']->session->appsession('default_prefs_set','projectmanager','set'); 269 270 $default_prefs =& $GLOBALS['egw']->preferences->default['projectmanager']; 271 272 $defaults = array( 273 'start_1' => 9*60, 274 'duration_1' => 8*60, 275 'start_2' => 9*60, 276 'duration_2' => 8*60, 277 'start_3' => 9*60, 278 'duration_3' => 8*60, 279 'start_4' => 9*60, 280 'duration_4' => 8*60, 281 'start_5' => 9*60, 282 'duration_5' => 6*60, 283 'duration_6' => 0, 284 'duration_0' => 0, 285 ); 286 foreach($defaults as $var => $default) 287 { 288 if (!isset($default_prefs[$var]) || $default_prefs[$var] === '') 289 { 290 $GLOBALS['egw']->preferences->add('projectmanager',$var,$default,'default'); 291 $need_save = True; 292 } 293 } 294 if ($need_save) 295 { 296 $GLOBALS['egw']->preferences->save_repository(False,'default'); 297 } 298 } 299 }
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 |