You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

undo.inc 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/addressbook/undo.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2011-2013, Kolab Systems AG |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Undelete contacts (CIDs) from last delete action |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Aleksander Machniak <machniak@kolabsys.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. // process ajax requests only
  21. if (!$OUTPUT->ajax_call) {
  22. return;
  23. }
  24. $undo = $_SESSION['contact_undo'];
  25. $delcnt = 0;
  26. foreach ((array)$undo['data'] as $source => $cid) {
  27. $CONTACTS = rcmail_contact_source($source);
  28. $plugin = $RCMAIL->plugins->exec_hook('contact_undelete', array(
  29. 'id' => $cid, 'source' => $source));
  30. $restored = !$plugin['abort'] ? $CONTACTS->undelete($cid) : $plugin['result'];
  31. if (!$restored) {
  32. $OUTPUT->show_message($plugin['message'] ?: 'contactrestoreerror', 'error');
  33. $OUTPUT->command('list_contacts');
  34. $OUTPUT->send();
  35. }
  36. else {
  37. $delcnt += $restored;
  38. }
  39. }
  40. $RCMAIL->session->remove('contact_undo');
  41. $OUTPUT->show_message('contactrestored', 'confirmation');
  42. $OUTPUT->command('list_contacts');
  43. // send response
  44. $OUTPUT->send();