Ejemplo n.º 1
0
/**
 * Move a module inside its dock (change its position in the display
 * @param integer $moduleId
 * @param string $dockName
 * @param string $direction 'up' or 'down'
 */
function move_module_in_dock($moduleId, $dockName, $direction)
{
    $tbl = claro_sql_get_main_tbl();
    switch ($direction) {
        case 'up':
            //1-find value of current module rank in the dock
            $sql = "SELECT `rank`\n                    FROM `" . $tbl['dock'] . "`\n                    WHERE `module_id`=" . (int) $moduleId . "\n                    AND `name`='" . claro_sql_escape($dockName) . "'";
            $result = claro_sql_query_get_single_value($sql);
            //2-move down above module
            $sql = "UPDATE `" . $tbl['dock'] . "`\n                    SET `rank` = `rank`+1\n                    WHERE `module_id` != " . (int) $moduleId . "\n                    AND `name`       = '" . claro_sql_escape($dockName) . "'\n                    AND `rank`       = " . (int) $result['rank'] . " -1 ";
            claro_sql_query($sql);
            //3-move up current module
            $sql = "UPDATE `" . $tbl['dock'] . "`\n                    SET `rank` = `rank`-1\n                    WHERE `module_id` = " . (int) $moduleId . "\n                    AND `name`      = '" . claro_sql_escape($dockName) . "'\n                    AND `rank` > 1";
            // this last condition is to avoid wrong update due to a page refreshment
            claro_sql_query($sql);
            break;
        case 'down':
            //1-find value of current module rank in the dock
            $sql = "SELECT `rank`\n                    FROM `" . $tbl['dock'] . "`\n                    WHERE `module_id`=" . (int) $moduleId . "\n                    AND `name`='" . claro_sql_escape($dockName) . "'";
            $result = claro_sql_query_get_single_value($sql);
            //this second query is to avoid a page refreshment wrong update
            $sqlmax = "SELECT MAX(`rank`) AS `max_rank`\n                      FROM `" . $tbl['dock'] . "`\n                      WHERE `name`='" . claro_sql_escape($dockName) . "'";
            $resultmax = claro_sql_query_get_single_value($sqlmax);
            if ($resultmax['max_rank'] == $result['rank']) {
                break;
            }
            //2-move up above module
            $sql = "UPDATE `" . $tbl['dock'] . "`\n                    SET `rank` = `rank` - 1\n                    WHERE `module_id` != " . $moduleId . "\n                    AND `name` = '" . claro_sql_escape($dockName) . "'\n                    AND `rank` = " . (int) $result['rank'] . " + 1\n                    AND `rank` > 1";
            claro_sql_query($sql);
            //3-move down current module
            $sql = "UPDATE `" . $tbl['dock'] . "`\n                    SET `rank` = `rank` + 1\n                    WHERE `module_id`=" . (int) $moduleId . "\n                    AND `name`='" . claro_sql_escape($dockName) . "'";
            claro_sql_query($sql);
            break;
    }
    // TODO FIXME handle failure
    generate_module_cache();
}
Ejemplo n.º 2
0
if (claro_is_in_a_course()) {
    // add other default course javascript here
    if (claro_is_in_a_group()) {
        // add other default group javascript here
    }
}
/*----------------------------------------------------------------------
  Find MODULES's includes to add and include them using a cache system
 ----------------------------------------------------------------------*/
// TODO : move module_cache to cache directory
// TODO : includePath is probably not needed
$module_cache_filename = get_conf('module_cache_filename', 'moduleCache.inc.php');
$cacheRepositorySys = get_path('rootSys') . get_conf('cacheRepository', 'tmp/cache/');
if (!file_exists($cacheRepositorySys . $module_cache_filename)) {
    require_once get_path('incRepositorySys') . '/lib/module/manage.lib.php';
    generate_module_cache();
}
require_once get_path('incRepositorySys') . '/lib/lock.lib.php';
if (file_exists($cacheRepositorySys . $module_cache_filename)) {
    include $cacheRepositorySys . $module_cache_filename;
} else {
    pushClaroMessage('module_cache not generated : check access right in ' . $cacheRepositorySys, 'warning');
}
// reset current module label after calling the cache
if (isset($tlabelReq) && get_current_module_label() != $tlabelReq) {
    // reset all previous occurence of module label in stack
    while (clear_current_module_label()) {
    }
    // set the current module label
    set_current_module_label($tlabelReq);
}