/** * Compiles a list of installed or defined modules */ function viewModules($option, $client) { global $database, $my, $mainframe, $mosConfig_list_limit; if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); // get the total number of records $database->setQuery("SELECT count(*) FROM #__modules WHERE {$where}"); $total = $database->loadResult(); require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $database->setQuery("SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages" . "\nFROM #__modules AS m" . "\nLEFT JOIN #__users AS u ON u.id = m.checked_out" . "\nLEFT JOIN #__groups AS g ON g.id = m.access" . "\nLEFT JOIN #__modules_menu AS mm ON mm.moduleid=m.id" . "\nWHERE {$where}" . "\nGROUP BY m.id" . "\nORDER BY published DESC, position ASC, ordering ASC" . "\nLIMIT {$pageNav->limitstart},{$pageNav->limit}"); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_modules::showModules($rows, $my->id, $client, $pageNav, $option); }
/** * Compiles a list of installed or defined modules */ function viewModules($option, $client) { global $database, $my, $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path; $filter_position = $mainframe->getUserStateFromRequest("filter_position{$option}{$client}", 'filter_position', 0); $filter_type = $mainframe->getUserStateFromRequest("filter_type{$option}{$client}", 'filter_type', 0); $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit)); $limitstart = intval($mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0)); $search = $mainframe->getUserStateFromRequest("search{$option}{$client}", 'search', ''); if (get_magic_quotes_gpc()) { $search = stripslashes($search); $filter_position = stripslashes($filter_position); $filter_type = stripslashes($filter_type); } if ($client == 'admin') { $where[] = "m.client_id = 1"; $client_id = 1; } else { $where[] = "m.client_id = 0"; $client_id = 0; $client = ''; } // used by filter if ($filter_position) { $where[] = "m.position = " . $database->Quote($filter_position); } if ($filter_type) { $where[] = "m.module = " . $database->Quote($filter_type); } if ($search) { $where[] = "LOWER( m.title ) LIKE '%" . $database->getEscaped(trim(strtolower($search))) . "%'"; } // get the total number of records $query = "SELECT COUNT(*)" . "\n FROM #__modules AS m" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); $database->setQuery($query); $total = $database->loadResult(); require_once $mosConfig_absolute_path . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $query = "SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages" . "\n FROM #__modules AS m" . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = m.access" . "\n LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . "\n GROUP BY m.id" . "\n ORDER BY position ASC, ordering ASC"; $database->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get list of Positions for dropdown filter $query = "SELECT t.position AS value, t.position AS text" . "\n FROM #__template_positions as t" . "\n LEFT JOIN #__modules AS m ON m.position = t.position" . "\n WHERE m.client_id = " . (int) $client_id . "\n GROUP BY t.position" . "\n ORDER BY t.position"; $positions[] = mosHTML::makeOption('0', _SEL_POSITION); $database->setQuery($query); $positions = array_merge($positions, $database->loadObjectList()); $lists['position'] = mosHTML::selectList($positions, 'filter_position', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "{$filter_position}"); // get list of Positions for dropdown filter $query = "SELECT module AS value, module AS text" . "\n FROM #__modules" . "\n WHERE client_id = " . (int) $client_id . "\n GROUP BY module" . "\n ORDER BY module"; $types[] = mosHTML::makeOption('0', _SEL_TYPE); $database->setQuery($query); $types = array_merge($types, $database->loadObjectList()); $lists['type'] = mosHTML::selectList($types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "{$filter_type}"); HTML_modules::showModules($rows, $my->id, $client, $pageNav, $option, $lists, $search); }