diff --git a/administrator/components/com_menus/models/menus.php b/administrator/components/com_menus/models/menus.php index 7404ce9f6ce58..e75c20ee66987 100644 --- a/administrator/components/com_menus/models/menus.php +++ b/administrator/components/com_menus/models/menus.php @@ -1,8 +1,10 @@ getStoreId('getItems'); // Try to load the data from internal storage. - if (!empty($this->cache[$store])) { + if (!empty($this->cache[$store])) + { return $this->cache[$store]; } @@ -59,7 +65,8 @@ public function getItems() $items = parent::getItems(); // If emtpy or an error, just return. - if (empty($items)) { + if (empty($items)) + { return array(); } @@ -87,7 +94,8 @@ public function getItems() $db->setQuery($query); $countPublished = $db->loadAssocList('menutype', 'count_published'); - if ($db->getErrorNum()) { + if ($db->getErrorNum()) + { $this->setError($db->getErrorMsg()); return false; } @@ -95,12 +103,12 @@ public function getItems() // Get the unpublished menu counts. $query->clear('where') ->where('m.published = 0') - ->where('m.menutype IN ('.$menuTypes.')') - ; + ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countUnpublished = $db->loadAssocList('menutype', 'count_published'); - if ($db->getErrorNum()) { + if ($db->getErrorNum()) + { $this->setError($db->getErrorMsg()); return false; } @@ -108,12 +116,12 @@ public function getItems() // Get the trashed menu counts. $query->clear('where') ->where('m.published = -2') - ->where('m.menutype IN ('.$menuTypes.')') - ; + ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countTrashed = $db->loadAssocList('menutype', 'count_published'); - if ($db->getErrorNum()) { + if ($db->getErrorNum()) + { $this->setError($db->getErrorMsg()); return false; } @@ -121,9 +129,9 @@ public function getItems() // Inject the values back into the array. foreach ($items as $item) { - $item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0; - $item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0; - $item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0; + $item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0; + $item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0; + $item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0; } // Add the items to the internal cache. @@ -135,7 +143,9 @@ public function getItems() /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query + * + * @since 1.6 */ protected function getListQuery() { @@ -161,7 +171,12 @@ protected function getListQuery() * * Note. Calling getState in this method will result in recursion. * - * @since 1.6 + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { @@ -172,12 +187,34 @@ protected function populateState($ordering = null, $direction = null) parent::populateState('a.id', 'asc'); } + /** + * Gets the extension id of the core mod_menu module. + * + * @return integer + * + * @since 2.5 + */ + public function getModMenuId() + { + $db = $this->getDbo(); + $query = $db->getQuery(true); + + $query->select('e.extension_id') + ->from('#__extensions AS e') + ->where('e.type = ' . $db->quote('module')) + ->where('e.element = ' . $db->quote('mod_menu')) + ->where('e.client_id = 0'); + $db->setQuery($query); + + return $db->loadResult(); + } + /** * Gets a list of all mod_mainmenu modules and collates them by menutype * - * @return array + * @return array */ - function &getModules() + public function &getModules() { $model = JModel::getInstance('Menu', 'MenusModel', array('ignore_request' => true)); $result = &$model->getModules(); diff --git a/administrator/components/com_menus/views/menus/tmpl/default.php b/administrator/components/com_menus/views/menus/tmpl/default.php index c2f84cfd60659..67bf1bb698f84 100644 --- a/administrator/components/com_menus/views/menus/tmpl/default.php +++ b/administrator/components/com_menus/views/menus/tmpl/default.php @@ -1,10 +1,10 @@ get('id'); -$listOrder = $this->escape($this->state->get('list.ordering')); -$listDirn = $this->escape($this->state->get('list.direction')); +$uri = JFactory::getUri(); +$return = base64_encode($uri); +$user = JFactory::getUser(); +$userId = $user->get('id'); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +$modMenuId = (int) $this->get('ModMenuId'); ?>