3 * the line below safe-guards this file from being accessed directly from
\r
4 * a web browser. It will only execute if required from within an ATutor script,
\r
5 * in our case the Module::install() method.
\r
7 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
8 require(AT_INCLUDE_PATH.'lib/constants.inc.php');
\r
10 $_course_privilege = TRUE; // possible values: FALSE | AT_PRIV_ADMIN | TRUE
\r
11 $_admin_privilege = TRUE; // possible values: FALSE | TRUE
\r
12 $_cron_interval = 0; // disable
\r
16 * the following code checks if there are any errors (generated previously)
\r
17 * then uses the SqlUtility to run any database queries it needs, ie. to create
\r
21 if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
\r
22 // deal with the SQL file:
\r
23 require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
\r
24 $sqlUtility =& new SqlUtility();
\r
27 * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
\r
28 * a convention we're using.
\r
30 $sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
\r
34 * The following core files are changed:
\r
36 * editor/add_news.php:
\r
41 * Open editor/add_news.php, check if changes need to be made, make them if neccessary
\r
45 $needle = "if (!\$msg->containsErrors() && (!isset(\$_POST['setvisual']) || isset(\$_POST['submit']))) {";
\r
46 $changes = "\n\t/*****
\r
47 \t* Added by announcement_subscription: Send mail to announcement subscribers
\r
49 \t \$subscriberMod =& \$moduleFactory->getModule('announcement_subscription');
\r
50 \t if (\$subscriberMod->isEnabled() && !\$subscriberMod->isMissing()) {
\r
51 \t\t include_once(AT_MODULE_PATH . 'announcement_subscription/sendmail.php');
\r
54 \t* End announcement_subscription
\r
58 $filename=('../../editor/add_news.php');
\r
59 if(!is_writable($filename)){
\r
60 $msg->addError('ANOUNCEMENTSUB_INSTALL_UNWRITE');
\r
62 $data = file($filename);
\r
63 foreach($data as $line){
\r
64 $newfile .= (strpos($line,$needle))? $line . "\n" . $changes . "\n": $line;
\r
65 if(strpos($line,'announcement_subscription/sendmail.php')){
\r
66 $msg->addInfo('ANNOUNCEMENTSUB_ALREADYINSTALLED_ADDNEWS');
\r
72 $file = fopen('$filename','w');
\r
73 if(fwrite($file,$newfile)){
\r
74 $msg->addFeedback('ANNOUNCEMENTSUB_INSTALL_ADDNEWS');
\r
76 $msg->addError('ANNOUNCEMENTSUB_INSTALL_ADDNEWS');
\r