function upgrade_chat_to_19() { global $includePath; // activate new module to replace the old one $tool = 'CLCHAT_19'; switch ($step = get_upgrade_status($tool)) { case 1: // install new chat if (!file_exists($includePath . '/../../module/CLCHAT')) { log_message('New Chat module not found : keep the old one !'); $step = set_upgrade_status($tool, 0); return $step; } list($backLog, $moduleId) = install_module($includePath . '/../../module/CLCHAT', true); log_message($backLog->output()); if ($moduleId) { list($backLog, $success) = activate_module_in_platform($moduleId); log_message($backLog->output()); } else { return $step; } if ($success) { $step = set_upgrade_status($tool, $step + 1); } else { return $step; } case 2: // remove old chat $moduleId = get_module_data('CLCHT', 'id'); if ($moduleId) { list($backLog, $success) = uninstall_module($moduleId); log_message($backLog->output()); } else { $success = true; } if ($success) { $step = set_upgrade_status($tool, $step + 1); } else { return $step; } default: $step = set_upgrade_status($tool, 0); return $step; } return false; }
/** * Activate a module, its effect is * - to call the activation script of the module (if there is any) * - to modify the information in the main DB * @param integer $moduleId : ID of the module that must be activated * @return array( backlog, boolean ) * backlog object * boolean true if the activation process suceeded, false otherwise */ function activate_module($moduleId, $activateInAllCourses = false) { $success = true; $backlog1 = new Backlog(); // find module informations $tbl = claro_sql_get_main_tbl(); $moduleInfo = get_module_info($moduleId); list($backlog2, $success) = activate_module_in_platform($moduleId); if (!$success) { return array($backlog2, $success); } $backlog1->append($backlog2); if ($activateInAllCourses && $moduleInfo['type'] == 'tool') { // FIXME : ONLY WHEN INSTALLING A MODULE ! if (activate_module_in_all_courses($moduleInfo['label'])) { $success = true; $backlog1->success(get_lang('Module activation in courses succeeded')); } else { $success = false; $backlog1->failure(get_lang('Module activation in courses failed')); } } return array($backlog1, $success); }