[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] filemanager/inc class.uifilemanager.inc.php, 1.25 cla
From: |
ceb |
Subject: |
[Phpgroupware-cvs] filemanager/inc class.uifilemanager.inc.php, 1.25 class.bofilemanager.inc.php, 1.19 |
Date: |
Thu, 10 Feb 2005 17:19:00 +0100 |
Update of filemanager/inc
Modified Files:
Branch: MAIN
class.uifilemanager.inc.php lines: +67 -91
class.bofilemanager.inc.php lines: +77 -56
Log Message:
quota
====================================================
Index: filemanager/inc/class.uifilemanager.inc.php
diff -u filemanager/inc/class.uifilemanager.inc.php:1.24
filemanager/inc/class.uifilemanager.inc.php:1.25
--- filemanager/inc/class.uifilemanager.inc.php:1.24 Tue Feb 8 00:06:31 2005
+++ filemanager/inc/class.uifilemanager.inc.php Thu Feb 10 16:19:46 2005
@@ -234,6 +234,13 @@
$link_data['rename_files'] = True;
$edit =
$this->bofilemanager->get_fileman();
$this->bofilemanager->save_sessiondata($edit,'changes');
+
+
if(!$this->bofilemanager->settings['name'])
+ {
+
$GLOBALS['phpgw']->preferences->read_repository();
+
$GLOBALS['phpgw']->preferences->change('filemanager','name','name');
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
break;
case 'edit_comments':
$link_data['edit_comments'] = True;
@@ -613,8 +620,6 @@
for($i=0;$i<count($files_array);$i++)
{
$file = $files_array[$i];
- $usage += $file['size'];
-
$file_output[$i]['checkbox'] = array('widget'
=> array( 'type' => 'checkbox','name' => 'fileman[]','value' => $file['name'],
'checked' =>
($this->bofilemanager->changes[$file['name']] == $file['name']?True:False)));
@reset($this->bofilemanager->file_attributes);
@@ -691,6 +696,14 @@
case 'size':
$file_output[$i][$internal] = $this->bofilemanager->borkb($file[$internal]);
break;
+ case 'version':
+
$file_output[$i][$internal] = array('widget' => array('type' => 'link',
+
'onClick' => "open_popup('" .
$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=filemanager.uifilemanager.history&file='
+
.
urlencode($file['name'])) . "','600','600');",
+
'href' => '#',
+
'caption' => $file[$internal]));
+ break;
default:
$file_output[$i][$internal] = $file[$internal];
}
@@ -698,19 +711,10 @@
}
}
- /* if
($quota == -1 || $quota == 0)
- {
-
html_text ('',NULL,1);
- }
- else
- {
-
html_text_bold (lang('Unused space').': ');
-
html_text (borkb ($quota - get_size($GLOBALS['homedir'],True), NULL, 1));
- }
-
$i = count_files($GLOBALS['homedir'],True);
-
-
html_break (2);
-
html_text_bold (lang('Total Files').': '); */
+ if ($this->bofilemanager->quota != -1)
+ {
+ $free =
$this->bofilemanager->borkb($this->bofilemanager->quota -
$this->bofilemanager->get_size($this->homedir,True));
+ }
$data = array
(
@@ -722,7 +726,8 @@
'lang_unused' => lang('unused
space'),
'usage' =>
$this->bofilemanager->borkb($this->bofilemanager->get_size($this->homedir,True)),
'files_total' =>
$this->bofilemanager->count_files($this->homedir,True),
- 'lang_files_total' => lang('files
total')
+ 'lang_files_total' => lang('files
total'),
+ 'unused' => $free
),
'files' => array
(
@@ -903,95 +908,66 @@
);
}
-
+
function history()
{
- $this->load_header();
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
$file =
$this->bofilemanager->path.$this->bofilemanager->dispsep.$this->bofilemanager->file;
- if($GLOBALS['phpgw']->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $col_headers = Array(
- 'Date' => 'created',
- 'Version' => 'version',
- 'Action Performed by' => 'owner_id',
- 'Operation' => 'comment'
- );
- $p =
CreateObject('phpgwapi.Template',$this->template_dir);
- $p->set_unknowns('remove');
- $p->set_file(
- Array(
- '_history' => 'history.tpl'
- )
- );
- $p->set_block('_history','history','history');
-
$p->set_block('_history','column_headers','column_headers');
-
$p->set_block('_history','column_rows','column_rows');
-
- $var = Array(
- 'path' => $this->link(
- Array(
- 'menuaction'
=> $this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.index',
- 'path'
=> urlencode($this->bofilemanager->path)
- ),
-
$this->bofilemanager->path
- ),
- 'filename' => $this->link(
- Array(
- 'menuaction'
=> $this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.view',
- 'path'
=> urlencode($this->bofilemanager->path),
- 'file'
=> urlencode($this->bofilemanager->file)
- ),
-
$this->bofilemanager->file
- )
+ if($GLOBALS['phpgw']->vfs->file_exists(array('string'
=> $file,'relatives' => Array(RELATIVE_NONE))))
+ {
+ $col_headers = array
+ (
+ lang('date')
=> 'created',
+ lang('version')
=> 'version',
+ lang('performed by') =>
'owner_id',
+ lang('operation')
=> 'comment'
);
- $p->set_var($var);
- $GLOBALS['tr_color'] =
$GLOBALS['phpgw_info']['theme']['row_off'];
- $var = Array(
- 'td_extras' => ''
- );
- @reset($col_headers);
- while(list($label,$field)= each($col_headers))
+ foreach($col_headers as $label => $field)
{
- $var['column_header'] =
'<b>'.$label.'</b>';
- $this->set_col_headers($p,$var);
+ $header[] = array('widget' =>
array('type' => 'label','caption' => $label));
}
- $p->set_var('tr_extras','
bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
- $p->parse('col_row','column_rows',True);
- $p->set_var('col_headers','');
+ $table_head = array('table_col' => $header);
- $journal_array =
$GLOBALS['phpgw']->vfs->get_journal(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- ));
- while(list($num,$journal_entry) =
each($journal_array))
+ $data = array();
+ $journal_array =
$GLOBALS['phpgw']->vfs->get_journal(array('string' => $file,'relatives' =>
Array(RELATIVE_NONE)));
+
+ if(is_array($journal_array))
{
- @reset($col_headers);
- while(list($label,$field)=
each($col_headers))
+ foreach($journal_array as $num =>
$journal_entry)
{
- switch($field)
+ $var = array();
+ @reset($col_headers);
+ foreach($col_headers as $label
=> $field)
{
- case 'owner_id':
-
$var['column_header'] = '<font
size="-2">'.$GLOBALS['phpgw']->accounts->id2name($journal_entry[$field]).'</font>';
- break;
- case 'created':
-
$var['column_header'] = '<font
size="-2">'.$this->bofilemanager->convert_date($journal_entry[$field]).'</font>';
- break;
- default:
-
$var['column_header'] = '<font size="-2">'.$journal_entry[$field].'</font>';
- break;
+ switch($field)
+ {
+ case 'owner_id':
+ $var[]
= array('widget' => array('type' => 'label','caption' =>
$GLOBALS['phpgw']->common->grab_owner_name($journal_entry[$field])));
+ break;
+ case 'created':
+ $var[]
= array('widget' => array('type' => 'label','caption' =>
$this->bofilemanager->convert_date($journal_entry[$field])));
+ break;
+ default:
+ $var[]
= array('widget' => array('type' => 'label','caption' =>
$journal_entry[$field]));
+ break;
+ }
}
- $this->set_col_headers($p,$var);
+ $table_rows[] =
array('table_col' => $var);
}
- $p->set_var('tr_extras','
bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
- $p->parse('col_row','column_rows',True);
- $p->set_var('col_headers','');
}
- $p->pfp('output','history');
+
+ $data = array
+ (
+ 'error' => '',
+ 'action_url' => '#',
//$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.preferences'),
+ 'title' =>
lang('history for %1',$file),
+ 'table' =>
array('width' => '100%','table_head' => $table_head ,'table_row' =>
$table_rows,'table_footer' => $table_footer),
+ 'lang_close' => lang('close window')
+ );
+ //_debug_array($data);
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('history' => $data));
}
}
====================================================
Index: filemanager/inc/class.bofilemanager.inc.php
diff -u filemanager/inc/class.bofilemanager.inc.php:1.18
filemanager/inc/class.bofilemanager.inc.php:1.19
--- filemanager/inc/class.bofilemanager.inc.php:1.18 Tue Feb 8 00:06:31 2005
+++ filemanager/inc/class.bofilemanager.inc.php Thu Feb 10 16:19:46 2005
@@ -64,6 +64,7 @@
var $memberships = array();
var $now;
var $matches;
+ var $quota = 0;
// var $debug = True;
var $debug = False;
@@ -317,6 +318,8 @@
{
$this->access_add = True;
}
+
+ $this->quota =
($GLOBALS['phpgw']->accounts->data['quota'] ==
-1?-1:$GLOBALS['phpgw']->accounts->data['quota']*1024*1024);
}
function initialize_vars($name)
@@ -547,7 +550,7 @@
}
if(!is_array($this->files_array))
{
- $this->files_array = Array();
+ $this->files_array = array();
}
return $this->files_array;
}
@@ -671,7 +674,11 @@
{
if($this->fileman[$i])
{
- if($GLOBALS['phpgw']->vfs->cp(array(
+
if(!$this->get_quota($this->fileman[$i]))
+ {
+ $result[] = lang('Could not
copy %1 to %2 quota
exceeded',$this->todir.SEP.$this->fileman[$i],$this->path.SEP.$this->fileman[$i]);
+ }
+ elseif($GLOBALS['phpgw']->vfs->cp(array(
'from' =>
$this->path.SEP.$this->fileman[$i],
'to' =>
$this->todir.SEP.$this->fileman[$i],
'relatives' =>
array(RELATIVE_NONE,RELATIVE_NONE))))
@@ -680,7 +687,7 @@
}
else
{
- $result[] = lang('could not
copy %1 to %2',
$this->path.SEP.$this->fileman[$i],$this->todir.SEP.$this->fileman[$i]);
+ $result[] = lang('could not
copy %1 to %2',
$this->todir.SEP.$this->fileman[$i],$this->path.SEP.$this->fileman[$i]);
}
}
}
@@ -794,7 +801,7 @@
{
if($badchar =
$this->bad_chars($this->createfile,True,True))
{
- $result[] = lang('file names cannot
contain %1', $badchar);
+ $result[] = lang('file names cannot
contain %1, file %2', $badchar,$this->path.SEP.$this->createfile);
return $result;
}
if($GLOBALS['phpgw']->vfs->file_exists(array(
@@ -822,46 +829,47 @@
{
for ($i = 0;$i<$this->show_upload_boxes;++$i)
{
- if ($badchar = $this->bad_chars
($this->upload_file['name'][$i], True, True))
+
if(!$this->check_quota($this->upload_file['size'][$i]))
{
- $result[] = lang('file names cannot
contain %1',$badchar);
- //echo $GLOBALS['phpgw']->common->error_list (array
(html_encode ('File names cannot contain "'.$badchar.'"', 1)));
- continue;
+ $result[] = lang('could not upload %1
quota exceeded',$this->upload_file['name'][$i]);
}
+ elseif($badchar =
$this->bad_chars($this->upload_file['name'][$i],True,True))
+ {
+ $result[] = lang('file names cannot
contain %1, file %2',$badchar,$this->upload_file['name'][$i]);
+ //echo $GLOBALS['phpgw']->common->error_list
(array (html_encode ('File names cannot contain "'.$badchar.'"', 1)));
+ }
+ 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 (
+ $ls_array =
$GLOBALS['phpgw']->vfs->ls(array(
'string' =>
$this->upload_file['name'][$i],
'relatives' => array
(RELATIVE_ALL),
'checksubdirs' => False,
- 'nofiles' => True
- )
- );
-
- $fileinfo = $ls_array[0];
+ 'nofiles' => True));
+
+ $fileinfo = $ls_array[0];
- if ($fileinfo['name'])
- {
- if ($fileinfo['mime_type'] ==
'Directory')
+ if ($fileinfo['name'])
{
- $result[] = lang('cannot
replace %1 because it is a directory', $fileinfo['name']);
- continue;
+ if ($fileinfo['mime_type'] ==
'Directory')
+ {
+ $result[] =
lang('cannot replace %1 because it is a directory', $fileinfo['name']);
+ }
}
- }
- if ($this->upload_file['size'][$i] > 0)
- {
- if ($fileinfo['name'] &&
$fileinfo['deleteable'] != 'N')
+ if ($this->upload_file['size'][$i] > 0)
{
-
if($GLOBALS['phpgw']->vfs->cp(array(
+ if ($fileinfo['name'] &&
$fileinfo['deleteable'] != 'N')
+ {
+
if($GLOBALS['phpgw']->vfs->cp(array(
'from'
=> $this->upload_file['tmp_name'][$i],
'to'
=> $this->upload_file['name'][$i],
'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$GLOBALS['phpgw']->vfs->set_attributes(array(
+ {
+
$GLOBALS['phpgw']->vfs->set_attributes(array(
'string' => $this->upload_file['name'][$i],
'relatives' => array(RELATIVE_ALL),
'attributes' => array(
@@ -872,55 +880,52 @@
'mime_type' => $this->upload_file['type'][$i],
'deleteable' => 'Y',
'comment' => stripslashes ($upload_comment[$i]))));
- $result[] =
lang('replaced %1 (%2
bytes)',$this->path.'/'.$this->upload_file['name'][$i],$this->upload_file['size'][$i]);
+ $result[] =
lang('replaced %1 (%2
bytes)',$this->path.'/'.$this->upload_file['name'][$i],$this->upload_file['size'][$i]);
+ }
+ else
+ {
+ $result[] =
lang( 'failed to upload file: %1',$this->upload_file['name'][$i]);
+ }
}
else
{
- $result[] = lang(
'failed to upload file: %1',$this->upload_file['name'][$i]);
- }
- }
- else
- {
-
if($GLOBALS['phpgw']->vfs->cp(array(
+
if($GLOBALS['phpgw']->vfs->cp(array(
'from'
=> $this->upload_file['tmp_name'][$i],
'to'
=> $this->upload_file['name'][$i],
'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$GLOBALS['phpgw']->vfs->set_attributes(array(
+ {
+
$GLOBALS['phpgw']->vfs->set_attributes(array(
'string' => $this->upload_file['name'][$i],
'relatives' => array(RELATIVE_ALL),
'attributes' => array (
'mime_type' => $this->upload_file['type'][$i],
'comment' => stripslashes ($this->upload_comment[$i]))));
- $result[] =
lang('created %1 (%2 bytes)',$this->path.'/'.$this->upload_file['name'][$i] ,
$this->upload_file['size'][$i]);
- }
- else
- {
- $result[] =
lang('failed to upload file: %1',$this->upload_file['name'][$i]);
+ $result[] =
lang('created %1 (%2 bytes)',$this->path.'/'.$this->upload_file['name'][$i] ,
$this->upload_file['size'][$i]);
+ }
+ else
+ {
+ $result[] =
lang('failed to upload file: %1',$this->upload_file['name'][$i]);
+ }
}
}
- }
- elseif ($this->upload_file['name'][$i])
- {
- $GLOBALS['phpgw']->vfs->touch(array(
+ elseif ($this->upload_file['name'][$i])
+ {
+
$GLOBALS['phpgw']->vfs->touch(array(
'string' =>
$this->upload_file['name'][$i],
'relatives' =>
array(RELATIVE_ALL)));
-
$GLOBALS['phpgw']->vfs->set_attributes(array(
+
$GLOBALS['phpgw']->vfs->set_attributes(array(
'string' =>
$this->upload_file['name'][$i],
'relatives' =>
array(RELATIVE_ALL),
'attributes' =>
array(
'mime_type' => $this->upload_file['type'][$i],
'comment' => $this->upload_comment[$i])));
- $result[] = ' Created
'.$this->path.'/'.$this->upload_file['name'][$i].' '. $this->file_size[$i];
+ $result[] = ' Created
'.$this->path.'/'.$this->upload_file['name'][$i].' '. $this->file_size[$i];
+ }
}
}
- if(is_array($result))
- {
- return $result;
- }
- return True;
+ return is_array($result)?$result:True;
}
/**TODO : xslt-ise this */
@@ -1163,5 +1168,21 @@
}
return $size;
}
+
+ function check_quota($file)
+ {
+ $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;
+ }
+ elseif(($this->quota - $size_homedir - $size_file) > 0)
+ {
+ return True;
+ }
+ return False;
+ }
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] filemanager/inc class.uifilemanager.inc.php, 1.25 class.bofilemanager.inc.php, 1.19,
ceb <=
- Prev by Date:
[Phpgroupware-cvs] folders/templates/base/images tree_space.gif, 1.1 tree_collapse.png, 1.1 tree_leaf.gif, 1.1 tree_vertline.gif, 1.1 tree_expand.gif, 1.1 tree_expand.png, 1.1 tree_split.png, 1.1 evo-sent_itm.gif, 1.1 tree_leaf.png, 1.1 tree_space.png, 1.1 tree_end.png, 1.1 tree_collapse.gif, 1.1 navbar.gif, 1.1 tree_end.gif, 1.1 evo-inbox.gif, 1.1 evo_delete.gif, 1.1 tree_split.gif, 1.1 navbar.png, 1.1 tree_vertline.png, 1.1 phpgw.gif, 1.1
- Next by Date:
[Phpgroupware-cvs] property/inc/export GABNr,1.4
- Previous by thread:
[Phpgroupware-cvs] folders/templates/base/images tree_space.gif, 1.1 tree_collapse.png, 1.1 tree_leaf.gif, 1.1 tree_vertline.gif, 1.1 tree_expand.gif, 1.1 tree_expand.png, 1.1 tree_split.png, 1.1 evo-sent_itm.gif, 1.1 tree_leaf.png, 1.1 tree_space.png, 1.1 tree_end.png, 1.1 tree_collapse.gif, 1.1 navbar.gif, 1.1 tree_end.gif, 1.1 evo-inbox.gif, 1.1 evo_delete.gif, 1.1 tree_split.gif, 1.1 navbar.png, 1.1 tree_vertline.png, 1.1 phpgw.gif, 1.1
- Next by thread:
[Phpgroupware-cvs] property/inc/export GABNr,1.4
- Index(es):