forked from atutor/scorm_packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_uninstall.php
35 lines (29 loc) · 1.25 KB
/
module_uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/*******
* module_uninstall.php performs reversion of module_install.php
*/
/*******
* the line below safe-guards this file from being accessed directly from
* a web browser. It will only execute if required from within an ATutor script,
* in our case the Module::uninstall() method.
*/
if (!defined('AT_INCLUDE_PATH')) { exit; }
$directory = realpath(AT_INCLUDE_PATH . '../') . '/sco'; // a top level directory
// check if the directory exists
if (is_dir($directory)) {
require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!clr_dir($directory))
$msg->addError(array('MODULE_UNINSTALL', '<li>'.$directory.' can not be removed. Please manually remove it.</li>'));
}
/******
* the following code checks if there are any errors (generated previously)
* then uses the SqlUtility to run reverted database queries of module.sql,
* ie. "create table" statement in module.sql is run as drop according table.
*/
if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
// deal with the SQL file:
require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
$sqlUtility = new SqlUtility();
$sqlUtility->revertQueryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
}
?>