d62b347ab79c9a321fc9091f7bef1dac4f722108
[atutor.git] / mods / photo_album / module_uninstall.php
1 <?php\r
2 /*==============================================================\r
3   Photo Album\r
4  ==============================================================\r
5   Copyright (c) 2006 by Dylan Cheon & Kelvin Wong\r
6   Institute for Assistive Technology / University of Victoria\r
7   http://www.canassist.ca/                                    \r
8                                                                \r
9   This program is free software. You can redistribute it and/or\r
10   modify it under the terms of the GNU General Public License  \r
11   as published by the Free Software Foundation.                \r
12  ==============================================================\r
13  */\r
14 // $Id:\r
15 \r
16 /**\r
17  * @desc        This file installs the photo album module\r
18  * @author      Dylan Cheon & Kelvin Wong\r
19  * @copyright   2006, Institute for Assistive Technology / University of Victoria \r
20  * @link        http://www.canassist.ca/                                    \r
21  * @license GNU\r
22  */\r
23  \r
24 /**\r
25  * @desc 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.\r
26  */\r
27 if (!defined('AT_INCLUDE_PATH')) { exit; }\r
28 if (!defined('AT_MODULE_PATH')) { exit; }\r
29 //define('AT_MODULE_PATH', realpath(AT_INCLUDE_PATH.'../mods') . DIRECTORY_SEPARATOR);\r
30 \r
31 /********\r
32  * the following code is used for removing a module-specific directory created in module_install.php.\r
33  * it generates appropriate error messages to aid in its creation.\r
34  */\r
35 $pa_array[0]=AT_CONTENT_DIR.'photo_album';\r
36 \r
37 // check if the directory exists\r
38 foreach ($pa_array as $directory){\r
39         if (is_dir($directory)) {\r
40                 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');\r
41         \r
42                 if (!clr_dir($directory))\r
43                         $msg->addError(array('MODULE_UNINSTALL', '<li>'.$directory.' can not be removed. Please manually remove it.</li>'));\r
44         }\r
45 }\r
46 \r
47 /******\r
48  * the following code checks if there are any errors (generated previously)\r
49  * then uses the SqlUtility to run reverted database queries of module.sql, \r
50  * ie. "create table" statement in module.sql is run as drop according table.\r
51  */\r
52 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {\r
53         // deal with the SQL file:\r
54         require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');\r
55         $sqlUtility =& new SqlUtility();\r
56 \r
57         /**\r
58          * the SQL file could be stored anywhere, and named anything, "module.sql" is simply\r
59          * a convention we're using.\r
60          */\r
61         $sqlUtility->revertQueryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);\r
62 }\r
63 \r
64 ?>\r