Changeset 3638


Ignore:
Timestamp:
12/28/10 16:21:40 (13 years ago)
Author:
alexandrecorreia
Message:

Ticket #1468 - Notificacao por email de uploads de arquivos enviados pelo modulo Filemanager

Location:
branches/2.2/filemanager
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/filemanager/inc/class.notifications.inc.php

    r3636 r3638  
    2020                'AddEmail'                      => True, 
    2121                'DeleteEmail'           => True, 
    22                 'DeleteEmailUser'       => True 
     22                'DeleteEmailUser'       => True, 
     23                'EmailsToSend'          => True 
    2324        ); 
    2425         
    2526        public function notifications() 
    2627        { 
    27                 if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
    28                 { 
    29                         $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
    30                 }                
    3128                $this->db_name = $GLOBALS['phpgw_info']['server']['db_name']; 
    3229                $this->db_host = $GLOBALS['phpgw_info']['server']['db_host']; 
     
    4744        public function AddEmail() 
    4845        {        
     46                if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
     47                { 
     48                        $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
     49                }                
     50                 
    4951                $emailFrom      = $_GET['emailFrom']; 
    5052                $emailTo        = $_GET['emailTo']; 
     
    8890        public function DeleteEmail() 
    8991        { 
     92                if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
     93                { 
     94                        $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
     95                }                
     96 
    9097                $emailFrom      = $_GET['emailFrom']; 
    9198                $emailTo        = $_GET['emailTo']; 
     
    129136        public function DeleteEmailUser() 
    130137        { 
     138                if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
     139                { 
     140                        $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
     141                }                
     142 
    131143                $id     = $_GET['filemanagerId'];                
    132144                $return = "False"; 
     
    143155        } 
    144156         
     157        public function EmailsToSend( $pEmail ) 
     158        { 
     159                $query = "SELECT * FROM  phpgw_filemanager_notification WHERE email_from = '".$pEmail."'"; 
     160                 
     161                if( $this->db ) 
     162                { 
     163                        if( $this->db->query($query) ) 
     164                        { 
     165                                while( $this->db->next_record()) 
     166                                        $result[] = $this->db->row();                                    
     167                        } 
     168                } 
     169 
     170                return $result[0]['email_to']; 
     171        } 
     172         
    145173        public function SearchId( $pData ) 
    146174        { 
     175                if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
     176                { 
     177                        $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
     178                }                
     179 
    147180                $query = "SELECT * FROM phpgw_filemanager_notification WHERE filemanager_id ='".$pData."';"; 
    148181                 
     
    161194        public function SearchEmail( $pEmail, $pLimit, $pOffset ) 
    162195        { 
     196                if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') ) 
     197                { 
     198                        $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
     199                }                
     200 
    163201                $query = "SELECT * FROM phpgw_filemanager_notification WHERE email_from like '%".$pEmail."%' " . 
    164202                                 "ORDER BY email_from OFFSET (".$pOffset."-1)*".$pLimit." LIMIT ".$pLimit.";"; 
  • branches/2.2/filemanager/inc/class.uifilemanager.inc.php

    r3610 r3638  
    1717        /* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ 
    1818 
    19         class uifilemanager 
    20         { 
    21                 var $public_functions = array( 
    22                         'index' => True, 
    23                         'help'  => True, 
    24                         'view'  => True, 
    25                         'export'=> True, 
    26                         'touch' => True, 
    27                         'history' => True, 
    28                         'edit' => True, 
    29                         'fileModels'=>True, 
    30                         'getReturnExecuteForm' => True, 
    31                         'dir_ls' => True, 
    32                         'search' => True, 
    33                         'get_folders_list' => True, 
    34                         'showUploadboxes' => True, 
    35                         'createdir' => True, 
    36                         'removedir' => True, 
    37                         'uploadModel'=>True 
     19class uifilemanager 
     20{ 
     21        var $public_functions = array( 
     22                'index'                                 => True, 
     23                'help'                                  => True, 
     24                'view'                                  => True, 
     25                'export'                                => True, 
     26                'touch'                                 => True, 
     27                'history'                               => True, 
     28                'edit'                                  => True, 
     29                'fileModels'                    => True, 
     30                'getReturnExecuteForm'  => True, 
     31                'dir_ls'                                => True, 
     32                'search'                                => True, 
     33                'get_folders_list'              => True, 
     34                'showUploadboxes'               => True, 
     35                'createdir'                     => True, 
     36                'removedir'                     => True, 
     37                'uploadModel'                   => True 
     38        ); 
     39 
     40        //keep 
     41        var $bo; 
     42        var $vfs_functions; 
     43        var $t; //template object 
     44        var $dispath; 
     45        var $cwd; 
     46        var $lesspath; 
     47        var $readable_groups; 
     48        var $files_array; 
     49        var $numoffiles; 
     50        var $dispsep; 
     51 
     52        var $target; 
     53 
     54        var $prefs;//array 
     55 
     56        var $groups_applications; 
     57 
     58        var $current_config; 
     59        var $dirs; 
     60        var $to; 
     61        var $changedir; // for switching dir. 
     62        var $cdtodir; // for switching dir. 
     63        var $newfile_or_dir; 
     64        var $newfile_x; 
     65        var $createfile_var; 
     66        var $move_to_x; 
     67        var $copy_to_x; 
     68        var $edit_x; 
     69        var $edit_file; 
     70        var $edit_preview_x; 
     71        var $edit_save_x; 
     72        var $edit_save_done_x; 
     73        var $edit_cancel_x; 
     74 
     75        // this ones must be checked thorougly; 
     76        var $fileman = Array(); 
     77        //var $fileman; 
     78        var $path; 
     79        var $file; // FIXME WHERE IS THIS FILLED? 
     80        var $sortby; 
     81        var $messages; 
     82        var $limit; //for paging (paginacao) 
     83        var $offset; //for paging (paginacao) 
     84 
     85        var $now; 
     86 
     87        function uifilemanager() 
     88        { 
     89                $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; 
     90 
     91                $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); 
     92 
     93                $this->now = date('Y-m-d'); 
     94 
     95                $this->bo = CreateObject('filemanager.bofilemanager'); 
     96 
     97                $this->vfs_functions = CreateObject('filemanager.vfs_functions'); 
     98 
     99                $this->t = $GLOBALS['phpgw']->template; 
     100                $c = CreateObject('phpgwapi.config','filemanager'); 
     101                $c->read_repository(); 
     102                $this->current_config = $c->config_data; 
     103 
     104 
     105                // here local vars are created from the HTTP vars 
     106                @reset($GLOBALS['HTTP_POST_VARS']); 
     107                while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) 
     108                { 
     109                        $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; 
     110                } 
     111 
     112                @reset($GLOBALS['HTTP_GET_VARS']); 
     113                while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) 
     114                { 
     115                        $$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
     116                        $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
     117 
     118                } 
     119 
     120                $to_decode = array 
     121                ( 
     122                        'op'    => array('op' => ''), 
     123                        'path'  => array('path' => ''), 
     124                        'filename' => array('filename' => ''), 
     125                        'file'  => array('file' => ''), 
     126                        'sortby'        => array('sortby' => ''), 
     127                        'messages'      => array('messages'     => ''), 
     128                        'show_upload_boxes'     => array('show_upload_boxes' => ''), 
     129                        'from'  =>      array('from' => ''), 
     130                        'to' => array('to' => '') 
     131 
    38132                ); 
    39133 
    40                 //keep 
    41                 var $bo; 
    42                 var $vfs_functions; 
    43                 var $t; //template object 
    44                 var $dispath; 
    45                 var $cwd; 
    46                 var $lesspath; 
    47                 var $readable_groups; 
    48                 var $files_array; 
    49                 var $numoffiles; 
    50                 var $dispsep; 
    51  
    52                 var $target; 
    53  
    54                 var $prefs;//array 
    55  
    56                 var $groups_applications; 
    57  
    58                 var $current_config; 
    59                 var $dirs; 
    60                 var $to; 
    61                 var $changedir; // for switching dir. 
    62                 var $cdtodir; // for switching dir. 
    63                 var $newfile_or_dir; 
    64                 var $newfile_x; 
    65                 var $createfile_var; 
    66                 var $move_to_x; 
    67                 var $copy_to_x; 
    68                 var $edit_x; 
    69                 var $edit_file; 
    70                 var $edit_preview_x; 
    71                 var $edit_save_x; 
    72                 var $edit_save_done_x; 
    73                 var $edit_cancel_x; 
    74  
    75                 // this ones must be checked thorougly; 
    76                 var $fileman = Array(); 
    77                 //var $fileman; 
    78                 var $path; 
    79                 var $file; // FIXME WHERE IS THIS FILLED? 
    80                 var $sortby; 
    81                 var $messages; 
    82                 var $limit; //for paging (paginacao) 
    83                 var $offset; //for paging (paginacao) 
    84  
    85                 var $now; 
    86  
    87                 function uifilemanager() 
    88                 { 
    89                         $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; 
    90  
    91                         $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); 
    92  
    93                         $this->now = date('Y-m-d'); 
    94  
    95                         $this->bo = CreateObject('filemanager.bofilemanager'); 
    96  
    97                         $this->vfs_functions = CreateObject('filemanager.vfs_functions'); 
    98  
    99                         $this->t = $GLOBALS['phpgw']->template; 
    100                         $c = CreateObject('phpgwapi.config','filemanager'); 
    101                         $c->read_repository(); 
    102                         $this->current_config = $c->config_data; 
    103  
    104  
    105                         // here local vars are created from the HTTP vars 
    106                         @reset($GLOBALS['HTTP_POST_VARS']); 
    107                         while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) 
    108                         { 
    109                                 $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; 
    110                         } 
    111  
    112                         @reset($GLOBALS['HTTP_GET_VARS']); 
    113                         while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) 
    114                         { 
    115                                 $$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
    116                                 $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
    117  
    118                         } 
    119  
    120                         $to_decode = array 
     134                reset($to_decode); 
     135                while(list($var, $conditions) = each($to_decode)) 
     136                { 
     137                        while(list($condvar, $condvalue) = each($conditions)) 
     138                        { 
     139                                if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) 
     140                                { 
     141                                        $this->$var = stripslashes(base64_decode($$var)); 
     142                                } 
     143                        } 
     144                } 
     145 
     146                // get appl. and user prefs 
     147                $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); 
     148                $pref->read_repository(); 
     149                //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); 
     150                $pref->save_repository(True); 
     151                $pref_array = $pref->read_repository(); 
     152                $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array 
     153 
     154                //always show name 
     155 
     156                $this->prefs[name] =1; 
     157 
     158 
     159                if($this->prefs['viewinnewwin']) 
     160                { 
     161                        $this->target = '_blank'; 
     162                } 
     163 
     164 
     165                /* 
     166                        Check for essential directories 
     167                        admin must be able to disable these tests 
     168                */ 
     169                 
     170                // check if basedir exist  
     171                $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     172                if($test[mime_type]!='Directory') 
     173                { 
     174                        die('Base directory does not exist, Ask adminstrator to check the global configuration.'); 
     175                } 
     176 
     177                $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     178                if($test[mime_type]!='Directory') 
     179                { 
     180                        $this->bo->vfs->override_acl = 1; 
     181 
     182                        $this->bo->vfs->mkdir(array( 
     183                                'string' => $this->bo->fakebase, 
     184                                'relatives' => array(RELATIVE_NONE) 
     185                        )); 
     186                         
     187                        $this->bo->vfs->override_acl = 0; 
     188 
     189                        //test one more time 
     190                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     191 
     192                        if($test[mime_type]!='Directory') 
     193                        { 
     194                                die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); 
     195                        } 
     196                        else 
     197                        { 
     198                                $this->messages[]= lang('Fake Base Dir did not exist, created a new one.'); 
     199                        } 
     200                } 
     201 
     202                $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     203                if($test[mime_type]!='Directory') 
     204                { 
     205                        $this->bo->vfs->override_acl = 1; 
     206 
     207                        $this->bo->vfs->mkdir(array( 
     208                                'string' => $this->bo->homedir, 
     209                                'relatives' => array(RELATIVE_NONE) 
     210                        )); 
     211                        $this->bo->vfs->set_quota(array( 
     212                                'string' => $this->bo->homedir, 
     213                                'relatives' => array(RELATIVE_NONE), 
     214                                'new_quota' => $this->current_config['filemanager_quota_size']  
     215                        )); 
     216 
     217                        $this->bo->vfs->override_acl = 0; 
     218 
     219                        //test one more time 
     220                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     221 
     222                        if($test[mime_type]!='Directory') 
     223                        { 
     224                                die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); 
     225                        } 
     226                        else 
     227                        { 
     228                                $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); 
     229                                // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 
     230                        } 
     231 
     232 
     233                } 
     234        } 
     235        function fileModels() 
     236        { 
     237                $GLOBALS['phpgw_info']['flags'] = array 
    121238                        ( 
    122                                 'op'    => array('op' => ''), 
    123                                 'path'  => array('path' => ''), 
    124                                 'filename' => array('filename' => ''), 
    125                                 'file'  => array('file' => ''), 
    126                                 'sortby'        => array('sortby' => ''), 
    127                                 'messages'      => array('messages'     => ''), 
    128                                 'show_upload_boxes'     => array('show_upload_boxes' => ''), 
    129                                 'from'  =>      array('from' => ''), 
    130                                 'to' => array('to' => '') 
    131  
     239                                'currentapp'    => 'filemanager', 
     240                                'noheader'      => False, 
     241                                'nonavbar' => False, 
     242                                'nofooter'      => False, 
     243                                'noappheader'   => False, 
     244                                'enable_browser_class'  => True 
    132245                        ); 
    133246 
    134                         reset($to_decode); 
    135                         while(list($var, $conditions) = each($to_decode)) 
    136                         { 
    137                                 while(list($condvar, $condvalue) = each($conditions)) 
    138                                 { 
    139                                         if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) 
    140                                         { 
    141                                                 $this->$var = stripslashes(base64_decode($$var)); 
    142                                         } 
    143                                 } 
    144                         } 
    145  
    146                         // get appl. and user prefs 
    147                         $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); 
    148                         $pref->read_repository(); 
    149                         //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); 
    150                         $pref->save_repository(True); 
    151                         $pref_array = $pref->read_repository(); 
    152                         $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array 
    153  
    154                         //always show name 
    155  
    156                         $this->prefs[name] =1; 
    157  
    158  
    159                         if($this->prefs['viewinnewwin']) 
    160                         { 
    161                                 $this->target = '_blank'; 
    162                         } 
    163  
    164  
    165                         /* 
    166                                 Check for essential directories 
    167                                 admin must be able to disable these tests 
    168                         */ 
    169                          
    170                         // check if basedir exist  
    171                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    172                         if($test[mime_type]!='Directory') 
    173                         { 
    174                                 die('Base directory does not exist, Ask adminstrator to check the global configuration.'); 
    175                         } 
    176  
    177                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    178                         if($test[mime_type]!='Directory') 
    179                         { 
    180                                 $this->bo->vfs->override_acl = 1; 
    181  
    182                                 $this->bo->vfs->mkdir(array( 
    183                                         'string' => $this->bo->fakebase, 
    184                                         'relatives' => array(RELATIVE_NONE) 
    185                                 )); 
    186                                  
    187                                 $this->bo->vfs->override_acl = 0; 
    188  
    189                                 //test one more time 
    190                                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    191  
    192                                 if($test[mime_type]!='Directory') 
    193                                 { 
    194                                         die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); 
    195                                 } 
    196                                 else 
    197                                 { 
    198                                         $this->messages[]= lang('Fake Base Dir did not exist, created a new one.'); 
    199                                 } 
    200                         } 
    201  
    202                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    203                         if($test[mime_type]!='Directory') 
    204                         { 
    205                                 $this->bo->vfs->override_acl = 1; 
    206  
    207                                 $this->bo->vfs->mkdir(array( 
    208                                         'string' => $this->bo->homedir, 
    209                                         'relatives' => array(RELATIVE_NONE) 
    210                                 )); 
    211                                 $this->bo->vfs->set_quota(array( 
    212                                         'string' => $this->bo->homedir, 
    213                                         'relatives' => array(RELATIVE_NONE), 
    214                                         'new_quota' => $this->current_config['filemanager_quota_size']  
    215                                 )); 
     247                $GLOBALS['phpgw']->common->phpgw_header(); 
     248                $this->t->set_file(array('models' => 'fileModels.tpl')); 
     249                $this->t->set_block('models','header','header'); 
     250                $this->t->set_block('models','body','body'); 
     251                $this->t->set_block('models','footer','footer'); 
     252                $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); 
     253                $this->t->set_var('model_1','article'); 
     254                $this->t->set_var('lang_1',lang('article')); 
     255 
     256                $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 
     257                $this->t->set_var('model_2','calendar'); 
     258                $this->t->set_var('lang_2',lang('calendar')); 
     259 
     260                $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 
     261                $this->t->set_var('model_3','todo'); 
     262                $this->t->set_var('lang_3',lang('todo')); 
     263 
     264                $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 
     265                $this->t->set_var('model_4','slide'); 
     266                $this->t->set_var('lang_4',lang('slide')); 
     267 
     268                $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 
     269                $this->t->set_var('model_5','cards'); 
     270                $this->t->set_var('lang_5',lang('cards')); 
     271 
     272                $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 
     273                $this->t->set_var('model_6','resume'); 
     274                $this->t->set_var('lang_6',lang('resume')); 
     275 
     276 
     277                $this->t->pparse('out','models'); 
     278 
     279 
     280        } 
     281        function uploadModel(){ 
     282                $GLOBALS['phpgw_info']['flags'] = array 
     283                        ( 
     284                                'currentapp'    => 'filemanager', 
     285                                'noheader'      => False, 
     286                                'nonavbar' => False, 
     287                                'nofooter'      => False, 
     288                                'noappheader'   => False, 
     289                                'enable_browser_class'  => True 
     290                        ); 
     291 
     292                $GLOBALS['phpgw']->common->phpgw_header(); 
     293 
     294                $filename = lang('new')."_".lang($this->model).rand(0,1000).".html"; 
     295                $this->bo->vfs->cp(array( 
     296                        'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html', 
     297                        'to'=> $filename, 
     298                        'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
     299                )); 
     300 
     301                $this->bo->vfs->set_attributes(array( 
     302                        'string'=> $filename, 
     303                        'relatives'     => array(RELATIVE_ALL), 
     304                        'attributes'=> array( 
     305                                'mime_type' => "text/html", 
     306                                'comment' => "" 
     307                        ) 
     308                )); 
     309                $this->filename = $filename; 
     310                $this->edit(); 
     311 
     312        } 
     313        function index() 
     314        { 
     315                $GLOBALS['phpgw_info']['flags'] = array 
     316                ( 
     317                        'currentapp'    => 'filemanager', 
     318                        'noheader'      => False, 
     319                        'nonavbar' => False, 
     320                        'nofooter'      => False, 
     321                        'noappheader'   => False, 
     322                        'enable_browser_class'  => True 
     323                ); 
     324 
     325                $GLOBALS['phpgw']->common->phpgw_header(); 
     326                 
     327                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>"; 
     328                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 
     329                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; 
     330                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; 
     331                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>"; 
     332                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>"; 
     333                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>"; 
     334 
     335 
     336                // Temas Expresso 
     337                $theme = "window_" . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . ".css"; 
     338 
     339                if( !file_exists('filemanager/tp/expressowindow/css/'.$theme) ) 
     340                        $theme = "window_default.css"; 
     341 
     342                // Path FileManager 
     343                $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 
     344                $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 
    216345         
    217                                 $this->bo->vfs->override_acl = 0; 
    218  
    219                                 //test one more time 
    220                                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    221  
    222                                 if($test[mime_type]!='Directory') 
    223                                 { 
    224                                         die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); 
    225                                 } 
    226                                 else 
    227                                 { 
    228                                         $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); 
    229                                         // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 
    230                                 } 
    231  
    232  
    233                         } 
    234                 } 
    235                 function fileModels() 
    236                 { 
    237                         $GLOBALS['phpgw_info']['flags'] = array 
    238                                 ( 
    239                                         'currentapp'    => 'filemanager', 
    240                                         'noheader'      => False, 
    241                                         'nonavbar' => False, 
    242                                         'nofooter'      => False, 
    243                                         'noappheader'   => False, 
    244                                         'enable_browser_class'  => True 
    245                                 ); 
    246  
    247                         $GLOBALS['phpgw']->common->phpgw_header(); 
    248                         $this->t->set_file(array('models' => 'fileModels.tpl')); 
    249                         $this->t->set_block('models','header','header'); 
    250                         $this->t->set_block('models','body','body'); 
    251                         $this->t->set_block('models','footer','footer'); 
    252                         $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); 
    253                         $this->t->set_var('model_1','article'); 
    254                         $this->t->set_var('lang_1',lang('article')); 
    255  
    256                         $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 
    257                         $this->t->set_var('model_2','calendar'); 
    258                         $this->t->set_var('lang_2',lang('calendar')); 
    259  
    260                         $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 
    261                         $this->t->set_var('model_3','todo'); 
    262                         $this->t->set_var('lang_3',lang('todo')); 
    263  
    264                         $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 
    265                         $this->t->set_var('model_4','slide'); 
    266                         $this->t->set_var('lang_4',lang('slide')); 
    267  
    268                         $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 
    269                         $this->t->set_var('model_5','cards'); 
    270                         $this->t->set_var('lang_5',lang('cards')); 
    271  
    272                         $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 
    273                         $this->t->set_var('model_6','resume'); 
    274                         $this->t->set_var('lang_6',lang('resume')); 
    275  
    276  
    277                         $this->t->pparse('out','models'); 
    278  
    279  
    280                 } 
    281                 function uploadModel(){ 
    282                         $GLOBALS['phpgw_info']['flags'] = array 
    283                                 ( 
    284                                         'currentapp'    => 'filemanager', 
    285                                         'noheader'      => False, 
    286                                         'nonavbar' => False, 
    287                                         'nofooter'      => False, 
    288                                         'noappheader'   => False, 
    289                                         'enable_browser_class'  => True 
    290                                 ); 
    291  
    292                         $GLOBALS['phpgw']->common->phpgw_header(); 
    293  
    294                         $filename = lang('new')."_".lang($this->model).rand(0,1000).".html"; 
    295                         $this->bo->vfs->cp(array( 
    296                                 'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html', 
    297                                 'to'=> $filename, 
    298                                 'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
    299                         )); 
    300  
    301                         $this->bo->vfs->set_attributes(array( 
    302                                 'string'=> $filename, 
    303                                 'relatives'     => array(RELATIVE_ALL), 
    304                                 'attributes'=> array( 
    305                                         'mime_type' => "text/html", 
    306                                         'comment' => "" 
    307                                 ) 
    308                         )); 
    309                         $this->filename = $filename; 
    310                         $this->edit(); 
    311  
    312                 } 
    313                 function index() 
    314                 { 
    315                         $GLOBALS['phpgw_info']['flags'] = array 
    316                         ( 
    317                                 'currentapp'    => 'filemanager', 
    318                                 'noheader'      => False, 
    319                                 'nonavbar' => False, 
    320                                 'nofooter'      => False, 
    321                                 'noappheader'   => False, 
    322                                 'enable_browser_class'  => True 
    323                         ); 
    324  
    325                         $GLOBALS['phpgw']->common->phpgw_header(); 
    326                          
    327                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>"; 
    328                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 
    329                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; 
    330                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; 
    331                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>"; 
    332                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>"; 
    333                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>"; 
    334  
    335  
    336                         // Temas Expresso 
    337                         $theme = "window_" . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . ".css"; 
    338  
    339                         if( !file_exists('filemanager/tp/expressowindow/css/'.$theme) ) 
    340                                 $theme = "window_default.css"; 
    341  
    342                         // Path FileManager 
    343                         $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 
    344                         $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 
     346                if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1)) 
     347                        $webserver_url .= '/'; 
     348         
     349                $webserver_url  = $webserver_url . 'filemanager/';  
    345350                 
    346                         if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1)) 
    347                                 $webserver_url .= '/'; 
     351                $js   = "var path_filemanager   = '".$webserver_url."';"; 
     352                $js      .= "var my_home_filemanager    = '".trim($GLOBALS['uifilemanager']->bo->vfs->my_home)."';"; 
    348353                 
    349                         $webserver_url  = $webserver_url . 'filemanager/';  
    350                          
    351                         $js   = "var path_filemanager   = '".$webserver_url."';"; 
    352                         $js      .= "var my_home_filemanager    = '".trim($GLOBALS['uifilemanager']->bo->vfs->my_home)."';"; 
    353                          
    354                         echo "<script type='text/javascript'>".$js."</script>"; 
    355  
    356                         // Expresso Window - CSS 
    357                         print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/'.$theme.'" >'; 
    358  
    359                         // Expresso Window - JS  
    360                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/xtools.js'></script>"; 
    361                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/jsloader.js'></script>"; 
    362                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/makeW.js'></script>"; 
    363                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/dragdrop.js'></script>"; 
    364                         echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/show_hidden.js'></script>"; 
    365  
    366                         echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; 
    367  
    368                         include('load_lang.php'); 
    369  
    370                         # Page to process users 
    371                         # Code is fairly hackish at the beginning, but it gets better 
    372                         # Highly suggest turning wrapping off due to long SQL queries 
    373  
    374                         ### 
    375                         # Some hacks to set and display directory paths correctly 
    376                         ### 
    377                         // new method for switching to a new dir. 
    378                         if($this->changedir=='true' && $this->cdtodir || $this->goto_x) 
    379                         { 
    380                                 $this->path = $this->cdtodir; 
    381                         } 
    382  
    383                         if(!$this->path) 
    384                         { 
    385                                 $this->path = $this->bo->vfs->pwd(); 
    386  
    387                                 if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') 
    388                                 { 
    389                                         $this->path = $this->bo->homedir;  
    390                                 } 
    391                         } 
    392  
    393                         $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    394                         $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    395  
    396                         $pwd = $this->bo->vfs->pwd(); 
    397  
    398                         if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1))   
    399                         { 
    400                                 $this->cwd = '/'; 
    401                         } 
    402                         else 
    403                         { 
    404                                 $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); 
    405                         } 
    406  
    407                         $this->disppath = $this->path; 
    408  
    409                         /* This just prevents // in some cases */ 
    410                         if($this->path == '/') 
    411                         { 
    412                                 $this->dispsep = ''; 
    413                         } 
    414                         else 
    415                         { 
    416                                 $this->dispsep = '/'; 
    417                         } 
    418  
    419                         if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) 
    420                         { 
    421                                 $this->lesspath = '/'; 
    422                         } 
    423  
    424                         /*Check permission*/ 
    425                         if($this->bo->vfs->acl_check(array( 
     354                echo "<script type='text/javascript'>".$js."</script>"; 
     355 
     356                // Expresso Window - CSS 
     357                print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/'.$theme.'" >'; 
     358 
     359                // Expresso Window - JS  
     360                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/xtools.js'></script>"; 
     361                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/jsloader.js'></script>"; 
     362                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/makeW.js'></script>"; 
     363                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/dragdrop.js'></script>"; 
     364                echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/show_hidden.js'></script>"; 
     365 
     366                echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; 
     367 
     368                include('load_lang.php'); 
     369 
     370                # Page to process users 
     371                # Code is fairly hackish at the beginning, but it gets better 
     372                # Highly suggest turning wrapping off due to long SQL queries 
     373 
     374                ### 
     375                # Some hacks to set and display directory paths correctly 
     376                ### 
     377                // new method for switching to a new dir. 
     378                if($this->changedir=='true' && $this->cdtodir || $this->goto_x) 
     379                { 
     380                        $this->path = $this->cdtodir; 
     381                } 
     382 
     383                if(!$this->path) 
     384                { 
     385                        $this->path = $this->bo->vfs->pwd(); 
     386 
     387                        if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') 
     388                        { 
     389                                $this->path = $this->bo->homedir;  
     390                        } 
     391                } 
     392 
     393                $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     394                $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     395 
     396                $pwd = $this->bo->vfs->pwd(); 
     397 
     398                if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1))   
     399                { 
     400                        $this->cwd = '/'; 
     401                } 
     402                else 
     403                { 
     404                        $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); 
     405                } 
     406 
     407                $this->disppath = $this->path; 
     408 
     409                /* This just prevents // in some cases */ 
     410                if($this->path == '/') 
     411                { 
     412                        $this->dispsep = ''; 
     413                } 
     414                else 
     415                { 
     416                        $this->dispsep = '/'; 
     417                } 
     418 
     419                if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) 
     420                { 
     421                        $this->lesspath = '/'; 
     422                } 
     423 
     424                /*Check permission*/ 
     425                if($this->bo->vfs->acl_check(array( 
     426                        'string' => $this->path, 
     427                        'relatives' => array(RELATIVE_NONE), 
     428                        'operation' => PHPGW_ACL_READ 
     429                ))) 
     430                { 
     431                        $this->can_read = True; 
     432                } 
     433 
     434 
     435                if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') 
     436                { 
     437                        /*Flush journal-deleted*/ 
     438                        $this->bo->vfs->flush_journal(array( 
    426439                                'string' => $this->path, 
    427440                                'relatives' => array(RELATIVE_NONE), 
    428                                 'operation' => PHPGW_ACL_READ 
     441                                'deleteall' => True 
     442                        )); 
     443                        $_SESSION['phpgw_info']['user']['filemanager']['flush'] = 'flushed'; 
     444                } 
     445 
     446 
     447 
     448                # if is different path than home and no permission allowed 
     449                if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) 
     450                { 
     451                        $this->messages[] = lang('You do not have access to %1', $this->path); 
     452                        $this->path = $this->homedir; 
     453                        $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     454                        $GLOBALS['phpgw']->common->phpgw_footer(); 
     455                        $GLOBALS['phpgw']->common->phpgw_exit(); 
     456                } 
     457 
     458                $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; 
     459                $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); 
     460 
     461                # Verify path is real 
     462                if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) 
     463                { 
     464                        if(!$this->bo->vfs->file_exists(array( 
     465                                'string' => $this->path, 
     466                                'relatives' => array(RELATIVE_NONE) 
    429467                        ))) 
    430468                        { 
    431                                 $this->can_read = True; 
    432                         } 
    433  
    434  
    435                         if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') 
    436                         { 
    437                                 /*Flush journal-deleted*/ 
    438                                 $this->bo->vfs->flush_journal(array( 
    439                                         'string' => $this->path, 
    440                                         'relatives' => array(RELATIVE_NONE), 
    441                                         'deleteall' => True 
    442                                 )); 
    443                                 $_SESSION['phpgw_info']['user']['filemanager']['flush'] = 'flushed'; 
    444                         } 
    445  
    446  
    447  
    448                         # if is different path than home and no permission allowed 
    449                         if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) 
    450                         { 
    451                                 $this->messages[] = lang('You do not have access to %1', $this->path); 
     469                                $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); 
    452470                                $this->path = $this->homedir; 
    453471                                $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     
    455473                                $GLOBALS['phpgw']->common->phpgw_exit(); 
    456474                        } 
    457  
    458                         $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; 
    459                         $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); 
    460  
    461                         # Verify path is real 
    462                         if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) 
    463                         { 
    464                                 if(!$this->bo->vfs->file_exists(array( 
    465                                         'string' => $this->path, 
    466                                         'relatives' => array(RELATIVE_NONE) 
    467                                 ))) 
     475                } 
     476 
     477 
     478                # Default is to sort by name 
     479                if(!$this->sortby) 
     480                { 
     481                        $this->sortby = 'name'; 
     482                } 
     483                if($this->update_x == 1){ 
     484                        $this->bo->vfs->update_real(array( 
     485                                'string'        => $this->path, 
     486                                'relatives'     => array(RELATIVE_NONE) 
     487                        )); 
     488                        header('Location:'.$this->encode_href('index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
     489                } 
     490                elseif($this->newfile_x && $this->newfile_or_dir) // create new textfile 
     491                { 
     492                        $this->createfile(); 
     493                } 
     494                elseif($this->edit_cancel_x) 
     495                { 
     496                        $this->readFilesInfo(); 
     497                        $this->fileListing(); 
     498                } 
     499                elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) 
     500                { 
     501                        $this->edit(); 
     502                } 
     503                else 
     504                { 
     505                        //$this->readFilesInfo(); 
     506                        $this->fileListing(); 
     507                } 
     508        } 
     509        function get_permissions(){ 
     510                /* get permissions */ 
     511                if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined 
     512 
     513                { 
     514                        $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined 
     515 
     516                } 
     517                else 
     518                { 
     519                        $this->bo->vfs->working_id = $this->bo->userinfo['username']; 
     520                } 
     521 
     522                # Check available permissions for $this->path, so we can disable unusable operations in user interface 
     523                $path = explode('/',$this->path); 
     524                $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); 
     525                $user_id = $GLOBALS['phpgw_info']['user']['account_id']; 
     526                if ($owner_id == $user_id) 
     527                { 
     528                        $rights = 31; 
     529                }else 
     530                { 
     531                        $acl = CreateObject ('phpgwapi.acl', $owner_id); 
     532                        $acl->account_id = $owner_id; 
     533                        $acl->read_repository(); 
     534                        $rights = $acl->get_rights($user_id); 
     535                } 
     536                return $rights;  
     537        } 
     538        function dir_ls() 
     539        { 
     540                // change dir to this->path 
     541                $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     542                $return['permissions'] = $this->get_permissions(); 
     543                $return['quota']['usedSpace'] = $this->bo->vfs->get_size(array( 
     544                                'string'        => $this->path, 
     545                                'relatives'     => array(RELATIVE_NONE) 
     546                )); 
     547                $return['files_count'] = $this->bo->vfs->count_files(array( 
     548                                'string'        => $this->path, 
     549                )); 
     550                $quota = $this->bo->vfs->get_quota(array( 
     551                        'string'        => $this->path 
     552                )); 
     553                reset($this->files_array); 
     554                $this->readFilesInfo(); 
     555 
     556                for($i = 0; $i != $this->numoffiles; $i++) 
     557                { 
     558                        $files = $this->files_array[$i]; 
     559 
     560                        if($files['mime_type'] == "Directory") 
     561                        { 
     562                                continue; 
     563                        } 
     564                        /* small keys to safe bandwidth */ 
     565                        $tuple['name'] = htmlentities($files['name']); 
     566                        if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1){ 
     567                                if ($files['mime_type'] == 'image/png' ||  
     568                                        $files['mime_type'] == 'image/gif' ||  
     569                                        $files['mime_type'] == 'image/jpg') 
    468570                                { 
    469                                         $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); 
    470                                         $this->path = $this->homedir; 
    471                                         $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    472                                         $GLOBALS['phpgw']->common->phpgw_footer(); 
    473                                         $GLOBALS['phpgw']->common->phpgw_exit(); 
     571                                        $filename = str_replace('=','',base64_encode($tuple['name'])); 
     572                                        $pathname = str_replace('=','',base64_encode($this->path)); 
     573                                        $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file='.$filename.'&path='.$pathname; 
    474574                                } 
    475                         } 
    476  
    477  
    478                         # Default is to sort by name 
    479                         if(!$this->sortby) 
    480                         { 
    481                                 $this->sortby = 'name'; 
    482                         } 
    483                         if($this->update_x == 1){ 
    484                                 $this->bo->vfs->update_real(array( 
    485                                         'string'        => $this->path, 
    486                                         'relatives'     => array(RELATIVE_NONE) 
    487                                 )); 
    488                                 header('Location:'.$this->encode_href('index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
    489                         } 
    490                         elseif($this->newfile_x && $this->newfile_or_dir) // create new textfile 
    491                         { 
    492                                 $this->createfile(); 
    493                         } 
    494                         elseif($this->edit_cancel_x) 
    495                         { 
    496                                 $this->readFilesInfo(); 
    497                                 $this->fileListing(); 
    498                         } 
    499                         elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) 
    500                         { 
    501                                 $this->edit(); 
     575                                else 
     576                                        $tuple['icon'] =  $this->mime_icon($files['mime_type'],64); 
    502577                        } 
    503578                        else 
    504                         { 
    505                                 //$this->readFilesInfo(); 
    506                                 $this->fileListing(); 
    507                         } 
    508                 } 
    509                 function get_permissions(){ 
    510                         /* get permissions */ 
    511                         if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined 
    512  
    513                         { 
    514                                 $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined 
    515  
     579                                $tuple['icon'] = $this->mime_icon($files['mime_type']); 
     580                        $tuple['type'] = $files['type']; 
     581                        $tuple['created'] = $this->vfs_functions->dateString2timeStamp($files['created']); 
     582                        $tuple['modified'] = $this->vfs_functions->dateString2timeStamp($files['modified']); 
     583                        $tuple['size'] = $files['size']; 
     584                        $tuple['mime_type'] = $files['mime_type']; 
     585                        $tuple['pub'] = $files['type']; 
     586                        $tuple['createdby_id'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 
     587                        $tuple['modifiedby_id'] = $files['modifiedby_id']?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):''; 
     588                        $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); 
     589                        $tuple['comment'] = $files['comment']; 
     590                        $tuple['version'] = $files['version']; 
     591                        $output[] = $tuple; 
     592 
     593                } 
     594                $return['files'] = $output; 
     595                $return['quota']['quotaSize'] = ($quota*1024*1024); 
     596                echo serialize($return); 
     597        } 
     598        function get_folders_list() 
     599        { 
     600                $this->update_groups();  
     601                $this->groups_applications = array(); 
     602 
     603                $user_groups = $GLOBALS['phpgw']->accounts->membership(); 
     604                foreach($user_groups as $val){ 
     605                        $account_name = $GLOBALS['phpgw']->accounts->id2name($val['account_id']); 
     606                        $this->readable_groups[$account_name] = array( 
     607                                'account_id' => $val['account_id'], 
     608                                'account_name' => $account_name 
     609                        ); 
     610                } 
     611 
     612                foreach ($this->readable_groups as $value) 
     613                { 
     614                        $applications = CreateObject('phpgwapi.applications', $value['account_id']); 
     615                        $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); 
     616                } 
     617 
     618 
     619                // selectbox for change/move/and copy to 
     620                $this->dirs = $this->all_other_directories(); 
     621                foreach($this->dirs as $dir) 
     622                        $return[] = $dir['directory'] . $dir['name']; 
     623                sort(&$return, SORT_STRING); 
     624                echo serialize($return); 
     625        } 
     626        function fileListing() 
     627        { 
     628                $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); 
     629                $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); 
     630                $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); 
     631 
     632                if($this->numoffiles || $this->cwd) 
     633                { 
     634                        $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 
     635                        $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
     636                        $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; 
     637                        $_SESSION['phpgw_info']['user']['preferences']['filemanager']['lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; 
     638                        $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; 
     639                        // Used for important operations that needs security 
     640                        for ($key = ""; strlen($key) < 150; $key .= chr(rand(48,95))); 
     641                        $_SESSION['phpgw_info']['filemanager']['user']['sec_key'] = $key; 
     642                        $vars[sec_key]='<input type="hidden" id="userKey" value=\''.$key.'\'>'; 
     643                        $vars[script]='<script>initDrawApi();</script>'; 
     644                         
     645                        $vars[new_button]=$this->toolButton('new','createfile',lang('New...')); 
     646                        $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; 
     647                         
     648                        // reload button with this url 
     649                        $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); 
     650 
     651                        // go up icon when we're not at the top, dont allow to go outside /home = fakebase 
     652                        if($this->path != '/' && $this->path != $this->bo->fakebase) 
     653                        { 
     654                                $vars[tools_button] = $this->toolButton('tools','tools',lang('tools')); 
    516655                        } 
    517656                        else 
    518                         { 
    519                                 $this->bo->vfs->working_id = $this->bo->userinfo['username']; 
    520                         } 
    521  
    522                         # Check available permissions for $this->path, so we can disable unusable operations in user interface 
    523                         $path = explode('/',$this->path); 
    524                         $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); 
    525                         $user_id = $GLOBALS['phpgw_info']['user']['account_id']; 
    526                         if ($owner_id == $user_id) 
    527                         { 
    528                                 $rights = 31; 
    529                         }else 
    530                         { 
    531                                 $acl = CreateObject ('phpgwapi.acl', $owner_id); 
    532                                 $acl->account_id = $owner_id; 
    533                                 $acl->read_repository(); 
    534                                 $rights = $acl->get_rights($user_id); 
    535                         } 
    536                         return $rights;  
    537                 } 
    538                 function dir_ls() 
    539                 { 
    540                         // change dir to this->path 
    541                         $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    542                         $return['permissions'] = $this->get_permissions(); 
    543                         $return['quota']['usedSpace'] = $this->bo->vfs->get_size(array( 
    544                                         'string'        => $this->path, 
    545                                         'relatives'     => array(RELATIVE_NONE) 
     657                                $vars[tools_button] = ""; 
     658 
     659                        $vars[toolbar1]=$toolbar; 
     660 
     661                        if(count($this->messages)>0)  
     662                        { 
     663                                foreach($this->messages as $msg) 
     664                                { 
     665                                        $messages.='<span>'.$msg.'</span>'; 
     666                                } 
     667                        } 
     668                        $this->messages = NULL; 
     669                         
     670                        $vars[messages]=$messages; 
     671 
     672                        $this->t->set_var($vars); 
     673                        $this->t->pparse('out','filemanager_header'); 
     674                } 
     675 
     676                $this->t->set_var($vars); 
     677                $this->t->pparse('out','filemanager_footer'); 
     678 
     679                $GLOBALS['phpgw']->common->phpgw_footer(); 
     680                $GLOBALS['phpgw']->common->phpgw_exit(); 
     681        } 
     682 
     683        function readFilesInfo() 
     684        { 
     685                // start files info 
     686 
     687                # Read in file info from database to use in the rest of the script 
     688                # $fakebase is a special directory.  In that directory, we list the user's 
     689                # home directory and the directories for the groups they're in 
     690                $this->numoffiles = 0; 
     691                if($this->path == $this->bo->fakebase) 
     692                { 
     693                        // FIXME this test can be removed 
     694                        if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) 
     695                        { 
     696                                $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); 
     697                        } 
     698 
     699                        $ls_array = $this->bo->vfs->ls(array( 
     700                                'string' => $this->bo->homedir, 
     701                                'relatives' => array(RELATIVE_NONE), 
     702                                'checksubdirs' => False, 
     703                                'nofiles' => True 
    546704                        )); 
    547                         $return['files_count'] = $this->bo->vfs->count_files(array( 
    548                                         'string'        => $this->path, 
    549                         )); 
    550                         $quota = $this->bo->vfs->get_quota(array( 
    551                                 'string'        => $this->path 
    552                         )); 
    553                         reset($this->files_array); 
    554                         $this->readFilesInfo(); 
    555  
    556                         for($i = 0; $i != $this->numoffiles; $i++) 
    557                         { 
    558                                 $files = $this->files_array[$i]; 
    559  
    560                                 if($files['mime_type'] == "Directory") 
     705 
     706                        $this->files_array[] = $ls_array[0]; 
     707                        $this->numoffiles++; 
     708 
     709                        reset($this->readable_groups); 
     710                        while(list($num, $group_array) = each($this->readable_groups)) 
     711                        { 
     712                                # If the group doesn't have access to this app, we don't show it 
     713                                /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 
    561714                                { 
    562715                                        continue; 
    563716                                } 
    564                                 /* small keys to safe bandwidth */ 
    565                                 $tuple['name'] = htmlentities($files['name']); 
    566                                 if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1){ 
    567                                         if ($files['mime_type'] == 'image/png' ||  
    568                                                 $files['mime_type'] == 'image/gif' ||  
    569                                                 $files['mime_type'] == 'image/jpg') 
    570                                         { 
    571                                                 $filename = str_replace('=','',base64_encode($tuple['name'])); 
    572                                                 $pathname = str_replace('=','',base64_encode($this->path)); 
    573                                                 $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file='.$filename.'&path='.$pathname; 
    574                                         } 
    575                                         else 
    576                                                 $tuple['icon'] =  $this->mime_icon($files['mime_type'],64); 
     717                                */ 
     718 
     719 
     720                                if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'      => array(RELATIVE_NONE)))) 
     721                                { 
     722                                        $this->bo->vfs->override_acl = 1; 
     723                                        $this->bo->vfs->mkdir(array( 
     724                                                'string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
     725                                                'relatives' => array(RELATIVE_NONE) 
     726                                        )); 
     727 
     728                                        // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content 
     729                                         
     730                                         
     731                                        $this->bo->vfs->override_acl = 0; 
     732 
     733                                        $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id']))); 
    577734                                } 
    578                                 else 
    579                                         $tuple['icon'] = $this->mime_icon($files['mime_type']); 
    580                                 $tuple['type'] = $files['type']; 
    581                                 $tuple['created'] = $this->vfs_functions->dateString2timeStamp($files['created']); 
    582                                 $tuple['modified'] = $this->vfs_functions->dateString2timeStamp($files['modified']); 
    583                                 $tuple['size'] = $files['size']; 
    584                                 $tuple['mime_type'] = $files['mime_type']; 
    585                                 $tuple['pub'] = $files['type']; 
    586                                 $tuple['createdby_id'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 
    587                                 $tuple['modifiedby_id'] = $files['modifiedby_id']?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):''; 
    588                                 $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); 
    589                                 $tuple['comment'] = $files['comment']; 
    590                                 $tuple['version'] = $files['version']; 
    591                                 $output[] = $tuple; 
    592  
    593                         } 
    594                         $return['files'] = $output; 
    595                         $return['quota']['quotaSize'] = ($quota*1024*1024); 
    596                         echo serialize($return); 
    597                 } 
    598                 function get_folders_list() 
    599                 { 
    600                         $this->update_groups();  
    601                         $this->groups_applications = array(); 
    602  
    603                         $user_groups = $GLOBALS['phpgw']->accounts->membership(); 
    604                         foreach($user_groups as $val){ 
    605                                 $account_name = $GLOBALS['phpgw']->accounts->id2name($val['account_id']); 
    606                                 $this->readable_groups[$account_name] = array( 
    607                                         'account_id' => $val['account_id'], 
    608                                         'account_name' => $account_name 
    609                                 ); 
    610                         } 
    611  
    612                         foreach ($this->readable_groups as $value) 
    613                         { 
    614                                 $applications = CreateObject('phpgwapi.applications', $value['account_id']); 
    615                                 $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); 
    616                         } 
    617  
    618  
    619                         // selectbox for change/move/and copy to 
    620                         $this->dirs = $this->all_other_directories(); 
    621                         foreach($this->dirs as $dir) 
    622                                 $return[] = $dir['directory'] . $dir['name']; 
    623                         sort(&$return, SORT_STRING); 
    624                         echo serialize($return); 
    625                 } 
    626                 function fileListing() 
    627                 { 
    628                         $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); 
    629                         $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); 
    630                         $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); 
    631  
    632                         if($this->numoffiles || $this->cwd) 
    633                         { 
    634                                 $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 
    635                                 $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
    636                                 $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; 
    637                                 $_SESSION['phpgw_info']['user']['preferences']['filemanager']['lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; 
    638                                 $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; 
    639                                 // Used for important operations that needs security 
    640                                 for ($key = ""; strlen($key) < 150; $key .= chr(rand(48,95))); 
    641                                 $_SESSION['phpgw_info']['filemanager']['user']['sec_key'] = $key; 
    642                                 $vars[sec_key]='<input type="hidden" id="userKey" value=\''.$key.'\'>'; 
    643                                 $vars[script]='<script>initDrawApi();</script>'; 
    644                                  
    645                                 $vars[new_button]=$this->toolButton('new','createfile',lang('New...')); 
    646                                 $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; 
    647                                  
    648                                 // reload button with this url 
    649                                 $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); 
    650  
    651                                 // go up icon when we're not at the top, dont allow to go outside /home = fakebase 
    652                                 if($this->path != '/' && $this->path != $this->bo->fakebase) 
    653                                 { 
    654                                         $vars[tools_button] = $this->toolButton('tools','tools',lang('tools')); 
    655                                 } 
    656                                 else 
    657                                         $vars[tools_button] = ""; 
    658  
    659                                 $vars[toolbar1]=$toolbar; 
    660  
    661                                 if(count($this->messages)>0)  
    662                                 { 
    663                                         foreach($this->messages as $msg) 
    664                                         { 
    665                                                 $messages.='<span>'.$msg.'</span>'; 
    666                                         } 
    667                                 } 
    668                                 $this->messages = NULL; 
    669                                  
    670                                 $vars[messages]=$messages; 
    671  
    672                                 $this->t->set_var($vars); 
    673                                 $this->t->pparse('out','filemanager_header'); 
    674                         } 
    675  
    676                         $this->t->set_var($vars); 
    677                         $this->t->pparse('out','filemanager_footer'); 
    678  
    679                         $GLOBALS['phpgw']->common->phpgw_footer(); 
    680                         $GLOBALS['phpgw']->common->phpgw_exit(); 
    681                 } 
    682  
    683                 function readFilesInfo() 
    684                 { 
    685                         // start files info 
    686  
    687                         # Read in file info from database to use in the rest of the script 
    688                         # $fakebase is a special directory.  In that directory, we list the user's 
    689                         # home directory and the directories for the groups they're in 
    690                         $this->numoffiles = 0; 
    691                         if($this->path == $this->bo->fakebase) 
    692                         { 
    693                                 // FIXME this test can be removed 
    694                                 if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) 
    695                                 { 
    696                                         $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); 
    697                                 } 
    698  
    699                                 $ls_array = $this->bo->vfs->ls(array( 
    700                                         'string' => $this->bo->homedir, 
    701                                         'relatives' => array(RELATIVE_NONE), 
    702                                         'checksubdirs' => False, 
    703                                         'nofiles' => True 
    704                                 )); 
     735 
     736                                $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); 
    705737 
    706738                                $this->files_array[] = $ls_array[0]; 
     739 
    707740                                $this->numoffiles++; 
    708  
    709                                 reset($this->readable_groups); 
    710                                 while(list($num, $group_array) = each($this->readable_groups)) 
    711                                 { 
    712                                         # If the group doesn't have access to this app, we don't show it 
    713                                         /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 
    714                                         { 
    715                                                 continue; 
    716                                         } 
    717                                         */ 
    718  
    719  
    720                                         if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'      => array(RELATIVE_NONE)))) 
    721                                         { 
    722                                                 $this->bo->vfs->override_acl = 1; 
    723                                                 $this->bo->vfs->mkdir(array( 
    724                                                         'string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
    725                                                         'relatives' => array(RELATIVE_NONE) 
    726                                                 )); 
    727  
    728                                                 // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content 
    729                                                  
    730                                                  
    731                                                 $this->bo->vfs->override_acl = 0; 
    732  
    733                                                 $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id']))); 
    734                                         } 
    735  
    736                                         $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); 
    737  
    738                                         $this->files_array[] = $ls_array[0]; 
    739  
    740                                         $this->numoffiles++; 
    741                                 } 
     741                        } 
     742                } 
     743                else 
     744                { 
     745                        $ls_array = $this->bo->vfs->ls(array( 
     746                                'string' => $this->path, 
     747                                'relatives'     => array(RELATIVE_NONE), 
     748                                'checksubdirs' => False, 
     749                                'nofiles'       => False, 
     750                                'orderby'       => $this->criteria, 
     751                                'otype'         => $this->otype, 
     752                                'limit'         => $this->limit, 
     753                                'offset'        => $this->offset 
     754                        )); 
     755 
     756                        while(list($num, $file_array) = each($ls_array)) 
     757                        { 
     758                                $this->numoffiles++; 
     759                                $this->files_array[] = $file_array; 
     760                        } 
     761                } 
     762 
     763                if(!is_array($this->files_array)) 
     764                { 
     765                        $this->files_array = array(); 
     766                } 
     767                // end file count 
     768        } 
     769         
     770        function removedir() 
     771        { 
     772                //$toRemove = $this->path ^ $_SESSION['phpgw_info']['filemanager']['user']['sec_key']; 
     773                $toRemove = $this->path; 
     774                 
     775                if ( $this->bo->vfs->rm(array( 'string' => $toRemove, 'relatives' => array (RELATIVE_NONE) )) ) 
     776                        echo "True"; 
     777                else 
     778                        echo "False"; 
     779        } 
     780         
     781        function createdir() 
     782        { 
     783                if( $this->bo->badchar = $this->bo->bad_chars($this->filename, True, True) ) 
     784                { 
     785                        echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
     786                        return; 
     787                } 
     788                /* TODO is this right or should it be a single $ ? */ 
     789                if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ') 
     790                { 
     791                        echo lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
     792                } 
     793                 
     794                $ls_array = $this->bo->vfs->ls(array( 
     795                        'string'        => $this->path . '/' . $this->filename, 
     796                        'relatives'     => array(RELATIVE_NONE), 
     797                        'checksubdirs'  => False, 
     798                        'nofiles'       => True 
     799                )); 
     800 
     801                $fileinfo = $ls_array[0]; 
     802 
     803                if($fileinfo['name']) 
     804                { 
     805                        if($fileinfo['mime_type'] != 'Directory') 
     806                        { 
     807                                echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    742808                        } 
    743809                        else 
    744810                        { 
    745                                 $ls_array = $this->bo->vfs->ls(array( 
    746                                         'string' => $this->path, 
    747                                         'relatives'     => array(RELATIVE_NONE), 
    748                                         'checksubdirs' => False, 
    749                                         'nofiles'       => False, 
    750                                         'orderby'       => $this->criteria, 
    751                                         'otype'         => $this->otype, 
    752                                         'limit'         => $this->limit, 
    753                                         'offset'        => $this->offset 
    754                                 )); 
    755  
    756                                 while(list($num, $file_array) = each($ls_array)) 
    757                                 { 
    758                                         $this->numoffiles++; 
    759                                         $this->files_array[] = $file_array; 
    760                                 } 
    761                         } 
    762  
    763                         if(!is_array($this->files_array)) 
    764                         { 
    765                                 $this->files_array = array(); 
    766                         } 
    767                         // end file count 
    768                 } 
     811                                echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
     812                        } 
     813                } 
     814                else 
     815                { 
     816                        $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     817                         
     818                        if( $this->bo->vfs->mkdir(array('string' => $this->filename )) ) 
     819                        { 
     820                                echo lang('Created directory %1', $this->disppath.'/'.$this->filename); 
     821                        } 
     822                        else 
     823                        { 
     824                                echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename); 
     825                        } 
     826                } 
     827                echo lang('Directory created'); 
     828        } 
     829         
     830        function getReturnExecuteForm() 
     831        { 
     832                $response = $_SESSION['response']; 
    769833                 
    770                 function removedir() 
    771                 { 
    772                         //$toRemove = $this->path ^ $_SESSION['phpgw_info']['filemanager']['user']['sec_key']; 
    773                         $toRemove = $this->path; 
    774                          
    775                         if ( $this->bo->vfs->rm(array( 'string' => $toRemove, 'relatives' => array (RELATIVE_NONE) )) ) 
    776                                 echo "True"; 
    777                         else 
    778                                 echo "False"; 
    779                 } 
     834                unset($_SESSION['response']); 
    780835                 
    781                 function createdir() 
    782                 { 
    783                         if( $this->bo->badchar = $this->bo->bad_chars($this->filename, True, True) ) 
    784                         { 
    785                                 echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
    786                                 return; 
    787                         } 
    788                         /* TODO is this right or should it be a single $ ? */ 
    789                         if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ') 
    790                         { 
    791                                 echo lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
    792                         } 
    793                          
    794                         $ls_array = $this->bo->vfs->ls(array( 
    795                                 'string'        => $this->path . '/' . $this->filename, 
    796                                 'relatives'     => array(RELATIVE_NONE), 
    797                                 'checksubdirs'  => False, 
    798                                 'nofiles'       => True 
    799                         )); 
    800  
    801                         $fileinfo = $ls_array[0]; 
    802  
    803                         if($fileinfo['name']) 
    804                         { 
    805                                 if($fileinfo['mime_type'] != 'Directory') 
    806                                 { 
    807                                         echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    808                                 } 
    809                                 else 
    810                                 { 
    811                                         echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
    812                                 } 
    813                         } 
    814                         else 
    815                         { 
    816                                 $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    817                                  
    818                                 if( $this->bo->vfs->mkdir(array('string' => $this->filename )) ) 
    819                                 { 
    820                                         echo lang('Created directory %1', $this->disppath.'/'.$this->filename); 
    821                                 } 
    822                                 else 
    823                                 { 
    824                                         echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename); 
    825                                 } 
    826                         } 
    827                         echo lang('Directory created'); 
    828                 } 
     836                echo $response; 
     837        } 
     838         
     839        function showUploadboxes() 
     840        { 
     841                $notify = CreateObject('filemanager.notifications'); 
    829842                 
    830                 function getReturnExecuteForm() 
    831                 { 
    832                         $response = $_SESSION['response']; 
    833                          
    834                         unset($_SESSION['response']); 
    835                          
    836                         echo $response; 
    837                 } 
     843                $var = array( 
     844                                        'change_upload_boxes'   => lang('Show'),                                 
     845                                        'form_action'                   => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), 
     846                                        'emails_to'                             => $notify->EmailsToSend($GLOBALS['phpgw']->preferences->values['email']), 
     847                                        'lang_file'                             => lang('File'), 
     848                                        'lang_comment'                  => lang('Comment'), 
     849                                        'lang_advanced_upload'  => lang('Advanced Upload'), 
     850                                        'lang_upload'                   => lang('Upload files'), 
     851                                        'max_size'                              => lang('Note: Uploaded is limited to %1MB',( $this->current_config['filemanager_Max_file_size'])),                              
     852                                        'path'                                  => $this->path 
     853                ); 
    838854                 
    839                 function showUploadboxes() 
    840                 { 
    841                         $var = array( 
    842                                                 'change_upload_boxes'   => lang('Show'),                                 
    843                                                 'form_action'                   => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), 
    844                                                 'lang_file'                             => lang('File'), 
    845                                                 'lang_comment'                  => lang('Comment'), 
    846                                                 'lang_advanced_upload'  => lang('Advanced Upload'), 
    847                                                 'lang_upload'                   => lang('Upload files'), 
    848                                                 'max_size'                              => lang('Note: Uploaded is limited to %1MB',( $this->current_config['filemanager_Max_file_size'])),                              
    849                                                 'path'                                  => $this->path 
    850                                         ); 
    851                          
    852                         print( serialize($var) ); 
    853                          
    854                 } 
    855  
    856                 /* create textfile */ 
    857                 function createfile() 
    858                 { 
    859                         $this->filename=$this->newfile_or_dir; 
    860                         if($this->filename) 
    861                         { 
    862                                 if($badchar = $this->bo->bad_chars($this->filename, True, True)) 
    863                                 { 
    864                                         $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); 
    865  
    866                                         $this->fileListing(); 
    867                                 } 
    868  
    869                                 if($this->bo->vfs->file_exists(array( 
    870                                         'string'=> $this->filename, 
    871                                         'relatives'     => array(RELATIVE_ALL) 
    872                                 ))) 
    873                                 { 
    874                                         $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 
    875                                         $this->fileListing(); 
    876                                 } 
    877  
    878                                 if($this->bo->vfs->touch(array( 
    879                                         'string'        => $this->filename, 
    880                                         'relatives'     => array(RELATIVE_ALL) 
    881                                 ))) 
    882                                 { 
    883                                         $this->edit = 1; 
    884                                         $this->numoffiles++; 
    885                                         $this->edit(); 
    886                                 } 
    887                                 else 
    888                                 { 
    889                                         $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename); 
    890                                         $this->fileListing(); 
    891                                 } 
    892                         } 
    893                 } 
    894  
    895                 # Handle Editing files 
    896                 function edit() 
    897                 { 
    898                         if($this->filename) 
    899                         { 
    900                                 if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){ 
    901                                         $GLOBALS['phpgw']->redirect('/index.php'); 
    902                                 } 
    903                                 $ls_array = $this->bo->vfs->ls(array( 
    904                                         'string'        => $this->path.'/'.$this->filename, 
    905                                         'relatives'     => array(RELATIVE_NONE), 
    906                                         'checksubdirs'  => False, 
    907                                         'nofiles'       => True 
    908                                 )); 
    909                                 $this->bo->vfs->touch(array( 
    910                                         'string'=> $this->path.'/'.$this->filename, 
    911                                         'relatives'     => array(RELATIVE_NONE) 
    912                                 )); 
    913  
    914  
    915                                 if($ls_array[0]['mime_type']) 
    916                                 { 
    917                                         $mime_type = $ls_array[0]['mime_type']; 
    918                                 } 
    919                                 elseif($this->prefs['viewtextplain']) 
    920                                 { 
    921                                         $mime_type = 'text/plain'; 
    922                                 } 
    923                                 $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822'); 
    924  
    925                                 if(!in_array($mime_type,$editable)){ 
    926                                         $this->messages[] = lang('Error:').lang('Impossible to edit this file'); 
    927                                         $this->readFilesInfo(); 
    928                                         $this->fileListing(); 
    929                                         return; 
    930                                 } 
    931                         } 
    932  
    933                         $this->readFilesInfo(); 
    934  
    935                         if ($mime_type == 'text/html') 
    936                                 $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); 
    937                         else 
    938                                 $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
    939  
    940                         $this->t->set_block('filemanager_edit','row','row'); 
    941  
    942  
    943                         $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 
    944  
    945                         $vars[preview_content]=''; 
    946                         if($this->edit_file) 
    947                         { 
    948                                 $this->edit_file_content = stripslashes($this->edit_file_content); 
    949                         } 
    950  
    951                         if($this->edit_preview_x) 
    952                         { 
    953                                 $content = $this->edit_file_content; 
    954  
    955                                 $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); 
    956  
    957                                 $vars[preview_content]=nl2br($content); 
    958                         } 
    959                         elseif($this->edit_save_x || $this->edit_save_done_x) 
    960                         { 
    961                                 $content = $this->edit_file_content; 
    962                                 //die( $content); 
    963                                 if($this->bo->vfs->write(array( 
    964                                         'string'        => $this->path.'/'.$this->edit_file, 
    965                                         'relatives'     => array(RELATIVE_NONE), 
    966                                         'content'       => $content 
    967                                 ))) 
    968                                 { 
    969                                         $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); 
    970  
    971                                         if($this->edit_save_done_x) 
    972                                         { 
    973                                                 $this->readFilesInfo(); 
    974                                                 $this->fileListing(); 
    975                                                 exit; 
    976                                         } 
    977                                 } 
    978                                 else 
    979                                 { 
    980                                         $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); 
    981                                 } 
    982                         } 
    983  
    984                         # If we're in preview or save mode, we only show the file 
    985                         # being previewed or saved 
    986                         if($this->edit_file &&($this->filename != $this->edit_file)) 
    987                         { 
    988                                 continue; 
    989                         } 
    990  
    991                         if($this->filename && $this->bo->vfs->file_exists(array( 
     855                print( serialize($var) ); 
     856                 
     857        } 
     858 
     859        /* create textfile */ 
     860        function createfile() 
     861        { 
     862                $this->filename=$this->newfile_or_dir; 
     863                if($this->filename) 
     864                { 
     865                        if($badchar = $this->bo->bad_chars($this->filename, True, True)) 
     866                        { 
     867                                $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); 
     868 
     869                                $this->fileListing(); 
     870                        } 
     871 
     872                        if($this->bo->vfs->file_exists(array( 
     873                                'string'=> $this->filename, 
     874                                'relatives'     => array(RELATIVE_ALL) 
     875                        ))) 
     876                        { 
     877                                $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 
     878                                $this->fileListing(); 
     879                        } 
     880 
     881                        if($this->bo->vfs->touch(array( 
    992882                                'string'        => $this->filename, 
    993883                                'relatives'     => array(RELATIVE_ALL) 
    994884                        ))) 
    995885                        { 
    996                                 if($this->edit_file) 
     886                                $this->edit = 1; 
     887                                $this->numoffiles++; 
     888                                $this->edit(); 
     889                        } 
     890                        else 
     891                        { 
     892                                $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename); 
     893                                $this->fileListing(); 
     894                        } 
     895                } 
     896        } 
     897 
     898        # Handle Editing files 
     899        function edit() 
     900        { 
     901                if($this->filename) 
     902                { 
     903                        if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){ 
     904                                $GLOBALS['phpgw']->redirect('/index.php'); 
     905                        } 
     906                        $ls_array = $this->bo->vfs->ls(array( 
     907                                'string'        => $this->path.'/'.$this->filename, 
     908                                'relatives'     => array(RELATIVE_NONE), 
     909                                'checksubdirs'  => False, 
     910                                'nofiles'       => True 
     911                        )); 
     912                        $this->bo->vfs->touch(array( 
     913                                'string'=> $this->path.'/'.$this->filename, 
     914                                'relatives'     => array(RELATIVE_NONE) 
     915                        )); 
     916 
     917 
     918                        if($ls_array[0]['mime_type']) 
     919                        { 
     920                                $mime_type = $ls_array[0]['mime_type']; 
     921                        } 
     922                        elseif($this->prefs['viewtextplain']) 
     923                        { 
     924                                $mime_type = 'text/plain'; 
     925                        } 
     926                        $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822'); 
     927 
     928                        if(!in_array($mime_type,$editable)){ 
     929                                $this->messages[] = lang('Error:').lang('Impossible to edit this file'); 
     930                                $this->readFilesInfo(); 
     931                                $this->fileListing(); 
     932                                return; 
     933                        } 
     934                } 
     935 
     936                $this->readFilesInfo(); 
     937 
     938                if ($mime_type == 'text/html') 
     939                        $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); 
     940                else 
     941                        $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
     942 
     943                $this->t->set_block('filemanager_edit','row','row'); 
     944 
     945 
     946                $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 
     947 
     948                $vars[preview_content]=''; 
     949                if($this->edit_file) 
     950                { 
     951                        $this->edit_file_content = stripslashes($this->edit_file_content); 
     952                } 
     953 
     954                if($this->edit_preview_x) 
     955                { 
     956                        $content = $this->edit_file_content; 
     957 
     958                        $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); 
     959 
     960                        $vars[preview_content]=nl2br($content); 
     961                } 
     962                elseif($this->edit_save_x || $this->edit_save_done_x) 
     963                { 
     964                        $content = $this->edit_file_content; 
     965                        //die( $content); 
     966                        if($this->bo->vfs->write(array( 
     967                                'string'        => $this->path.'/'.$this->edit_file, 
     968                                'relatives'     => array(RELATIVE_NONE), 
     969                                'content'       => $content 
     970                        ))) 
     971                        { 
     972                                $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); 
     973 
     974                                if($this->edit_save_done_x) 
    997975                                { 
    998                                         $content = stripslashes($this->edit_file_content); 
     976                                        $this->readFilesInfo(); 
     977                                        $this->fileListing(); 
     978                                        exit; 
    999979                                } 
    1000                                 else 
    1001                                 { 
    1002                                         $content = $this->bo->vfs->read(array('string' => $this->filename)); 
    1003                                 } 
    1004                                 $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); 
    1005                                 $vars[edit_file]=$this->filename; 
    1006                                 # We need to include all of the fileman entries for each file's form, 
    1007                                 # so we loop through again 
    1008                                 for($i = 0; $i != $this->numoffiles; $i++) 
    1009                                 { 
    1010                                         if($this->filename) $value='value="'.$this->filename.'"'; 
    1011                                         $vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />'; 
    1012                                 } 
    1013                                 $vars[file_content]=$content; 
    1014  
    1015                                 $vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); 
    1016                                 $vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1))); 
    1017                                 $vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); 
    1018                                 $vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); 
    1019  
    1020                                 if ($mime_type == 'text/html'){ 
    1021                                         $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> 
    1022                                                 <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea> 
     980                        } 
     981                        else 
     982                        { 
     983                                $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); 
     984                        } 
     985                } 
     986 
     987                # If we're in preview or save mode, we only show the file 
     988                # being previewed or saved 
     989                if($this->edit_file &&($this->filename != $this->edit_file)) 
     990                { 
     991                        continue; 
     992                } 
     993 
     994                if($this->filename && $this->bo->vfs->file_exists(array( 
     995                        'string'        => $this->filename, 
     996                        'relatives'     => array(RELATIVE_ALL) 
     997                ))) 
     998                { 
     999                        if($this->edit_file) 
     1000                        { 
     1001                                $content = stripslashes($this->edit_file_content); 
     1002                        } 
     1003                        else 
     1004                        { 
     1005                                $content = $this->bo->vfs->read(array('string' => $this->filename)); 
     1006                        } 
     1007                        $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); 
     1008                        $vars[edit_file]=$this->filename; 
     1009                        # We need to include all of the fileman entries for each file's form, 
     1010                        # so we loop through again 
     1011                        for($i = 0; $i != $this->numoffiles; $i++) 
     1012                        { 
     1013                                if($this->filename) $value='value="'.$this->filename.'"'; 
     1014                                $vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />'; 
     1015                        } 
     1016                        $vars[file_content]=$content; 
     1017 
     1018                        $vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); 
     1019                        $vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1))); 
     1020                        $vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); 
     1021                        $vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); 
     1022 
     1023                        if ($mime_type == 'text/html'){ 
     1024                                $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> 
     1025                                        <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea> 
    10231026                                                <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ 
    10241027removePlugins : \'elementspath\', 
     
    10341037                                });</script>'; 
    10351038 
    1036                                 } 
    1037  
    1038  
    1039                                 $this->t->set_var($vars); 
    1040                                 $this->t->parse('rows','row'); 
    1041                                 $this->t->pparse('out','row'); 
    1042  
    1043                         } 
    1044  
    1045                 } 
    1046  
    1047                 function history() 
    1048                 { 
    1049                         if($this->file) // FIXME this-file is never defined 
    1050                         { 
    1051                                 $journal_array = $this->bo->vfs->get_journal(array( 
    1052                                         'string'        => $this->file,//FIXME 
    1053                                         'relatives'     => array(RELATIVE_ALL) 
    1054                                 )); 
    1055  
    1056                                 if(is_array($journal_array)) 
     1039                        } 
     1040 
     1041 
     1042                        $this->t->set_var($vars); 
     1043                        $this->t->parse('rows','row'); 
     1044                        $this->t->pparse('out','row'); 
     1045 
     1046                } 
     1047 
     1048        } 
     1049 
     1050        function history() 
     1051        { 
     1052                if($this->file) // FIXME this-file is never defined 
     1053                { 
     1054                        $journal_array = $this->bo->vfs->get_journal(array( 
     1055                                'string'        => $this->file,//FIXME 
     1056                                'relatives'     => array(RELATIVE_ALL) 
     1057                        )); 
     1058 
     1059                        if(is_array($journal_array)) 
     1060                        { 
     1061                                $this->html_table_begin(); 
     1062                                $this->html_table_row_begin(); 
     1063                                $this->html_table_col_begin(); 
     1064                                echo lang('Date'); 
     1065                                $this->html_table_col_end(); 
     1066                                $this->html_table_col_begin(); 
     1067                                echo lang('Version'); 
     1068                                $this->html_table_col_end(); 
     1069                                $this->html_table_col_begin(); 
     1070                                echo lang('Who'); 
     1071                                $this->html_table_col_end(); 
     1072                                $this->html_table_col_begin(); 
     1073                                echo lang('Operation'); 
     1074                                $this->html_table_col_end(); 
     1075                                $this->html_table_row_end(); 
     1076 
     1077                                while(list($num, $journal_entry) = each($journal_array)) 
    10571078                                { 
    1058                                         $this->html_table_begin(); 
    10591079                                        $this->html_table_row_begin(); 
    10601080                                        $this->html_table_col_begin(); 
    1061                                         echo lang('Date'); 
     1081                                        $this->bo->html_text($journal_entry['created'] . '&nbsp;&nbsp;&nbsp;'); 
    10621082                                        $this->html_table_col_end(); 
    10631083                                        $this->html_table_col_begin(); 
    1064                                         echo lang('Version'); 
     1084                                        $this->bo->html_text($journal_entry['version'] . '&nbsp;&nbsp;&nbsp;' ); 
    10651085                                        $this->html_table_col_end(); 
    10661086                                        $this->html_table_col_begin(); 
    1067                                         echo lang('Who'); 
     1087                                        $this->bo->html_text($GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']) . '&nbsp;&nbsp;&nbsp;'); 
    10681088                                        $this->html_table_col_end(); 
    10691089                                        $this->html_table_col_begin(); 
    1070                                         echo lang('Operation'); 
     1090                                        $this->bo->html_text($journal_entry['comment']); 
    10711091                                        $this->html_table_col_end(); 
    1072                                         $this->html_table_row_end(); 
    1073  
    1074                                         while(list($num, $journal_entry) = each($journal_array)) 
    1075                                         { 
    1076                                                 $this->html_table_row_begin(); 
    1077                                                 $this->html_table_col_begin(); 
    1078                                                 $this->bo->html_text($journal_entry['created'] . '&nbsp;&nbsp;&nbsp;'); 
    1079                                                 $this->html_table_col_end(); 
    1080                                                 $this->html_table_col_begin(); 
    1081                                                 $this->bo->html_text($journal_entry['version'] . '&nbsp;&nbsp;&nbsp;' ); 
    1082                                                 $this->html_table_col_end(); 
    1083                                                 $this->html_table_col_begin(); 
    1084                                                 $this->bo->html_text($GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']) . '&nbsp;&nbsp;&nbsp;'); 
    1085                                                 $this->html_table_col_end(); 
    1086                                                 $this->html_table_col_begin(); 
    1087                                                 $this->bo->html_text($journal_entry['comment']); 
    1088                                                 $this->html_table_col_end(); 
    1089                                         } 
    1090  
    1091                                         $this->html_table_end(); 
    1092                                         $GLOBALS['phpgw']->common->phpgw_footer(); 
    1093                                         $GLOBALS['phpgw']->common->phpgw_exit(); 
    10941092                                } 
    1095                                 else 
    1096                                 { 
    1097                                         echo lang('No version history for this file/directory'); 
    1098                                 } 
    1099                         } 
    1100                 } 
    1101                 function view() 
    1102                 { 
    1103                         if (!$this->bo->vfs->acl_check(array( 
    1104                                 'string'        => $this->path, 
     1093 
     1094                                $this->html_table_end(); 
     1095                                $GLOBALS['phpgw']->common->phpgw_footer(); 
     1096                                $GLOBALS['phpgw']->common->phpgw_exit(); 
     1097                        } 
     1098                        else 
     1099                        { 
     1100                                echo lang('No version history for this file/directory'); 
     1101                        } 
     1102                } 
     1103        } 
     1104        function view() 
     1105        { 
     1106                if (!$this->bo->vfs->acl_check(array( 
     1107                        'string'        => $this->path, 
     1108                        'relatives'     => array(RELATIVE_NONE), 
     1109                        'operation'     => PHPGW_ACL_READ 
     1110                ))) 
     1111                { 
     1112                        $this->messages[] = lang("You have no permission to access this file"); 
     1113                        header('Location:'.$this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
     1114 
     1115                        return; 
     1116                } 
     1117                if($this->file) //FIXME 
     1118                { 
     1119                        $ls_array = $this->bo->vfs->ls(array( 
     1120                                'string'        => $this->path.'/'.$this->file,//FIXME 
     1121                                'relatives'     => array(RELATIVE_NONE), 
     1122                                'checksubdirs'  => False, 
     1123                                'nofiles'       => True 
     1124                        )); 
     1125                        if($ls_array[0]['mime_type']) 
     1126                        { 
     1127                                $mime_type = $ls_array[0]['mime_type']; 
     1128                        } 
     1129                        elseif($this->prefs['viewtextplain']) 
     1130                        { 
     1131                                $mime_type = 'text/plain'; 
     1132                        } 
     1133                        $viewable = array('text/plain','text/csv','text/html', 
     1134                                'text/text','image/jpeg','image/png','image/gif', 
     1135                                'audio/mpeg','video/mpeg'); 
     1136 
     1137                        if(in_array($mime_type,$viewable))  
     1138                        { 
     1139                                /*Note: if you put application/octet-stream you force download */ 
     1140                                header('Content-type: ' . $mime_type); 
     1141                                header('Content-disposition: filename="' . addslashes($this->file) . '"'); 
     1142                                Header("Pragma: public"); 
     1143                        } 
     1144                        else 
     1145                        { 
     1146                                $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type,$ls_array[0]['size']); 
     1147                        } 
     1148                        if ($ls_array[0]['size'] < 10240) 
     1149                        { 
     1150                                echo $this->bo->vfs->read(array( 
     1151                                        'string'    => $this->path.'/'.$this->file,//FIXME 
     1152                                        'relatives'    => array(RELATIVE_NONE) 
     1153                                )); 
     1154                        } 
     1155                        else 
     1156                        { 
     1157                                $this->bo->vfs->print_content(array( 
     1158                                        'string' => $this->path.'/'.$this->file, 
     1159                                        'relatives' => array(RELATIVE_NONE) 
     1160                                ) 
     1161                        ); 
     1162                        } 
     1163                        $GLOBALS['phpgw']->common->phpgw_exit(); 
     1164                } 
     1165        } 
     1166 
     1167        function export(){ 
     1168                if($this->file) 
     1169                { 
     1170                        $ls_array = $this->bo->vfs->ls(array( 
     1171                                'string'        => $this->path.'/'.$this->file, 
    11051172                                'relatives'     => array(RELATIVE_NONE), 
    1106                                 'operation'     => PHPGW_ACL_READ 
    1107                         ))) 
    1108                         { 
    1109                                 $this->messages[] = lang("You have no permission to access this file"); 
    1110                                 header('Location:'.$this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
    1111  
    1112                                 return; 
    1113                         } 
    1114                         if($this->file) //FIXME 
    1115                         { 
    1116                                 $ls_array = $this->bo->vfs->ls(array( 
    1117                                         'string'        => $this->path.'/'.$this->file,//FIXME 
    1118                                         'relatives'     => array(RELATIVE_NONE), 
    1119                                         'checksubdirs'  => False, 
    1120                                         'nofiles'       => True 
    1121                                 )); 
    1122                                 if($ls_array[0]['mime_type']) 
    1123                                 { 
    1124                                         $mime_type = $ls_array[0]['mime_type']; 
    1125                                 } 
    1126                                 elseif($this->prefs['viewtextplain']) 
    1127                                 { 
    1128                                         $mime_type = 'text/plain'; 
    1129                                 } 
    1130                                 $viewable = array('text/plain','text/csv','text/html', 
    1131                                         'text/text','image/jpeg','image/png','image/gif', 
    1132                                         'audio/mpeg','video/mpeg'); 
    1133  
    1134                                 if(in_array($mime_type,$viewable))  
    1135                                 { 
    1136                                         /*Note: if you put application/octet-stream you force download */ 
    1137                                         header('Content-type: ' . $mime_type); 
    1138                                         header('Content-disposition: filename="' . addslashes($this->file) . '"'); 
    1139                                         Header("Pragma: public"); 
    1140                                 } 
    1141                                 else 
    1142                                 { 
    1143                                         $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type,$ls_array[0]['size']); 
    1144                                 } 
    1145                                 if ($ls_array[0]['size'] < 10240) 
    1146                                 { 
    1147                                         echo $this->bo->vfs->read(array( 
    1148                                                 'string'    => $this->path.'/'.$this->file,//FIXME 
    1149                                                 'relatives'    => array(RELATIVE_NONE) 
    1150                                         )); 
    1151                                 } 
    1152                                 else 
    1153                                 { 
    1154                                         $this->bo->vfs->print_content(array( 
    1155                                                 'string' => $this->path.'/'.$this->file, 
    1156                                                 'relatives' => array(RELATIVE_NONE) 
    1157                                         ) 
    1158                                 ); 
    1159                                 } 
    1160                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1161                         } 
    1162                 } 
    1163  
    1164                 function export(){ 
    1165                         if($this->file) 
    1166                         { 
    1167                                 $ls_array = $this->bo->vfs->ls(array( 
    1168                                         'string'        => $this->path.'/'.$this->file, 
    1169                                         'relatives'     => array(RELATIVE_NONE), 
    1170                                         'checksubdirs'  => False, 
    1171                                         'nofiles'       => True 
    1172                                 )); 
    1173                                 /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 
    1174                                 if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
    1175                                 { 
    1176                                         // recently than last minute: someone is editing 
    1177                                 }*/ 
    1178                                 $mime_type = $ls_array[0]['mime_type']; 
    1179                                 $formats = array('text/html'); 
    1180                                 if(!in_array($mime_type,$formats)){ 
    1181                                         echo lang('Impossible to export this file'); 
    1182                                         return False; 
    1183                                 } 
    1184                                 $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file, 
    1185                                                'relatives'     => array(RELATIVE_NONE) 
    1186                                        )); 
    1187  
    1188                                 include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); 
    1189                                 $dompdf = new DOMPDF(); 
    1190                                 $dompdf->load_html($content); 
    1191                                 $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); 
    1192                                 /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate'*/ 
    1193                                 $dompdf->render(); 
    1194                                 $dompdf->stream(strtok($this->file,'.').".pdf"); 
    1195                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1196                         } 
    1197                 } 
    1198  
    1199                 //give back an array with all directories except current and dirs that are not accessable 
    1200                 function all_other_directories() 
    1201                 { 
    1202                         # First we get the directories in their home directory 
    1203                         $dirs = array(); 
    1204                         $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); 
     1173                                'checksubdirs'  => False, 
     1174                                'nofiles'       => True 
     1175                        )); 
     1176                        /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 
     1177                        if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
     1178                        { 
     1179                                // recently than last minute: someone is editing 
     1180                        }*/ 
     1181                        $mime_type = $ls_array[0]['mime_type']; 
     1182                        $formats = array('text/html'); 
     1183                        if(!in_array($mime_type,$formats)){ 
     1184                                echo lang('Impossible to export this file'); 
     1185                                return False; 
     1186                        } 
     1187                        $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file, 
     1188                                       'relatives'     => array(RELATIVE_NONE) 
     1189                               )); 
     1190 
     1191                        include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); 
     1192                        $dompdf = new DOMPDF(); 
     1193                        $dompdf->load_html($content); 
     1194                        $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); 
     1195                        /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate'*/ 
     1196                        $dompdf->render(); 
     1197                        $dompdf->stream(strtok($this->file,'.').".pdf"); 
     1198                        $GLOBALS['phpgw']->common->phpgw_exit(); 
     1199                } 
     1200        } 
     1201 
     1202        //give back an array with all directories except current and dirs that are not accessable 
     1203        function all_other_directories() 
     1204        { 
     1205                # First we get the directories in their home directory 
     1206                $dirs = array(); 
     1207                $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); 
     1208 
     1209                $tmp_arr=array( 
     1210                        'string'        => $this->bo->homedir, 
     1211                        'relatives'     => array(RELATIVE_NONE), 
     1212                        'checksubdirs'  => True, 
     1213                        'mime_type'     => 'Directory' 
     1214                ); 
     1215 
     1216                $ls_array = $this->bo->vfs->ls($tmp_arr,True); 
     1217 
     1218                while(list($num, $dir) = each($ls_array)) 
     1219                { 
     1220                        $dirs[] = $dir; 
     1221                } 
     1222 
     1223 
     1224                # Then we get the directories in their readable groups' home directories 
     1225                reset($this->readable_groups); 
     1226                while(list($num, $group_array) = each($this->readable_groups)) 
     1227                { 
     1228                        // Don't list directories for groups that don't exists 
     1229                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
     1230                                'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     1231                        if($test[mime_type]!='Directory') 
     1232                        { 
     1233                                continue; 
     1234                        } 
     1235 
     1236                        $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); 
    12051237 
    12061238                        $tmp_arr=array( 
    1207                                 'string'        => $this->bo->homedir, 
     1239                                'string'        => $this->bo->fakebase.'/'.$group_array['account_name'], 
    12081240                                'relatives'     => array(RELATIVE_NONE), 
    12091241                                'checksubdirs'  => True, 
     
    12121244 
    12131245                        $ls_array = $this->bo->vfs->ls($tmp_arr,True); 
    1214  
    12151246                        while(list($num, $dir) = each($ls_array)) 
    12161247                        { 
    12171248                                $dirs[] = $dir; 
    12181249                        } 
    1219  
    1220  
    1221                         # Then we get the directories in their readable groups' home directories 
    1222                         reset($this->readable_groups); 
    1223                         while(list($num, $group_array) = each($this->readable_groups)) 
    1224                         { 
    1225                                 // Don't list directories for groups that don't exists 
    1226                                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
    1227                                         'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    1228                                 if($test[mime_type]!='Directory') 
     1250                } 
     1251                reset($dirs); 
     1252                while(list($num, $dir) = each($dirs)) 
     1253                { 
     1254                        if(!$dir['directory']) 
     1255                        { 
     1256                                continue; 
     1257                        } 
     1258 
     1259                        # So we don't display // 
     1260                        if($dir['directory'] != '/') 
     1261                        { 
     1262                                $dir['directory'] .= '/'; 
     1263                        } 
     1264                        $return[] = $dir; 
     1265                } 
     1266                return $return; 
     1267        } 
     1268 
     1269        function update_groups() 
     1270        { 
     1271                # Get their readable groups to be used throughout the script 
     1272                $acl = array(); 
     1273                $groups = array(); 
     1274                $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager'); 
     1275                if (is_array($acl)) 
     1276                        foreach($acl as $key => $value){ 
     1277                                $info = array(); 
     1278                                $info = $GLOBALS['phpgw']->accounts->get_account_data($value); 
     1279                                $groups[$key]['account_id'] = $value; 
     1280                                $groups[$key]['account_lid'] = $info[$value]['lid']; 
     1281                                $groups[$key]['account_name'] = $info[$value]['firstname']; 
     1282                                $groups[$key]['account_lastname'] = $info[$value]['lastname']; 
     1283                                $groups[$key]['account_fullname'] = $info[$value]['fullname']; 
     1284                        } 
     1285                $this->readable_groups = array(); 
     1286                while(list($num, $account) = each($groups)) 
     1287                { 
     1288                        if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) 
     1289                        { 
     1290                                $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); 
     1291                        } 
     1292                } 
     1293 
     1294        } 
     1295        function search() 
     1296        { 
     1297                /* TODO this is a primitive search */ 
     1298                $this->update_groups(); 
     1299                        $this->dirs = $this->all_other_directories(); 
     1300                $path = $this->path; 
     1301                if (strlen($this->text) > 3) 
     1302                {                                                                 
     1303                        $this->text = strtoupper($this->text); 
     1304                        foreach($this->dirs as $elem) 
     1305                        { 
     1306                                $this->path = $elem['directory'].$elem['name']; 
     1307                                reset($this->files_array); 
     1308                                $this->readFilesInfo(); 
     1309                                for($i = 0; $i < count($this->files_array); $i++) 
    12291310                                { 
    1230                                         continue; 
     1311                                        $comment = strtoupper($this->files_array[$i]['comment']); 
     1312                                        $name = strtoupper($this->files_array[$i]['name']); 
     1313                                        if (strstr($name,$this->text) || 
     1314                                        strstr($comment,$this->text) ){ 
     1315                                                $return[$this->files_array[$i]['directory'].$name] = $this->files_array[$i]; 
     1316                                                $return[$this->files_array[$i]['directory'].$name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); 
     1317                                        } 
    12311318                                } 
    1232  
    1233                                 $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); 
    1234  
    1235                                 $tmp_arr=array( 
    1236                                         'string'        => $this->bo->fakebase.'/'.$group_array['account_name'], 
    1237                                         'relatives'     => array(RELATIVE_NONE), 
    1238                                         'checksubdirs'  => True, 
    1239                                         'mime_type'     => 'Directory' 
    1240                                 ); 
    1241  
    1242                                 $ls_array = $this->bo->vfs->ls($tmp_arr,True); 
    1243                                 while(list($num, $dir) = each($ls_array)) 
     1319                                if (count($return) > 50) 
    12441320                                { 
    1245                                         $dirs[] = $dir; 
     1321                                        $return = array_slice($return,0,50); 
     1322                                        break; 
    12461323                                } 
    1247                         } 
    1248                         reset($dirs); 
    1249                         while(list($num, $dir) = each($dirs)) 
    1250                         { 
    1251                                 if(!$dir['directory']) 
    1252                                 { 
    1253                                         continue; 
    1254                                 } 
    1255  
    1256                                 # So we don't display // 
    1257                                 if($dir['directory'] != '/') 
    1258                                 { 
    1259                                         $dir['directory'] .= '/'; 
    1260                                 } 
    1261                                 $return[] = $dir; 
    1262                         } 
    1263                         return $return; 
    1264                 } 
    1265  
    1266                 function update_groups() 
    1267                 { 
    1268                         # Get their readable groups to be used throughout the script 
    1269                         $acl = array(); 
    1270                         $groups = array(); 
    1271                         $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager'); 
    1272                         if (is_array($acl)) 
    1273                                 foreach($acl as $key => $value){ 
    1274                                         $info = array(); 
    1275                                         $info = $GLOBALS['phpgw']->accounts->get_account_data($value); 
    1276                                         $groups[$key]['account_id'] = $value; 
    1277                                         $groups[$key]['account_lid'] = $info[$value]['lid']; 
    1278                                         $groups[$key]['account_name'] = $info[$value]['firstname']; 
    1279                                         $groups[$key]['account_lastname'] = $info[$value]['lastname']; 
    1280                                         $groups[$key]['account_fullname'] = $info[$value]['fullname']; 
    1281                                 } 
    1282                         $this->readable_groups = array(); 
    1283                         while(list($num, $account) = each($groups)) 
    1284                         { 
    1285                                 if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) 
    1286                                 { 
    1287                                         $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); 
    1288                                 } 
    1289                         } 
    1290  
    1291                 } 
    1292                 function search() 
    1293                 { 
    1294                         /* TODO this is a primitive search */ 
    1295                         $this->update_groups(); 
    1296                         $this->dirs = $this->all_other_directories(); 
    1297                         $path = $this->path; 
    1298                         if (strlen($this->text) > 3) 
    1299                         {                                                                 
    1300                                 $this->text = strtoupper($this->text); 
    1301                                 foreach($this->dirs as $elem) 
    1302                                 { 
    1303                                         $this->path = $elem['directory'].$elem['name']; 
    1304                                         reset($this->files_array); 
    1305                                         $this->readFilesInfo(); 
    1306                                         for($i = 0; $i < count($this->files_array); $i++) 
    1307                                         { 
    1308                                                 $comment = strtoupper($this->files_array[$i]['comment']); 
    1309                                                 $name = strtoupper($this->files_array[$i]['name']); 
    1310                                                 if (strstr($name,$this->text) || 
    1311                                                 strstr($comment,$this->text) ){ 
    1312                                                         $return[$this->files_array[$i]['directory'].$name] = $this->files_array[$i]; 
    1313                                                         $return[$this->files_array[$i]['directory'].$name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); 
    1314                                                 } 
    1315                                         } 
    1316                                         if (count($return) > 50) 
    1317                                         { 
    1318                                                 $return = array_slice($return,0,50); 
    1319                                                 break; 
    1320                                         } 
    1321                                 }        
    1322                         } 
    1323                         echo serialize(array_values($return)); 
    1324                 } 
    1325  
    1326                 /* seek icon for mimetype else return an unknown icon */ 
    1327                 function mime_icon($mime_type, $size=16) 
    1328                 { 
    1329                         if(!$mime_type) $mime_type='unknown'; 
    1330  
    1331                         $mime_type=str_replace  ('/','_',$mime_type); 
    1332  
    1333                         $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); 
    1334                         if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); 
    1335  
    1336                         return $img; 
    1337                 } 
    1338  
    1339                 function toolButton($link,$img='',$description='') 
    1340                 { 
    1341                         $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
    1342  
    1343                         if($img) 
    1344                         { 
    1345                                 return '<span name="'.$link.'" class="toolButton" onclick="toolbar.control(\''.$link.'\',this);" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/></a><small>'.$description.'</small></span>'; 
    1346                         } 
    1347                 } 
    1348  
    1349                 function inputButton($name,$img='',$description='') 
    1350                 { 
    1351                         $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
    1352  
    1353                         if($img) 
    1354                         { 
    1355                                 return '<td class="" align="center" valign="middle" height="28" width="70"> 
    1356                                 <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small> 
    1357                                 </td>'; 
    1358                         } 
    1359                 } 
    1360  
    1361  
    1362                 function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) 
    1363                 { 
    1364                         $text = ' '; 
    1365                         if($type != NULL && $type) 
    1366                         { 
    1367                                 if($type == 'checkbox') 
    1368                                 { 
    1369                                         $value = $this->bo->string_encode($value, 1); 
    1370                                 } 
    1371                                 $text .= 'type="'.$type.'" '; 
    1372                         } 
    1373                         if($name != NULL && $name) 
    1374                         { 
    1375                                 $text .= 'name="'.$name.'" '; 
    1376                         } 
    1377                         if($value != NULL && $value) 
    1378                         { 
    1379                                 $text .= 'value="'.$value.'" '; 
    1380                         } 
    1381                         if(is_int($maxlength) && $maxlength >= 0) 
    1382                         { 
    1383                                 $text .= 'maxlength="'.$maxlength.'" '; 
    1384                         } 
    1385                         if(is_int($size) && $size >= 0) 
    1386                         { 
    1387                                 $text .= 'size="'.$size.'" '; 
    1388                         } 
    1389                         if($checked != NULL && $checked) 
    1390                         { 
    1391                                 $text .= 'checked '; 
    1392                         } 
    1393  
    1394                         return '<input'.$text.$string.'>'; 
    1395                 } 
    1396  
    1397                 function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) 
    1398                 { 
    1399                         $text = ' '; 
    1400                         if($value != NULL && $value) 
    1401                         { 
    1402                                 $text .= ' value="'.$value.'" '; 
    1403                         } 
    1404                         if($selected != NULL && $selected) 
    1405                         { 
    1406                                 $text .= ' selected'; 
    1407                         } 
    1408                         return  '<option'.$text.'>'.$displayed.'</option>'; 
    1409                 } 
    1410  
    1411                 function encode_href($href = NULL, $args = NULL , $extra_args) 
     1324                        }        
     1325                } 
     1326                echo serialize(array_values($return)); 
     1327        } 
     1328 
     1329        /* seek icon for mimetype else return an unknown icon */ 
     1330        function mime_icon($mime_type, $size=16) 
     1331        { 
     1332                if(!$mime_type) $mime_type='unknown'; 
     1333 
     1334                $mime_type=str_replace  ('/','_',$mime_type); 
     1335 
     1336                $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); 
     1337                if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); 
     1338 
     1339                return $img; 
     1340        } 
     1341 
     1342        function toolButton($link,$img='',$description='') 
     1343        { 
     1344                $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
     1345 
     1346                if($img) 
     1347                { 
     1348                        return '<span name="'.$link.'" class="toolButton" onclick="toolbar.control(\''.$link.'\',this);" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/></a><small>'.$description.'</small></span>'; 
     1349                } 
     1350        } 
     1351 
     1352        function inputButton($name,$img='',$description='') 
     1353        { 
     1354                $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
     1355 
     1356                if($img) 
     1357                { 
     1358                        return '<td class="" align="center" valign="middle" height="28" width="70"> 
     1359                        <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small> 
     1360                        </td>'; 
     1361                } 
     1362        } 
     1363 
     1364 
     1365        function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) 
     1366        { 
     1367                $text = ' '; 
     1368                if($type != NULL && $type) 
     1369                { 
     1370                        if($type == 'checkbox') 
     1371                        { 
     1372                                $value = $this->bo->string_encode($value, 1); 
     1373                        } 
     1374                        $text .= 'type="'.$type.'" '; 
     1375                } 
     1376                if($name != NULL && $name) 
     1377                { 
     1378                        $text .= 'name="'.$name.'" '; 
     1379                } 
     1380                if($value != NULL && $value) 
     1381                { 
     1382                        $text .= 'value="'.$value.'" '; 
     1383                } 
     1384                if(is_int($maxlength) && $maxlength >= 0) 
     1385                { 
     1386                        $text .= 'maxlength="'.$maxlength.'" '; 
     1387                } 
     1388                if(is_int($size) && $size >= 0) 
     1389                { 
     1390                        $text .= 'size="'.$size.'" '; 
     1391                } 
     1392                if($checked != NULL && $checked) 
     1393                { 
     1394                        $text .= 'checked '; 
     1395                } 
     1396 
     1397                return '<input'.$text.$string.'>'; 
     1398        } 
     1399 
     1400        function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) 
     1401        { 
     1402                $text = ' '; 
     1403                if($value != NULL && $value) 
     1404                { 
     1405                        $text .= ' value="'.$value.'" '; 
     1406                } 
     1407                if($selected != NULL && $selected) 
     1408                { 
     1409                        $text .= ' selected'; 
     1410                } 
     1411                return  '<option'.$text.'>'.$displayed.'</option>'; 
     1412        } 
     1413 
     1414        function encode_href($href = NULL, $args = NULL , $extra_args) 
     1415        { 
     1416                $href = $this->bo->string_encode($href, 1); 
     1417                $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 
     1418 
     1419                $address = $GLOBALS['phpgw']->link($href, $all_args); 
     1420 
     1421                return $address; 
     1422        } 
     1423 
     1424        function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) 
     1425        { 
     1426                //      unset($encode); 
     1427                if($encode) 
    14121428                { 
    14131429                        $href = $this->bo->string_encode($href, 1); 
    14141430                        $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 
    1415  
     1431                } 
     1432                else 
     1433                { 
     1434                        //                              $href = $this->bo->string_encode($href, 1); 
     1435                        $all_args = $args.'&'.$extra_args; 
     1436                } 
     1437                ### 
     1438                # This decodes / back to normal 
     1439                ### 
     1440                //                      $all_args = preg_replace("/%2F/", "/", $all_args); 
     1441                //                      $href = preg_replace("/%2F/", "/", $href); 
     1442 
     1443                /* Auto-detect and don't disturb absolute links */ 
     1444                if(!preg_match("|^http(.{0,1})://|", $href)) 
     1445                { 
     1446                        //Only add an extra / if there isn't already one there 
     1447 
     1448                        // die(SEP); 
     1449                        if(!($href[0] == SEP)) 
     1450                        { 
     1451                                $href = SEP . $href; 
     1452                        } 
     1453 
     1454                        /* $phpgw->link requires that the extra vars be passed separately */ 
     1455                        //                              $link_parts = explode("?", $href); 
    14161456                        $address = $GLOBALS['phpgw']->link($href, $all_args); 
    1417  
    1418                         return $address; 
    1419                 } 
    1420  
    1421                 function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) 
    1422                 { 
    1423                         //      unset($encode); 
    1424                         if($encode) 
    1425                         { 
    1426                                 $href = $this->bo->string_encode($href, 1); 
    1427                                 $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 
    1428                         } 
    1429                         else 
    1430                         { 
    1431                                 //                              $href = $this->bo->string_encode($href, 1); 
    1432                                 $all_args = $args.'&'.$extra_args; 
    1433                         } 
    1434                         ### 
    1435                         # This decodes / back to normal 
    1436                         ### 
    1437                         //                      $all_args = preg_replace("/%2F/", "/", $all_args); 
    1438                         //                      $href = preg_replace("/%2F/", "/", $href); 
    1439  
    1440                         /* Auto-detect and don't disturb absolute links */ 
    1441                         if(!preg_match("|^http(.{0,1})://|", $href)) 
    1442                         { 
    1443                                 //Only add an extra / if there isn't already one there 
    1444  
    1445                                 // die(SEP); 
    1446                                 if(!($href[0] == SEP)) 
    1447                                 { 
    1448                                         $href = SEP . $href; 
    1449                                 } 
    1450  
    1451                                 /* $phpgw->link requires that the extra vars be passed separately */ 
    1452                                 //                              $link_parts = explode("?", $href); 
    1453                                 $address = $GLOBALS['phpgw']->link($href, $all_args); 
    1454                                 //                              $address = $GLOBALS['phpgw']->link($href); 
    1455                         } 
    1456                         else 
    1457                         { 
    1458                                 $address = $href; 
    1459                         } 
    1460  
    1461                         /* If $linkonly is set, don't add any HTML */ 
    1462                         if($linkonly) 
    1463                         { 
    1464                                 $rstring = $address; 
    1465                         } 
    1466                         else 
    1467                         { 
    1468                                 if($target) 
    1469                                 { 
    1470                                         $target = 'target='.$target; 
    1471                                 } 
    1472  
    1473                                 $text = trim($text); 
    1474                                 $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>'; 
    1475                         } 
    1476  
    1477                         return($this->bo->eor($rstring, $return)); 
    1478                 } 
    1479  
    1480                 function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) 
    1481                 { 
    1482                         if($width != NULL && $width) 
    1483                         { 
    1484                                 $width = "width=$width"; 
    1485                         } 
    1486                         if(is_int($border) && $border >= 0) 
    1487                         { 
    1488                                 $border = "border=$border"; 
    1489                         } 
    1490                         if(is_int($cellspacing) && $cellspacing >= 0) 
    1491                         { 
    1492                                 $cellspacing = "cellspacing=$cellspacing"; 
    1493                         } 
    1494                         if(is_int($cellpadding) && $cellpadding >= 0) 
    1495                         { 
    1496                                 $cellpadding = "cellpadding=$cellpadding"; 
    1497                         } 
    1498                         if($rules != NULL && $rules) 
    1499                         { 
    1500                                 $rules = "rules=$rules"; 
    1501                         } 
    1502  
    1503                         $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>"; 
    1504                         return($this->bo->eor($rstring, $return)); 
    1505                 } 
    1506  
    1507                 function html_table_end($return = 0) 
    1508                 { 
    1509                         $rstring = "</table>"; 
    1510                         return($this->bo->eor($rstring, $return)); 
    1511                 } 
    1512  
    1513                 function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) 
    1514                 { 
    1515                         if($align != NULL && $align) 
    1516                         { 
    1517                                 $align = "align=$align"; 
    1518                         } 
    1519                         if($halign != NULL && $halign) 
    1520                         { 
    1521                                 $halign = "halign=$halign"; 
    1522                         } 
    1523                         if($valign != NULL && $valign) 
    1524                         { 
    1525                                 $valign = "valign=$valign"; 
    1526                         } 
    1527                         if($bgcolor != NULL && $bgcolor) 
    1528                         { 
    1529                                 $bgcolor = "bgcolor=$bgcolor"; 
    1530                         } 
    1531                         $rstring = "<tr $align $halign $valign $bgcolor $string>"; 
    1532                         return($this->bo->eor($rstring, $return)); 
    1533                 } 
    1534  
    1535                 function html_table_row_end($return = 0) 
    1536                 { 
    1537                         $rstring = "</tr>"; 
    1538                         return($this->bo->eor($rstring, $return)); 
    1539                 } 
    1540  
    1541                 function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) 
    1542                 { 
    1543                         if($align != NULL && $align) 
    1544                         { 
    1545                                 $align = "align=$align"; 
    1546                         } 
    1547                         if($halign != NULL && $halign) 
    1548                         { 
    1549                                 $halign = "halign=$halign"; 
    1550                         } 
    1551                         if($valign != NULL && $valign) 
    1552                         { 
    1553                                 $valign = "valign=$valign"; 
    1554                         } 
    1555                         if(is_int($rowspan) && $rowspan >= 0) 
    1556                         { 
    1557                                 $rowspan = "rowspan=$rowspan"; 
    1558                         } 
    1559                         if(is_int($colspan) && $colspan >= 0) 
    1560                         { 
    1561                                 $colspan = "colspan=$colspan"; 
    1562                         } 
    1563  
    1564                         $rstring = "<td $align $halign $valign $rowspan $colspan $string>"; 
    1565                         return($this->bo->eor($rstring, $return)); 
    1566                 } 
    1567  
    1568                 function html_table_col_end($return = 0) 
    1569                 { 
    1570                         $rstring = "</td>"; 
    1571                         return($this->bo->eor($rstring, $return)); 
    1572                 } 
    1573         } 
     1457                        //                              $address = $GLOBALS['phpgw']->link($href); 
     1458                } 
     1459                else 
     1460                { 
     1461                        $address = $href; 
     1462                } 
     1463 
     1464                /* If $linkonly is set, don't add any HTML */ 
     1465                if($linkonly) 
     1466                { 
     1467                        $rstring = $address; 
     1468                } 
     1469                else 
     1470                { 
     1471                        if($target) 
     1472                        { 
     1473                                $target = 'target='.$target; 
     1474                        } 
     1475 
     1476                        $text = trim($text); 
     1477                        $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>'; 
     1478                } 
     1479 
     1480                return($this->bo->eor($rstring, $return)); 
     1481        } 
     1482 
     1483        function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) 
     1484        { 
     1485                if($width != NULL && $width) 
     1486                { 
     1487                        $width = "width=$width"; 
     1488                } 
     1489                if(is_int($border) && $border >= 0) 
     1490                { 
     1491                        $border = "border=$border"; 
     1492                } 
     1493                if(is_int($cellspacing) && $cellspacing >= 0) 
     1494                { 
     1495                        $cellspacing = "cellspacing=$cellspacing"; 
     1496                } 
     1497                if(is_int($cellpadding) && $cellpadding >= 0) 
     1498                { 
     1499                        $cellpadding = "cellpadding=$cellpadding"; 
     1500                } 
     1501                if($rules != NULL && $rules) 
     1502                { 
     1503                        $rules = "rules=$rules"; 
     1504                } 
     1505 
     1506                $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>"; 
     1507                return($this->bo->eor($rstring, $return)); 
     1508        } 
     1509 
     1510        function html_table_end($return = 0) 
     1511        { 
     1512                $rstring = "</table>"; 
     1513                return($this->bo->eor($rstring, $return)); 
     1514        } 
     1515 
     1516        function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) 
     1517        { 
     1518                if($align != NULL && $align) 
     1519                { 
     1520                        $align = "align=$align"; 
     1521                } 
     1522                if($halign != NULL && $halign) 
     1523                { 
     1524                        $halign = "halign=$halign"; 
     1525                } 
     1526                if($valign != NULL && $valign) 
     1527                { 
     1528                        $valign = "valign=$valign"; 
     1529                } 
     1530                if($bgcolor != NULL && $bgcolor) 
     1531                { 
     1532                        $bgcolor = "bgcolor=$bgcolor"; 
     1533                } 
     1534                $rstring = "<tr $align $halign $valign $bgcolor $string>"; 
     1535                return($this->bo->eor($rstring, $return)); 
     1536        } 
     1537 
     1538        function html_table_row_end($return = 0) 
     1539        { 
     1540                $rstring = "</tr>"; 
     1541                return($this->bo->eor($rstring, $return)); 
     1542        } 
     1543 
     1544        function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) 
     1545        { 
     1546                if($align != NULL && $align) 
     1547                { 
     1548                        $align = "align=$align"; 
     1549                } 
     1550                if($halign != NULL && $halign) 
     1551                { 
     1552                        $halign = "halign=$halign"; 
     1553                } 
     1554                if($valign != NULL && $valign) 
     1555                { 
     1556                        $valign = "valign=$valign"; 
     1557                } 
     1558                if(is_int($rowspan) && $rowspan >= 0) 
     1559                { 
     1560                        $rowspan = "rowspan=$rowspan"; 
     1561                } 
     1562                if(is_int($colspan) && $colspan >= 0) 
     1563                { 
     1564                        $colspan = "colspan=$colspan"; 
     1565                } 
     1566 
     1567                $rstring = "<td $align $halign $valign $rowspan $colspan $string>"; 
     1568                return($this->bo->eor($rstring, $return)); 
     1569        } 
     1570 
     1571        function html_table_col_end($return = 0) 
     1572        { 
     1573                $rstring = "</td>"; 
     1574                return($this->bo->eor($rstring, $return)); 
     1575        } 
     1576} 
  • branches/2.2/filemanager/js/common_functions.js

    r3619 r3638  
    103103                        pArgs.path_filemanager  = path_filemanager; 
    104104                        pArgs.width                     = 450; 
    105                  
     105         
    106106                var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs ); 
    107107                 
    108108                draw_window( _html, 490, 350, get_lang("upload files") ); 
     109                 
     110                sendNotification( pArgs.emails_to ); 
    109111        } 
    110112         
     
    247249} 
    248250 
    249 function enterComments(e,el){ 
    250         if (e.keyCode == KEY_ENTER) 
     251function enterComments(e,el) 
     252{ 
     253        if ( e.keyCode == KEY_ENTER ) 
     254        { 
    251255                el.blur(); 
     256        } 
    252257} 
    253258 
     
    402407{ 
    403408        var _div = document.getElementById('sendNotifcation'); 
    404  
    405         loadXtools(); 
    406                  
    407         var pArgs =  
    408         { 
    409                 'lang_delete' : get_lang('delete'), 
    410                 'lang_send_notification_email_to' :     get_lang("Send Notification email to:") 
    411         }; 
    412                  
    413         _div.innerHTML += Xtools.parse( Xtools.xml("teste"), "send_notification.xsl", pArgs); 
     409         
     410        var _SendNotification = function() 
     411        { 
     412                var pArgs =  
     413                { 
     414                        'lang_delete'                                           : get_lang('delete'), 
     415                        'lang_send_notification_email_to'       : get_lang("Send Notification email to:"), 
     416                        'value_email'                                           : ( ( arguments.length > 0 ) ? arguments[0] : "" ) 
     417                }; 
     418 
     419                loadXtools(); 
     420                 
     421                _div.innerHTML += Xtools.parse( Xtools.xml("send_notification"), "send_notification.xsl", pArgs); 
     422        } 
     423         
     424        if( arguments.length > 0 ) 
     425        { 
     426                var emailsTo = arguments[0].split(","); 
     427                 
     428                _div.innerHTML += "<div style='margin:4 2 2 4px;'>" + 
     429                                              "<label style='font-weight: bold;'>" + get_lang('The following addresses will be notified') + " : </label>" + 
     430                                              "</div>"; 
     431                for( var i = 0 ;  i < emailsTo.length ; i++ ) 
     432                { 
     433                        _SendNotification( emailsTo[i] ); 
     434                        _div.innerHTML += "<div style='margin:1 2 1 4px;'> - " + emailsTo[i] + "</div>"; 
     435                } 
     436                _div.innerHTML += "<br/>"; 
     437        } 
     438        else 
     439                _SendNotification(); 
    414440} 
    415441 
  • branches/2.2/filemanager/setup/phpgw_pt-br.lang

    r3636 r3638  
    203203Comments by user: %1    filemanager     pt-br   Coment&aacute;rios do usu&aacute;rio: %1 
    204204The file can be accessed by: %1 filemanager     pt-br   O arquivo pode ser acessado pelo endere&ccedil;o: %1 
     205The following addresses will be notified        filemanager     pt-br   Os endereços abaixo serão notificados 
    205206Send Notification email to:     filemanager     pt-br   Enviar email de notificação para: 
  • branches/2.2/filemanager/tp/expressowindow/xsl/send_notification.xsl

    r3610 r3638  
    55        <xsl:param name = "lang_delete" /> 
    66        <xsl:param name = "lang_send_notification_email_to" /> 
     7        <xsl:param name = "value_email" /> 
    78         
    8         <xsl:template match="teste"> 
     9        <xsl:template match="send_notification"> 
    910         
    10                 <div style="margin: 4px;"> 
    11                         <label> 
    12                                 <xsl:value-of select="$lang_send_notification_email_to" /> 
    13                         </label> 
    14                         <br/> 
    15                         <input type="text" name="notifTo[]" size="38"/> 
    16                         <span style="color:red; cursor:pointer; margin-left:2px;" onclick="removeInput(this);"><xsl:value-of select="$lang_delete" /></span> 
     11                <div style="margin:4px;"> 
     12                        <xsl:choose> 
     13                                <xsl:when test="$value_email"> 
     14                                        <input type="hidden" name="notifTo[]" size="38" value="{$value_email}" /> 
     15                                </xsl:when> 
     16                                 
     17                                <xsl:otherwise> 
     18                                        <label> 
     19                                                <xsl:value-of select="$lang_send_notification_email_to" /> 
     20                                        </label> 
     21                                        <br/> 
     22                                        <input type="text" name="notifTo[]" size="38"/> 
     23                                        <span style="color:red; cursor:pointer; margin-left:2px;" onclick="removeInput(this);"> 
     24                                                <xsl:value-of select="$lang_delete" /> 
     25                                        </span> 
     26                                </xsl:otherwise> 
     27                        </xsl:choose> 
    1728                </div> 
    1829                 
Note: See TracChangeset for help on using the changeset viewer.