From 8458c7ca0e787db4a04fb1a6264e15153fd173b3 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sun, 23 Jan 2011 18:10:40 +0000 Subject: When creating a new contact, add it to the selected group; consider the selected group when deleting a contact --- program/js/app.js | 3 +++ program/steps/addressbook/save.inc | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'program') diff --git a/program/js/app.js b/program/js/app.js index c81212fb5..1c8c4c3c9 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3766,6 +3766,9 @@ function rcube_webmail() this.show_contentframe(false); } + if (this.env.group) + qs += '&_gid='+urlencode(this.env.group); + // also send search request to get the right records from the next page if (this.env.search_request) qs += '&_search='+this.env.search_request; diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index 7d29b6fb2..5d8b53159 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -131,7 +131,6 @@ foreach ($GLOBALS['CONTACT_COLTYPES'] as $col => $colprop) { if (empty($a_record['name'])) $a_record['name'] = join(' ', array_filter(array($a_record['prefix'], $a_record['firstname'], $a_record['middlename'], $a_record['surname'], $a_record['suffix'],))); -#var_dump($a_record); // Basic input checks (TODO: delegate to $CONTACTS instance) if (empty($a_record['name'])/* || empty($a_record['email'])*/) { @@ -242,6 +241,18 @@ else { if ($insert_id) { + // add new contact to the specified group + if ($CONTACTS->group_id) { + $plugin = $RCMAIL->plugins->exec_hook('group_addmembers', array('group_id' => $CONTACTS->group_id, 'ids' => $insert_id, 'source' => $source)); + + if (!$plugin['abort']) { + if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + 1 > $maxnum)) + $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); + + $CONTACTS->add_to_group($gid, $plugin['ids']); + } + } + // add contact row or jump to the page where it should appear $CONTACTS->reset(); $result = $CONTACTS->search($CONTACTS->primary_key, $insert_id); -- cgit v1.2.3