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}

-
+ @@ -295,6 +295,12 @@ + + + + + + Index: templates/default/hours_listhours.tpl =================================================================== RCS file: /cvsroot/phpgroupware/projects/templates/default/hours_listhours.tpl,v retrieving revision 1.29 diff -u -r1.29 hours_listhours.tpl --- templates/default/hours_listhours.tpl 12 Mar 2004 02:42:55 -0000 1.29 +++ templates/default/hours_listhours.tpl 28 Apr 2004 12:25:53 -0000 @@ -29,6 +29,10 @@ + + + +
{lang_quality}:
{lang_files}:{attachment}{lang_attach}:
{lang_available} {lang_plus_jobs}: {atime_main}
{lang_files}:{attachment}
Index: templates/default/list.tpl =================================================================== RCS file: /cvsroot/phpgroupware/projects/templates/default/list.tpl,v retrieving revision 1.42 diff -u -r1.42 list.tpl --- templates/default/list.tpl 15 Mar 2004 17:43:39 -0000 1.42 +++ templates/default/list.tpl 28 Apr 2004 12:25:53 -0000 @@ -20,6 +20,10 @@ {lang_customer}: {customer_main} + + {lang_files}: + {attachment} + Index: templates/default/view.tpl =================================================================== RCS file: /cvsroot/phpgroupware/projects/templates/default/view.tpl,v retrieving revision 1.19 diff -u -r1.19 view.tpl --- templates/default/view.tpl 12 Mar 2004 02:42:55 -0000 1.19 +++ templates/default/view.tpl 28 Apr 2004 12:25:53 -0000 @@ -48,7 +48,7 @@ {lang_priority}: {priority} -   + 6nbsp;   @@ -192,6 +192,10 @@ {edit_milestones_button} + + + {lang_files}: + {attachment}