1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Basic_Searchbasic extends IMP_Basic_Base
24: {
25: 26:
27: protected function _init()
28: {
29: global $injector, $notification;
30:
31: if (!$this->indices->mailbox->access_search) {
32: $notification->push(_("Searching is not available."), 'horde.error');
33: $this->indices->mailbox->url('mailbox')->redirect();
34: }
35:
36: $imp_flags = $injector->getInstance('IMP_Flags');
37: $imp_search = $injector->getInstance('IMP_Search');
38:
39:
40: if ($this->vars->search_basic) {
41: $c_list = array();
42:
43: if ($this->vars->search_criteria_text) {
44: switch ($this->vars->search_criteria) {
45: case 'from':
46: case 'subject':
47: $c_list[] = new IMP_Search_Element_Header(
48: $this->vars->search_criteria_text,
49: $this->vars->search_criteria,
50: $this->vars->search_criteria_not
51: );
52: break;
53:
54: case 'recip':
55: $c_list[] = new IMP_Search_Element_Recipient(
56: $this->vars->search_criteria_text,
57: $this->vars->search_criteria_not
58: );
59: break;
60:
61: case 'body':
62: case 'text':
63: $c_list[] = new IMP_Search_Element_Text(
64: $this->vars->search_criteria_text,
65: ($this->vars->search_criteria == 'body'),
66: $this->vars->search_criteria_not
67: );
68: break;
69: }
70: }
71:
72: if ($this->vars->search_criteria_flag) {
73: $formdata = $imp_flags->parseFormId($this->vars->search_criteria_flag);
74: $c_list[] = new IMP_Search_Element_Flag(
75: $formdata['flag'],
76: ($formdata['set'] && !$this->vars->search_criteria_flag_not)
77: );
78: }
79:
80: if (empty($c_list)) {
81: $notification->push(_("No search criteria specified."), 'horde.error');
82: } else {
83:
84: $q_ob = $imp_search->createQuery($c_list, array(
85: 'id' => IMP_Search::BASIC_SEARCH,
86: 'mboxes' => array($this->indices->mailbox),
87: 'type' => IMP_Search::CREATE_QUERY
88: ));
89:
90:
91: IMP_Mailbox::get($q_ob)->url('mailbox')->redirect();
92: }
93: }
94:
95: $flist = $imp_flags->getList(array(
96: 'imap' => true,
97: 'mailbox' => $this->indices->mailbox
98: ));
99: $flag_set = array();
100: foreach ($flist as $val) {
101: $flag_set[] = array(
102: 'val' => $val->form_set,
103: 'label' => $val->label
104: );
105: }
106:
107:
108: $view = new Horde_View(array(
109: 'templatePath' => IMP_TEMPLATES . '/basic/search'
110: ));
111: $view->addHelper('FormTag');
112: $view->addHelper('Tag');
113:
114: $view->action = self::url();
115: $view->advsearch = Horde::link($this->indices->mailbox->url(IMP_Basic_Search::url()));
116: $view->mbox = $this->indices->mailbox->form_to;
117: $view->search_title = sprintf(_("Search %s"), $this->indices->mailbox->display_html);
118: $view->flist = $flag_set;
119:
120: $this->title = _("Search");
121: $this->output = $view->render('search-basic');
122: }
123:
124: 125:
126: public static function url(array $opts = array())
127: {
128: return Horde::url('basic.php')->add('page', 'searchbasic');
129: }
130:
131: }
132: