2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institution */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /***********************************************************************/
16 * the line below safe-guards this file from being accessed directly from
17 * a web browser. It will only execute if required from within an ATutor script,
18 * in our case the Module::install() method.
20 if (!defined('AT_INCLUDE_PATH')) { exit; }
23 * Note: the many options for these variables are used to decrease confusion.
24 * TRUE | FALSE | 1 will be the convention.
27 * specifies the type of instructor privilege this module uses.
28 * set to empty | FALSE | 0 to disable any privileges.
29 * set to 1 | AT_PRIV_ADMIN to use the instructor only privilege.
30 * set to TRUE | 'new' to create a privilege specifically for this module:
31 * will make this module available as a student privilege.
34 * specifies the type of ATutor administrator privilege this module uses.
35 * set to FALSE | AT_ADMIN_PRIV_ADMIN to use the super administrator only privilege.
36 * set to TRUE | 'new' to create a privilege specifically for this module:
37 * will make this module available as an administrator privilege.
41 * if non-zero specifies in minutes how often the module's cron job should be run.
42 * set to 0 or not set to disable.
44 $_course_privilege = TRUE; // possible values: FALSE | AT_PRIV_ADMIN | TRUE
48 * the following code is used for creating a module-specific directory.
49 * it generates appropriate error messages to aid in its creation.
51 $directory = AT_PA_CONTENT_DIR;
54 * check if GD is installed and is version 2 or higher
56 if (! extension_loaded('gd')) {
57 $msg->addError(array('MODULE_INSTALL', '<li>This module requires the GD Library. Please <a href="http://www.boutell.com/gd/" title="Link to GD web site">install it</a>.</li>'));
59 if (function_exists('gd_info')) {
60 // use gd_info if possible...
62 preg_match('/\d/', $gd_info['GD Version'], $match);
64 $msg->addError(array('MODULE_INSTALL', '<li>This module requires GD version 2 or higher. Please <a href="http://www.boutell.com/gd/" title="Link to GD web site">install it</a>.</li>'));
67 $supported_images = array();
68 if ($gd_info['GIF Create Support']) {
69 $supported_images[] = 'gif';
71 if ($gd_info['JPG Support']) {
72 $supported_images[] = 'jpg';
74 if ($gd_info['PNG Support']) {
75 $supported_images[] = 'png';
77 if (!$supported_images) {
78 $msg->addError(array('MODULE_INSTALL', '<li>This module must be able to support gif/jpg/png. Please recompile your GD library with those types supported.</li>'));
81 // ...otherwise use phpinfo().
84 $info = ob_get_contents();
86 $info = stristr($info, 'gd version');
87 preg_match('/\d/', $info, $match);
89 $msg->addError(array('MODULE_INSTALL', '<li>This module requires the GD Library version 2 or higher. Please <a href="http://www.boutell.com/gd/" title="Link to GD web site">install it</a>.</li>'));
94 // check if the directory is writeable
95 if (!is_dir($directory) && !@mkdir($directory)) {
96 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' does not exist. Please create it.</li>'));
97 } else if (!is_writable($directory) && @chmod($directory, 0666)) {
98 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' is not writeable. On Unix issue the command <kbd>chmod a+rw</kbd>.</li>'));
102 * the following code checks if there are any errors (generated previously)
103 * then uses the SqlUtility to run any database queries it needs, ie. to create
106 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
107 // deal with the SQL file:
108 require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
109 $sqlUtility =& new SqlUtility();
112 * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
113 * a convention we're using.
115 $sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);