return '<div class="msgflags ' . $c . '" title="' . htmlspecialchars($l) . '"></div>';
}
+ /**
+ * Process a flag ID formatted for use in form data.
+ *
+ * @param string $id The ID from form data.
+ *
+ * @return array Two element array:
+ * <pre>
+ * 'flag' - (string) The flag name.
+ * 'set' - (boolean) Whether the flag should be set or not.
+ * </pre>
+ */
+ public function parseFormId($id)
+ {
+ if (strpos($id, '0\\') === 0) {
+ return array('flag' => substr($id, 2), 'set' => false);
+ }
+ return array('flag' => $id, 'set' => true);
+ }
+
}
$search_array = array();
$search_fields = $this->searchFields();
$flag_fields = $this->flagFields();
+ $imp_flags = IMP_Imap_Flags::singleton();
foreach ($search['field'] as $key => $val) {
$ob = new Horde_Imap_Client_Search_Query();
if (isset($flag_fields[$val])) {
- if (strpos($val, '0\\') === 0) {
- $val = substr($val, 2);
- $ob->flag($val, false);
- } else {
- $ob->flag($val, true);
- }
+ $val = $imp_flags->parseFormId($val);
+ $ob->flag($val['flag'], $val['set']);
$search_array[] = $ob;
} else {
switch ($search_fields[$val]['type']) {
Horde_Nls::setTimeZone();
$do_filter = false;
+$imp_flags = IMP_Imap_Flags::singleton();
$open_compose_window = null;
/* Run through the action handlers */
case 'flag_messages':
$flag = Horde_Util::getPost('flag');
if ($flag && !empty($indices)) {
- $set = true;
- if (strpos($flag, '0\\') === 0) {
- $flag = substr($flag, 2);
- $set = false;
- }
+ $flag = $imp_imap_flags->parseFormId($flag);
$imp_message = IMP_Message::singleton();
- $imp_message->flag(array($flag), $indices, $set);
+ $imp_message->flag(array($flag['flag']), $indices, $flag['set']);
}
break;
exit;
}
-$imp_flags = IMP_Imap_Flags::singleton();
-
/* Display the navbar and actions if there is at least 1 message in mailbox. */
if ($pageOb['msgcount']) {
$use_trash = $prefs->getValue('use_trash');
$mailbox_name = $index_array['mailbox'];
$indices_array = array($mailbox_name => array($index));
+$imp_flags = IMP_Imap_Flags::singleton();
+
switch ($actionID) {
case 'blacklist':
case 'whitelist':
case 'flag_message':
$flag = Horde_Util::getFormData('flag');
if ($flag && !empty($indices_array)) {
- $peek = $set = true;
- if (strpos($flag, '0\\') === 0) {
- $flag = substr($flag, 2);
- $set = false;
- }
- $imp_message->flag(array($flag), $indices_array, $set);
+ $peek = true;
+ $flag = $imp_flags->parseFormId($flag);
+ $imp_message->flag(array($flag['flag']), $indices_array, $flag['set']);
if ($prefs->getValue('mailbox_return')) {
_returnToMailbox($imp_mailbox->getMessageIndex());
require IMP_BASE . '/mailbox.php';
/* Generate the view link. */
$view_link = IMP::generateIMPUrl('view.php', $imp_mbox['mailbox'], $index, $mailbox_name);
-$imp_flags = IMP_Imap_Flags::singleton();
-
/* Everything below here is related to preparing the output. */
/* Set the status information of the message. */