public function __construct() { // Normally construct the application controller parent::__construct(); // !!! Your module cunstructer here !!! // /* Module template option ('module_view_paths') When set to true, the template system will load the pages view file from the the templates module view folder if it exists: ( template_path/module_views/module_name/viewname.php ) If it doesnt exist, then it loads the default module view file: ( modules/module_name/views/viewname.php ) If set to false, it will load the default view for the URI ( template_path/views/controller/viewname.php ) ) */ $this->Template->config('module_view_paths', true); /* Example loading a module config file First Param => 'Module Name', Second Param => 'Config Array Name', ( !! Must be Unique! Cannot be 'Core', 'App', OR 'DB' !! ) Third Param => 'Config File Name', Forth Param => 'Array Variable Name' ( !! ONLY IF config options are in an array !! ) */ load_module_config('Devtest', 'mod_config', 'config.php', 'config_options'); // Usage $this->Config = load_class('Config'); $this->Config->get('var_name', 'mod_config'); // OR config('var_name', 'mod_config'); }
require_once $portletPath; $className = "{$moduleLabel}_Portlet"; // Load portlet from database $portletInDB = $portletList->loadPortlet($className); // If it's not in DB, add it if (!$portletInDB) { if (class_exists($className)) { $portlet = new $className($portletInDB['label']); if ($portlet->getLabel()) { $portletList->addPortlet($portlet->getLabel(), $portlet->getName()); } else { Console::warning("Portlet {$className} has no label !"); } } } load_module_config($moduleLabel); Language::load_module_translation($moduleLabel); } } } } catch (Exception $e) { $dialogBox->error(get_lang('Cannot load portlets')); pushClaroMessage($e->__toString()); } // Generate Output from Portlet $outPortlet = ''; $portletList = $portletList->loadAll(true); if (!empty($portletList)) { foreach ($portletList as $portlet) { try { if (empty($portlet['label'])) {
/** * Uninstall a specific module to the platform * * @param integer $moduleId the id of the module to uninstall * @return array( backlog, boolean ) * backlog object * boolean true if the uninstall process suceeded, false otherwise * @todo remove the need of the Backlog and use Exceptions instead */ function uninstall_module($moduleId, $deleteModuleData = true) { $success = true; $backlog = new Backlog(); //first thing to do : deactivate the module // deactivate_module($moduleId); $moduleInfo = get_module_info($moduleId); if ($moduleInfo['type'] == 'tool' && $moduleId) { // 2- delete the module in the cours_tool table, used for every course creation list($backlog2, $success2) = unregister_module_from_courses($moduleId); if ($success2) { $backlog->success(get_lang('Module uninstalled in all courses')); } else { $backlog->append($backlog2); } } //Needed tables and vars $tbl = claro_sql_get_main_tbl(); $backlog = new Backlog(); // 0- find info about the module to uninstall $sql = "SELECT `label`\n FROM `" . $tbl['module'] . "`\n WHERE `id` = " . (int) $moduleId; $module = claro_sql_query_get_single_row($sql); if ($module == false) { $backlog->failure(get_lang("No module to uninstall")); $success = false; } else { // 1- Include the local 'uninstall.sql' and 'uninstall.php' file of the module if they exist // call uninstall.php first in case it requires module database schema to run if (isset($uninstallPhpScript)) { unset($uninstallPhpScript); } $uninstallPhpScript = get_module_path($module['label']) . '/setup/uninstall.php'; if (file_exists($uninstallPhpScript)) { language::load_translation(); language::load_locale_settings(); language::load_module_translation($module['label']); load_module_config($module['label']); require $uninstallPhpScript; $backlog->info(get_lang('Module uninstallation script called')); } if (isset($uninstallSqlScript)) { unset($uninstallSqlScript); } $uninstallSqlScript = get_module_path($module['label']) . '/setup/uninstall.sql'; if ($deleteModuleData && file_exists($uninstallSqlScript)) { $sql = file_get_contents($uninstallSqlScript); if (!empty($sql)) { $sql = str_replace('__CL_MAIN__', get_conf('mainTblPrefix'), $sql); if (false !== claro_sql_multi_query($sql)) { $backlog->success(get_lang('Database uninstallation succeeded')); } else { $backlog->failure(get_lang('Database uninstallation failed')); $success = false; } } } elseif (!$deleteModuleData && file_exists($uninstallSqlScript)) { $backlog->info(get_lang('Database uninstallation skipped')); } // 2- delete related files and folders $modulePath = get_module_path($module['label']); if (file_exists($modulePath)) { if (claro_delete_file($modulePath)) { $backlog->success(get_lang('Delete scripts of the module')); } else { $backlog->failure(get_lang('Error while deleting the scripts of the module')); $success = false; } } // delete the module in the cours_tool table, used for every course creation //retrieve this module_id first $sql = "SELECT id as tool_id FROM `" . $tbl['tool'] . "`\n WHERE claro_label = '" . $module['label'] . "'"; $tool_to_delete = claro_sql_query_get_single_row($sql); $tool_id = $tool_to_delete['tool_id']; $sql = "DELETE FROM `" . $tbl['tool'] . "`\n WHERE claro_label = '" . $module['label'] . "'\n "; claro_sql_query($sql); // 3- delete related entries in main DB $sql = "DELETE FROM `" . $tbl['module'] . "`\n WHERE `id` = " . (int) $moduleId; claro_sql_query($sql); $sql = "DELETE FROM `" . $tbl['module_info'] . "`\n WHERE `module_id` = " . (int) $moduleId; claro_sql_query($sql); $sql = "DELETE FROM `" . $tbl['module_contexts'] . "`\n WHERE `module_id` = " . (int) $moduleId; claro_sql_query($sql); // 4-Manage right - Delete read action $action = new RightToolAction(); $action->setName('read'); $action->setToolId($tool_id); $action->delete(); // Manage right - Delete edit action $action = new RightToolAction(); $action->setName('edit'); $action->setToolId($tool_id); $action->delete(); // 5- remove all docks entries in which the module displays // TODO FIXME handle failure remove_module_dock($moduleId, 'ALL'); // 6- cache file with the module's include must be renewed after uninstallation of the module if (!generate_module_cache()) { $backlog->failure(get_lang('Module cache update failed')); $success = false; } else { $backlog->success(get_lang('Module cache update succeeded')); } } return array($backlog, $success); }
*/ //$tlabelReq = 'CLUSR'; require '../inc/claro_init_global.inc.php'; //used libraries require_once get_path('incRepositorySys') . '/lib/admin.lib.inc.php'; require_once get_path('incRepositorySys') . '/lib/user.lib.php'; require_once get_path('incRepositorySys') . '/lib/class.lib.php'; require_once get_path('incRepositorySys') . '/lib/course_user.lib.php'; require_once get_path('incRepositorySys') . '/lib/group.lib.inc.php'; require_once get_path('incRepositorySys') . '/lib/password.lib.php'; require_once get_path('incRepositorySys') . '/lib/utils/validator.lib.php'; require_once get_path('incRepositorySys') . '/lib/utils/input.lib.php'; require_once get_path('incRepositorySys') . '/lib/thirdparty/parsecsv/parsecsv.lib.php'; require_once './csvimport.class.php'; include claro_get_conf_repository() . 'user_profile.conf.php'; load_module_config('CLUSR'); if (!$is_courseAllowed) { claro_disp_auth_form(true); } $is_courseManager = claro_is_course_manager(); $is_platformAdmin = claro_is_platform_admin(); $is_allowedToEnroll = $is_courseManager && get_conf('is_coursemanager_allowed_to_enroll_single_user') || $is_platformAdmin; $is_allowedToImport = $is_courseManager && get_conf('is_coursemanager_allowed_to_import_user_list') || $is_platformAdmin; $is_allowedToCreate = $is_courseManager && get_conf('is_coursemanager_allowed_to_register_single_user') || $is_platformAdmin; if (!$is_allowedToImport) { claro_die(get_lang('Not allowed')); } $courseId = claro_get_current_course_id(); $userInput = Claro_UserInput::getInstance(); $userInput->setValidator('cmd', new Claro_Validator_AllowedList(array('rqCSV', 'rqChangeFormat', 'exChangeFormat', 'rqLoadDefaultFormat', 'exLoadDefaultFormat'))); $userInput->setValidator('fieldSeparator', new Claro_Validator_allowedList(array(',', ';', ' ')));
public function render() { $claro_buffer = new ClaroBuffer(); $claro_buffer->append("\n" . '<!-- ' . $this->name . ' -->' . "\n"); foreach ($this->appletList as $applet) { set_current_module_label($applet['label']); pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug'); // install course applet if (claro_is_in_a_course()) { install_module_in_course($applet['label'], claro_get_current_course_id()); } if ($applet['activation'] == 'activated' && file_exists($applet['path'])) { load_module_config(); Language::load_module_translation(); if ($this->useList() && count($this->appletList) > 0) { $claro_buffer->append("<li\n id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\"><span>\n"); } else { $claro_buffer->append("<span\n id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\">\n"); } include_once $applet['path']; if ($this->useList() && count($this->appletList) > 0) { $claro_buffer->append("\n</span></li>\n"); } else { $claro_buffer->append("\n</span>\n"); } } else { Console::debug("Applet not found or not activated : " . $applet['label']); } clear_current_module_label(); pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug'); } $claro_buffer->append("\n" . '<!-- End of ' . $this->name . ' -->' . "\n"); return $claro_buffer->getContent(); }
/** * CLAROLINE * * @version 1.11 $Revision: 14314 $ * * @copyright (c) 2001-2012, Universite catholique de Louvain (UCL) * * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * * @package CLSTAT * * @author Claro Team <*****@*****.**> * */ require '../inc/claro_init_global.inc.php'; load_module_config('CLLNP'); require_once get_path('incRepositorySys') . '/lib/class.lib.php'; if (!claro_is_in_a_course() || !claro_is_course_allowed()) { claro_disp_auth_form(true); } if (!claro_is_course_manager()) { claro_die(get_lang('Not allowed')); } // path id can not be empty, return to the list of learning paths if (empty($_REQUEST['path_id'])) { claro_redirect("../learnPath/learningPathList.php"); exit; } $nameTools = get_lang('Learning paths tracking'); ClaroBreadCrumbs::getInstance()->setCurrent($nameTools, Url::Contextualize('learnPath_details.php?path_id=' . $_REQUEST['path_id'])); ClaroBreadCrumbs::getInstance()->prepend(get_lang('Learning path list'), Url::Contextualize(get_module_url('CLLNP') . '/learningPathList.php'));
/** * Helper to set current module label and load config and language files * @param string $moduleLabel */ function set_and_load_current_module($moduleLabel) { load_module_language($moduleLabel); load_module_config($moduleLabel); set_current_module_label($moduleLabel); }