Exemplo n.º 1
0
function _scorm_deleteitem($idscorm_package, $idscorm_organization, $erasetrackcontent = FALSE)
{
    /* remove items: based on organizations */
    //$rs = sql_query("SELECT idscorm_organization FROM ".$prefix."_scorm_organizations WHERE idscorm_package=".$idscorm_package);
    //while(list($idscorm_organization) = sql_fetch_row($rs)) {
    if ($erasetrackcontent) {
        // selected tracking remove
        $rsItems = sql_query("SELECT idscorm_item FROM " . $GLOBALS['prefix_lms'] . "_scorm_items WHERE idscorm_organization=" . $idscorm_organization);
        while (list($idscorm_item) = sql_fetch_row($rsItems)) {
            sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking WHERE idscorm_resource=" . $idscorm_item);
        }
    }
    sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_items WHERE idscorm_organization=" . $idscorm_organization);
    //}
    /* remove organizations */
    sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_organizations WHERE idscorm_organization=" . $idscorm_organization);
    // detect if there are other organization in package
    $rs = sql_query("SELECT idscorm_organization FROM " . $GLOBALS['prefix_lms'] . "_scorm_organizations WHERE idscorm_package=" . $idscorm_package);
    if (mysql_num_rows($rs) == 0) {
        $rs = sql_query("SELECT path FROM " . $GLOBALS['prefix_lms'] . "_scorm_package WHERE idscorm_package='" . (int) $idscorm_package . "'") or die(mysql_error());
        list($path) = sql_fetch_row($rs);
        $scopath = str_replace('\\', '/', $GLOBALS['where_files_relative'] . '/appLms/' . Get::sett('pathscorm'));
        /* remove all zip directory */
        if (file_exists($scopath . $path)) {
            /* if is the only occurrence of path in db delete files */
            $rs = sql_query("SELECT idscorm_package FROM " . $GLOBALS['prefix_lms'] . "_scorm_package" . " WHERE path = '" . $path . "'");
            if (mysql_num_rows($rs) == 1) {
                $size = Get::dir_size($scopath . $path);
                require_once dirname(__FILE__) . '/scorm_utils.php';
                // for del tree
                delDirTree($scopath . $path);
                if (isset($_SESSION['idCourse']) && defined("LMS")) {
                    $GLOBALS['course_descriptor']->subFileToUsedSpace(false, $size);
                }
            }
        }
        /* remove resources */
        sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_resources WHERE idscorm_package=" . $idscorm_package);
        /* remove packages */
        sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_package WHERE idscorm_package=" . $idscorm_package);
    }
}
Exemplo n.º 2
0
 public static function exceed_quota($file_path, $quota, $used, $manual_file_size = false)
 {
     if ($quota == 0) {
         return false;
     }
     $quota = $quota * 1024 * 1024;
     if ($manual_file_size === false) {
         $filesize = Get::dir_size($file_path);
     } else {
         $filesize = $manual_file_size;
     }
     return $used + $filesize > $quota;
 }