4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/undo.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2011, Kolab Systems AG |
9 | Licensed under the GNU GPL |
12 | Undelete contacts (CIDs) from last delete action |
14 +-----------------------------------------------------------------------+
15 | Author: Aleksander Machniak <machniak@kolabsys.com> |
16 +-----------------------------------------------------------------------+
18 $Id: undo.inc 4916 2011-07-07 11:44:26Z alec $
22 // process ajax requests only
23 if (!$OUTPUT->ajax_call)
26 $undo = $_SESSION['contact_undo'];
29 foreach ((array)$undo['data'] as $source => $cid)
31 $CONTACTS = rcmail_contact_source($source);
33 $plugin = $RCMAIL->plugins->exec_hook('contact_undelete', array(
34 'id' => $cid, 'source' => $source));
36 $restored = !$plugin['abort'] ? $CONTACTS->undelete($cid) : $plugin['result'];
39 $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'contactrestoreerror', 'error');
40 $OUTPUT->command('list_contacts');
48 // update saved search after data changed
49 if ($delcnt && ($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$search_request])) {
50 $search = (array)$_SESSION['search'][$search_request];
52 foreach ($search as $s => $set) {
53 $source = $RCMAIL->get_address_book($s);
57 $source->set_pagesize(9999);
58 $source->set_search_set($set);
61 $result = $source->list_records(array('name', 'email'));
63 if (!$result->count) {
68 while ($row = $result->next()) {
69 $row['sourceid'] = $s;
70 $key = $row['name'] . ':' . $row['sourceid'];
71 $records[$key] = $row;
75 $search[$s] = $source->get_search_set();
78 $_SESSION['search'][$search_request] = $search;
81 $RCMAIL->session->remove('contact_undo');
83 $OUTPUT->show_message('contactrestored', 'confirmation');
84 $OUTPUT->command('list_contacts');