projects
/
Pman.Core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5e27d5c
)
Fix #7109 - add download event
author
Alan
<alan@roojs.com>
Wed, 9 Feb 2022 06:53:21 +0000
(14:53 +0800)
committer
Alan
<alan@roojs.com>
Wed, 9 Feb 2022 06:53:21 +0000
(14:53 +0800)
DataObjects/Events.php
patch
|
blob
|
history
GnumericToExcel.php
patch
|
blob
|
history
diff --git
a/DataObjects/Events.php
b/DataObjects/Events.php
index
a5f48db
..
a04484c
100644
(file)
--- a/
DataObjects/Events.php
+++ b/
DataObjects/Events.php
@@
-475,6
+475,26
@@
class Pman_Core_DataObjects_Events extends DB_DataObject
static function writeEventLogExtra($data) {
self::$extra_data = $data;
}
static function writeEventLogExtra($data) {
self::$extra_data = $data;
}
+ static $files = array();
+
+ /**
+ * Add a file to the output log
+ * this needs to be called before addEvent, and the data format should be the same as $_FILES
+ * eg.
+ *
+ * DB_DataObject::factory('Events')->addFile(array(
+ * 'tmp_name' => real file location
+ * 'name' => real file name
+ * 'type' => mimetype
+ * 'size' => filesize
+ *
+ * ))
+ *
+ */
+ function addFile($data)
+ {
+ self::$files[] = $data;
+ }
function logDir($user = false)
{
function logDir($user = false)
{
@@
-536,9
+556,10
@@
class Pman_Core_DataObjects_Events extends DB_DataObject
$i=0;
$files = array();
$i=0;
$files = array();
+
- $i = 0;
- foreach (
$_FILES
as $k=>$f){
+
+ foreach (
array_merge($_FILES, self::$files)
as $k=>$f){
// does not handle any other file[] arrary very well..
if (empty($f['tmp_name']) || !file_exists($f['tmp_name'])) {
continue;
// does not handle any other file[] arrary very well..
if (empty($f['tmp_name']) || !file_exists($f['tmp_name'])) {
continue;
diff --git
a/GnumericToExcel.php
b/GnumericToExcel.php
index
5ce821d
..
5a23e4a
100644
(file)
--- a/
GnumericToExcel.php
+++ b/
GnumericToExcel.php
@@
-119,18
+119,23
@@
class Pman_Core_GnumericToExcel extends Pman
$mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
$ext = "xlsx";
}
$mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
$ext = "xlsx";
}
-
-
-
-
-
-
- // unlink($srcTmp);
if (empty($fname)) {
$fname = basename($targetTmp);
}
$fname .= preg_match('/\.' . $ext . '/i', $fname) ? '' : ('.' . $ext); // make sure it ends in xls..
if (empty($fname)) {
$fname = basename($targetTmp);
}
$fname .= preg_match('/\.' . $ext . '/i', $fname) ? '' : ('.' . $ext); // make sure it ends in xls..
+
+ DB_DataObject::factory('Events')->addFile(array(
+ 'tmp_name' => $targetTmp,
+ 'name' => $fname,
+ 'type' => $mime,
+ 'size' => filesize($targetTmp)
+ ));
+
+ $this->addEvent("DOWNLOAD", false, $fname );
+
+ // unlink($srcTmp);
+
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
header('Content-length: '. filesize($targetTmp));
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
header('Content-length: '. filesize($targetTmp));