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);
     }
 }
 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");
     }
 }
 public function actionSet()
 {
     $dt = Setting::model()->findAll();
     foreach ($dt as $d) {
         $_GLOBALS['tipe'] = $d->content_setting;
     }
 }
 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"));
     }
 }
Exemple #5
0
 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();
 }
 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"));
     }
 }
Exemple #7
0
 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;
 }
 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);
     }
 }
Exemple #9
0
 /**
  * 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;
 }
Exemple #10
0
 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);
     }
 }
Exemple #11
0
 /**
  * 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;
 }
 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));
     }
 }
Exemple #13
0
 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);
     }
 }
Exemple #14
0
 private static function initCache()
 {
     Settings::$cache = array();
     $settings = Setting::model()->findAll();
     foreach ($settings as $setting) {
         Settings::$cache[$setting->key] = $setting->value;
     }
 }
 /**
  * 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'));
 }
 public function init()
 {
     parent::init();
     $config = Setting::model()->findAll('scope=:scope', array(':scope' => 'base'));
     foreach ($config as $key => $row) {
         $this->setting_base[$row['variable']] = $row['value'];
     }
 }
 /**
  * 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 = Setting::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #18
0
 public static function getValueByCode($code, $isMultiLang = false)
 {
     if ($isMultiLang == true) {
         $model = Setting::model()->localized(Yii::app()->language, false)->findByAttributes(array('code' => $code));
     } else {
         $model = Setting::model()->findByAttributes(array('code' => $code));
     }
     return is_null($model) ? null : $model->value;
 }
 /**
  * Adds the setting with its default value to the settings table. Nothing 
  * is done if the setting already exists.
  * @return type
  */
 public function up()
 {
     $name = $this->getName();
     $setting = Setting::model()->findByPk($name);
     if ($setting !== null) {
         return;
     }
     $this->insert('settings', array('name' => $name, 'value' => (string) $this->getDefaultValue()));
 }
 public function handleSetting($event)
 {
     $settings = Setting::model()->fetchAllSetting();
     $this->_setting =& $settings;
     $this->handleCredits();
     $this->handleCreditsFormula();
     $this->_setting["verhash"] = StringUtil::random(3);
     Syscache::model()->modify("setting", $settings);
 }
Exemple #21
0
 public function actionSwitchstatus()
 {
     if (Ibos::app()->getRequest()->getIsAjaxRequest()) {
         $val = EnvUtil::getRequest("val");
         $result = Setting::model()->updateSettingValueByKey("appclosed", (int) $val);
         CacheUtil::update(array("setting"));
         return $this->ajaxReturn(array("IsSuccess" => $result), "json");
     }
 }
Exemple #22
0
 public function run()
 {
     if (session_status() === PHP_SESSION_NONE) {
         session_start();
     }
     $dt = Setting::model()->findAll();
     foreach ($dt as $d) {
         $_SESSION[$d['tipe']] = $d['content_setting'];
     }
 }
Exemple #23
0
 public function save()
 {
     $reflect = new ReflectionClass($this);
     $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
     foreach ($props as $prop) {
         $setting = Setting::model()->findByPk($prop->name);
         $setting->value = $this->{$prop->name};
         $setting->save(false);
     }
 }
Exemple #24
0
 public function set($name, $value)
 {
     $this->_map = null;
     $setting = Setting::model()->findByPk($name);
     if (!$setting) {
         $setting = new Setting();
         $setting->name = $name;
     }
     $setting->value = $value;
     $setting->save();
 }
Exemple #25
0
 /**
  * 
  * @param string $name
  * @return mixed
  */
 public function get($name)
 {
     // try to retrieve model
     $model = Setting::model()->name($name)->find();
     // Setting exists -> return value
     if ($model instanceof Setting) {
         return $model->value;
     } else {
         return NULL;
     }
 }
Exemple #26
0
 public static function getIsImOpen($type)
 {
     $setting = Setting::model()->fetchSettingValueByKey("im");
     $arrays = unserialize($setting);
     if (is_array($arrays) && isset($arrays[$type])) {
         if (isset($arrays[$type]["open"]) && $arrays[$type]["open"] == "1") {
             return true;
         }
     }
     return false;
 }
 /**
  * (non-PHPdoc)
  * @see yii/CWidget#run()
  */
 public function run()
 {
     // criteria for last entries
     $c = new CDbCriteria();
     $c->order = 't.viewCount DESC';
     $c->limit = Setting::model()->name(Setting::MOST_VIEWED_ENTRIES_WIDGET_COUNT)->find()->value;
     // get entries
     $models = Entry::model()->findAll($c);
     // render view
     $this->render('mostViewed', array('models' => $models));
 }
Exemple #28
0
 public function setValue($settingName, $settingValue, $storeId = 0, $group = 'config')
 {
     $setting = Setting::model()->findByAttributes(array('key' => $settingName, 'store_id' => $storeId, 'group' => $group));
     if (is_null($setting)) {
         $setting = new Setting();
         $setting->key = $settingName;
         $setting->store_id = $storeId;
         $setting->group = $group;
     }
     $setting->value = $settingValue;
     $setting->save();
 }
 public function loadModel($method)
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'setting_group=:group';
     $criteria->params = array(':group' => $method);
     $model = Setting::model()->findAll($criteria);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 private function view()
 {
     $query = $this->request->getPost('Setting', []);
     $model = Setting::model();
     $model->attributes = $query;
     $condition = $this->createSearchCriteria($query);
     $pager = new CPagination($model->count($condition));
     $pager->setPageSize(20);
     $condition['offset'] = $pager->getOffset();
     $condition['limit'] = $pager->getLimit();
     $data = $model->findAll($condition);
     $this->render('setting', ['data' => new RedArrayDataProvider($data), 'pager' => $pager, 'model' => $model]);
 }