X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FEvents.php;h=e8682ac8f2cadde618b6512710cb4b1c744fc85e;hp=7c4b14d5a3ed8cd436ee2412d59c050bfd3606ec;hb=HEAD;hpb=7c956b1ea74995c6e42e3851cf35788fecbb40c3 diff --git a/DataObjects/Events.php b/DataObjects/Events.php index 7c4b14d5..a04484c4 100644 --- a/DataObjects/Events.php +++ b/DataObjects/Events.php @@ -475,11 +475,31 @@ class Pman_Core_DataObjects_Events extends DB_DataObject 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) { $ff = HTML_FlexyFramework::get(); - if ($user == false) { + if ($user === false) { if (function_exists('posix_getpwuid')) { $uinfo = posix_getpwuid( posix_getuid () ); @@ -536,9 +556,10 @@ class Pman_Core_DataObjects_Events extends DB_DataObject $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; @@ -646,11 +667,11 @@ class Pman_Core_DataObjects_Events extends DB_DataObject $date = date('/Y/m/d/', strtotime($this->event_when)); $file = $logdir. $date. $this->id . ".json"; - if (!file_exists(dirname($file))) { + if (!file_exists($file)) { // try looking www-dir.. $file = $this->logDir('www-data'). $date. $this->id . ".json"; - if (!file_exists(dirname($file))) { + if (!file_exists($file)) { return false; } }