True, 'edit' => True, 'delete' => True ); function uicategories() { $GLOBALS['phpgw_info']['flags']['xslt_app'] = True; $this->bo = CreateObject('admin.bocategories'); $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); $this->start = $this->bo->start; $this->query = $this->bo->query; $this->sort = $this->bo->sort; $this->order = $this->bo->order; $this->cat_id = $this->bo->cat_id; if($this->debug) { $this->_debug_sqsof(); } } function _debug_sqsof() { $data = array( 'start' => $this->start, 'query' => $this->query, 'sort' => $this->sort, 'order' => $this->order, 'cat_id' => $this->cat_id ); echo '
UI:
'; _debug_array($data); } function save_sessiondata() { $data = array ( 'start' => $this->start, 'query' => $this->query, 'sort' => $this->sort, 'order' => $this->order ); if(isset($this->cat_id)) { $data['cat_id'] = $this->cat_id; } $this->bo->save_sessiondata($data); } function index() { $global_cats = get_var('global_cats',array('POST','GET')); $GLOBALS['phpgw']->xslttpl->add_file(array('app_data','cats', $GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'search_field', $GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'nextmatchs')); $link_data = array ( 'menuaction' => 'admin.uicategories.index', 'appname' => $GLOBALS['appname'], 'global_cats' => $global_cats ); if ($GLOBALS['appname']) { $GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . ' ' . lang('global categories') . ': ' . lang('category list'); } else { $GLOBALS['phpgw_info']['flags']['app_header'] = lang('global categories') . ': ' . lang('category list'); } if (!$global_cats) { $global_cats = False; } $categories = $this->bo->get_list($global_cats); $cat_header[] = array ( 'sort_name' => $this->nextmatchs->show_sort_order(array ( 'sort' => $this->sort, 'var' => 'cat_name', 'order' => $this->order, 'extra' => $link_data )), 'lang_add_sub' => lang('add sub'), 'lang_name' => lang('name'), 'lang_descr' => lang('description'), 'lang_edit' => lang('edit'), 'lang_delete' => lang('delete'), 'lang_sort_statustext' => lang('sort the entries'), 'sort_descr' => $this->nextmatchs->show_sort_order(array ( 'sort' => $this->sort, 'var' => 'cat_description', 'order' => $this->order, 'extra' => $link_data )) ); while (is_array($categories) && list(,$cat) = each($categories)) { $level = $cat['level']; $cat_name = $GLOBALS['phpgw']->strip_html($cat['name']); $main = 'yes'; if ($level > 0) { $space = ' . '; $spaceset = str_repeat($space,$level); $cat_name = $spaceset . $cat_name; $main = 'no'; } $descr = $GLOBALS['phpgw']->strip_html($cat['descr']); if ($GLOBALS['appname'] && $cat['app_name'] == 'phpgw') { $appendix = ' <' . lang('Global') . '>'; } else { $appendix = ''; } $link_data['menuaction'] = 'admin.uicategories.edit'; $link_data['parent'] = $cat['cat_id']; $add_sub_url = $GLOBALS['phpgw']->link('/index.php',$link_data); if ($GLOBALS['appname'] && $cat['app_name'] == $GLOBALS['appname']) { $show_edit_del = True; } elseif(!$GLOBALS['appname'] && $cat['app_name'] == 'phpgw') { $show_edit_del = True; } else { $show_edit_del = False; } if ($show_edit_del) { $link_data['cat_id'] = $cat['cat_id']; $link_data['menuaction'] = 'admin.uicategories.edit'; $edit_url = $GLOBALS['phpgw']->link('/index.php',$link_data); $lang_edit = lang('edit'); $link_data['menuaction'] = 'admin.uicategories.delete'; $delete_url = $GLOBALS['phpgw']->link('/index.php',$link_data); $lang_delete = lang('delete'); } else { $edit_url = ''; $lang_edit = ''; $delete_url = ''; $lang_delete = ''; } $content[] = array ( 'name' => $cat_name . $appendix, 'descr' => $descr, 'date' => $note['date'], 'main' => $main, 'add_sub_url' => $add_sub_url, 'edit_url' => $edit_url, 'delete_url' => $delete_url, 'lang_add_sub_statustext' => lang('add a subcategory'), 'lang_edit_statustext' => lang('edit this category'), 'lang_delete_statustext' => lang('delete this category'), 'lang_add_sub' => lang('add sub'), 'lang_edit' => $lang_edit, 'lang_delete' => $lang_delete ); } $link_data['menuaction'] = 'admin.uicategories.edit'; $link_data['parent'] = ''; $cat_add[] = array ( 'lang_add' => lang('add'), 'lang_add_statustext' => lang('add a category'), 'add_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), 'lang_done' => lang('done'), 'lang_done_statustext' => lang('return to admin mainscreen'), 'done_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.mainscreen') ); $link_data['menuaction'] = 'admin.uicategories.index'; $data = array ( 'start_record' => $this->start, 'record_limit' => $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'], 'num_records' => count($categoris), 'all_records' => $this->bo->cats->total_records, 'nextmatchs_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), 'nextmatchs_img_path' => $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'), 'select_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), 'lang_searchfield_statustext' => lang('Enter the search string. To show all entries, empty this field and press the SUBMIT button again'), 'lang_searchbutton_statustext' => lang('Submit the search string'), 'query' => $this->query, 'lang_search' => lang('search'), 'cat_header' => $cat_header, 'cat_data' => $content, 'cat_add' => $cat_add ); $this->save_sessiondata(); $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('cat_list' => $data)); } function edit() { $global_cats = get_var('global_cats',array('POST','GET')); $parent = get_var('parent',array('GET')); $values = get_var('values',array('POST')); if ($values['save']) { if (is_array($values)) { $values['cat_id'] = $this->cat_id; $values['access'] = 'public'; } $error = $this->bo->check_values($values); if (is_array($error)) { $message = $GLOBALS['phpgw']->common->error_list($error); } else { $this->cat_id = $this->bo->save_cat($values); $message = lang('Category %1 has been saved !',$values['name']); } } if (!$this->cat_id) { $function = lang('add category'); $action = 'add'; } else { $action = 'edit'; $function = lang('edit category'); $cats = $this->bo->cats->return_single($this->cat_id); $parent = $cats['parent']; } if ($GLOBALS['appname']) { $GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . ' ' . lang('global categories') . ': ' . $function; } else { $GLOBALS['phpgw_info']['flags']['app_header'] = lang('global categories') . ': ' . $function; } $GLOBALS['phpgw']->xslttpl->add_file(array('app_data','cats')); if ($GLOBALS['appname']) { $GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit global category for %1',lang($GLOBALS['appname']))); } else { $GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit global category')); } $link_data = array ( 'menuaction' => 'admin.uicategories.index', 'appname' => $GLOBALS['appname'], 'global_cats' => $global_cats ); $data = array ( 'action' => $action, 'done_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), 'lang_name' => lang('name'), 'lang_descr' => lang('description'), 'lang_parent' => lang('parent category'), 'old_parent' => $cats['parent'], 'lang_save' => lang('save'), 'lang_done' => lang('done'), 'lang_delete' => lang('delete'), 'lang_reset' => lang('reset'), 'value_name' => $GLOBALS['phpgw']->strip_html($cats['name']), 'value_descr' => $GLOBALS['phpgw']->strip_html($cats['descr']), 'message' => $message, 'lang_content_statustext' => lang('Enter a description for the category'), 'lang_done_statustext' => lang('Back to the list'), 'lang_save_statustext' => lang('Save the category'), 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the parent category. If this is a main category select NO CATEGORY'), 'select_name' => 'values[parent]', 'cat_list' => $this->bo->cats->formatted_xslt_list(array('format' => 'select','selected' => $parent,'globals' => $global_cats)) ); $link_data['menuaction'] = 'admin.uicategories.edit'; if ($this->cat_id) { $link_data['cat_id'] = $this->cat_id; } $data['edit_url'] = $GLOBALS['phpgw']->link('/index.php',$link_data); $data['delete_url'] = $GLOBALS['phpgw']->link('/index.php',$link_data); $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('cat_edit' => $data)); } function delete() { $global_cats = get_var('global_cats',array('POST','GET')); if ($GLOBALS['appname']) { $GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . ' ' . lang('global categories') . ': ' . lang('delete category'); } else { $GLOBALS['phpgw_info']['flags']['app_header'] = lang('global categories') . ': ' . lang('delete category'); } $link_data = array ( 'menuaction' => 'admin.uicategories.index', 'appname' => $GLOBALS['appname'], 'global_cats' => $global_cats ); if (!$this->cat_id) { Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); } if (get_var('confirm',array('POST'))) { if (get_var('subs',array('POST'))) { switch (get_var('subs',array('POST'))) { case 'move': $this->bo->delete(array('cat_id' => $this->cat_id, 'modify_subs' => True)); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); break; case 'drop': $this->bo->delete(array('cat_id' => $this->cat_id, 'drop_subs' => True)); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); break; default: $error_msg = lang('Please choose one of the methods to handle the subcategories'); break; } } else { $this->bo->delete(array('cat_id' => $this->cat_id)); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); } } $GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'app_delete')); if ($GLOBALS['appname']) { $type = 'noglobalapp'; } else { $type = 'noglobal'; } $apps_cats = $this->bo->exists(array('type' => $type, 'cat_name' => '', 'cat_id' => $this->cat_id)); if ($apps_cats) { $lang_confirm_msg = lang('This category is currently being used by applications as a parent category. ') . lang('You will need to reassign these subcategories before you can delete this category'); } else { $lang_confirm_msg = lang('Are you sure you want to delete this global category ?'); $exists = $this->bo->exists(array ( 'type' => 'subs', 'cat_name' => '', 'cat_id' => $this->cat_id )); if ($exists) { $subs = 'yes'; $lang_sub_select_move = lang('Do you want to move all global subcategories one level down ?'); $lang_sub_select_drop = lang('Do you want to delete all global subcategories ?'); } } $data = array ( 'done_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), 'lang_confirm_msg' => $lang_confirm_msg, 'lang_yes' => lang('yes'), 'subs' => $subs, 'lang_sub_select_move' => $lang_sub_select_move, 'lang_sub_select_drop' => $lang_sub_select_drop, 'lang_yes_statustext' => lang('Delete the entry'), 'lang_no_statustext' => lang('Back to the list'), 'lang_no' => lang('no'), 'lang_error_msg' => $error_msg ); $link_data['menuaction'] = 'admin.uicategories.delete'; $link_data['cat_id'] = $this->cat_id; $data['delete_url'] = $GLOBALS['phpgw']->link('/index.php',$link_data); $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data)); } } ?>