Back to Access class

Method actions

public static string
actions
(mixed $name, mixed $selected, mixed $component, mixed $section = 'global')
Returns a UL list of actions with checkboxes
Parameters
  • string $name The name of the checkbox controls array
  • array $selected An array of the checked boxes
  • string $component The component the permissions apply to
  • string $section The section (within a component) the permissions apply to
Returns
  • string
Since
  • 1.6
-
  • \Joomla\CMS\Access\Access
Class: Access
Project: Joomla

Method actions - Source code

/**
 * Returns a UL list of actions with checkboxes
 *
 * @param   string  $name       The name of the checkbox controls array
 * @param   array   $selected   An array of the checked boxes
 * @param   string  $component  The component the permissions apply to
 * @param   string  $section    The section (within a component) the permissions apply to
 *
 * @return  string
 *
 * @see     AccessCheck
 * @since   1.6
 */
public static function actions($name, $selected, $component, $section = 'global')
{
    static $count;
    $count++;
    $actions = AccessCheck::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml', "/access/section[@name='" . $section . "']/");
    $html = array();
    $html[] = '<ul class="checklist access-actions">';
    for ($i = 0, $n = count($actions); $i < $n; $i++) {
        $item =& $actions[$i];
        // Setup  the variable attributes.
        $eid = $count . 'action_' . $item->id;
        $checked = in_array($item->id, $selected) ? ' checked="checked"' : '';
        // Build the HTML for the item.
        $html[] = '	<li>';
        $html[] = '		<input type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"';
        $html[] = '			' . $checked . '>';
        $html[] = '		<label for="' . $eid . '">';
        $html[] = '			' . Text::_($item->title);
        $html[] = '		</label>';
        $html[] = '	</li>';
    }
    $html[] = '</ul>';
    return implode("\n", $html);
}