Exemple #1
0
         }
     }
 }
 foreach ($preInstalledTools as $claroLabel) {
     $modulePath = get_module_path($claroLabel);
     if (file_exists($modulePath)) {
         $moduleId = register_module($modulePath);
         if (false !== activate_module($moduleId)) {
             trigger_error('module (id:' . $moduleId . ' ) not activated ', E_USER_WARNING);
         }
     } else {
         trigger_error('module path not found', E_USER_WARNING);
     }
 }
 // init default right profile
 init_default_right_profile();
 /***
  * Generate module conf from definition files.
  */
 $config_code_list = get_config_code_list('module');
 if (is_array($config_code_list)) {
     foreach ($config_code_list as $config_code) {
         // new config object
         $config = new Config($config_code);
         //generate conf
         list($message, $configToolError) = generate_conf($config, $form_value_list);
         if ($configToolError) {
             $configError = true;
             $messageConfigErrorList[] = $message;
         }
     }
/**
 * Upgrade right (from main database) to 1.8
 * @return step value, 0 if succeed
 */
function upgrade_main_database_right_to_18()
{
    include_once $GLOBALS['includePath'] . '/lib/right/right_profile.lib.php';
    include_once $GLOBALS['includePath'] . '/../install/init_profile_right.lib.php';
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tool = 'RIGHT_18';
    switch ($step = get_upgrade_status($tool)) {
        case 1:
            // add right tables
            $sqlForUpdate[] = " CREATE TABLE IF NOT EXISTS `" . $tbl_mdb_names['right_profile'] . "` (\n               `profile_id` int(11) NOT NULL auto_increment,\n               `type` enum('COURSE','PLATFORM') NOT NULL default 'COURSE',\n               `name` varchar(255) NOT NULL default '',\n               `label` varchar(50) NOT NULL default '',\n               `description` varchar(255) default '',\n               `courseManager` tinyint(4) default '0',\n               `mailingList` tinyint(4) default '0',\n               `userlistPublic` tinyint(4) default '0',\n               `groupTutor` tinyint(4) default '0',\n               `locked` tinyint(4) default '0',\n               `required` tinyint(4) default '0',\n               PRIMARY KEY  (`profile_id`),\n               KEY `type` (`type`)\n            )ENGINE=MyISAM ";
            $sqlForUpdate[] = "CREATE TABLE IF NOT EXISTS `" . $tbl_mdb_names['right_action'] . "` (\n               `id` int(11) NOT NULL auto_increment,\n               `name` varchar(255) NOT NULL default '',\n               `description` varchar(255) default '',\n               `tool_id` int(11) default NULL,\n               `rank` int(11) default '0',\n               `type` enum('COURSE','PLATFORM') NOT NULL default 'COURSE',\n               PRIMARY KEY  (`id`),\n               KEY `tool_id` (`tool_id`),\n               KEY `type` (`type`)\n             )ENGINE=MyISAM ";
            $sqlForUpdate[] = "CREATE TABLE IF NOT EXISTS `" . $tbl_mdb_names['right_rel_profile_action'] . "` (\n               `profile_id` int(11) NOT NULL,\n               `action_id` int(11) NOT NULL,\n               `courseId`  varchar(40) NOT NULL default '',\n               `value` tinyint(4) default '0',\n               PRIMARY KEY  (`profile_id`,`action_id`,`courseId`)\n             ) ENGINE=MyISAM ";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 2:
            create_required_profile();
            $step = set_upgrade_status($tool, $step + 1);
        case 3:
            // Init action/right
            $sql = " SELECT id\n                     FROM `" . $tbl_mdb_names['tool'] . "`";
            $result = claro_sql_query_fetch_all_cols($sql);
            $toolIdList = $result['id'];
            foreach ($toolIdList as $toolId) {
                // Manage right - Add read action
                $action = new RightToolAction();
                $action->setName('read');
                $action->setToolId($toolId);
                $action->save();
                // Manage right - Add edit action
                $action = new RightToolAction();
                $action->setName('edit');
                $action->setToolId($toolId);
                $action->save();
            }
            $step = set_upgrade_status($tool, $step + 1);
        case 4:
            init_default_right_profile();
            $step = set_upgrade_status($tool, $step + 1);
        case 5:
            // set profile_id in rel course_user
            $sqlForUpdate[] = "UPDATE `" . $tbl_mdb_names['rel_course_user'] . "` SET `profile_id` = " . claro_get_profile_id(USER_PROFILE) . "\n                               WHERE `isCourseManager` = 0";
            $sqlForUpdate[] = "UPDATE `" . $tbl_mdb_names['rel_course_user'] . "` SET `profile_id` = " . claro_get_profile_id(MANAGER_PROFILE) . "\n                               WHERE `isCourseManager` = 1";
            // set default profile_id in course
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        default:
            $step = set_upgrade_status($tool, 0);
            return $step;
    }
    return false;
}