// (special request can come from the tool id, or the tool label) if ($tidReq && $tidReq != $_SESSION['_tid'] || $tlabelReq && (!isset($_SESSION['_courseTool']['label']) || $tlabelReq != $_SESSION['_courseTool']['label'])) { $tidReset = true; } if ($tidReset || $cidReset) { if (($tidReq || $tlabelReq) && $_cid) { $tbl_mdb_names = claro_sql_get_main_tbl(); $tbl_tool = $tbl_mdb_names['tool']; $sql = " SELECT ctl.id AS id ,\n pct.id AS toolId ,\n pct.claro_label AS label ,\n ctl.script_name AS name ,\n ctl.visibility AS visibility ,\n pct.icon AS icon ,\n pct.access_manager AS access_manager,\n pct.script_url AS url\n\n FROM `" . $_course['dbNameGlu'] . "tool_list` ctl,\n `" . $tbl_tool . "` pct\n\n WHERE `ctl`.`tool_id` = `pct`.`id`\n AND (`ctl`.`id` = '" . (int) $tidReq . "'\n OR (" . (int) is_null($tidReq) . " AND pct.claro_label = '" . claro_sql_escape($tlabelReq) . "')\n )"; // Note : 'ctl' stands for 'course tool list' and 'pct' for 'platform course tool' $_courseTool = claro_sql_query_get_single_row($sql); if (is_array($_courseTool)) { $_tid = $_courseTool['id']; $_mainToolId = $_courseTool['toolId']; } else { $activatedModules = get_module_label_list(true); if (!in_array($tlabelReq, $activatedModules)) { exit('WARNING !! Undefined Tlabel or Tid: your script declare ' . 'be a tool wich is not registred at line ' . __LINE__ . '. ' . 'Please contact your platform administrator.'); } else { $_tid = null; $_mainToolId = null; $_courseTool = null; } } } else { // course $_tid = null; $_mainToolId = null; $_courseTool = null; } } else {
protected function mergeModuleUsers($uidToRemove, $uidToKeep) { $courseModuleList = get_module_label_list(); foreach ($courseModuleList as $courseModule) { $moduleMergeUserPath = get_module_path($courseModule['label']) . '/connector/mergeuser.cnr.php'; if (file_exists($moduleMergeUserPath)) { require_once $moduleMergeUserPath; $moduleMergeClass = $courseModule['label'] . '_MergeUser'; if (class_exists($moduleMergeClass)) { $moduleMerge = new $moduleMergeClass(); if (method_exists($moduleMerge, 'mergeUsers')) { try { if (!$moduleMerge->mergeUsers($uidToRemove, $uidToKeep)) { $this->hasError = true; } } catch (Exception $e) { Console::error($e->getMessage()); $this->hasError = true; } } } } } }
$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 !"); } } } else { continue; } } $moduleList = get_module_label_list(); if (is_array($moduleList)) { foreach ($moduleList as $moduleId => $moduleLabel) { $portletPath = get_module_path($moduleLabel) . '/connector/desktop.cnr.php'; if (file_exists($portletPath)) { 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 {
/** * Remove database for all modules in the given course * @param string courseId * @return array( * boolean success * Backlog log ) * @author Frederic Minne <*****@*****.**> */ function delete_all_modules_from_course($courseId) { $backlog = new Backlog(); $success = true; if (!($moduleLabelList = get_module_label_list(false))) { $success = false; $backlog->failure(claro_failure::get_last_failure()); } else { foreach ($moduleLabelList as $moduleLabel) { if (!delete_module_in_course($moduleLabel, $courseId)) { $backlog->failure(get_lang('delete failed for module %module', array('%module' => $moduleLabel))); $success = false; } else { $backlog->success(get_lang('delete succeeded for module %module', array('%module' => $moduleLabel))); } } } return array($success, $backlog); }