mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 12:20:44 +02:00
model/pref handlers optimization
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
* e107 Base Model
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2009-09-03 22:27:32 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2009-09-04 15:27:28 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -531,14 +531,17 @@ class e_model
|
||||
return $this;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
//TODO - sanitize method based on validation rules OR _FIELD_TYPES array?
|
||||
if($sanitize)
|
||||
{
|
||||
$src_data = $tp->toDB($src_data);
|
||||
$src_data = e107::getParser()->toDB($src_data);
|
||||
}
|
||||
|
||||
$this->setData($src_data, null, $strict);
|
||||
foreach ($src_data as $key => $value)
|
||||
{
|
||||
$this->setData($key, $value, $strict);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1043,6 +1046,6 @@ class e_model
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString((func_get_arg(0) === true));
|
||||
return $this->toString((@func_get_arg(0) === true));
|
||||
}
|
||||
}
|
@@ -9,8 +9,8 @@
|
||||
* e107 Preference Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $
|
||||
* $Revision: 1.17 $
|
||||
* $Date: 2009-09-03 14:15:36 $
|
||||
* $Revision: 1.18 $
|
||||
* $Date: 2009-09-04 15:27:28 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
@@ -130,6 +130,14 @@ class e_pref extends e_model
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
//Merge only allowed
|
||||
if(is_array($pref_name))
|
||||
{
|
||||
$this->mergeData($pref_name, false, false, false);
|
||||
return $this;
|
||||
}
|
||||
|
||||
parent::setData($pref_name, $value, false);
|
||||
|
||||
//BC
|
||||
@@ -142,12 +150,13 @@ class e_pref extends e_model
|
||||
|
||||
/**
|
||||
* Advanced setter - $pref_name is parsed (multidimensional arrays support)
|
||||
* Object data reseting is not allowed, adding new pref is not allowed
|
||||
* Object data reseting is not allowed, adding new pref is controlled by $strict parameter
|
||||
* @param string|array $pref_name
|
||||
* @param mixed $value
|
||||
* @param boolean $strict true - update only, false - same as setPref()
|
||||
* @return e_pref
|
||||
*/
|
||||
public function updatePref($pref_name, $value = null)
|
||||
public function updatePref($pref_name, $value = null, $strict = false)
|
||||
{
|
||||
global $pref;
|
||||
//object reset not allowed, adding new pref is not allowed
|
||||
@@ -155,7 +164,15 @@ class e_pref extends e_model
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
parent::setData($pref_name, $value, true);
|
||||
|
||||
//Merge only allowed
|
||||
if(is_array($pref_name))
|
||||
{
|
||||
$this->mergeData($pref_name, $strict, false, false);
|
||||
return $this;
|
||||
}
|
||||
|
||||
parent::setData($pref_name, $value, $strict);
|
||||
|
||||
//BC
|
||||
if($this->alias === 'core')
|
||||
|
Reference in New Issue
Block a user