true, 'search' => true ); function ui_home() { $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); $this->common = CreateObject('mobile.common_functions'); $this->imap_functions = CreateObject('expressoMail1_2.imap_functions'); $this->db = CreateObject('phpgwapi.db'); $this->bocalendar = CreateObject('calendar.bocalendar'); } function index($params) { $this->template->set_file(Array('home_index' => 'home_index.tpl')); $this->template->set_block('home_index','page'); $this->template->set_block('home_index','folder_block'); $this->template->set_block('home_index','commitment_block'); //langs $this->template->set_var('lang_context_email', lang("context email")); $this->template->set_var('lang_context_contact', lang("context contact")); $this->template->set_var('lang_context_commitment', lang("context commitment")); $this->template->set_var('lang_search', lang("search")); $this->template->set_var('lang_my_mail', lang("my mail")); $this->template->set_var('lang_my_folders', lang("my folders")); $this->template->set_var('lang_my_commitments', lang("my commitments")); $this->template->set_var('lang_new_mail', lang("new mail")); $this->template->set_var('lang_mark_as_read', lang("mark as read")); $this->template->set_var('lang_selected', lang("selected")); $accountId = $GLOBALS['phpgw_info']['user']['account_id']; //pegando as pastas $default_folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'default', 'noQuotaInfo' => true)); $total_quota = $this->imap_functions->get_quota(array()); $this->set_folder_block($default_folders, "default_folders_box"); if(isset($params["expand_folders"]) && $params["expand_folders"] == 1) { $personal_folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'personal', 'noQuotaInfo' => true)); $this->set_folder_block($personal_folders, "personal_folders_box", sizeof($default_folders)); $this->template->set_var('expand_folders', 0); } else { $this->template->set_var('expand_folders', 1); } $this->template->set_var('quota_percent', $total_quota["quota_percent"]); $this->template->set_var('quota_used', $this->common->borkb($total_quota["quota_used"]*1024)); $this->template->set_var('quota_limit', $this->common->borkb($total_quota["quota_limit"]*1024)); //pegando os eventos do dia atual $year = $this->bocalendar->year; $month = $this->bocalendar->month; $day = $this->bocalendar->day; $tstart = mktime(0,0,0,$month,$day,$year); //$tstart = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day); $tstop = $tstart + 86400; //(24horas*60min*60seg*1dia) $this->bocalendar->so->owner = $accountId; $this->bocalendar->so->open_box($accountId); $this->bocalendar->store_to_cache( array( 'owner' => $accountId, 'syear' => date('Y',$tstart), 'smonth' => date('m',$tstart), 'sday' => date('d',$tstart), 'eyear' => date('Y',$tstop), 'emonth' => date('m',$tstop), 'eday' => date('d',$tstop) ) ); $events = $this->bocalendar->cached_events; foreach($events[$year.$this->common->complete_string($month,2,"R","0").$this->common->complete_string($day,2,"R","0")] as $index=>$event) { $this->template->set_var('dd_class', (($index%2==0) ? "par" : "") ); $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") ); $this->template->set_var('commitment_title', $event["title"] ); $this->template->parse('commitments_box', 'commitment_block' ,True); } $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page')); } /** * * * $index_increment utilizado para quando passar o array das pastas pessoais somar com a quantidade de pastas default. */ function set_folder_block($folders, $box_target, $index_increment = 0) { foreach($folders as $index=>$folder) { $this->template->set_var('dd_class', (($index%2==0) ? "par" : "") ); $this->template->set_var('folder_id', $index + $index_increment ); $this->template->set_var('folder_name', $folder["folder_name"] ); $this->template->set_var('folder_unseen', $folder["folder_unseen"] ); $this->imap_functions->open_mbox($folder["folder_id"],true); $this->template->set_var('folder_total_msg', $this->imap_functions->get_num_msgs(array('folder' => $folder["folder_id"] ) ) ); $this->template->parse($box_target, 'folder_block' ,True); } } function search($params) { $params['name'] = 'teste'; $params['default_folders'] = 1; //Contacts $bo_cc = CreateObject('mobile.bo_mobilecc'); $catalogs = $bo_cc->get_all_catalogs(); $contacts_result = array(); foreach($catalogs as $catalog) { $bo_cc->set_catalog($catalog['catalog']); $partial_result = $bo_cc->search($params['name']); $contacts_result = array_merge($contacts_result,$partial_result); } // print_r($contacts_result); //E-mails $no_mail_search=false; $imap_functions = CreateObject('expressoMail1_2.imap_functions'); $mail_params = array('filter' => $params["name"]); if(isset($params['default_folders'])) { if(!isset($params['personal_folders'])) $mail_params['folderType'] = 'default'; } else { if(isset($params['personal_folders'])) $mail_params['folderType'] = 'personal'; else $no_mail_search = true; } if(!$no_mail_search) $messages = $imap_functions->mobile_search($mail_params); // print_r($messages); //calendar ini_set('display_errors','1'); $bo_calendar = CreateObject('calendar.bocalendar',1); $event_ids = $bo_calendar->search_keywords($params['name']); foreach($event_ids as $key => $id) { $event = $bo_calendar->read_entry($id); if(!$bo_calendar->check_perms(PHPGW_ACL_READ,$event)) { continue; } //TODO Montar as linhas com os eventos } } /* TODO Temporário esse método */ function debug($var) { echo "
";
			print_r($var);
			echo "
"; } } ?>