function processSave($id = 0, $post = null) { //save aclparam and core param in individual columns $id = JRequest::getVar('id', $id); $data = array(); if ($post === null) { $post = JRequest::get('post'); } $model = $this->getModel(); // Get the complete INI string of params $param = new XiptParameter(); $post['coreparams']['core_display_message'] = base64_encode($post['coreparams']['core_display_message']); $param->loadArray($post['coreparams'], 'xipt_coreparams'); $data['coreparams'] = $param->toString('XiptINI', 'xipt_coreparams'); $data['aclname'] = $post['aclname']; $data['rulename'] = $post['rulename']; $data['published'] = $post['published']; $aclObject = XiptAclFactory::getAclObject($data['aclname']); $data['aclparams'] = $aclObject->collectParamsFromPost($post); // Save it // XITODO : clean it if (!($info['id'] = $model->save($data, $id))) { $info['msg'] = XiptText::_('ERROR_IN_SAVING_RULE'); } else { $info['msg'] = XiptText::_('RULE_SAVED'); } return $info; }
function edit($data, $tpl = 'edit') { //call htmlrender fn $aclObject = XiptAclFactory::getAclObject($data['aclname']); $aclObject->bind($data); $helpMsg = XiptAclHelper::getHelpMessage($data['aclname']); $this->assign('helpMsg', $helpMsg); $this->assignRef('coreParamsHtml', $aclObject->getCoreParamsHtml()); $this->assignRef('aclParamsHtml', $aclObject->getAclParamsHtml()); $this->assign('aclruleInfo', $data); $this->setToolbar($tpl); return parent::display($tpl); }
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; }