- Plugin API: improved 'abort' flag handling, added 'result' item in some hooks: group_*, contact_*, identity_* (#1486914)
| | |
| | | - Add option do bind for an individual LDAP address book (#1486997) |
| | | - Change reply prefix to display email address only if sender name doesn't exist (#1486550) |
| | | - Fix charset replacement in HTML message bodies (#1487021) |
| | | - Plugin API: improved 'abort' flag handling, added 'result' item in some hooks (#1486914) |
| | | |
| | | RELEASE 0.4.1 |
| | | ------------- |
| | |
| | | $ids = array(); |
| | | |
| | | foreach ($arr_cids as $cid) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_create', array( |
| | | 'record' => $CONTACTS->get_record($cid, true), |
| | | 'source' => $target, |
| | | 'group' => $target_group, |
| | | )); |
| | | $a_record = $plugin['record']; |
| | | $a_record = $CONTACTS->get_record($cid, true); |
| | | |
| | | if (!$plugin['abort']) { |
| | | // check if contact exists, if so, we'll need it's ID |
| | | $result = $TARGET->search('email', $a_record['email'], true, true); |
| | | |
| | | // insert contact record |
| | | if (!$result->count) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_create', array( |
| | | 'record' => $a_record, 'source' => $target, 'group' => $target_group)); |
| | | |
| | | if (!$plugin['abort']) { |
| | | if ($insert_id = $TARGET->insert($a_record, false)) { |
| | | $ids[] = $insert_id; |
| | | $success++; |
| | | } |
| | | } |
| | | else if ($plugin['result']) { |
| | | $ids = array_merge($ids, $plugin['result']); |
| | | $success++; |
| | | } |
| | | } |
| | | else { |
| | | $record = $result->first(); |
| | | $ids[] = $record['ID']; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (($cnt = $TARGET->add_to_group($target_group, $plugin['ids'])) && $cnt > $success) |
| | | $success = $cnt; |
| | | } |
| | | else if ($plugin['result']) |
| | | $success = $plugin['result']; |
| | | } |
| | | } |
| | | |
| | |
| | | ($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && |
| | | preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid) |
| | | ) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_delete', array('id' => $cid, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_delete', array( |
| | | 'id' => $cid, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | |
| | | $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : false; |
| | | if (!$deleted) |
| | | { |
| | | $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : $plugin['result']; |
| | | |
| | | if (!$deleted) { |
| | | // send error message |
| | | exit; |
| | | } |
| | |
| | | $CONTACTS->set_group($gid); |
| | | $num2add = count(explode(',', $plugin['ids'])); |
| | | |
| | | if (!$plugin['abort'] && ($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + $num2add > $maxnum)) |
| | | if (!$plugin['abort']) { |
| | | if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + $num2add > $maxnum)) { |
| | | $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); |
| | | else if (!$plugin['abort'] && $CONTACTS->add_to_group($gid, $plugin['ids'])) |
| | | $OUTPUT->send(); |
| | | } |
| | | $result = $CONTACTS->add_to_group($gid, $plugin['ids']); |
| | | } |
| | | else { |
| | | $result = $plugin['result']; |
| | | } |
| | | |
| | | if ($result) |
| | | $OUTPUT->show_message('contactaddedtogroup'); |
| | | else if ($plugin['message']) |
| | | $OUTPUT->show_message($plugin['message'], 'warning'); |
| | |
| | | if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('group_delmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source)); |
| | | |
| | | if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $plugin['ids'])) |
| | | if (!$plugin['abort']) |
| | | $result = $CONTACTS->remove_from_group($gid, $plugin['ids']); |
| | | else |
| | | $result = $plugin['result']; |
| | | |
| | | if ($result) |
| | | $OUTPUT->show_message('contactremovedfromgroup'); |
| | | else if ($plugin['message']) |
| | | $OUTPUT->show_message($plugin['message'], 'warning'); |
| | |
| | | else if ($RCMAIL->action == 'group-create') { |
| | | if ($name = trim(get_input_value('_name', RCUBE_INPUT_POST))) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('group_create', array('name' => $name, 'source' => $source)); |
| | | |
| | | if (!$plugin['abort']) |
| | | $created = $CONTACTS->create_group($plugin['name']); |
| | | else |
| | | $created = $plugin['result']; |
| | | } |
| | | |
| | | if ($created && $OUTPUT->ajax_call) { |
| | |
| | | else if ($RCMAIL->action == 'group-rename') { |
| | | if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('group_rename', array('group_id' => $gid, 'name' => $name, 'source' => $source)); |
| | | |
| | | if (!$plugin['abort']) |
| | | $newname = $CONTACTS->rename_group($gid, $plugin['name']); |
| | | else |
| | | $newname = $plugin['result']; |
| | | } |
| | | |
| | | if ($newname && $OUTPUT->ajax_call) |
| | |
| | | else if ($RCMAIL->action == 'group-delete') { |
| | | if ($gid = get_input_value('_gid', RCUBE_INPUT_POST)) { |
| | | $plugin = $RCMAIL->plugins->exec_hook('group_delete', array('group_id' => $gid, 'source' => $source)); |
| | | |
| | | if (!$plugin['abort']) |
| | | $deleted = $CONTACTS->delete_group($gid); |
| | | else |
| | | $deleted = $plugin['result']; |
| | | } |
| | | |
| | | if ($deleted) |
| | |
| | | $a_record = $plugin['record']; |
| | | |
| | | // insert record and send response |
| | | if (!$plugin['abort'] && ($success = $CONTACTS->insert($a_record))) { |
| | | if (!$plugin['abort']) |
| | | $success = $CONTACTS->insert($a_record); |
| | | else |
| | | $success = $plugin['result']; |
| | | |
| | | if ($success) { |
| | | $IMPORT_STATS->inserted++; |
| | | $IMPORT_STATS->names[] = $vcard->displayname; |
| | | } else { |
| | |
| | | array('id' => $cid, 'record' => $a_record, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $a_record = $plugin['record']; |
| | | |
| | | if (!$plugin['abort'] && ($result = $CONTACTS->update($cid, $a_record))) |
| | | { |
| | | if (!$plugin['abort']) |
| | | $result = $CONTACTS->update($cid, $a_record); |
| | | else |
| | | $result = $plugin['result']; |
| | | |
| | | if ($result) { |
| | | // LDAP DN change |
| | | if (is_string($result) && strlen($result)>1) { |
| | | $newcid = $result; |
| | |
| | | $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); |
| | | rcmail_overwrite_action('show'); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | // show error message |
| | | $OUTPUT->show_message('errorsaving', 'error', null, false); |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); |
| | | rcmail_overwrite_action('show'); |
| | | } |
| | | } |
| | | |
| | | // insert a new contact |
| | | else |
| | | { |
| | | else { |
| | | // check for existing contacts |
| | | $existing = $CONTACTS->search('email', $a_record['email'], true, false); |
| | | |
| | | // show warning message |
| | | if ($existing->count) |
| | | { |
| | | if ($existing->count) { |
| | | $OUTPUT->show_message('contactexists', 'warning', null, false); |
| | | rcmail_overwrite_action('add'); |
| | | return; |
| | | } |
| | | |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_create', array('record' => $a_record, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_create', array( |
| | | 'record' => $a_record, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $a_record = $plugin['record']; |
| | | |
| | | // insert record and send response |
| | | if (!$plugin['abort'] && ($insert_id = $CONTACTS->insert($a_record))) |
| | | { |
| | | if (!$plugin['abort']) |
| | | $insert_id = $CONTACTS->insert($a_record); |
| | | else |
| | | $insert_id = $plugin['result']; |
| | | |
| | | |
| | | if ($insert_id) { |
| | | // add contact row or jump to the page where it should appear |
| | | $CONTACTS->reset(); |
| | | $result = $CONTACTS->search($CONTACTS->primary_key, $insert_id); |
| | |
| | | $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | // show error message |
| | | $OUTPUT->show_message('errorsaving', 'error', null, false); |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); |
| | | rcmail_overwrite_action('add'); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_POST, true), 1, false); |
| | | |
| | | if (!empty($contact_arr[1]['mailto'])) |
| | | { |
| | | if (!empty($contact_arr[1]['mailto'])) { |
| | | $contact = array( |
| | | 'email' => $contact_arr[1]['mailto'], |
| | | 'name' => $contact_arr[1]['name'] |
| | |
| | | |
| | | // check for existing contacts |
| | | $existing = $CONTACTS->search('email', $contact['email'], true, false); |
| | | |
| | | if ($done = $existing->count) |
| | | $OUTPUT->show_message('contactexists', 'warning'); |
| | | else |
| | | { |
| | | else { |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null)); |
| | | $contact = $plugin['record']; |
| | | |
| | | if (!$plugin['abort'] && ($done = $CONTACTS->insert($contact))) |
| | | $done = !$plugin['abort'] ? $CONTACTS->insert($contact) : $plugin['result']; |
| | | |
| | | if ($done) |
| | | $OUTPUT->show_message('addedsuccessfully', 'confirmation'); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!$done) |
| | | $OUTPUT->show_message('errorsavingcontact', 'warning'); |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsavingcontact', 'warning'); |
| | | |
| | | $OUTPUT->send(); |
| | | |
| | |
| | | { |
| | | $plugin = $RCMAIL->plugins->exec_hook('identity_delete', array('id' => $iid)); |
| | | |
| | | if (!$plugin['abort'] && $USER->delete_identity($iid)) { |
| | | $deleted = !$plugin['abort'] ? $USER->delete_identity($iid) : $plugin['result']; |
| | | |
| | | if ($deleted) |
| | | $OUTPUT->show_message('deletedsuccessfully', 'confirmation', null, false); |
| | | } |
| | | else { |
| | | $OUTPUT->show_message('nodeletelastidentity', 'error', null, false); |
| | | } |
| | | else |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'nodeletelastidentity', 'error', null, false); |
| | | |
| | | // send response |
| | | if ($OUTPUT->ajax_call) |
| | | $OUTPUT->send(); |
| | |
| | | |
| | | // go to identities page |
| | | rcmail_overwrite_action('identities'); |
| | | |
| | | |
| | |
| | | if ($save_data['reply-to']) |
| | | $save_data['reply-to'] = idn_to_ascii($save_data['reply-to']); |
| | | |
| | | if (!$plugin['abort'] && ($updated = $USER->update_identity($iid, $save_data))) |
| | | { |
| | | if (!$plugin['abort']) |
| | | $updated = $USER->update_identity($iid, $save_data); |
| | | else |
| | | $updated = $plugin['result']; |
| | | |
| | | if ($updated) { |
| | | $OUTPUT->show_message('successfullysaved', 'confirmation'); |
| | | |
| | | if (!empty($_POST['_standard'])) |
| | | $default_id = get_input_value('_iid', RCUBE_INPUT_POST); |
| | | |
| | | if ($_POST['_framed']) |
| | | { |
| | | if ($_POST['_framed']) { |
| | | // update the changed col in list |
| | | // ... |
| | | } |
| | | } |
| | | else if ($plugin['abort'] || $DB->is_error()) |
| | | { |
| | | else { |
| | | // show error message |
| | | $OUTPUT->show_message('errorsaving', 'error', null, false); |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); |
| | | rcmail_overwrite_action('edit-identity'); |
| | | return; |
| | | } |
| | |
| | | $save_data['bcc'] = idn_to_ascii($save_data['bcc']); |
| | | $save_data['reply-to'] = idn_to_ascii($save_data['reply-to']); |
| | | |
| | | if (!$plugin['abort'] && $save_data['email'] && ($insert_id = $USER->insert_identity($save_data))) |
| | | { |
| | | if (!$plugin['abort']) |
| | | $insert_id = $save_data['email'] ? $USER->insert_identity($save_data) : null; |
| | | else |
| | | $insert_id = $plugin['result']; |
| | | |
| | | if ($insert_id) { |
| | | $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); |
| | | |
| | | $_GET['_iid'] = $insert_id; |
| | |
| | | if (!empty($_POST['_standard'])) |
| | | $default_id = $insert_id; |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | // show error message |
| | | $OUTPUT->show_message('errorsaving', 'error', null, false); |
| | | $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); |
| | | rcmail_overwrite_action('edit-identity'); |
| | | return; |
| | | } |
| | |
| | | |
| | | // go to next step |
| | | rcmail_overwrite_action('identities'); |
| | | |
| | | |