protected function getMaxPurv($uid, $posid, $url) { $allPosIds = PositionRelated::model()->fetchAllPositionIdByUid($uid); array_push($allPosIds, $posid); array_unique($allPosIds); $purvs = array(); foreach ($allPosIds as $posid) { $p = NodeRelated::model()->fetchDataValByIdentifier($url, $posid); $purvs[] = intval($p); } $viewPurv = max($purvs); return $viewPurv; }
public static function wrapUserInfo($user) { $user["group_title"] = ""; $user["next_group_credit"] = $user["upgrade_percent"] = 0; $currentGroup = !empty($user["groupid"]) ? UserGroup::model()->fetchByPk($user["groupid"]) : array(); if (!empty($currentGroup)) { $user["group_title"] = $currentGroup["title"]; if ($currentGroup["creditslower"] !== "0") { $user["upgrade_percent"] = round((double) $user["credits"] / $currentGroup["creditslower"] * 100, 2); } $user["next_group_credit"] = (int) $currentGroup["creditslower"]; } $user["level"] = self::getUserLevel($user["groupid"]); CacheUtil::load(array("department", "position")); $position = PositionUtil::loadPosition(); $department = DepartmentUtil::loadDepartment(); if (0 < $user["deptid"]) { $relatedDeptId = DepartmentRelated::model()->fetchAllDeptIdByUid($user["uid"]); $deptIds = array_merge((array) $relatedDeptId, array($user["deptid"])); $user["alldeptid"] = implode(",", array_unique($deptIds)); $user["allupdeptid"] = Department::model()->queryDept($user["alldeptid"]); $user["alldowndeptid"] = Department::model()->fetchChildIdByDeptids($user["alldeptid"]); $user["relatedDeptId"] = implode(",", $relatedDeptId); $user["deptname"] = isset($department[$user["deptid"]]) ? $department[$user["deptid"]]["deptname"] : ""; } else { $user["alldeptid"] = $user["allupdeptid"] = $user["alldowndeptid"] = $user["relatedDeptId"] = $user["deptname"] = ""; } if (0 < $user["positionid"]) { $relatedPosId = PositionRelated::model()->fetchAllPositionIdByUid($user["uid"]); $posIds = array_merge(array($user["positionid"]), (array) $relatedPosId); $user["allposid"] = implode(",", array_unique($posIds)); $user["relatedPosId"] = implode(",", $relatedPosId); $user["posname"] = isset($position[$user["positionid"]]) ? $position[$user["positionid"]]["posname"] : ""; } else { $user["allposid"] = $user["relatedPosId"] = $user["posname"] = ""; } $user["space_url"] = "?r=user/home/index&uid=" . $user["uid"]; $user["avatar_middle"] = "avatar.php?uid={$user["uid"]}&size=middle&engine=" . ENGINE; $user["avatar_small"] = "avatar.php?uid={$user["uid"]}&size=small&engine=" . ENGINE; $user["avatar_big"] = "avatar.php?uid={$user["uid"]}&size=big&engine=" . ENGINE; $user["bg_big"] = "bg.php?uid={$user["uid"]}&size=big&engine=" . ENGINE; $user["bg_small"] = "bg.php?uid={$user["uid"]}&size=small&engine=" . ENGINE; $profile = UserProfile::model()->fetchByUid($user["uid"]); $user = array_merge($user, (array) $profile); return $user; }
public function fetchUidByPosId($posId, $returnDisabled = true) { static $posIds = array(); if (!isset($posIds[$posId])) { $posIds[$posId] = array(); $extCondition = $returnDisabled ? 1 : " status != 2 "; $criteria = array("select" => "uid", "condition" => "`positionid`={$posId} AND {$extCondition}"); $posCriteria = array("select" => "uid", "condition" => "`positionid`={$posId}"); $main = $this->fetchAll($criteria); $auxiliary = PositionRelated::model()->fetchAll($posCriteria); foreach (array_merge($main, $auxiliary) as $uid) { $posIds[$posId][] = $uid["uid"]; } } return $posIds[$posId]; }
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"); } }