[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property inc/class.botts.inc.php inc/class.uitt...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property inc/class.botts.inc.php inc/class.uitt... |
Date: |
Sat, 19 May 2007 20:52:10 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Changes by: Sigurd Nes <sigurdne> 07/05/19 20:52:10
Modified files:
inc : class.botts.inc.php class.uitts.inc.php
templates/base : config.tpl tts.xsl
Log message:
upload files to tickets
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/property/inc/class.botts.inc.php?cvsroot=phpgroupware&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/property/inc/class.uitts.inc.php?cvsroot=phpgroupware&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/property/templates/base/config.tpl?cvsroot=phpgroupware&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/property/templates/base/tts.xsl?cvsroot=phpgroupware&r1=1.17&r2=1.18
Patches:
Index: inc/class.botts.inc.php
===================================================================
RCS file: /sources/phpgroupware/property/inc/class.botts.inc.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- inc/class.botts.inc.php 24 Apr 2007 08:04:10 -0000 1.33
+++ inc/class.botts.inc.php 19 May 2007 20:52:10 -0000 1.34
@@ -24,7 +24,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage helpdesk
- * @version $Id: class.botts.inc.php,v 1.33 2007/04/24 08:04:10 sigurdne
Exp $
+ * @version $Id: class.botts.inc.php,v 1.34 2007/05/19 20:52:10 sigurdne
Exp $
*/
/**
@@ -80,6 +80,10 @@
$this->config->read_repository();
$this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
if ($session)
{
$this->read_sessiondata();
@@ -393,6 +397,25 @@
$ticket['user_lid']=$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
$ticket['category_name']=ucfirst($this->get_category_name($ticket['cat_id']));
+ $this->vfs->override_acl = 1;
+
+ $ticket['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. SEP . 'fmticket' .
SEP . $id,
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ $j = count($ticket['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$ticket['files'][$i]['file_name']=urlencode($ticket['files'][$i]['name']);
+ }
+
+
+ if(!$ticket['files'][0]['file_id'])
+ {
+ unset($ticket['files']);
+ }
return $ticket;
}
@@ -782,5 +805,116 @@
{
$this->so->delete($id);
}
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'fmticket',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'fmticket',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'fmticket');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP. 'fmticket');
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($id='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'fmticket',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'fmticket',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'fmticket');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'fmticket');
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'fmticket' . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'fmticket' . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'fmticket' . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'fmticket' . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+ function delete_file($values,$id='')
+ {
+ for ($i=0;$i<count($values['delete_file']);$i++)
+ {
+ $file = $this->fakebase. SEP . 'fmticket' . SEP
. $id . SEP . $values['delete_file'][$i];
+
+ if($this->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->rm (array(
+ 'string' => $file,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'fmticket' . SEP . $id . SEP
.$values['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'fmticket' . SEP . $id . SEP .
$values['delete_file'][$i]);
+ }
+ $this->vfs->override_acl = 0;
+ }
+ }
+ return $receipt;
+ }
}
?>
Index: inc/class.uitts.inc.php
===================================================================
RCS file: /sources/phpgroupware/property/inc/class.uitts.inc.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- inc/class.uitts.inc.php 29 Mar 2007 08:48:58 -0000 1.56
+++ inc/class.uitts.inc.php 19 May 2007 20:52:10 -0000 1.57
@@ -24,7 +24,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage helpdesk
- * @version $Id: class.uitts.inc.php,v 1.56 2007/03/29 08:48:58 sigurdne
Exp $
+ * @version $Id: class.uitts.inc.php,v 1.57 2007/05/19 20:52:10 sigurdne
Exp $
*/
/**
@@ -44,7 +44,8 @@
'add2' => True,
'delete' => True,
'excel' => True,
- 'excel2' => True
+ 'excel2' => True,
+ 'view_file' => True
);
function property_uitts()
@@ -86,6 +87,7 @@
$this->allrows =
$this->bo->allrows;
$this->start_date =
$this->bo->start_date;
$this->end_date =
$this->bo->end_date;
+ $this->fakebase =
$this->bo->fakebase;
$this->menu->sub ='ticket';
}
@@ -1024,7 +1026,39 @@
if(!isset($receipt['error']))
{
+ $receipt =
$this->bo->create_home_dir($receipt);
+
$receipt = $this->bo->add($values);
+
+ $values['file_name']=str_replace('
','_',$_FILES['file']['name']);
+
+ if($values['file_name'])
+ {
+ $to_file = $this->fakebase. SEP
. 'fmticket' . SEP . $receipt['id'] . SEP . $values['file_name'];
+
+
if($this->bo->vfs->file_exists(array(
+ 'string' =>
$to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+ else
+ {
+
$this->bo->create_document_dir($receipt['id']);
+
$this->bo->vfs->override_acl = 1;
+
+ if(!$this->bo->vfs->cp
(array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' =>
$to_file,
+ 'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+
$this->bo->vfs->override_acl = 0;
+ }
+ }
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts','');
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
$this->currentapp.'.uitts.index'));
@@ -1108,7 +1142,6 @@
break;
}
-
$msgbox_data =
(isset($receipt)?$this->bocommon->msgbox_data($receipt):'');
$GLOBALS['phpgw']->js->validate_file('dateformat','dateformat',$this->currentapp);
@@ -1167,6 +1200,7 @@
'lang_mailnotification' =>
lang('Send e-mail'),
'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
'pref_send_mail' =>
(isset($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'])?$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification']:''),
+ 'fileupload' =>
(isset($this->bo->config->config_data['fmttsfileupload'])?$this->bo->config->config_data['fmttsfileupload']:''),
);
//_debug_array($data);
@@ -1438,6 +1472,39 @@
$so2 =
CreateObject($this->currentapp.'.sotts2');
$so2->acl_location = $this->acl_location;
$receipt = $so2->update_ticket($values,$id);
+ if(isset($values['delete_file']) &&
is_array($values['delete_file']))
+ {
+ $this->bo->delete_file($values,$id);
+ }
+
+ $values['file_name']=str_replace('
','_',$_FILES['file']['name']);
+
+ if($values['file_name'])
+ {
+ $to_file = $this->fakebase. SEP .
'fmticket' . SEP . $id . SEP . $values['file_name'];
+
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+ else
+ {
+
$this->bo->create_document_dir($id);
+ $this->bo->vfs->override_acl =
1;
+
+ if(!$this->bo->vfs->cp (array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' => $to_file,
+ 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+ $this->bo->vfs->override_acl =
0;
+ }
+ }
}
$ticket = $this->bo->read_single($id);
@@ -1609,6 +1676,12 @@
$GLOBALS['phpgw']->js->validate_file('dateformat','dateformat',$this->currentapp);
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.view_file',
+ 'id' => $id
+ );
+
$data = array
(
'value_origin' =>
(isset($ticket['origin'])?$ticket['origin']:''),
@@ -1710,6 +1783,18 @@
'lang_mailnotification' =>
lang('Send e-mail'),
'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
'pref_send_mail' =>
(isset($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'])?$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification']:''),
+ 'fileupload' =>
(isset($this->bo->config->config_data['fmttsfileupload'])?$this->bo->config->config_data['fmttsfileupload']:''),
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=>
(isset($this->bo->config->config_data['files_url'])?$this->bo->config->config_data['files_url']:''),
+ 'files'
=> $ticket['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_delete_file'
=> lang('Delete file'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+ 'lang_delete_file_statustext' => lang('Check
to delete file'),
+ 'lang_upload_file'
=> lang('Upload file'),
+ 'lang_file_statustext' =>
lang('Select file to upload'),
+
);
//_debug_array($data);
$appname =
lang('helpdesk');
@@ -1953,5 +2038,46 @@
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view2' => $data));
}
+
+ function view_file()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
$this->currentapp.'.uilocation.stop', 'perm'=>1, 'acl_location'=>
$this->acl_location));
+ }
+
+ $file_name =
urldecode(get_var('file_name',array('POST','GET')));
+ $id = get_var('id',array('POST','GET'));
+
+ $file = $this->fakebase. SEP . 'fmticket' . SEP . $id .
SEP . $file_name;
+
+//echo 'file: ' . $file . '<br>';
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+
+ }
+ }
}
?>
Index: templates/base/config.tpl
===================================================================
RCS file: /sources/phpgroupware/property/templates/base/config.tpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- templates/base/config.tpl 20 Jun 2006 10:54:17 -0000 1.5
+++ templates/base/config.tpl 19 May 2007 20:52:10 -0000 1.6
@@ -99,6 +99,15 @@
</tr>
-->
<tr class="row_off">
+ <td>{lang_TTS_file_upload}:</td>
+ <td>
+ <select name="newsettings[fmttsfileupload]">
+ <option value="" {selected_fmttsfileupload_}>NO</option>
+ <option value="1" {selected_fmttsfileupload_1}>YES</option>
+ </select>
+ </td>
+ </tr>
+ <tr class="row_off">
<td>{lang_Mail_Notification_(TTS)}:</td>
<td>
<select name="newsettings[mailnotification]">
Index: templates/base/tts.xsl
===================================================================
RCS file: /sources/phpgroupware/property/templates/base/tts.xsl,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- templates/base/tts.xsl 22 Dec 2006 15:02:12 -0000 1.17
+++ templates/base/tts.xsl 19 May 2007 20:52:10 -0000 1.18
@@ -1,4 +1,4 @@
-<!-- $Id: tts.xsl,v 1.17 2006/12/22 15:02:12 sigurdne Exp $ -->
+<!-- $Id: tts.xsl,v 1.18 2007/05/19 20:52:10 sigurdne Exp $ -->
<xsl:template name="app_data">
<xsl:choose>
@@ -394,7 +394,7 @@
</xsl:when>
</xsl:choose>
<xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form name="form" method="post" action="{$form_action}">
+ <form ENCTYPE="multipart/form-data" name="form"
method="post" action="{$form_action}">
<xsl:call-template name="location_form"/>
<tr>
@@ -514,6 +514,26 @@
</td>
</tr>
+
+ <xsl:choose>
+ <xsl:when test="fileupload = 1">
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_upload_file"/>
+ </td>
+ <td>
+ <input type="file"
name="file" size="40" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_file_statustext"/>
+
<xsl:text>'; return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
<tr height="50">
<td>
<xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
@@ -734,7 +754,7 @@
</xsl:when>
</xsl:choose>
<xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form name="form" method="post" action="{$form_action}">
+ <form ENCTYPE="multipart/form-data" name="form"
method="post" action="{$form_action}">
<tr class="th">
<td class="th_text" valign="top">
<xsl:value-of select="lang_ticket"/>
@@ -1012,6 +1032,87 @@
</td>
</tr>
+
+ <xsl:choose>
+ <xsl:when test="files!=''">
+ <tr>
+ <td align="left" valign="top">
+ <xsl:value-of select="//lang_files"/>
+ </td>
+ <td>
+ <table>
+ <tr class="th">
+ <td class="th_text" width="85%"
align="left">
+ <xsl:value-of
select="lang_filename"/>
+ </td>
+ <td class="th_text" width="15%"
align="center">
+ <xsl:value-of
select="lang_delete_file"/>
+ </td>
+ </tr>
+ <xsl:for-each select="files" >
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when
test="@class">
+
<xsl:value-of select="@class"/>
+ </xsl:when>
+ <xsl:when
test="position() mod 2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td align="left">
+ <xsl:choose>
+ <xsl:when
test="//link_to_files!=''">
+ <xsl:variable
name="link_to_file"><xsl:value-of select="//link_to_files"/>/<xsl:value-of
select="directory"/>/<xsl:value-of select="file_name"/></xsl:variable>
+ <a
href="{$link_to_file}" target="_blank"
onMouseover="window.status='{//lang_view_file_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of select="name"/></a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable
name="link_view_file"><xsl:value-of
select="//link_view_file"/>&file_name=<xsl:value-of
select="file_name"/></xsl:variable>
+ <a
href="{$link_view_file}" target="_blank"
onMouseover="window.status='{//lang_view_file_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of select="name"/></a>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text> </xsl:text>
+ </td>
+ <td align="center">
+ <input type="checkbox"
name="values[delete_file][]" value="{name}"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="//lang_delete_file_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="fileupload = 1">
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_upload_file"/>
+ </td>
+ <td>
+ <input type="file"
name="file" size="40" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_file_statustext"/>
+
<xsl:text>'; return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
<tr height="50">
<td>
<xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property inc/class.botts.inc.php inc/class.uitt...,
Sigurd Nes <=