From 11c03702ddd5fe0b7c009aabfb25cd6d10eea339 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 7 Jun 2017 17:54:09 +0200 Subject: [PATCH] Implement sub_app attribute for customfields widget, in order to be able to store sub-app's specific customfields --- admin/inc/class.admin_customfields.inc.php | 2 +- api/js/etemplate/et2_extension_customfields.js | 5 +++++ api/src/Etemplate/Widget/Customfields.php | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index 53850f0b21..b6e4ca60db 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -127,7 +127,7 @@ class admin_customfields { // determine appname $this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['appname'] ? $content['appname'] : false)); - if(!$this->appname) die(lang('Error! No appname found')); + if(!$this->appname || !Api\Link::get_registry($this->appname, 'title')) die(lang('Error! No appname found')); $this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private']; diff --git a/api/js/etemplate/et2_extension_customfields.js b/api/js/etemplate/et2_extension_customfields.js index e3368287e9..435c0d0422 100644 --- a/api/js/etemplate/et2_extension_customfields.js +++ b/api/js/etemplate/et2_extension_customfields.js @@ -48,6 +48,11 @@ var et2_customfields_list = (function(){ "use strict"; return et2_valueWidget.ex 'private': { ignore: true, type: 'boolean' + }, + 'sub_app': { + 'name': 'sub app name', + 'type': "string", + 'description': "Name of sub application" } }, diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index d8f00b13c0..3aa65f9574 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -126,6 +126,7 @@ class Customfields extends Transformer if(!$app) { $app =& $this->setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']); + if ($this->attrs['sub-app']) $app .= '-'.$this->attrs['sub-app']; $customfields =& $this->setElementAttribute(self::GLOBAL_VALS, 'customfields', Api\Storage\Customfields::get($app)); } @@ -283,7 +284,7 @@ class Customfields extends Transformer $widget->id = self::$prefix.$fname; $widget->attrs['type'] = $type; $widget->set_attrs($xml); - + // some type-specific (default) attributes switch($type) { @@ -402,7 +403,7 @@ class Customfields extends Transformer // Arrays are not valid, but leave filemanager alone, we'll catch it // when saving. This allows files for new entries. if (is_array($valid) && $field_settings['type'] !== 'filemanager') $valid = implode(',', $valid); - + // NULL is valid for most fields, but not custom fields due to backend handling // See so_sql_cf->save() if (is_null($valid)) $valid = false;