Changeset 1627


Ignore:
Timestamp:
11/12/09 09:06:56 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Implementações novas, com arquivos restritos, quota, ckeditor

Files:
829 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • sandbox/filemanager/inc/class.uifilemanager.inc.php

    r1592 r1627  
    2727                        'history' => True, 
    2828                        'edit' => True, 
    29                         'download'=>True 
     29                        'fileModels'=>True, 
     30                        'uploadModel'=>True 
    3031                ); 
    3132 
    3233                //keep 
    3334                var $bo; 
     35                var $vfs_functions; 
    3436                var $t; //template object 
    3537                var $dispath; 
     
    5153                var $current_config; 
    5254                var $goto_x; 
    53                 var $download_x; 
    5455                var $todir; 
    5556                var $changedir; // for switching dir. 
     
    6465                var $rename_x; 
    6566                var $move_to_x; 
    66                 //              var $copy_to; 
     67//              var $copy_to; 
    6768                var $copy_to_x; 
    6869                var $edit_x; 
     
    9899                        $this->bo = CreateObject('filemanager.bofilemanager'); 
    99100 
     101                        $this->vfs_functions = CreateObject('filemanager.vfs_functions'); 
     102 
    100103                        $this->t = $GLOBALS['phpgw']->template; 
    101104                        $c = CreateObject('phpgwapi.config','filemanager'); 
     
    115118                        { 
    116119                                $$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
     120                                $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
     121 
    117122                        } 
    118123 
     
    221226                                else 
    222227                                { 
    223                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( 
    224                                                 lang('Fake Base Dir did not exist, eGroupWare created a new one.') 
    225                                         )); 
     228                                        $this->messages[]= lang('Fake Base Dir did not exist, eGroupWare created a new one.'); 
    226229                                } 
    227230                        } 
     
    237240                                        'relatives' => array(RELATIVE_NONE) 
    238241                                )); 
    239                                  
     242                                $this->bo->vfs->set_quota(array( 
     243                                        'string' => $this->bo->homedir, 
     244                                        'relatives' => array(RELATIVE_NONE), 
     245                                        'new_quota' => $this->current_config['filemanager_quota_size']  
     246                                )); 
     247         
    240248                                $this->bo->vfs->override_acl = 0; 
    241249 
     
    249257                                else 
    250258                                { 
    251                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( 
    252                                                 lang('Your Home Dir did not exist, eGroupWare created a new one.') 
    253                                         )); 
     259                                        $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); 
    254260                                        // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 
    255261                                } 
     
    258264                         
    259265                } 
    260  
     266                function fileModels() 
     267                { 
     268                        $GLOBALS['phpgw_info']['flags'] = array 
     269                                ( 
     270                                        'currentapp'    => 'filemanager', 
     271                                        'noheader'      => False, 
     272                                        'nonavbar' => False, 
     273                                        'nofooter'      => False, 
     274                                        'noappheader'   => False, 
     275                                        'enable_browser_class'  => True 
     276                                ); 
     277 
     278                        $GLOBALS['phpgw']->common->phpgw_header(); 
     279                        $this->t->set_file(array('models' => 'fileModels.tpl')); 
     280                        $this->t->set_block('models','header','header'); 
     281                        $this->t->set_block('models','body','body'); 
     282                        $this->t->set_block('models','footer','footer'); 
     283                        $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); 
     284                        $this->t->set_var('model_1','article'); 
     285                        $this->t->set_var('lang_1',lang('article')); 
     286 
     287                        $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 
     288                        $this->t->set_var('model_2','calendar'); 
     289                        $this->t->set_var('lang_2',lang('calendar')); 
     290 
     291                        $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 
     292                        $this->t->set_var('model_3','todo'); 
     293                        $this->t->set_var('lang_3',lang('todo')); 
     294 
     295                        $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 
     296                        $this->t->set_var('model_4','slide'); 
     297                        $this->t->set_var('lang_4',lang('slide')); 
     298 
     299                        $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 
     300                        $this->t->set_var('model_5','cards'); 
     301                        $this->t->set_var('lang_5',lang('cards')); 
     302 
     303                        $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 
     304                        $this->t->set_var('model_6','resume'); 
     305                        $this->t->set_var('lang_6',lang('resume')); 
     306 
     307 
     308                        $this->t->pparse('out','models'); 
     309 
     310 
     311                } 
     312                function uploadModel(){ 
     313                        $GLOBALS['phpgw_info']['flags'] = array 
     314                                ( 
     315                                        'currentapp'    => 'filemanager', 
     316                                        'noheader'      => False, 
     317                                        'nonavbar' => False, 
     318                                        'nofooter'      => False, 
     319                                        'noappheader'   => False, 
     320                                        'enable_browser_class'  => True 
     321                                ); 
     322 
     323                        $GLOBALS['phpgw']->common->phpgw_header(); 
     324 
     325                        $filename = lang('new')."_".lang($this->model).rand(0,1000).".html"; 
     326                        $this->bo->vfs->cp(array( 
     327                                'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html', 
     328                                'to'=> $filename, 
     329                                'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
     330                        )); 
     331 
     332                        $this->bo->vfs->set_attributes(array( 
     333                                'string'=> $filename, 
     334                                'relatives'     => array(RELATIVE_ALL), 
     335                                'attributes'=> array( 
     336                                        'mime_type' => "text/html", 
     337                                        'comment' => "" 
     338                                ) 
     339                        )); 
     340                        $this->fileman[0] = $filename; 
     341                        $this->edit(); 
     342 
     343                } 
    261344                function index() 
    262345                { 
    263                         if($noheader || $nofooter || ($this->download_x && (count($this->fileman) > 0))) 
     346                        if($noheader || $nofooter || (count($this->fileman) > 0)) 
    264347                        { 
    265348                                $noheader = True; 
     
    400483                        if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ))) 
    401484                        { 
    402                                 $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path))); 
     485                                $this->messages[]= lang('Error:').lang('You do not have access to %1', $this->path); 
    403486                                $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory')); 
    404487 
     
    445528                                ))) 
    446529                                { 
    447                                         $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path))); 
     530                                        $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); 
    448531                                        $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory')); 
    449532 
     
    527610                                $this->moveTo(); 
    528611                        } 
    529                         elseif($this->download_x) 
    530                         { 
    531                                 $this->download(); 
    532                         } 
    533612                        elseif($this->renamefiles) 
    534613                        { 
     
    557636                                $this->fileListing(); 
    558637                        } 
    559                 } 
    560                 // String format is YYYY-MM-DD HH:MM 
    561                 function dateString2timeStamp($string){ 
    562                         return mktime($string[11].$string[12], 
    563                                 $string[14].$string[15], 
    564                                 $string[17].$string[18],  
    565                                 $string[5].$string[6],  
    566                                 $string[8].$string[9], 
    567                                 $string[0].$string[1]. 
    568                                 $string[2].$string[3]); 
    569638                } 
    570639                function fileListing() 
     
    587656                                } 
    588657                                $columns++; 
    589                                 $vars[usedSpace]='<input type="hidden" id="usedSpace" value="'.round(($this->usedSpace()/1024)/1024).'">'; 
    590                                 $vars[quotaSize]='<input type="hidden" id="quotaSize" value="'.$this->current_config['filemanager_quota_size'].'">'; 
    591                                 $vars[javascript]='<script src="filemanager/js/draw_api.js"></script>'; 
     658                                $usedSpace = $this->bo->vfs->get_size(array( 
     659                                        'string'        => $this->path, 
     660                                        'relatives'     => array(RELATIVE_NONE) 
     661                                )); 
     662                                $quota = $this->bo->vfs->get_quota(array( 
     663                                        'string'        => $this->path 
     664                                )); 
     665 
     666                                $vars[usedSpace]='<input type="hidden" id="usedSpace" value="'.$usedSpace.'">'; 
     667                                $vars[quotaSize]='<input type="hidden" id="quotaSize" value="'.($quota*1024*1024).'">'; 
     668                                $vars[javascript]='<script src="filemanager/js/draw_api.js"></script> 
     669                                        <link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
    592670                                $vars[toolbar0]=$this->toolbar('location'); 
    593671                                $vars[toolbar1]=$this->toolbar('list_nav'); 
     
    611689                                ### 
    612690                                $this->t->set_var('actions',lang('select')); 
     691                                $this->t->set_var('mini_bar','&nbsp;'); 
     692 
    613693 
    614694                                reset($this->bo->file_attributes); 
     
    717797                                                $this->t->set_var('actions',''); 
    718798                                        } 
     799                                        $minibar_data=""; 
     800                                        if($this->path == $this->bo->homedir) 
     801                                        { 
     802                                                if ($files['type'] == "1") 
     803                                                { 
     804                                                        $image = $GLOBALS['phpgw']->common->image('filemanager','button_lock'); 
     805                                                } 
     806                                                else 
     807                                                { 
     808                                                        $image = $GLOBALS['phpgw']->common->image('filemanager','button_unlock'); 
     809                                                } 
     810                                                $link=$this->encode_href('/index.php','menuaction=filemanager.vfs_functions.setRestricted','file='.$files['name'].'&path='.$this->path); 
     811                                                $minibar_data = '<img id="restrict_'.$files['name'].'" onclick="javascript:cExecute(\''.$link.'\',setRestricted)" alt="'.lang("mark as restricted").'" title="'.lang("mark as restricted").'" src="'.$image.'">'; 
     812                                        } 
     813 
     814 
     815                                        if ($files['mime_type'] == "text/html") 
     816                                        { 
     817                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.export','file='.$files['name'].'&path='.$this->path); 
     818                                                $image=$GLOBALS['phpgw']->common->image('filemanager','button_export'); 
     819                                                $minibar_data.='<a href="'.$link.'"><img alt="'.lang("export").'" title="'.lang("export").'" src="'.$image.'"></a>'; 
     820                                        } 
     821                                        else 
     822                                                $minibar_data.= "<a>&nbsp;</a>"; 
     823                                        $this->t->set_var('mini_bar',$minibar_data); 
     824 
    719825 
    720826                                        # File name and icon 
     
    755861 
    756862                                                                $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;<a href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>'; 
    757                                                                 if ($files['mime_type'] == "text/html") 
    758                                                                 { 
    759                                                                         $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.export','file='.$files['name'].'&path='.$this->path); 
    760                                                                         $image=$GLOBALS['phpgw']->common->image('filemanager','button_export'); 
    761                                                                         $col_data.='<a href="'.$link.'"><img alt="'.lang("export").'" title="'.lang("export").'" src="'.$image.'"></a>'; 
    762                                                                 } 
    763863                                                        } 
    764864                                                } 
     
    796896                                        if($this->prefs['created']) 
    797897                                        { 
    798                                                 $timestamp = $this->dateString2timeStamp($files['created']); 
     898                                                $timestamp = $this->vfs_functions->dateString2timeStamp($files['created']); 
    799899                                                if (time() - $timestamp > 86400) // Older than yesterday 
    800900                                                        $col_data=date("Y-m-d",$timestamp); 
     
    809909                                        { 
    810910                                                if ($files['modified'] != ''){ 
    811                                                         $timestamp = $this->dateString2timeStamp($files['modified']); 
     911                                                        $timestamp = $this->vfs_functions->dateString2timeStamp($files['modified']); 
    812912                                                        if (time() - $timestamp > 86400) // Older than yesterday 
    813913                                                                $col_data=date("Y-m-d",$timestamp); 
     
    9571057                                        'nofiles' => True 
    9581058                                )); 
     1059 
    9591060                                $this->files_array[] = $ls_array[0]; 
    9601061                                $this->numoffiles++; 
     
    10631164                                        // selectbox for change/move/and copy to 
    10641165                                        $dirs_options=$this->all_other_directories_options(); 
    1065                                         $toolbar.='<select name="cdtodir" onChange="document.formfm.changedir.value=\'true\';document.formfm.submit()">'.$current_option.$dirs_options.'</select> 
     1166                                        $toolbar.='<select id="cdtodir" name="cdtodir" onChange="document.formfm.changedir.value=\'true\';document.formfm.submit()">'.$current_option.$dirs_options.'</select> 
    10661167                                        <input type="hidden" name="changedir" value="false"></td> 
    10671168                                        '; 
    10681169                                        //$toolbar.=$this->inputImage('goto','goto',lang('Quick jump to')); 
    10691170                                        // upload button 
    1070                                         if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 
     1171                                        /*if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 
    10711172                                        { 
    10721173                                                // upload button 
    1073                                                 $total = ($this->current_config['filemanager_quota_size'])*1024*1024; 
    1074                                                 $usedSpace = $this->usedSpace(); 
    1075                                                 if ($usedSpace < $total) 
    1076                                                         $toolbar.=$this->inputImage('upload','upload',lang('Upload')); 
     1174                                                $toolbar.=$this->inputImage('upload','upload',lang('Upload')); 
    10771175                                                 
    10781176 
    1079                                         } 
     1177                                        }*/ 
    10801178                                        $toolbar.='</tr></table>'; 
    10811179                                        $toolbar.='</div><br><br>'; 
     
    10911189                                                //$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; 
    10921190                                                //$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
     1191                                                // create dir and file button 
     1192                                                if($this->can_add) 
     1193                                                { 
     1194                                                        //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; 
     1195                                                        //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
     1196 
     1197                                                        $toolbar.='<td><input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" /></td>'; 
     1198                                                        $toolbar.='<div onclick="alert(\'asdf\')">'; 
     1199                                                        //TODO : create folder with problems 
     1200                                                        //$toolbar3.=$this->inputImage('newdir','createdir',lang('Create Folder')); 
     1201                                                        $toolbar.=$this->inputImage('new','createfile',lang('New...')); 
     1202                                                        $toolbar.='</div>'; 
     1203                                                } 
    10931204 
    10941205                                                if(!$this->rename_x && !$this->edit_comments_x && $this->can_edit) 
     
    11131224                                                        $toolbar.=$this->inputImage('edit_comments','edit_comments',lang('Edit comments')); 
    11141225                                                } 
    1115                                                 $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
     1226 
    11161227                                        } 
    11171228 
     
    11221233                                                if($this->path != '/' && $this->path != $this->bo->fakebase) 
    11231234                                                { 
    1124                                                         //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; 
    1125                                                         //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
    1126  
    11271235                                                        $dirs_options=$this->all_other_directories_options(); 
    1128  
    1129                                                         $toolbar3.=$this->inputImage('copy_to','copy_to',lang('Copy to')); 
    1130                                                         if ($this->can_delete) 
    1131                                                                 $toolbar3.=$this->inputImage('move_to','move_to',lang('Move to')); 
    1132                                                         $toolbar3.='<td><select name="todir"><option value="">'.lang('select a folder').'</option>'.$dirs_options.'</select></td>'; 
    1133  
    1134                                                         $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
    1135  
    1136                                                 } 
    1137  
    1138                                                 // create dir and file button 
    1139                                                 if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 
    1140                                                 { 
    1141                                                         //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; 
    1142                                                         //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; 
    1143  
    1144                                                         $toolbar3.='<td><input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" /></td>'; 
    1145                                                         $toolbar3.='<div onclick="alert(\'asdf\')">'; 
    1146                                                         //TODO : create folder with problems 
    1147                                                         //$toolbar3.=$this->inputImage('newdir','createdir',lang('Create Folder')); 
    1148                                                         $toolbar3.=$this->inputImage('newfile','createfile',lang('Create File')); 
    1149                                                         $toolbar3.='</div>'; 
     1236                                                        if (strlen($dirs_options) > 0){ 
     1237                                                                $toolbar3.=$this->inputImage('copy_to','copy_to',lang('Copy to')); 
     1238                                                                if ($this->can_delete) 
     1239                                                                        $toolbar3.=$this->inputImage('move_to','move_to',lang('Move to')); 
     1240                                                        } 
     1241                                                        $toolbar3.='<td><select name="todir" style="visibility:hidden">'.$dirs_options.'</select></td>'; 
     1242 
    11501243                                                } 
    11511244 
     
    11711264 
    11721265 
    1173                 function usedSpace(){ 
    1174                            for($i = 0; $i != $this->numoffiles; $i++) 
    1175                                 $usedspace += $this->files_array[$i]['size']; 
    1176                            return $usedspace; 
    1177                 } 
    1178  
    11791266                // move to bo 
    11801267                # Handle File Uploads 
    11811268                function fileUpload() 
    11821269                { 
    1183                         if ($this->usedSpace() > ($this->current_config['filemanager_quota_size'])*1024*1024) 
    1184                                 echo lang('You exceded the quota'); 
    1185                         else 
    11861270                        if($this->path != '/' && $this->path != $this->bo->fakebase) 
    11871271                        { 
     
    11901274                                        if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) 
    11911275                                        { 
    1192                                                 $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); 
     1276                                                $this->messages[]=lang('Error:').lang('File names cannot contain "%1"', $badchar); 
    11931277 
    11941278                                                continue; 
     
    12091293                                                if($fileinfo['mime_type'] == 'Directory') 
    12101294                                                { 
    1211                                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); 
     1295                                                        $this->messages[]= lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']); 
    12121296                                                        continue; 
    12131297                                                } 
     
    12471331                                                        $tmp_arr=array( 
    12481332                                                                'from'  => $_FILES['upload_file']['tmp_name'][$i], 
    1249                                                                 'to'    => $_FILES['upload_file']['name'][$i], 
     1333                                                                'to'    => lang('new')."_".$_FILES['upload_file']['name'][$i], 
    12501334                                                                'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
    12511335                                                        ); 
    12521336                                                        $this->bo->vfs->cp($tmp_arr); 
    12531337 
    1254                                                         $this->messages[]=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); 
     1338                                                        $this->messages[]=lang('Created new %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); 
    12551339                                                } 
    12561340                                                else 
     
    12991383                        } 
    13001384                } 
    1301  
    13021385                # Handle Editing comments 
    13031386                function editComment() 
     
    13071390                                if($badchar = $this->bo->bad_chars($this->comment_files[$file], False, True)) 
    13081391                                { 
    1309                                         $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1))); 
     1392                                        $this->messages[]=lang('Error:').$this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1); 
    13101393                                        continue; 
    13111394                                } 
     
    13331416                                if($badchar = $this->bo->bad_chars($to, True, True)) 
    13341417                                { 
    1335                                         $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); 
     1418                                        $this->messages[]=lang('Error:').$this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1); 
    13361419                                        continue; 
    13371420                                } 
     
    13391422                                if(ereg("/", $to) || ereg("\\\\", $to)) 
    13401423                                { 
    1341                                         $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /"))); 
    1342                                 } 
    1343                                 elseif($this->verifyLock($from,RELATIVE_ALL) && $this->bo->vfs->mv(array( 
     1424                                        $this->messages[]=lang('Error:').lang("File names cannot contain \\ or /"); 
     1425                                } 
     1426                                elseif($this->vfs_functions->verifyLock($from,RELATIVE_ALL) && $this->bo->vfs->mv(array( 
    13441427                                        'from'  => $from, 
    13451428                                        'to'    => $to 
     
    13501433                                else 
    13511434                                { 
    1352                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); 
     1435                                        $this->messages[]= lang('Error:').lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); 
    13531436                                } 
    13541437                        } 
     
    13621445                        if(!$this->todir) 
    13631446                        { 
    1364                                 $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move file because no destination directory is given ', $this->disppath.'/'.$file))); 
     1447                                $this->messages[] = lang('Error:').lang('Could not move file because no destination directory is given ', $this->disppath.'/'.$file); 
    13651448 
    13661449                        } 
     
    13811464                                        else 
    13821465                                        { 
    1383                                                 $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); 
     1466                                                $this->messages[] = lang('Error:').lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); 
    13841467                                        } 
    13851468                                } 
     
    14001483                        if(!$this->todir) 
    14011484                        { 
    1402                                 $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not copy file because no destination directory is given ', $this->disppath.'/'.$file))); 
     1485                                $this->messages[] = lang('Error:').lang('Could not copy file because no destination directory is given ', $this->disppath.'/'.$file); 
    14031486 
    14041487                        } 
     
    14371520                                if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) 
    14381521                                { 
    1439                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1))); 
     1522                                        $this->messages[]= lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
    14401523                                } 
    14411524 
     
    14431526                                if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') 
    14441527                                { 
    1445                                         $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space'))); 
     1528                                        $this->messages[]= lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
    14461529                                } 
    14471530 
     
    14591542                                        if($fileinfo['mime_type'] != 'Directory') 
    14601543                                        { 
    1461                                                 $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( 
    1462                                                         lang('%1 already exists as a file', 
    1463                                                         $fileinfo['name']) 
    1464                                                 )); 
     1544                                                $this->messages[]= lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    14651545                                        } 
    14661546                                        else 
    14671547                                        { 
    1468                                                 $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name']))); 
     1548                                                $this->messages[]= lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
    14691549                                        } 
    14701550                                } 
     
    14771557                                        else 
    14781558                                        { 
    1479                                                 $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); 
     1559                                                $this->messages[]=lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir); 
    14801560                                        } 
    14811561                                } 
     
    14851565                        } 
    14861566                } 
    1487                 function verifyLock($file,$relative){ 
    1488                         $ls_array = $this->bo->vfs->ls(array( 
    1489                                 'string'        => $file, 
    1490                                 'relatives'     => array($relative), 
    1491                                 'checksubdirs'  => False, 
    1492                                 'nofiles'       => True 
    1493                         )); 
    1494                         $timestamp = $this->dateString2timeStamp($ls_array[0]['modified']); 
    1495                         if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']) // recently than last minute: someone is editing 
    1496                         { 
    1497                                 $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('This file is being edited right now by:').$GLOBALS['phpgw']->accounts->id2name($ls_array[0]['modifiedby_id']))); 
    1498                                 return False; 
    1499  
     1567                function delete() 
     1568                { 
     1569                        if( is_array($this->fileman) && count($this->fileman) >= 1) 
     1570                        { 
     1571                                foreach($this->fileman as $filename) 
     1572                                { 
     1573                                        if($this->vfs_functions->verifyLock($filename,RELATIVE_ALL) && $this->bo->vfs->delete(array('string' => $filename))) 
     1574                                        { 
     1575                                                $this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>'; 
     1576                                        } 
     1577                                        else 
     1578                                        { 
     1579                                                $this->messages[]=lang('Error:').lang('Could not delete %1', $this->disppath.'/'.$filename); 
     1580                                        } 
     1581                                } 
    15001582                        } 
    15011583                        else 
    1502                                 return True; 
    1503                 } 
    1504                 function delete() 
    1505                 { 
    1506                         if( is_array($this->fileman) && count($this->fileman) >= 1) 
    1507                         { 
    1508                                 foreach($this->fileman as $filename) 
    1509                                 { 
    1510                                         if($this->verifyLock($filename,RELATIVE_ALL) && $this->bo->vfs->delete(array('string' => $filename))) 
    1511                                         { 
    1512                                                 $this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>'; 
    1513                                         } 
    1514                                         else 
    1515                                         { 
    1516                                                 $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename))); 
    1517                                         } 
    1518                                 } 
    1519                         } 
    1520                         else 
    15211584                        { 
    15221585                                // make this a javascript func for quicker respons 
    1523                                 $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.'))); 
     1586                                $this->messages[]=lang('Error:').lang('Please select a file to delete.'); 
    15241587                        } 
    15251588                        $this->readFilesInfo(); 
     
    15541617                        $this->t->set_block('upload','upload_footer','upload_footer'); 
    15551618 
    1556                         # Decide how many upload boxes to show 
    1557                         if(!$this->show_upload_boxes || $this->show_upload_boxes <= 0) 
    1558                         { 
    1559                                 if(!$this->show_upload_boxes = $this->prefs['show_upload_boxes']) 
    1560                                 { 
    1561                                         $this->show_upload_boxes = 1; 
    1562                                 } 
    1563                         } 
    1564  
    1565                         # Show file upload boxes. Note the last argument to html().  Repeats $this->show_upload_boxes times 
    15661619                        if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) 
    15671620                        { 
     
    15701623                                $vars[lang_file]=lang('File'); 
    15711624                                $vars[lang_comment]=lang('Comment'); 
    1572                                 $vars[num_upload_boxes]=$this->show_upload_boxes; 
     1625                                $vars[num_upload_boxes]=1; 
    15731626                                $this->t->set_var($vars); 
    15741627                                $this->t->pparse('out','upload_header'); 
    15751628 
    1576                                 for($i=0;$i<$this->show_upload_boxes;$i++) 
    1577                                 { 
    1578                                         $this->t->set_var('row_tr_color',$tr_color); 
    1579                                         $this->t->parse('rows','row'); 
    1580                                         $this->t->pparse('out','row'); 
    1581                                 } 
     1629                                $this->t->set_var('row_tr_color',$tr_color); 
     1630                                $this->t->parse('rows','row'); 
     1631                                $this->t->pparse('out','row'); 
    15821632 
    15831633                                $vars[lang_upload]=lang('Upload files'); 
    15841634                                $vars[change_upload_boxes].=lang('Show') . '&nbsp;'; 
    1585                                 $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=5', '5'); 
    1586                                 $links.='&nbsp;'; 
    1587                                 $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=10', '10'); 
    1588                                 $links.='&nbsp;'; 
    1589                                 $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=20', '20'); 
    1590                                 $links.='&nbsp;'; 
    1591                                 $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=50', '50'); 
    1592                                 $links.='&nbsp;'; 
    1593                                 $links.= lang('upload fields'); 
    1594                                 $vars[change_upload_boxes].=$links; 
    15951635                                $this->t->set_var($vars); 
    15961636                                $this->t->pparse('out','upload_footer'); 
     
    16061646                                if($badchar = $this->bo->bad_chars($this->createfile_var, True, True)) 
    16071647                                { 
    1608                                         $this->messages[] = $GLOBALS['phpgw']->common->error_list(array( 
    1609                                                 lang('File names cannot contain "%1"',$badchar), 
    1610                                                 1) 
    1611                                         ); 
     1648                                        $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); 
    16121649 
    16131650                                        $this->fileListing(); 
     
    16191656                                ))) 
    16201657                                { 
    1621                                         $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var))); 
     1658                                        $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var); 
    16221659                                        $this->fileListing(); 
    16231660                                } 
     
    16361673                                else 
    16371674                                { 
    1638                                         $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile_var))); 
     1675                                        $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->createfile_var); 
    16391676                                        $this->fileListing(); 
    16401677                                } 
     
    16491686                        if($this->file) 
    16501687                        { 
    1651                                 if (! $this->verifyLock($this->path.'/'.$this->file,RELATIVE_NONE)){ 
     1688                                if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->file,RELATIVE_NONE)){ 
    16521689                                        echo $this->messages['0']; 
    16531690                                        $GLOBALS['phpgw']->redirect('/index.php'); 
     
    16611698                                        'nofiles'       => True 
    16621699                                )); 
    1663  
    16641700                                $this->bo->vfs->touch(array( 
    16651701                                        'string'=> $this->path.'/'.$this->file, 
     
    16671703                                )); 
    16681704 
     1705 
    16691706                                if($ls_array[0]['mime_type']) 
    16701707                                { 
     
    16861723 
    16871724                        if ($mime_type == 'text/html') 
    1688                         { 
    16891725                                $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); 
    1690                                 $this->t->set_block('filemanager_edit','row','row'); 
    1691                                 include_once("fckeditor.php"); 
    1692                                 $oFCKeditor = new FCKeditor('edit_file_content') ; 
    1693                                 $oFCKeditor->BasePath   = 'filemanager/tp/fckeditor/'; 
    1694                                 $oFCKeditor->ToolbarSet = 'Default'; 
    1695  
    1696                         } 
    1697                         else{ 
     1726                        else 
    16981727                                $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
    1699                                 $this->t->set_block('filemanager_edit','row','row'); 
    1700  
    1701                         } 
     1728 
     1729                        $this->t->set_block('filemanager_edit','row','row'); 
     1730 
    17021731 
    17031732                        $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 
     
    17861815 
    17871816                                         if ($mime_type == 'text/html'){ 
    1788                                         $oFCKeditor->Value = $content; 
    1789                                         $vars[fck_edit] = $oFCKeditor->Create(); 
     1817                                                 $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> 
     1818                                                         <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea> 
     1819                                                         <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ 
     1820                                        removePlugins : \'elementspath\', 
     1821                                        skin : \'office2003\', 
     1822                                        toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print", 
     1823                                        "Undo","Redo","-","Find","Replace","-","SelectAll" ], 
     1824                                        ["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold", 
     1825                                        "Italic","Underline","Strike","-","Subscript","Superscript", 
     1826                                        "NumberedList","BulletedList","-","Outdent","Indent","Blockquote", 
     1827                                        "JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock", 
     1828                                        "Link", "TextColor","BGColor","Maximize"], 
     1829                                        ["Styles","Format","Font","FontSize"]] 
     1830                                         });</script>'; 
    17901831 
    17911832                                        } 
     
    18541895                        } 
    18551896                } 
    1856                 function touch(){ 
    1857                         if($this->file) 
    1858                         if ($this->bo->vfs->touch(array('string'=> $this->file,'relatives' => array(RELATIVE_ALL)))) 
    1859                         { 
    1860                                 echo "True"; 
    1861                                 return True; 
    1862                         } 
    1863                         else 
    1864                                 return False; 
    1865  
    1866                 } 
    18671897                function view() 
    18681898                { 
     1899                        if (!$this->bo->vfs->acl_check(array( 
     1900                                'string'        => $this->path, 
     1901                                'relatives'     => array(RELATIVE_NONE), 
     1902                                'operation'     => PHPGW_ACL_READ 
     1903                        ))) 
     1904                        { 
     1905                                echo lang("You have no permission to access this file"); 
     1906                                return false; 
     1907                        } 
    18691908                        if($this->file) //FIXME 
    18701909                        { 
     
    18861925                                $viewable = array('','text/plain','text/csv','text/html','text/text'); 
    18871926 
    1888                                 if(in_array($mime_type,$viewable) && !$_GET['download']) 
     1927                                if(in_array($mime_type,$viewable)) 
    18891928                                { 
    18901929                                         
    1891                                     header('Content-type: ' . $mime_type); 
     1930                                        header('Content-type: ' . $mime_type); 
    18921931                                        header('Content-disposition: filename="' . $this->file . '"');//FIXME 
    18931932                                        Header("Pragma: public"); 
     
    19141953                                        'nofiles'       => True 
    19151954                                )); 
    1916                                 $timestamp = $this->dateString2timeStamp($ls_array[0]['modified']); 
     1955                                /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 
    19171956                                if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
    19181957                                { 
    1919                                                 // recently than last minute: someone is editing 
    1920                                 } 
     1958                                        // recently than last minute: someone is editing 
     1959                                }*/ 
    19211960                                $mime_type = $ls_array[0]['mime_type']; 
    19221961                                $formats = array('text/html'); 
     
    19391978                        } 
    19401979                } 
    1941                 function download() 
    1942                 { 
    1943                         for($i = 0; $i != $this->numoffiles; $i++) 
    1944                         { 
    1945                                 if(!$this->fileman[$i]) 
    1946                                 { 
    1947                                         continue; 
    1948                                 } 
    1949  
    1950                                 $download_browser = CreateObject('phpgwapi.browser'); 
    1951                                 $download_browser->content_header($this->fileman[$i]); 
    1952                                 echo $this->bo->vfs->read(array('string' => $this->fileman[$i])); 
    1953                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1954                         } 
    1955                 } 
    19561980 
    19571981                //give back an array with all directories except current and dirs that are not accessable 
  • sandbox/filemanager/inc/hook_settings.inc.php

    r1592 r1627  
    5555        } 
    5656 
    57         $upload_boxes=array( 
    58                 "1"=>"1", 
    59                 "5"=>"5", 
    60                 "10"=>"10", 
    61                 "20"=>"20", 
    62                 "30"=>"30" 
    63         ); 
    64          
    65         create_select_box('Default number of upload fields to show','show_upload_boxes',$upload_boxes); 
    6657        $type=array( 
    6758                "portrait"=>lang("portrait"), 
  • sandbox/filemanager/js/common_functions.js

    r1575 r1627  
     1var menuTimeout; 
     2/* draw_menu(id of menu, left position, top position, menu elements) */ 
     3function draw_menu(id,left_pos,top_pos,elements){ 
     4        var menu = document.getElementById('menu_newFile'+id); 
     5        if (menu == null){ 
     6                menu = document.createElement('DIV'); 
     7                menu.id = "menu_newFile"+id; 
     8                menu.style.left = left_pos+"px"; 
     9                menu.style.top = top_pos+"px"; 
     10                for(j in elements) 
     11                        menu.innerHTML += "<a href="+elements[j]['url']+">"+elements[j]['text']+"</a><br>"; 
     12 
     13                menu.onmouseout = function () { menuTimeout = setTimeout("document.getElementById('menu_newFile"+id+"').style.visibility = 'hidden'",50);} 
     14                menu.onmouseover = function () { clearTimeout(menuTimeout); }; 
     15                menu.className = "menu_box"; 
     16                document.getElementById('tableDivAppbox').appendChild(menu); 
     17        } 
     18        menu.style.visibility = ''; 
     19 
     20} 
    121function formfmValidate(arg) 
    222{ 
     23        var button = document.getElementsByName(arg); 
     24        button = button[0]; 
    325        switch (arg) { 
    426                case 'newdir': 
    5                 case 'newfile': 
    6                         var name = prompt(get_lang('Enter with the name of new file/directory'), ''); 
    7                         var input_text = document.getElementById('newfile_or_dir'); 
    8                         if (name == null || ! validateFileExtension(name)) 
    9                         { 
    10                                 return false; 
    11                         } 
    12                         else 
    13                         { 
    14                                 var fileExtension = name.split("."); 
    15                                 fileExtension = fileExtension[1]; 
    16                                 if (typeof(fileExtension) == 'undefined') 
    17                                         input_text.value = name+".html"; 
    18                                 else 
    19                                         input_text.value = name; 
    20                                 return true; 
    21                         } 
    22                         break 
     27                        break; 
     28                case 'new': 
     29                        elements = new Array(); 
     30                        elements[0] = new Array(); 
     31                        elements[0]['text'] = get_lang('empty file'); 
     32                        elements[0]['url'] = 'javascript:newEmptyFile();'; 
     33                        elements[1] = new Array(); 
     34                        elements[1]['text'] = get_lang('File from model'); 
     35                        address = document.location.toString(); 
     36                        address = address.split("?"); 
     37                        elements[1]['url'] = address[0]+"?menuaction=filemanager.uifilemanager.fileModels"; 
     38                        elements[2] = new Array(); 
     39                        elements[2]['text'] = get_lang('Upload'); 
     40                        address = document.location.toString(); 
     41                        address = address.split("?"); 
     42                        elements[2]['url'] = address[0]+"?menuaction=filemanager.uifilemanager.index&upload=clicked&upload.x=1&path="+base64_encode(document.getElementById('cdtodir').value); 
     43 
     44                        draw_menu(arg,button.parentNode.offsetLeft+50,190,elements); 
     45                        return false; 
     46                        break; 
    2347                case 'edit_comments': 
    2448                case 'rename': 
     
    3458                        else 
    3559                        { 
    36                                 alert(get_lang('Please select a file')); 
     60                                write_msg(get_lang('Please select a file')); 
    3761                                return false; 
    3862                        } 
     63                        break; 
     64                case 'move_to': 
     65                case 'copy_to': 
     66                        filesUrl = ""; 
     67                        var one_checked = false; 
     68                        files=document.getElementsByClassName('checkbox'); 
     69                        for (i = 0; i <  files.length; i++) 
     70                                if (files[i].checked){ 
     71                                        one_checked = true; 
     72                                        filesUrl += "&"+files[i].name+"="+files[i].value; 
     73                                } 
     74                        if (!one_checked) 
     75                        { 
     76                                write_msg(get_lang('Please select a file')); 
     77                                return false; 
     78                        } 
     79                        var elements = new Array(); 
     80                        inputEl = document.getElementsByName('todir'); 
     81                        for(i=0; i< inputEl[0].childNodes.length; i++) 
     82                        { 
     83                                elements[i] = new Array(); 
     84                                elements[i]['text'] =inputEl[0].childNodes[i].innerHTML; 
     85                                address = document.location.toString(); 
     86                                address = address.split("&"); 
     87                                elements[i]['url'] = address[0]+ 
     88                                        "&todir="+inputEl[0].childNodes[i].innerHTML+ 
     89                                        "&"+arg+".x=10"+filesUrl; 
     90                        } 
     91                        draw_menu(arg,button.parentNode.offsetLeft+50,190,elements); 
     92                        return false; 
     93                        break; 
    3994                default: 
    4095                        return true; 
     
    62117        if ( error_flag == true ) 
    63118        { 
    64                 alert(get_lang('File extension forbidden or invalid file') + '.'); 
     119                write_error(get_lang('File extension forbidden or invalid file') + '.'); 
    65120                return false; 
    66121        } 
     
    81136 
    82137} 
     138 
     139 
     140function newEmptyFile(){ 
     141        var name = prompt(get_lang('Enter with the name of new file/directory'), ''); 
     142        var input_text = document.getElementById('newfile_or_dir'); 
     143        if (name != null && name != '' && validateFileExtension(name)) 
     144        { 
     145                var fileExtension = name.split("."); 
     146                fileExtension = fileExtension[1]; 
     147                if (typeof(fileExtension) == 'undefined') 
     148                        input_text.value = name+".html"; 
     149                else 
     150                        input_text.value = name; 
     151                address = document.location.toString(); 
     152                address = address.split("&"); 
     153                document.location = address[0]+"&newfile.x=clicked&newfile_or_dir="+input_text.value; 
     154 
     155        } 
     156 
     157} 
     158 
     159 
     160/* 
     161 * base64.js - Base64 encoding and decoding functions 
     162 * 
     163 * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com> 
     164 * Released under the MIT license 
     165 */ 
     166 
     167function base64_encode(str) { 
     168        var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 
     169        var encoded = []; 
     170        var c = 0; 
     171        while (c < str.length) { 
     172                var b0 = str.charCodeAt(c++); 
     173                var b1 = str.charCodeAt(c++); 
     174                var b2 = str.charCodeAt(c++); 
     175                var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0); 
     176                var i0 = (buf & (63 << 18)) >> 18; 
     177                var i1 = (buf & (63 << 12)) >> 12; 
     178                var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6; 
     179                var i3 = isNaN(b2) ? 64 : (buf & 63); 
     180                encoded[encoded.length] = chars.charAt(i0); 
     181                encoded[encoded.length] = chars.charAt(i1); 
     182                encoded[encoded.length] = chars.charAt(i2); 
     183                encoded[encoded.length] = chars.charAt(i3); 
     184        } 
     185        return encoded.join(''); 
     186} 
     187 
     188function base64_decode(str) { 
     189        var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 
     190        var invalid = { 
     191strlen: (str.length % 4 != 0), 
     192        chars:  new RegExp('[^' + chars + ']').test(str), 
     193        equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str))) 
     194        }; 
     195        if (invalid.strlen || invalid.chars || invalid.equals) 
     196                throw new Error('Invalid base64 data'); 
     197        var decoded = []; 
     198        var c = 0; 
     199        while (c < str.length) { 
     200                var i0 = chars.indexOf(str.charAt(c++)); 
     201                var i1 = chars.indexOf(str.charAt(c++)); 
     202                var i2 = chars.indexOf(str.charAt(c++)); 
     203                var i3 = chars.indexOf(str.charAt(c++)); 
     204                var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63); 
     205                var b0 = (buf & (255 << 16)) >> 16; 
     206                var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8; 
     207                var b2 = (i3 == 64) ? -1 : (buf & 255); 
     208                decoded[decoded.length] = String.fromCharCode(b0); 
     209                if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1); 
     210                if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2); 
     211        } 
     212        return decoded.join(''); 
     213} 
     214 
     215 
     216function setRestricted(data){ 
     217        if (data.indexOf("True") == 0){ 
     218                returnVal = data.split(':'); 
     219                var img_lock = document.getElementById('restrict_'+returnVal[1]); 
     220                if (img_lock.src.indexOf('button_unlock') > 0) 
     221                { 
     222                        img_lock.src = img_lock.src.replace(/button_unlock/g,'button_lock'); 
     223                        write_msg(get_lang('%1 marked as restricted',returnVal[1])); 
     224                } 
     225                else 
     226                { 
     227                        img_lock.src = img_lock.src.replace(/button_lock/g,'button_unlock'); 
     228                        write_msg(get_lang('%1 unmarked as restricted',returnVal[1])); 
     229                } 
     230        } 
     231        else 
     232                write_error("Could not mark as restricted"); 
     233} 
  • sandbox/filemanager/js/draw_api.js

    r1564 r1627  
    44var usedSpace = document.getElementById('usedSpace').value; 
    55 
    6 document.getElementById('content_quota').innerHTML = '<table width="102" cellspacing="0" cellpadding="0" border="0" id="table_quota"><tbody><tr><td width="102" nowrap="true" height="15" background="../phpgwapi/templates/default/images/dsunused.gif"><table cellspacing="0" cellpadding="0" border="0" style="width: '+parseInt((usedSpace/quotaSize)*100)+'%;"><tbody><tr><td height="15" class="dsused"/></tr></tbody></table></td><td nowrap="true" align="center"><span class="boxHeaderText">'+parseInt(usedSpace/quotaSize*100)+'% ('+usedSpace+'M/'+quotaSize+'M)</span></td></tr></tbody></table></td></tr></table>' 
     6document.getElementById('content_quota').innerHTML = '<table width="102" cellspacing="0" cellpadding="0" border="0" id="table_quota"><tbody><tr><td width="102" nowrap="true" height="15" background="../phpgwapi/templates/default/images/dsunused.gif"><table cellspacing="0" cellpadding="0" border="0" style="width: '+parseInt((usedSpace/quotaSize)*100)+'%;"><tbody><tr><td height="15" class="dsused"/></tr></tbody></table></td><td nowrap="true" align="center"><span class="boxHeaderText">'+parseInt(usedSpace/quotaSize*100)+'% ('+(usedSpace/1024/1024).toFixed(1)+'M/'+(quotaSize/1024/1024)+'M)</span></td></tr></tbody></table></td></tr></table>' 
     7 
     8var headerMsgLock = false; 
     9var labelBefore = ""; 
     10function write_msg (message){ 
     11        if (headerMsgLock){ 
     12                setTimeout('write_msg("'+message+'");', 300); 
     13                return; 
     14        } 
     15        headerMsgLock = true; 
     16        headerDiv = document.getElementById("divAppboxHeader"); 
     17        labelBefore = headerDiv.innerHTML; 
     18        headerDiv.innerHTML = '<table width=100% cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_info_th">'+message+'</th><th width="40%"></th></tr></tbody></table>'; 
     19        setTimeout('headerMsgLock = false; document.getElementById("divAppboxHeader").innerHTML = labelBefore;', 3000); 
     20} 
     21 
     22function write_error (message){ 
     23        if (headerMsgLock){ 
     24                setTimeout('write_error("'+message+'");', 300); 
     25                return; 
     26        } 
     27        headerMsgLock = true; 
     28        headerDiv = document.getElementById("divAppboxHeader"); 
     29        labelBefore = headerDiv.innerHTML; 
     30        headerDiv.innerHTML = '<table width=100% cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_error_th">'+message+'</th><th width="40%"></th></tr></tbody></table>'; 
     31        setTimeout('headerMsgLock = false; document.getElementById("divAppboxHeader").innerHTML = labelBefore;', 3000); 
     32} 
     33 
     34function displayMessages(){ 
     35        var messages = document.getElementById("allMessages"); 
     36        for (i=0; i < messages.childNodes.length; i++){ 
     37                if (messages.childNodes[i].innerHTML.indexOf(get_lang('Error:')) == 0) 
     38                        write_error(messages.childNodes[i].innerHTML); 
     39                else 
     40                        write_msg(messages.childNodes[i].innerHTML); 
     41        } 
     42} 
     43setTimeout('displayMessages();',500); 
  • sandbox/filemanager/js/global.js

    r1556 r1627  
    11var title_app = '<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>'+ 
    2 '<tr>'+ 
     2'<tr class="divAppboxHeader">'+ 
    33'<td style="padding-left:17px" width=33% id="content_quota" align=left></td>'+ 
    4 '<td class="divAppboxHeader" width=33% id="main_title">Expresso FileManager</td>'+ 
     4'<td width=33% id="main_title">Expresso FileManager</td>'+ 
    55'<td width=33% id="div_menu_c3" align=right></td>'+ 
    66'</tr></table>'; 
  • sandbox/filemanager/js/refresh.js

    r1575 r1627  
    22 
    33setTimeout("pooling_refresh();",refresh_time); 
    4  
    5  
    6 /* 
    7  * base64.js - Base64 encoding and decoding functions 
    8  * 
    9  * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com> 
    10  * Released under the MIT license 
    11  */ 
    12  
    13 function base64_encode(str) { 
    14         var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 
    15         var encoded = []; 
    16         var c = 0; 
    17         while (c < str.length) { 
    18                 var b0 = str.charCodeAt(c++); 
    19                 var b1 = str.charCodeAt(c++); 
    20                 var b2 = str.charCodeAt(c++); 
    21                 var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0); 
    22                 var i0 = (buf & (63 << 18)) >> 18; 
    23                 var i1 = (buf & (63 << 12)) >> 12; 
    24                 var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6; 
    25                 var i3 = isNaN(b2) ? 64 : (buf & 63); 
    26                 encoded[encoded.length] = chars.charAt(i0); 
    27                 encoded[encoded.length] = chars.charAt(i1); 
    28                 encoded[encoded.length] = chars.charAt(i2); 
    29                 encoded[encoded.length] = chars.charAt(i3); 
    30         } 
    31         return encoded.join(''); 
    32 } 
    33  
    34 function base64_decode(str) { 
    35         var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 
    36         var invalid = { 
    37 strlen: (str.length % 4 != 0), 
    38         chars:  new RegExp('[^' + chars + ']').test(str), 
    39         equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str))) 
    40         }; 
    41         if (invalid.strlen || invalid.chars || invalid.equals) 
    42                 throw new Error('Invalid base64 data'); 
    43         var decoded = []; 
    44         var c = 0; 
    45         while (c < str.length) { 
    46                 var i0 = chars.indexOf(str.charAt(c++)); 
    47                 var i1 = chars.indexOf(str.charAt(c++)); 
    48                 var i2 = chars.indexOf(str.charAt(c++)); 
    49                 var i3 = chars.indexOf(str.charAt(c++)); 
    50                 var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63); 
    51                 var b0 = (buf & (255 << 16)) >> 16; 
    52                 var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8; 
    53                 var b2 = (i3 == 64) ? -1 : (buf & 255); 
    54                 decoded[decoded.length] = String.fromCharCode(b0); 
    55                 if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1); 
    56                 if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2); 
    57         } 
    58         return decoded.join(''); 
    59 } 
    60  
    61  
    624 
    635 
     
    668        } 
    679        var filename=document.getElementsByName('edit_file'); 
    68         cExecute("/index.php?menuaction=filemanager.uifilemanager.touch&file="+base64_encode(filename[0].value),handler); 
     10        cExecute("/index.php?menuaction=filemanager.vfs_functions.touch&file="+base64_encode(filename[0].value),handler); 
    6911        setTimeout("pooling_refresh();",refresh_time); 
    7012} 
  • sandbox/filemanager/setup/phpgw_pt-br.lang

    r1592 r1627  
    2323create file     filemanager     pt-br   Criar Arquivo 
    2424create folder   filemanager     pt-br   Criar Pasta 
     25new     filemanager     pt-br   novo 
    2526created filemanager     pt-br   Criado 
    2627created %1      filemanager     pt-br   Criado %1 
     28You have no permission to access this file      filemanager     pt-br   Você não tem permissão para acessar este arquivo 
    2729created %1,%2   filemanager     pt-br   Criado %1, %2 
    2830created by      filemanager     pt-br   Criado por 
     31Error:  filemanager     pt-br   Erro: 
    2932created directory %1    filemanager     pt-br   Criada pasta %1 
    3033date    filemanager     pt-br   Data 
     
    3235This file is being edited right now by: filemanager     pt-br   Este arquivo está sendo editado por:  
    3336portrait        filemanager     pt-br   retrato 
     37Could not mark as restricted    filemanager     pt-br   Não foi possível marcar como restrito 
     38%1 marked as restricted filemanager     pt-br   %1 foi marcado como restrito 
     39%1 unmarked as restricted       filemanager     pt-br   %1 foi desmarcado como restrito 
     40Mark as restricted      filemanager     pt-br   Marcar como restrito 
     41Unmark as restricted    filemanager     pt-br   Desmarcar como restrito 
    3442landscape       filemanager     pt-br   paisagem 
    3543letter  filemanager     pt-br   carta 
     
    9199rename  filemanager     pt-br   Renomear 
    92100renamed %1 to %2        filemanager     pt-br   Renomeado %1 para %2 
    93 replaced %1     filemanager     pt-br   Substituído %1 
     101created new %1  filemanager     pt-br   Criado novo arquivo %1 
    94102save %1 filemanager     pt-br   Salvar %1 
    95103save %1, and go back to file listing    filemanager     pt-br   Salvar %1, e voltar para listagem dos arquivos 
     
    118126users   filemanager     pt-br   Usuários 
    119127version filemanager     pt-br   Versão 
     128New...  filemanager     pt-br   Novo... 
     129Empty file      filemanager     pt-br   Arquivo vazio 
     130File from model filemanager     pt-br   Arquivo de modelo 
     131Article filemanager     pt-br   Artigo 
     132Todo    filemanager     pt-br   Tarefas 
     133Slide   filemanager     pt-br   Apresentação 
     134Cards   filemanager     pt-br   Cartões 
     135Resume  filemanager     pt-br   Currículo 
    120136Impossbile to edit this file    filemanager     pt-br   Impossível editar o arquivo selecionado 
    121137Enter with the name of new file/directory       filemanager     pt-br   Insira o nome do novo arquivo/diretório 
  • sandbox/filemanager/templates/default/edit_file.tpl

    r1575 r1627  
    1212        <input type="hidden" name="edit_file" value="{edit_file}" /> 
    1313        {filemans_hidden} 
    14         <textarea name="edit_file_content" rows="10" cols="50">{file_content}</textarea> 
     14        <textarea name="edit_file_content" rows="15" cols="80">{file_content}</textarea> 
    1515<!--                    </td> 
    1616                </tr> 
  • sandbox/filemanager/templates/default/filelisting.tpl

    r1556 r1627  
    33{quotaSize} 
    44{javascript} 
    5 <form name="formfm" method="post" action="{form_action}"> 
     5<form id="formfm" name="formfm" method="post" action="{form_action}"> 
    66{toolbar0} 
    77<div id="fmMenu"> 
     
    99</div> 
    1010<div id="fmFileWindow"> 
    11 {messages}                      <table cellspacing="0" cellpadding="2"> 
    12                                 <tbody> 
     11<table cellspacing="0" cellpadding="2"> 
     12<tbody> 
    1313<!-- END filemanager_header --> 
    1414 
     
    1919<!-- BEGIN row --> 
    2020        <tr bgcolor="{row_tr_color}"> 
    21                 <td valign="middle" style="padding-left:2px;padding-right:2px;">{actions}</td> 
     21                <td valign="middle" style="padding-left:2px;padding-right:2px;">{actions}{mini_bar}</td> 
    2222                {columns} 
    2323        </tr> 
     
    3030<div id="fmStatusBar"><b>{lang_files_in_this_dir}:</b> {files_in_this_dir} <b>{lang_used_space}: </b> {used_space}</div> 
    3131</form> 
     32<div style="visibility: hidden;" id="allMessages">{messages}</div> 
    3233<!-- END filemanager_footer --> 
    33  
  • sandbox/filemanager/templates/default/upload.tpl

    r1506 r1627  
    11<!-- BEGIN upload_header --> 
     2<script src="filemanager/js/uploadForm.js" type="text/javascript"></script> 
    23<form method="post" action="{form_action}" enctype="multipart/form-data"> 
    34<div> 
     
    1112 
    1213<!-- BEGIN row --> 
    13         <tr > 
    14         <td><input maxlength="255" name="upload_file[]" type="file"></td> 
     14        <tr id="uploadOption"> 
     15        <td><input onchange="javascript:addNewInput();" maxlength="255" name="upload_file[]" type="file"></td> 
    1516        <td><input name="upload_comment[]" type="text"></td> 
    1617        </tr> 
     
    2223<input value="true" name="uploadprocess" type="hidden"> 
    2324<input value="{path}" name="path" type="hidden"> 
    24 <input value="{num_upload_boxes}" name="show_upload_boxes" type="hidden"> 
     25<input value="{num_upload_boxes}" name="show_upload_boxes" id="show_upload_boxes" type="hidden"> 
    2526<input value="{lang_upload}" name="upload_files" type="submit"> 
    26 <br/> 
    27 {change_upload_boxes} 
    2827</div> 
    2928</form> 
  • trunk/phpgwapi/inc/class.vfs_sql.inc.php

    r1575 r1627  
    3838                var $working_id; 
    3939                var $working_lid; 
     40                var $my_home; 
    4041                var $meta_types; 
    4142                var $now; 
     
    5253                        $this->working_id = $GLOBALS['phpgw_info']['user']['account_id']; 
    5354                        $this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id); 
     55                        $this->my_home = $this->fakebase.'/'.$this->working_lid; 
    5456                        $this->now = date ('Y-m-d H:i:s'); 
    5557 
     
    6466                        $this->attributes[] = 'deleteable'; 
    6567                        $this->attributes[] = 'content'; 
     68                        $this->attributes[] = 'type'; 
    6669 
    6770                        /* 
     
    612615                function acl_check ($data) 
    613616                { 
     617 
    614618                        if (!is_array ($data)) 
    615619                        { 
    616620                                $data = array (); 
    617621                        } 
     622 
     623                        /* ExpressoLivre principle: In your home you do what you want*/ 
     624                        if (strpos($data['string'],$this->my_home) === 0) 
     625                                return True; 
    618626 
    619627                        $default_values = array 
     
    845853                                $data = array (); 
    846854                        } 
     855 
     856                        $path = explode('/',$data['string']); 
     857                        $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 
     858                        if ($quota > 0 && $this->get_size($data) >= $quota * 1024 * 1024) 
     859                                return false; 
     860 
    847861 
    848862                        $default_values = array 
     
    10821096                                $data = array (); 
    10831097                        } 
     1098                        $path = explode('/',$data['to']); 
     1099                        $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 
     1100                        $size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1])); 
     1101                        if ($quota > 0 && $size >= $quota * 1024 * 1024) 
     1102                                return false; 
    10841103 
    10851104                        $default_values = array 
     
    13441363                                $data = array (); 
    13451364                        } 
     1365 
     1366                        $path = explode('/',$data['to']); 
     1367                        $quota = $this->get_quota(array('string' => '/'.$path[1].'/'.$path[2])); 
     1368                        $size = $this->get_size(array('string' => $data['to'], 'relatives' => $data['relatives'][1])); 
     1369                        if ($quota > 0 && $size >= $quota * 1024 * 1024) 
     1370                                return false; 
     1371 
    13461372 
    13471373                        $default_values = array 
     
    23252351                        return $size; 
    23262352                } 
     2353                /* 
     2354                 * get the quota defined for the path in sql table 
     2355                 */ 
     2356                function get_quota($data){ 
     2357                        if (!is_array ($data)) 
     2358                        { 
     2359                                $data = array (); 
     2360                        } 
     2361 
     2362                        $default_values = array 
     2363                                ( 
     2364                                        'relatives'     => array (RELATIVE_CURRENT) 
     2365                                ); 
     2366 
     2367                        $data = array_merge ($this->default_values ($data, $default_values), $data); 
     2368 
     2369                        $p = $this->path_parts (array( 
     2370                                        'string'        => $data['string'], 
     2371                                        'relatives'     => RELATIVE_NONE 
     2372                                ) 
     2373                        ); 
     2374 
     2375                        if (!$this->acl_check (array( 
     2376                                'string'        => $p->fake_full_path, 
     2377                                'relatives'     => $p->mask, 
     2378                                'operation'     => PHPGW_ACL_READ 
     2379                        )) 
     2380                        ) 
     2381                        { 
     2382                                return False; 
     2383                        } 
     2384                        $query = $GLOBALS['phpgw']->db->query ("SELECT quota_size FROM phpgw_vfs_quota WHERE directory = '".$data['string']."' LIMIT 1;", __LINE__,__FILE__); 
     2385 
     2386                        $GLOBALS['phpgw']->db->next_record (); 
     2387                        $record = $GLOBALS['phpgw']->db->Record; 
     2388                        return $record['quota_size']; 
     2389                } 
     2390                function set_quota($data){ 
     2391                        if (!is_array ($data)) 
     2392                        { 
     2393                                $data = array (); 
     2394                        } 
     2395 
     2396                        $default_values = array 
     2397                                ( 
     2398                                        'relatives'     => array (RELATIVE_CURRENT) 
     2399                                ); 
     2400 
     2401                        $data = array_merge ($this->default_values ($data, $default_values), $data); 
     2402 
     2403                        $p = $this->path_parts (array( 
     2404                                        'string'        => $data['string'], 
     2405                                        'relatives'     => array ($data['relatives'][0]) 
     2406                                ) 
     2407                        ); 
     2408 
     2409                        if (!$this->acl_check (array( 
     2410                                'string'        => $p->fake_full_path, 
     2411                                'relatives'     => array ($p->mask), 
     2412                                'operation'     => PHPGW_ACL_READ 
     2413                        )) 
     2414                        ) 
     2415                        { 
     2416                                return False; 
     2417                        } 
     2418                        // INSERT INTO phpgw_vfs_quota values('/home/amuller',200); 
     2419                        // 
     2420                        return $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_vfs_quota VALUES ('".$data['string']."',".$data['new_quota'].");", __LINE__,__FILE__); 
     2421                } 
     2422 
    23272423 
    23282424                /*! 
     
    23992495                        $dir = $p->fake_full_path; 
    24002496 
     2497 
    24012498                        /* If they pass us a file or 'nofiles' is set, return the info for $dir only */ 
    24022499                        if (@$data['file_id'] 
     
    24282525                                else 
    24292526                                { 
    2430                                         $sql .= "directory='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_leading_dirs_clean). 
    2431                                                 "' AND name='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_name_clean)."'". 
     2527                                        $sql .= " directory='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_leading_dirs_clean)."' AND". 
     2528                                                " name='".$GLOBALS['phpgw']->db->db_addslashes($p->fake_name_clean)."'". 
    24322529                                                $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 
    24332530                                } 
     
    25082605                        /* SELECT all, the, attributes FROM phpgw_vfs WHERE file=$dir */ 
    25092606                        $sql = 'SELECT '; 
     2607                        if (!$this->acl_check (array ( 
     2608                                'string' => $p->fake_full_path, 
     2609                                'relatives' => array ($p->mask), 
     2610                                'operation' => PHPGW_ACL_PRIVATE) 
     2611                        )) 
     2612                        $query_type = " type != 1 AND"; 
     2613                        else 
     2614                                $query_type = ""; 
    25102615 
    25112616                        foreach($this->attributes as $num => $attribute) 
     
    25202625 
    25212626                        $dir_clean = $this->clean_string (array ('string' => $dir)); 
    2522                         $sql .= " FROM phpgw_vfs WHERE directory LIKE '".$GLOBALS['phpgw']->db->db_addslashes($dir_clean)."%'"; 
     2627                        $sql .= " FROM phpgw_vfs WHERE ".$query_type." directory LIKE '".$GLOBALS['phpgw']->db->db_addslashes($dir_clean)."%'"; 
    25232628                        $sql .= $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)); 
    25242629 
     
    25272632                                $sql .= " AND mime_type='".$data['mime_type']."'"; 
    25282633                        } 
    2529  
    2530                         $sql .= ' ORDER BY '.$data['orderby']; 
    2531  
     2634                        if (strlen($data['orderby']) > 0) 
     2635                                $sql .= ' ORDER BY '.$data['orderby']; 
    25322636                        $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); 
    25332637 
Note: See TracChangeset for help on using the changeset viewer.