public function unitExport(EfrontUnit $unit)
 {
     $currentLesson = $this->getCurrentLesson();
     $unitExportFolder = $this->moduleBaseDir . "assets/";
     try {
         $dir = new EfrontDirectory($unitExportFolder);
         $dir->delete();
     } catch (Exception $e) {
     }
     $htmlExportFolder = $unitExportFolder . 'html/';
     $filesExportFolder = $unitExportFolder . 'html/files/';
     is_dir($filesExportFolder) or mkdir($filesExportFolder, 0755, true);
     //is_dir($htmlExportFolder)  OR mkdir($htmlExportFolder, 0755, true);
     $filelist = array();
     $unitFiles = $unit->getFiles(true);
     $units[] = $unit;
     $data = $unit['data'];
     foreach ($unitFiles as $file) {
         $filePath = str_replace($currentLesson->getDirectory(), "/", EfrontFile::encode($file['path']));
         //Added this line in case of a space in path(urlencode makes it + and rawurlencode convers also slashes ) (#2143)
         $data = str_replace("content/lessons/" . ($currentLesson->lesson['share_folder'] ? $currentLesson->lesson['share_folder'] : $currentLesson->lesson['id']) . str_replace(' ', '%20', $filePath), "files" . str_replace(' ', '%20', $filePath), $data);
         $data = str_replace("content/lessons/" . ($currentLesson->lesson['share_folder'] ? $currentLesson->lesson['share_folder'] : $currentLesson->lesson['id']) . $filePath, "files" . $filePath, $data);
         $data = str_replace("view_file.php?file=" . $file['id'], "files" . $filePath, $data);
     }
     $unitContent = $data;
     $unitFilename = $htmlExportFolder . $unit['name'] . ".html";
     file_put_contents(EfrontFile::encode($unitFilename), $unitContent);
     $filelist = array_merge($filelist, $unitFiles);
     foreach ($filelist as $file) {
         $filePath = str_replace($currentLesson->getDirectory(), "", $file['path']);
         if (!is_dir($filesExportFolder . dirname($filePath))) {
             mkdir($filesExportFolder . dirname($filePath), 0755, true);
         }
         $file->copy($filesExportFolder . $filePath);
     }
     $unitDirectory = new EfrontDirectory($unitExportFolder);
     if (eF_checkParameter($unit['name'], 'file')) {
         $filename = $unit['name'] . '.zip';
     } else {
         $filename = 'unit.zip';
     }
     $compressedFile = $unitDirectory->compress($filename, false);
     //$unitDirectory -> delete();
     return $compressedFile;
 }
 /**
  * Delete user
  *
  * This function is used to delete a user from the system.
  * The user cannot be deleted if he is the last system administrator.
  * <br/>Example:
  * <code>
  * $user = EfrontUserFactory :: factory('jdoe');
  * $user -> delete();
  * </code>
  *
  * @return boolean True if the user was deleted successfully
  * @since 3.5.0
  * @access public
  */
 public function delete()
 {
     // Added by Masoud Sadjadi on July 6, 2014 to support vLab in eFront
     $vLab_username = $this->user['login'];
     $this->logout();
     ///MODULES2 - Module user delete events - Before anything else
     // Get all modules (NOT only the ones that have to do with the user type)
     $modules = eF_loadAllModules();
     // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen
     foreach ($modules as $module) {
         $module->onDeleteUser($this->user['login']);
     }
     try {
         $directory = new EfrontDirectory($this->user['directory']);
         $directory->delete();
     } catch (EfrontFileException $e) {
         $message = _USERDIRECTORYCOULDNOTBEDELETED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ')';
         //This does nothing at the moment
     }
     foreach ($this->aspects as $aspect) {
         $aspect->delete();
     }
     calendar::deleteUserCalendarEvents($this->user['login']);
     eF_updateTableData("f_forums", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_messages", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_topics", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_poll", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("news", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("files", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_folders", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_personal_messages", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("bookmarks", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("comments", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_users_to_polls", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("logs", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("rules", "users_LOGIN='******'login'] . "'");
     //eF_deleteTableData("users_online", "users_LOGIN='******'login']."'");
     eF_deleteTableData("user_times", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_surveys", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_done_surveys", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("survey_questions_done", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("lessons_timeline_topics_data", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("events", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("profile_comments", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_content", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_lessons", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_courses", "users_LOGIN='******'login'] . "'");
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         eF_deleteTableData("payments", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("facebook_connect", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("users_to_skillgap_tests", "users_LOGIN='******'login'] . "'");
     }
     #cpp#endif
     //This line was in EfrontProfessor and EfrontStudent without an obvious reason. Admins may also be members of groups
     eF_deleteTableData("users_to_groups", "users_LOGIN='******'login'] . "'");
     //Changing order of these lines because of #4318, where system removal notification was set (user triggering the event)
     eF_deleteTableData("notifications", "recipient='" . $this->user['login'] . "'");
     EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_REMOVAL, "users_LOGIN" => $this->user['login'], "users_name" => $this->user['name'], "users_surname" => $this->user['surname']));
     eF_deleteTableData("users", "login='******'login'] . "'");
     // Added by Masoud Sadjadi on July 6, 2014 to support vLab in eFront
     // Beging addition
     // $vLab_username 				= $this -> user['login'];
     $vLab_username_urlEncoded = rawurlencode($vLab_username);
     $vLab_courseid = 123;
     // Kaseya 7.0 Fundamentals Workshop
     $vLab_courseid_urlEncoded = rawurlencode($vLab_courseid);
     // $vLab_moodleURL = "http://localhost/moodle19";
     $vLab_moodleURL = "http://ita-portal.cis.fiu.edu";
     // auto delete
     $str = $vLab_moodleURL . "/mod/deva/embedded/auto-delete.php?username={$vLab_username_urlEncoded}&courseid={$vLab_courseid_urlEncoded}";
     // echo $str . '<br>';
     $payload = file_get_contents($str);
     // echo $payload;
     return true;
 }
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#delete()
  */
 public function delete()
 {
     if (!$this->remote) {
         $directory = new EfrontDirectory(G_THEMESPATH . $this->{$this->entity}['path']);
         $directory->delete();
     }
     eF_deleteTableData($this->entity, "id=" . $this->{$this->entity}['id']);
     $modules = eF_loadAllModules();
     foreach ($modules as $key => $module) {
         $module->onDeleteTheme($this->{$this->entity}['id']);
     }
     EfrontCache::getInstance()->deleteCache('themes');
 }
Example #4
0
$cacheId = null;
$message = $message_type = '';
$benchmark = new EfrontBenchmark($debug_TimeStart);
$benchmark->set('init');
//Set headers in order to eliminate browser cache (especially IE's)
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header("cache-control: no-transform");
//To prevent 3G carriers from compressing the site, which will break all grids
//Delete installation directory after install/upgrade
if (is_dir("install") && isset($_GET['delete_install'])) {
    try {
        $dir = new EfrontDirectory('install');
        $dir->delete();
    } catch (Exception $e) {
        echo "The installation directory could not be deleted. Please delete it manually or your system security is at risk.";
    }
}
if (G_VERSIONTYPE != 'community') {
    #cpp#ifndef COMMUNITY
    try {
        if (isset($_GET['logout']) && $GLOBALS['configuration']['facebook_api_key'] && $GLOBALS['configuration']['facebook_secret'] && EfrontFacebook::userConnected()) {
            //probably never goes here with new way
            $path = "../libraries/";
            //require_once $path . "external/facebook-platform/php/facebook.php";
            require_once $path . "external/facebook/facebook.php";
            $facebook = new Facebook(array('appId' => $GLOBALS['configuration']['facebook_api_key'], 'secret' => $GLOBALS['configuration']['facebook_secret'], 'cookie' => true));
            $smarty->assign("T_OPEN_FACEBOOK_SESSION", 1);
            $smarty->assign("T_FACEBOOK_API_KEY", $GLOBALS['configuration']['facebook_api_key']);
 private function createCourseTempDirectory()
 {
     $userTempDir = $this->createUserTempDirectory();
     $courseTempDir = $userTempDir['path'] . '/course_export_' . $this->course['id'];
     //The compressed file will be moved to the user's temp directory
     if (is_dir($courseTempDir)) {
         //If the user's temp directory does not exist, create it
         $foo = new EfrontDirectory($courseTempDir);
         $foo->delete();
     }
     $courseTempDir = EfrontDirectory::createDirectory($courseTempDir, false);
     return $courseTempDir;
 }
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#delete()
  */
 public function delete()
 {
     $folderMessages = eF_getTableData("f_personal_messages", "id", "f_folders_ID=" . $this->{$this->entity}['id']);
     foreach ($folderMessages as $message) {
         eF_PersonalMessage::eF_deletePersonalMessage($message['id']);
     }
     $folderDirectory = new EfrontDirectory(G_UPLOADPATH . $this->{$this->entity}['users_LOGIN'] . '/message_attachments/' . $this->{$this->entity}['name']);
     $folderDirectory->delete();
     parent::delete();
 }
Example #7
0
 /**
  * Restore system
  *
  * This function is used to restore a backup previously taken
  * <br/>Example:
  * <code>
  * </code>
  *
  * @param EfrontFile $restoreFile The file restore from
  * @param boolean $force Force restore even if versions are incompatible
  * @since 3.5.2
  * @access public
  */
 public static function restore($restoreFile, $force = false)
 {
     if (!$restoreFile instanceof EfrontFile) {
         $restoreFile = new EfrontFile($restoreFile);
     }
     $tempDir = G_BACKUPPATH . 'temp/';
     if (is_dir($tempDir)) {
         $dir = new EfrontDirectory($tempDir);
         $dir->delete();
     }
     mkdir($tempDir, 0755);
     $restoreFile = $restoreFile->copy($tempDir . '/');
     $restoreFile->uncompress(false);
     $filesystem = new FileSystemTree($tempDir);
     $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST));
     foreach ($iterator as $key => $value) {
         if (strpos($key, 'version.txt') !== false) {
             $backupVersion = file_get_contents($key);
         }
     }
     if (version_compare($backupVersion, G_VERSION_NUM) != 0 && !$force) {
         throw new Exception(_INCOMPATIBLEVERSIONS . '<br/> ' . _BACKUPVERSION . ':' . $backupVersion . ' / ' . _CURRENTVERSION . ': ' . G_VERSION_NUM, EfrontSystemException::INCOMPATIBLE_VERSIONS);
     }
     $sql = file_get_contents($tempDir . 'db_backup/sql.txt');
     $sql = explode(";\n", $sql);
     $node = $filesystem->seekNode($tempDir . 'db_backup');
     for ($i = 0; $i < sizeof($sql); $i += 2) {
         preg_match("/drop table (.+)/", $sql[$i], $matches);
         if ($matches[1]) {
             $temp[$matches[1]] = array($sql[$i], $sql[$i + 1]);
         }
     }
     $sql = $temp;
     //For each one of the tables that have backup data, recreate its table and import data
     $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($node), RecursiveIteratorIterator::SELF_FIRST));
     $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=0");
     foreach ($iterator as $file => $value) {
         $tableName = preg_replace("/\\.\\d+/", "", basename($file));
         if (isset($sql[$tableName])) {
             try {
                 eF_executeNew($sql[$tableName][0]);
             } catch (Exception $e) {
                 /*Don't halt for missing tables that can't be deleted*/
             }
             eF_executeNew($sql[$tableName][1]);
             unset($sql[$tableName]);
         }
         if (strpos($file, 'sql.txt') === false && strpos($file, 'version.txt') === false) {
             $data = unserialize(file_get_contents($file));
             $tableExists = false;
             try {
                 $tableExists = eF_describeTable($tableName);
             } catch (Exception $e) {
             }
             if ($tableExists !== false && !preg_match("/^\\w+_view\$/", $tableName)) {
                 eF_insertTableDataMultiple($tableName, $data);
             }
         }
     }
     $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=1");
     //Turn off foreign key checks in order to be able to run "drop table" queries
     eF_executeNew("SET FOREIGN_KEY_CHECKS = 0;");
     //For each one of the tables that don't have backup data, simply recreate
     foreach ($sql as $tableName => $query) {
         try {
             eF_executeNew($query[0]);
         } catch (Exception $e) {
             /*Don't halt for missing tables that can't be deleted*/
         }
         eF_executeNew($query[1]);
     }
     eF_executeNew("SET FOREIGN_KEY_CHECKS = 1;");
     if (is_dir(G_BACKUPPATH . 'temp/upload')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/upload');
         $dir->copy(G_ROOTPATH . 'upload', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/lessons')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/lessons');
         $dir->copy(G_CONTENTPATH . 'lessons', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/efront_root')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/efront_root');
         $dir->copy(G_ROOTPATH, true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/certificate_templates')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/certificate_templates');
         $dir->copy(G_ROOTPATH . 'www/certificate_templates', true);
     }
     if (is_dir(G_BACKUPPATH . 'temp/editor_templates')) {
         $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/editor_templates');
         $dir->copy(G_ROOTPATH . 'www/content/editor_templates', true);
     }
     $dir = new EfrontDirectory($tempDir);
     $dir->delete();
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache('user');
     }
     return true;
 }
 public function scormExport()
 {
     $scormExportFolder = G_SCORMPATH . $this->lesson['id'] . "/";
     try {
         $dir = new EfrontDirectory($scormExportFolder);
         $dir->delete();
     } catch (Exception $e) {
     }
     $htmlExportFolder = $scormExportFolder . 'html/';
     $filesExportFolder = $scormExportFolder . 'html/files/';
     is_dir($filesExportFolder) or mkdir($filesExportFolder, 0755, true);
     //is_dir($htmlExportFolder)  OR mkdir($htmlExportFolder, 0755, true);
     $filelist = array();
     $content = new EfrontContentTree($this, true);
     foreach (new EfrontContentFilterIterator(new EfrontNoSCORMFilterIterator(new EfrontVisitableAndEmptyFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($content->tree, RecursiveIteratorIterator::SELF_FIRST))))) as $key => $unit) {
         $unitFiles = $unit->getFiles(true);
         $units[] = $unit;
         $data = $unit['data'];
         foreach ($unitFiles as $file) {
             $filePath = str_replace($this->getDirectory(), "/", EfrontFile::encode($file['path']));
             //Added this line in case of a space in path(urlencode makes it + and rawurlencode convers also slashes ) (#2143)
             $data = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']) . str_replace(' ', '%20', $filePath), "files" . str_replace(' ', '%20', $filePath), $data);
             $data = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']) . $filePath, "files" . $filePath, $data);
             $data = str_replace("view_file.php?file=" . $file['id'], "files" . $filePath, $data);
         }
         $unitContent = $this->createSCORMHtmlFiles($data);
         $unitFilename = $htmlExportFolder . str_replace('?', ' ', $unit['name']) . ".html";
         file_put_contents(EfrontFile::encode($unitFilename), $unitContent);
         $metadata = $this->getSCORMAssetMetadata($unit);
         $metadataFilename = $htmlExportFolder . str_replace('?', ' ', $unit['name']) . ".xml";
         //file_put_contents($metadataFilename, $metadata);
         file_put_contents(EfrontFile::encode($metadataFilename), $metadata);
         $filelist = array_merge($filelist, $unitFiles);
     }
     foreach ($filelist as $file) {
         $filePath = str_replace($this->getDirectory(), "", $file['path']);
         if (!is_dir($filesExportFolder . dirname($filePath))) {
             mkdir($filesExportFolder . dirname($filePath), 0755, true);
         }
         $file->copy($filesExportFolder . $filePath, true, false);
         $metadata = $this->getSCORMAssetMetadata($file);
         $metadataFilename = EfrontFile::encode($filesExportFolder . $filePath . ".xml");
         file_put_contents($metadataFilename, $metadata);
     }
     /*Create manifest*/
     $prerequisites = $this->getSCORMPrerequisites();
     $organizations_str = $this->buildSCORMManifestOrganizations($prerequisites);
     $resources_str = $this->buildSCORMManifestResources($units);
     $metadata_str = $this->buildSCORMManifestMetadata(0);
     $manifest = $this->buildSCORMManifestMain($metadata_str . $organizations_str . $resources_str);
     file_put_contents($scormExportFolder . "imsmanifest.xml", $manifest);
     /*Create functions files*/
     list($func1, $func2) = $this->getAPIFunctions();
     file_put_contents($scormExportFolder . "APIWrapper.js", $func1);
     file_put_contents($scormExportFolder . "SCOFunctions.js", $func2);
     $scormDirectory = new EfrontDirectory($scormExportFolder);
     if (eF_checkParameter($this->lesson['name'], 'path')) {
         $filename = $this->lesson['name'] . '.zip';
     } else {
         $filename = 'SCO.zip';
     }
     $compressedFile = $scormDirectory->compress($filename, false);
     $scormDirectory->delete();
     return $compressedFile;
 }
Example #9
0
             mkdir($projectDir, 0755);
         }
         $projectDirectory = new EfrontDirectory($projectDir);
         foreach ($projectFiles as $title => $file) {
             try {
                 $projectFile = new EfrontFile($file['id']);
                 $newFileName = EfrontFile::encode($title . '_' . date("d.m.Y", $file['upload_timestamp']) . '_' . $projectFile['name']);
                 $projectFile->copy($projectDir . '/' . $newFileName);
             } catch (EfrontFileException $e) {
                 //Don't halt for a single file
                 $message .= $e->getMessage() . ' (' . $e->getCode() . ')';
             }
         }
         $zipFileName = $currentUser->user['directory'] . '/projects/' . EfrontFile::encode($_GET['compress_user']) . '.zip';
         $zipFile = $projectDirectory->compress($zipFileName, false, true);
         $projectDirectory->delete();
         eF_redirect("view_file.php?file=" . urlencode($zipFile['path']) . "&action=download");
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _FILESCOULDNOTBEDOWNLOADED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } else {
     if ((isset($_GET['add_project']) || isset($_GET['edit_project']) && in_array($_GET['edit_project'], array_keys($projects))) && $_professor_) {
         //ajax request for inserting file in editor
         //This page has a file manager, so bring it on with the correct options
         $basedir = $currentLesson->getDirectory();
         //Default options for the file manager
         if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') {
             $options = array('lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0);
         } else {
Example #10
0
            }
            $ims_filename = "ims_lesson" . $lessons_id . ".zip";
            if (is_file(IMS_FOLDER . "/" . $ims_filename)) {
                unlink(IMS_FOLDER . "/" . $ims_filename);
            }
            $lessons_id = $currentLesson->lesson['id'];
            try {
                $filesystem = new FileSystemTree($currentLesson->getDirectory());
                foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST)) as $key => $value) {
                    $value instanceof EfrontDirectory ? $filelist[] = preg_replace("#" . $currentLesson->getDirectory() . "#", "", $key) . '/' : ($filelist[] = preg_replace("#" . $currentLesson->getDirectory() . "#", "", $key));
                }
                $lesson_entries = eF_getTableData("content", "id,name,data", "lessons_ID=" . $lessons_id . " and ctg_type!='tests' and active=1");
                require_once "ims_tools.php";
                create_manifest($lessons_id, $lesson_entries, $filelist, IMS_FOLDER);
                $imsDirectory = new EfrontDirectory(IMS_FOLDER . "/lesson" . $lessons_id . "/");
                $compressedFile = $imsDirectory->compress(false, false, true);
                $imsDirectory->delete();
                $smarty->assign("T_IMS_EXPORT_FILE", $compressedFile);
                $smarty->assign("T_MESSAGE", _SUCCESSFULLYEXPORTEDIMSFILE);
                $smarty->assign("T_MESSAGE_TYPE", "success");
            } catch (Exception $e) {
                $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                $message = _SOMEPROBLEMEMERGED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                $message_type = "failure";
            }
        }
        $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
        $form->accept($renderer);
        $smarty->assign('T_EXPORT_IMS_FORM', $renderer->toArray());
    }
}
 /**
  * Delete user
  *
  * This function is used to delete a user from the system.
  * The user cannot be deleted if he is the last system administrator.
  * <br/>Example:
  * <code>
  * $user = EfrontUserFactory :: factory('jdoe');
  * $user -> delete();
  * </code>
  *
  * @return boolean True if the user was deleted successfully
  * @since 3.5.0
  * @access public
  */
 public function delete()
 {
     $this->logout();
     ///MODULES2 - Module user delete events - Before anything else
     // Get all modules (NOT only the ones that have to do with the user type)
     $modules = eF_loadAllModules();
     // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen
     foreach ($modules as $module) {
         $module->onDeleteUser($this->user['login']);
     }
     try {
         $directory = new EfrontDirectory($this->user['directory']);
         $directory->delete();
     } catch (EfrontFileException $e) {
         $message = _USERDIRECTORYCOULDNOTBEDELETED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ')';
         //This does nothing at the moment
     }
     foreach ($this->aspects as $aspect) {
         $aspect->delete();
     }
     calendar::deleteUserCalendarEvents($this->user['login']);
     eF_updateTableData("f_forums", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_messages", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_topics", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("f_poll", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("news", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_updateTableData("files", array("users_LOGIN" => ''), "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_folders", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_personal_messages", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("bookmarks", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("comments", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("f_users_to_polls", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("logs", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("rules", "users_LOGIN='******'login'] . "'");
     //eF_deleteTableData("users_online", "users_LOGIN='******'login']."'");
     eF_deleteTableData("user_times", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_surveys", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_done_surveys", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("survey_questions_done", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("lessons_timeline_topics_data", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("events", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("profile_comments", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_content", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_lessons", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("users_to_courses", "users_LOGIN='******'login'] . "'");
     eF_deleteTableData("scorm_data", "users_LOGIN='******'login'] . "'");
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         eF_deleteTableData("payments", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("facebook_connect", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("users_to_skillgap_tests", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_data_2004", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_activity_progress_information", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_activity_state_information", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_comments_from_learner", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_global_state_information", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_interactions", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_learner_preferences", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_maps_info", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_objective_progress_information", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_shared_data", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_shared_data_not_g", "users_LOGIN='******'login'] . "'");
         eF_deleteTableData("scorm_sequencing_objective_progress_information_all", "users_LOGIN='******'login'] . "'");
     }
     #cpp#endif
     //This line was in EfrontProfessor and EfrontStudent without an obvious reason. Admins may also be members of groups
     eF_deleteTableData("users_to_groups", "users_LOGIN='******'login'] . "'");
     //Changing order of these lines because of #4318, where system removal notification was set (user triggering the event)
     eF_deleteTableData("notifications", "recipient='" . $this->user['login'] . "'");
     EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_REMOVAL, "users_LOGIN" => $this->user['login'], "users_name" => $this->user['name'], "users_surname" => $this->user['surname']));
     eF_deleteTableData("users", "login='******'login'] . "'");
     return true;
 }
 /**
  * Handle AJAX actions
  *
  * This function is used to perform the necessary ajax actions,
  * that may be fired by the file manager
  * <br/>Example:
  * <code>
  * $basedir    = $currentLesson -> getDirectory();
  * $filesystem = new FileSystemTree($basedir);
  * $filesystem -> handleAjaxActions();
  * </code>
  *
  * @param EfrontUser $currentUser The current user
  * @since 3.5.0
  * @access public
  */
 public function handleAjaxActions($currentUser)
 {
     if (isset($_GET['delete_file']) && (eF_checkParameter($_GET['delete_file'], 'id') || strpos(urldecode($_GET['delete_file']), $this->dir['path']) !== false)) {
         try {
             $file = new EfrontFile(urldecode($_GET['delete_file']));
             if (strpos($file['path'], $this->dir['path']) === false) {
                 throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
             }
             $file->delete();
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     } else {
         if (isset($_GET['share']) && (eF_checkParameter($_GET['share'], 'id') || strpos(urldecode($_GET['share']), $this->dir['path']) !== false)) {
             try {
                 $file = new EfrontFile(urldecode($_GET['share']));
                 if (strpos($file['path'], $this->dir['path']) === false) {
                     throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                 }
                 $file->share();
             } catch (Exception $e) {
                 handleAjaxExceptions($e);
             }
             exit;
         } else {
             if (isset($_GET['unshare']) && (eF_checkParameter($_GET['unshare'], 'id') || strpos(urldecode($_GET['unshare']), $this->dir['path']) !== false)) {
                 try {
                     $file = new EfrontFile(urldecode($_GET['unshare']));
                     if (strpos($file['path'], $this->dir['path']) === false) {
                         throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                     }
                     $file->unshare();
                 } catch (Exception $e) {
                     handleAjaxExceptions($e);
                 }
                 exit;
             } else {
                 if (isset($_GET['uncompress']) && (eF_checkParameter($_GET['uncompress'], 'id') || strpos(urldecode($_GET['uncompress']), $this->dir['path']) !== false)) {
                     try {
                         $file = new EfrontFile(urldecode($_GET['uncompress']));
                         if (strpos($file['path'], $this->dir['path']) === false) {
                             throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                         }
                         $file->uncompress();
                     } catch (Exception $e) {
                         handleAjaxExceptions($e);
                     }
                     exit;
                 } elseif (isset($_GET['delete_folder']) && (eF_checkParameter($_GET['delete_folder'], 'id') || strpos(urldecode($_GET['delete_folder']), $this->dir['path']) !== false)) {
                     try {
                         $directory = new EfrontDirectory(urldecode($_GET['delete_folder']));
                         if (strpos($directory['path'], $this->dir['path']) === false) {
                             throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                         }
                         $directory->delete();
                     } catch (Exception $e) {
                         handleAjaxExceptions($e);
                     }
                     exit;
                 } elseif (isset($_GET['download']) && (eF_checkParameter($_GET['download'], 'id') || strpos(urldecode($_GET['download']), $this->dir['path']) !== false)) {
                     try {
                         $file = new EfrontFile(urldecode($_GET['download']));
                         if (strpos($file['path'], $this->dir['path']) === false) {
                             throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                         }
                         $file->sendFile(true);
                     } catch (Exception $e) {
                         handleAjaxExceptions($e);
                     }
                     exit;
                 } elseif (isset($_GET['view']) && (eF_checkParameter($_GET['view'], 'id') || strpos(urldecode($_GET['view']), $this->dir['path']) !== false)) {
                     try {
                         $file = new EfrontFile(urldecode($_GET['view']));
                         if (strpos($file['path'], $this->dir['path']) === false) {
                             throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                         }
                         $file->sendFile(false);
                     } catch (Exception $e) {
                         handleAjaxExceptions($e);
                     }
                     exit;
                 } elseif (isset($_GET['update']) && (eF_checkParameter($_GET['update'], 'id') || strpos(urldecode($_GET['update']), $this->dir['path']) !== false)) {
                     try {
                         $_GET['type'] == 'file' ? $file = new EfrontFile(urldecode($_GET['update'])) : ($file = new EfrontDirectory(urldecode($_GET['update'])));
                         if (strpos($file['path'], $this->dir['path']) === false) {
                             throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
                         }
                         $previousName = $file['name'];
                         if ($file['name'] != $_GET['name']) {
                             $file->rename(dirname($file['path']) . '/' . EfrontFile::encode(urldecode($_GET['name'])));
                         }
                         echo json_encode(array('previousName' => $previousName, 'name' => $file['name']));
                     } catch (Exception $e) {
                         handleAjaxExceptions($e);
                     }
                     exit;
                 }
             }
         }
     }
 }
Example #13
0
 /**
  * Delete done test information
  *
  * This function is used to delete the done information for the specified
  * user.
  * <br/>Example:
  * <code>
  * $test -> undo('jdoe');                           //Delete test information for user jdoe
  * $test -> undo('jdoe', 43);                       //Delete test information for user jdoe and completed test 43
  * </code>
  *
  * @param mixed $user The user to delete test for, either a user login or an EfrontUser instance
  * @param int $instance A specific completedTest instance to delete. If it's ommited, all completed tests from this user will be deleted
  * @since 3.5.2
  * @access public
  */
 public function undo($user, $instance = false)
 {
     if ($user instanceof EfrontUser) {
         $login = $user->user['login'];
     } elseif (eF_checkParameter($user, 'login')) {
         $login = $user;
     } else {
         throw new EfrontTestException(_INVALIDLOGIN . ': ' . $user, EfrontTestException::INVALID_LOGIN);
     }
     if (!$instance) {
         $result = eF_getTableData("completed_tests", "id", "users_LOGIN='******' and tests_ID=" . $this->test['id']);
         foreach ($result as $value) {
             if (is_dir(G_UPLOADPATH . $login . '/tests/' . $value['id'])) {
                 try {
                     $directory = new EfrontDirectory(G_UPLOADPATH . $login . '/tests/' . $value['id'] . '/');
                     $directory->delete();
                 } catch (EfrontFileException $e) {
                 }
             }
         }
         if ($this->test['content_ID']) {
             //Set the unit as "not seen"
             if (!$user instanceof EfrontUser) {
                 $user = EfrontUserFactory::factory($login, false, 'student');
             }
             $user->setSeenUnit($this->test['content_ID'], key($this->getLesson()), 0);
         } else {
             eF_updateTableData("users_to_skillgap_tests", array("solved" => 0), "tests_id = " . $this->test['id'] . " AND users_login = '******'");
         }
         eF_deleteTableData("completed_tests", "users_LOGIN='******' and tests_ID=" . $this->test['id']);
     } else {
         if (!eF_checkParameter($instance, 'id')) {
             throw new EfrontTestException(_INVALIDID . ': ' . $instance, EfrontTestException::INVALID_ID);
         }
         $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct", "ct.*", "users_LOGIN='******' and ct.id = " . $instance);
         if (sizeof($result) == 0) {
             throw new EfrontTestException(_USERHASNOTDONETEST . ': ' . $login, EfrontTestException::NOT_DONE_TEST);
         }
         if (is_dir(G_UPLOADPATH . $login . '/tests/' . $instance)) {
             try {
                 $directory = new EfrontDirectory(G_UPLOADPATH . $login . '/tests/' . $instance . '/');
                 $directory->delete();
             } catch (EfrontFileException $e) {
             }
         }
         //If the test is the last one (the 'active'), set it as not seen.
         //If it doesn't have a content id, it is a skill-gap test
         if ($result[0]['archive'] == 0 && $this->test['content_ID']) {
             if (!$user instanceof EfrontUser) {
                 $user = EfrontUserFactory::factory($login, false, 'student');
             }
             $user->setSeenUnit($this->test['content_ID'], key($this->getLesson()), 0);
         } else {
             if (!$this->test['content_ID']) {
                 eF_updateTableData("users_to_skillgap_tests", array("solved" => 0), "tests_id = " . $this->test['id'] . " AND users_login = '******'");
             }
         }
         eF_deleteTableData("completed_tests", "id=" . $instance);
     }
 }
Example #14
0
function clearBackupTempFolder()
{
    try {
        $directory = new EfrontDirectory(G_BACKUPPATH . 'temp/');
        $directory->delete();
    } catch (Exception $e) {
    }
}
Example #15
0
     if (is_dir($value)) {
         try {
             $directory = new EfrontDirectory($value);
             $directory->delete();
         } catch (EfrontFileException $e) {
         }
         //Don't stop on filesystem errors
     }
 }
 $fileSystemTree = new FileSystemTree(G_ROOTPATH . 'www/editor/tiny_mce/plugins', true);
 foreach (new EfrontDirectoryOnlyFilterIterator($fileSystemTree->tree) as $key => $value) {
     if (is_dir($key . '/jscripts')) {
         try {
             if ($value['name'] != 'preview' && $value['name'] != 'Jsvk') {
                 $directory = new EfrontDirectory($key . '/jscripts');
                 $directory->delete();
             }
         } catch (EfrontFileException $e) {
         }
         //Don't stop on filesystem errors
     }
 }
 try {
     $cacheTree = new FileSystemTree(G_THEMECACHE, true);
     foreach (new EfrontDirectoryOnlyFilterIterator($cacheTree->tree) as $value) {
         $value->delete();
     }
 } catch (Exception $e) {
 }
 EfrontConfiguration::setValue('database_version', G_VERSION_NUM);
 if (!defined("PREPROCESSED") && $GLOBALS['configuration']['version_type'] != G_VERSIONTYPE) {