Attachment of Uploaded files (stored under /infolog via VFS) based on the patch of juergen@henge-ernst.de

This commit is contained in:
Ralf Becker 2001-10-04 00:46:06 +00:00
parent e005b1ba36
commit f9107de6ac
9 changed files with 281 additions and 40 deletions

View File

@ -17,40 +17,46 @@
{
var $public_functions = array
(
'get_list' => True,
'view' => True,
'add' => True,
'edit' => True,
'delete' => True,
'get_list' => True,
'view' => True,
'add' => True,
'edit' => True,
'delete' => True,
'get_file' => True,
'add_file' => True,
'preferences' => True
);
var $icons;
var $vfs;
var $basedir='/infolog';
function uiinfolog( )
{
$this->bo = CreateObject('infolog.boinfolog');
$this->vfs = CreateObject('phpgwapi.vfs');
$this->icons = array(
'type' => array(
'task' => 'task.gif', 'task_alt' => 'Task',
'phone' => 'phone.gif', 'phone_alt' => 'Phonecall',
'note' => 'note.gif', 'note_alt' => 'Note',
'confirm' => 'confirm.gif','confirm_alt' => 'Confirmation',
'reject' => 'reject.gif', 'reject_alt' => 'Reject',
'email' => 'email.gif', 'email_alt' => 'Email' ),
'task' => 'task.gif', 'task_alt' => 'Task',
'phone' => 'phone.gif', 'phone_alt' => 'Phonecall',
'note' => 'note.gif', 'note_alt' => 'Note',
'confirm' => 'confirm.gif', 'confirm_alt' => 'Confirmation',
'reject' => 'reject.gif', 'reject_alt' => 'Reject',
'email' => 'email.gif', 'email_alt' => 'Email' ),
'action' => array(
'new' => 'new.gif', 'new_alt' => 'Add Sub',
'view' => 'view.gif', 'view_alt' => 'View Subs',
'parent' => 'parent.gif', 'parent_alt' => 'View other Subs',
'edit' => 'edit.gif', 'edit_alt' => 'Edit',
'delete' => 'delete.gif', 'delete_alt' => 'Delete' ),
'new' => 'new.gif', 'new_alt' => 'Add Sub',
'view' => 'view.gif', 'view_alt' => 'View Subs',
'parent' => 'parent.gif', 'parent_alt' => 'View other Subs',
'edit' => 'edit.gif', 'edit_alt' => 'Edit',
'addfile' => 'addfile.gif', 'addfile_alt' => 'Add a file',
'delete' => 'delete.gif', 'delete_alt' => 'Delete' ),
'status' => array(
'billed' => 'billed.gif', 'billed_alt' => 'billed',
'done' => 'done.gif', 'done_alt' => 'done',
'billed' => 'billed.gif', 'billed_alt' => 'billed',
'done' => 'done.gif', 'done_alt' => 'done',
'will-call' => 'will-call.gif', 'will-call_alt' => 'will-call',
'call' => 'call.gif', 'call_alt' => 'call',
'ongoing' => 'ongoing.gif','ongoing_alt' => 'ongoing',
'offer' => 'offer.gif', 'offer_alt' => 'offer' )
'call' => 'call.gif', 'call_alt' => 'call',
'ongoing' => 'ongoing.gif', 'ongoing_alt' => 'ongoing',
'offer' => 'offer.gif', 'offer_alt' => 'offer' )
);
$this->filters = array(
@ -190,6 +196,20 @@
{
$owner = "<span class=private>$owner</span>";
}
// add the links to the files which corrospond to this entry
$attachments=$this->vfs->ls($this->basedir.'/'.$info['info_id'].'/',array(REALTIVE_NONE));
while (list($keys,$fileinfo) = each($attachments))
{
$links .= isset($links) ? ', ' : '<br>';
$links .= $this->html->a_href($fileinfo['name'],'/index.php',
$this->menuaction('get_file') + array(
'info_id' => $info['info_id'],
'filename' => $fileinfo['name'])
);
if ($fileinfo['comment']) $links .= ' (' . $fileinfo['comment'] . ')';
}
return array(
'type' => $this->icon('type',$info['info_type']),
'status' => $this->icon('status',$info['info_status']),
@ -197,12 +217,13 @@
'subject' => $subject,
'des' => nl2br($info['info_des']),
'startdate' => $GLOBALS['phpgw']->common->show_date($info['info_startdate'],
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
'enddate' => $enddate,
'owner' => $owner,
'datecreated' => $GLOBALS['phpgw']->common->show_date($info['info_datecreated'],
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
'responsible' => $responsible
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
'responsible' => $responsible,
'filelinks' => $links
);
}
@ -252,7 +273,8 @@
global $cat_filter,$cat_id,$sort,$order,$query,$start,$filter;
global $action,$addr_id,$proj_id,$info_id;
if (!$for_include) {
if (!$for_include)
{
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
}
@ -419,6 +441,10 @@
$this->icon('action','edit'),'/index.php',
$hidden_vars+array('info_id' => $id)+
$this->menuaction('edit')));
$t->set_var('addfiles',$html->a_href(
$this->icon('action','addfile'),'/index.php',
$hidden_vars+array('info_id' => $id)+
$this->menuaction('add_file')));
}
else
{
@ -485,6 +511,127 @@
$t->pfp('out','info_list_t',true);
}
/*
** Send a requested file to the user.
** ACL check is done by the VFS
*/
function get_file( )
{
$info_id=$GLOBALS['HTTP_GET_VARS']['info_id'];
$filename=$GLOBALS['HTTP_GET_VARS']['filename'];
$browser = CreateObject('phpgwapi.browser');
$referer = $this->get_referer();
if (!$info_id || !$filename || !$this->bo->check_access($info_id,PHPGW_ACL_READ))
{
Header('Location: ' . $html->link($referer));
$GLOBALS['phpgw']->common->phpgw_exit();
}
$fn=$this->basedir.'/'.$info_id.'/'.$filename;
$browser->content_header($fn);
echo $this->vfs->read($fn,array(RELATIVE_ROOT));
$GLOBALS['phpgw']->common->phpgw_exit();
}
/*
** Put a file to the corrosponding place in the VFS and set the attributes
** ACL check is done by the VFS
*/
function add_one_file($info_id,$filepos,$name,$size,$type,$comment='')
{
//echo "<p>add_one_file: info_id='$info_id', filepos='$filepos', name='$name', size='$size', type='$type', comment='$comment'</p>\n";
if ($filepos && ($filepos!="none") && $info_id)
{
// create the root for attached files in infolog, if it does not exists
if (!($this->vfs->file_exists($this->basedir,array(RELATIVE_ROOT))))
{
$this->vfs->override_acl = 1;
$this->vfs->mkdir($this->basedir,array(RELATIVE_ROOT));
$this->vfs->override_acl = 0;
}
if (!$this->vfs->securitycheck($filename))
{
return lang('Invalid filename');
}
else
{
$dir=$this->basedir.'/'.$info_id;
if (!($this->vfs->file_exists($dir,array(RELATIVE_ROOT))))
{
$this->vfs->override_acl = 1;
$this->vfs->mkdir($dir,array(RELATIVE_ROOT));
$this->vfs->override_acl = 0;
}
$this->vfs->cp($filepos,$dir.'/'.$name,array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT));
$this->vfs->set_attributes ($dir.'/'.$name, array (RELATIVE_ROOT),
array ('mime_type' => $type,
'comment' => stripslashes ($comment),
'app' => 'infolog'));
}
}
}
/*
** Display dialog to add one file to an info_log entry
*/
function add_file( )
{
global $upload,$info_id;
global $attachfile,$attachfile_name,$attachfile_size,$attachfile_type;
global $filecomment;
global $sort,$order,$query,$start,$filter,$cat_id,$referer;
$t = $this->template; $html = $this->html;
$hidden_vars = array('sort' => $sort,'order' => $order,
'query' => $query,'start' => $start,
'filter' => $filter,'cat_id' => $cat_id );
if (!isset($referer))
$referer = $this->get_referer();
if (!isset($info_id) || !$info_id || !$this->bo->check_access($info_id,PHPGW_ACL_EDIT))
{
$error[]=lang('Access denied');
Header('Location: ' . $html->link($referer, $hidden_vars+array('cd'=>15)));
$GLOBALS['phpgw']->common->phpgw_exit();
}
if ($upload) {
$fileerror = $this->add_one_file($info_id,$attachfile,$attachfile_name,$attachfile_size,$attachfile_type,$filecomment);
if ($fileerror!='') $error[]=$fileerror;
}
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
$t->set_file(array('info_add_file' => 'add_file.tpl'));
$t->set_var( $this->setStyleSheet( ));
$t->set_var( $this->infoHeaders( ));
$t->set_var( $this->formatInfo( $info_id ));
$t->set_var( 'hidden_vars',$html->input_hidden($hidden_vars+array('info_id' => $info_id)));
if (is_array($error))
{
$t->set_var('error_list',$GLOBALS['phpgw']->common->error_list($error));
}
$t->set_var('lang_info_action',lang('InfoLog').' - '.lang('attach file'));
$t->set_var('actionurl',$html->link('/index.php',array('menuaction' => 'infolog.uiinfolog.add_file')));
$t->set_var('lang_file',lang('attach file').':');
$t->set_var('lang_comment',lang('comment').':');
$t->set_var('submit_button',$html->submit_button('upload','attach file'));
$t->set_var('cancel_button',$html->form_1button('cancel_button','Cancel','',$referer));
$t->pfp('out','info_add_file');
}
function edit( )
{
global $cat_id,$sort,$order,$query,$start,$filter;
@ -494,6 +641,8 @@
global $dur_days,$eday,$emonth,$eyear;
global $type,$from,$addr,$id_addr,$id_project,$subject,$des,$access;
global $pri,$status,$confirm,$info_cat,$id_parent,$responsible;
global $attachfile,$attachfile_name,$attachfile_size,$attachfile_type;
global $filecomment;
$t = $this->template; $html = $this->html;
@ -614,10 +763,16 @@
'id_parent' => $id_parent,
'responsible' => $responsible
));
// save the attached file
$fileerror = $this->add_one_file($this->bo->so->data['info_id'],$attachfile,$attachfile_name,$attachfile_size,$attachfile_type,$filecomment);
if ($fileerror!='') $error[]=$fileerror;
}
if (!$query_addr && !$query_project)
{
Header('Location: ' . $html->link($referer, array('cd'=>15)));
$GLOBALS['phpgw']->common->phpgw_exit();
}
}
}
@ -782,6 +937,9 @@
if (!isset($access)) $access = $this->bo->so->data['info_access'] == 'private';
$t->set_var('access_list',$html->checkbox('access',$access));
$t->set_var('lang_file',lang('attach file').':');
$t->set_var('lang_comment',lang('comment').':');
$t->set_var('edit_button',$html->submit_button('save','Save'));
if (!$action && $this->bo->check_access($info_id,PHPGW_ACL_DELETE))
@ -814,12 +972,24 @@
!$this->bo->check_access($info_id,PHPGW_ACL_DELETE))
{
Header('Location: ' . $html->link($referer));
$GLOBALS['phpgw']->common->phpgw_exit();
}
if ($confirm)
{
$this->bo->delete($info_id);
Header('Location: ' . $html->link($referer,array( 'cd' => 16 )));
/*
** Also remove the attached files for that entry
*/
$dir=$this->basedir.'/'.$info_id;
if ($this->vfs->file_exists($dir,array(RELATIVE_ROOT)))
{
$this->vfs->override_acl = 1;
$this->vfs->delete($dir,array(RELATIVE_ROOT));
$this->vfs->override_acl = 0;
}
}
else
{

View File

@ -1,16 +1,21 @@
%1 records imported infolog de %1 Datensätze importiert
%1 records read (not yet imported, you may go back and uncheck test import) infolog de %1 Datensätze gelesen (noch nicht importiert, sie können %2zurück%3 gehen und Test Import ausschalten)
Add a file infolog de Datei anhängen
Invalid filename infolog de Ungültiger Dateiname
accept infolog de bei Annahme
action infolog de Befehle
add infolog de Hinzufügen
add sub infolog de neues Teilprojekt anlegen
all infolog de alle
are you sure you want to delete this entry infolog de Sind Sie sicher, dass Sie diesen Eintrag löschen wollen?
attach file infolog de Datei anhängen
back to projectlist infolog de Zurück zur Gesamtliste
billed infolog de abgerechnet
both infolog de Annahme+erledigt
call infolog de anrufen
category infolog de Kategorie
close infolog de Schließen
comment infolog de Kommentar
confirm infolog de Bestätigung
csv-fieldname infolog de CSV-Feldname
csv-filename infolog de CSV-Dateiname
@ -30,20 +35,20 @@ fieldseparator infolog de Feldbegrenzer
finish infolog de wenn erledigt
from infolog de Von
import infolog de Import
infolog - import csv-file infolog de InfoLog - Import CSV-Datei
infolog common de InfoLog
infolog - delete infolog de InfoLog - Löschen
infolog - edit infolog de InfoLog - Bearbeiten
infolog - import csv-file infolog de InfoLog - Import CSV-Datei
infolog - new infolog de InfoLog - Anlegen
infolog - new subproject infolog de InfoLog - Anlegen Teilprojekt
infolog - subprojects from infolog de InfoLog - Teilprojekte von
infolog-fieldname infolog de InfoLog-Feldname
infolog common de InfoLog
infolog preferences common de InfoLog Einstellungen
infolog-fieldname infolog de InfoLog-Feldname
last changed infolog de letzte Änderung
list no Subs/Childs infolog de Teilprojekte/Antwortdokumente nicht anzeigen
no - cancel infolog de Nein - Abbruch
no filter infolog de kein Filter
no entries found, try again ... infolog de Kein Einträge gefunden, nochmal versuchen ...
no filter infolog de kein Filter
none infolog de keine
not infolog de nicht
not assigned infolog de nicht zugewiesen
@ -63,9 +68,9 @@ pattern for search in projects infolog de Muster f
phone infolog de Anruf
phone/email infolog de Telefon/Email
phonecall infolog de Telefonanruf
project infolog de Projekt
priority infolog de Priorität
private infolog de Privat
project infolog de Projekt
re: infolog de Re:
reject infolog de Absage
responsible infolog de Auftrag an

View File

@ -1,16 +1,21 @@
%1 records imported infolog en %1 records imported
%1 records read (not yet imported, you may go back and uncheck test import) infolog en %1 records read (not yet imported, you may go %2back%3 and uncheck Test Import)
Add a file infolog de Add a file
Invalid filename infolog de Invalid filename
accept infolog en accept
action infolog en Action
add infolog en Add
add sub infolog en add Sub
all infolog en All
are you sure you want to delete this entry infolog en Are you sure you want to delete this entry
attach file infolog en Attach file
back to Projectlist infolog en Back to Projectlist
billed infolog en billed
both infolog en both
call infolog en call
category infolog en Category
close infolog de Close
comment infolog en Comment
confirm infolog en confirm
csv-fieldname infolog en CSV-Fieldname
csv-filename infolog en CSV-Filename
@ -30,20 +35,20 @@ fieldseparator infolog en Fieldseparator
finish infolog en finish
from infolog en From
import infolog en Import
infolog - import CSV-File infolog en InfoLog - Import CSV-File
infolog common en InfoLog
infolog - delete infolog en Info Log - Delete
infolog - edit infolog en InfoLog - Edit
infolog - import CSV-File infolog en InfoLog - Import CSV-File
infolog - new infolog en InfoLog - New
infolog - new subproject infolog en InfoLog - New Subproject
infolog - subprojects from infolog en InfoLog - Subprojects from
infolog-fieldname infolog en Info Log-Fieldname
infolog common en InfoLog
infolog preferences common en InfoLog preferences
infolog-fieldname infolog en Info Log-Fieldname
last changed infolog en last changed
list no Subs/Childs infolog en List no Subs/Childs
no - cancel infolog en No - Cancel
no filter infolog en no Filter
no entries found, try again ... infolog en no entries found, try again ...
no filter infolog en no Filter
none infolog en None
not infolog en not
not assigned infolog en not assigned
@ -63,9 +68,9 @@ pattern for search in projects infolog en pattern for search in Projects
phone infolog en Phonecall
phone/email infolog en Phone/Email
phonecall infolog en Phonecall
project infolog en Project
priority infolog en Priority
private infolog en Private
project infolog en Project
re: infolog en Re:
reject infolog en reject
responsible infolog en Responsible

View File

@ -0,0 +1,49 @@
{info_css}
<p class=action>{lang_info_action}<br>
<center>{error_list}</center>
<hr noshade width="98%" align="center" size="1">
<center>
<table width=95% border=0 cellspacing=1 cellpadding=3>
<tr bgcolor="{th_bg}">
<td width="5%" class=list>{lang_type}</td>
<td width="5%" class=list>{lang_status}</td>
<td class=list>{lang_subject}</td>
<td width="10%" class=list>{lang_startdate}</td>
<td width="10%" class=list>{lang_enddate}</td>
<td width="10%" class=list>{lang_owner}</td>
<td width="10%" class=list>{lang_responsible}</td>
</tr>
<tr bgcolor="{th_bg}" valign="top">
<td class=list>{type}</td>
<td class=list>{status}</td>
<td class=list>{subject}<br>{des}{filelinks}</td>
<td class=list>{startdate}</td>
<td class=list>{enddate}</td>
<td class=list>{owner}<br>{datecreated}</td>
<td class=list">{responsible}</td>
</tr>
</table><p>
<center>
<form method="POST" name="EditorForm" action="{actionurl}" enctype="multipart/form-data">
{hidden_vars}
<table width="90%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>{lang_file}</td>
<td><input type="file" name="attachfile" value=""></td>
<td>{lang_comment}</td>
<td><input name="filecomment" size="30" maxlength="64" value=""></td>
</tr>
</table>
<p>
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr valign="bottom">
<td>{submit_button}</td>
<td>{cancel_button}</td>
</tr>
</table>
</form>
</center>
</html>

View File

@ -15,7 +15,7 @@
<tr bgcolor="{th_bg}" valign="top">
<td class=list>{type}</td>
<td class=list>{status}</td>
<td class=list>{subject}<br>{des}</td>
<td class=list>{subject}<br>{des}{filelinks}</td>
<td class=list>{startdate}</td>
<td class=list>{enddate}</td>
<td class=list>{owner}<br>{datecreated}</td>

View File

@ -6,7 +6,7 @@
<center>{error_list}</center>
<center>
<form method="POST" name="EditorForm" action="{actionurl}">
<form method="POST" name="EditorForm" action="{actionurl}" enctype="multipart/form-data">
{common_hidden_vars}
<table width="90%" border="0" cellspacing="0" cellpadding="2">
@ -61,6 +61,18 @@
<tr>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td>{lang_file}</td>
<td><input type="file" name="attachfile" value=""></td>
<td>{lang_comment}</td>
<td><input name="filecomment" size="30" maxlength="64" value=""></td>
</tr>
<tr>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td width="15%">{lang_start_date}:</td>
<td width="40%">{start_select_date}</td>

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

View File

@ -22,7 +22,7 @@
<tr bgcolor="{th_bg}" valign="top">
<td class=list>{type}</td>
<td class=list>{status}</td>
<td class=list>{subject}<br>{des}</td>
<td class=list>{subject}<br>{des}{filelinks}</td>
<td class=list>{startdate}<br>{enddate}</td>
<td class=list>{owner}<br>{datecreated}</td>
<td class=list">{responsible}</td>
@ -48,14 +48,14 @@
<tr bgcolor="{tr_color}" valign="top">
<td class=list>{type}</td>
<td class=list>{status}</td>
<td class=list>{subject}<br>{des}</td>
<td class=list>{subject}<br>{des}{filelinks}</td>
<td class=list>{startdate}<br>{enddate}</td>
<td class=list>{owner}<br>{datecreated}</td>
<td class=list>{responsible}</td>
<td class=list>{subadd}
{viewsub}
{viewparent}</td>
<td class=list>{edit}&nbsp;{delete}</td>
<td class=list>{edit}&nbsp;{delete}&nbsp;{addfiles}</td>
</tr>
<!-- END info_list -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B