From: Michael M Slusarz Date: Tue, 25 Aug 2009 16:08:52 +0000 (-0600) Subject: Use IMP_Imap_Flags::getFlagList() to build the flag menu for searches. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=619cbf77c784a058a2242af443b927b2c0b8eefc;p=horde.git Use IMP_Imap_Flags::getFlagList() to build the flag menu for searches. --- diff --git a/imp/lib/UI/Search.php b/imp/lib/UI/Search.php index 89dc9178b..22f6feab8 100644 --- a/imp/lib/UI/Search.php +++ b/imp/lib/UI/Search.php @@ -21,10 +21,6 @@ class IMP_UI_Search const TEXT = 4; const SIZE = 5; - /* Defines used to identify the flag input. */ - const FLAG_NOT = 0; - const FLAG_HAS = 1; - /** * Return the base search fields. * @@ -105,48 +101,17 @@ class IMP_UI_Search */ public function flagFields() { - return array( - 'seen' => array( - 'flag' => '\\seen', - 'label' => _("Seen messages"), - 'type' => self::FLAG_HAS - ), - 'unseen' => array( - 'flag' => '\\seen', - 'label' => _("Unseen messages"), - 'type' => self::FLAG_NOT - ), - 'answered' => array( - 'flag' => '\\answered', - 'label' => _("Answered messages"), - 'type' => self::FLAG_HAS - ), - 'unanswered' => array( - 'flag' => '\\answered', - 'label' => _("Unanswered messages"), - 'type' => self::FLAG_NOT - ), - 'flagged' => array( - 'flag' => '\\flagged', - 'label' => _("Flagged messages"), - 'type' => self::FLAG_HAS - ), - 'unflagged' => array( - 'flag' => '\\flagged', - 'label' => _("Unflagged messages"), - 'type' => self::FLAG_NOT - ), - 'deleted' => array( - 'flag' => '\\deleted', - 'label' => _("Deleted messages"), - 'type' => self::FLAG_HAS - ), - 'undeleted' => array( - 'flag' => '\\deleted', - 'label' => _("Undeleted messages"), - 'type' => self::FLAG_NOT - ), - ); + $imp_flags = IMP_Imap_Flags::singleton(); + $flist = $imp_flags->getFlagList(null); + + $flags = array(); + + for ($i = 0, $cnt = count($flist['set']); $i < $cnt; ++$i) { + $flags[$flist['set'][$i]['f']] = $flist['set'][$i]['l']; + $flags[$flist['unset'][$i]['f']] = sprintf(_("Not %s"), $flist['unset'][$i]['l']); + } + + return $flags; } /** @@ -168,7 +133,12 @@ class IMP_UI_Search $ob = new Horde_Imap_Client_Search_Query(); if (isset($flag_fields[$val])) { - $ob->flag($flag_fields[$val]['flag'], (bool)$flag_fields[$val]['type']); + if (strpos($val, '0\\') === 0) { + $val = substr($val, 2); + $ob->flag($val, false); + } else { + $ob->flag($val, true); + } $search_array[] = $ob; } else { switch ($search_fields[$val]['type']) { diff --git a/imp/search-basic.php b/imp/search-basic.php index c0acd7e77..452161ed0 100644 --- a/imp/search-basic.php +++ b/imp/search-basic.php @@ -41,7 +41,7 @@ $search_mailbox = Horde_Util::getFormData('search_mailbox'); foreach ($imp_ui_search->searchFields() as $key => $val) { if ($val['type'] != IMP_UI_Search::DATE) { - $s_fields[$key] = array( + $s_fields[] = array( 'val' => $key, 'label' => $val['label'] ); @@ -49,9 +49,9 @@ foreach ($imp_ui_search->searchFields() as $key => $val) { } foreach ($imp_ui_search->flagFields() as $key => $val) { - $f_fields[$key] = array( + $f_fields[] = array( 'val' => $key, - 'label' => $val['label'] + 'label' => $val ); } diff --git a/imp/search.php b/imp/search.php index f7449822f..0710afedc 100644 --- a/imp/search.php +++ b/imp/search.php @@ -201,7 +201,7 @@ foreach ($imp_search_fields as $key => $val) { foreach ($imp_ui_search->flagFields() as $key => $val) { $f_fields[$key] = array( 'val' => $key, - 'label' => $val['label'], + 'label' => $val, 'sel' => null ); }