Beispiel #1
0
 public function setAuthToken($user_id, $auth_token, $type = null, $subj = null)
 {
     if (!$type) {
         $type = cmsRequest::getDeviceType();
     }
     return $this->insert('{users}_auth_tokens', array('ip' => sprintf('%u', ip2long(cmsUser::getIp())), 'access_type' => cmsModel::arrayToYaml(array('type' => $type, 'subj' => $subj)), 'auth_token' => $auth_token, 'user_id' => $user_id));
 }
Beispiel #2
0
 /**
  * Подготавливает значение $value поля $field для вставки в запрос
  * @param string $field
  * @param string $value
  * @return string
  */
 public function prepareValue($field, $value)
 {
     // если значение поля - массив,
     // то преобразуем его в YAML
     if (is_array($value)) {
         $value = "'" . $this->escape(cmsModel::arrayToYaml($value)) . "'";
     } else {
         // если это поле даты публикации и оно не установлено,
         // то используем текущее время
         if (strpos($field, 'date_') === 0 && $value === false) {
             $value = "NULL";
         } else {
             if (strpos($field, 'date_') === 0 && ($value == '' || is_null($value))) {
                 $value = "CURRENT_TIMESTAMP";
             } else {
                 // если это поле булево,
                 // то преобразуем его в число
                 if (is_bool($value)) {
                     $value = (int) $value;
                 } else {
                     // если значение поля не задано,
                     // то запишем в базу NULL
                     if ($value === '' || is_null($value)) {
                         $value = 'NULL';
                     } else {
                         $value = $this->escape(trim($value));
                         $value = "'{$value}'";
                     }
                 }
             }
         }
     }
     return $value;
 }
Beispiel #3
0
 public function updateMenuItem($id, $item)
 {
     if (is_array($item['options'])) {
         $item['options'] = cmsModel::arrayToYaml($item['options']);
     }
     cmsCache::getInstance()->clean("menu.items");
     return $this->update('menu_items', $id, $item);
 }
Beispiel #4
0
 public function saveOptions($options)
 {
     $options_file = cmsConfig::get('root_path') . "system/config/theme_{$this->name}.yml";
     if (!is_writable($options_file)) {
         return false;
     }
     $options_yaml = cmsModel::arrayToYaml($options);
     return @file_put_contents($options_file, $options_yaml);
 }
Beispiel #5
0
 public function saveOptions($options)
 {
     $options_file = $this->site_config->root_path . "system/config/theme_{$this->name}.yml";
     if (file_exists($options_file)) {
         if (!is_writable($options_file)) {
             return false;
         }
     } else {
         if (!is_writable(dirname($options_file))) {
             return false;
         }
     }
     $options_yaml = cmsModel::arrayToYaml($options);
     $success = file_put_contents($options_file, $options_yaml);
     if ($success && function_exists('opcache_invalidate')) {
         @opcache_invalidate($options_file, true);
     }
     return $success;
 }