private function updateAuthItem($positionId, $authItem = array(), $dataVal = array()) { if (!empty($authItem)) { $nodes = Node::model()->fetchAllSortByPk("id"); NodeRelated::model()->deleteAllByPositionId($positionId); $auth = Ibos::app()->authManager; $role = $auth->getAuthItem($positionId); if ($role === null) { $role = $auth->createRole($positionId, "", "", ""); } AuthItemChild::model()->deleteByParent($positionId); foreach ($authItem as $key => $nodeId) { $node = $nodes[$key]; if (strcasecmp($key, $nodeId) !== 0 && $nodeId === "data") { $vals = $dataVal[$key]; if (is_array($vals)) { NodeRelated::model()->addRelated("", $positionId, $node); foreach ($vals as $id => $val) { $childNode = Node::model()->fetchByPk($id); NodeRelated::model()->addRelated($val, $positionId, $childNode, $id); AuthUtil::addRoleChildItem($role, $childNode, explode(",", $childNode["routes"])); } } } else { NodeRelated::model()->addRelated("", $positionId, $node); $routes = explode(",", $node["routes"]); AuthUtil::addRoleChildItem($role, $node, $routes); } } } }