remove old readme
[atutor.git] / docs / mods / _standard / basiclti / module_uninstall.php
1 <?php
2 /*******
3  * module_uninstall.php performs reversion of module_install.php
4  */
5
6 /*******
7  * the line below safe-guards this file from being accessed directly from
8  * a web browser. It will only execute if required from within an ATutor script,
9  * in our case the Module::uninstall() method.
10  */
11 if (!defined('AT_INCLUDE_PATH')) { exit; }
12
13 /********
14  * the following code is used for removing a module-specific directory created in module_install.php.
15  * it generates appropriate error messages to aid in its creation.
16  */
17 $directory = AT_CONTENT_DIR .'basiclti';
18
19 // check if the directory exists
20 if (is_dir($directory)) {
21         require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
22
23         if (!clr_dir($directory))
24                 $msg->addError(array('MODULE_UNINSTALL', '<li>'.$directory.' can not be removed. Please manually remove it.</li>'));
25 }
26
27 /******
28  * the following code checks if there are any errors (generated previously)
29  * then uses the SqlUtility to run reverted database queries of module.sql, 
30  * ie. "create table" statement in module.sql is run as drop according table.
31  */
32 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
33         // deal with the SQL file:
34         require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
35         $sqlUtility = new SqlUtility();
36
37         /*
38          * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
39          * a convention we're using.
40          */
41         $sqlUtility->revertQueryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
42 }
43
44 ?>
45