From: Michael M Slusarz Date: Tue, 25 Aug 2009 17:15:28 +0000 (-0600) Subject: Do parsing of flag form IDs in IMP_Imap_Flags:: X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5fa1d924ecaba1a2217720fab3f38453903924f7;p=horde.git Do parsing of flag form IDs in IMP_Imap_Flags:: --- diff --git a/imp/lib/Imap/Flags.php b/imp/lib/Imap/Flags.php index 4add4d66a..298965bc6 100644 --- a/imp/lib/Imap/Flags.php +++ b/imp/lib/Imap/Flags.php @@ -388,4 +388,23 @@ class IMP_Imap_Flags return '
'; } + /** + * Process a flag ID formatted for use in form data. + * + * @param string $id The ID from form data. + * + * @return array Two element array: + *
+     * 'flag' - (string) The flag name.
+     * 'set' - (boolean) Whether the flag should be set or not.
+     * 
+ */ + public function parseFormId($id) + { + if (strpos($id, '0\\') === 0) { + return array('flag' => substr($id, 2), 'set' => false); + } + return array('flag' => $id, 'set' => true); + } + } diff --git a/imp/lib/UI/Search.php b/imp/lib/UI/Search.php index 22f6feab8..2b097bfb4 100644 --- a/imp/lib/UI/Search.php +++ b/imp/lib/UI/Search.php @@ -128,17 +128,14 @@ class IMP_UI_Search $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']) { diff --git a/imp/mailbox.php b/imp/mailbox.php index 9dfbeeef4..2c56bdaad 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -76,6 +76,7 @@ if (!is_array(($indices = Horde_Util::getFormData('indices')))) { Horde_Nls::setTimeZone(); $do_filter = false; +$imp_flags = IMP_Imap_Flags::singleton(); $open_compose_window = null; /* Run through the action handlers */ @@ -167,13 +168,9 @@ case 'copy_messages': 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; @@ -480,8 +477,6 @@ if (empty($pageOb['end'])) { 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'); diff --git a/imp/message.php b/imp/message.php index a998e27db..294cb1f1d 100644 --- a/imp/message.php +++ b/imp/message.php @@ -77,6 +77,8 @@ $index = $index_array['index']; $mailbox_name = $index_array['mailbox']; $indices_array = array($mailbox_name => array($index)); +$imp_flags = IMP_Imap_Flags::singleton(); + switch ($actionID) { case 'blacklist': case 'whitelist': @@ -143,12 +145,9 @@ case 'notspam_report': 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'; @@ -379,8 +378,6 @@ $mailbox_url = Horde_Util::addParameter(IMP::generateIMPUrl('mailbox.php', $imp_ /* 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. */