[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] filemanager/inc class.uiactions.inc.php, 1.3 hook_sid
From: |
ceb |
Subject: |
[Phpgroupware-cvs] filemanager/inc class.uiactions.inc.php, 1.3 hook_sidebox_menu.inc.php, 1.2 |
Date: |
Mon, 11 Apr 2005 00:36:00 +0200 |
Update of filemanager/inc
Modified Files:
Branch: MAIN
class.uiactions.inc.php lines: +175 -3
hook_sidebox_menu.inc.php lines: +17 -17
Log Message:
added functions for attaching files
====================================================
Index: filemanager/inc/class.uiactions.inc.php
diff -u filemanager/inc/class.uiactions.inc.php:1.2
filemanager/inc/class.uiactions.inc.php:1.3
--- filemanager/inc/class.uiactions.inc.php:1.2 Sat Jan 22 02:22:52 2005
+++ filemanager/inc/class.uiactions.inc.php Sun Apr 10 22:36:06 2005
@@ -1,8 +1,180 @@
<?php
+ /***
+ * Filemanager - Attached files
+ *
+ * @author Bettina Gille address@hidden
+ * @author Lars Piepho <address@hidden>
+ * @copyright Copyright (C) 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$
+ * $Source$
+ */
class uiactions
- {
- var $action_classes = array(
+ {
+ var $public_functions = array
+ (
+ 'show_file' => True,
+ 'save_file' => True,
+ 'delete_file' => True,
+ 'get_file' => True
+ );
+ var $file;
+ var $action_id;
+ var $app;
+ var $appdir;
+
+ function uiactions()
+ {
+ $this->app =
$_REQUEST['app']?$_REQUEST['app']:$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->appdir = $GLOBALS['basedir'] . '/' .
$this->app;
+
+ $this->file = $_REQUEST['file'];
+ $this->action_id = $_REQUEST['action_id'];
+
+ if (@!is_object($GLOBALS['phpgw']->vfs))
+ {
+ $GLOBALS['phpgw']->vfs = CreateObject
('phpgwapi.vfs');
+ }
+ $GLOBALS['phpgw']->vfs->override_acl = True;
+ }
+
+ function show_file()
+ {
+ $ls_array = $GLOBALS['phpgw']->vfs->ls(array
+ (
+ 'string' => $this->file,
+ 'relatives' => array (RELATIVE_ALL),
+ 'checksubdirs' => False,
+ 'nofiles' => True
+ ));
+
+ if ($ls_array[0]['mime_type'])
+ {
+ $mime_type = $ls_array[0]['mime_type'];
+ }
+ elseif ($GLOBALS['settings']['viewtextplain'])
+ {
+ $mime_type = 'application/octet-stream;';
+ }
+ $filename = basename($this->file);
+ header('Content-type: ' . $mime_type);
+ header('Content-Disposition: attachment; filename=' .
$filename);
+ echo $GLOBALS['phpgw']->vfs->read(array
+ (
+ 'string' => $this->file,
+ 'relatives' => array(RELATIVE_NONE)
+ ));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+
+ function save_file($action_id, $source = '', $destination = '')
+ {
+ //Check if home/groupdirectory exists. If not, we
create it
+ if (!file_exists($this->appdir))
+ {
+ $GLOBALS['phpgw']->vfs->override_acl = 1;
+ $GLOBALS['phpgw']->vfs->mkdir(array
+ (
+ 'string' => $this->appdir,
+ 'relatives' => array (RELATIVE_ALL)
+ ));
+ $GLOBALS['phpgw']->vfs->override_acl = 0;
+ }
+
+ $attdir = $this->appdir . '/' . $action_id;
+
+ if (!file_exists($attdir))
+ {
+ $GLOBALS['phpgw']->vfs->override_acl = 1;
+ $GLOBALS['phpgw']->vfs->mkdir(array
+ (
+ 'string' => $attdir,
+ 'relatives' => array (RELATIVE_ALL)
+ ));
+ $GLOBALS['phpgw']->vfs->override_acl = 0;
+ }
+
+ if(!$source || !$destination)
+ {
+ $source = $_FILES['attachment']['tmp_name'];
+ $destination = $_FILES['attachment']['name'];
+ }
+
+ $GLOBALS['phpgw']->vfs->override_acl = 1;
+ $GLOBALS['phpgw']->vfs->cp(array
+ (
+ 'from' => $source,
+ 'to' => $attdir . '/' . $destination,
+ 'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
+ ));
+ $GLOBALS['phpgw']->vfs->override_acl = 0;
+ }
+
+ function delete_file()
+ {
+ //$this->app = $_GET['app'];
+ //$this->appdir = $GLOBALS['basedir'] . '/' .
$this->app;
+
+ if(!$this->file && file_exists($this->appdir . '/' .
$this->action_id))
+ {
+ $GLOBALS['phpgw']->vfs->override_acl = 1;
+ $GLOBALS['phpgw']->vfs->delete(array
+ (
+ 'string' => $this->appdir . '/'
. $this->action_id,
+ 'relatives' => array (RELATIVE_ALL)
+ ));
+ $GLOBALS['phpgw']->vfs->override_acl = 0;
+ }
+ elseif($this->file)
+ {
+ $GLOBALS['phpgw']->vfs->override_acl = 1;
+ $GLOBALS['phpgw']->vfs->rm(array
+ (
+ 'string' => $this->appdir . '/'
. $this->action_id . '/' . $this->file,
+ 'relatives' => array (RELATIVE_ALL)
+ ));
+ $GLOBALS['phpgw']->vfs->override_acl = 0;
+
+ Header('Location: ' . $_SERVER['HTTP_REFERER']);
+ //$GLOBALS['phpgw']->redirect_link($referer);
+ }
+ }
+
+ function get_files($action_id, $delete = False)
+ {
+ $directory = '/' . $this->app . '/' . $action_id;
+
+ $GLOBALS['phpgw']->db->query("SELECT name from
phpgw_vfs where directory like '" . $directory . "' AND size > 0 AND mime_type
NOT like 'journal-deleted'",__LINE__,__FILE__);
+
+ while($GLOBALS['phpgw']->db->next_record() != '')
+ {
+ $attachment = $directory . '/' .
$GLOBALS['phpgw']->db->f('name');
+
+ $view_link =
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'filemanager.uiactions.show_file','file' => $attachment,'app' => $this->app));
+ if($delete)
+ {
+ $del_link =
$GLOBALS['phpgw']->link('/index.php',array
+
(
+
'menuaction'
=> 'filemanager.uiactions.delete_file',
+
'action_id'
=> $action_id,
+
'file'
=> basename($attachment),
+
'app'
=> $this->app));
+ $del = '<a href="' . $del_link .
'"><img src="' . $GLOBALS['phpgw']->common->image('phpgwapi','delete') . '"
title="' . lang('delete') . '" border="0"></a>';
+ }
+ $att_link .= '<a href="' . $view_link . '"
target="_blank">' . basename($attachment) . '</a>  ' . $del . '<br />';
+ }
+ return $att_link;
+ }
+
+ function file_exists($data)
+ {
+ return $GLOBALS['phpgw']->vfs->file_exists($data);
+ }
+
+
+ /*var $action_classes = array(
0=>'filemanager.uiaction_edit'
);
var $actions = array();
@@ -46,6 +218,6 @@
}
}
- }
+ }*/
}
?>
====================================================
Index: filemanager/inc/hook_sidebox_menu.inc.php
diff -u filemanager/inc/hook_sidebox_menu.inc.php:1.1
filemanager/inc/hook_sidebox_menu.inc.php:1.2
--- filemanager/inc/hook_sidebox_menu.inc.php:1.1 Tue Feb 8 00:06:31 2005
+++ filemanager/inc/hook_sidebox_menu.inc.php Sun Apr 10 22:36:07 2005
@@ -1,17 +1,17 @@
<?php
-
/**************************************************************************\
- * phpGroupWare - projects's Sidebox-Menu for idots-template
*
- * http://www.phpgroupware.org
*
- * Written by Pim Snel <address@hidden>
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
- /* $Id$ */
+ /**
+ * Filemanager - Sidebox-Menu for iDots Template
+ *
+ * @author Bettina Gille address@hidden
+ * @author Pim Snel <address@hidden>
+ * @copyright Copyright (C) 2003-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$
+ * $Source$
+ */
- /*
+ /*
This hookfile is for generating an app-specific side menu used
in the idots
template set.
@@ -22,12 +22,12 @@
*/
{
- $appname = 'filemanager';
- $menu_title =
$GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '. lang('Menu');
+ $appname = 'filemanager';
+ $menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title']
. ' '. lang('Menu');
- $file[] = array('text' => 'Preferences',
- 'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.preferences'));
+ $file[] = array('text' => 'Preferences',
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.preferences'));
- display_sidebox($appname,$menu_title,$file);
+ display_sidebox($appname,$menu_title,$file);
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] filemanager/inc class.uiactions.inc.php, 1.3 hook_sidebox_menu.inc.php, 1.2,
ceb <=
- Prev by Date:
[Phpgroupware-cvs] projects/inc hook_sidebox_menu.inc.php, 1.14 hook_preferences.inc.php, 1.27 hook_admin.inc.php, 1.23 hook_deleteaccount.inc.php, 1.7 hook_home.inc.php, 1.5 hook_manual.inc.php, 1.4 hook_add_def_pref.inc.php, 1.9
- Next by Date:
[Phpgroupware-cvs] projects/inc class.uiprojects_base.inc.php, 1.12 class.uiprojects.inc.php, 1.159 class.attached_files.inc.php, 1.3
- Previous by thread:
[Phpgroupware-cvs] projects/inc hook_sidebox_menu.inc.php, 1.14 hook_preferences.inc.php, 1.27 hook_admin.inc.php, 1.23 hook_deleteaccount.inc.php, 1.7 hook_home.inc.php, 1.5 hook_manual.inc.php, 1.4 hook_add_def_pref.inc.php, 1.9
- Next by thread:
[Phpgroupware-cvs] projects/inc class.uiprojects_base.inc.php, 1.12 class.uiprojects.inc.php, 1.159 class.attached_files.inc.php, 1.3
- Index(es):