function performACLCheck($ajax = false, $callArray, $args) { //Return if admin $userId = JFactory::getUser()->id; if (XiptHelperUtils::isAdmin($userId)) { return false; } $option = JRequest::getVar('option'); $feature = JRequest::getCmd('view'); $task = JRequest::getCmd('task'); // depending upon call get feature and task, might be objectID if ($ajax) { $option = 'com_community'; $feature = JString::strtolower($callArray[0]); $task = JString::strtolower($callArray[1]); } // if user is uploading avatar at the time of registration then // the user id will be availabale from tmpuser if ($option == 'com_community' && $feature == 'register' && ($task == 'registerAvatar' || $task == 'registerSucess')) { $userId = JFactory::getSession()->get('tmpUser', '')->id; } $viewuserid = JRequest::getVar('userid', 0); // assign into one array $info['option'] = $option; $info['view'] = $feature; $info['task'] = strtolower($task); $info['userid'] = $userId; $info['viewuserid'] = $viewuserid; $info['ajax'] = $ajax; $info['args'] = $args; //get all published rules $rules = XiptAclFactory::getAclRulesInfo(array('published' => 1)); if (empty($rules)) { return false; } foreach ($rules as $rule) { $aclObject = XiptAclFactory::getAclObject($rule->aclname); $aclObject->bind($rule); if (false == $aclObject->isApplicable($info)) { continue; } if (false == $aclObject->checkViolation($info)) { //rule might update viewuserid, pass corerct id to next rule $info['viewuserid'] = $viewuserid; continue; } $aclObject->handleViolation($info); break; } return false; }
function load($id) { if (0 == $id) { return $this; } $filter = array(); $filter['id'] = $id; $result = XiptAclFactory::getAclRulesInfo($filter); if (!$result) { return $this; } $info = array_shift($result); $this->id = $info->id; $this->aclname = $info->aclname; $this->published = $info->published; $this->rulename = $info->rulename; $this->coreparams->bind($info->coreparams); $this->aclparams->bind($info->aclparams); return $this; }