本文整理汇总了PHP中Setting::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::model方法的具体用法?PHP Setting::model怎么用?PHP Setting::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSetup
public function actionSetup()
{
$formSubmit = EnvUtil::submitCheck("securitySubmit");
if ($formSubmit) {
$fields = array("expiration", "minlength", "mixed", "errorlimit", "errorrepeat", "errortime", "autologin", "allowshare", "timeout");
$updateList = array();
foreach ($fields as $field) {
if (!isset($_POST[$field])) {
$_POST[$field] = 0;
}
$updateList[$field] = $_POST[$field];
}
if (intval($updateList["timeout"]) == 0) {
$this->error("请填写一个正确的大于0的超时时间值");
}
Setting::model()->updateSettingValueByKey("account", $updateList);
CacheUtil::update(array("setting"));
$this->success(Ibos::lang("Save succeed", "message"));
} else {
$data = array();
$account = Setting::model()->fetchSettingValueByKey("account");
$data["account"] = unserialize($account);
$this->render("setup", $data);
}
}
示例2: actionEdit
public function actionEdit()
{
if (Ibos::app()->request->getIsAjaxRequest()) {
if (EnvUtil::getRequest("op") === "structure") {
$curId = EnvUtil::getRequest("curid");
$objId = EnvUtil::getRequest("objid");
$status = $this->setStructure($curId, $objId);
$this->ajaxReturn(array("IsSuccess" => $status), "json");
}
$deptId = EnvUtil::getRequest("deptid");
if ($deptId == 0) {
$keys = array("phone", "fullname", "shortname", "fax", "zipcode", "address", "adminemail");
$postData = array();
foreach ($_POST as $key => $value) {
if (in_array($key, $keys)) {
$postData[$key] = $value;
}
}
Setting::model()->updateSettingValueByKey("unit", $postData);
$editStatus = true;
CacheUtil::update(array("setting"));
} else {
$this->dealWithBranch();
$this->dealWithSpecialParams();
$data = Department::model()->create();
$editStatus = Department::model()->modify($data["deptid"], $data);
$editStatus && OrgUtil::update();
}
$this->ajaxReturn(array("IsSuccess" => !!$editStatus), "json");
}
}
示例3: actionSet
public function actionSet()
{
$dt = Setting::model()->findAll();
foreach ($dt as $d) {
$_GLOBALS['tipe'] = $d->content_setting;
}
}
示例4: actionEdit
public function actionEdit()
{
if (EnvUtil::submitCheck("emailSubmit")) {
$setting = array();
foreach ($this->_fields as $field) {
if (array_key_exists($field, $_POST)) {
$setting[$field] = intval($_POST[$field]);
} else {
$setting[$field] = 0;
}
}
$roles = array();
if (isset($_POST["role"])) {
foreach ($_POST["role"] as $role) {
if (!empty($role["positionid"]) && !empty($role["size"])) {
$positionId = StringUtil::getId($role["positionid"]);
$roles[implode(",", $positionId)] = intval($role["size"]);
}
}
}
$setting["emailroleallocation"] = serialize($roles);
foreach ($setting as $key => $value) {
Setting::model()->updateSettingValueByKey($key, $value);
}
CacheUtil::update("setting");
$this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
}
}
示例5: init
public function init()
{
$this->_yii = Yii::app();
$this->_baseUrl = Yii::app()->baseUrl;
$this->_basePath = Yii::app()->basePath;
$this->_request = Yii::app()->request;
$this->_fonts = ROOT_PATH . '/public';
$this->_data = ROOT_PATH . '/protected/data/';
$this->_static_public = $this->_baseUrl . '/public';
//检测系统是否已经安装
if (!file_exists($this->_data . '/install.lock')) {
$this->redirect($this->createUrl('/install/step1'));
}
//后台全局设置
$settings = Setting::model()->findAll();
foreach ($settings as $row) {
$this->_setting[$row['variable']] = $row['value'];
}
//内容模型id
$model_types = ModelType::model()->findAll();
if ($model_types && is_array($model_types)) {
foreach ($model_types as $tp) {
$this->_type_ids[$tp->type_key] = $tp->id;
}
}
//内容模型对象
$this->_content_models = ModelType::getContentModel();
}
示例6: actionUpdate
public function actionUpdate()
{
if (EnvUtil::submitCheck("formhash")) {
$fieldArr = array("reporttypemanage" => "", "stampenable" => 0, "stampdetails" => "", "pointsystem" => 5, "autoreview" => 0, "autoreviewstamp" => 1);
foreach ($_POST as $key => $value) {
if (in_array($key, array_keys($fieldArr))) {
$fieldArr[$key] = $value;
}
}
$stampStr = "";
if (!empty($fieldArr["stampdetails"])) {
foreach ($fieldArr["stampdetails"] as $score => $stampId) {
$stampId = empty($stampId) ? 0 : $stampId;
$stampStr .= $stampId . ":" . $score . ",";
}
}
$fieldArr["stampdetails"] = rtrim($stampStr, ",");
$apprise = EnvUtil::getRequest("apprise");
if (empty($_POST["stampdetails"][$apprise])) {
$fieldArr["autoreview"] = 0;
} else {
$fieldArr["autoreviewstamp"] = $_POST["stampdetails"][$apprise];
}
Setting::model()->modify("reportconfig", array("svalue" => serialize($fieldArr)));
CacheUtil::update("setting");
$this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
}
}
示例7: authenticate
public function authenticate()
{
$user = User::model()->with('service')->find('username=:u', ['u' => $this->username]);
$verifyPassword = false;
if (empty($user)) {
$state = 1;
} else {
$verifyPassword = CPasswordHelper::verifyPassword($this->password, $user->password);
$state = $verifyPassword ? 0 : 1;
}
$result = Fraudmetrix::login($this->username, $state);
if ($result['success'] == true && $result['final_decision'] == 'Reject') {
$this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
$this->errorMessage = '未知错误';
} else {
if (empty($user)) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
$this->errorMessage = '用户邮箱不存在';
} else {
if ($user->state == 1) {
$this->errorCode = self::ERROR_NOT_LOGIN;
$this->errorMessage = '登录账号已被锁定';
} elseif (!$verifyPassword) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
$this->errorMessage = '用户密码错误';
} else {
$server = Setting::model()->get('wakfu', 'server');
$this->errorCode = self::ERROR_NONE;
$this->setPersistentStates(array_merge($user->getAttributes(), ['last_login_time' => $user->last_login_time, 'last_login_ip' => $user->last_login_ip, 'sign_up_time' => $user->sign_up_time, 'sign_up_ip' => $user->sign_up_ip, 'server' => $server[$user->service->server], 'port' => $user->service->port]));
$this->afterLogin($user);
}
}
}
return !$this->errorCode;
}
示例8: actionSetup
public function actionSetup()
{
if (EnvUtil::submitCheck("formhash")) {
$_POST["wbpostfrequency"] = 5 < intval($_POST["wbpostfrequency"]) ? $_POST["wbpostfrequency"] : 5;
$_POST["wbnums"] = 140 <= intval($_POST["wbnums"]) ? $_POST["wbnums"] : 140;
$wbwatermark = isset($_POST["wbwatermark"]) ? 1 : 0;
$wbwcenabled = isset($_POST["wbwcenabled"]) ? 1 : 0;
$postType = array("image" => 0, "topic" => 0, "praise" => 0);
if (isset($_POST["wbposttype"])) {
foreach ($postType as $key => &$val) {
if (isset($_POST["wbposttype"][$key])) {
$val = 1;
}
}
}
if (isset($_POST["wbmovements"])) {
} else {
$_POST["wbmovements"] = array();
}
$data = array("wbnums" => $_POST["wbnums"], "wbpostfrequency" => $_POST["wbpostfrequency"], "wbposttype" => $postType, "wbwatermark" => $wbwatermark, "wbwcenabled" => $wbwcenabled, "wbmovement" => $_POST["wbmovements"]);
foreach ($data as $key => $value) {
Setting::model()->updateSettingValueByKey($key, $value);
}
CacheUtil::update("setting");
$this->success(Ibos::lang("Operation succeed", "message"));
} else {
$data = array("config" => WbCommonUtil::getSetting(), "movementModule" => WbCommonUtil::getMovementModules());
$this->render("setup", $data);
}
}
示例9: updateSettingByKey
/**
* Update setting by key
*/
public function updateSettingByKey($key, $value)
{
$return = Setting::model()->updateAll(array('value' => $value), 'settingkey=:key', array(':key' => $key));
// Clear cache
Yii::app()->settings->clearCache();
return $return;
}
示例10: actionIndex
public function actionIndex()
{
$unit = Setting::model()->fetchSettingValueByKey("unit");
$formSubmit = EnvUtil::submitCheck("unitSubmit");
if ($formSubmit) {
$postData = array();
if (!empty($_FILES["logo"]["name"])) {
!empty($unit["logourl"]) && FileUtil::deleteFile($unit["logourl"]);
$postData["logourl"] = $this->imgUpload("logo");
} elseif (!empty($_POST["logourl"])) {
$postData["logourl"] = $_POST["logourl"];
} else {
$postData["logourl"] = "";
}
$keys = array("phone", "fullname", "shortname", "fax", "zipcode", "address", "adminemail", "systemurl");
foreach ($keys as $key) {
if (isset($_POST[$key])) {
$postData[$key] = StringUtil::filterCleanHtml($_POST[$key]);
} else {
$postData[$key] = "";
}
}
Setting::model()->updateSettingValueByKey("unit", $postData);
CacheUtil::update(array("setting"));
$this->success(Ibos::lang("Save succeed", "message"));
} else {
$license = Setting::model()->fetchSettingValueByKey("license");
$data = array("unit" => unserialize($unit), "license" => $license);
$this->render("index", $data);
}
}
示例11: getDefaultPicture
/**
* Gets the default profile picture for a specifc user.
* @param string $userId The Id of the user to get profile picture. If this is empty, the current user's avatar will be returned.
* @param string $type The type of picture to return (original, thumb.profile, thumb.feed, thumb.icon)
* @return array The picture info (path, alt, title, width, height)
*/
public static function getDefaultPicture($userId = '', $type = 'original')
{
if (empty($userId)) {
$userId = Yii::app()->user->getId();
if (empty($userId)) {
return null;
}
}
// Detect user's gender to decide which avatar should be chosen
$gender = Profile::model()->getFieldInfo($userId, User::PREFIX, 'gender');
if ($gender['value'] === 'male') {
$info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-male.jpg';
} else {
$info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-female.jpg';
}
// Alt and title
$info['alt'] = $info['title'] = UserModule::t('Default Avatar');
// Get size
//Yii::app()->getModule('system'); // Get module 'system'
$photoTypes = Setting::model()->get('photo_types', array('value'));
/*var_dump($photoTypes->value);
var_dump($photoTypes['value']); die;*/
$photoTypes = json_decode($photoTypes['value'], true);
// true indicates that the object will be converted to associative arrays
if (!isset($photoTypes[$type])) {
$info['width'] = 160;
$info['height'] = 160;
} else {
$info['width'] = $photoTypes[$type]['width'];
$info['height'] = $photoTypes[$type]['height'];
}
return $info;
}
示例12: actionParam
public function actionParam()
{
if (EnvUtil::submitCheck("formhash")) {
$data = array("sealfrom" => $_POST["seal_from"]);
$workRemindBefore = intval($_POST["work_remind_before"]);
$unitBefore = $_POST["unit_before"];
if (!empty($workRemindBefore)) {
$workRemindBefore .= $unitBefore;
$data["wfremindbefore"] = $workRemindBefore;
}
$workRemindAfter = $_POST["work_remind_after"];
$unitAfter = $_POST["unit_after"];
if (!empty($workRemindAfter)) {
$workRemindAfter .= $unitAfter;
$data["wfremindafter"] = $workRemindAfter;
}
foreach ($data as $key => $value) {
Setting::model()->updateSettingValueByKey($key, $value);
}
CacheUtil::update("setting");
$this->success(Ibos::lang("Operation succeed", "message"));
} else {
$keys = "wfremindbefore,wfremindafter,sealfrom";
$values = Setting::model()->fetchSettingValueByKeys($keys);
$param = array();
foreach ($values as $key => $value) {
if ($key == "wfremindbefore" || $key == "wfremindafter") {
$param[$key . "desc"] = substr($value, 0, -1);
$param[$key . "unit"] = substr($value, -1, 1);
}
$param[$key] = $value;
}
$this->render("param", array("param" => $param));
}
}
示例13: actionIndex
public function actionIndex()
{
$type = EnvUtil::getRequest("type");
$allowType = array("rtx", "qq");
if (!in_array($type, $allowType)) {
$type = "rtx";
}
$diff = array_diff($allowType, array($type));
$value = Setting::model()->fetchSettingValueByKey("im");
$im = unserialize($value);
$formSubmit = EnvUtil::submitCheck("imSubmit");
if ($formSubmit) {
$type = $_POST["type"];
if ($type == "rtx") {
$keys = array("open", "server", "appport", "sdkport", "push", "sso", "reverselanding", "syncuser");
} elseif ($type == "qq") {
$keys = array("open", "id", "token", "appid", "appsecret", "push", "sso", "syncuser", "syncorg", "showunread", "refresh_token", "time", "expires_in");
}
$updateList = array();
foreach ($keys as $key) {
if (isset($_POST[$key])) {
$updateList[$key] = $_POST[$key];
} else {
$updateList[$key] = 0;
}
}
if ($updateList["open"] == "1") {
$this->checkImUnique($diff);
$correct = MessageUtil::getIsImBinding($type, $updateList);
if ($correct !== true) {
$updateList["open"] = 0;
} elseif ($type == "qq") {
$updateList["checkpass"] = 1;
}
} else {
if ($type == "qq") {
$updateList["checkpass"] = 0;
}
$correct = true;
}
$im[$type] = $updateList;
Setting::model()->updateSettingValueByKey("im", $im);
CacheUtil::update(array("setting"));
if ($correct === true) {
$this->success(Ibos::lang("Save succeed", "message"));
} else {
$updateList["open"] = 0;
if (is_array($correct)) {
$msg = isset($correct[ICIM::ERROR_INIT]) ? implode(",", $correct[ICIM::ERROR_INIT]) : Ibos::lang("Unknown error", "error");
} else {
$msg = Ibos::lang("Unknown error", "error");
}
$this->error(Ibos::lang("Binding error", "", array("{err}" => $msg)));
}
} else {
$data = array("type" => $type, "im" => $im[$type]);
$this->render($type, $data);
}
}
示例14: initCache
private static function initCache()
{
Settings::$cache = array();
$settings = Setting::model()->findAll();
foreach ($settings as $setting) {
Settings::$cache[$setting->key] = $setting->value;
}
}
示例15: actionReset
/**
* Resets all settings to their default values and redirects to the admin
* page
*/
public function actionReset()
{
foreach (Setting::model()->getDefinitions() as $name => $definition) {
$this->saveSetting($name, $definition['default']);
}
Yii::app()->user->setFlash('success', Yii::t('Settings', 'Settings have been reset to defaults'));
$this->redirect(array('setting/admin'));
}