* * http://www.radix.net/~cknudsen * * Modified by Mark Peters * * -------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ class uiicalendar { var $bo; var $template; var $public_functions = array( 'test' => True, 'import' => True, 'import_from_mail' => True ); function uiicalendar() { $this->bo = CreateObject('calendar.boicalendar'); $this->template = $GLOBALS['phpgw']->template; $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Calendar - [iv]Cal Importer'); } function print_test($val,$title,$x_pre='') { // echo 'VAL = '._debug_array($val,False)."
\n"; if(is_array($val)) { @reset($val); while(list($key,$value) = each($val)) { if(is_array($key)) { $this->print_test($key,$title,$x_pre); } elseif(is_array($value)) { $this->print_test($value,$title,$x_pre); } else { if($x_pre && $key == 'name') { $x_key = $x_pre.$value; list($key,$value) = each($val); $key=$x_key; } if($this->bo->parameter[$key]['type'] == 'function') { $function = $this->bo->parameter[$key]['function']; $v_value = $this->bo->$function($value); } else { $v_value = $value; } echo $title.' ('.$key.') = '.$v_value."
\n"; } } } elseif($val != '') { echo $title.' = '.$val."
\n"; } } function import_from_mail() { $msg_number = $_GET['msg_number']; $idx_file = $_GET['idx_file']; $newfilename = $_GET['newfilename']; $msg_part = $_GET['msg_part']; $msg_folder = $_GET['msg_folder']; $encoding = strtolower($_GET['encoding']); $fileContent = ""; if($msg_number && $msg_part && $msg_folder && (intval($idx_file == '0' ? '1' : $idx_file))) { $username = $_SESSION['phpgw_info']['expressomail']['user']['userid']; $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd']; $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; $imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort']; if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') { $imap_options = '/tls/novalidate-cert'; } else { $imap_options = '/notls/novalidate-cert'; } $mbox_stream = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password); $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); $imap_attachment = CreateObject("expressoMail1_2.imap_attachment"); $a = $imap_attachment->download_attachment($mbox_stream, $msg_number); $filename = $a[$idx_file]['name']; } else $filename = $idx_file; $filename = $filename ? $filename : "attachment.bin"; $newfilename = $newfilename ? $newfilename : $filename; $strFileType = strrev(substr(strrev(strtolower($filename)),0,4)); if($fileContent) { if($encoding == 'base64') $calendar = imap_base64($fileContent); else if($encoding == 'quoted-printable') $calendar = quoted_printable_decode($fileContent); else $calendar = $fileContent; } $this->bo->import(explode("\n",$calendar),true); } function import() { unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw_info']['flags']['nonappheader'] = True; $GLOBALS['phpgw_info']['flags']['nonappfooter'] = True; $GLOBALS['phpgw']->common->phpgw_header(); if(!@is_dir($GLOBALS['phpgw_info']['server']['temp_dir'])) { mkdir($GLOBALS['phpgw_info']['server']['temp_dir'],0700); } echo ''; if ($GLOBALS['HTTP_GET_VARS']['action'] == 'GetFile') { echo '
' . lang('You must select a [iv]Cal. (*.[iv]cs)') . '


'; } $this->template->set_file( Array( 'vcalimport' => 'vcal_import.tpl' ) ); $var = Array( 'vcal_header' => '

', 'ical_lang' => lang('(i/v)Cal'), 'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.boicalendar.import'), 'lang_access' => lang('Access'), 'lang_groups' => lang('Which groups'), 'access_option'=> $access_option, 'group_option' => $group_option, 'load_vcal' => lang('Load [iv]Cal') ); $this->template->set_var($var); $this->template->pparse('out','vcalimport'); } } ?>