123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- function removescormDir($dir) {
- global $_course;
- if(!@$opendir = opendir($dir)) {
- return false;
- }
- while($readdir = readdir($opendir)) {
- if($readdir != '..' && $readdir != '.') {
- if(is_file($dir.'/'.$readdir)) {
- $pos = strpos('/'.$readdir, 'imsmanifest.xml');
- if ($pos) {
-
-
- $path = api_get_path(SYS_COURSE_PATH).$_course['official_code'].'/scorm';
- $pos = strpos($dir, $path);
- if ($pos == 0) {
- $scormdir = substr($dir, strlen($path), strlen($dir) - strlen($path));
- $courseid = $_course['official_code'];
- $sql = "SELECT * FROM ".Database::get_scorm_table(TABLE_SCORM_MAIN)." where (contentTitle='$scormdir' and dokeosCourse='$courseid')";
- $result = Database::query($sql);
- while ($row = Database::fetch_array($result)) {
- $c = $row['contentId'];
- $sql2 = "DELETE FROM ".Database::get_scorm_table(TABLE_SCORM_SCO_DATA)." where contentId=$c";
- $result2 = Database::query($sql2);
- }
- $sql = "DELETE FROM ".Database::get_scorm_table(TABLE_SCORM_MAIN)." where (contentTitle='$scormdir' and dokeosCourse='$courseid')";
- $result = Database::query($sql);
- }
- }
- if (!@unlink($dir.'/'.$readdir)) {
- return false;
- }
- } elseif (is_dir($dir.'/'.$readdir)) {
- if(!removescormDir($dir.'/'.$readdir)) {
- return false;
- }
- }
- }
- }
- closedir($opendir);
- if (!@rmdir($dir)) {
- return false;
- }
- return true;
- }
- function scorm_delete($file) {
- if (check_name_exist($file)) {
- if (is_dir($file)) {
- return removescormDir($file);
- }
- } else {
- return false;
- }
- }
- function get_scorm_paths_from_dir($basedir, $curdir, &$attribute){
- $scormcontent = false;
- $saved_dir = getcwd();
- $res = @chdir (realpath($basedir.$curdir));
- if ($res === false) { return(null); }
- $handle = opendir('.');
- define('A_DIRECTORY', 1);
- define('A_FILE', 2);
- $fileList = array();
-
- while ($file = readdir($handle)) {
- if ($file == '.' || $file == '..' || $file == '.htaccess') {
- continue;
- }
- $fileList['name'][] = $file;
-
- if(is_dir($file)) {
- $fileList['type'][] = A_DIRECTORY;
- $fileList['size'][] = false;
- $fileList['date'][] = false;
- } elseif (is_file($file)) {
- $fileList['type'][] = A_FILE;
- $fileList['size'][] = filesize($file);
- $fileList['date'][] = filectime($file);
- }
-
- if (is_array($attribute) && count($attribute['path']) > 0) {
- $keyAttribute = array_search($curdir.'/'.$file, $attribute['path']);
- }
- if ($keyAttribute !== false) {
- $fileList['comment' ][] = $attribute['comment' ][$keyAttribute];
- $fileList['visibility'][] = $attribute['visibility'][$keyAttribute];
- unset ($attribute['comment' ][$keyAttribute],
- $attribute['visibility'][$keyAttribute],
- $attribute['path' ][$keyAttribute]);
- } else {
- $fileList['comment' ][] = false;
- $fileList['visibility'][] = false;
- }
- }
- closedir($handle);
- chdir($saved_dir);
- return $fileList;
- }
- function get_scorm_version($path){
- return '1.2';
- }
|