/** * Gets a user preference item's value * * @param string $key * @param string $for * * @return mixed */ static function get($key, $for = null) { global $Database, $signedIn, $currentUser; if (empty($for) && $signedIn) { $for = $currentUser->id; } if (isset(Users::$_PREF_CACHE[$for][$key])) { return Users::$_PREF_CACHE[$for][$key]; } $default = null; if (isset(static::$_defaults[$key])) { $default = static::$_defaults[$key]; } if (!$signedIn) { return $default; } $Database->where('user', $for); return Users::$_PREF_CACHE[$for][$key] = parent::get($key, $default); }
/** * This method returns all the keys of the global settings in an array. * Returns an array of keys if found. * Returns false if no keys. * * @return array | boolean */ public static function getKeys() { $dependency = new CDbCacheDependency('SELECT MAX(updated_time) FROM global_settings'); $criteria = new CDbCriteria(); $criteria->select = 'label'; $models = GlobalSettings::model()->cache(1000, $dependency)->findAll($criteria); if ($models) { $result = array(); foreach ($models as $model) { $result[] = $model->label; } return $result; } else { return false; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = GlobalSettings::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionGlobalSettings() { if (!isset($_SESSION['filemanager'])) { $_SESSION['filemanager'] = TRUE; } $_SESSION['currentFolder'] = 'globalSettings/'; $model = GlobalSettings::listGlobalSettings(); $types = GlobalSettings::getTypes(); if (isset($_POST['GlobalSettings'])) { $validateArray = array('formatDate', 'pageTitle', 'adminEmail_username', 'adminEmail_password', 'adminEmail_server', 'metaDescription', 'metaKeywords', 'commentType_type', 'commentType_pageSize'); foreach ($model->attributes as $attribute => $arr) { if (is_array($arr)) { foreach ($arr as $key => $val) { $model[$attribute . '_' . $key] = isset($_POST['GlobalSettings'][$attribute . '_' . $key]) ? preg_replace('/"/', '\'', $_POST['GlobalSettings'][$attribute . '_' . $key]) : $model[$attribute . '_' . $key]; } } elseif (is_string($arr) && preg_match('/^((?!_).)*$/s', $attribute)) { $model->{$attribute} = isset($_POST['GlobalSettings'][$attribute]) ? preg_replace('/"/', '\'', strip_tags($_POST['GlobalSettings'][$attribute])) : NULL; } } if (!empty($model->adminEmail_password)) { $key = Yii::app()->extraFunctions->getMCKey(); $model->adminEmail_password = Yii::app()->extraFunctions->mcEncrypt($_POST['GlobalSettings']['adminEmail_password'], $key); } else { $model->adminEmail_password = $model->adminEmail['password']; } if ($model->maintenance_status === '1') { array_push($validateArray, 'maintenance_status', 'maintenance_message'); } else { $model->maintenance_message = $model->maintenance['message']; } if ($model->facebook_status === '1') { array_push($validateArray, 'facebook_status', 'facebook_link'); } else { $model->facebook_link = $model->facebook['link']; } if ($model->google_status === '1') { array_push($validateArray, 'google_status', 'google_link'); } else { $model->google_link = $model->google['link']; } if ($model->skype_status === '1') { array_push($validateArray, 'skype_status', 'skype_nickname'); } else { $model->skype_nickname = $model->skype['nickname']; } if ($model->redisCache_status === '1') { //// Yii::app()->cache->createConnection = true; // $checkConnection = Yii::app()->cache->isConnected(); //// Yii::app()->cache->createConnection = FALSE; // if ($checkConnection !== TRUE) // { // $model->redisCache_status = '0'; // $model->redisCache_expiredCache = $model->redisCache['expiredCache']; // Yii::app()->user->setFlash('cacheError', Yii::t('config', Yii::app()->cache->errorMessage['errorDescription'])); // } else // { // array_push($validateArray, 'redisCache_status', 'redisCache_expiredCache'); // } array_push($validateArray, 'redisCache_status', 'redisCache_expiredCache'); } else { $model->redisCache_expiredCache = $model->redisCache['expiredCache']; } if ($model->commentType_type === 'facebook') { array_push($validateArray, 'commentType_appID'); $model->commentType_maxTreeLevel = $model->commentType['maxTreeLevel']; } else { array_push($validateArray, 'commentType_maxTreeLevel'); $model->commentType_appID = $model->commentType['appID']; } if ($model->validate($validateArray)) { $result = GlobalSettings::saveSettings($model); if ($result) { Yii::app()->user->setFlash('success', Yii::t('config', 'Update global configuration successfully.')); } else { Yii::app()->user->setFlash('error', Yii::t('config', 'Update global configuration failed. Please try it later.')); } $this->redirect('/' . backend . '/config/globalSettings'); } } $this->render(strtolower($this->action->Id), array('model' => $model, 'types' => $types)); // "maintenance" => array( // "status" => "1", // "message" => "<table width=\"100%\"> //<tbody> //<tr> //<td><img src=\"/images/globalSettings/maintenance.jpg/\" alt=\"\" width=\"\" height=\"\" /></td> //<td>Sorry! Our website is temporarily down for maintenance. Please visit later!</td> //</tr> //</tbody> //</table>"; }
* @package Esform * @version $Id: app.controller.php 470 2007-07-08 17:48:26Z ichii386 $ */ /** アプリケーションベースディレクトリ */ define('BASE', dirname(dirname(__FILE__))); /** include_pathの設定(アプリケーションディレクトリを追加) */ $cnf = 'app/data/config.cgi'; $app = BASE . "/app"; $lib = BASE . "/lib"; $tmp = BASE . '/tmp'; ini_set('include_path', implode(PATH_SEPARATOR, array($app, $lib, ini_get('include_path')))); if (!is_writable($tmp)) { print 'tmpディレクトリに書き込み権限がありません。'; exit; } GlobalSettings::setup(); /** アプリケーションライブラリのインクルード */ require_once 'Ethna/Ethna.php'; require_once 'Esform_Error.php'; require_once 'Esform_ActionClass.php'; require_once 'Esform_ActionForm.php'; require_once 'Esform_ViewClass.php'; // Xserverなどで基底クラスがundefinedになる対策 require_once 'action/Project.php'; /** * Esformアプリケーションのコントローラ定義 * * @author {$author} * @access public * @package Esform */