mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Added e107::serialize() and e107::unserialize() (static alias of e107::getArrayStorage()->read/write() functions)
This commit is contained in:
@@ -321,7 +321,7 @@ class e_array {
|
|||||||
* @param string $ArrayData
|
* @param string $ArrayData
|
||||||
* @return array stored data
|
* @return array stored data
|
||||||
*/
|
*/
|
||||||
public function read($ArrayData)
|
public function unserialize($ArrayData)
|
||||||
{
|
{
|
||||||
if ($ArrayData == ""){
|
if ($ArrayData == ""){
|
||||||
return false;
|
return false;
|
||||||
@@ -353,7 +353,7 @@ class e_array {
|
|||||||
* @param bool $AddSlashes default true, add slashes for db storage, else false
|
* @param bool $AddSlashes default true, add slashes for db storage, else false
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function write($ArrayData, $AddSlashes = true)
|
public function serialize($ArrayData, $AddSlashes = false)
|
||||||
{
|
{
|
||||||
if (!is_array($ArrayData)) {
|
if (!is_array($ArrayData)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -374,7 +374,13 @@ class e_array {
|
|||||||
*/
|
*/
|
||||||
function WriteArray($ArrayData, $AddSlashes = true) {
|
function WriteArray($ArrayData, $AddSlashes = true) {
|
||||||
|
|
||||||
return $this->write($ArrayData, $AddSlashes);
|
return $this->serialize($ArrayData, $AddSlashes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function write($ArrayData, $AddSlashes = true) {
|
||||||
|
|
||||||
|
return $this->serialize($ArrayData, $AddSlashes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +393,12 @@ class e_array {
|
|||||||
*/
|
*/
|
||||||
function ReadArray($ArrayData)
|
function ReadArray($ArrayData)
|
||||||
{
|
{
|
||||||
return $this->read($ArrayData);
|
return $this->unserialize($ArrayData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function read($ArrayData)
|
||||||
|
{
|
||||||
|
return $this->unserialize($ArrayData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1405,6 +1405,29 @@ class e107
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string containg exported array data. - preferred.
|
||||||
|
*
|
||||||
|
* @param array $ArrayData array to be stored
|
||||||
|
* @param bool $AddSlashes default false, add slashes for db storage, else false
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function serialize($ArrayData, $AddSlashes = false)
|
||||||
|
{
|
||||||
|
return self::getArrayStorage()->serialize($ArrayData, $AddSlashes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array from stored array data.
|
||||||
|
*
|
||||||
|
* @param string $ArrayData
|
||||||
|
* @return array stored data
|
||||||
|
*/
|
||||||
|
public static function unserialize($ArrayData)
|
||||||
|
{
|
||||||
|
return self::getArrayStorage()->unserialize($ArrayData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve current user model object.
|
* Retrieve current user model object.
|
||||||
|
@@ -791,7 +791,7 @@ class e_db_mysql
|
|||||||
{
|
{
|
||||||
if(!isset($arg['_FIELD_TYPES']['_DEFAULT']))
|
if(!isset($arg['_FIELD_TYPES']['_DEFAULT']))
|
||||||
{
|
{
|
||||||
$arg['_FIELD_TYPES']['_DEFAULT'] = 'todb';
|
$arg['_FIELD_TYPES']['_DEFAULT'] = 'string';
|
||||||
}
|
}
|
||||||
$fieldTypes = $arg['_FIELD_TYPES'];
|
$fieldTypes = $arg['_FIELD_TYPES'];
|
||||||
unset($arg['_FIELD_TYPES']);
|
unset($arg['_FIELD_TYPES']);
|
||||||
|
@@ -164,7 +164,7 @@ class user_class
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userCache = e107::getArrayStorage()->write($this->class_tree, FALSE);
|
$userCache = e107::serialize($this->class_tree, FALSE);
|
||||||
$e107->ecache->set_sys(UC_CACHE_TAG,$userCache);
|
$e107->ecache->set_sys(UC_CACHE_TAG,$userCache);
|
||||||
unset($userCache);
|
unset($userCache);
|
||||||
}
|
}
|
||||||
|
@@ -168,7 +168,7 @@ class e107forum
|
|||||||
$fid = intval($data['dl']);
|
$fid = intval($data['dl']);
|
||||||
|
|
||||||
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.intval($data['id']));
|
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.intval($data['id']));
|
||||||
$attach = e107::getArrayStorage()->read($array['post_attachments']);
|
$attach = e107::serialize($array['post_attachments']);
|
||||||
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$fid]);
|
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$fid]);
|
||||||
|
|
||||||
e107::getFile()->send($file);
|
e107::getFile()->send($file);
|
||||||
|
@@ -256,11 +256,11 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
|
|||||||
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
||||||
|
|
||||||
$type = $ur['type'];
|
$type = $ur['type'];
|
||||||
$newValues[$type][] = basename($ur['fname']);
|
$newValues[$type][] = $ur['fname'];
|
||||||
// $attachments[] = $_tmp;
|
// $attachments[] = $_tmp;
|
||||||
}
|
}
|
||||||
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array'; //XXX Horrible "FIELD_TYPES" idea.
|
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array'; //XXX Horrible "FIELD_TYPES" idea.
|
||||||
$postInfo['post_attachments'] = e107::getArrayStorage()->write($newValues); //FIXME
|
$postInfo['post_attachments'] = e107::serialize($newValues); //FIXME
|
||||||
}
|
}
|
||||||
// var_dump($uploadResult);
|
// var_dump($uploadResult);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user