-
Notifications
You must be signed in to change notification settings - Fork 127
/
Smartmobile.php
175 lines (154 loc) · 5.28 KB
/
Smartmobile.php
1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @category Horde
* @copyright 2012-2014 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
/**
* Defines AJAX actions used exclusively in the IMP smartmobile view.
*
* Global tasks:
- flag_config: (boolean) True if flag information is needed.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2012-2014 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
class IMP_Ajax_Application_Handler_Smartmobile
extends Horde_Core_Ajax_Application_Handler
{
/**
*/
public function __construct(Horde_Core_Ajax_Application $base)
{
parent::__construct($base);
/* Disable quota - not used in smartmobile for now. */
$base->queue->quota(null);
/* Disable implicit polling - not used in smartmobile for now. */
$base->queue->poll(null);
if ($this->vars->flag_config) {
$base->queue->flagConfig(Horde_Registry::VIEW_SMARTMOBILE);
}
}
/**
* AJAX action: Get autocomplete data.
*
* Variables used:
* - search: (string) The address search string.
*
* @return array Returns an array of matched addresses (full address),
* which are HTML escaped.
*/
public function smartmobileAutocomplete()
{
$imple = new IMP_Ajax_Imple_ContactAutoCompleter();
return array_map('htmlspecialchars', $imple->getAddressList($this->vars->search)->base_addresses);
}
/**
* AJAX action: Get forward compose data.
*
* @see IMP_Ajax_Application#getForwardData()
*/
public function smartmobileGetForwardData()
{
$result = $this->_base->callAction('getForwardData');
if ($result && $result->opts->attach) {
$GLOBALS['notification']->push(_("Forwarded message will be automatically added to your outgoing message."), 'horde.message');
}
return $result;
}
/**
* AJAX action: Check access rights for creation of a submailbox.
*
* Variables used:
* - all: (integer) If 1, return all mailboxes. Otherwise, return only
* INBOX, special mailboxes, and polled mailboxes.
*
* @return string HTML to use for the folder tree.
*/
public function smartmobileFolderTree()
{
$ftree = $GLOBALS['injector']->getInstance('IMP_Ftree');
/* Poll all mailboxes on initial display. */
$this->_base->queue->poll($ftree->poll->getPollList(), true);
$iterator = new AppendIterator();
/* Add special mailboxes explicitly. INBOX should appear first. */
$special = new ArrayIterator();
$special->append($ftree['INBOX']);
foreach (IMP_Mailbox::getSpecialMailboxesSort() as $val) {
if (isset($ftree[$val])) {
$special->append($ftree[$val]);
}
}
$iterator->append($special);
/* Now add polled mailboxes. */
$filter = new IMP_Ftree_IteratorFilter($ftree);
$filter->add(array(
$filter::CONTAINERS,
$filter::REMOTE,
$filter::SPECIALMBOXES
));
if (!$this->vars->all) {
$filter->add($filter::POLLED);
}
$filter->mboxes = array('INBOX');
$iterator->append($filter);
return $ftree->createTree($this->vars->all ? 'smobile_folders_all' : 'smobile_folders', array(
'iterator' => $iterator,
'render_type' => 'IMP_Tree_Jquerymobile'
))->getTree(true);
}
/**
* Return the copy/move selection list.
*
* Variables used: NONE
*
* @return string HTML to use for the folder tree.
*/
public function copyMoveMailboxList()
{
$iterator = new IMP_Ftree_IteratorFilter($GLOBALS['injector']->getInstance('IMP_Ftree'));
$iterator->add($iterator::REMOTE);
return strval(new IMP_Ftree_Select(array(
'heading' => _("This message to"),
'iterator' => $iterator,
'optgroup' => true,
'inc_tasklists' => true,
'inc_notepads' => true,
'new_mbox' => true
)));
}
/**
* AJAX action: Send message.
*
* @see IMP_Ajax_Application#getForwardData()
*
* @return string HTML to use for the folder tree.
*/
public function smartmobileSendMessage()
{
global $injector, $prefs;
$identity = $injector->getInstance('IMP_Identity');
$send_id = $prefs->isLocked('default_identity')
? null
: $this->vars->identity;
/* There is no sent-mail config option on smartmobile compose page,
* so need to add that information now. */
if ($identity->getValue('save_sent_mail', $send_id)) {
$sent_mbox = $identity->getValue(IMP_Mailbox::MBOX_SENT, $send_id);
if ($sent_mbox && !$sent_mbox->readonly) {
$this->vars->save_sent_mail = true;
$this->vars->save_sent_mail_mbox = $sent_mbox->form_to;
}
}
return $this->_base->callAction('sendMessage');
}
}