2 /*==============================================================
\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
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
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
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::install() method.
\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
32 * Note: the many options for these variables are used to decrease confusion.
\r
33 * TRUE | FALSE | 1 will be the convention.
\r
35 * $_course_privilege
\r
36 * specifies the type of instructor privilege this module uses.
\r
37 * set to empty | FALSE | 0 to disable any privileges.
\r
38 * set to 1 | AT_PRIV_ADMIN to use the instructor only privilege.
\r
39 * set to TRUE | 'new' to create a privilege specifically for this module:
\r
40 * will make this module available as a student privilege.
\r
43 * specifies the type of ATutor administrator privilege this module uses.
\r
44 * set to FALSE | AT_ADMIN_PRIV_ADMIN to use the super administrator only privilege.
\r
45 * set to TRUE | 'new' to create a privilege specifically for this module:
\r
46 * will make this module available as an administrator privilege.
\r
48 $_course_privilege = TRUE; // possible values: FALSE | AT_PRIV_ADMIN | TRUE
\r
49 $_admin_privilege = TRUE; // possible values: FALSE | TRUE
\r
53 * the following code is used for creating a module-specific directory.
\r
54 * it generates appropriate error messages to aid in its creation.
\r
56 $pa_array[0]=AT_CONTENT_DIR.'photo_album';
\r
58 // check if the directory is writeable
\r
59 foreach ($pa_array as $directory){
\r
60 if (!is_dir($directory) && !@mkdir($directory)) {
\r
61 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' does not exist. Please create it.</li>'));
\r
62 } else if (!is_writable($directory) && @chmod($directory, 0777)) {
\r
63 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' is not writeable. On Unix issue the command <kbd>chmod a+rw</kbd>.</li>'));
\r
68 * check if GD is installed and is version 2 or higher
\r
70 if (! extension_loaded('gd')) {
\r
71 $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>'));
\r
73 if (function_exists('gd_info')) {
\r
74 // use gd_info if possible...
\r
75 $gd_ver_info = gd_info();
\r
76 preg_match('/\d/', $gd_ver_info['GD Version'], $match);
\r
77 if ($match[0] < 2) {
\r
78 $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>'));
\r
81 // ...otherwise use phpinfo().
\r
84 $info = ob_get_contents();
\r
86 $info = stristr($info, 'gd version');
\r
87 preg_match('/\d/', $info, $match);
\r
88 if ($match[0] < 2) {
\r
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>'));
\r
95 * the following code checks if there are any errors (generated previously)
\r
96 * then uses the SqlUtility to run any database queries it needs, ie. to create
\r
99 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
\r
100 // deal with the SQL file:
\r
101 require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
\r
102 $sqlUtility =& new SqlUtility();
\r
105 * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
\r
106 * a convention we're using.
\r
108 $sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
\r