Changeset 662 for trunk/admin
- Timestamp:
- 02/06/09 08:37:34 (15 years ago)
- Location:
- trunk/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/inc/class.uicategories.inc.php
r577 r662 345 345 function edit() 346 346 { 347 $cat_group = split(",",$_POST['idgroup']); 348 349 if (count($cat_group) == 0) 350 $cat_group = array('0'=>'0'); 351 347 352 $new_parent = (int)$_POST['new_parent']; 348 353 $cat_parent = (int)$_POST['cat_parent']; … … 351 356 $cat_data = $_POST['cat_data']; 352 357 $old_parent = (int)$_POST['old_parent']; 353 $cat_group = $_POST['idgroup']; 354 358 355 359 if ($new_parent) 356 360 { … … 378 382 { 379 383 $data = serialize($cat_data); 380 381 $values = array 382 ( 383 'parent' => $cat_parent, 384 'descr' => $cat_description, 385 'name' => $cat_name, 386 'group' => $cat_group, 387 'access' => 'public', 388 'data' => $data 389 ); 390 if ($this->cat_id) 391 { 392 $values['id'] = $this->cat_id; 393 $values['old_parent'] = $old_parent; 394 } 395 $error = $this->bo->check_values($values); 396 if (is_array($error)) 397 { 398 $this->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error)); 399 } 400 else 401 { 402 $this->cat_id = $this->bo->save_cat($values); 403 $GLOBALS['phpgw']->redirect_link('/index.php',$link_data); 404 } 384 $redirect_ = false; 385 foreach($cat_group as $index_ => $catValue) 386 { 387 $values = array 388 ( 389 'parent' => $cat_parent, 390 'descr' => $cat_description, 391 'name' => $cat_name, 392 'group' => $catValue, 393 'access' => 'public', 394 'data' => $data 395 ); 396 if ($this->cat_id) 397 { 398 if ($index_ == 0){ 399 $values['id'] = $this->cat_id; 400 $values['old_parent'] = $old_parent; 401 } 402 else{ 403 $this->bo->save_cat($values); 404 } 405 } 406 $error = $this->bo->check_values($values); 407 if (is_array($error)) 408 { 409 $this->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error)); 410 } 411 else 412 { 413 $redirect_ = true; 414 $this->cat_id = $this->bo->save_cat($values); 415 unset($values); 416 } 417 } 418 if ($redirect_) 419 $GLOBALS['phpgw']->redirect_link('/index.php',$link_data); 420 405 421 } 406 422 … … 449 465 $cat['description'] = str_replace($matches[1],'',$cat['description']); 450 466 } 451 452 $hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\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"; 467 if (strlen($cat['name_group']) == 0) 468 { 469 $cat['name_group'] = lang("All"); 470 $cat['id_group'] = 0; 471 } 472 $this->template->set_var('category_namegroup',$GLOBALS['phpgw']->strip_html($cat['name_group'])); 473 474 // Hidden vars 475 $this->template->set_var('cat_id',$this->cat_id); 476 $this->template->set_var('cat_parent',$cat['parent']); 477 $this->template->set_var('cat_id_group',$cat['id_group']); 478 479 $this->template->set_var('lang_add_multiple_categories',lang("add multiple categories?")); 455 480 456 481 $link_data['menuaction'] = 'admin.uicategories.edit'; … … 472 497 $this->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cat['description'])); 473 498 $this->template->set_var('category_list',$this->bo->cats->formatted_list(array('selected' => $cat['parent'],'self' => $this->cat_id))); 474 $this->template->set_var('category_namegroup',$GLOBALS['phpgw']->strip_html($cat['name_group']));475 499 $this->template->set_var('bt_rem_id_group_visibility',$cat['name_group'] ? "visible" : "hidden"); 476 500 if (!is_object($GLOBALS['phpgw']->html)) -
trunk/admin/templates/default/category_form.tpl
r577 r662 26 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 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>28 <select multiple id="groupsfound" style="width: 300px" size="4"></select> 29 <button type="button" onClick="javascript:add('groupsfound','td_group');"><img src="{template_set}/images/add.png" style="vertical-align: bottom;"/></button></td> 30 30 </tr> 31 31 <tr class="row_off"> 32 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> 33 <td id="td_group" id="namegroup" valign="center" colspan="2"> 34 <div> 35 <label id="{cat_id_group}" style="font-weight:bold">{category_namegroup}</label> 36 <button valign="top" type="button" onClick="javascript:remove({cat_id_group});"> 37 <img src="{template_set}/images/delete.png" style="vertical-align: middle;"> 38 </button> 39 </div> 40 </td> 35 41 </tr> 36 42 … … 48 54 <td>{td_data}</td> 49 55 </tr> 50 <!-- END data_row -->56 <!-- END data_row --> 51 57 <tr valign="bottom" height="50"> 52 <td><input type="submit" name="save" value="{lang_save}"></td> 58 <input type="hidden" name="cat_id" value="{cat_id}"> 59 <input type="hidden" name="old_parent" value="{cat_parent}"> 60 <input type="hidden" id="idgroup" name="idgroup" value="{cat_id_group}"> 61 <td><input onclick="return verifyCatOwners('td_group')" type="submit" name="save" value="{lang_save}"></td> 53 62 <td><form method="POST" action="{cancel_url}"><input type="submit" name="cancel" value="{lang_cancel}"></form></td> 54 63 <td align="right">{delete}</td> … … 57 66 </form> 58 67 </center> 59 60 68 <!-- END form --> 61 69 <script language="JavaScript" type="text/javascript"> 62 70 function remove(to){ 63 document.getElementById("name"+to).innerHTML = ''; 64 document.getElementById("id"+to).value = '-1'; 65 show_button("id"+to); 71 var to_el = document.getElementById(to); 72 var gId = to_el.id; 73 document.getElementById('idgroup').value = document.getElementById('idgroup').value.replace(gId,''); 74 document.getElementById(to).parentNode.innerHTML = ''; 66 75 } 67 76 function show_button(id){ … … 71 80 function add(from, to){ 72 81 var sel_from = document.getElementById(from); 82 to_el = document.getElementById(to); 73 83 for (i = 0 ; i < sel_from.length; i++){ 74 84 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; 85 var div_el = document.createElement('DIV'); 86 el_name = document.createElement('LABEL'); 87 el_name.innerHTML = sel_from.options[i].text; 88 el_name.id = sel_from[i].value; 89 document.getElementById('idgroup').value += ","+sel_from[i].value; 90 el_name.style.fontWeight = "bold"; 91 el_name.innerHTML += '<button valign="top" type="button" onClick="javascript:remove('+sel_from[i].value+');"><img src="{template_set}/images/delete.png" style="vertical-align: middle;"></button>'; 92 div_el.appendChild(el_name); 93 to_el.appendChild(div_el); 81 94 } 95 } 96 } 97 function verifyCatOwners(field){ 98 var sel_ = document.getElementById(field); 99 var groups = document.getElementById('idgroup').value; 100 if (groups.indexOf(',') == 0) 101 document.getElementById('idgroup').value = groups.substr(1,groups.length); 102 if (document.getElementById('idgroup').value.indexOf(',') != -1) 103 { 104 var add_mult = confirm("{lang_add_multiple_categories}"); 105 if (!add_mult) 106 return false; 82 107 } 83 108 }
Note: See TracChangeset
for help on using the changeset viewer.