source: branches/2.2/mobile/inc/class.ui_home.inc.php @ 3571

Revision 3571, 6.3 KB checked in by eduardoalex, 14 years ago (diff)

Ticket #1408 - Modificado o layout da tela de enviar email do expresso mini.

Line 
1<?php
2    class ui_home {
3                var $imap_functions;
4                var $db;
5                var $bocalendar;
6                var $common;
7                var $template;
8       
9                var $public_functions = array(
10                        'index' => true,
11                        'search' => true
12                );
13               
14                function ui_home() {
15                        $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
16                        $this->common   = CreateObject('mobile.common_functions');
17                        $this->imap_functions   = CreateObject('expressoMail1_2.imap_functions');
18                        $this->db       = CreateObject('phpgwapi.db');
19                        $this->bocalendar = CreateObject('calendar.bocalendar');
20                }
21               
22                function index($params) {
23                        $this->template->set_file(array('home_index' => 'home_index.tpl'));
24                        $this->template->set_block('home_index','page');       
25                        $this->template->set_block('home_index','folder_block');
26                        $this->template->set_block('home_index','commitment_block');
27                       
28                        //langs
29                        $this->template->set_var('lang_context_email', lang("context email"));
30                        $this->template->set_var('lang_context_contact', lang("context contact"));
31                        $this->template->set_var('lang_context_commitment', lang("context commitment"));
32                        $this->template->set_var('lang_search', lang("search"));
33                        $this->template->set_var('lang_my_mail', lang("my mail"));
34                        $this->template->set_var('lang_my_folders', lang("my folders"));
35                        $this->template->set_var('lang_my_commitments', lang("my commitments"));
36      $this->template->set_var('lang_my_contacts', lang("my contacts"));
37                        $this->template->set_var('lang_new_mail', lang("new mail"));
38                        $this->template->set_var('lang_mark_as_read', lang("mark as read"));
39                        $this->template->set_var('lang_selected', lang("selected"));
40                       
41                        $accountId = $GLOBALS['phpgw_info']['user']['account_id'];
42                       
43                        //pegando as pastas
44                        $default_folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'default', 'noQuotaInfo' => true));
45                        $total_quota = $this->imap_functions->get_quota(array());               
46                                       
47                        $this->set_folder_block($default_folders, "default_folders_box");
48                       
49                        if(isset($params["expand_folders"]) && $params["expand_folders"] == 1)
50                        {
51                                $personal_folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'personal', 'noQuotaInfo' => true));
52                                $this->set_folder_block($personal_folders, "personal_folders_box", sizeof($default_folders));
53                                $this->template->set_var('expand_folders', 0);                 
54                        } else {
55                                $this->template->set_var('expand_folders', 1);
56                        }
57                       
58                        $this->template->set_var('quota_percent', $total_quota["quota_percent"]);
59                        $this->template->set_var('quota_used', $this->common->borkb($total_quota["quota_used"]*1024));
60                        $this->template->set_var('quota_limit', $this->common->borkb($total_quota["quota_limit"]*1024));
61                       
62                        //pegando os eventos do dia atual
63                        $year = $this->bocalendar->year;
64                        $month = $this->bocalendar->month;
65                        $day = $this->bocalendar->day;
66                       
67                        $tstart = mktime(0,0,0,$month,$day,$year);
68                       
69                        $tstop = $tstart + 86400; //(24horas*60min*60seg*1dia)                 
70                        $this->bocalendar->so->owner = $accountId;
71                        $this->bocalendar->so->open_box($accountId);
72                        $this->bocalendar->store_to_cache( array(
73                                'owner' => $accountId,
74                                'syear'  => date('Y',$tstart),
75                                'smonth' => date('m',$tstart),
76                                'sday'   => date('d',$tstart),
77                                'eyear'  => date('Y',$tstop),
78                                'emonth' => date('m',$tstop),
79                                'eday'   => date('d',$tstop)
80                        ) );
81                       
82                        $events  = $this->bocalendar->cached_events;
83                       
84                        foreach($events[$year.$this->common->complete_string($month,2,"R","0").$this->common->complete_string($day,2,"R","0")] as $index=>$event)
85                        {
86                                $this->template->set_var('dd_class', (($index%2==0) ? "par" : "") );
87                                $this->template->set_var('commitment_time', $this->common->complete_string($event["start"]["hour"],2,"R","0") .":". $this->common->complete_string($event["start"]["min"],2,"R","0") );
88                                $this->template->set_var('commitment_title', $event["title"] );
89                               
90                                $this->template->parse('commitments_box', 'commitment_block' ,True);
91                        }
92                       
93                        $GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]);
94                        $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page'));
95                }
96               
97                /**
98                 *
99                 *
100                 * $index_increment utilizado para quando passar o array das pastas pessoais somar com a quantidade de pastas default.
101                 */
102                function set_folder_block($folders, $box_target, $index_increment = 0) {
103                        foreach($folders as $index=>$folder)
104                        {
105                                $this->template->set_var('dd_class', (($index%2==0) ? "par" : "") );
106                                $this->template->set_var('folder_id', $index + $index_increment );
107                                $this->template->set_var('folder_name', $folder["folder_name"] );
108                                $this->template->set_var('folder_unseen', $folder["folder_unseen"] );
109                               
110                                $this->imap_functions->open_mbox($folder["folder_id"],true);
111                                $this->template->set_var('folder_total_msg', $this->imap_functions->get_num_msgs(array('folder' => $folder["folder_id"] ) ) );
112                               
113                                $this->template->parse($box_target, 'folder_block' ,true);
114                        }
115                }
116               
117        function search($params) {
118                        $params['name'] = 'teste';
119                        $params['default_folders'] = 1;
120
121                        //Contacts                     
122                        $bo_cc =  CreateObject('mobile.bo_mobilecc');
123                       
124                        $catalogs = $bo_cc->get_all_catalogs();
125
126                        $contacts_result = array();
127                        foreach($catalogs as $catalog) {
128                                $bo_cc->set_catalog($catalog['catalog']);
129                                $partial_result = $bo_cc->search($params['name']);
130                                $contacts_result = array_merge($contacts_result,$partial_result);
131                        }
132
133                        //E-mails
134                        $no_mail_search=false;
135                        $imap_functions = CreateObject('expressoMail1_2.imap_functions');
136                        $mail_params = array('filter' => $params["name"]);
137                        if(isset($params['default_folders'])) {
138                                if(!isset($params['personal_folders']))
139                                        $mail_params['folderType'] = 'default';                 
140                        }
141                        else {
142                                if(isset($params['personal_folders']))
143                                        $mail_params['folderType'] = 'personal';
144                                else
145                                        $no_mail_search = true;
146                        }
147                       
148                        if(!$no_mail_search)
149                                $messages = $imap_functions->mobile_search($mail_params);
150                       
151                        //calendar
152                        ini_set('display_errors','1');
153                        $bo_calendar = CreateObject('calendar.bocalendar',1);
154                        $event_ids = $bo_calendar->search_keywords($params['name']);
155                        foreach($event_ids as $key => $id)
156                        {
157                                $event = $bo_calendar->read_entry($id);
158
159                                if(!$bo_calendar->check_perms(PHPGW_ACL_READ,$event))
160                                {
161                                        continue;
162                                }
163
164                                //TODO Montar as linhas com os eventos
165               
166                        }
167                }
168               
169        }
170?>
Note: See TracBrowser for help on using the repository browser.