[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Addressbook * 4 * http://www.egroupware.org * 5 * Written by Joseph Engo <jengo@phpgroupware.org> and * 6 * Miles Lott <milosch@groupwhere.org> * 7 * ----------------------------------------------- * 8 * This program is free software; you can redistribute it and/or modify it * 9 * under the terms of the GNU General Public License as published by the * 10 * Free Software Foundation; either version 2 of the License, or (at your * 11 * option) any later version. * 12 \**************************************************************************/ 13 14 /* $Id: class.uifields.inc.php 20295 2006-02-15 12:31:25Z $ */ 15 16 class uifields 17 { 18 var $public_functions = array( 19 'index' => True, 20 'add' => True, 21 'edit' => True, 22 'delete' => True 23 ); 24 var $bo; 25 26 function uifields() 27 { 28 $GLOBALS['egw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 29 $GLOBALS['egw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); 30 $this->bo = CreateObject('addressbook.bofields'); 31 } 32 33 function index() 34 { 35 if(!$GLOBALS['egw']->acl->check('run',1,'admin')) 36 { 37 $GLOBALS['egw']->common->phpgw_header(); 38 echo parse_navbar(); 39 echo lang('access not permitted'); 40 $GLOBALS['egw']->common->phpgw_exit(); 41 } 42 43 $GLOBALS['egw']->template->set_file(array( 44 'field_list_t' => 'listfields.tpl', 45 'field_list' => 'listfields.tpl' 46 )); 47 $GLOBALS['egw']->template->set_block('field_list_t','field_list','list'); 48 49 $field = $_POST['field']; 50 $start = $_POST['start'] ? $_POST['start'] : $_GET['start']; 51 $query = $_POST['query'] ? $_POST['query'] : $_GET['query']; 52 $sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort']; 53 54 $common_hidden_vars = 55 '<input type="hidden" name="sort" value="' . $sort . '">' . "\n" 56 . '<input type="hidden" name="order" value="' . $order . '">' . "\n" 57 . '<input type="hidden" name="query" value="' . $query . '">' . "\n" 58 . '<input type="hidden" name="start" value="' . $start . '">' . "\n" 59 . '<input type="hidden" name="filter" value="' . $filter . '">' . "\n"; 60 61 $GLOBALS['egw']->template->set_var('lang_action',lang('Custom Fields')); 62 $GLOBALS['egw']->template->set_var('add_action',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add')); 63 $GLOBALS['egw']->template->set_var('lang_add',lang('Add')); 64 $GLOBALS['egw']->template->set_var('title_fields',lang('addressbook').' - '.lang('Custom Fields')); 65 $GLOBALS['egw']->template->set_var('lang_search',lang('Search')); 66 $GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index')); 67 $GLOBALS['egw']->template->set_var('lang_done',lang('Done')); 68 $GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/admin/index.php')); 69 70 if(!$start) 71 { 72 $start = 0; 73 } 74 75 if(!$sort) 76 { 77 $sort = 'ASC'; 78 } 79 80 $fields = $this->bo->_read($start,$limit,$query,$sort); 81 $total_records = count($fields); 82 83 $GLOBALS['egw']->common->phpgw_header(); 84 echo parse_navbar(); 85 86 $GLOBALS['egw']->template->set_var('left',$GLOBALS['egw']->nextmatchs->left('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index')); 87 $GLOBALS['egw']->template->set_var('right',$GLOBALS['egw']->nextmatchs->right('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index')); 88 89 $GLOBALS['egw']->template->set_var('lang_showing',$GLOBALS['egw']->nextmatchs->show_hits($total_records,$start)); 90 91 $GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']); 92 $GLOBALS['egw']->template->set_var('sort_field',$GLOBALS['egw']->nextmatchs->show_sort_order($sort,'name',$order,'/index.php',lang('Name')),'menuaction=addressbook.uifields.index'); 93 $GLOBALS['egw']->template->set_var('lang_edit',lang('Edit')); 94 $GLOBALS['egw']->template->set_var('lang_delete',lang('Delete')); 95 96 for($i=0;$i<count($fields);$i++) 97 { 98 $tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color); 99 $GLOBALS['egw']->template->set_var(tr_color,$tr_color); 100 101 $field = $fields[$i]['name']; 102 $title = $fields[$i]['title']; 103 104 $GLOBALS['egw']->template->set_var('cfield',$title); 105 106 $params = array( 107 'menuaction' => 'addressbook.uifields.edit', 108 'field' => urlencode($field), 109 'start' => $start, 110 'query' => $query, 111 'sort' => $sort, 112 'order' => $order, 113 'filter' => $filter 114 ); 115 $GLOBALS['egw']->template->set_var('edit',$GLOBALS['egw']->link('/index.php',$params)); 116 $GLOBALS['egw']->template->set_var('lang_edit_entry',lang('Edit')); 117 118 $params['menuaction'] = 'addressbook.uifields.delete'; 119 $GLOBALS['egw']->template->set_var('delete',$GLOBALS['egw']->link('/index.php',$params)); 120 $GLOBALS['egw']->template->set_var('lang_delete_entry',lang('Delete')); 121 $GLOBALS['egw']->template->parse('list','field_list',True); 122 } 123 124 $GLOBALS['egw']->template->parse('out','field_list_t',True); 125 $GLOBALS['egw']->template->p('out'); 126 } 127 128 function add() 129 { 130 if(!$GLOBALS['egw']->acl->check('run',1,'admin')) 131 { 132 $GLOBALS['egw']->common->phpgw_header(); 133 echo parse_navbar(); 134 echo lang('access not permitted'); 135 $GLOBALS['egw']->common->phpgw_exit(); 136 } 137 138 $field = stripslashes($_POST['field']); 139 $field_name = stripslashes($_POST['field_name']); 140 $start = $_POST['start']; 141 $query = $_POST['query']; 142 $sort = $_POST['sort']; 143 $submit = $_POST['submit']; 144 145 $GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl')); 146 $GLOBALS['egw']->template->set_block('form','add','addhandle'); 147 $GLOBALS['egw']->template->set_block('form','edit','edithandle'); 148 149 if($submit) 150 { 151 $errorcount = 0; 152 153 if(!$field_name) 154 { 155 $error[$errorcount++] = lang('Please enter a name for that field !'); 156 } 157 158 $fields = $this->bo->_read($start,$limit,$field_name); 159 if($fields[0]['name']) 160 { 161 $error[$errorcount++] = lang('That field name has been used already !'); 162 } 163 164 if(!$error) 165 { 166 $this->bo->_save($field,$field_name); 167 } 168 } 169 170 $GLOBALS['egw']->common->phpgw_header(); 171 echo parse_navbar(); 172 173 if($errorcount) 174 { 175 $GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error)); 176 } 177 if(($submit) && (!$error) && (!$errorcount)) 178 { 179 $GLOBALS['egw']->template->set_var('message',lang('Field %1 has been added !', $field_name)); 180 } 181 if((!$submit) && (!$error) && (!$errorcount)) 182 { 183 $GLOBALS['egw']->template->set_var('message',''); 184 } 185 186 $GLOBALS['egw']->template->set_var('title_fields',lang('Add Custom Field')); 187 $GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add')); 188 $GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index')); 189 $GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="field" value="' . $field . '">'); 190 191 $GLOBALS['egw']->template->set_var('lang_name',lang('Field name')); 192 193 $GLOBALS['egw']->template->set_var('lang_add',lang('Add')); 194 $GLOBALS['egw']->template->set_var('lang_reset',lang('Clear Form')); 195 $GLOBALS['egw']->template->set_var('lang_done',lang('Done')); 196 197 $GLOBALS['egw']->template->set_var('field_name',$field_name); 198 199 $GLOBALS['egw']->template->set_var('edithandle',''); 200 $GLOBALS['egw']->template->set_var('addhandle',''); 201 $GLOBALS['egw']->template->pparse('out','form'); 202 $GLOBALS['egw']->template->pparse('addhandle','add'); 203 } 204 205 function edit() 206 { 207 if(!$GLOBALS['egw']->acl->check('run',1,'admin')) 208 { 209 $GLOBALS['egw']->common->phpgw_header(); 210 echo parse_navbar(); 211 echo lang('access not permitted'); 212 $GLOBALS['egw']->common->phpgw_exit(); 213 } 214 215 $field = stripslashes($_POST['field'] ? $_POST['field'] : $_GET['field']); 216 $field_name = stripslashes($_POST['field_name']); 217 $start = $_POST['start'] ? $_POST['start'] : $_GET['start']; 218 $query = $_POST['query'] ? $_POST['query'] : $_GET['query']; 219 $sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort']; 220 $submit = $_POST['submit']; 221 222 if(!$field) 223 { 224 Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start")); 225 } 226 227 $GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl')); 228 $GLOBALS['egw']->template->set_block('form','add','addhandle'); 229 $GLOBALS['egw']->template->set_block('form','edit','edithandle'); 230 231 $hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n" 232 . '<input type="hidden" name="query" value="' . $query . '">' . "\n" 233 . '<input type="hidden" name="start" value="' . $start . '">' . "\n" 234 . '<input type="hidden" name="field" value="' . $field . '">' . "\n"; 235 236 if($submit) 237 { 238 $errorcount = 0; 239 if(!$field_name) 240 { 241 $error[$errorcount++] = lang('Please enter a name for that field !'); 242 } 243 244 if(!$error) 245 { 246 $this->bo->_save($field,$field_name); 247 } 248 } 249 250 $GLOBALS['egw']->common->phpgw_header(); 251 echo parse_navbar(); 252 253 if($errorcount) 254 { 255 $GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error)); 256 } 257 if(($submit) && (!$error) && (!$errorcount)) 258 { 259 $GLOBALS['egw']->template->set_var('message',lang('Field %1 has been updated !', $field_name)); 260 } 261 if((!$submit) && (!$error) && (!$errorcount)) 262 { 263 $GLOBALS['egw']->template->set_var('message',''); 264 } 265 266 if($submit) 267 { 268 $field = $field_name; 269 } 270 else 271 { 272 $fields = $this->bo->_read($start,$limit,$field); 273 $field = $GLOBALS['egw']->strip_html($fields[0]['title']); 274 $fn = $fields[0]['name']; 275 } 276 277 $GLOBALS['egw']->template->set_var('title_fields',lang('Edit Custom Field')); 278 $GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.edit')); 279 $GLOBALS['egw']->template->set_var('deleteurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.delete&field=$fn&start=$start&query=$query&sort=$sort")); 280 $GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort")); 281 282 $GLOBALS['egw']->template->set_var('hidden_vars',$hidden_vars); 283 $GLOBALS['egw']->template->set_var('lang_name',lang('Field name')); 284 285 $GLOBALS['egw']->template->set_var('lang_done',lang('Done')); 286 $GLOBALS['egw']->template->set_var('lang_edit',lang('Edit')); 287 $GLOBALS['egw']->template->set_var('lang_delete',lang('Delete')); 288 289 $GLOBALS['egw']->template->set_var('field_name',$field); 290 291 $GLOBALS['egw']->template->set_var('edithandle',''); 292 $GLOBALS['egw']->template->set_var('addhandle',''); 293 294 $GLOBALS['egw']->template->pparse('out','form'); 295 $GLOBALS['egw']->template->pparse('edithandle','edit'); 296 } 297 298 function delete() 299 { 300 if(!$GLOBALS['egw']->acl->check('run',1,'admin')) 301 { 302 $GLOBALS['egw']->common->phpgw_header(); 303 echo parse_navbar(); 304 echo lang('access not permitted'); 305 $GLOBALS['egw']->common->phpgw_exit(); 306 } 307 308 $field = urldecode($_POST['field'] ? $_POST['field'] : $_GET['field']); 309 $field_id = $_POST['field_id'] ? $_POST['field_id'] : $_GET['field_id']; 310 $start = $_POST['start'] ? $_POST['start'] : $_GET['start']; 311 $query = $_POST['query'] ? $_POST['query'] : $_GET['query']; 312 $sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort']; 313 314 if(!$field) 315 { 316 Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index')); 317 } 318 319 if($_POST['confirm']) 320 { 321 $this->bo->_save($field); 322 Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort")); 323 } 324 else 325 { 326 $GLOBALS['egw']->common->phpgw_header(); 327 echo parse_navbar(); 328 329 $hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n" 330 . '<input type="hidden" name="order" value="' . $order .'">' . "\n" 331 . '<input type="hidden" name="query" value="' . $query .'">' . "\n" 332 . '<input type="hidden" name="start" value="' . $start .'">' . "\n" 333 . '<input type="hidden" name="field" value="' . $field .'">' . "\n"; 334 335 $GLOBALS['egw']->template->set_file(array('field_delete' => 'delete_common.tpl')); 336 $GLOBALS['egw']->template->set_var('messages',lang('Are you sure you want to delete this field?')); 337 338 $nolinkf = $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&field_id=$field_id&start=$start&query=$query&sort=$sort"); 339 $nolink = '<a href="' . $nolinkf . '">' . lang('No') . '</a>'; 340 $GLOBALS['egw']->template->set_var('no',$nolink); 341 342 $yeslinkf = $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifieldsdelete&field_id=' . $field_id . '&confirm=True'); 343 $yeslinkf = '<form method="POST" name="yesbutton" action="' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.delete') . '">' 344 . $hidden_vars 345 . '<input type="hidden" name="field_id" value="' . $field_id . '">' 346 . '<input type="hidden" name="confirm" value="True">' 347 . '<input type="submit" name="yesbutton" value="Yes">' 348 . '</form><script>document.yesbutton.yesbutton.focus()</script>'; 349 350 $yeslink = '<a href="' . $yeslinkf . '">' . lang('Yes') . '</a>'; 351 $yeslink = $yeslinkf; 352 $GLOBALS['egw']->template->set_var('yes',$yeslink); 353 354 $GLOBALS['egw']->template->pparse('out','field_delete'); 355 } 356 } 357 } 358 ?>
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 |