From bfb335f7c33796c776f906390b83fb289980e854 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 16 Nov 2022 14:10:34 -0700 Subject: [PATCH] * Resources: Customfields can now be per category --- admin/inc/class.admin_customfields.inc.php | 16 +++-- admin/templates/default/customfields.xet | 55 ++++++++--------- .../inc/class.resources_customfields.inc.php | 59 +++++++++++++++++++ resources/inc/class.resources_hooks.inc.php | 26 ++++---- resources/templates/default/admin.types.xet | 18 ++++++ resources/templates/default/edit.xet | 22 +++---- 6 files changed, 139 insertions(+), 57 deletions(-) create mode 100644 resources/inc/class.resources_customfields.inc.php create mode 100644 resources/templates/default/admin.types.xet diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index dc86bd89de..ed82c0140d 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -430,7 +430,10 @@ class admin_customfields $test = new Etemplate(); if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; - $this->tmpl = new Etemplate(); + if(is_null($this->tmpl)) + { + $this->tmpl = new Etemplate(); + } $this->tmpl->read('admin.customfield_edit'); Api\Translation::add_app('infolog'); // til we move the translations @@ -501,13 +504,14 @@ class admin_customfields } $content['statustext'] = $content['options'][$content['cf_type']]; $content['attributes'] = self::$type_attribute_flags; + $exec = static::class == 'admin_customfields' ? 'admin.admin_customfields.edit' : $this->appname . '.' . static::class . '.edit'; - $this->tmpl->exec('admin.admin_customfields.edit',$content,$sel_options,$readonlys,array( - 'cf_id' => $cf_id, - 'cf_app' => $this->appname, - 'cf_name' => $content['cf_name'], + $this->tmpl->exec($exec, $content, $sel_options, $readonlys, array( + 'cf_id' => $cf_id, + 'cf_app' => $this->appname, + 'cf_name' => $content['cf_name'], 'use_private' => $this->use_private, - ),2); + ), 2); } /** diff --git a/admin/templates/default/customfields.xet b/admin/templates/default/customfields.xet index 819e362802..82b2dac7a1 100644 --- a/admin/templates/default/customfields.xet +++ b/admin/templates/default/customfields.xet @@ -15,13 +15,11 @@ - - - + + + - - - + + + + + + + + + + + + + + + + + + + + @@ -92,4 +89,4 @@ - + \ No newline at end of file diff --git a/resources/inc/class.resources_customfields.inc.php b/resources/inc/class.resources_customfields.inc.php new file mode 100644 index 0000000000..9bdca1d4d9 --- /dev/null +++ b/resources/inc/class.resources_customfields.inc.php @@ -0,0 +1,59 @@ +bo = new resources_bo(); + $this->tmpl = new Etemplate(); + + // For index - override so "add" button opens correctly + $this->tmpl->setElementAttribute("nm", "header_left", "resources.customfields.add"); + + $content_types = $this->bo->acl->get_cats(Acl::ADD); + array_walk($content_types, function ($name, $id) + { + $this->content_types[$id] = array('name' => $name); + }); + + Api\Translation::add_app('resources'); + } + + public function edit($content = null) + { + // Turn private off + $_GET['use_private'] = false; + unset($content['use_private']); + + parent::edit($content); + } +} diff --git a/resources/inc/class.resources_hooks.inc.php b/resources/inc/class.resources_hooks.inc.php index ceac6f92d4..f22e91d0ab 100644 --- a/resources/inc/class.resources_hooks.inc.php +++ b/resources/inc/class.resources_hooks.inc.php @@ -52,18 +52,22 @@ class resources_hooks if ($GLOBALS['egw_info']['user']['apps']['admin']) { - $file = Array( - 'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'), - 'Global Categories' => Egw::link('/index.php',array( - 'menuaction' => 'admin.admin_categories.index', - 'appname' => $appname, - 'global_cats'=> true, - 'ajax' => 'true' + $file = array( + 'Site Configuration' => Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=' . $appname . '&ajax=true'), + 'Global Categories' => Egw::link('/index.php', array( + 'menuaction' => 'admin.admin_categories.index', + 'appname' => $appname, + 'global_cats' => true, + 'ajax' => 'true' )), - 'Configure Access Permissions' => Egw::link('/index.php', - 'menuaction=resources.resources_acl_ui.index&ajax=true'), - 'Custom Fields'=>egw::link('/index.php', - 'menuaction=admin.admin_customfields.index&appname=resources&ajax=true'), + 'Configure Access Permissions' => Egw::link( + '/index.php', + 'menuaction=resources.resources_acl_ui.index&ajax=true' + ), + 'Custom Fields' => egw::link( + '/index.php', + 'menuaction=resources.resources_customfields.index&appname=resources&ajax=true' + ), ); if ($location == 'admin') { diff --git a/resources/templates/default/admin.types.xet b/resources/templates/default/admin.types.xet new file mode 100644 index 0000000000..c0309cfa75 --- /dev/null +++ b/resources/templates/default/admin.types.xet @@ -0,0 +1,18 @@ + + + + + + +