本文整理匯總了PHP中JAccess::getAssetRules方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAccess::getAssetRules方法的具體用法?PHP JAccess::getAssetRules怎麽用?PHP JAccess::getAssetRules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JAccess
的用法示例。
在下文中一共展示了JAccess::getAssetRules方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array $array Named array
* @param mixed $ignore Optional array or list of parameters to ignore
*
* @return null|string null is operation was satisfactory, otherwise returns an error
*
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
$input = JFactory::getApplication()->input;
$task = $input->getString('task', '');
if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_autofilter') && $array['state'] == 1)) {
$array['state'] = 0;
}
if ($array['id'] == 0) {
$array['created_by'] = JFactory::getUser()->id;
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_autofilter.categorie.' . $array['id'])) {
$actions = JAccess::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/com_autofilter/access.xml', "/access/section[@name='categorie']/");
$default_actions = JAccess::getAssetRules('com_autofilter.categorie.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
// Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例2: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
*
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_mapa.mapadevenezuela.' . $array['id'])) {
$actions = JAccess::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/com_mapa/access.xml', "/access/section[@name='mapadevenezuela']/");
$default_actions = JAccess::getAssetRules('com_mapa.mapadevenezuela.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
//Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例3: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array $array Named array
* @param mixed $ignore Optional array or list of parameters to ignore
*
* @return null|string null is operation was satisfactory, otherwise returns an error
*
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
// Support for multiple or not foreign key field: ingredients_id
if (!empty($array['ingredients_id'])) {
if (is_array($array['ingredients_id'])) {
$array['ingredients_id'] = implode(',', $array['ingredients_id']);
} else {
if (strrpos($array['ingredients_id'], ',') != false) {
$array['ingredients_id'] = explode(',', $array['ingredients_id']);
}
}
} else {
$array['ingredients_id'] = '';
}
// Support for multiple or not foreign key field: recipe_id
if (!empty($array['recipe_id'])) {
if (is_array($array['recipe_id'])) {
$array['recipe_id'] = implode(',', $array['recipe_id']);
} else {
if (strrpos($array['recipe_id'], ',') != false) {
$array['recipe_id'] = explode(',', $array['recipe_id']);
}
}
} else {
$array['recipe_id'] = '';
}
$input = JFactory::getApplication()->input;
$task = $input->getString('task', '');
if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_akrecipes') && $array['state'] == 1)) {
$array['state'] = 0;
}
if ($array['id'] == 0) {
$array['created_by'] = JFactory::getUser()->id;
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_akrecipes.ingredient997479.' . $array['id'])) {
$actions = JAccess::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/com_akrecipes/access.xml', "/access/section[@name='ingredient997479']/");
$default_actions = JAccess::getAssetRules('com_akrecipes.ingredient997479.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
// Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例4: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
// Must load admin language files
$lang = JFactory::getLanguage();
$lang->load("com_jevents", JPATH_ADMINISTRATOR);
$db = JFactory::getDBO();
$class = $node->attributes('class');
if (!$class) {
$class = "inputbox";
}
//jimport("joomla.html.html.list");
$params = JComponentHelper::getParams("com_jevents");
$db = JFactory::getDBO();
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
if (strpos($name, "jevadmin") === 0) {
$action = "core.admin";
} else {
if (strpos($name, "jeveditor") === 0) {
$action = "core.edit";
} else {
if (strpos($name, "jevpublisher") === 0) {
$action = "core.edit.state";
} else {
if (strpos($name, "admin") === 0) {
$action = "core.edit.state";
} else {
$action = "core.create";
}
}
}
}
// need to merge the arrays because of stupid way Joomla checks super user permissions
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups[$action]->getData());
// use union orf arrays sincee getData no longer has string keys in the resultant array
//$creatorgroups = $creatorgroups["core.admin"]->getData()+ $creatorgroups["core.create"]->getData();
// use union orf arrays sincee getData no longer has string keys in the resultant array
$creatorgroupsdata = $creatorgroups["core.admin"]->getData();
// take the higher permission setting
foreach ($creatorgroups[$action]->getData() as $creatorgroup => $permission) {
if ($permission) {
$creatorgroupsdata[$creatorgroup] = $permission;
}
}
$users = array(0);
foreach ($creatorgroupsdata as $creatorgroup => $permission) {
if ($permission == 1) {
$users = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $users);
}
}
$sql = "SELECT id AS value, name AS text FROM #__users where id IN (" . implode(",", array_values($users)) . ") ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
$users2[] = JHTML::_('select.option', '0', '- ' . JText::_('SELECT_USER') . ' -');
$users2 = array_merge($users2, $users);
$users = JHTML::_('select.genericlist', $users2, $control_name . '[' . $name . ']', 'class="' . $class . '" size="1" ', 'value', 'text', $value);
return $users;
}
示例5: edit
function edit($tpl = null)
{
$document =& JFactory::getDocument();
// this already includes administrator
$livesite = JURI::base();
if (JVersion::isCompatible("1.6.0")) {
JEVHelper::stylesheet('eventsadmin16.css', 'administrator/components/' . JEV_COM_COMPONENT . '/assets/css/');
} else {
$document->addStyleSheet($livesite . 'components/' . JEV_COM_COMPONENT . '/assets/css/eventsadmin.css');
}
$document->setTitle(JText::_('JEVENTS') . ' :: ' . JText::_('JEVENTS'));
// Set toolbar items for the page
JToolBarHelper::title(JText::_('JEV_EDIT_USER'), 'jevents');
JToolBarHelper::save("user.save");
JToolBarHelper::cancel("user.overview");
//JToolBarHelper::help( 'edit.user', true);
$option = JRequest::getCmd('option', JEV_COM_COMPONENT);
$db =& JFactory::getDBO();
$params =& JComponentHelper::getParams(JEV_COM_COMPONENT);
if (JVersion::isCompatible("1.6.0")) {
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups["core.create"]->getData());
$users = array(0);
foreach ($creatorgroups as $creatorgroup => $permission) {
if ($permission == 1) {
$users = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $users);
}
}
$sql = "SELECT * FROM #__users where id IN (" . implode(",", array_values($users)) . ") ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
} else {
$minaccess = $params->getValue("jevcreator_level", 19);
// get users AUTHORS and above
$sql = "SELECT * FROM #__users where gid>=" . $minaccess;
$db->setQuery($sql);
$users = $db->loadObjectList();
}
$userOptions[] = JHTML::_('select.option', '-1', 'Select User');
foreach ($users as $user) {
$userOptions[] = JHTML::_('select.option', $user->id, $user->name . " ({$user->username})");
}
$jevuser =& $this->get('user');
$userlist = JHTML::_('select.genericlist', $userOptions, 'user_id', 'class="inputbox" size="1" ', 'value', 'text', $jevuser->user_id);
JLoader::register('JEventsCategory', JEV_ADMINPATH . "/libraries/categoryClass.php");
$categories = JEventsCategory::categoriesTree();
$lists['categories'] = JHTML::_('select.genericlist', $categories, 'categories[]', 'multiple="multiple" size="15"', 'value', 'text', explode("|", $jevuser->categories));
// get calendars
$sql = "SELECT label as text, ics_id as value FROM #__jevents_icsfile where icaltype=2";
$db->setQuery($sql);
$calendars = $db->loadObjectList();
$lists['calendars'] = JHTML::_('select.genericlist', $calendars, 'calendars[]', 'multiple="multiple" size="15"', 'value', 'text', explode("|", $jevuser->calendars));
$this->assignRef('lists', $lists);
$this->assignRef("users", $userlist);
$this->assignRef('jevuser', $jevuser);
JHTML::_('behavior.tooltip');
}
示例6: edit
function edit($tpl = null)
{
$document = JFactory::getDocument();
// this already includes administrator
$document->setTitle(JText::_('JEVENTS') . ' :: ' . JText::_('JEVENTS'));
// Set toolbar items for the page
JToolBarHelper::title(JText::_('JEV_EDIT_USER'), 'jevents');
JToolBarHelper::save("user.save");
JToolBarHelper::cancel("user.overview");
//JToolBarHelper::help( 'edit.user', true);
$option = JRequest::getCmd('option', JEV_COM_COMPONENT);
$db = JFactory::getDBO();
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$rules = JAccess::getAssetRules("com_jevents", true);
$data = $rules->getData();
$creatorgroups = $data["core.create"]->getData();
foreach ($data["core.admin"]->getData() as $creatorgroup => $permission) {
if ($permission == 1) {
$creatorgroups[$creatorgroup] = $permission;
}
}
// array_merge does a re-indexing !!
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups["core.create"]->getData());
$users = array(0);
foreach ($creatorgroups as $creatorgroup => $permission) {
if ($permission == 1) {
$users = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $users);
}
}
$sql = "SELECT * FROM #__users where id IN (" . implode(",", array_values($users)) . ") ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
$userOptions[] = JHTML::_('select.option', '-1', JText::_('SELECT_USER'));
foreach ($users as $user) {
$userOptions[] = JHTML::_('select.option', $user->id, $user->name . " ({$user->username})");
}
$jevuser = $this->get('user');
$userlist = JHTML::_('select.genericlist', $userOptions, 'user_id', 'class="inputbox" size="1" ', 'value', 'text', $jevuser->user_id);
JLoader::register('JEventsCategory', JEV_ADMINPATH . "/libraries/categoryClass.php");
$categories = JEventsCategory::categoriesTree();
$lists['categories'] = JHTML::_('select.genericlist', $categories, 'categories[]', 'multiple="multiple" size="15"', 'value', 'text', explode("|", $jevuser->categories));
// get calendars
$sql = "SELECT label as text, ics_id as value FROM #__jevents_icsfile where icaltype=2";
$db->setQuery($sql);
$calendars = $db->loadObjectList();
$lists['calendars'] = JHTML::_('select.genericlist', $calendars, 'calendars[]', 'multiple="multiple" size="15"', 'value', 'text', explode("|", $jevuser->calendars));
$this->assignRef('lists', $lists);
$this->assignRef("users", $userlist);
$this->assignRef('jevuser', $jevuser);
JHTML::_('behavior.tooltip');
if (JevJoomlaVersion::isCompatible("3.0")) {
$this->setLayout("edit");
} else {
$this->setLayout("edit16");
}
}
示例7: getOptions
public function getOptions()
{
$params = JComponentHelper::getParams("com_jevents");
$db = JFactory::getDBO();
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
if (strpos($this->name, "jevadmin") === 0) {
$action = "core.admin";
} else {
if (strpos($this->name, "jeveditor") === 0) {
$action = "core.edit";
} else {
if (strpos($this->name, "jevpublisher") === 0) {
$action = "core.edit.state";
} else {
if (strpos($this->name, "admin") === 0) {
$action = "core.edit.state";
} else {
$action = "core.create";
}
}
}
}
// need to merge the arrays because of stupid way Joomla checks super user permissions
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups[$action]->getData());
// use union orf arrays sincee getData no longer has string keys in the resultant array
//$creatorgroups = $creatorgroups["core.admin"]->getData()+ $creatorgroups["core.create"]->getData();
// use union orf arrays sincee getData no longer has string keys in the resultant array
$creatorgroupsdata = $creatorgroups["core.admin"]->getData();
// take the higher permission setting
foreach ($creatorgroups[$action]->getData() as $creatorgroup => $permission) {
if ($permission) {
$creatorgroupsdata[$creatorgroup] = $permission;
}
}
$users = array(0);
foreach ($creatorgroupsdata as $creatorgroup => $permission) {
if ($permission == 1) {
$users = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $users);
}
}
$sql = "SELECT id AS value, name AS text , sendEmail FROM #__users where id IN (" . implode(",", array_values($users)) . ") ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
$nulluser = new stdClass();
$nulluser->value = 0;
$nulluser->sendEmail = 0;
$nulluser->text = JText::_("SELECT_ADMIN");
array_unshift($users, $nulluser);
return $users;
}
示例8: checkGroup
public static function checkGroup($groupId, $action, $asset = null)
{
$groupId = (int) $groupId;
if ($groupId == 0) {
$groupId = 17;
//ROOT
}
$action = strtolower($action);
$asset = strtolower($asset);
if (empty($asset)) {
$asset = 1;
}
if (empty(JAccess::$_assetRules[$asset])) {
JAccess::$_assetRules[$asset] = JAccess::getAssetRules($asset);
}
$groupPath = JAccess::getGroupPath($groupId);
return JAccess::$_assetRules[$asset]->allow($action, $groupPath);
}
示例9: getAdminGroups
public static function getAdminGroups()
{
if (!is_array(self::$groups)) {
self::$groups = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->qn('id'))->select($db->qn('lft'))->select($db->qn('rgt'))->from($db->qn('#__usergroups'));
$db->setQuery($query);
if ($groups = $db->loadObjectList()) {
$rules = JAccess::getAssetRules(1);
foreach ($groups as $group) {
if ($rules->allow('core.admin', array($group->id))) {
self::$groups[] = (int) $group->id;
$children = self::getAdminGroupsChildren($group->lft, $group->rgt);
foreach ($children as $child_id) {
self::$groups[] = (int) $child_id;
}
}
}
}
}
return self::$groups;
}
示例10: _getRulesData
protected function _getRulesData()
{
// get the identities for the group.
$db = JFactory::getDBO();
// Get the user groups from the database.
$db->setQuery('SELECT b.id' . ' FROM #__usergroups AS a' . ' LEFT JOIN `#__usergroups` AS b ON a.lft >= b.lft AND a.rgt <= b.rgt' . ' WHERE a.id = ' . (int) $this->getState('report.group_id'));
$identities = $db->loadResultArray();
// Get list of extensions.
$query = new JQuery();
$query->select('name, element');
$query->from('#__extensions');
$query->where('type = ' . $db->quote('component'));
$db->setQuery($query);
$extensions = $db->loadObjectList();
$actions = $this->getActions();
foreach ($extensions as &$extension) {
$extension->actions = array();
$rules = JAccess::getAssetRules($extension->element, true);
foreach ($actions as $action => $name) {
$extension->actions[$action] = $rules->allow($action, $identities);
}
}
return array('extensions' => $extensions, 'actions' => $actions);
}
示例11: save
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
// Include the user plugins for events.
JPluginHelper::importPlugin($this->events_map['save']);
/**
* Check the super admin permissions for group
* We get the parent group permissions and then check the group permissions manually
* We have to calculate the group permissions manually because we haven't saved the group yet
*/
$parentSuperAdmin = JAccess::checkGroup($data['parent_id'], 'core.admin');
// Get core.admin rules from the root asset
$rules = JAccess::getAssetRules('root.1')->getData('core.admin');
// Get the value for the current group (will be true (allowed), false (denied), or null (inherit)
$groupSuperAdmin = $rules['core.admin']->allow($data['id']);
// We only need to change the $groupSuperAdmin if the parent is true or false. Otherwise, the value set in the rule takes effect.
if ($parentSuperAdmin === false) {
// If parent is false (Denied), effective value will always be false
$groupSuperAdmin = false;
} elseif ($parentSuperAdmin === true) {
// If parent is true (allowed), group is true unless explicitly set to false
$groupSuperAdmin = $groupSuperAdmin === false ? false : true;
}
// Check for non-super admin trying to save with super admin group
$iAmSuperAdmin = JFactory::getUser()->authorise('core.admin');
if (!$iAmSuperAdmin && $groupSuperAdmin) {
$this->setError(JText::_('JLIB_USER_ERROR_NOT_SUPERADMIN'));
return false;
}
/**
* Check for super-admin changing self to be non-super-admin
* First, are we a super admin
*/
if ($iAmSuperAdmin) {
// Next, are we a member of the current group?
$myGroups = JAccess::getGroupsByUser(JFactory::getUser()->get('id'), false);
if (in_array($data['id'], $myGroups)) {
// Now, would we have super admin permissions without the current group?
$otherGroups = array_diff($myGroups, array($data['id']));
$otherSuperAdmin = false;
foreach ($otherGroups as $otherGroup) {
$otherSuperAdmin = $otherSuperAdmin ? $otherSuperAdmin : JAccess::checkGroup($otherGroup, 'core.admin');
}
/**
* If we would not otherwise have super admin permissions
* and the current group does not have super admin permissions, throw an exception
*/
if (!$otherSuperAdmin && !$groupSuperAdmin) {
$this->setError(JText::_('JLIB_USER_ERROR_CANNOT_DEMOTE_SELF'));
return false;
}
}
}
if (JFactory::getApplication()->input->get('task') == 'save2copy') {
$data['title'] = $this->generateGroupTitle($data['parent_id'], $data['title']);
}
// Proceed with the save
return parent::save($data);
}
示例12: assetFormWidget
/**
* Creates the HTML for the permissions widget
*
* @param array $actions Array of action objects
* @param integer $assetId Id of a specific asset to create a widget for.
* @param integer $parent Id of the parent of the asset
* @param string $control The form control
* @param string $idPrefix Prefix for the ids assigned to specific action-group pairs
*
* @return string HTML for the permissions widget
*
* @since 11.1
*
* @see JAccess
* @see JFormFieldRules
*/
public static function assetFormWidget($actions, $assetId = null, $parent = null, $control = 'jform[rules]', $idPrefix = 'jform_rules')
{
$images = self::_getImagesArray();
// Get the user groups.
$groups = self::_getUserGroups();
// Get the incoming inherited rules as well as the asset specific rules.
$inheriting = JAccess::getAssetRules($parent ? $parent : self::_getParentAssetId($assetId), true);
$inherited = JAccess::getAssetRules($assetId, true);
$rules = JAccess::getAssetRules($assetId);
$html = array();
$html[] = '<div class="acl-options">';
$html[] = JHtml::_('tabs.start', 'acl-rules-' . $assetId, array('useCookie' => 1));
$html[] = JHtml::_('tabs.panel', JText::_('JLIB_HTML_ACCESS_SUMMARY'), 'summary');
$html[] = ' <p>' . JText::_('JLIB_HTML_ACCESS_SUMMARY_DESC') . '</p>';
$html[] = ' <table class="aclsummary-table" summary="' . JText::_('JLIB_HTML_ACCESS_SUMMARY_DESC') . '">';
$html[] = ' <caption>' . JText::_('JLIB_HTML_ACCESS_SUMMARY_DESC_CAPTION') . '</caption>';
$html[] = ' <tr>';
$html[] = ' <th class="col1 hidelabeltxt">' . JText::_('JLIB_RULES_GROUPS') . '</th>';
foreach ($actions as $i => $action) {
$html[] = ' <th class="col' . ($i + 2) . '">' . JText::_($action->title) . '</th>';
}
$html[] = ' </tr>';
foreach ($groups as $i => $group) {
$html[] = ' <tr class="row' . $i % 2 . '">';
$html[] = ' <td class="col1">' . $group->text . '</td>';
foreach ($actions as $i => $action) {
$html[] = ' <td class="col' . ($i + 2) . '">' . ($assetId ? $inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'] : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . '</td>';
}
$html[] = ' </tr>';
}
$html[] = ' </table>';
foreach ($actions as $action) {
$actionTitle = JText::_($action->title);
$actionDesc = JText::_($action->description);
$html[] = JHtml::_('tabs.panel', $actionTitle, $action->name);
$html[] = ' <p>' . $actionDesc . '</p>';
$html[] = ' <table class="aclmodify-table" summary="' . strip_tags($actionDesc) . '">';
$html[] = ' <caption>' . JText::_('JLIB_HTML_ACCESS_MODIFY_DESC_CAPTION_ACL') . ' ' . $actionTitle . ' ' . JText::_('JLIB_HTML_ACCESS_MODIFY_DESC_CAPTION_TABLE') . '</caption>';
$html[] = ' <tr>';
$html[] = ' <th class="col1 hidelabeltxt">' . JText::_('JLIB_RULES_GROUP') . '</th>';
$html[] = ' <th class="col2">' . JText::_('JLIB_RULES_INHERIT') . '</th>';
$html[] = ' <th class="col3 hidelabeltxt">' . JText::_('JMODIFY') . '</th>';
$html[] = ' <th class="col4">' . JText::_('JCURRENT') . '</th>';
$html[] = ' </tr>';
foreach ($groups as $i => $group) {
$selected = $rules->allow($action->name, $group->value);
$html[] = ' <tr class="row' . $i % 2 . '">';
$html[] = ' <td class="col1">' . $group->text . '</td>';
$html[] = ' <td class="col2">' . ($inheriting->allow($action->name, $group->identities) ? $images['allow-i'] : $images['deny-i']) . '</td>';
$html[] = ' <td class="col3">';
$html[] = ' <select id="' . $idPrefix . '_' . $action->name . '_' . $group->value . '" class="inputbox" size="1" name="' . $control . '[' . $action->name . '][' . $group->value . ']" title="' . JText::sprintf('JLIB_RULES_SELECT_ALLOW_DENY_GROUP', $actionTitle, $group->text) . '">';
$html[] = ' <option value=""' . ($selected === null ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_INHERIT') . '</option>';
$html[] = ' <option value="1"' . ($selected === true ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_ALLOWED') . '</option>';
$html[] = ' <option value="0"' . ($selected === false ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_DENIED') . '</option>';
$html[] = ' </select>';
$html[] = ' </td>';
$html[] = ' <td class="col4">' . ($assetId ? $inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'] : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . '</td>';
$html[] = ' </tr>';
}
$html[] = ' </table>';
}
$html[] = JHtml::_('tabs.end');
// Build the footer with legend and special purpose buttons.
$html[] = ' <div class="clr"></div>';
$html[] = ' <ul class="acllegend fltlft">';
$html[] = ' <li class="acl-allowed">' . JText::_('JLIB_RULES_ALLOWED') . '</li>';
$html[] = ' <li class="acl-denied">' . JText::_('JLIB_RULES_DENIED') . '</li>';
$html[] = ' </ul>';
$html[] = '</div>';
return implode("\n", $html);
}
示例13: getDefaultAssetRules
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__assets'))->where($db->quoteName('name') . ' = ' . $db->quote($component));
$db->setQuery($query);
$db->execute();
if ($db->loadRowList()) {
// asset alread set so use saved rules
$assetId = (int) $db->loadResult();
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules) {
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule) {
$v = explode('.', $name);
if ($view !== $v[0]) {
// remove since it is not part of this view
unset($_result->{$name});
} else {
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count($_result)) {
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
return $rules;
}
return $result;
}
}
return JAccess::getAssetRules(0);
}
示例14: getDefaultAssetValues
/**
* Gets the default asset values for a component.
*
* @param $string $component The component asset name to search for
*
* @return JAccessRules The JAccessRules object for the asset
*/
protected function getDefaultAssetValues($component)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__assets'))->where($db->quoteName('name') . ' = ' . $db->quote($component));
$db->setQuery($query);
$assetId = (int) $db->loadResult();
return JAccess::getAssetRules($assetId);
}
示例15: saveTask
/**
* Save entry
*
* @return void
*/
public function saveTask()
{
// Check for request forgeries
Request::checkToken();
// Incoming password blacklist edits
$fields = Request::getVar('fields', array(), 'post');
// Load the record
$row = Accessgroup::oneOrNew($fields['id'])->set($fields);
// Check the super admin permissions for group
// We get the parent group permissions and then check the group permissions manually
// We have to calculate the group permissions manually because we haven't saved the group yet
$parentSuperAdmin = \JAccess::checkGroup($fields['parent_id'], 'core.admin');
// Get core.admin rules from the root asset
$rules = \JAccess::getAssetRules('root.1')->getData('core.admin');
// Get the value for the current group (will be true (allowed), false (denied), or null (inherit)
$groupSuperAdmin = $rules['core.admin']->allow($row->get('id'));
// We only need to change the $groupSuperAdmin if the parent is true or false. Otherwise, the value set in the rule takes effect.
if ($parentSuperAdmin === false) {
// If parent is false (Denied), effective value will always be false
$groupSuperAdmin = false;
} elseif ($parentSuperAdmin === true) {
// If parent is true (allowed), group is true unless explicitly set to false
$groupSuperAdmin = $groupSuperAdmin === false ? false : true;
}
// Check for non-super admin trying to save with super admin group
$iAmSuperAdmin = User::authorise('core.admin');
if (!$iAmSuperAdmin && $groupSuperAdmin) {
Notify::error(Lang::txt('JLIB_USER_ERROR_NOT_SUPERADMIN'));
return $this->editTask($row);
}
// Check for super-admin changing self to be non-super-admin
// First, are we a super admin>
if ($iAmSuperAdmin) {
// Next, are we a member of the current group?
$myGroups = \JAccess::getGroupsByUser(User::get('id'), false);
if (in_array($fields['id'], $myGroups)) {
// Now, would we have super admin permissions without the current group?
$otherGroups = array_diff($myGroups, array($fields['id']));
$otherSuperAdmin = false;
foreach ($otherGroups as $otherGroup) {
$otherSuperAdmin = $otherSuperAdmin ? $otherSuperAdmin : \JAccess::checkGroup($otherGroup, 'core.admin');
}
// If we would not otherwise have super admin permissions
// and the current group does not have super admin permissions, throw an exception
if (!$otherSuperAdmin && !$groupSuperAdmin) {
Notify::error(Lang::txt('JLIB_USER_ERROR_CANNOT_DEMOTE_SELF'));
return $this->editTask($row);
}
}
}
if ($this->getTask() == 'save2copy') {
$row->set('id', null);
}
// Try to save
if (!$row->save()) {
Notify::error($row->getError());
return $this->editTask($row);
}
Notify::success(Lang::txt('COM_MEMBERS_SAVE_SUCCESS'));
if ($this->getTask() == 'save2new') {
$row = Accessgroup::blank();
}
// Fall through to edit form
if (in_array($this->getTask(), array('apply', 'save2new', 'save2copy'))) {
return $this->editTask($row);
}
// Redirect
$this->cancelTask();
}