Fix Attach model store() and storeFile()
This commit is contained in:
parent
15b0a7a4d8
commit
906b7841d4
|
@ -6,12 +6,9 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Attach;
|
use Friendica\Model\Attach;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Util\DateTimeFormat;
|
|
||||||
use Friendica\Util\Mimetype;
|
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
function wall_attach_post(App $a) {
|
function wall_attach_post(App $a) {
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
namespace Friendica\Model;
|
namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\BaseObject;
|
use Friendica\BaseObject;
|
||||||
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\StorageManager;
|
use Friendica\Core\StorageManager;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\Util\Security;
|
use Friendica\Util\Security;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
use Friendica\Util\Mimetype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle attach dabatase table
|
* Class to handle attach dabatase table
|
||||||
|
@ -156,8 +158,8 @@ class Attach extends BaseObject
|
||||||
* @param string $data Binary data
|
* @param string $data Binary data
|
||||||
* @param integer $uid User ID
|
* @param integer $uid User ID
|
||||||
* @param string $filename Filename
|
* @param string $filename Filename
|
||||||
* @param string $filetype Mimetype. optional
|
* @param string $filetype Mimetype. optional, default = ''
|
||||||
* @param integer $filesize File size in bytes. optional
|
* @param integer $filesize File size in bytes. optional, default = null
|
||||||
* @param string $allow_cid Permissions, allowed contacts. optional, default = ''
|
* @param string $allow_cid Permissions, allowed contacts. optional, default = ''
|
||||||
* @param string $allow_gid Permissions, allowed groups. optional, default = ''
|
* @param string $allow_gid Permissions, allowed groups. optional, default = ''
|
||||||
* @param string $deny_cid Permissions, denied contacts.optional, default = ''
|
* @param string $deny_cid Permissions, denied contacts.optional, default = ''
|
||||||
|
@ -165,13 +167,13 @@ class Attach extends BaseObject
|
||||||
*
|
*
|
||||||
* @return boolean/integer Row id on success, False on errors
|
* @return boolean/integer Row id on success, False on errors
|
||||||
*/
|
*/
|
||||||
public function store($data, $uid, $filename, $filetype = '' , $filesize = -1, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
|
public function store($data, $uid, $filename, $filetype = '' , $filesize = null, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
|
||||||
{
|
{
|
||||||
if ($filetype === '') {
|
if ($filetype === '') {
|
||||||
$filetype = Mimetype::getContentType($filename);
|
$filetype = Mimetype::getContentType($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filesize < 0) {
|
if (is_null($filesize)) {
|
||||||
$filesize = strlen($data);
|
$filesize = strlen($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +208,7 @@ class Attach extends BaseObject
|
||||||
if ($r === true) {
|
if ($r === true) {
|
||||||
return DBA::lastInsertId();
|
return DBA::lastInsertId();
|
||||||
}
|
}
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,7 +224,7 @@ class Attach extends BaseObject
|
||||||
|
|
||||||
$data = @file_get_contents($src);
|
$data = @file_get_contents($src);
|
||||||
|
|
||||||
return self::store($data, $uid, $filename, '', '', $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
return self::store($data, $uid, $filename, '', null, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue