element['section'] ? (string) $this->element['section'] : ''; $component = $this->element['component'] ? (string) $this->element['component'] : ''; $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; // Get the actions for the asset. $actions = JAccess::getActions($component, $section); // Iterate over the children and add to the actions. foreach ($this->element->children() as $el) { if ($el->getName() == 'action') { $actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'], 'description' => (string) $el['description']); } } // Get the explicit rules for this asset. if ($section == '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(); } else { // Find the asset id of the content. // Note that for global configuration, com_config injects asset_id = 1 into the form. $assetId = $this->form->getValue($assetField); } // Use the compact form for the content rules (deprecated). /* @todo remove code: if (!empty($component) && $section != 'component') { return JHtml::_('rules.assetFormWidget', $actions, $assetId, $assetId ? null : $component, $this->name, $this->id); } */ // Full width format. // Get the rules for just this asset (non-recursive). $assetRules = JAccess::getAssetRules($assetId); // Get the available user groups. $groups = $this->getUserGroups(); // Prepare output $html = array(); // Description $html[] = '

' . JText::_('JLIB_RULES_SETTINGS_DESC') . '

'; // Begin tabs $html[] = '
'; // Building tab nav $html[] = ''; $html[] = '
'; // Start a row for each user group. foreach ($groups as $group) { // Initial Active Pane $active = ""; if ($group->value == 1) { $active = " active"; } $html[] = '
'; $html[] = ''; $html[] = ''; $html[] = ''; $html[] = ''; $html[] = ''; // The calculated setting is not shown for the root group of global configuration. $canCalculateSettings = ($group->parent_id || !empty($component)); if ($canCalculateSettings) { $html[] = ''; } $html[] = ''; $html[] = ''; $html[] = ''; foreach ($actions as $action) { $html[] = ''; $html[] = ''; $html[] = ''; // Build the Calculated Settings column. // The inherited settings column is not displayed for the root group in global configuration. if ($canCalculateSettings) { $html[] = ''; } $html[] = ''; } $html[] = ''; $html[] = '
'; $html[] = '' . JText::_('JLIB_RULES_ACTION') . ''; $html[] = ''; $html[] = '' . JText::_('JLIB_RULES_SELECT_SETTING') . ''; $html[] = ''; $html[] = '' . JText::_('JLIB_RULES_CALCULATED_SETTING') . ''; $html[] = '
'; $html[] = ''; $html[] = ''; $html[] = '  '; // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict. if (($assetRule === true) && ($inheritedRule === false)) { $html[] = JText::_('JLIB_RULES_CONFLICT'); } $html[] = ''; // This is where we show the current effective settings considering currrent group, path and cascade. // Check whether this is a component or global. Change the text slightly. if (JAccess::checkGroup($group->value, 'core.admin', $assetId) !== true) { if ($inheritedRule === null) { $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . ''; } elseif ($inheritedRule === true) { $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . ''; } elseif ($inheritedRule === false) { if ($assetRule === false) { $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . ''; } else { $html[] = ' ' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED') . ''; } } } elseif (!empty($component)) { $html[] = ' ' . JText::_('JLIB_RULES_ALLOWED_ADMIN') . ''; } else { // Special handling for groups that have global admin because they can't be denied. // The admin rights can be changed. if ($action->name === 'core.admin') { $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . ''; } elseif ($inheritedRule === false) { // Other actions cannot be changed. $html[] = ' ' . JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . ''; } else { $html[] = ' ' . JText::_('JLIB_RULES_ALLOWED_ADMIN') . ''; } } $html[] = '
'; } $html[] = '
'; $html[] = '
'; if ($section == 'component' || $section == null) { $html[] = JText::_('JLIB_RULES_SETTING_NOTES'); } else { $html[] = JText::_('JLIB_RULES_SETTING_NOTES_ITEM'); } $html[] = '
'; return implode("\n", $html); } /** * Get a list of the user groups. * * @return array * * @since 11.1 */ protected function getUserGroups() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level, a.parent_id') ->from('#__usergroups AS a') ->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt') ->group('a.id, a.title, a.lft, a.rgt, a.parent_id') ->order('a.lft ASC'); $db->setQuery($query); $options = $db->loadObjectList(); return $options; } }