Ignore:
Timestamp:
05/29/07 14:06:42 (17 years ago)
Author:
niltonneto
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/calendar/inc/class.uicalendar.inc.php

    r24 r29  
    10041004                function export($vcal_id=0) 
    10051005                { 
    1006                         if(!isset($_POST['cal_id']) || !$_POST['cal_id']) 
    1007                         { 
    1008                                 Header('Location: '.$this->index()); 
    1009                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1010                         } 
    1011                         $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
    1012                         $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
    1013                         if(!isset($_POST['output_file']) || !$_POST['output_file']) 
    1014                         { 
    1015                                 unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    1016                                 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    1017                                 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Export'); 
    1018                                 $GLOBALS['phpgw']->common->phpgw_header(); 
    1019  
    1020                                 $p = $GLOBALS['phpgw']->template; 
    1021                                 $p->set_file( 
    1022                                         Array( 
    1023                                                 'form_button'   => 'form_button_script.tpl' 
    1024                                         ) 
    1025                                 ); 
    1026                                 $var = Array( 
    1027                                         'action_url_button'     => $this->page('export'), 
    1028                                         'action_text_button'    => lang('Submit'), 
    1029                                         'action_confirm_button' => '', 
    1030                                         'action_extra_field'    => "\n".lang('Enter Output Filename: ( .vcs appended )')."\n".'   <input name="output_file" size="25" maxlength="80" value="">'."\n" 
    1031                                                 . '   <input type="hidden" name="cal_id" value="'.$_POST['cal_id'].'">' 
    1032                                 ); 
    1033                                 $p->set_var($var); 
    1034                                 echo $p->fp('out','form_button'); 
    1035                         } 
    1036                         else 
    1037                         { 
    1038                                 $output_file = $_POST['output_file'].'.vcs'; 
    1039                                 $vfs = CreateObject('phpgwapi.vfs'); 
    1040 //                              if(!$vfs->file_exists('.calendar',array(RELATIVE_USER))) 
    1041 //                              { 
    1042 //                                      $vfs->mkdir('.calendar',array(RELATIVE_USER)); 
    1043 //                              } 
    1044  
    1045                                 $content = ExecMethod('calendar.boicalendar.export', Array( 
    1046                                         'l_event_id' => $_POST['cal_id'], 
    1047                                         'chunk_split' => False, 
    1048                                 )); 
    1049  
    1050                                 $vfs->cd(array( 
    1051                                         'string' => '/', 
    1052                                         'relatives' => array(RELATIVE_USER) 
    1053                                 )); 
    1054                                 $vfs->write(array( 
    1055                                         'string' => $output_file, 
    1056                                         'relatives' => array (RELATIVE_USER), 
    1057                                         'content' => $content 
    1058                                 )); 
    1059  
    1060                                 if($this->debug) 
    1061                                 { 
    1062                                         echo '<!-- DEBUG: Output Filename = '.$output_file.' -->'."\n"; 
    1063                                         echo '<!-- DEBUG: Fakebase = '.$vfs->fakebase.' -->'."\n"; 
    1064                                         echo '<!-- DEBUG: Path = '.$vfs->pwd().' -->'."\n"; 
    1065                                 } 
    1066                                 if ($this->bo->return_to) 
    1067                                 { 
    1068                                         $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->bo->return_to); 
    1069                                 } 
    1070                                 else 
    1071                                 { 
    1072                                         $GLOBALS['phpgw']->redirect($this->index()); 
    1073                                 } 
    1074                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1075                         } 
     1006                         
     1007                        $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
     1008                        srand((double)microtime()*1000000); 
     1009                        $random_number = rand(100000000,999999999); 
     1010                        $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); 
     1011                        $filename = $temp_path . $newfilename; 
     1012                        $attach_fd = fopen($filename,"w+"); 
     1013                        $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); 
     1014                        $event = $this->bo->read_entry($cal_id); 
     1015                        include_once('class.bocalendar.inc.php'); 
     1016                        $cal = new bocalendar; 
     1017                        $tmpattach=$cal->create_vcard($event); 
     1018                        fwrite($attach_fd,$tmpattach); 
     1019                        header ("Content-Type: text/plain");  
     1020                        header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
     1021                        header('Content-Length: ' . filesize($filename)); 
     1022                        header("Content-disposition: attachment; filename="."export.vcard"); 
     1023                        readfile($filename); 
     1024                        fclose($attach_fd); 
    10761025                } 
    10771026 
Note: See TracChangeset for help on using the changeset viewer.