Hopefully I didn't screw anything up. Changed over to use GLOBALS, and alot of coding stds. Also, found a little problem with the filesize field. Trying to get the value, prior to having it filled in the database. Always returning '0'.

This commit is contained in:
skeeter 2001-12-10 04:04:56 +00:00
parent 7ff752c886
commit cce860ee66
5 changed files with 658 additions and 533 deletions

View File

@ -1,5 +1,5 @@
<?php
require (PHPGW_APP_INC . "/main.inc.php");
require (PHPGW_APP_INC . '/main.inc.php');
?>

View File

@ -1,82 +1,110 @@
<?php
function html_form_begin ($action, $method = "post", $enctype = NULL, $string = HTML_FORM_BEGIN_STRING, $return = 0)
function html_form_begin ($action, $method = 'post', $enctype = NULL, $string = HTML_FORM_BEGIN_STRING, $return = 0)
{
global $phpgw;
global $sep;
$action = string_encode ($action, 1);
$action = $sep . $action;
$action = html_link ($action, NULL, 1, 0, 1);
$action = SEP . $action;
$text = 'action="'.html_link ($action, NULL, 1, 0, 1).'"';
if ($method == NULL)
$method = "post";
$method = "method=$method";
{
$method = 'post';
}
$text .= ' method="'.$method.'"';
if ($enctype != NULL && $enctype)
$enctype = "enctype=$enctype";
$rstring = "<form action=$action $method $enctype $string>";
{
$text .= ' enctype="'.$enctype.'"';
}
$rstring = '<form '.$text.' '.$string.'>';
return (eor ($rstring, $return));
}
function html_form_input ($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = HTML_FORM_INPUT_STRING, $return = 0)
{
$text = ' ';
if ($type != NULL && $type)
{
if ($type == "checkbox")
if ($type == 'checkbox')
{
$value = string_encode ($value, 1);
}
$type = "type=$type";
$text .= 'type="'.$type.'" ';
}
if ($name != NULL && $name)
$name = "name=\"$name\"";
{
$text .= 'name="'.$name.'" ';
}
if ($value != NULL && $value)
{
$value = "value=\"$value\"";
$text .= 'value="'.$value.'" ';
}
if (is_int ($maxlength) && $maxlength >= 0)
$maxlength = "maxlength=$maxlength";
{
$text .= 'maxlength="'.$maxlength.'" ';
}
if (is_int ($size) && $size >= 0)
$size = "size=$size";
{
$text .= 'size="'.$size.'" ';
}
if ($checked != NULL && $checked)
$checked = "checked";
$rstring = "<input $type $name $value $maxlength $size $checked $string>";
{
$text .= 'checked ';
}
$rstring = '<input'.$text.$string.'>';
return (eor ($rstring, $return));
}
function html_form_textarea ($name = NULL, $rows = NULL, $cols = NULL, $value = NULL, $string = HTML_FORM_TEXTAREA_STRING, $return = 0)
{
$text =' ';
if ($name != NULL && $name)
$name = "name=\"$name\"";
{
$text .= 'name="'.$name.'" ';
}
if (is_int ($rows) && $rows >= 0)
$rows = "rows=$rows";
{
$text .= 'rows="'.$rows.'" ';
}
if (is_int ($cols) && $cols >= 0)
$cols = "cols=$cols";
$rstring = "<textarea $name $rows $cols $string>$value</textarea>";
{
$text .= 'cols="'.$cols.'" ';
}
$rstring = '<textarea'.$text.$string.'>'.$value.'</textarea>';
return (eor ($rstring, $return));
}
function html_form_select_begin ($name = NULL, $return = 0)
{
$test = ' ';
if ($name != NULL && $name)
$name = "name=$name";
$rstring = "<select $name>";
{
$text = 'name="'.$name.'" ';
}
$rstring = '<select'.$text.'>';
return (eor ($rstring, $return));
}
function html_form_select_end ($return = 0)
{
$rstring = "</select>";
$rstring = '</select>';
return (eor ($rstring, $return));
}
function html_form_option ($value = NULL, $displayed = NULL, $selected = NULL, $return = 0)
{
$text = ' ';
if ($value != NULL && $value)
$value = "value=\"$value\"";
{
$text .= ' value="'.$value.'" ';
}
if ($selected != NULL && $selected)
$selected = "selected";
$rstring = "<option $value $selected>$displayed</option>";
{
$text .= ' selected';
}
$rstring = '<option'.$text.'>'.$displayed.'</option>';
return (eor ($rstring, $return));
}
@ -89,16 +117,24 @@ function html_form_end ($return = 0)
function html_nbsp ($times = 1, $return = 0)
{
if ($times == NULL)
{
$times = 1;
}
for ($i = 0; $i != $times; $i++)
{
if ($return)
$rstring .= "&nbsp;";
{
$rstring .= '&nbsp;';
}
else
echo "&nbsp;";
{
echo '&nbsp;';
}
}
if ($return)
{
return ($rstring);
}
}
function html ($string, $times = 1, $return = 0)
@ -106,23 +142,35 @@ function html ($string, $times = 1, $return = 0)
for ($i = 0; $i != $times; $i++)
{
if ($return)
{
$rstring .= $string;
}
else
{
echo $string;
}
}
if ($return)
{
return ($rstring);
}
}
function html_break ($break, $string = "", $return = 0)
function html_break ($break, $string = '', $return = 0)
{
if ($break == 1)
$break = '<br>';
if ($break == 2)
$break = '<p>';
if ($break == 5)
$break = '<hr>';
return (eor ($break . $string, $return));
switch($break)
{
case 1:
$break_str = '<br>';
break;
case 2:
$break_str = '<p>';
break;
case 5:
$break_str = '<hr>';
break;
}
return (eor ($break_str . $string, $return));
}
function html_page_begin ($title = NULL, $return = 0)
@ -133,71 +181,91 @@ function html_page_begin ($title = NULL, $return = 0)
function html_page_body_begin ($bgcolor = HTML_PAGE_BODY_COLOR, $background = NULL, $text = NULL, $link = NULL, $vlink = NULL, $alink = NULL, $string = HTML_PAGE_BODY_STRING, $return = 0)
{
$text_out = ' ';
if ($bgcolor != NULL && $bgcolor)
$bgcolor = "bgcolor=$bgcolor";
{
$text_out .= 'bgcolor="'.$bgcolor.'" ';
}
if ($background != NULL && $background)
$background = "background=$background";
{
$text_out .= 'background="'.$background.'" ';
}
if ($text != NULL && $text)
$text = "text=$text";
{
$text_out .= 'text="'.$text.'" ';
}
if ($link != NULL && $link)
$link = "link=$link";
{
$text_out .= 'link="'.$link.'" ';
}
if ($vlink != NULL && $vlink)
$vlink = "vlink=$vlink";
{
$text_out .= 'vlink="'.$vlink.'" ';
}
if ($alink != NULL && $alink)
$alink = "alink=$alink";
// $rstring = "<body $bgcolor $background $text $link $vlink $alink $string>";
{
$text_out .= 'alink="'.$alink.'" ';
}
// $rstring = '<body'.$text_out.$string.'>';
return (eor ($rstring, $return));
}
function html_page_body_end ($return = 0)
{
// $rstring = "</body>";
// $rstring = '</body>';
return (eor ($rstring, $return));
}
function html_page_end ($return = 0)
{
// $rstring = "</html>";
// $rstring = '</html>';
return (eor ($rstring, $return));
}
function html_page_close ()
{
global $phpgw;
// html_page_body_end ();
// html_page_end ();
$phpgw->common->phpgw_footer ();
$phpgw->common->phpgw_exit ();
$GLOBALS['phpgw']->common->phpgw_footer ();
$GLOBALS['phpgw']->common->phpgw_exit ();
}
function html_text_bold ($text = NULL, $return = 0, $lang = 0)
{
if ($lang)
{
$text = translate ($text);
$rstring = "<b>$text</b>";
}
$rstring = '<b>'.$text.'</b>';
return (eor ($rstring, $return));
}
function html_text_underline ($text = NULL, $return = 0, $lang = 0)
{
if ($lang)
{
$text = translate ($text);
$rstring = "<u>$text</u>";
}
$rstring = '<u>'.$text.'</u>';
return (eor ($rstring, $return));
}
function html_text_italic ($text = NULL, $return = 0, $lang = 0)
{
if ($lang)
{
$text = translate ($text);
$rstring = "<i>$text</i>";
}
$rstring = '<i>'.$text.'</i>';
return (eor ($rstring, $return));
}
function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0)
{
if ($lang)
{
$text = translate ($text);
$rstring .= html_break (1, NULL, $return);
}
$rstring = html_break (1, NULL, $return);
$rstring .= html_text_bold ($text, $return);
$rstring .= html_nbsp (3, $return);
if ($size != NULL && $size >= 0)
@ -206,24 +274,36 @@ function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0)
$rstring = html_encode ($rstring, 1);
if ($return)
{
return ($rstring);
}
}
function html_text_summary_error ($text = NULL, $text2 = NULL, $size = NULL, $return = 0, $lang = 0)
{
if ($lang)
{
$text = translate ($lang);
$rstring .= html_text_error ($text, 1, $return);
}
$rstring = html_text_error ($text, 1, $return);
if (($text2 != NULL && $text2) || ($size != NULL && $size))
{
$rstring .= html_nbsp (3, $return);
}
if ($text2 != NULL && $text2)
{
$rstring .= html_text_error ($text2, NULL, $return);
}
if ($size != NULL && $size >= 0)
{
$rstring .= borkb ($size, 1, $return);
}
if ($return)
{
return ($rstring);
}
}
function html_font_set ($size = NULL, $color = NULL, $family = NULL, $return = 0)
@ -272,10 +352,6 @@ function html_page_error ($errorwas = NULL, $title = "Error", $return = 0)
function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linkonly = 0, $target = NULL)
{
global $phpgw;
global $sep;
global $appname;
if ($encode)
$href = string_encode ($href, 1);
@ -288,11 +364,11 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko
/* Auto-detect and don't disturb absolute links */
if (!preg_match ("|^http(.{0,1})://|", $href))
{
$href = $sep . $href;
$href = SEP . $href;
/* $phpgw->link requires that the extra vars be passed separately */
$link_parts = explode ("?", $href, 2);
$address = $phpgw->link ($link_parts[0], $link_parts[1]);
$address = $GLOBALS['phpgw']->link ($link_parts[0], $link_parts[1]);
}
else
{
@ -307,9 +383,11 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko
else
{
if ($target)
$target = "target=$target";
{
$target = 'target='.$target;
}
$rstring = "<a href=$address $target>$text</a>";
$rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>';
}
return (eor ($rstring, $return));
@ -317,12 +395,9 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko
function html_link_back ($return = 0)
{
global $hostname;
global $path;
global $groupinfo;
global $appname;
$rstring .= html_link ("$appname/index.php?path=$path", HTML_TEXT_NAVIGATION_BACK_TO_USER, 1);
$rstring .= html_link ($GLOBALS['appname'].'/index.php?path='.$path, HTML_TEXT_NAVIGATION_BACK_TO_USER, 1);
return (eor ($rstring, $return));
}

View File

@ -2,48 +2,48 @@
error_reporting (4);
if (@!$phpgw->vfs)
if (@!is_object($GLOBALS['phpgw']->vfs))
{
$phpgw->vfs = CreateObject ('phpgwapi.vfs');
$GLOBALS['phpgw']->vfs = CreateObject ('phpgwapi.vfs');
}
### Start Configuration Options ###
### These are automatically set in phpGW - do not edit ###
$sep = SEP;
$rootdir = $phpgw->vfs->basedir;
$fakebase = $phpgw->vfs->fakebase;
$appname = $phpgw_info["flags"]["currentapp"];
$settings = $phpgw_info["user"]["preferences"][$appname];
$GLOBALS['rootdir'] = $GLOBALS['phpgw']->vfs->basedir;
$GLOBALS['fakebase'] = $GLOBALS['phpgw']->vfs->fakebase;
$GLOBALS['appname'] = $GLOBALS['phpgw_info']['flags']['currentapp'];
$GLOBALS['settings'] = $GLOBALS['phpgw_info']['user']['preferences'][$appname];
if (stristr ($rootdir, PHPGW_SERVER_ROOT))
if (stristr ($GLOBALS['rootdir'], PHPGW_SERVER_ROOT))
{
$filesdir = substr ($rootdir, strlen (PHPGW_SERVER_ROOT));
$GLOBALS['filesdir'] = substr ($GLOBALS['rootdir'], strlen (PHPGW_SERVER_ROOT));
}
else
{
unset ($filesdir);
unset ($GLOBALS['filesdir']);
}
$hostname = $phpgw_info["server"]["webserver_url"] . $filesdir;
$GLOBALS['hostname'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $GLOBALS['filesdir'];
###
# Note that $userinfo["username"] is actually the id number, not the login name
###
$userinfo["username"] = $phpgw_info["user"]["account_id"];
$userinfo["account_lid"] = $phpgw->accounts->id2name ($userinfo["username"]);
$userinfo["hdspace"] = 10000000000;
$homedir = "$fakebase/$userinfo[account_lid]";
$GLOBALS['userinfo']['username'] = $GLOBALS['phpgw_info']['user']['account_id'];
$GLOBALS['userinfo']['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['username']);
$GLOBALS['userinfo']['hdspace'] = 10000000000;
$GLOBALS['homedir'] = $GLOBALS['fakebase'].'/'.$GLOBALS['userinfo']['account_lid'];
### End Configuration Options ###
if (!defined ("NULL"))
if (!defined ('NULL'))
{
define ("NULL", "");
define ('NULL', '');
}
require (PHPGW_APP_INC . "/db.inc.php");
require (PHPGW_APP_INC . '/db.inc.php');
/* Set up any initial db settings */
db_init ();
@ -54,27 +54,40 @@ db_init ();
/* We have to define these by hand in phpGW, or rely on it's templates */
define ('HTML_TABLE_FILES_HEADER_BG_COLOR', "");
define ('HTML_TABLE_FILES_HEADER_TEXT_COLOR', "maroon");
define ('HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR', "");
define ('HTML_TABLE_FILES_COLUMN_HEADER_TEXT_COLOR', "maroon");
define ('HTML_TABLE_FILES_BG_COLOR', "");
define ('HTML_TABLE_FILES_TEXT_COLOR', "maroon");
define ('HTML_TEXT_ERROR_COLOR', "red");
define ('HTML_TEXT_NAVIGATION_BACK_TO_USER', "Back to file manager");
define ('HTML_TABLE_FILES_HEADER_BG_COLOR', '');
define ('HTML_TABLE_FILES_HEADER_TEXT_COLOR', 'maroon');
define ('HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR', '');
define ('HTML_TABLE_FILES_COLUMN_HEADER_TEXT_COLOR', 'maroon');
define ('HTML_TABLE_FILES_BG_COLOR', '');
define ('HTML_TABLE_FILES_TEXT_COLOR', 'maroon');
define ('HTML_TEXT_ERROR_COLOR', 'red');
define ('HTML_TEXT_NAVIGATION_BACK_TO_USER', 'Back to file manager');
###
# Need to include this here so they recognize the settings
###
require (PHPGW_APP_INC . "/html.inc.php");
require (PHPGW_APP_INC . '/html.inc.php');
###
# Define the list of file attributes. Format is "internal_name" => "Displayed name"
# This is used both by internally and externally for things like preferences
###
$file_attributes = array ("name" => "Filename", "mime_type" => "MIME Type", "size" => "Size", "created" => "Created", "modified" => "Modified", "owner" => "Owner", "createdby_id" => "Created by", "modifiedby_id" => "Created by", "modifiedby_id" => "Modified by", "app" => "Application", "comment" => "Comment", "version" => "Version");
$file_attributes = Array(
'name' => 'Filename',
'mime_type' => 'MIME Type',
'size' => 'Size',
'created' => 'Created',
'modified' => 'Modified',
'owner' => 'Owner',
'createdby_id' => 'Created by',
'modifiedby_id' => 'Created by',
'modifiedby_id' => 'Modified by',
'app' => 'Application',
'comment' => 'Comment',
'version' => 'Version'
);
###
# Calculate and display B or KB
@ -89,14 +102,14 @@ function borkb ($size, $enclosed = NULL, $return = 0)
if ($enclosed)
{
$left = "(";
$right = ")";
$left = '(';
$right = ')';
}
if ($size < 1024)
$rstring = $left . $size . "B" . $right;
$rstring = $left . $size . 'B' . $right;
else
$rstring = $left . round($size/1024) . "KB" . $right;
$rstring = $left . round($size/1024) . 'KB' . $right;
return (eor ($rstring, $return));
}
@ -164,24 +177,22 @@ function eor ($rstring, $return)
function string_encode ($string, $return = False)
{
global $hostname;
if (preg_match ("/=(.*)(&|$)/U", $string))
{
$rstring = preg_replace ("/=(.*)(&|$)/Ue", "'=' . rawurlencode (base64_encode ('\\1')) . '\\2'", $string);
}
elseif (ereg ("^$hostname", $string))
elseif (ereg ('^'.$GLOBALS['hostname'], $string))
{
$rstring = ereg_replace ("^$hostname/", "", $string);
$rstring = ereg_replace ('^'.$GLOBALS['hostname'].'/', '', $string);
$rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring);
$rstring = "$hostname/$rstring";
$rstring = $GLOBALS['hostname'].'/'.$rstring;
}
else
{
$rstring = rawurlencode ($string);
/* Terrible hack, decodes all /'s back to normal */
$rstring = preg_replace ("/%2F/", "/", $rstring);
$rstring = preg_replace ("/%2F/", '/', $rstring);
}
return (eor ($rstring, $return));
@ -208,13 +219,10 @@ function html_encode ($string, $return)
function translate ($text)
{
global $phpgw;
return ($phpgw->lang ($text));
return ($GLOBALS['phpgw']->lang($text));
}
$help_info = array
(
$help_info = Array(
array ("up", "The Up button takes you to the directory above the current directory. For example, if you're in /home/jdoe/mydir, the Up button would take you to /home/jdoe."),
array ("directory_name", "The name of the directory you're currently in."),
array ("home", "The Home button takes you to your personal home directory."),

File diff suppressed because it is too large Load Diff

View File

@ -91,6 +91,7 @@
var $override_acl;
var $linked_dirs;
var $meta_types;
var $now;
/*!
@function vfs
@ -103,12 +104,15 @@
$this->working_id = $GLOBALS['phpgw_info']['user']['account_id'];
$this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id);
$this->now = date ('Y-m-d');
$this->override_acl = 0;
// $this->override_acl = 0;
$this->override_acl = 1;
/*
File/dir attributes, each corresponding to a database field. Useful for use in loops
If an attribute was added to the table, add it here and possibly add it to
set_attributes ()
set_attributes now uses this array(). 07-Dec-01 skeeter
*/
$this->attributes = array(
@ -355,7 +359,7 @@
{
return False;
}
$value = "Copied $state_one to $state_two";
$value = 'Copied '.$state_one.' to '.$state_two;
$incversion = False;
break;
case VFS_OPERATION_MOVED:
@ -367,7 +371,7 @@
{
return False;
}
$value = "Moved $state_one to $state_two";
$value = 'Moved '.$state_one.' to '.$state_two;
$incversion = False;
break;
case VFS_OPERATION_DELETED:
@ -480,14 +484,14 @@
We copy it going the other way as well, so both files show the operation.
The code is a bad hack to prevent recursion. Ideally it would use VFS_OPERATION_COPIED
*/
$this->add_journal ($state_two, array (RELATIVE_NONE), "Copied $state_one to $state_two", NULL, NULL, False);
$this->add_journal ($state_two, array (RELATIVE_NONE), 'Copied '.$state_one.' to '.$state_two, NULL, NULL, False);
}
if ($operation == VFS_OPERATION_MOVED)
{
$state_one_path_parts = $this->path_parts ($state_one, array (RELATIVE_NONE));
$query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='journal-deleted' WHERE directory='$state_one_path_parts->fake_leading_dirs_clean' AND name='$state_one_path_parts->fake_name_clean' AND mime_type='journal'");
$query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='journal-deleted' WHERE directory='".$state_one_path_parts->fake_leading_dirs_clean."' AND name='".$state_one_path_parts->fake_name_clean."' AND mime_type='journal'");
/*
We create the file in addition to logging the MOVED operation. This is an
@ -532,7 +536,7 @@
$p = $this->path_parts ($string, array ($relatives[0]));
$sql = "DELETE FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'";
$sql = "DELETE FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'";
if (!$deleteall)
{
@ -582,7 +586,7 @@
return False;
}
$sql = "SELECT * FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'";
$sql = "SELECT * FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'";
if ($type == 1)
{
@ -896,7 +900,7 @@
$basedir = ereg_replace ($sep . $sep, $sep, $basedir);
}
$basedir = ereg_replace ("$sep$", '', $basedir);
$basedir = ereg_replace ($sep.'$', '', $basedir);
return $basedir;
}
@ -923,9 +927,6 @@
return True;
}
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$account_lid = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['phpgw_info']['user']['account_id']);
$p = $this->path_parts ($file, array ($relatives[0]));
/* Temporary, until we get symlink type files set up */
@ -956,7 +957,7 @@
}
/* Read access is always allowed here, but nothing else is */
if ($file == "/" || $file == $this->fakebase)
if ($file == '/' || $file == $this->fakebase)
{
if ($operation == PHPGW_ACL_READ)
{
@ -972,22 +973,22 @@
We don't use ls () to get owner_id as we normally would,
because ls () calls acl_check (), which would create an infinite loop
*/
$query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='$p2->fake_leading_dirs_clean' AND name='$p2->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__);
$query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='".$p2->fake_leading_dirs_clean."' AND name='".$p2->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__);
$GLOBALS['phpgw']->db->next_record ();
$group_id = $GLOBALS['phpgw']->db->Record['owner_id'];
/* They always have access to their own files */
if ($group_id == $account_id)
if ($group_id == $GLOBALS['phpgw_info']['user']['account_id'])
{
return True;
}
/* Check if they're in the group. If so, they have access */
$memberships = $GLOBALS['phpgw']->accounts->membership ($account_id);
$memberships = $GLOBALS['phpgw']->accounts->membership ($GLOBALS['phpgw_info']['user']['account_id']);
if (is_array ($memberships))
{
reset ($memberships);
@reset ($memberships);
while (list ($num, $group_array) = @each ($memberships))
{
@ -1060,7 +1061,7 @@
}
else
{
$currentdir = $GLOBALS['phpgw']->common->appsession ();
$currentdir = $GLOBALS['phpgw']->session->appsession('vfs','');
$basedir = $this->getabsolutepath ($currentdir . $sep . $target, array ($relatives[0]), True);
}
}
@ -1069,7 +1070,7 @@
$basedir = $this->getabsolutepath ($target, array ($relatives[0]));
}
$GLOBALS['phpgw']->common->appsession ($basedir);
$GLOBALS['phpgw']->session->appsession('vfs','',$basedir);
return True;
}
@ -1082,7 +1083,7 @@
*/
function pwd ($full = True)
{
$currentdir = $GLOBALS['phpgw']->common->appsession ();
$currentdir = $GLOBALS['phpgw']->session->appsession('vfs','');
if (!$full)
{
@ -1139,10 +1140,11 @@
@param $contents contents
@result Boolean True/False
*/
function write ($file, $relatives = '', $contents)
function write ($file, $relatives = '', $contents = '')
{
if (!is_array ($relatives))
{
settype($relatives,'array');
$relatives = array (RELATIVE_CURRENT);
}
@ -1171,12 +1173,12 @@
*/
$this->touch ($p->fake_full_path, array ($p->mask));
if ($fp = fopen ($p->real_full_path, "wb"))
if ($fp = fopen ($p->real_full_path, 'wb'))
{
fwrite ($fp, $contents, strlen ($contents));
fclose ($fp);
$this->set_attributes ($p->fake_full_path, array ($p->mask), array ('size' => $this->get_size ($p->real_full_path, array (RELATIVE_NONE|VFS_REAL))));
$this->set_attributes ($p->fake_full_path, array ($p->mask), array ('size' => filesize($p->real_full_path)));
if ($journal_operation)
{
@ -1205,9 +1207,6 @@
$relatives = array (RELATIVE_CURRENT);
}
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
$p = $this->path_parts ($file, array ($relatives[0]));
umask (000);
@ -1224,7 +1223,7 @@
}
/* We, however, have to decide this ourselves */
if ($this->file_exists ($p->fake_full_path, array ($p->mask)))
if ($this->file_exists($p->fake_full_path, array ($p->mask)))
{
if (!$this->acl_check ($p->fake_full_path, array ($p->mask), PHPGW_ACL_EDIT))
{
@ -1235,7 +1234,7 @@
$p->fake_full_path,
array ($p->mask),
array (
'modifiedby_id' => $account_id,
'modifiedby_id' => $GLOBALS['phpgw_info']['user']['account_id'],
'modified' => $this->now
)
);
@ -1247,17 +1246,18 @@
return False;
}
$query = $GLOBALS['phpgw']->db->query ("INSERT INTO phpgw_vfs (owner_id, directory, name) VALUES ($this->working_id, '$p->fake_leading_dirs_clean', '$p->fake_name_clean')", __LINE__, __FILE__);
$this->set_attributes(
$p->fake_full_path,
array ($p->mask),
array (
'createdby_id' => $account_id,
'owner_id' => $this->working_id,
'directory' => $p->fake_leading_dirs_clean,
'name' => $p->fake_name_clean,
'createdby_id' => $GLOBALS['phpgw_info']['user']['account_id'],
'created' => $this->now,
'size' => 0,
'deleteable' => 'Y',
'app' => $currentapp
'app' => $GLOBALS['phpgw_info']['flags']['currentapp']
)
);
$this->correct_attributes ($p->fake_full_path, array ($p->mask));
@ -1703,12 +1703,13 @@
if (!$this->file_exists ($p->fake_full_path, array ($p->mask)))
{
$query = $GLOBALS['phpgw']->db->query ("INSERT INTO phpgw_vfs (owner_id, name, directory) VALUES ($this->working_id, '$p->fake_name_clean', '$p->fake_leading_dirs_clean')", __LINE__, __FILE__);
$this->set_attributes(
$p->fake_full_path,
array ($p->mask),
array (
'owner_id' => $this->working_id,
'name' => $p->fake_name_clean,
'directory' => $p->fake_leading_dirs_clean,
'createdby_id' => $account_id,
'size' => 4096,
'mime_type' => 'Directory',
@ -1804,6 +1805,8 @@
link_directory
link_name
version
name
directory
*/
function set_attributes ($file, $relatives = '', $attributes = '')
{
@ -1830,63 +1833,78 @@
if (!$this->file_exists ($file, array ($relatives[0])))
{
return False;
$exists = False;
}
else
{
$exists = True;
}
/*
All this voodoo just decides which attributes to update
depending on if the attribute was supplied in the $attributes array
*/
$ls_array = $this->ls ($p->fake_full_path, array ($p->mask), False, False, True);
$record = $ls_array[0];
$attribute_names = array(
'owner_id', 'createdby_id', 'modifiedby_id',
'created', 'modified', 'size', 'mime_type',
'deleteable', 'comment', 'app',
'link_directory', 'link_name', 'version'
);
$sql = 'UPDATE phpgw_vfs SET ';
$change_attributes = 0;
while (list ($num, $attribute) = each ($attribute_names))
$sql_array = Array();
$sql_fields = '';
$sql_vals = '';
@reset($this->attributes);
while (list ($num, $attribute) = each ($this->attributes))
{
if (isset ($attributes[$attribute]))
if (isset($attributes[$attribute]))
{
$$attribute = $attributes[$attribute];
/*
Indicate that the EDITED_COMMENT operation needs to be journaled,
but only if the comment changed
*/
if ($attribute == 'comment' && $attributes[$attribute] != $record[$attribute])
if($exists)
{
$edited_comment = 1;
if($sql_vals)
{
$sql_vals .= ', ';
}
$sql_vals .= "$attribute='".$this->db_clean($attributes[$attribute])."'";
}
$$attribute = $this->db_clean ($$attribute);
if ($change_attributes > 0)
else
{
$sql .= ', ';
if($sql_fields)
{
$sql_fields .= ',';
}
if($sql_vals)
{
$sql_vals .= ',';
}
$sql_fields .= $attribute;
$sql_vals .= "'".$this->db_clean($attributes[$attribute])."'";
}
$sql .= "$attribute='" . $$attribute . "'";
$change_attributes++;
}
}
$sql .= " WHERE file_id='$record[file_id]'";
$sql .= $this->extra_sql (VFS_SQL_UPDATE);
$query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__);
if($exists)
{
if($sql_vals)
{
$sql = "UPDATE phpgw_vfs SET $sql_vals WHERE file_id='".$record['file_id']."'".$this->extra_sql(VFS_SQL_UPDATE);
}
else
{
$sql = '';
}
}
else
{
$sql = "INSERT INTO phpgw_vfs($sql_fields) VALUES ($sql_vals)";
}
$query = ($sql?$GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__):False);
if ($query)
{
if ($edited_comment)
/*
Indicate that the EDITED_COMMENT operation needs to be journaled,
but only if the comment changed
*/
if (isset($attributes['comment']) && $attributes['comment'] != $record['comment'])
{
$this->add_journal ($p->fake_full_path, array ($p->mask), VFS_OPERATION_EDITED_COMMENT);
}
@ -1919,19 +1937,16 @@
{
$ls_array = $this->ls ($p->fake_leading_dirs, array ($p->mask), False, False, True);
$this->set_attributes ($p->fake_full_path, array ($p->mask), array ('owner_id' => $ls_array[0]['owner_id']));
return True;
}
elseif (preg_match ("+^$this->fakebase\/(.*)$+U", $p->fake_full_path, $matches))
{
$this->set_attributes ($p->fake_full_path, array ($p->mask), array ("owner_id" => $GLOBALS['phpgw']->accounts->name2id ($matches[1])));
$this->set_attributes ($p->fake_full_path, array ($p->mask), array ('owner_id' => $GLOBALS['phpgw']->accounts->name2id ($matches[1])));
return True;
}
else
{
$this->set_attributes ($p->fake_full_name, array ($p->mask), array ('owner_id' => 0));
return True;
}
}
@ -1999,14 +2014,12 @@
if ($p->outside)
{
$rr = file_exists ($p->real_full_path);
return $rr;
return file_exists ($p->real_full_path);
}
$query = $GLOBALS['phpgw']->db->query ("SELECT name FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__);
$query = $GLOBALS['phpgw']->db->query ("SELECT name FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__);
if ($GLOBALS['phpgw']->db->next_record ())
if ($GLOBALS['phpgw']->db->num_rows())
{
return True;
}
@ -2140,10 +2153,10 @@
$sql .= ', ';
}
$sql .= "$attribute";
$sql .= $attribute;
}
$sql .= " FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'";
$sql .= " FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'";
$sql .= $this->extra_sql (VFS_SQL_SELECT);
@ -2200,19 +2213,19 @@
$sql .= ", ";
}
$sql .= "$attribute";
$sql .= $attribute;
}
$dir_clean = $this->db_clean ($dir);
$sql .= " FROM phpgw_vfs WHERE directory LIKE '$dir_clean%'";
$sql .= " FROM phpgw_vfs WHERE directory LIKE '".$dir_clean."%'";
$sql .= $this->extra_sql (VFS_SQL_SELECT);
if ($mime_type)
{
$sql .= " AND mime_type='$mime_type'";
$sql .= " AND mime_type='".$mime_type."'";
}
$sql .= " ORDER BY $orderby";
$sql .= ' ORDER BY '.$orderby;
$query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__);
@ -2427,12 +2440,10 @@
$mime_type = 'Directory';
}
$size = filesize ($p->real_full_path);
$rarray = array(
'directory' => $p->fake_leading_dirs,
'name' => $p->fake_name,
'size' => $size,
'size' => filesize ($p->real_full_path),
'mime_type' => $mime_type
);