2 /****************************************************************/
\r
4 /****************************************************************/
\r
5 /* Copyright (c) 2002-2009 */
\r
6 /* Adaptive Technology Resource Centre / University of Toronto */
\r
7 /* http://atutor.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
13 // $Id: module_install.php 8406 2009-04-01 20:38:44Z hwong $
\r
16 * the line below safe-guards this file from being accessed directly from
\r
17 * a web browser. It will only execute if required from within an ATutor script,
\r
18 * in our case the Module::install() method.
\r
20 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
23 * Note: the many options for these variables are used to decrease confusion.
\r
24 * TRUE | FALSE | 1 will be the convention.
\r
26 * $_course_privilege
\r
27 * specifies the type of instructor privilege this module uses.
\r
28 * set to empty | FALSE | 0 to disable any privileges.
\r
29 * set to 1 | AT_PRIV_ADMIN to use the instructor only privilege.
\r
30 * set to TRUE | 'new' to create a privilege specifically for this module:
\r
31 * will make this module available as a student privilege.
\r
34 * specifies the type of ATutor administrator privilege this module uses.
\r
35 * set to FALSE | AT_ADMIN_PRIV_ADMIN to use the super administrator only privilege.
\r
36 * set to TRUE | 'new' to create a privilege specifically for this module:
\r
37 * will make this module available as an administrator privilege.
\r
41 * if non-zero specifies in minutes how often the module's cron job should be run.
\r
42 * set to 0 or not set to disable.
\r
44 $_course_privilege = TRUE; // possible values: FALSE | AT_PRIV_ADMIN | TRUE
\r
45 $_admin_privilege = TRUE; // possible values: FALSE | TRUE
\r
46 $_cron_interval = 0;
\r
50 * the following code is used for creating a module-specific directory.
\r
51 * it generates appropriate error messages to aid in its creation.
\r
54 $directory = AT_CONTENT_DIR .'AtOpenCaps';
\r
55 // check if the directory is writeable
\r
56 if (!is_dir($directory) && !@mkdir($directory)) {
\r
57 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' does not exist. Please create it.</li>'));
\r
58 } else if (!is_writable($directory) && @chmod($directory, 0666)) {
\r
59 $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' is not writeable. On Unix issue the command <kbd>chmod a+rw</kbd>.</li>'));
\r
64 * the following code checks if there are any errors (generated previously)
\r
65 * then uses the SqlUtility to run any database queries it needs, ie. to create
\r
68 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
\r
69 // deal with the SQL file:
\r
70 require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
\r
71 $sqlUtility =& new SqlUtility();
\r
74 * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
\r
75 * a convention we're using.
\r
77 $sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
\r