phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] filemanager/inc class.bofilemanager.inc.php cla...


From: Dave Hall
Subject: [Phpgroupware-cvs] filemanager/inc class.bofilemanager.inc.php cla...
Date: Wed, 16 Aug 2006 14:20:33 +0000

CVSROOT:        /cvsroot/phpgroupware
Module name:    filemanager
Changes by:     Dave Hall <skwashd>     06/08/16 14:20:33

Modified files:
        inc            : class.bofilemanager.inc.php 
                         class.uifilemanager.inc.php 

Log message:
        fixes for a few glitches i found

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/filemanager/inc/class.bofilemanager.inc.php?cvsroot=phpgroupware&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/filemanager/inc/class.uifilemanager.inc.php?cvsroot=phpgroupware&r1=1.35&r2=1.36

Patches:
Index: class.bofilemanager.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/inc/class.bofilemanager.inc.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- class.bofilemanager.inc.php 5 Nov 2005 23:13:38 -0000       1.26
+++ class.bofilemanager.inc.php 16 Aug 2006 14:20:32 -0000      1.27
@@ -8,7 +8,7 @@
        * @copyright Portions Copyright (C) 2000-2005 Free Software Foundation, 
Inc http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package filemanager
-       * @version $Id: class.bofilemanager.inc.php,v 1.26 2005/11/05 23:13:38 
ceb Exp $
+       * @version $Id: class.bofilemanager.inc.php,v 1.27 2006/08/16 14:20:32 
skwashd Exp $
        * @internal Based on phpWebhosting
        */
 
@@ -19,7 +19,7 @@
         */
        class bofilemanager
        {
-               var $access_add = False;
+               var $access_add = false;
                var $basedir;
                var $fakebase;
                var $settings;
@@ -57,8 +57,8 @@
                var $quota = 0;
                var $command_line;
 
-       //      var $debug = True;
-               var $debug = False;
+               //var $debug = true;
+               var $debug = false;
 
                function bofilemanager()
                {
@@ -122,7 +122,7 @@
                        }
                        $this->hostname                                 = 
$GLOBALS['phpgw_info']['server']['webserver_url'].$this->filesdir;
                        $this->userinfo['account_id']   = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->userinfo['account_lid']  = 
$GLOBALS['phpgw']->accounts->id2name($this->userinfo['account_id']);
+                       $this->userinfo['account_lid']  = 
$GLOBALS['phpgw_info']['user']['account_lid'];
                        $this->userinfo['hdspace']              = 10000000000;
                        $this->homedir                                  = 
$this->fakebase.SEP.$this->userinfo['account_lid'];
 
@@ -220,13 +220,13 @@
                                                                        'fake' 
=> False
                                                                        
)).'<br>'
                                        . 'fake getabsolutepath: 
'.$GLOBALS['phpgw']->vfs->getabsolutepath().'<br>'
-                                       . 'appsession: 
'.$GLOBALS['phpgw']->session->appsession('vfs','').'<br>'
+                                       . 'appsession: ' . 
trim($GLOBALS['phpgw']->session->appsession('vfs','')) . '<br>'
                                        . 'pwd: 
'.$GLOBALS['phpgw']->vfs->pwd().'<br>';
                        }
 
-                       ###
-                       # Get their memberships to be used throughout the script
-                       ###
+                       /*      
+                                Get their memberships to be used throughout 
the script
+                       */
 
                        $groups = 
$GLOBALS['phpgw']->accounts->membership($this->userinfo['account_id']);
 
@@ -236,15 +236,15 @@
                        }
                        //_debug_array($groups);
 
-                       ###
-                       # Don't list directories for groups that don't have 
access
-                       ###
+                       /*
+                               Don't list directories for groups that don't 
have access
+                       */
 
                        for($i=0;$i<count($groups);++$i)
                        {
                                if 
($GLOBALS['phpgw']->vfs->acl_check(array('owner_id' => 
$groups[$i]['account_id'],'operation' => PHPGW_ACL_READ)))
                                {
-                                       $applications = 
CreateObject('phpgwapi.applications',$groups[$i]['account_id']);
+                                       $applications =& 
CreateObject('phpgwapi.applications', $groups[$i]['account_id']);
                                        $apps = 
$applications->read_account_specific();
                                        //_debug_array($apps);
                                        if(!$apps['filemanager'])
@@ -262,10 +262,10 @@
                        $this->memberships = $groups;
                        //_debug_array($this->memberships);
 
-                       ###
-                       # We determine if they're in their home directory or a 
group's directory,
-                       # and set the VFS working_id appropriately
-                       ###
+                       /*
+                               We determine if they're in their home directory 
or a group's directory,
+                               and set the VFS working_id appropriately
+                       */
                        
if((preg_match('+^'.$this->fakebase.'\/(.*)(\/|$)+U',$this->path,$this->matches))
 && $this->matches[1] != $this->userinfo['account_lid'])
                        {
                                $GLOBALS['phpgw']->vfs->working_id = 
$GLOBALS['phpgw']->accounts->name2id($this->matches[1]);
@@ -277,39 +277,42 @@
 
                        if ($GLOBALS['phpgw']->vfs->acl_check(array('string' => 
$this->path,'relatives' => array (RELATIVE_NONE),'operation' => PHPGW_ACL_ADD)))
                        {
-                               $this->access_add = True;
+                               $this->access_add = true;
                        }
 
-                       $this->quota = 
($GLOBALS['phpgw']->accounts->data['quota'] == 
-1?-1:$GLOBALS['phpgw']->accounts->data['quota']*1024*1024); 
+                       if ( $GLOBALS['phpgw']->accounts->data['quota'] == -1 )
+                       {
+                               $this->quota = -1;
                }
-
-               function initialize_vars($name)
+                       else
                {
-                       $var = get_var($name,Array('GET','POST','POST'));
+                               $this->quota = 
$GLOBALS['phpgw']->accounts->data['quota'] * 1024 * 1024;
+                       }
+               }
                        
-                       //to get the file uploads, without requiring 
register_globals in php.ini
-                       if(phpversion() >= '4.2.0')
+               function initialize_vars($name)
                        {
-                               $meth = '_FILES';
-                       }
-                       else
+                       $var = '';
+                       if ( isset($_FILES[$name]))
                        {
-                               $meth = 'HTTP_POST_FILES';
+                               $var = $_FILES[$name];
                        }
-                       if(@isset($GLOBALS[$meth][$name]))
+                       else if (isset($_REQUEST[$name]) )
                        {
-                               $var = $GLOBALS[$meth][$name];
+                               $var = $_REQUEST[$name];
                        }
+
                        if($this->debug)
                        {
-                               echo '<!-- '.$name.' = '.$var.' -->'."\n";
+                               echo "<!-- {$name} = {$var} -->\n";
                        }
+
                        if(is_array($this->$name) && $var)
                        {
                                //_debug_array($var);
 
                                $temp = Array();
-                               while(list($varkey,$varvalue) = each($var))
+                               foreach ( $var as $varkey => $varvalue )
                                {
                                        if(is_int($varkey))
                                        {
@@ -325,6 +328,7 @@
                        {
                                $temp = urldecode($var);
                        }
+
                        if(isset($temp))
                        {
                                $this->$name = $temp;
@@ -364,7 +368,8 @@
                function get_fileman()
                {
                        $edit=array();
-                       for ($i=0; $i!=count($this->fileman);$i++)
+                       $cnt_fileman = count($this->fileman);
+                       for ($i=0; $i < $cnt_fileman; ++$i)
                        {
                                $edit[$this->fileman[$i]] = $this->fileman[$i];
                        }
@@ -378,10 +383,10 @@
 
                function create_home_dir()
                {
-                       ###
-                       # If their home directory doesn't exist, we create it
-                       # Same for group directories
-                       ###
+                       /*
+                               If their home directory doesn't exist, we 
create it
+                               Same for group directories
+                       */
 
                        if($this->debug)
                        {
@@ -399,11 +404,11 @@
                                }
                                //$GLOBALS['phpgw']->vfs->override_acl = 0;
                        }
-                       
elseif(preg_match("|^".$this->fakebase."\/(.*)$|U",$this->path,$this->matches))
+                       elseif(preg_match("|^{$this->fakebase}\/(.*)$|U", 
$this->path, $this->matches))
                        {
                                if 
(!$GLOBALS['phpgw']->vfs->file_exists(array('string' => $this->path,'relatives' 
=> array(RELATIVE_NONE))))
                                {
-                                       $group_id = 
$GLOBALS['phpgw']->accounts->name2id($this->matches[1]);
+                                       $group_id = (int) 
$GLOBALS['phpgw']->accounts->name2id($this->matches[1]);
                                        $GLOBALS['phpgw']->vfs->working_id = 
$group_id;
                                        $GLOBALS['phpgw']->vfs->override_acl = 
1;
 
@@ -411,7 +416,7 @@
                                        {
                                                $error = lang('failed to create 
directory %1',$this->homedir);
                                        }
-                                       //$GLOBALS['phpgw']->vfs->override_acl 
= 0;
+                                       $GLOBALS['phpgw']->vfs->override_acl = 
0;
 
                                        if($this->debug)
                                        {
@@ -426,6 +431,8 @@
                                                        'relatives' => 
array(RELATIVE_NONE),
                                                        'attributes' => 
array('owner_id' => $group_id, 'createdby_id' => $group_id)));
                                        }
+                                       $GLOBALS['phpgw']->vfs->working_id = 
$this->userinfo['account_id'];
+                                       $GLOBALS['phpgw']->vfs->override_acl = 
0;
                                }
                        }
                        if(strlen($error))
@@ -436,12 +443,11 @@
 
                function load_files()
                {
-                       ###
-                       # Read in file info from database to use in the rest of 
the script
-                       # $fakebase is a special directory.  In that directory, 
we list the user's
-                       # home directory and the directories for the groups 
they're in
-                       ###
-
+                       /*
+                               Read in file info from database to use in the 
rest of the script
+                               $fakebase is a special directory.  In that 
directory, we list the user's
+                               home directory and the directories for the 
groups they're in
+                       */
                        if ($this->path == $this->fakebase)
                        {
                                //echo 'path: ' . $this->path . "\n";
@@ -460,30 +466,30 @@
                                        ));
                                $this->files_array[] = $ls_array[0];
 
-                               reset ($this->memberships);
-                               while(list($num, $group_array) = 
each($this->memberships))
+                               foreach ( $this->memberships as $group_array )
+                               {
+                                       if ( 
!$GLOBALS['phpgw']->vfs->file_exists(array('string' => 
"{$this->fakebase}/{$group_array['account_name']}", 'relatives' => 
array(RELATIVE_NONE) ) ) )
                                {
-                                       if 
(!$GLOBALS['phpgw']->vfs->file_exists(array(
-                                               'string' => 
$this->fakebase.'/'.$group_array['account_name'],
-                                               'relatives' => 
Array(RELATIVE_NONE)
-                                               )))
-                                       {
-                                               
$GLOBALS['phpgw']->vfs->mkdir(array(
-                                                       'string' => 
$this->fakebase.'/'.$group_array['account_name'],
-                                                       'relatives' => 
Array(RELATIVE_NONE)
+                                               
$GLOBALS['phpgw']->vfs->mkdir(array
+                                               (
+                                                       'string'        => 
"{$this->fakebase}/{$group_array['account_name']}",
+                                                       'relatives'     => 
array(RELATIVE_NONE)
                                                        ));
-                                               
$GLOBALS['phpgw']->vfs->set_attributes(array(
-                                                       'string' => 
$this->fakebase.'/'.$group_array['account_name'],
-                                                       'relatives' => 
Array(RELATIVE_NONE),
-                                                       'attributes'=> 
Array('owner_id' => $group_array['account_id'], 'createdby_id' => 
$group_array['account_id'])
+
+                                               
$GLOBALS['phpgw']->vfs->set_attributes(array
+                                               (
+                                                       'string'        => 
"{$this->fakebase}/{$group_array['account_name']}",
+                                                       'relatives' => 
array(RELATIVE_NONE),
+                                                       'attributes'=> 
array('owner_id' => $group_array['account_id'], 'createdby_id' => 
$group_array['account_id'])
                                                        ));
                                        }
 
-                                       $ls_array = 
$GLOBALS['phpgw']->vfs->ls(array(
-                                               'string' => 
$this->fakebase.'/'.$group_array['account_name'],
-                                               'relatives' => 
Array(RELATIVE_NONE),
-                                               'checksubdirs' => False,
-                                               'nofiles' => True
+                                       $ls_array = 
$GLOBALS['phpgw']->vfs->ls(array
+                                       (
+                                               'string'                => 
"{$this->fakebase}/{$group_array['account_name']}",
+                                               'relatives'     => 
array(RELATIVE_NONE),
+                                               'checksubdirs'  => false,
+                                               'nofiles'               => true
                                                ));
                                        $this->files_array[] = $ls_array[0];
                                }
@@ -493,19 +499,21 @@
                                //echo 'path: ' . $this->path . "\n";
                                //echo 'fake: ' . $this->fakebase;
 
-                               $ls_array = $GLOBALS['phpgw']->vfs->ls(array(
+                               $ls_array = $GLOBALS['phpgw']->vfs->ls(array
+                               (
                                        'string' => $this->path,
-                                       'relatives' => Array(RELATIVE_NONE),
-                                       'checksubdirs' => False,
-                                       'orderby' =>$this->sortby
+                                       'relatives'     => array(RELATIVE_NONE),
+                                       'checksubdirs'  => false,
+                                       'orderby'               => $this->sortby
                                        ));
+                               //echo '<pre>' . print_r($ls_array, true) . 
'</pre>';
 
                                if ($this->debug)
                                {
-                                       echo '# of files found in 
"'.$this->path.'" : '.count($ls_array).'<br>'."\n";
+                                       echo "# of files found in 
'{$this->path}' : " . count($ls_array) . "<br>\n";
                                }
 
-                               while(list($num,$file_array) = each($ls_array))
+                               foreach ( $ls_array as $file_array )
                                {
                                        $this->files_array[] = $file_array;
                                        if ($this->debug)
@@ -806,9 +814,9 @@
                                }
                                else
                                {
-                                       ###
-                                       # Check to see if the file exists in 
the database, and get its info at the same time
-                                       ###
+                                       /*
+                                               Check to see if the file exists 
in the database, and get its info at the same time
+                                       */
                
                                        $ls_array = 
$GLOBALS['phpgw']->vfs->ls(array(
                                                'string'        => 
$this->upload_file['name'][$i],
@@ -983,10 +991,9 @@
                        }
                }
 
-               ###
-               # Check for and return the first unwanted character
-               ###
-
+               /**
+               * Check for and return the first unwanted character
+               */
                function bad_chars($string,$all = True,$return = 0)
                {
                        if($all)
@@ -1006,9 +1013,9 @@
                        return $rstring;
                }
 
-               ###
-               # Match character in string using ord ().
-               ###
+               /**
+               * Match character in string using ord ().
+               */
                function ord_match($string, $charnum)
                {
                        for ($i=0;$i<strlen($string);$i++)
@@ -1023,11 +1030,10 @@
                        return False;
                }
 
-               ###
-               # Decide whether to echo or return.  Used by HTML functions
-               ###
-
-               function eor($rstring,$return)
+               /**
+               * Decide whether to echo or return.  Used by HTML functions
+               */
+               function eor($rstring, $return)
                {
                        if($return)
                        {
@@ -1036,16 +1042,16 @@
                        else
                        {
                                html_text($rstring."\n");
-                               return 0;
+                               return '';
                        }
                }
 
-               ###
-               # URL encode a string
-               # First check if its a query string, then if its just a URL, 
then just encodes it all
-               # Note: this is a hack.  It was made to work with form actions, 
form values, and links only,
-               # but should be able to handle any normal query string or URL
-               ###
+               /**
+               * URL encode a string
+               * First check if its a query string, then if its just a URL, 
then just encodes it all
+               * Note: this is a hack.  It was made to work with form actions, 
form values, and links only,
+               * but should be able to handle any normal query string or URL
+               */
 
                function string_encode($string,$return = False)
                {
@@ -1077,20 +1083,19 @@
                        return($this->eor($rstring,$return));
                }
 
-               ###
-               # HTML encode a string
-               # This should be used with anything in an HTML tag that might 
contain < or >
-               ###
-
+               /**
+               * HTML encode a string
+               * This should be used with anything in an HTML tag that might 
contain < or >
+               */
                function html_encode($string,$return)
                {
                        return($this->eor(htmlspecialchars($string),$return));
                }
 
-               #######
-               # Returns the amount of file(s) in a certain Path
-               # either recursive or non recursive
-               #######
+               /**
+               * Returns the amount of file(s) in a certain Path
+               * either recursive or non recursive
+               */
                function count_files($path,$subdirs)
                {
                        $ls_array = $GLOBALS['phpgw']->vfs->ls(array(
@@ -1106,9 +1111,9 @@
                        return (count($ls_array)-count($ls_dirs));
                }
 
-               ########
-               # Return the size of either a File or a Directory
-               ########
+               /**
+               * Return the size of either a File or a Directory
+               */
                function get_size($files,$homedir)
                {
                        if($homedir)
@@ -1137,18 +1142,18 @@
 
                function check_quota($file)
                {
-                       $homedir        = $this->get_size($this->homedir,True);
-                       $size_file      = $this->get_size(array('directory' => 
$this->path,'name' => $file),False);
+                       $homedir        = $this->get_size($this->homedir, True);
+                       $size_file      = $this->get_size(array('directory' => 
$this->path, 'name' => $file),False);
 
                        if($this->quota == -1)
                        {
-                               return True;
+                               return true;
                        }
                        elseif(($this->quota - $size_homedir - $size_file) > 0)
                        {
-                               return True;
+                               return true;
                        }
-                       return False;
+                       return false;
                }
 
                function f_execute()

Index: class.uifilemanager.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/inc/class.uifilemanager.inc.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- class.uifilemanager.inc.php 5 Nov 2005 23:44:26 -0000       1.35
+++ class.uifilemanager.inc.php 16 Aug 2006 14:20:32 -0000      1.36
@@ -8,7 +8,7 @@
        * @copyright Portions Copyright (C) 2000-2005 Free Software Foundation, 
Inc http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package filemanager
-       * @version $Id: class.uifilemanager.inc.php,v 1.35 2005/11/05 23:44:26 
ceb Exp $
+       * @version $Id: class.uifilemanager.inc.php,v 1.36 2006/08/16 14:20:32 
skwashd Exp $
        * @internal Based on phpWebhosting
        */
 
@@ -38,6 +38,7 @@
 
                var $bofilemanager;
                var $browser;
+               //TODO use the API mime-icons ... still being implemented
                var $mime_ico = array
                (
                        'application/pdf'               => 'pdf',
@@ -541,7 +542,6 @@
 
                        $file_attributes[] =  array('widget'=> array('type' => 
'plain','caption' => lang('sort by')),
                                                                                
'help' => array('widget' => array('type' => 'help','onClick' => 
$this->bofilemanager->build_help('sort_by'))));
-                       @reset($this->bofilemanager->file_attributes);
 
                        //_debug_array($this->bofilemanager->settings);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]