From ee9c657fb6d3c43574ba27b8b4614f9dcad90e06 Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 20 Mar 2024 15:05:40 +0200 Subject: [PATCH] UI and schema update for CF tab and readonly --- admin/inc/class.admin_customfields.inc.php | 7 +++++ admin/lang/egw_de.lang | 3 +++ admin/lang/egw_en.lang | 3 +++ admin/templates/default/customfield_edit.xet | 27 ++++++++++++-------- admin/templates/default/customfields.xet | 8 +++++- api/setup/setup.inc.php | 4 +-- api/setup/tables_current.inc.php | 5 ++-- api/setup/tables_update.inc.php | 11 ++++++++ api/src/Storage/Customfields.php | 2 ++ 9 files changed, 55 insertions(+), 15 deletions(-) diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index 4d77cd927c..523c7406c2 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -43,6 +43,11 @@ class admin_customfields */ protected $use_private = false; + /** + * Allow custom fields to be readonly for certain users/groups + */ + protected $use_readonly = false; + /** * userdefiened types e.g. type of infolog * @@ -341,6 +346,7 @@ class admin_customfields die(lang('Error! No appname found')); } $this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || !empty($content['use_private']); + $this->use_readonly = !isset($_GET['use_readonly']) || (boolean)$_GET['use_readonly'] || !empty($content['use_readonly']); // Read fields, constructor doesn't always know appname $this->fields = Api\Storage\Customfields::get($this->appname,true); @@ -453,6 +459,7 @@ class admin_customfields //echo 'customfields=
'; print_r($this->fields); echo "
\n"; $content['cf_order'] = (count($this->fields)+1) * 10; $content['use_private'] = $this->use_private; + $content['use_readonly'] = $this->use_readonly; if($cf_id) { diff --git a/admin/lang/egw_de.lang b/admin/lang/egw_de.lang index c7a455930e..ad26922d9c 100644 --- a/admin/lang/egw_de.lang +++ b/admin/lang/egw_de.lang @@ -269,6 +269,7 @@ custom 1 admin de Benutzerdefiniert 1 custom 2 admin de Benutzerdefiniert 2 custom 3 admin de Benutzerdefiniert 3 custom fields admin de Benutzerdefinierte Felder +custom fields tab admin de Benutzerdefinierte Felder Tab custom translation admin de Eigene Übersetzung customfield '%1' added admin de Benutzerdefiniertes Feld '%1' hinzugefügt customfield '%1' deleted admin de Benutzerdefiniertes Feld '%1' gelöscht @@ -660,6 +661,7 @@ must change password upon next login admin de Muss das Passwort beim nächsten L name must not be empty !!! admin de Name darf nicht leer sein! name of account admin de Name des Kontos name of organisation admin de Name der Organisation +name of tab to create and show field in admin de Name des anzulegenden Tabs in dem das Feld angezeigt wird name of the egroupware instance, eg. default admin de Name der EGroupware-Instanz, z.B. default new group name admin de Neuer Gruppenname new name admin de Neuer Name @@ -813,6 +815,7 @@ search peer servers admin de Serververbund durchsuchen secret deleted, two factor authentication disabled. admin de Geheimnis gelöscht, 2-Faktor-Authentifizierung deaktiviert. secure connection admin de Sichere Verbindung security admin de Sicherheit +select accounts for which the custom field should be readonly admin de Benutzer auswählen, für die dieses benutzerdefinierte Feld schreibgeschützt sein soll. select accounts for which the custom field should be visible admin de Benutzer auswählen, für die dieses benutzerdefinierte Feld sichtbar sein soll. select group managers admin de Gruppenmanager auswählen select language to define language based message. language 'english' is default page for all languages therefore for setting a general message across all languages you only need to set the 'english' page. admin de Wählen Sie die Sprache, um eine sprachabhängige Nachricht zu definieren. Sprache 'Englisch' ist die Standardseite für alle Sprachen, daher müssen Sie für die Einstellung einer allgemeinen Nachricht für allen Sprachen nur die Seite 'Englisch' erstellen. diff --git a/admin/lang/egw_en.lang b/admin/lang/egw_en.lang index 15b845484d..09c17105cb 100644 --- a/admin/lang/egw_en.lang +++ b/admin/lang/egw_en.lang @@ -269,6 +269,7 @@ custom 1 admin en Custom 1 custom 2 admin en Custom 2 custom 3 admin en Custom 3 custom fields admin en Custom fields +custom fields tab admin en custom fields tab custom translation admin en Custom translation customfield '%1' added admin en Customfield '%1' added customfield '%1' deleted admin en Customfield '%1' deleted @@ -660,6 +661,7 @@ must change password upon next login admin en Must change password upon next log name must not be empty !!! admin en Name must not be empty! name of account admin en Name of account name of organisation admin en Name of organization +name of tab to create and show field in admin en Name of tab to create and show field in name of the egroupware instance, eg. default admin en Name of the EGroupware instance new group name admin en New group name new name admin en New name @@ -813,6 +815,7 @@ search peer servers admin en Search peer servers secret deleted, two factor authentication disabled. admin en Secret deleted, two factor authentication disabled. secure connection admin en Secure connection security admin en Security +select accounts for which the custom field should be readonly admin en Select accounts for which the custom field should be readonly select accounts for which the custom field should be visible admin en Select accounts the custom field should be visible for. select group managers admin en Select group managers select language to define language based message. language 'english' is default page for all languages therefore for setting a general message across all languages you only need to set the 'english' page. admin en Select language to define language based message. Language 'english' is default page for all languages therefore for setting a general message across all languages you only need to set the 'english' page. diff --git a/admin/templates/default/customfield_edit.xet b/admin/templates/default/customfield_edit.xet index 9fba04128f..4020751051 100644 --- a/admin/templates/default/customfield_edit.xet +++ b/admin/templates/default/customfield_edit.xet @@ -31,22 +31,29 @@ + + + + - - - - - - - + + + + + + + + + + - - - + + + diff --git a/admin/templates/default/customfields.xet b/admin/templates/default/customfields.xet index 20a204aaac..608b904b23 100644 --- a/admin/templates/default/customfields.xet +++ b/admin/templates/default/customfields.xet @@ -35,10 +35,12 @@ + + @@ -48,12 +50,14 @@ + + @@ -66,13 +70,15 @@ - + + + diff --git a/api/setup/setup.inc.php b/api/setup/setup.inc.php index 6b976a8869..e3b224a2bb 100644 --- a/api/setup/setup.inc.php +++ b/api/setup/setup.inc.php @@ -11,7 +11,7 @@ /* Basic information about this app */ $setup_info['api']['name'] = 'api'; $setup_info['api']['title'] = 'EGroupware API'; -$setup_info['api']['version'] = '23.1.005'; +$setup_info['api']['version'] = '23.1.006'; $setup_info['api']['versions']['current_header'] = '1.29'; // maintenance release in sync with changelog in doc/rpm-build/debian.changes $setup_info['api']['versions']['maintenance_release'] = '23.1.20240304'; @@ -139,4 +139,4 @@ $setup_info['groupdav']['author'] = $setup_info['groupdav']['maintainer'] = arra ); $setup_info['groupdav']['license'] = 'GPL'; $setup_info['groupdav']['hooks']['preferences'] = 'EGroupware\\Api\\CalDAV\\Hooks::menus'; -$setup_info['groupdav']['hooks']['settings'] = 'EGroupware\\Api\\CalDAV\\Hooks::settings'; \ No newline at end of file +$setup_info['groupdav']['hooks']['settings'] = 'EGroupware\\Api\\CalDAV\\Hooks::settings'; diff --git a/api/setup/tables_current.inc.php b/api/setup/tables_current.inc.php index 82ecacb8bc..a18973489b 100644 --- a/api/setup/tables_current.inc.php +++ b/api/setup/tables_current.inc.php @@ -382,7 +382,8 @@ $phpgw_baseline = array( 'cf_private' => array('type' => 'ascii','meta' => 'account-commasep','precision' => '2048','comment' => 'comma-separated account_id'), 'cf_modifier' => array('type' => 'int','meta' => 'account','precision' => '4','comment' => 'last modifier'), 'cf_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'last modification time'), - 'cf_tab' => array('type' => 'varchar','precision' => '64','comment' => 'tab customfield should be shown') + 'cf_tab' => array('type' => 'varchar','precision' => '64','comment' => 'tab customfield should be shown'), + 'cf_readonly' => array('type' => 'ascii','meta' => 'account-commasep','precision' => '2048','comment' => 'comma-separated account_id') ), 'pk' => array('cf_id'), 'fk' => array(), @@ -552,4 +553,4 @@ $phpgw_baseline = array( 'ix' => array('account_id'), 'uc' => array() ) -); \ No newline at end of file +); diff --git a/api/setup/tables_update.inc.php b/api/setup/tables_update.inc.php index bb85341119..b0842f95f1 100644 --- a/api/setup/tables_update.inc.php +++ b/api/setup/tables_update.inc.php @@ -954,4 +954,15 @@ function api_upgrade23_1_004() )); return $GLOBALS['setup_info']['api']['currentver'] = '23.1.005'; +} +function api_upgrade23_1_005() +{ + $GLOBALS['egw_setup']->oProc->AddColumn('egw_customfields','cf_readonly',array( + 'type' => 'ascii', + 'meta' => 'account-commasep', + 'precision' => '2048', + 'comment' => 'comma-separated account_id' + )); + + return $GLOBALS['setup_info']['api']['currentver'] = '23.1.006'; } \ No newline at end of file diff --git a/api/src/Storage/Customfields.php b/api/src/Storage/Customfields.php index 27eb1c2786..33c41fb68e 100644 --- a/api/src/Storage/Customfields.php +++ b/api/src/Storage/Customfields.php @@ -435,8 +435,10 @@ class Customfields implements \IteratorAggregate 'cf_len' => (string)$cf['len'] !== '' ? $cf['len'] : null, 'cf_rows' => (string)$cf['rows'] !== '' ? $cf['rows'] : null, 'cf_order' => $cf['order'], + 'cf_tab' => $cf['tab'] ?? null ?: null, 'cf_needed' => $cf['needed'], 'cf_private' => $cf['private'] ? implode(',', $cf['private']) : null, + 'cf_readonly' => $cf['readonly'] ? implode(',', $cf['readonly']) : null, 'cf_modifier' => $GLOBALS['egw_info']['user']['account_id'], 'cf_modified' => time(), ), array(