source: branches/2.2/calendar/inc/class.uiicalendar.inc.php @ 3736

Revision 3736, 4.0 KB checked in by eduardoalex, 13 years ago (diff)

Ticket #1532 - Adicionada mensagem de erro ao tentar importar o evento 2 vezes

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Calendar                                                    *
4  * http://www.egroupware.org                                                *
5  * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net>               *
6  *          http://www.radix.net/~cknudsen                                  *
7  * Modified by Mark Peters <skeeter@phpgroupware.org>                       *
8  * --------------------------------------------                             *
9  *  This program is free software; you can redistribute it and/or modify it *
10  *  under the terms of the GNU General Public License as published by the   *
11  *  Free Software Foundation; either version 2 of the License, or (at your  *
12  *  option) any later version.                                              *
13  \**************************************************************************/
14
15
16        class uiicalendar
17        {
18                var $bo;
19                var $template;
20
21                var $public_functions = array(
22                        'test'          => True,
23                        'import'                => True,
24                        'import_from_mail' => True
25                );
26
27
28
29                function uiicalendar()
30                {
31                        $this->bo = CreateObject('calendar.boicalendar');
32                        $this->template = $GLOBALS['phpgw']->template;
33                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Calendar - [iv]Cal Importer');
34                }
35
36                function print_test($val,$title,$x_pre='')
37                {
38//                      echo 'VAL = '._debug_array($val,False)."<br>\n";
39                        if(is_array($val))
40                        {
41                                @reset($val);
42                                while(list($key,$value) = each($val))
43                                {
44                                        if(is_array($key))
45                                        {
46                                                $this->print_test($key,$title,$x_pre);
47                                        }
48                                        elseif(is_array($value))
49                                        {
50                                                $this->print_test($value,$title,$x_pre);
51                                        }
52                                        else
53                                        {
54                                                if($x_pre && $key == 'name')
55                                                {
56                                                        $x_key = $x_pre.$value;
57                                                        list($key,$value) = each($val);
58                                                        $key=$x_key;
59                                                }
60                                                if($this->bo->parameter[$key]['type'] == 'function')
61                                                {
62                                                        $function = $this->bo->parameter[$key]['function'];
63                                                        $v_value = $this->bo->$function($value);
64                                                }
65                                                else
66                                                {
67                                                        $v_value = $value;
68                                                }
69                                                echo $title.' ('.$key.') = '.$v_value."<br>\n";
70                                        }
71                                }
72                        }
73                        elseif($val != '')
74                        {
75                                echo $title.' = '.$val."<br>\n";
76                        }
77                }
78
79                function import_from_mail($calendar) {
80                        return $this->bo->import(explode("\n",$calendar),true);
81                }
82               
83                function get_error_message($error_number) {
84                        switch ($error_number) {
85                                case 1:
86                                        return lang('event already exists');
87                        }
88                }
89
90                function import()
91                {
92                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
93                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
94                        $GLOBALS['phpgw_info']['flags']['nonappheader'] = True;
95                        $GLOBALS['phpgw_info']['flags']['nonappfooter'] = True;
96                        $GLOBALS['phpgw']->common->phpgw_header();
97
98                        if(!@is_dir($GLOBALS['phpgw_info']['server']['temp_dir']))
99                        {
100                                mkdir($GLOBALS['phpgw_info']['server']['temp_dir'],0700);
101                        }
102
103                        echo '<body bgcolor="' . $GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
104
105                        if ($GLOBALS['HTTP_GET_VARS']['action'] == 'GetFile')
106                        {
107                                echo '<b><center>' . lang('You must select a [iv]Cal. (*.[iv]cs)') . '</b></center><br><br>';
108                        }
109
110                        $this->template->set_file(array('vcalimport' => 'vcal_import.tpl'));
111                        $this->template->set_block('vcalimport','page_block');
112                        $this->template->set_block('vcalimport','error_block');
113                       
114                        if($GLOBALS['HTTP_GET_VARS']['error_number']) {
115                                $this->template->set_var('error_message',$this->get_error_message( $GLOBALS['HTTP_GET_VARS']['error_number'] ) );
116                                $this->template->parse('error_box','error_block',true);
117                        }
118                       
119                        $var = Array(
120                                'vcal_header'   => '<p>',
121                                'ical_lang'             => lang('(i/v)Cal'),
122                                'action_url'    => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.boicalendar.import'),
123                                'lang_access'   => lang('Access'),
124                                'lang_groups'   => lang('Which groups'),
125                                'access_option'=> $access_option,
126                                'group_option'  => $group_option,
127                                'load_vcal'     => lang('Load [iv]Cal')
128                        );
129                        $this->template->set_var($var);
130                        $this->template->pfp('out', 'page_block');
131                        // $this->template->pparse('out','page_block');
132                }
133        }
134?>
Note: See TracBrowser for help on using the repository browser.