first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,155 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users component debugging helper.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersHelperDebug
{
/**
* Get a list of the components.
*
* @return array
* @since 1.6
*/
public static function getComponents()
{
// Initialise variable.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('name AS text, element AS value')
->from('#__extensions')
->where('enabled >= 1')
->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if (count($items))
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
// Load language
$extension = $item->value;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
JArrayHelper::sortObjects($items, 'text', 1, true, true);
}
return $items;
}
/**
* Get a list of the actions for the component or code actions.
*
* @param string The name of the component.
*
* @return array
* @since 1.6
*/
public static function getDebugActions($component = null)
{
$actions = array();
// Try to get actions for the component
if (!empty($component))
{
$component_actions = JAccess::getActions($component);
if (!empty($component_actions))
{
foreach ($component_actions as &$action)
{
$actions[$action->title] = array($action->name, $action->description);
}
}
}
// Use default actions from configuration if no component selected or component doesn't have actions
if (empty($actions))
{
$filename = JPATH_ADMINISTRATOR . '/components/com_config/models/forms/application.xml';
if (is_file($filename))
{
$xml = simplexml_load_file($filename);
foreach ($xml->children()->fieldset as $fieldset)
{
if ('permissions' == (string) $fieldset['name'])
{
foreach ($fieldset->children() as $field)
{
if ('rules' == (string) $field['name'])
{
foreach ($field->children() as $action)
{
$actions[(string) $action['title']] = array(
(string) $action['name'],
(string) $action['description']
);
}
break;
break;
break;
}
}
}
}
// Load language
$lang = JFactory::getLanguage();
$extension = 'com_config';
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load($extension, $source, null, false, false)
|| $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load($extension, $source, $lang->getDefault(), false, false);
}
}
return $actions;
}
/**
* Get a list of filter options for the levels.
*
* @return array An array of JHtmlOption elements.
*/
public static function getLevelsOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1', JText::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1));
$options[] = JHtml::_('select.option', '2', JText::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2));
$options[] = JHtml::_('select.option', '3', JText::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3));
$options[] = JHtml::_('select.option', '4', '4');
$options[] = JHtml::_('select.option', '5', '5');
$options[] = JHtml::_('select.option', '6', '6');
return $options;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,205 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extended Utility class for the Users component.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 2.5
*/
class JHtmlUsers
{
/**
* Display an image.
*
* @param string $src The source of the image
*
* @return string A <img> element if the specified file exists, otherwise, a null string
*
* @since 2.5
*/
public static function image($src)
{
$src = preg_replace('#[^A-Z0-9\-_\./]#i', '', $src);
$file = JPATH_SITE . '/' . $src;
jimport('joomla.filesystem.path');
JPath::check($file);
if (!file_exists($file))
{
return '';
}
return '<img src="' . JUri::root() . $src . '" alt="" />';
}
/**
* Displays an icon to add a note for this user.
*
* @param integer $userId The user ID
*
* @return string A link to add a note
*
* @since 2.5
*/
public static function addNote($userId)
{
$title = JText::_('COM_USERS_ADD_NOTE');
return '<a href="' . JRoute::_('index.php?option=com_users&task=note.add&u_id=' . (int) $userId) . '">'
. '<span class="label label-info"><i class="icon-vcard"></i>' . $title . '</span></a>';
}
/**
* Displays an icon to filter the notes list on this user.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to apply a filter
*
* @since 2.5
*/
public static function filterNotes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::_('COM_USERS_FILTER_NOTES');
return '<a href="' . JRoute::_('index.php?option=com_users&view=notes&filter_search=uid:' . (int) $userId) . '">'
. JHtml::_('image', 'admin/filter_16.png', 'COM_USERS_NOTES', array('title' => $title), true) . '</a>';
}
/**
* Displays a note icon.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to a modal window with the user notes
*
* @since 2.5
*/
public static function notes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::plural('COM_USERS_N_USER_NOTES', $count);
return '<a class="modal"'
. ' href="' . JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id=' . (int) $userId) . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'
. '<span class="label label-info"><i class="icon-drawer-2"></i>' . $title . '</span></a>';
}
/**
* Build an array of block/unblock user states to be used by jgrid.state,
* State options will be different for any user
* and for currently logged in user
*
* @param boolean $self True if state array is for currently logged in user
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function blockStates( $self = false)
{
if ($self)
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' => 'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish'
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' => '',
'inactive_title' => 'COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish'
)
);
}
else
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' => 'COM_USERS_TOOLBAR_UNBLOCK',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish'
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' => 'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish'
)
);
}
return $states;
}
/**
* Build an array of activate states to be used by jgrid.state,
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function activateStates()
{
$states = array(
1 => array(
'task' => 'activate',
'text' => '',
'active_title' => 'COM_USERS_TOOLBAR_ACTIVATE',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish'
),
0 => array(
'task' => '',
'text' => '',
'active_title' => '',
'inactive_title' => 'COM_USERS_ACTIVATED',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish'
)
);
return $states;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,193 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users component helper.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersHelper
{
/**
* @var JObject A cache for the available actions.
* @since 1.6
*/
protected static $actions;
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_USERS'),
'index.php?option=com_users&view=users',
$vName == 'users'
);
// Groups and Levels are restricted to core.admin
$canDo = self::getActions();
if ($canDo->get('core.admin'))
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_GROUPS'),
'index.php?option=com_users&view=groups',
$vName == 'groups'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_LEVELS'),
'index.php?option=com_users&view=levels',
$vName == 'levels'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTES'),
'index.php?option=com_users&view=notes',
$vName == 'notes'
);
$extension = JFactory::getApplication()->input->getString('extension');
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
'index.php?option=com_categories&extension=com_users',
$vName == 'categories' || $extension == 'com_users'
);
}
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @since 1.6
* @todo Refactor to work with notes
*/
public static function getActions()
{
if (empty(self::$actions))
{
$user = JFactory::getUser();
self::$actions = new JObject;
$actions = JAccess::getActions('com_users');
foreach ($actions as $action)
{
self::$actions->set($action->name, $user->authorise($action->name, 'com_users'));
}
}
return self::$actions;
}
/**
* Get a list of filter options for the blocked state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('JENABLED'));
$options[] = JHtml::_('select.option', '1', JText::_('JDISABLED'));
return $options;
}
/**
* Get a list of filter options for the activated state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getActiveOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('COM_USERS_ACTIVATED'));
$options[] = JHtml::_('select.option', '1', JText::_('COM_USERS_UNACTIVATED'));
return $options;
}
/**
* Get a list of the user groups for filtering.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getGroups()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value')
->select('a.title AS text')
->select('COUNT(DISTINCT b.id) AS level')
->from('#__usergroups as a')
->join('LEFT', '#__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt')
->group('a.id, a.title, a.lft, a.rgt')
->order('a.lft ASC');
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseNotice(500, $e->getMessage());
return null;
}
foreach ($options as &$option)
{
$option->text = str_repeat('- ', $option->level).$option->text;
}
return $options;
}
/**
* Creates a list of range options used in filter select list
* used in com_users on users view
*
* @return array
*
* @since 2.5
*/
public static function getRangeOptions()
{
$options = array(
JHtml::_('select.option', 'today', JText::_('COM_USERS_OPTION_RANGE_TODAY')),
JHtml::_('select.option', 'past_week', JText::_('COM_USERS_OPTION_RANGE_PAST_WEEK')),
JHtml::_('select.option', 'past_1month', JText::_('COM_USERS_OPTION_RANGE_PAST_1MONTH')),
JHtml::_('select.option', 'past_3month', JText::_('COM_USERS_OPTION_RANGE_PAST_3MONTH')),
JHtml::_('select.option', 'past_6month', JText::_('COM_USERS_OPTION_RANGE_PAST_6MONTH')),
JHtml::_('select.option', 'past_year', JText::_('COM_USERS_OPTION_RANGE_PAST_YEAR')),
JHtml::_('select.option', 'post_year', JText::_('COM_USERS_OPTION_RANGE_POST_YEAR')),
);
return $options;
}
}