From 9726db1eaac4990bf1cac00a9d1d93d9c2e711b0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 22 Nov 2010 17:10:11 +0000 Subject: [PATCH] *Users can now see and restore their 'deleted' but held contacts, if deletion prevention is turned on. There is now a config setting to allow users to purge their own 'deleted' contacts. --- addressbook/inc/class.addressbook_bo.inc.php | 2 +- addressbook/inc/class.addressbook_so.inc.php | 6 ++++-- addressbook/inc/class.addressbook_ui.inc.php | 12 +++++++++++- addressbook/templates/default/config.tpl | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 9a74245ab3..62601e40cf 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -141,7 +141,7 @@ class addressbook_bo extends addressbook_so /** * Keep deleted addresses, or really delete them * Set in Admin -> Addressbook -> Site Configuration - * ''=really delete, 'history'=keep, only admins delete + * ''=really delete, 'history'=keep, only admins delete, 'userpurge'=keep, users delete * * @var string */ diff --git a/addressbook/inc/class.addressbook_so.inc.php b/addressbook/inc/class.addressbook_so.inc.php index 2c1f5bec78..d24cfaa4ad 100755 --- a/addressbook/inc/class.addressbook_so.inc.php +++ b/addressbook/inc/class.addressbook_so.inc.php @@ -324,8 +324,10 @@ class addressbook_so ))); } - // Add in deleted type for admins - if($this->is_admin()) { + // Add in deleted type, if holding deleted contacts + $config = config::read('phpgwapi'); + if($config['history']) + { $this->content_types[self::DELETED_TYPE] = array( 'name' => lang('Deleted'), 'options' => array( diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index acca419f7a..e2d9aaece5 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -282,6 +282,12 @@ class addressbook_ui extends addressbook_bo $sel_options['action'] += array( 'delete' => lang('Delete'), ); + if($content['nm']['col_filter']['tid'] == 'D' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') + { + // User not allowed to purge + unset($sel_options['action']['delete']); + } + // check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no) if (isset($GLOBALS['egw_info']['user']['apps']['admin']) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) { @@ -1089,7 +1095,7 @@ class addressbook_ui extends addressbook_bo { $row['tel_prefered'] = $row[$row['tel_prefer']].' ♥'; } - $readonlys["delete[$row[id]]"] = !$this->check_perms(EGW_ACL_DELETE,$row); + $readonlys["delete[$row[id]]"] = !$this->check_perms(EGW_ACL_DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge'); $readonlys["edit[$row[id]]"] = !$this->check_perms(EGW_ACL_EDIT,$row); if ($row['photo']) $photos = true; @@ -1534,6 +1540,10 @@ class addressbook_ui extends addressbook_bo if($content['tid'] == addressbook_so::DELETED_TYPE) { $content['link_to']['show_deleted'] = true; + if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') + { + $readonlys['button[delete]'] = true; + } } // Enable history diff --git a/addressbook/templates/default/config.tpl b/addressbook/templates/default/config.tpl index 2ec2f9be8c..96631336bc 100644 --- a/addressbook/templates/default/config.tpl +++ b/addressbook/templates/default/config.tpl @@ -82,6 +82,7 @@