Index: inc/class.attachedFiles.inc.php
===================================================================
RCS file: inc/class.attachedFiles.inc.php
diff -N inc/class.attachedFiles.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.attachedFiles.inc.php 28 Apr 2004 12:25:52 -0000
@@ -0,0 +1,162 @@
+ true,
+ 'save_file' => true,
+ 'delete_file' => true,
+ 'get_file' => true
+ );
+ var $file;
+ var $vfs;
+ var $project_id;
+
+ function attachedFiles()
+ {
+ $this->file = $_REQUEST['file'];
+ $this->project_id = $_REQUEST['project_id'];
+ $this->vfs = CreateObject('phpgwapi.vfs');
+ }
+
+ function show_file()
+ {
+ $ls_array = $this->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 = 'text/plain';
+ }
+ $filename = basename($this->file);
+ header('Content-type: ' . $mime_type);
+ header('Content-Disposition: attachment; filename=' . $filename);
+ echo $this->vfs->read (array (
+ 'string' => $this->file,
+ 'relatives' => array (RELATIVE_NONE)));
+ $GLOBALS['phpgw']->common->phpgw_exit ();
+ }
+
+ function save_file($project_id)
+ {
+ //Check if home/groupdirectory exists. If not, we create it
+ $basedir = $GLOBALS['basedir'] . "/projects";
+ if (!file_exists($basedir))
+ {
+ $this->vfs->override_acl = 1;
+ $this->vfs->mkdir (array (
+ 'string' => $basedir,
+ 'relatives' => array (RELATIVE_ALL)));
+ $this->vfs->override_acl = 0;
+ }
+
+ $attdir = $basedir . "/" . $project_id;
+
+ $this->vfs->override_acl = 1;
+ $this->vfs->mkdir (array (
+ 'string' => $attdir,
+ 'relatives' => array (RELATIVE_ALL)));
+ $this->vfs->override_acl = 0;
+
+ $this->vfs->override_acl = 1;
+ $this->vfs->cp(array (
+ 'from' => $_FILES['attachment']['tmp_name'],
+ 'to' => $attdir . '/' . $_FILES['attachment']['name'],
+ 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)));
+ $this->vfs->override_acl = 0;
+ }
+
+ function delete_file($project_id = true)
+ {
+ $basedir = $GLOBALS['basedir'] . "/projects";
+
+ if(!$this->file)
+ {
+ $this->vfs->override_acl = 1;
+ $this->vfs->delete(array (
+ 'string' => $basedir . "/" . $project_id,
+ 'relatives' => array (RELATIVE_ALL)));
+ $this->vfs->override_acl = 0;
+ }
+ else
+ {
+ $this->vfs->override_acl = 1;
+ $this->vfs->rm(array (
+ 'string' => $basedir . "/" . $this->project_id . "/" . $this->file,
+ 'relatives' => array (RELATIVE_ALL)));
+ $this->vfs->override_acl = 0;
+ $GLOBALS['phpgw']->redirect_link('/index.php', Array(
+ 'menuaction' => 'projects.uiprojects.edit_project',
+ 'project_id' => $this->project_id
+ ));
+ }
+ }
+
+ function get_files($project_id, $delete = false)
+ {
+ $GLOBALS['phpgw']->db->query("SELECT name from phpgw_vfs where directory like '/projects/" . $project_id . "' AND size > 0 AND mime_type NOT like 'journal-deleted'",__LINE__,__FILE__); //
+ $x = 0;
+ while ($GLOBALS['phpgw']->db->next_record() != "")
+ {
+ $attachment[$x] = '/projects/' . $project_id . '/' . $GLOBALS['phpgw']->db->f('name');
+ ++$x;
+ }
+
+ for($i=0; $i <= $x-1; $i++)
+ {
+ $file = $GLOBALS['phpgw']->link('/index.php',Array(
+ 'menuaction' => 'projects.attachedFiles.show_file',
+ 'file' => $attachment[$i]
+ ));
+ if($delete)
+ {
+ $delFile = basename($attachment[$i]);
+ $delLink = $GLOBALS['phpgw']->link('/index.php',Array(
+ 'menuaction' => 'projects.attachedFiles.delete_file',
+ 'project_id' => $project_id,
+ 'file' => $delFile
+ ));
+ $del = "";
+ }
+
+ $attLink .= "" . basename($attachment[$i]) . "   " . $del . "
";
+ }
+ return ($attLink);
+ }
+
+ }
+?>
Index: inc/class.soprojects.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/projects/inc/class.soprojects.inc.php,v
retrieving revision 1.95
diff -u -r1.95 class.soprojects.inc.php
--- inc/class.soprojects.inc.php 16 Mar 2004 17:06:21 -0000 1.95
+++ inc/class.soprojects.inc.php 28 Apr 2004 12:25:53 -0000
@@ -347,7 +347,7 @@
}
function add_project($values)
- {
+ {
$values['descr'] = $this->db->db_addslashes($values['descr']);
$values['title'] = $this->db->db_addslashes($values['title']);
$values['number'] = $this->db->db_addslashes($values['number']);
Index: inc/class.uiprojecthours.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/projects/inc/class.uiprojecthours.inc.php,v
retrieving revision 1.74
diff -u -r1.74 class.uiprojecthours.inc.php
--- inc/class.uiprojecthours.inc.php 24 Mar 2004 16:35:15 -0000 1.74
+++ inc/class.uiprojecthours.inc.php 28 Apr 2004 12:25:53 -0000
@@ -57,6 +57,7 @@
$this->account = $GLOBALS['phpgw_info']['user']['account_id'];
$this->grants = $GLOBALS['phpgw']->acl->get_grants('projects');
$this->grants[$this->account] = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
+ $this->attachedFiles = CreateObject('projects.attachedFiles');
$this->start = $this->bohours->start;
$this->query = $this->bohours->query;
@@ -411,6 +412,8 @@
$GLOBALS['phpgw']->template->set_var('ptime_main',$main['ptime']);
$GLOBALS['phpgw']->template->set_var('atime_main',$main['ahours_jobs']);
$GLOBALS['phpgw']->template->parse('main','project_main',True);
+ $GLOBALS['phpgw']->template->set_var('attachment',$this->attachedFiles->get_files($this->project_id));
+ $GLOBALS['phpgw']->template->set_var('lang_files',lang('Files'));
}
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
Index: inc/class.uiprojects.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/projects/inc/class.uiprojects.inc.php,v
retrieving revision 1.139
diff -u -r1.139 class.uiprojects.inc.php
--- inc/class.uiprojects.inc.php 20 Apr 2004 12:42:14 -0000 1.139
+++ inc/class.uiprojects.inc.php 28 Apr 2004 12:25:53 -0000
@@ -59,6 +59,7 @@
$this->boprojects = CreateObject('projects.boprojects',True, $action);
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->sbox = CreateObject('phpgwapi.sbox');
+ $this->attachedFiles = CreateObject('projects.attachedFiles');
$this->start = $this->boprojects->start;
$this->query = $this->boprojects->query;
@@ -287,6 +288,7 @@
function list_projects()
{
+
$action = get_var('action',array('POST','GET'));
$pro_main = get_var('pro_main',array('POST','GET'));
@@ -330,6 +332,8 @@
$GLOBALS['phpgw']->template->set_var('number_main',$main['number']);
$GLOBALS['phpgw']->template->set_var('customer_main',$main['customerout']);
$GLOBALS['phpgw']->template->set_var('url_main',$main['url']);
+ $GLOBALS['phpgw']->template->set_var('attachment',$this->attachedFiles->get_files($pro_main));
+ $GLOBALS['phpgw']->template->set_var('lang_files',lang('Files'));
$GLOBALS['phpgw']->template->parse('main','project_main',True);
}
@@ -725,7 +729,7 @@
}
function edit_project()
- {
+ {
$action = get_var('action',array('GET','POST'));
$pro_main = get_var('pro_main',array('GET','POST'));
$pro_parent = get_var('pro_parent',array('GET','POST'));
@@ -765,7 +769,8 @@
}
else
{
- $project_id = $this->boprojects->save_project($action, $values);
+ $project_id = $this->boprojects->save_project($action, $values);
+ $this->attachedFiles->save_file($project_id);
$link_data['project_id'] = $project_id;
if($_POST['save'])
{
@@ -1136,6 +1141,12 @@
$GLOBALS['phpgw']->template->set_var('result',$values['result']);
$GLOBALS['phpgw']->template->set_var('test',$values['test']);
$GLOBALS['phpgw']->template->set_var('quality',$values['quality']);
+
+ $GLOBALS['phpgw']->template->set_var('attachment',$this->attachedFiles->get_files($project_id, true));
+ $GLOBALS['phpgw']->template->set_var('lang_files',lang('Files'));
+ $GLOBALS['phpgw']->template->set_var('lang_attach',lang('Attach File'));
+
+
//--------- coordinator -------------
@@ -1264,6 +1275,7 @@
$this->display_app_header();
}
+
$GLOBALS['phpgw']->template->set_file(array('view' => 'view.tpl'));
$GLOBALS['phpgw']->template->set_block('view','sub','subhandle');
$GLOBALS['phpgw']->template->set_block('view','accounting_act','acthandle');
@@ -1451,6 +1463,9 @@
$GLOBALS['phpgw']->template->set_var('edit_roles_events_button','');
}
}
+
+ $GLOBALS['phpgw']->template->set_var('attachment',$this->attachedFiles->get_files($project_id));
+ $GLOBALS['phpgw']->template->set_var('lang_files',lang('Files'));
$GLOBALS['phpgw']->template->set_var('ownhandle','');
$GLOBALS['phpgw']->template->set_var('acthandle','');
$GLOBALS['phpgw']->template->set_var('bothhandle','');
@@ -1485,6 +1500,7 @@
if ($_POST['yes'])
{
+ $this->attachedFiles->delete_file($pa_id);
$this->boprojects->delete_project($pa_id,(isset($_POST['subs'])?True:False));
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
Index: templates/default/form.tpl
===================================================================
RCS file: /cvsroot/phpgroupware/projects/templates/default/form.tpl,v
retrieving revision 1.64
diff -u -r1.64 form.tpl
--- templates/default/form.tpl 24 Mar 2004 16:35:15 -0000 1.64
+++ templates/default/form.tpl 28 Apr 2004 12:25:53 -0000
@@ -25,7 +25,7 @@
{message}
-