public function handleUsers($event) { $users = array(); $records = User::model()->fetchAll(array("condition" => "status IN (0,1)")); if (!empty($records)) { foreach ($records as $record) { $users[$record["uid"]] = UserUtil::wrapUserInfo($record); } } Syscache::model()->modify("users", $users); }
public function actionAdd() { MainUtil::checkLicenseLimit(); if (EnvUtil::submitCheck("userSubmit")) { $origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING); $_POST["salt"] = StringUtil::random(6); $_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : ""; $_POST["createtime"] = TIMESTAMP; $_POST["guid"] = StringUtil::createGuid(); $this->dealWithSpecialParams(); $data = User::model()->create(); $newId = User::model()->add($data, true); if ($newId) { UserCount::model()->add(array("uid" => $newId)); $ip = Ibos::app()->setting->get("clientip"); UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip)); UserProfile::model()->add(array("uid" => $newId)); if (!empty($_POST["auxiliarydept"])) { $deptIds = StringUtil::getId($_POST["auxiliarydept"]); $this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]); } if (!empty($_POST["auxiliarypos"])) { $posIds = StringUtil::getId($_POST["auxiliarypos"]); $this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]); } $newUser = User::model()->fetchByPk($newId); $users = UserUtil::loadUser(); $users[$newId] = UserUtil::wrapUserInfo($newUser); User::model()->makeCache($users); OrgUtil::update(); OrgUtil::hookSyncUser($newId, $origPass, 1); $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index")); } else { $this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index")); } } else { $deptid = ""; $manager = ""; $account = Ibos::app()->setting->get("setting/account"); if ($account["mixed"]) { $preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+"; } else { $preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$"; } if ($deptid = EnvUtil::getRequest("deptid")) { $deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d"); $manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u"); } $this->setPageTitle(Ibos::lang("Add user")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user")))); $this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg)); } }
public function updateByUid($uid, $attributes) { $counter = $this->updateByPk($uid, $attributes); $users = UserUtil::loadUser(); $users[$uid] = UserUtil::wrapUserInfo(array_merge($users[$uid], $attributes)); $this->makeCache($users); return $counter; }
private function addUser() { if (Ibos::app()->request->isAjaxRequest) { $fields = array("username", "password", "realname", "mobile", "deptid", "positionid", "email"); if (empty($_POST["username"]) || empty($_POST["password"])) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Username or password not empty"))); } foreach ($fields as $field) { if (isset($_POST[$field]) && !empty($_POST[$field])) { $_POST[$field] = StringUtil::filterDangerTag($_POST[$field]); } } $salt = StringUtil::random(6); $userData = array("salt" => $salt, "username" => $_POST["username"], "password" => !empty($_POST["password"]) ? md5(md5($_POST["password"]) . $salt) : "", "realname" => $_POST["realname"], "mobile" => $_POST["mobile"], "createtime" => TIMESTAMP, "deptid" => intval($_POST["deptid"]), "positionid" => intval($_POST["positionid"]), "email" => $_POST["email"]); $newId = User::model()->add($userData, true); if ($newId) { UserCount::model()->add(array("uid" => $newId)); $ip = Ibos::app()->setting->get("clientip"); UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip)); UserProfile::model()->add(array("uid" => $newId)); $newUser = User::model()->fetchByPk($newId); $users = UserUtil::loadUser(); $users[$newId] = UserUtil::wrapUserInfo($newUser); User::model()->makeCache($users); OrgUtil::update(); $res["isSuccess"] = true; } else { $res["isSuccess"] = false; $res["msg"] = Ibos::lang("Add user failed"); } $this->ajaxReturn($res); } }