From d2a8e376f5ba4205029f323d423de7ff0423e8e7 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 18 Feb 2015 11:41:17 +0000 Subject: [PATCH] * Admin: add a description to stock groups Admins, Default and NoGroup, allow to edit that description for LDAP and ADS --- admin/inc/class.admin_ui.inc.php | 1 + phpgwapi/inc/class.accounts.inc.php | 44 ++++++++++++++++++++++++ phpgwapi/inc/class.accounts_ads.inc.php | 4 --- phpgwapi/inc/class.accounts_ldap.inc.php | 4 ++- phpgwapi/lang/egw_de.lang | 3 ++ phpgwapi/lang/egw_en.lang | 3 ++ 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/admin/inc/class.admin_ui.inc.php b/admin/inc/class.admin_ui.inc.php index c7a2cf84b9..8ce6abb20f 100644 --- a/admin/inc/class.admin_ui.inc.php +++ b/admin/inc/class.admin_ui.inc.php @@ -426,6 +426,7 @@ class admin_ui { $tree['item'][] = self::fix_userdata(array( 'text' => $group['account_lid'], + 'tooltip' => $group['account_description'], 'id' => $root.'/'.$group['account_id'], )); } diff --git a/phpgwapi/inc/class.accounts.inc.php b/phpgwapi/inc/class.accounts.inc.php index b5c6c8e42b..61839c96a4 100644 --- a/phpgwapi/inc/class.accounts.inc.php +++ b/phpgwapi/inc/class.accounts.inc.php @@ -335,6 +335,17 @@ class accounts else { $account_search[$serial]['data'] = $this->backend->search($param); + if ($param['type'] !== 'accounts') + { + foreach($account_search[$serial]['data'] as &$account) + { + // add default description for Admins and Default group + if ($account['account_type'] === 'g' && empty($account['account_description'])) + { + self::add_default_group_description($account); + } + } + } $account_search[$serial]['total'] = $this->total = $this->backend->total; } //echo "

accounts::search(".array2string(unserialize($serial)).")= returning ".count($account_search[$serial]['data'])." of $this->total entries

".print_r($account_search[$serial]['data'],True)."
\n"; @@ -429,6 +440,12 @@ class accounts $data = self::cache_read($id); + // add default description for Admins and Default group + if ($data['account_type'] === 'g' && empty($data['account_description'])) + { + self::add_default_group_description($data); + } + if ($set_depricated_names && $data) { foreach($this->depricated_names as $name) @@ -469,6 +486,28 @@ class accounts return json_encode($account); } + /** + * Add a default description for stock groups: Admins, Default, NoGroup + * + * @param array &$data + */ + protected static function add_default_group_description(array &$data) + { + switch($data['account_lid']) + { + case 'Default': + $data['account_description'] = lang('EGroupware all users group, do NOT delete'); + break; + case 'Admins': + $data['account_description'] = lang('EGroupware administrators group, do NOT delete'); + break; + case 'NoGroup': + $data['account_description'] = lang('EGroupware anonymous users group, do NOT delete'); + break; + } + error_log(__METHOD__."(".array2string($data).")"); + } + /** * Saves / adds the data of one account * @@ -490,6 +529,11 @@ class accounts } } } + // add default description for Admins and Default group + if ($data['account_type'] === 'g' && empty($data['account_description'])) + { + self::add_default_group_description($data); + } if (($id = $this->backend->save($data)) && $data['account_type'] != 'g') { // if we are not on a pure LDAP system, we have to write the account-date via the contacts class now diff --git a/phpgwapi/inc/class.accounts_ads.inc.php b/phpgwapi/inc/class.accounts_ads.inc.php index c454f73e8c..736b43eec7 100644 --- a/phpgwapi/inc/class.accounts_ads.inc.php +++ b/phpgwapi/inc/class.accounts_ads.inc.php @@ -578,10 +578,6 @@ class accounts_ads protected function _save_group(array &$data, array $old=null) { //error_log(__METHOD__.'('.array2string($data).', old='.array2string($old).')'); - if (empty($data['account_description'])) - { - $data['account_description'] = 'EGroupware '.lang('Group').' '.$data['account_lid']; - } if (!$old) // new entry { diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 2e90d5b048..ee9d23e105 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -446,7 +446,7 @@ class accounts_ldap } } $sri = ldap_search($this->ds, $this->group_context,'(&(objectClass=posixGroup)(gidnumber=' . abs($account_id).'))', - array('dn', 'gidnumber', 'cn', 'objectclass', static::MAIL_ATTR, 'memberuid')); + array('dn', 'gidnumber', 'cn', 'objectclass', static::MAIL_ATTR, 'memberuid', 'description')); $ldap_data = ldap_get_entries($this->ds, $sri); if (!$ldap_data['count']) @@ -467,6 +467,7 @@ class accounts_ldap 'objectclass' => array_map('strtolower', $data['objectclass']), 'account_email' => $data[static::MAIL_ATTR][0], 'members' => array(), + 'account_description' => $data['description'][0], ); if (isset($data['memberuid'])) @@ -554,6 +555,7 @@ class accounts_ldap { $to_write['gidnumber'] = abs($data['account_id']); $to_write['cn'] = $data['account_lid']; + $to_write['description'] = $data['account_description']; return $to_write; } diff --git a/phpgwapi/lang/egw_de.lang b/phpgwapi/lang/egw_de.lang index 8ad4ee9e67..a04c545222 100644 --- a/phpgwapi/lang/egw_de.lang +++ b/phpgwapi/lang/egw_de.lang @@ -277,6 +277,9 @@ edit %1 category for common de %1 Kategorie editieren für edit categories common de Kategorien editieren edit category common de Kategorie editieren egroupware common de EGroupware +egroupware administrators group, do not delete common de EGroupware Gruppe für Administratoren, NICHT löschen +egroupware all users group, do not delete common de EGroupware Gruppe für alle Benutzer, NICHT löschen +egroupware anonymous users group, do not delete common de EGroupware Gruppe für anonymen Benutzer, nicht löschen egroupware api version common de EGroupware API Version egroupware maintenance update %1 available common de EGroupware Fehlerbehebungsupdate %1 ist verfügbar egroupware security update %1 needs to be installed! common de EGroupware Sicherheitsupdate %1 muss installiert werden! diff --git a/phpgwapi/lang/egw_en.lang b/phpgwapi/lang/egw_en.lang index 278c038652..942998e8bb 100644 --- a/phpgwapi/lang/egw_en.lang +++ b/phpgwapi/lang/egw_en.lang @@ -277,6 +277,9 @@ edit %1 category for common en Edit %1 category for edit categories common en Edit categories edit category common en Edit category egroupware common en EGroupware +egroupware administrators group, do not delete common en EGroupware administrators group, do NOT delete +egroupware all users group, do not delete common en EGroupware all users group, do NOT delete +egroupware anonymous users group, do not delete common en EGroupware anonymous users group, do NOT delete egroupware api version common en EGroupware API version egroupware maintenance update %1 available common en EGroupware maintenance update %1 available egroupware security update %1 needs to be installed! common en EGroupware security update %1 needs to be installed!