Skip to content

Commit

Permalink
Merge pull request #55 from joomla/menusystem
Browse files Browse the repository at this point in the history
Menusystem
  • Loading branch information
coolcat-creations authored Feb 21, 2019
2 parents 5966b13 + 1ef169d commit e6d63b1
Show file tree
Hide file tree
Showing 36 changed files with 1,159 additions and 753 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO `#__modules` (`id`, `asset_id`, `title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES (88, 65, 'Need support?', '', '<p>You can find help here:<br /><a href="https://forum.joomla.org/" rel="nofollow">Joomla! Support forum</a><br /><a href="https://docs.joomla.org" rel="nofollow">Joomla! Documentation</a><br /><a href="https://www.joomla.org/" rel="nofollow">Joomla! News</a></p>', 1, 'sidebar', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 1, 1, '{"prepare_content":1,"layout":"_:default","moduleclass_sfx":"","cache":1,"cache_time":900,"module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');
INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (88, 0);
INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES ('Need support?', '', '<p>You can find help here:<br /><a href="https://forum.joomla.org/" rel="nofollow">Joomla! Support forum</a><br /><a href="https://docs.joomla.org" rel="nofollow">Joomla! Documentation</a><br /><a href="https://www.joomla.org/" rel="nofollow">Joomla! News</a></p>', 1, 'sidebar', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 1, 1, '{"prepare_content":1,"layout":"_:default","moduleclass_sfx":"","cache":1,"cache_time":900,"module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');
INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(319, 0, 'mod_submenu', 'module', 'mod_submenu', '', 1, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0);

INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
('System Submenu', '', NULL, 1, 'cpanel-system', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"system","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');

INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
('Content Submenu', '', NULL, 1, 'cpanel-content', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"content","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');

INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);

INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
('Menus Submenu', '', NULL, 1, 'cpanel-menus', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"menus","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');

INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);

INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
('Components Submenu', '', NULL, 1, 'cpanel-components', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"components","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');

INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);

INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`) VALUES
('Users Submenu', '', NULL, 1, 'cpanel-users', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"users","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');

INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES (LAST_INSERT_ID(), 0);
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
INSERT INTO "#__modules" ("id", "asset_id", "title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
(88, 65, 'Need support?', '', '<p>You can find help here:<br /><a href="https://forum.joomla.org/" rel="nofollow">Joomla! Support forum</a><br /><a href="https://docs.joomla.org" rel="nofollow">Joomla! Documentation</a><br /><a href="https://www.joomla.org/" rel="nofollow">Joomla! News</a></p>', 1, 'sidebar', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 1, 1, '{"prepare_content":1,"layout":"_:default","moduleclass_sfx":"","cache":1,"cache_time":900,"module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*');
INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (88, 0);
INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('Need support?', '', '<p>You can find help here:<br /><a href="https://forum.joomla.org/" rel="nofollow">Joomla! Support forum</a><br /><a href="https://docs.joomla.org" rel="nofollow">Joomla! Documentation</a><br /><a href="https://www.joomla.org/" rel="nofollow">Joomla! News</a></p>', 1, 'sidebar', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 1, 1, '{"prepare_content":1,"layout":"_:default","moduleclass_sfx":"","cache":1,"cache_time":900,"module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "checked_out", "checked_out_time", "ordering", "state") VALUES
(319, 0, 'mod_submenu', 'module', 'mod_submenu', '', 1, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0);

INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('System Submenu', '', NULL, 1, 'cpanel-system', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"system","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('Content Submenu', '', NULL, 1, 'cpanel-content', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"content","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);

INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('Menus Submenu', '', NULL, 1, 'cpanel-menus', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"menus","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);

INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('Components Submenu', '', NULL, 1, 'cpanel-components', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"components","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);

INSERT INTO "#__modules" ("title", "note", "content", "ordering", "position", "checked_out", "checked_out_time", "publish_up", "publish_down", "published", "module", "access", "showtitle", "params", "client_id", "language") VALUES
('Users Submenu', '', NULL, 1, 'cpanel-content', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_submenu', 1, 0, '{"menutype":"*","preset":"users","layout":"_:default","moduleclass_sfx":"","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}', 1, '*')
RETURNING id INTO lastmoduleid;

INSERT INTO "#__modules_menu" ("moduleid", "menuid") VALUES (lastmoduleid, 0);
145 changes: 145 additions & 0 deletions administrator/components/com_cpanel/Controller/SystemController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?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\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Updater\Updater;

/**
* Cpanel Controller
*
* @since 1.5
*/
class SystemController extends BaseController
{
public function loadSystemInfo()
{
$type = $this->input->get('type');

$count = 0;

switch ($type)
{
case 'postinstall':
$count = $this->countItems('com_postinstall', 'Messages');
break;

case 'installationwarnings':
$count = $this->countItems('com_installer', 'Warnings');
break;

case 'checkins':
$count = $this->countItems('com_checkin', 'Checkin');
break;

case 'databaseupdate':
$count = $this->countDatabaseUpdates();
break;

case 'systemupdate':
$count = $this->countSystemUpdates();
break;

case 'extensionupdate':
$count = $this->countExtensionUpdates();
break;

case 'extensiondiscover':
$count = $this->countItems('com_installer', 'Discover');
break;

default:
/**
* @TODO: Plugin event to allow custom sections to be added (see SystemModel)
*/
throw new \Exception(Text::_('COM_CPANEL_ERROR_DASHBOARD_TYPE_NOT_SUPPORTED'));
}

echo new JsonResponse($count);
}

protected function countDatabaseUpdates()
{
if (!Factory::getUser()->authorise('core.manage', 'com_installer'))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}

$boot = Factory::getApplication()->bootComponent('com_installer');
$model = $boot->getMVCFactory()->createModel('Database', 'Administrator', ['ignore_request' => true]);

$changeSet = $model->getItems();

$changeSetCount = 0;

foreach ($changeSet as $item)
{
$changeSetCount += $item['errorsCount'];
}

return $changeSetCount;
}

protected function countSystemUpdates()
{
if (!Factory::getUser()->authorise('core.manage', 'com_joomlaupdate'))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}

$boot = Factory::getApplication()->bootComponent('com_joomlaupdate');
$model = $boot->getMVCFactory()->createModel('Update', 'Administrator', ['ignore_request' => true]);

$model->refreshUpdates(true);

$joomlaUpdate = $model->getUpdateInformation();

$hasUpdate = $joomlaUpdate['hasUpdate'] ? $joomlaUpdate['latest'] : '';

return $hasUpdate;
}

protected function countExtensionUpdates()
{
if (!Factory::getUser()->authorise('core.manage', 'com_installer'))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}

$boot = Factory::getApplication()->bootComponent('com_installer');
$model = $boot->getMVCFactory()->createModel('Discover', 'Administrator', ['ignore_request' => true]);

$model->discover();

$items = count($model->getItems());

return $items;
}

protected function countItems($extension, $model)
{
if (!Factory::getUser()->authorise('core.manage', $extension))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}

$boot = Factory::getApplication()->bootComponent($extension);
$model = $boot->getMVCFactory()->createModel($model, 'Administrator', ['ignore_request' => true]);

$items = count($model->getItems());

return $items;
}
}
123 changes: 0 additions & 123 deletions administrator/components/com_cpanel/Entities/SystemHeader.php

This file was deleted.

Loading

0 comments on commit e6d63b1

Please sign in to comment.