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); } }