public function actionIndex() { $types = EnvUtil::getRequest("updatetype"); $data = array(); if (EnvUtil::submitCheck("formhash")) { $type = implode(",", $types); if (!empty($type)) { $this->redirect($this->createUrl("update/index", array("doupdate" => 1, "updatetype" => $type))); } } if (Ibos::app()->request->getIsAjaxRequest()) { $op = EnvUtil::getRequest("op"); if (LOCAL) { @set_time_limit(0); } if ($op == "data") { CacheUtil::update(); } if ($op == "static") { LOCAL && Ibos::app()->assetManager->republicAll(); OrgUtil::update(); } if ($op == "module") { ModuleUtil::updateConfig(); } Ibos::app()->cache->clear(); $this->ajaxReturn(array("isSuccess" => true)); } if (EnvUtil::getRequest("doupdate") == 1) { $type = explode(",", trim($types, ",")); $data["doUpdate"] = true; foreach ($type as $index => $act) { if (!empty($act)) { if (in_array("data", $type)) { unset($type[$index]); $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Data cache"); $data["op"] = "data"; break; } if (in_array("static", $type)) { unset($type[$index]); $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Static cache"); $data["op"] = "static"; break; } if (in_array("module", $type)) { $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Module setting"); $data["op"] = "module"; unset($type[$index]); break; } } } $data["next"] = $this->createUrl("update/index", array("doupdate" => intval(!empty($type)), "updatetype" => implode(",", $type))); } else { $data["doUpdate"] = false; } $this->render("index", $data); }
public function actionDel() { if (Ibos::app()->request->getIsAjaxRequest()) { $delId = EnvUtil::getRequest("id"); if (Department::model()->countChildByDeptId($delId)) { $delStatus = false; $msg = Ibos::lang("Remove the child department first"); } else { $delStatus = Department::model()->remove($delId); DepartmentRelated::model()->deleteAll("deptid = :deptid", array(":deptid" => $delId)); $relatedIds = User::model()->fetchAllUidByDeptid($delId); if (!empty($relatedIds)) { User::model()->updateByUids($relatedIds, array("deptid" => 0)); } $delStatus && OrgUtil::update(); $msg = Ibos::lang("Operation succeed", "message"); } $this->ajaxReturn(array("IsSuccess" => !!$delStatus, "msg" => $msg), "json"); } }
protected function setStatus($status, $uids) { $uidArr = explode(",", trim($uids, ",")); $attributes = array(); switch ($status) { case "lock": $attributes["status"] = 1; break; case "disabled": $attributes["status"] = 2; OrgUtil::hookSyncUser($uids, "", 0); break; case "enabled": default: $attributes["status"] = 0; OrgUtil::hookSyncUser($uids, "", 2); break; } $return = User::model()->updateByUids($uidArr, $attributes); OrgUtil::update(); return $this->ajaxReturn(array("isSuccess" => !!$return), "json"); }
public function handleInitOrg($event) { if (!FileUtil::fileExists("data/org.js")) { OrgUtil::update(); } }
public static function setPosition($positionId, $users) { $oldUids = User::model()->fetchUidByPosId($positionId, false); $userId = explode(",", trim($users, ",")); $newUids = StringUtil::getUid($userId); $delDiff = array_diff($oldUids, $newUids); $addDiff = array_diff($newUids, $oldUids); if (!empty($addDiff) || !empty($delDiff)) { $updateUser = false; $userData = self::loadUser(); if ($addDiff) { foreach ($addDiff as $newUid) { $record = $userData[$newUid]; if (empty($record["positionid"])) { User::model()->modify($newUid, array("positionid" => $positionId)); $updateUser = true; } elseif (strcmp($record["positionid"], $positionId) !== 0) { PositionRelated::model()->add(array("positionid" => $positionId, "uid" => $newUid), false, true); } } } if ($delDiff) { foreach ($delDiff as $diffId) { $record = $userData[$diffId]; PositionRelated::model()->delete("`positionid` = :positionid AND `uid` = :uid", array(":positionid" => $positionId, ":uid" => $diffId)); if (strcmp($positionId, $record["positionid"]) == 0) { User::model()->modify($diffId, array("positionid" => 0)); $updateUser = true; } } } $mainNumber = User::model()->count("`positionid` = :positionid", array(":positionid" => $positionId)); $auxiliaryNumber = PositionRelated::model()->countByPositionId($positionId); Position::model()->modify($positionId, array("number" => (int) $mainNumber + $auxiliaryNumber)); $updateUser && CacheUtil::update("users"); OrgUtil::update(); } }
public function afterDelete() { CacheUtil::update(); OrgUtil::update(); }
public function actionDel() { if (Ibos::app()->request->getIsAjaxRequest()) { $id = EnvUtil::getRequest("id"); $ids = explode(",", trim($id, ",")); foreach ($ids as $positionId) { Position::model()->deleteByPk($positionId); Ibos::app()->authManager->removeAuthItem($positionId); PositionResponsibility::model()->deleteAll("`positionid` = :positionid", array(":positionid" => $positionId)); PositionRelated::model()->deleteAll("positionid = :positionid", array(":positionid" => $positionId)); NodeRelated::model()->deleteAll("positionid = :positionid", array(":positionid" => $positionId)); $relatedIds = User::model()->fetchUidByPosId($positionId); if (!empty($relatedIds)) { User::model()->updateByUids($relatedIds, array("positionid" => 0)); } PositionUtil::cleanPurvCache($positionId); } OrgUtil::update(); $this->ajaxReturn(array("IsSuccess" => true), "json"); } }
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); } }