- md5
- f089bd4ab0d3cca3e84af0cac1a601b8
- sha1
- c9d3ce12e25970c6f2a2a4c5f103e3ea814ad3b2
- sha256
- ed3acff856263f2ad0fb6ae1163e8c6164d873f7da61cd4fe3994b0a175a42e2
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Cpanel\Administrator\Model;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Updater\Updater;
use Joomla\Component\Cpanel\Administrator\Entities\SystemHeader;
use Joomla\Component\Cpanel\Administrator\Entities\SystemItem;
/**
* Model to get a list of system icons.
*
* @since 4.0.0
*/
class SystemModel extends BaseDatabaseModel
{
/**
* Method to get a list of system icons with plugin hooks
*
* @return array
*
* @since 4.0.0
*/
public function getItems()
{
$user = Factory::getUser();
$systemSection = new SystemHeader('COM_CPANEL_SYSTEM_SETUP', 'cog');
$maintainSection = new SystemHeader('MOD_MENU_MAINTAIN', 'refresh');
$infoSection = new SystemHeader('MOD_MENU_INFORMATION', 'refresh');
$installSection = new SystemHeader('MOD_MENU_INSTALL', 'download');
$manageSection = new SystemHeader('MOD_MENU_MANAGE', 'refresh');
$updateSection = new SystemHeader('MOD_MENU_UPDATE', 'upload');
$templateSection = new SystemHeader('MOD_MENU_TEMPLATES', 'image');
$accessSection = new SystemHeader('MOD_MENU_ACCESS', 'lock');
// System
if ($user->authorise('core.admin'))
{
$systemSection->addItem(
new SystemItem('MOD_MENU_CONFIGURATION', 'index.php?option=com_config')
);
}
// Maintain
if ($user->authorise('core.manage', 'com_cache'))
{
$maintainSection->addItem(
new SystemItem('MOD_MENU_CLEAR_CACHE', 'index.php?option=com_cache')
);
$maintainSection->addItem(
new SystemItem('MOD_MENU_PURGE_EXPIRED_CACHE', 'index.php?option=com_cache&view=purge')
);
}
if ($user->authorise('core.manage', 'com_checkin'))
{
/** @var \Joomla\Component\Checkin\Administrator\Model\CheckinModel $checkinModel */
$checkinModel = $this->bootComponent('com_checkin')->getMVCFactory()->createModel('Checkin', 'Administrator', ['ignore_request' => true]);
$checkins = count($checkinModel->getItems());
$maintainSection->addItem(
new SystemItem('MOD_MENU_GLOBAL_CHECKIN', 'index.php?option=com_checkin', $checkins)
);
}
if ($user->authorise('core.manage', 'com_installer'))
{
/** @var \Joomla\Component\Installer\Administrator\Extension\InstallerComponent $installerComponent */
$installerComponent = $this->bootComponent('com_installer');
/** @var \Joomla\Component\Installer\Administrator\Model\WarningsModel $warningsModel */
$warningsModel = $installerComponent->getMVCFactory()->createModel('Warnings', 'Administrator', ['ignore_request' => true]);
$warningMessages = count($warningsModel->getItems());
$infoSection->addItem(
new SystemItem('MOD_MENU_INFORMATION_WARNINGS', 'index.php?option=com_installer&view=warnings', $warningMessages)
);
}
if ($user->authorise('core.manage', 'com_postinstall'))
{
/** @var \Joomla\Component\Postinstall\Administrator\Model\MessagesModel $messagesModel */
$messagesModel = $this->bootComponent('com_postinstall')->getMVCFactory()->createModel('Messages', 'Administrator', ['ignore_request' => true]);
$messages = count($messagesModel->getItems());
$infoSection->addItem(
new SystemItem('MOD_MENU_INFORMATION_POST_INSTALL_MESSAGES', 'index.php?option=com_postinstall', $messages)
);
}
if ($user->authorise('core.admin'))
{
$infoSection->addItem(
new SystemItem('MOD_MENU_SYSTEM_INFORMATION_SYSINFO', 'index.php?option=com_admin&view=sysinfo')
);
}
if ($user->authorise('core.manage', 'com_installer'))
{
/** @var \Joomla\Component\Installer\Administrator\Model\DatabaseModel $warningsModel */
$databaseModel = $installerComponent->getMVCFactory()->createModel('Database', 'Administrator', ['ignore_request' => true]);
$changeSet = $databaseModel->getItems();
$changeSetCount = 0;
foreach ($changeSet as $item)
{
$changeSetCount += $item['errorsCount'];
}
$infoSection->addItem(
new SystemItem(
'MOD_MENU_SYSTEM_INFORMATION_DATABASE',
'index.php?option=com_installer&view=database',
$changeSetCount === 0 ? '' : $changeSetCount
)
);
}
// Install
if ($user->authorise('core.manage', 'com_installer'))
{
/** @var \Joomla\Component\Installer\Administrator\Model\DiscoverModel $discoverModel */
$discoverModel = $this->bootComponent('com_installer')->getMVCFactory()->createModel('Discover', 'Administrator', ['ignore_request' => true]);
$discoverModel->discover();
$discoveredExtensions = count($discoverModel->getItems());
$installSection->addItem(
new SystemItem('MOD_MENU_INSTALL_EXTENSIONS', 'index.php?option=com_installer&view=install')
);
$installSection->addItem(
new SystemItem('MOD_MENU_INSTALL_DISCOVER', 'index.php?option=com_installer&view=discover', $discoveredExtensions)
);
$installSection->addItem(
new SystemItem('MOD_MENU_INSTALL_LANGUAGES', 'index.php?option=com_installer&view=languages')
);
}
if ($user->authorise('core.manage', 'com_installer'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_EXTENSIONS', 'index.php?option=com_installer&view=manage')
);
}
if ($user->authorise('core.manage', 'com_languages'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_LANGUAGES', 'index.php?option=com_languages&view=installed')
);
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_LANGUAGES_CONTENT', 'index.php?option=com_languages&view=languages')
);
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_LANGUAGES_OVERRIDES', 'index.php?option=com_languages&view=overrides')
);
}
if ($user->authorise('core.manage', 'com_csp'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_CSP', 'index.php?option=com_csp')
);
}
if ($user->authorise('core.manage', 'com_plugins'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_PLUGINS', 'index.php?option=com_plugins')
);
}
if ($user->authorise('core.manage', 'com_redirect'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_MANAGE_REDIRECTS', 'index.php?option=com_redirect')
);
}
if ($user->authorise('core.manage', 'com_modules'))
{
$manageSection->addItem(
new SystemItem('MOD_MENU_EXTENSIONS_MODULE_MANAGER_SITE', 'index.php?option=com_modules&view=modules&client_id=0')
);
$manageSection->addItem(
new SystemItem('MOD_MENU_EXTENSIONS_MODULE_MANAGER_ADMINISTRATOR', 'index.php?option=com_modules&view=modules&client_id=1')
);
}
if ($user->authorise('core.manage', 'com_joomlaupdate'))
{
/** @var \Joomla\Component\Joomlaupdate\Administrator\Model\UpdateModel $joomlaUpdateModel */
$joomlaUpdateModel = $this->bootComponent('com_joomlaupdate')->getMVCFactory()->createModel('Update', 'Administrator', ['ignore_request' => true]);
$joomlaUpdateModel->refreshUpdates(true);
$joomlaUpdate = $joomlaUpdateModel->getUpdateInformation();
$hasUpdate = $joomlaUpdate['hasUpdate'] ? $joomlaUpdate['latest'] : '';
$updateSection->addItem(
new SystemItem('MOD_MENU_UPDATE_JOOMLA', 'index.php?option=com_joomlaupdate', $hasUpdate)
);
}
if ($user->authorise('core.manage', 'com_installer'))
{
Updater::getInstance()->findUpdates();
/** @var \Joomla\Component\Installer\Administrator\Model\UpdateModel $updateModel */
$updateModel = $installerComponent->getMVCFactory()->createModel('Update', 'Administrator', ['ignore_request' => true]);
$extensionsCount = count($updateModel->getItems());
$updateSection->addItem(
new SystemItem('MOD_MENU_UPDATE_EXTENSIONS', 'index.php?option=com_installer&view=update', $extensionsCount)
);
$updateSection->addItem(
new SystemItem('MOD_MENU_UPDATE_SOURCES', 'index.php?option=com_installer&view=updatesites')
);
}
// Templates
if ($user->authorise('core.manage', 'com_templates'))
{
$templateSection->addItem(
new SystemItem('MOD_MENU_TEMPLATE_SITE_TEMPLATES', 'index.php?option=com_templates&view=templates&client_id=0')
);
$templateSection->addItem(
new SystemItem('MOD_MENU_TEMPLATE_SITE_STYLES', 'index.php?option=com_templates&view=styles&client_id=0')
);
$templateSection->addItem(
new SystemItem('MOD_MENU_TEMPLATE_ADMIN_TEMPLATES', 'index.php?option=com_templates&view=templates&client_id=1')
);
$templateSection->addItem(
new SystemItem('MOD_MENU_TEMPLATE_ADMIN_STYLES', 'index.php?option=com_templates&view=styles&client_id=1')
);
}
// Access
if ($user->authorise('core.manage', 'com_users'))
{
$accessSection->addItem(
new SystemItem('MOD_MENU_ACCESS_GROUPS', 'index.php?option=com_users&view=groups')
);
$accessSection->addItem(
new SystemItem('MOD_MENU_ACCESS_LEVELS', 'index.php?option=com_users&view=levels')
);
}
// Global Configuration - Permissions and Filters
if ($user->authorise('core.admin'))
{
$accessSection->addItem(
new SystemItem('MOD_MENU_ACCESS_SETTINGS', 'index.php?option=com_config#page-permissions')
);
$accessSection->addItem(
new SystemItem('MOD_MENU_ACCESS_TEXT_FILTERS', 'index.php?option=com_config#page-filters')
);
}
$links = [
$systemSection,
$maintainSection,
$infoSection,
$installSection,
$manageSection,
$updateSection,
$templateSection,
$accessSection
];
// TODO: Plugin event to allow custom sections to be added
return $links;
}
}
No other release has this exact content. See every version of this file.