Changeset 577
- Timestamp:
- 01/07/09 17:14:51 (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/inc/class.bocategories.inc.php
r2 r577 96 96 } 97 97 98 function get_list( )98 function get_list($id_group) 99 99 { 100 if($this->debug) { echo '<br>querying: "' . $this->query . '"'; } 101 return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,True );100 if($this->debug) { echo '<br>querying: "' . $this->query . '"'; } 101 return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,True,'',$id_group); 102 102 } 103 103 -
trunk/admin/inc/class.uicategories.inc.php
r2 r577 69 69 70 70 $dir = dir(PHPGW_SERVER_ROOT.'/phpgwapi/images'); 71 71 72 while($file = $dir->read()) 72 73 { … … 115 116 $this->template->set_var('lang_save',lang('Save')); 116 117 $this->template->set_var('lang_search',lang('Search')); 118 $this->template->set_var('lang_group_name',lang('group name')); 119 $this->template->set_var('lang_cat_name',lang('category name')); 117 120 $this->template->set_var('lang_sub',lang('Add sub')); 118 121 $this->template->set_var('lang_icon',lang('icon')); … … 129 132 $this->template->set_var('lang_color',lang('Color')); 130 133 $this->template->set_var('lang_icon',lang('Icon')); 134 $this->template->set_var('lang_Loading',lang("Loading")); 135 $this->template->set_var('lang_Searching', lang("search groups")); 136 $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X")); 137 $this->template->set_var('lang_Search_for', lang("Search Groups")); 138 $this->template->set_var('lang_cat_all', lang("All")); 139 $this->template->set_var('lang_permission', lang("Permission")); 140 $this->template->set_var('lang_Loading',lang("Loading")); 141 $this->template->set_var('lang_Searching', lang("Search Groups")); 142 $this->template->set_var('lang_Owner', lang("Owner (User/Group)")); 143 $this->template->set_var('lang_Add', lang("Add")); 144 $this->template->set_var('lang_Remove', lang("Remove")); 145 $this->template->set_var('lang_Search_for', lang("Search Groups")); 146 $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X")); 131 147 } 132 148 … … 148 164 $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 149 165 } 150 166 167 151 168 $this->template->set_file(array('cat_list_t' => 'listcats.tpl')); 152 169 $this->template->set_block('cat_list_t','cat_list','list'); … … 164 181 echo parse_navbar(); 165 182 $this->set_langs(); 183 166 184 $this->template->set_var('query',$this->query); 185 186 // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. 187 if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { 188 $this->template_dir = 'calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']; 189 $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); 190 if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ 191 $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 192 $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; 193 $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; 194 $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 195 $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 196 // Carrega todos scripts necessarios 197 $scripts = "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 198 "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". 199 "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>"; 200 // Fim 201 } 202 $this->template->set_var('scripts',$scripts); 203 } 204 $this->template->set_var('template_set',$this->template_dir); 167 205 168 206 $link_data['menuaction'] = 'admin.uicategories.index'; … … 173 211 $start = 0; 174 212 } 175 176 $cats = $this->bo->get_list(); 213 list($idgroup,$namegroup) = explode('.', @$_POST['group']); 214 if($this-> query || $namegroup) 215 $result_search = lang("result")." :: ".lang("about")." <b>'".($this-> query ? $this-> query : $namegroup)."'</b> :: "; 216 else 217 $this->template->set_var('type_search_'.($_POST['typesearch'] ? $_POST['typesearch'] : 'a').'_checked', "checked"); 218 $cats = $this->bo->get_list($idgroup); 219 177 220 if (!is_array($cats)) $cats = array(); 178 221 … … 182 225 $this->template->set_var('right',$right); 183 226 184 $this->template->set_var('lang_showing',$ this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start));185 186 $this->template->set_var('sort_name', $this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data));187 $this->template->set_var('sort_description', $this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data));227 $this->template->set_var('lang_showing',$result_search.$this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start)); 228 229 $this->template->set_var('sort_name', !$_POST['typesearch'] ? $this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data) : lang('Name')); 230 $this->template->set_var('sort_description', !$_POST['typesearch'] ? $this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data) : lang('Description')); 188 231 189 232 foreach($cats as $cat) … … 268 311 } 269 312 else 270 { 313 { 271 314 $this->template->set_var('edit',''); 272 315 } … … 283 326 284 327 $data = unserialize($cat['data']); 285 $icon = $data['icon']; 328 $icon = $data['icon']; 329 $permission = ($cat['owner'] == '-1' ? lang("all"): $cat['owner']); 330 $this->template->set_var('permission', $permission); 286 331 $dir_img = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'phpgwapi' . SEP . 'images' . SEP; 287 $this->template->set_var('icon', "<img src='". $dir_img . $icon ."'>");332 $this->template->set_var('icon', !$icon ? lang("None") : "<img src='". $dir_img . $icon ."'>"); 288 333 289 334 $this->template->fp('list','cat_list',True); … … 303 348 $cat_parent = (int)$_POST['cat_parent']; 304 349 $cat_name = $_POST['cat_name']; 305 $cat_description = $_POST['cat_description'];350 $cat_description = $_POST['cat_description']; 306 351 $cat_data = $_POST['cat_data']; 307 352 $old_parent = (int)$_POST['old_parent']; 353 $cat_group = $_POST['idgroup']; 308 354 309 355 if ($new_parent) … … 328 374 } 329 375 376 330 377 if ($_POST['save']) 331 378 { … … 337 384 'descr' => $cat_description, 338 385 'name' => $cat_name, 386 'group' => $cat_group, 339 387 'access' => 'public', 340 388 'data' => $data … … 360 408 361 409 $this->set_langs(); 410 // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. 411 if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { 412 $this->template_dir = 'calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']; 413 $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); 414 if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ 415 $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 416 $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; 417 $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; 418 $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 419 $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 420 // Carrega todos scripts necessarios 421 $scripts = "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 422 "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". 423 "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>"; 424 // Fim 425 $this->template->set_var('scripts',$scripts); 426 $this->template->set_var('template_set', $this->template_dir); 427 } 428 } 429 // FIM if. 362 430 363 431 $this->template->set_file(array('form' => 'category_form.tpl')); … … 368 436 $cat['data'] = unserialize($cat['data']); 369 437 } 438 370 439 else 371 440 { … … 373 442 $cat['parent'] = $_GET['cat_parent']; 374 443 } 444 375 445 // update the old calendar color format, color was added to the description 376 446 if (preg_match('/(#[0-9a-fA-F]{6})\n?$/',$cat['description'],$matches)) … … 381 451 382 452 $hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\n" . 383 '<input type="hidden" name="old_parent" value="' . $cat['parent'] . '">' . "\n"; 453 '<input type="hidden" name="old_parent" value="' . $cat['parent'] . '">' . "\n". 454 '<input type="hidden" id="idgroup" name="idgroup" value="' . $cat['id_group'] . '">' . "\n"; 384 455 385 456 $link_data['menuaction'] = 'admin.uicategories.edit'; … … 401 472 $this->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cat['description'])); 402 473 $this->template->set_var('category_list',$this->bo->cats->formatted_list(array('selected' => $cat['parent'],'self' => $this->cat_id))); 403 474 $this->template->set_var('category_namegroup',$GLOBALS['phpgw']->strip_html($cat['name_group'])); 475 $this->template->set_var('bt_rem_id_group_visibility',$cat['name_group'] ? "visible" : "hidden"); 404 476 if (!is_object($GLOBALS['phpgw']->html)) 405 477 { … … 407 479 } 408 480 $this->template->set_var('color',$GLOBALS['phpgw']->html->inputColor('cat_data[color]',$cat['data']['color'],lang('Click to select a color'))); 409 410 $options = '<option value=""'.(!$cat['data']['icon'] ? ' selected="1"':'').'>'.lang('none')."</options>\n";481 $options = ''; 482 //$options = '<option value="aanone.gif"'.(!$cat['data']['icon'] ? ' selected="1"':'').'>'.lang('none')."</options>\n"; 411 483 foreach ($this->icons as $icon) 412 484 { 485 if(!$cat['data']['icon']){ 486 $cat['data']['icon'] = "aanone.gif"; 487 } 413 488 $options .= '<option value="'.$icon.'"'.($icon == $cat['data']['icon'] ? ' selected="1"':'').'>'. 414 ucfirst(preg_replace('/\\.(png|gif|jpe?g)$/i','',$icon ))."</option>\n";489 ucfirst(preg_replace('/\\.(png|gif|jpe?g)$/i','',$icon == 'aanone.gif' ? lang('none') : $icon))."</option>\n"; 415 490 } 416 491 $this->template->set_var('select_icon', '<select name="cat_data[icon]" onchange="document.images[\'icon\'].src=\''.$this->img_url.'\' + this.value;">'.$options."</select>\n"); 417 $this->template->set_var('icon', '<img id="icon" src="'. $this->img_url.$cat['data']['icon'] .'">');492 $this->template->set_var('icon', '<img id="icon" src="'. $this->img_url.$cat['data']['icon'] .'">'); 418 493 419 494 $already_done = array('icon','color'); -
trunk/admin/templates/default/category_form.tpl
r2 r577 1 2 1 <!-- BEGIN form --> 2 <input type="hidden" id="txt_loading" value="{lang_Loading}"> 3 <input type="hidden" id="txt_searching" value="{lang_Searching}"> 4 <input type="hidden" id="txt_multipleGroup" value="{lang_Groups}"> 5 <input type="hidden" id="txt_typemoreletters" value="{lang_typemoreletters}"> 3 6 <br> 4 7 <center> … … 6 9 <table border="0" width="80%" cellspacing="2" cellpadding="2"> 7 10 <form name="edit_cat" action="{actionurl}" method="POST"> 11 {hidden_vars} 8 12 <tr class="th"> 9 13 <td colspan="2">{lang_parent}</td> … … 18 22 <td colspan="2"><textarea name="cat_description" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></td> 19 23 </tr> 24 <tr class="row_on"> 25 <td colspan="2">{lang_Search_for}</td> 26 <td valign="center" colspan="2"><input type="text" id="search_group" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching','groupsfound','g')"/> 27 <font color="red"><span id="cal_span_searching"> </span></font><br/> 28 <select id="groupsfound" style="width: 300px" size="4"></select> 29 <button type="button" onClick="javascript:add('groupsfound','group');"><img src="{template_set}/images/add.png" style="vertical-align: bottom;"/></button></td> 30 </tr> 31 <tr class="row_off"> 32 <td colspan="2">{lang_Owner}</td> 33 <td valign="center" colspan="2"><label id="namegroup" style="font-weight:bold">{category_namegroup}</label> 34 <button valign="top" style="visibility:{bt_rem_id_group_visibility}" id="bt_rem_idgroup" type="button" onClick="javascript:remove('group');"><img src="{template_set}/images/delete.png" style="vertical-align: middle;" /></button></td> 35 </tr> 36 20 37 <tr class="row_on"> 21 38 <td colspan="2">{lang_color}</td> … … 32 49 </tr> 33 50 <!-- END data_row --> 34 35 51 <tr valign="bottom" height="50"> 36 <td> 37 {hidden_vars} 38 <input type="submit" name="save" value="{lang_save}"></form></td> 39 <td> 40 <form method="POST" action="{cancel_url}"> 41 <input type="submit" name="cancel" value="{lang_cancel}"></form></td> 52 <td><input type="submit" name="save" value="{lang_save}"></td> 53 <td><form method="POST" action="{cancel_url}"><input type="submit" name="cancel" value="{lang_cancel}"></form></td> 42 54 <td align="right">{delete}</td> 43 55 </tr> 44 56 </table> 57 </form> 45 58 </center> 46 59 47 60 <!-- END form --> 61 <script language="JavaScript" type="text/javascript"> 62 function remove(to){ 63 document.getElementById("name"+to).innerHTML = ''; 64 document.getElementById("id"+to).value = '-1'; 65 show_button("id"+to); 66 } 67 function show_button(id){ 68 document.getElementById("bt_rem_"+id).style.visibility = 69 (document.getElementById(id).value != '-1' ? 'visible' : 'hidden'); 70 } 71 function add(from, to){ 72 var sel_from = document.getElementById(from); 73 for (i = 0 ; i < sel_from.length; i++){ 74 if (sel_from[i].selected) { 75 var name = document.getElementById("name"+to); 76 var id = document.getElementById("id"+to); 77 name.innerHTML = sel_from.options[i].text; 78 id.value = sel_from[i].value; 79 show_button("id"+to); 80 break; 81 } 82 } 83 } 84 </script> 85 {scripts} -
trunk/admin/templates/default/listcats.tpl
r2 r577 1 2 1 <center> 3 <table border="0" cellspacing="2" cellpadding="2"> 2 <table border="0" cellspacing="1" cellpadding="2"> 3 <!-- BEGIN search --> 4 4 <tr> 5 <td colspan="5" align="left"> 5 <td colspan="5" align="left" valign="top"><form name="form1" method="post" onSubmit="return on_submit()" action="{action_nurl}"> 6 <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="g" {type_search_g_checked}/>{lang_group_name} 7 <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="c" {type_search_c_checked}/>{lang_cat_name} 8 <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="a" {type_search_a_checked}/>{lang_cat_all}<br> 9 <div id="filterByGroup" style="display:none"><br> 10 {lang_Search_for} <input type="text" id="search_group" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching','groupsfound','g')"/><br> 11 <font color="red"><span id="cal_span_searching"> </span></font><br/> 12 <input type="hidden" id="group" name="group"/> 13 <select id="groupsfound" style="width: 300px" size="4"></select> <input type="submit" value="{lang_search}"> 14 </div> 15 <div id="filterByName" style="display:none"><br> 16 <input id="query" type="text" name="query" value=""> <input type="submit" value="{lang_search}"> 17 </form> 18 </td> 19 </tr> 20 <!-- END search --> 21 22 <tr> 23 <td colspan="6" align="left"> 6 24 <table border="0" width="100%"> 7 25 <tr> … … 13 31 </td> 14 32 </tr> 15 <!-- BEGIN search -->16 <tr>17 <td colspan="5" align="right">18 <form method="post" action="{action_nurl}">19 <input type="text" name="query"> <input type="submit" name="search" value="{lang_search}"></form></td>20 </tr>21 <!-- END search -->22 33 <tr class="th"> 23 34 <td width="20%">{sort_name}</td> 24 35 <td width="32%">{sort_description}</td> 25 <td>{lang_icon}</td> 36 <td width="1%" align="center">{lang_icon}</td> 37 <td width="8%" align="center">{lang_permission}</td> 26 38 <td width="8%" align="center">{lang_sub}</td> 27 39 <td width="8%" align="center">{lang_edit}</td> … … 34 46 <td>{name}</td> 35 47 <td>{descr}</td> 36 <td>{icon}</td> 48 <td align="center">{icon}</td> 49 <td align="center">{permission}</td> 37 50 <td align="center">{add_sub}</a></td> 38 51 <td align="center">{edit}</a></td> … … 53 66 </table> 54 67 </center> 68 {scripts} 69 <input type="hidden" id="txt_loading" value="{lang_Loading}"> 70 <input type="hidden" id="txt_searching" value="{lang_Searching}"> 71 <input type="hidden" id="txt_typemoreletters" value="{lang_typemoreletters}"> 72 <script language="JavaScript" type="text/javascript"> 73 function on_submit(){ 74 var select_group = document.getElementById("groupsfound"); 75 if(document.getElementById("query").value == "" && select_group.value == ""){ 76 return false; 77 } 78 else if(select_group.options.length == 0) 79 return true; 80 for(j in select_group.options){ 81 if(select_group.selectedIndex == j) 82 document.getElementById("group").value = select_group.options[j].value+"."+select_group.options[j].text; 83 } 84 return true; 85 } 86 function changeElement(){ 87 var types = document.form1.typesearch; 88 for(j in types){ 89 if(types[j].checked){ 90 if(types[j].value == 'a'){ 91 location.href = location.href.toString(); 92 } 93 document.getElementById('filterByGroup').style.display = (types[j].value == 'g' ? '' : 'none'); 94 document.getElementById('filterByName').style.display = (types[j].value == 'g' || types[j].value == 'a' ? 'none' : ''); 95 } 96 } 97 } 98 </script> -
trunk/phpgwapi/inc/class.categories.inc.php
r2 r577 56 56 $this->app_name = $GLOBALS['phpgw']->db->db_addslashes($app_name); 57 57 $this->db = $GLOBALS['phpgw']->db; 58 $this->db2 = $this->db; 58 $this->db2 = $this->db; 59 59 $this->grants = $GLOBALS['phpgw']->acl->get_grants($app_name); 60 60 } … … 137 137 @param $order order by 138 138 @param $globals True or False, includes the global egroupware categories or not 139 @param $parent_id 140 @param $lastmod integer defaults to -1 141 @param column string default to '' (All), includes the column returned. 139 142 @result $cats array 140 143 */ 141 144 function return_array($type,$start,$limit = True,$query = '',$sort = '',$order = '',$globals = False, $parent_id = '', $lastmod = -1, $column = '') 142 145 { 143 //casting and addslashes for security 144 $start = (int)$start; 145 $parent_id = (int)$parent_id; 146 $query = $this->db->db_addslashes($query); 147 $sort = $this->db->db_addslashes($sort); 148 $order = $this->db->db_addslashes($order); 149 150 if ($globals) 151 { 152 $global_cats = " OR cat_appname='phpgw'"; 153 } 154 155 $filter = $this->filter($type); 156 146 return $this -> return_sorted_array( $start, $limit, $query, $sort, $order, $globals, $parent_id, NULL, $lastmod, $column); 147 } 148 /*! 149 @function return_sorted_array 150 @abstract return an array populated with categories 151 @param $type string defaults to 'all' 152 @param $start ? 153 @param $limit ? 154 @param $query string defaults to '' 155 @param $sort string sort order, either defaults to 'ASC' 156 @param $order order by 157 @param $globals True or False, includes the global egroupware categories or not 158 @param $parent_id string defaults to '', includes the parent category ID 159 @param $group_id integer defaults to NULL, includes the gidNumber 160 @param $lastmod integer defaults to -1 161 @param column string default to '' (All), includes the column returned. 162 @result $cats array 163 */ 164 function return_sorted_array($start,$limit = True,$query = '',$sort = '',$order = '',$globals = False, $parent_id = '',$group_id = NULL,$lastmod = -1, $column = '') 165 { 166 //casting and slashes for security 167 $start = (int)$start; 168 $query = $this->db->db_addslashes($query); 169 $sort = $this->db->db_addslashes($sort); 170 $order = $this->db->db_addslashes($order); 171 $parent_id = (int)$parent_id; 172 173 if ($globals && !$group_id) 174 { 175 $global_cats = " cat_appname='phpgw'"; 176 } 177 157 178 if (!$sort) 158 179 { … … 160 181 } 161 182 162 if (!empty($order) && preg_match('/^[a-zA-Z_ (), ]+$/',$order) && (empty($sort) || preg_match('/^(ASC|DESC|asc|desc)$/',$sort)))183 if (!empty($order) && preg_match('/^[a-zA-Z_, ]+$/',$order) && (empty($sort) || preg_match('/^(ASC|DESC|asc|desc)$/',$sort))) 163 184 { 164 185 $ordermethod = " ORDER BY $order $sort"; … … 166 187 else 167 188 { 168 $ordermethod = ' ORDER BY cat_main, cat_level, cat_name ASC'; 169 } 170 171 if ($this->account_id == '-1') 172 { 173 $grant_cats = ' cat_owner=-1 '; 174 } 175 else 176 { 189 $ordermethod = ' ORDER BY cat_name ASC'; 190 } 191 192 if($group_id){ 193 $grant_cats .= " cat_owner='".$group_id."' "; 194 } 195 else if ($this->account_id != '-1'){ 196 $grants = $this->grants; 197 $groups = $GLOBALS['phpgw']->accounts->membership(); 198 177 199 if (is_array($this->grants)) 178 200 { 179 $grants = $this->grants; 180 while(list($user) = each($grants)) 181 { 182 $public_user_list[] = $user; 183 } 184 reset($public_user_list); 185 $grant_cats = ' (cat_owner=' . $this->account_id . " OR cat_owner=-1 OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ')) '; 201 202 foreach($grants as $idx => $user){ 203 $public_user_list[$user] = $user; 204 } 205 if(is_array($groups)){ 206 foreach($groups as $idx => $group) { 207 $public_user_list[$group['account_id']] = $group['account_id']; 208 } 209 } 210 @reset($public_user_list); 211 $grant_cats = " (cat_owner='" . $this->account_id . "' ".(is_array($public_user_list) ? "OR (cat_owner in(" . implode(',',$public_user_list) . ") AND cat_access='public')" : "").") "; 212 186 213 } 187 214 else 188 215 { 189 $grant_cats = ' cat_owner=' . $this->account_id . ' OR cat_owner=-1 '; 190 } 191 } 192 193 if ($parent_id > 0) 194 { 195 $parent_filter = ' AND cat_parent=' . $parent_id; 196 } 216 $grant_cats = " cat_owner='" . $this->account_id . "' or cat_owner='-1' "; 217 } 218 } 219 220 221 $parent_select = ' AND cat_parent=' . $parent_id; 197 222 198 223 if ($query) 199 224 { 200 $querymethod = " AND (cat_name LIKE '%$query%' OR cat_descriptionLIKE '%$query%') ";225 $querymethod = " AND (cat_name ILIKE '%$query%' OR cat_description ILIKE '%$query%') "; 201 226 } 202 227 … … 228 253 } 229 254 230 $sql = "SELECT $table_column FROM phpgw_categories WHERE (cat_appname='" . $this->app_name . "' AND" . $grant_cats . $global_cats . ')' 231 . $parent_filter . $querymethod . $filter; 232 233 $this->db2->query($sql,__LINE__,__FILE__); 234 $this->total_records = $this->db2->num_rows(); 235 236 if ($limit) 237 { 238 $this->db->limit_query($sql . $ordermethod,$start,__LINE__,__FILE__); 239 } 240 else 241 { 242 $this->db->query($sql . $ordermethod,__LINE__,__FILE__); 243 } 244 245 while ($this->db->next_record()) 246 { 247 if ($column) 248 { 249 $cats[] = array 250 ( 251 $column => $this->db->f(0) 252 ); 253 } 254 else 255 { 256 $cats[] = array 257 ( 258 'id' => $this->db->f('cat_id'), 259 'owner' => $this->db->f('cat_owner'), 260 'access' => $this->db->f('cat_access'), 261 'app_name' => $this->db->f('cat_appname'), 262 'main' => $this->db->f('cat_main'), 263 'level' => $this->db->f('cat_level'), 264 'parent' => $this->db->f('cat_parent'), 265 'name' => $this->db->f('cat_name'), 266 'description' => $this->db->f('cat_description'), 267 'data' => $this->db->f('cat_data'), 268 'last_mod' => $this->db->f('last_mod') 269 ); 270 } 271 } 272 return $cats; 273 } 274 275 function return_sorted_array($start,$limit = True,$query = '',$sort = '',$order = '',$globals = False, $parent_id = '') 276 { 277 //casting and slashes for security 278 $start = (int)$start; 279 $query = $this->db->db_addslashes($query); 280 $sort = $this->db->db_addslashes($sort); 281 $order = $this->db->db_addslashes($order); 282 $parent_id = (int)$parent_id; 283 284 if ($globals) 285 { 286 $global_cats = " OR cat_appname='phpgw'"; 287 } 288 289 if (!$sort) 290 { 291 $sort = 'ASC'; 292 } 293 294 if (!empty($order) && preg_match('/^[a-zA-Z_, ]+$/',$order) && (empty($sort) || preg_match('/^(ASC|DESC|asc|desc)$/'))) 295 { 296 $ordermethod = " ORDER BY $order $sort"; 297 } 298 else 299 { 300 $ordermethod = ' ORDER BY cat_name ASC'; 301 } 302 303 if ($this->account_id == '-1') 304 { 305 $grant_cats = " cat_owner='-1' "; 306 } 307 else 308 { 309 if (is_array($this->grants)) 310 { 311 $grants = $this->grants; 312 while(list($user) = each($grants)) 313 { 314 $public_user_list[] = $user; 315 } 316 reset($public_user_list); 317 $grant_cats = " (cat_owner='" . $this->account_id . "' OR cat_owner='-1' OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ")) "; 318 } 319 else 320 { 321 $grant_cats = " cat_owner='" . $this->account_id . "' or cat_owner='-1' "; 322 } 323 } 324 325 $parent_select = ' AND cat_parent=' . $parent_id; 326 327 if ($query) 328 { 329 $querymethod = " AND (cat_name LIKE '%$query%' OR cat_description LIKE '%$query%') "; 330 } 331 332 $sql = "SELECT * FROM phpgw_categories WHERE (cat_appname='" . $this->app_name . "' AND" . $grant_cats . $global_cats . ")" 333 . $querymethod; 334 255 256 $sql = "SELECT".$table_column."FROM phpgw_categories WHERE (cat_appname='" . $this->app_name. "' ". 257 ($grant_cats ? " AND".$grant_cats : "") .($global_cats ? " OR".$global_cats: ""). 258 ")".$querymethod; 259 335 260 $this->db2->query($sql . $parent_select,__LINE__,__FILE__); 336 261 $total = $this->db2->num_rows(); … … 350 275 $cats[$i]['id'] = (int)$this->db->f('cat_id'); 351 276 $cats[$i]['owner'] = (int)$this->db->f('cat_owner'); 277 if($cats[$i]['owner'] > 0){ 278 // Load Name Group. 279 $group = $this->get_group($cats[$i]['owner']); 280 $cats[$i]['owner'] = $group['name']; 281 } 352 282 $cats[$i]['access'] = $this->db->f('cat_access'); 353 283 $cats[$i]['app_name'] = $this->db->f('cat_appname'); … … 358 288 $cats[$i]['description'] = $this->db->f('cat_description'); 359 289 $cats[$i]['data'] = $this->db->f('cat_data'); 290 360 291 $i++; 361 292 } … … 365 296 { 366 297 $sub_select = ' AND cat_parent=' . $cats[$i]['id'] . ' AND cat_level=' . ($cats[$i]['level']+1); 367 368 /*$this->db2->query($sql . $sub_select,__LINE__,__FILE__); 369 $total_subs += $this->db2->num_rows(); 370 371 if ($limit) 372 { 373 $this->db->limit_query($sql . $sub_select . $ordermethod,$start,__LINE__,__FILE__); 374 } 375 else 376 {*/ 377 $this->db->query($sql . $sub_select . $ordermethod,__LINE__,__FILE__); 378 $total += $this->db->num_rows(); 379 //} 298 $this->db->query($sql . $sub_select . $ordermethod,__LINE__,__FILE__); 299 $total += $this->db->num_rows(); 380 300 381 301 $subcats = array(); … … 429 349 { 430 350 $this->db->query('SELECT * FROM phpgw_categories WHERE cat_id=' . (int)$id,__LINE__,__FILE__); 431 432 351 if ($this->db->next_record()) 433 352 { … … 442 361 $cats[0]['description'] = $this->db->f('cat_description'); 443 362 $cats[0]['data'] = $this->db->f('cat_data'); 363 if($cats[0]['owner'] > 0){ 364 // Load Group. 365 $group = $this->get_group($cats[0]['owner']); 366 $cats[0]['id_group'] = $group['id']; 367 $cats[0]['name_group'] = $group['name']; 368 } 444 369 } 445 370 return $cats; … … 459 384 return $this->formated_list($format,$type,$selected,$globals,$site_link); 460 385 } 386 function get_group($id) 387 { 388 if (!IsSet($id)) 389 return ""; 390 return array("id" => $id, "name" => $GLOBALS['phpgw']->accounts->id2name($id)); 391 } 392 461 393 function formated_list($format,$type='',$selected = '',$globals = False,$site_link = 'site') 462 394 { … … 591 523 $id_val = $values['id'] . ','; 592 524 } 593 594 525 $this->db->query('INSERT INTO phpgw_categories (' . $id_col . 'cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data,' 595 . 'cat_main,cat_level, last_mod) VALUES (' . $id_val . (int)$values['parent'] . ',' . $this->account_id. ",'" . $values['access']526 . 'cat_main,cat_level, last_mod) VALUES (' . $id_val . (int)$values['parent'] . ',' . ($values['group']!= 0 ? $values['group'] : $this->account_id) . ",'" . $values['access'] 596 527 . "','" . $this->app_name . "','" . $values['name'] . "','" . $values['descr'] . "','" . $values['data'] 597 528 . "'," . (int)$values['main'] . ',' . (int)$values['level'] . ',' . time() . ')',__LINE__,__FILE__); … … 687 618 $values['id'] = (int)$values['id']; 688 619 $values['parent'] = (int)$values['parent']; 689 620 $values['owner'] = (int)$values['group']; 621 if($values['owner']){ 622 $owner = "cat_owner = ".$values['owner'].","; 623 } 690 624 if (isset($values['old_parent']) && (int)$values['old_parent'] != $values['parent']) 691 625 { … … 710 644 $values['name'] = $this->db->db_addslashes($values['name']); 711 645 712 $sql = "UPDATE phpgw_categories SET cat_name='" . $values['name'] . "', cat_description='" . $values['descr']646 $sql = "UPDATE phpgw_categories SET $owner cat_name='" . $values['name'] . "', cat_description='" . $values['descr'] 713 647 . "', cat_data='" . $values['data'] . "', cat_parent=" . $values['parent'] . ", cat_access='" 714 648 . $values['access'] . "', cat_main=" . $values['main'] . ', cat_level=' . $values['level'] . ',last_mod=' . time()
Note: See TracChangeset
for help on using the changeset viewer.