function __construct($p = array())
 {
     $this->user_id = oseGetValue($p, 'user_id');
     if (empty($this->user_id)) {
         $user = oseCall('user2')->instance();
         $this->user_id = $user->get('id');
     }
     $p = oseSetValue($p, 'user_id', $this->user_id);
     $this->set('p', $p);
 }
Exemple #2
0
 public static function load($app = 'msc', $config_type = null, $type = 'array')
 {
     static $sApp, $objs;
     if ($sApp != $app) {
         $db = oseDB::instance();
         $where = array();
         if (!empty($config_type)) {
             if (is_array($config_type)) {
                 $values = array();
                 foreach ($config_type as $configType) {
                     $values[] = $db->Quote($configType);
                 }
             } else {
             }
         }
         $where[] = '`app`=' . $db->Quote($app);
         $where = oseDB::implodeWhere($where);
         $query = " SELECT * FROM `#__ose_app_config` " . $where;
         $db->setQuery($query);
         $objs = oseDB::loadList('obj');
     }
     if ($type == 'array') {
         $config = array();
     } else {
         $config = new stdClass();
     }
     if (empty($objs)) {
         return false;
     }
     foreach ($objs as $obj) {
         if (is_array($config_type)) {
             if (!in_array($obj->type, $config_type)) {
                 continue;
             }
         } else {
             if ($obj->type != $config_type && !empty($config_type)) {
                 continue;
             }
         }
         if (is_float($obj->value)) {
             $config = oseSetValue($config, $obj->key, (double) $obj->value);
         } elseif (is_numeric($obj->value)) {
             $config = oseSetValue($config, $obj->key, (int) $obj->value);
         } else {
             $config = oseSetValue($config, $obj->key, $obj->value);
         }
     }
     $config = oseSetValue($config, 'id', 1);
     $sApp = $app;
     return $config;
 }
Exemple #3
0
 static function setValue(&$item, $key, $default = null)
 {
     return oseSetValue($item, $key, $default);
 }
Exemple #4
0
 function __construct($info = array())
 {
     $params = oseGetValue($info, 'params');
     if (!empty($info)) {
         if (empty($params)) {
             $info = oseSetValue($info, 'params', '{}');
         }
         foreach ($info as $key => $value) {
             if (in_array($key, array('params', 'data', 'transactions'))) {
                 if (!is_array($value) && !is_object($value) && is_string($value)) {
                     if ($key == 'data') {
                         $this->set($key, oseJson::decode($value, true));
                     } else {
                         $this->set($key, oseJson::decode($value));
                     }
                 } else {
                     if (empty($value)) {
                         $this->set($key, $this->get($key));
                     } else {
                         $this->set($key, $value);
                     }
                 }
             } else {
                 $this->set($key, $value);
             }
         }
     } else {
         if (empty($params)) {
             $params = new stdClass();
             $this->set('params', $params);
         }
     }
 }
Exemple #5
0
 function load($data)
 {
     $i = 1;
     foreach ($data as $key => $item) {
         $ordering = oseGetValue($item, 'ordering', false);
         if (!$ordering) {
             if ($ordering != $i) {
                 $item = oseSetValue($item, 'ordering', $i);
                 $data[$key] = $item;
             }
         } else {
             $item = oseSetValue($item, 'ordering', $i);
             $data[$key] = $item;
         }
         $i++;
     }
     $this->data = $data;
 }