1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: class IMP_Ajax_Application_Handler_Smartmobile
27: extends Horde_Core_Ajax_Application_Handler
28: {
29: 30:
31: public function __construct(Horde_Core_Ajax_Application $base)
32: {
33: parent::__construct($base);
34:
35:
36: $base->queue->quota(null);
37:
38:
39: $base->queue->poll(null);
40:
41: if ($this->vars->flag_config) {
42: $base->queue->flagConfig(Horde_Registry::VIEW_SMARTMOBILE);
43: }
44: }
45:
46: 47: 48: 49: 50: 51: 52: 53: 54:
55: public function smartmobileAutocomplete()
56: {
57: return array_map(
58: 'htmlspecialchars',
59: $GLOBALS['injector']->getInstance('IMP_Contacts')->searchEmail(
60: $this->vars->search,
61: array('levenshtein' => true)
62: )->base_addresses
63: );
64: }
65:
66: 67: 68: 69: 70:
71: public function smartmobileGetForwardData()
72: {
73: $result = $this->_base->callAction('getForwardData');
74:
75: if ($result && $result->opts->attach) {
76: $GLOBALS['notification']->push(_("Forwarded message will be automatically added to your outgoing message."), 'horde.message');
77: }
78:
79: return $result;
80: }
81:
82: 83: 84: 85: 86: 87: 88: 89: 90:
91: public function smartmobileFolderTree()
92: {
93: $ftree = $GLOBALS['injector']->getInstance('IMP_Ftree');
94:
95:
96: $this->_base->queue->poll($ftree->poll->getPollList(), true);
97:
98: $iterator = new AppendIterator();
99:
100:
101: $special = new ArrayIterator();
102: $special->append($ftree['INBOX']);
103: foreach (IMP_Mailbox::getSpecialMailboxesSort() as $val) {
104: if (isset($ftree[$val])) {
105: $special->append($ftree[$val]);
106: }
107: }
108: $iterator->append($special);
109:
110:
111: $filter = new IMP_Ftree_IteratorFilter($ftree);
112: $filter->add(array(
113: $filter::CONTAINERS,
114: $filter::REMOTE,
115: $filter::SPECIALMBOXES
116: ));
117: if (!$this->vars->all) {
118: $filter->add($filter::POLLED);
119: }
120: $filter->mboxes = array('INBOX');
121: $iterator->append($filter);
122:
123: return $ftree->createTree($this->vars->all ? 'smobile_folders_all' : 'smobile_folders', array(
124: 'iterator' => $iterator,
125: 'render_type' => 'IMP_Tree_Jquerymobile'
126: ))->getTree(true);
127: }
128:
129: 130: 131: 132: 133: 134: 135:
136: public function copyMoveMailboxList()
137: {
138: $iterator = new IMP_Ftree_IteratorFilter($GLOBALS['injector']->getInstance('IMP_Ftree'));
139: $iterator->add($iterator::REMOTE);
140:
141: return strval(new IMP_Ftree_Select(array(
142: 'heading' => _("This message to"),
143: 'iterator' => $iterator,
144: 'optgroup' => true,
145: 'inc_tasklists' => true,
146: 'inc_notepads' => true,
147: 'new_mbox' => true
148: )));
149: }
150:
151: 152: 153: 154: 155: 156: 157:
158: public function smartmobileSendMessage()
159: {
160: global $injector, $prefs;
161:
162: $identity = $injector->getInstance('IMP_Identity');
163: $send_id = $prefs->isLocked('default_identity')
164: ? null
165: : $this->vars->identity;
166:
167: 168:
169: if ($identity->getValue('save_sent_mail', $send_id)) {
170: $sent_mbox = $identity->getValue(IMP_Mailbox::MBOX_SENT, $send_id);
171: if ($sent_mbox && !$sent_mbox->readonly) {
172: $this->vars->save_sent_mail = true;
173: $this->vars->save_sent_mail_mbox = $sent_mbox->form_to;
174: }
175: }
176:
177: return $this->_base->callAction('sendMessage');
178: }
179:
180: }
181: