1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Prefs_Special_Trash extends IMP_Prefs_Special_SpecialMboxes implements Horde_Core_Prefs_Ui_Special
24: {
25: 26:
27: public function init(Horde_Core_Prefs_Ui $ui)
28: {
29: }
30:
31: 32:
33: public function display(Horde_Core_Prefs_Ui $ui)
34: {
35: global $injector, $page_output, $prefs;
36:
37: $page_output->addScriptFile('folderprefs.js');
38: $page_output->addInlineJsVars(array(
39: 'ImpFolderPrefs.mboxes.trash' => _("Enter the name for your new trash mailbox.")
40: ));
41:
42: $imp_search = $injector->getInstance('IMP_Search');
43: $trash = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH);
44:
45: $view = new Horde_View(array(
46: 'templatePath' => IMP_TEMPLATES . '/prefs'
47: ));
48: $view->addHelper('FormTag');
49: $view->addHelper('Horde_Core_View_Helper_Label');
50: $view->addHelper('Tag');
51:
52: $iterator = new IMP_Ftree_IteratorFilter(
53: $injector->getInstance('IMP_Ftree')
54: );
55: $iterator->add($iterator::NONIMAP);
56: $iterator->mboxes = array('INBOX');
57:
58: $view->flist = new IMP_Ftree_Select(array(
59: 'basename' => true,
60: 'iterator' => $iterator,
61: 'new_mbox' => true,
62: 'selected' => $trash
63: ));
64: $view->nombox = IMP_Mailbox::formTo(self::PREF_NO_MBOX);
65: $view->special_use = $this->_getSpecialUse(Horde_Imap_Client::SPECIALUSE_TRASH);
66:
67: if (!$prefs->isLocked('vfolder') || $imp_search['vtrash']->enabled) {
68: $view->vtrash = IMP_Mailbox::formTo($imp_search->createSearchId('vtrash'));
69: $view->vtrash_select = $trash->vtrash;
70: }
71:
72: return $view->render('trash');
73: }
74:
75: 76:
77: public function update(Horde_Core_Prefs_Ui $ui)
78: {
79: global $injector, $prefs;
80:
81: $imp_search = $injector->getInstance('IMP_Search');
82: $curr_vtrash = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH)->vtrash;
83: $trash = IMP_Mailbox::formFrom($ui->vars->trash);
84:
85: if (!$prefs->isLocked('vfolder')) {
86: $vtrash = $imp_search['vtrash'];
87: $vtrash->enabled = $trash->vtrash;
88: $imp_search['vtrash'] = $vtrash;
89: }
90:
91: if (!$this->_updateSpecialMboxes(IMP_Mailbox::MBOX_TRASH, $trash, $ui->vars->trash_new, Horde_Imap_Client::SPECIALUSE_TRASH, $ui)) {
92: return false;
93: }
94:
95: $injector->getInstance('IMP_Factory_Imap')->create()->updateFetchIgnore();
96:
97: 98:
99: if ($curr_vtrash || $trash->vtrash) {
100: $injector->getInstance('IMP_Factory_MailboxList')->expireAll();
101: }
102:
103: return true;
104: }
105:
106: }
107: