function module_is_enabled($module) { $_nails_modules = get_loaded_modules(); // -------------------------------------------------------------------------- // Allow wildcard reset($_nails_modules); $_wildcard = key($_nails_modules); if ($_wildcard == '*') { return TRUE; } // -------------------------------------------------------------------------- preg_match('/^(.*?)(\\[(.*?)\\])?$/', $module, $_matches); $_module = isset($_matches[1]) ? $_matches[1] : ''; $_submodule = isset($_matches[3]) ? $_matches[3] : ''; if (isset($_nails_modules[$_module])) { // Are we testing for a submodule in particular? if ($_submodule) { return array_search($_submodule, $_nails_modules[$_module]) !== FALSE; } else { return TRUE; } } else { return FALSE; } }
// the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Pastèque is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Pastèque. If not, see <http://www.gnu.org/licenses/>. namespace Pasteque; // Load template if (!isset($config['template'])) { die("No template given"); } $tmpl_file = PT::$ABSPATH . "/templates/" . $config['template'] . "/module.php"; if (!file_exists($tmpl_file) || !is_readable($tmpl_file)) { die("Template not found"); } require_once $tmpl_file; // Load modules $modules = get_loaded_modules(get_user_id()); foreach ($modules as $module) { $module_file = PT::$ABSPATH . "/modules/" . $module . "/module.php"; if (file_exists($module_file)) { require_once $module_file; } } call_hooks("module_load"); load_modules_i18n(detect_preferred_language());
/** * Loop through the enabled modules and see if a controller exists for it; if * it does load it up and execute the announce static method to see if we can * display it to the active user. * * @access public * @return void * **/ private function _load_active_modules() { $_modules = get_loaded_modules(); // -------------------------------------------------------------------------- // Dashboard, always present, and always first $this->_loaded_modules['dashboard'] = $this->admin_model->find_module('dashboard'); // -------------------------------------------------------------------------- // Handle wildcard reset($_modules); if (key($_modules) == '*') { $_modules['admin'] = array(); $_controllers = scandir(NAILS_PATH . 'modules/admin/controllers/'); $_ignore = array('.', '..', '_admin.php'); foreach ($_controllers as $controller) { if (array_search($controller, $_ignore) === FALSE) { $_temp = pathinfo($controller); $_modules['admin'][] = $_temp['filename']; } } } // -------------------------------------------------------------------------- if (isset($_modules['admin']) && $_modules['admin']) { foreach ($_modules['admin'] as $module) { $_module = $this->admin_model->find_module($module); if ((array) $_module) { $this->_loaded_modules[$module] = $_module; } } } }