Drift between CVS and git
- large deletions - lucene updates - error() => print_error() - NO_MOODLE_COOKIES define - various other things
@ -30,7 +30,7 @@ if (empty($CFG->auth)) {
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
error(get_string('pluginnotinstalled', 'auth', $auth), $url);
|
||||
print_error('pluginnotinstalled', 'auth', $url, $auth);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -67,7 +67,7 @@ switch ($action) {
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
print_error('pluginnotenabled', 'auth', $url, $auth);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
@ -82,7 +82,7 @@ switch ($action) {
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
error(get_string('pluginnotenabled', 'auth', $auth), $url);
|
||||
print_error('pluginnotenabled', 'auth', $url, $auth);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
|
||||
/// Do not set moodle cookie because we do not need it here, it is better to emulate session
|
||||
$nomoodlecookie = true;
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
/// directory of the script when run from the command line. The require_once()
|
||||
@ -66,7 +66,6 @@
|
||||
|
||||
|
||||
/// emulate normal session
|
||||
$SESSION = new object();
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
|
||||
/// ignore admins timezone, language and locale - use site deafult instead!
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
@ -103,4 +103,4 @@
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -48,7 +48,7 @@
|
||||
}
|
||||
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
||||
$MNET->get_private_key();
|
||||
$_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
|
||||
$SESSION->mnet_confirm_delete_key = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
|
||||
notice_yesno(get_string("deletekeycheck", "mnet"),
|
||||
"index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key),
|
||||
"index.php",
|
||||
@ -61,13 +61,13 @@
|
||||
// We're deleting
|
||||
|
||||
|
||||
if (!isset($_SESSION['mnet_confirm_delete_key'])) {
|
||||
if (!isset($SESSION->mnet_confirm_delete_key)) {
|
||||
// fail - you're being attacked?
|
||||
}
|
||||
|
||||
$key = '';
|
||||
$time = '';
|
||||
@list($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
|
||||
@list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
|
||||
$MNET->get_private_key();
|
||||
|
||||
if($time < time() - 60) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
|
@ -27,7 +27,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
|
@ -27,7 +27,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
|
@ -1764,7 +1764,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
*
|
||||
* NOTE that this code will execute under the OS user credentials,
|
||||
* so we MUST avoid dealing with files -- such as session files.
|
||||
* (The caller should set $nomoodlecookie before including config.php)
|
||||
* (The caller should define('NO_MOODLE_COOKIES', true) before including config.php)
|
||||
*
|
||||
*/
|
||||
function ntlmsso_magic($sesskey) {
|
||||
|
@ -26,7 +26,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$nomoodlecookie = true; // cookie not needed
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
// as we will be executing under the OS security
|
||||
// context of the user we are trying to login, rather than
|
||||
// of the webserver.
|
||||
$nomoodlecookie=true;
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__)))."/config.php");
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
update_user_login_times();
|
||||
|
||||
// Don't show username on login page
|
||||
set_moodle_cookie('nobody');
|
||||
$SESSION->set_moodle_cookie('nobody');
|
||||
|
||||
set_login_session_preferences();
|
||||
|
||||
|
@ -38,8 +38,8 @@ httpsrequired();
|
||||
$loginurl = (!empty($CFG->alternateloginurl)) ? $CFG->alternateloginurl : '';
|
||||
|
||||
|
||||
if (get_moodle_cookie() == '') {
|
||||
set_moodle_cookie('nobody'); // To help search for cookies
|
||||
if ($SESSION->get_moodle_cookie() == '') {
|
||||
$SESSION->set_moodle_cookie('nobody'); // To help search for cookies
|
||||
}
|
||||
|
||||
if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) {
|
||||
|
@ -1,163 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function backup_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2003050300 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
|
||||
`backup_code` INT(12) UNSIGNED NOT NULL,
|
||||
`table_name` VARCHAR(30) NOT NULL,
|
||||
`old_id` INT(10) UNSIGNED NOT NULL,
|
||||
`new_id` INT(10) UNSIGNED,
|
||||
PRIMARY KEY (`backup_code`, `table_name`, `old_id`)
|
||||
)
|
||||
COMMENT = 'To store and convert ids in backup/restore'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050301 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
ADD `info` VARCHAR(30)");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050400 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
MODIFY `info` VARCHAR(255)");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003050401 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
|
||||
`backup_code` INT( 10 ) UNSIGNED NOT NULL ,
|
||||
`file_type` VARCHAR( 10 ) NOT NULL ,
|
||||
`path` VARCHAR( 255 ) NOT NULL ,
|
||||
`old_id` INT( 10 ) UNSIGNED,
|
||||
`new_id` INT( 10 ) UNSIGNED,
|
||||
PRIMARY KEY ( `backup_code` , `file_type` , `path` )
|
||||
) COMMENT = 'To store and recode ids to user & course files.'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003052000 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
MODIFY `info` TEXT");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003061100 and $result) {
|
||||
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
|
||||
MODIFY `info` MEDIUMTEXT");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003082600 and $result) {
|
||||
print_simple_box("This is the first non-alpha release of the Backup/Restore module.<p>Thanks for upgrading!","center", "50%", '', "20", "noticebox");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003112700 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_config` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`value` varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) TYPE=MyISAM COMMENT='To store backup configuration variables'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003120800 and $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_courses` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`courseid` int(10) unsigned NOT NULL default '0',
|
||||
`laststarttime` int(10) unsigned NOT NULL default '0',
|
||||
`lastendtime` int(10) unsigned NOT NULL default '0',
|
||||
`laststatus` varchar(1) NOT NULL default '0',
|
||||
`nextstarttime` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `courseid` (`courseid`)
|
||||
) TYPE=MyISAM COMMENT='To store every course backup status'");
|
||||
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_log` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`courseid` int(10) unsigned NOT NULL default '0',
|
||||
`time` int(10) unsigned NOT NULL default '0',
|
||||
`laststarttime` int(10) unsigned NOT NULL default '0',
|
||||
`info` varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM COMMENT='To store every course backup log info'");
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011600 and $result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(10) unsigned NOT NULL default '0',
|
||||
`file_type` varchar(10) NOT NULL default '',
|
||||
`path` varchar(255) NOT NULL default '',
|
||||
`old_id` int(10) unsigned NOT NULL default '0',
|
||||
`new_id` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `{$CFG->prefix}backup_files_uk` (`backup_code`,`file_type`,`path`)
|
||||
) TYPE=MyISAM COMMENT='To store and recode ids to user and course files.'");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_ids` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`backup_code` int(12) unsigned NOT NULL default '0',
|
||||
`table_name` varchar(30) NOT NULL default '',
|
||||
`old_id` int(10) unsigned NOT NULL default '0',
|
||||
`new_id` int(10) unsigned NOT NULL default '0',
|
||||
`info` mediumtext,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `{$CFG->prefix}backup_ids_uk` (`backup_code` ,`table_name`,`old_id`)
|
||||
) TYPE=MyISAM COMMENT='To store and convert ids in backup/restore'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// code to drop the prefix in tables
|
||||
if ($oldversion < 2006042100) {
|
||||
// see bug 5205, silent drops, so should not panic anyone
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files DROP INDEX backup_files_uk", false);
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files DROP INDEX {$CFG->prefix}backup_files_uk", false);
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids DROP INDEX backup_ids_uk", false);
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids DROP INDEX {$CFG->prefix}backup_ids_uk", false);
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_files ADD UNIQUE INDEX backup_files_uk(backup_code,file_type(10),path(255))");
|
||||
$result = execute_sql("ALTER TABLE {$CFG->prefix}backup_ids ADD UNIQUE INDEX backup_ids_uk(backup_code,table_name(30),old_id)");
|
||||
}
|
||||
|
||||
// chaing default nulls to not null default 0
|
||||
|
||||
if ($oldversion < 2006042800) {
|
||||
|
||||
execute_sql("UPDATE {$CFG->prefix}backup_files SET old_id='0' WHERE old_id IS NULL");
|
||||
table_column('backup_files','old_id','old_id','int','10','unsigned','0','not null');
|
||||
|
||||
execute_sql("UPDATE {$CFG->prefix}backup_files SET new_id='0' WHERE new_id IS NULL");
|
||||
table_column('backup_files','new_id','new_id','int','10','unsigned','0','not null');
|
||||
|
||||
execute_sql("UPDATE {$CFG->prefix}backup_ids SET new_id='0' WHERE new_id IS NULL");
|
||||
table_column('backup_ids','new_id','new_id','int','10','unsigned','0','not null');
|
||||
|
||||
execute_sql("UPDATE {$CFG->prefix}backup_ids SET info='' WHERE info IS NULL");
|
||||
table_column('backup_ids','info','info','mediumtext','','','','not null');
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,59 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
function backup_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2006011600 and $result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}backup_files (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
file_type varchar(10) NOT NULL default '',
|
||||
path varchar(255) NOT NULL default '',
|
||||
old_id integer default NULL,
|
||||
new_id integer default NULL,
|
||||
CONSTRAINT {$CFG->prefix}backup_files_uk UNIQUE (backup_code, file_type, path))");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
|
||||
}
|
||||
if ($result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}backup_ids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
backup_code integer NOT NULL default '0',
|
||||
table_name varchar(30) NOT NULL default '',
|
||||
old_id integer NOT NULL default '0',
|
||||
new_id integer default NULL,
|
||||
info text,
|
||||
CONSTRAINT {$CFG->prefix}backup_ids_uk UNIQUE (backup_code, table_name, old_id))");
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006042801) {
|
||||
table_column('backup_log', 'time', 'time', 'integer', '', '', '0');
|
||||
table_column('backup_log', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
|
||||
table_column('backup_log', 'courseid', 'courseid', 'integer', '', '', '0');
|
||||
|
||||
table_column('backup_courses', 'lastendtime', 'lastendtime', 'integer', '', '', '0');
|
||||
table_column('backup_courses', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
|
||||
table_column('backup_courses', 'courseid', 'courseid', 'integer', '', '', '0');
|
||||
table_column('backup_courses', 'nextstarttime', 'nextstarttime', 'integer', '', '', '0');
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,23 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function activity_modules_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function activity_modules_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function admin_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function admin_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -12,7 +12,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
|
||||
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
|
||||
|
||||
if (in_array($section, $bookmarks)) {
|
||||
error(get_string('bookmarkalreadyexists','admin'));
|
||||
print_error('bookmarkalreadyexists','admin');
|
||||
die;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
|
||||
set_user_preference('admin_bookmarks', $bookmarks);
|
||||
|
||||
} else {
|
||||
error(get_string('invalidsection','admin'));
|
||||
print_error('invalidsection','admin');
|
||||
die;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
|
||||
}
|
||||
|
||||
} else {
|
||||
error(get_string('invalidsection','admin'));
|
||||
print_error('invalidsection','admin');
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
|
||||
$key = array_search($section, $bookmarks);
|
||||
|
||||
if ($key === false) {
|
||||
error(get_string('nonexistentbookmark','admin'));
|
||||
print_error('nonexistentbookmark','admin');
|
||||
die;
|
||||
}
|
||||
|
||||
@ -38,12 +38,12 @@ if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey(
|
||||
|
||||
}
|
||||
|
||||
error(get_string('nobookmarksforuser','admin'));
|
||||
print_error('nobookmarksforuser','admin');
|
||||
die;
|
||||
|
||||
} else {
|
||||
error(get_string('invalidsection', 'admin'));
|
||||
print_error('invalidsection', 'admin');
|
||||
die;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function calendar_month_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function calendar_month_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function calendar_upcoming_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function calendar_upcoming_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function course_list_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function course_list_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function course_summary_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function course_summary_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function blocks_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 && $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}blocks` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(40) NOT NULL default '',
|
||||
`version` int(10) NOT NULL default '0',
|
||||
`cron` int(10) unsigned NOT NULL default '0',
|
||||
`lastcron` int(10) unsigned NOT NULL default '0',
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004101900 && $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}block` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(40) NOT NULL default '',
|
||||
`version` int(10) NOT NULL default '0',
|
||||
`cron` int(10) unsigned NOT NULL default '0',
|
||||
`lastcron` int(10) unsigned NOT NULL default '0',
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
`multiple` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('blocks');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block, false);
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("DROP TABLE `{$CFG->prefix}blocks`");
|
||||
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}block_instance` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pageid` int(10) not null default '0',
|
||||
`pagetype` varchar(12) not null default '',
|
||||
`position` enum('l', 'r') not null default 'l',
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX pageid(`pageid`)
|
||||
)");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course', '','','', 'id, shortname, blockinfo');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@list($left, $right) = split(':', $thiscourse->blockinfo);
|
||||
if(!empty($left)) {
|
||||
$arr = explode(',', $left);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = PAGE_COURSE_VIEW;
|
||||
$instance->position = BLOCK_POS_LEFT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
$arr = explode(',', $right);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = PAGE_COURSE_VIEW;
|
||||
$instance->position = BLOCK_POS_RIGHT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}course` DROP COLUMN blockinfo");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004112900 && $result) {
|
||||
$result = $result && table_column('block_instance', 'pagetype', 'pagetype', 'varchar', '20', '');
|
||||
$result = $result && table_column('block_instance', 'position', 'position', 'varchar', '10', '');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004112900 && $result) {
|
||||
execute_sql('UPDATE '.$CFG->prefix.'block_instance SET pagetype = \''.PAGE_COURSE_VIEW.'\' WHERE pagetype = \'\'');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005043000 && $result) {
|
||||
$records = get_records('block');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
$block->visible = 0;
|
||||
update_record('block', $block);
|
||||
notify('The '.$block->name.' block has been disabled because it is not compatible with Moodle 1.5 and needs to be updated by a programmer.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005081600) {
|
||||
$result = $result && modify_database('',"CREATE TABLE `prefix_block_pinned` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pagetype` varchar(20) not null default '',
|
||||
`position` varchar(10) not null default '',
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
PRIMARY KEY(`id`)
|
||||
) TYPE=MyISAM;");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090200) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}block_instance ADD INDEX pagetype (pagetype);",false); // do it silently, in case it's already there from 1.5
|
||||
modify_database('','ALTER TABLE prefix_block_pinned ADD INDEX pagetype (pagetype);');
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
?>
|
@ -1,160 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function blocks_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = execute_sql("
|
||||
CREATE TABLE {$CFG->prefix}blocks
|
||||
(
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
name varchar(40) NOT NULL default '',
|
||||
version INT8 NOT NULL default '0',
|
||||
cron INT8 NOT NULL default '0',
|
||||
lastcron INT8 NOT NULL default '0',
|
||||
visible int NOT NULL default '1'
|
||||
)
|
||||
") ;
|
||||
|
||||
}
|
||||
|
||||
if ($oldversion < 2004101900 && $result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}block (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
name varchar(40) NOT NULL default '',
|
||||
version INT8 NOT NULL default '0',
|
||||
cron INT8 NOT NULL default '0',
|
||||
lastcron INT8 NOT NULL default '0',
|
||||
visible int NOT NULL default '1',
|
||||
multiple int NOT NULL default '0'
|
||||
)
|
||||
");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('blocks');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block, false);
|
||||
}
|
||||
execute_sql("SELECT setval('{$CFG->prefix}block_id_seq', (SELECT MAX(id) FROM {$CFG->prefix}block), true)");
|
||||
}
|
||||
|
||||
execute_sql("DROP TABLE {$CFG->prefix}blocks");
|
||||
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}block_instance (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 not null default '0',
|
||||
pageid INT8 not null default '0',
|
||||
pagetype varchar(12) not null default '',
|
||||
position char not null default 'l' check (position in ('l', 'r')) ,
|
||||
weight int not null default '0',
|
||||
visible int not null default '0',
|
||||
configdata text not null default ''
|
||||
)");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course', '','','', 'id, shortname, blockinfo');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@list($left, $right) = split(':', $thiscourse->blockinfo);
|
||||
if(!empty($left)) {
|
||||
$arr = explode(',', $left);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = PAGE_COURSE_VIEW;
|
||||
$instance->position = BLOCK_POS_LEFT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
$arr = explode(',', $right);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = PAGE_COURSE_VIEW;
|
||||
$instance->position = BLOCK_POS_RIGHT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN blockinfo");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004112900 && $result) {
|
||||
$result = $result && table_column('block_instance', 'pagetype', 'pagetype', 'varchar', '20', '');
|
||||
$result = $result && table_column('block_instance', 'position', 'position', 'varchar', '10', '');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005043000 && $result) {
|
||||
$records = get_records('block');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
$block->visible = 0;
|
||||
update_record('block', $block);
|
||||
notify('The '.$block->name.' block has been disabled because it is not compatible with Moodle 1.5 and needs to be updated by a programmer.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005022401 && $result) { // Mass cleanup of bad upgrade scripts
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pageid_idx ON {$CFG->prefix}block_instance (pageid)",false); // this one should be quiet...
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET DEFAULT \'\'');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER position SET DEFAULT \'\'');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET NOT NULL');
|
||||
modify_database('','ALTER TABLE prefix_block_instance ALTER position SET NOT NULL');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005081600) {
|
||||
modify_database('',"CREATE TABLE prefix_block_pinned (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 NOT NULL default 0,
|
||||
pagetype varchar(20) NOT NULL default '',
|
||||
position varchar(10) NOT NULL default '',
|
||||
weight INT NOT NULL default 0,
|
||||
visible INT NOT NULL default 0,
|
||||
configdata text NOT NULL default 0
|
||||
);");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090200) {
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pagetype_idx ON {$CFG->prefix}block_instance (pagetype);",false); // do it silently, in case it's already there from 1.5
|
||||
modify_database('','CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);');
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
?>
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function news_items_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function news_items_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function online_users_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function online_users_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function participants_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function participants_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function recent_activity_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function recent_activity_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
function rss_client_upgrade($oldversion) {
|
||||
/// This function does anything necessary to upgrade
|
||||
/// older versions to match current functionality
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2003111500) {
|
||||
# Do something ...
|
||||
}
|
||||
|
||||
if ($oldversion < 2005111400) {
|
||||
// title and description should be TEXT as we don't have control over their length.
|
||||
table_column('block_rss_client','title','title','text',10,'unsigned','');
|
||||
table_column('block_rss_client','description','description','text',10,'unsigned','');
|
||||
}
|
||||
|
||||
|
||||
if ($oldversion < 2006091100) {
|
||||
|
||||
// We need a new field to store whether an RSS feed is shared or private.
|
||||
table_column('block_rss_client', '', 'shared', 'integer');
|
||||
|
||||
// Admin feeds used to be displayed to everybody (shared feeds).
|
||||
$admins = get_admins();
|
||||
if (!empty($admins)) {
|
||||
$count = 0;
|
||||
foreach($admins as $admin) {
|
||||
if (!$count) {
|
||||
$adminsql = 'userid = '.$admin->id;
|
||||
} else {
|
||||
$adminsql .= ' OR userid = '.$admin->id;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
if ($rssfeeds = get_records_select('block_rss_client', $adminsql)) {
|
||||
foreach ($rssfeeds as $rssfeed) {
|
||||
if (!set_field('block_rss_client', 'shared', 1)) {
|
||||
notice('Could not set '.$rssfeed->title.' as a shared RSS feed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// see MDL-6707 for more info about problem that was here
|
||||
|
||||
if ($oldversion < 2006100101) {
|
||||
|
||||
// Upgrade block to use the Roles System.
|
||||
$block = get_record('block', 'name', 'rss_client');
|
||||
|
||||
if ($blockinstances = get_records('block_instance', 'blockid', $block->id)) {
|
||||
|
||||
if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
|
||||
notice('Default student role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
|
||||
notice('Default teacher role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
|
||||
notice('Default student role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
|
||||
foreach ($blockinstances as $bi) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $bi->id);
|
||||
|
||||
if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) {
|
||||
|
||||
// Only the admin was allowed to manage the RSS feed block
|
||||
// on the site home page.
|
||||
|
||||
// Since this is already the default behavior set in
|
||||
// blocks/rss_client/db/access.php, we don't need to
|
||||
// specifically assign the capabilities here.
|
||||
|
||||
} else {
|
||||
|
||||
// Who can add shared feeds? This was defined in lib/rsslib.php
|
||||
// for config var block_rss_client_submitters.
|
||||
switch ($CFG->block_rss_client_submitters) {
|
||||
|
||||
case 0:
|
||||
// SUBMITTERS_ALL_ACCOUNT_HOLDERS
|
||||
|
||||
foreach ($adminroles as $adminrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $studentrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// SUBMITTERS_ADMIN_ONLY
|
||||
|
||||
// Since this is already the default behavior set in
|
||||
// blocks/rss_client/db/access.php, we don't need to
|
||||
// specifically assign the capabilities here.
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// SUBMITTERS_ADMIN_AND_TEACHER
|
||||
|
||||
foreach ($adminroles as $adminrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_PREVENT, $studentrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
|
||||
} // End switch.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
@ -1,145 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
function rss_client_upgrade($oldversion) {
|
||||
/// This function does anything necessary to upgrade
|
||||
/// older versions to match current functionality
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2005111400) {
|
||||
// title and description should be TEXT as we don't have control over their length.
|
||||
table_column('block_rss_client','title','title','text');
|
||||
table_column('block_rss_client','description','description','text');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090201) {
|
||||
modify_database('', 'ALTER TABLE prefix_block_rss_client
|
||||
ALTER COLUMN title SET DEFAULT \'\',
|
||||
ALTER COLUMN description SET DEFAULT \'\'');
|
||||
}
|
||||
|
||||
|
||||
if ($oldversion < 2006091100) {
|
||||
|
||||
// We need a new field to store whether an RSS feed is shared or private.
|
||||
table_column('block_rss_client', '', 'shared', 'integer');
|
||||
|
||||
// Admin feeds used to be displayed to everybody (shared feeds).
|
||||
$admins = get_admins();
|
||||
if (!empty($admins)) {
|
||||
$count = 0;
|
||||
foreach($admins as $admin) {
|
||||
if (!$count) {
|
||||
$adminsql = 'userid = '.$admin->id;
|
||||
} else {
|
||||
$adminsql .= ' OR userid = '.$admin->id;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
if ($rssfeeds = get_records_select('block_rss_client', $adminsql)) {
|
||||
foreach ($rssfeeds as $rssfeed) {
|
||||
if (!set_field('block_rss_client', 'shared', 1)) {
|
||||
notice('Could not set '.$rssfeed->title.' as a shared RSS feed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// see MDL-6707 for more info about problem that was here
|
||||
|
||||
if ($oldversion < 2006100101) {
|
||||
|
||||
// Upgrade block to use the Roles System.
|
||||
$block = get_record('block', 'name', 'rss_client');
|
||||
|
||||
if ($blockinstances = get_records('block_instance', 'blockid', $block->id)) {
|
||||
|
||||
if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
|
||||
notice('Default student role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
|
||||
notice('Default teacher role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
|
||||
notice('Default student role was not found. Roles and permissions '.
|
||||
'for all your Remote RSS Feed blocks will have to be '.
|
||||
'manually set after this upgrade.');
|
||||
}
|
||||
|
||||
foreach ($blockinstances as $bi) {
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $bi->id);
|
||||
|
||||
if ($bi->pagetype == 'course-view' && $bi->pageid == SITEID) {
|
||||
|
||||
// Only the admin was allowed to manage the RSS feed block
|
||||
// on the site home page.
|
||||
|
||||
// Since this is already the default behavior set in
|
||||
// blocks/rss_client/db/access.php, we don't need to
|
||||
// specifically assign the capabilities here.
|
||||
|
||||
} else {
|
||||
|
||||
// Who can add shared feeds? This was defined in lib/rsslib.php
|
||||
// for config var block_rss_client_submitters.
|
||||
switch ($CFG->block_rss_client_submitters) {
|
||||
|
||||
case 0:
|
||||
// SUBMITTERS_ALL_ACCOUNT_HOLDERS
|
||||
|
||||
foreach ($adminroles as $adminrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $studentrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// SUBMITTERS_ADMIN_ONLY
|
||||
|
||||
// Since this is already the default behavior set in
|
||||
// blocks/rss_client/db/access.php, we don't need to
|
||||
// specifically assign the capabilities here.
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// SUBMITTERS_ADMIN_AND_TEACHER
|
||||
|
||||
foreach ($adminroles as $adminrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $adminrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('block/rss_client:createsharedfeeds', CAP_PREVENT, $studentrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
|
||||
} // End switch.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
@ -81,4 +81,4 @@
|
||||
|
||||
} //block_search
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -12,8 +12,8 @@
|
||||
<FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="standard" SEQUENCE="false" ENUM="false" PREVIOUS="doctype" NEXT="title"/>
|
||||
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
|
||||
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
|
||||
<FIELD NAME="docdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
|
||||
<FIELD NAME="updated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
|
||||
<FIELD NAME="docdate" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
|
||||
<FIELD NAME="updated" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
|
||||
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
|
||||
</FIELDS>
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function search_forums_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function search_forums_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function section_links_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004050500 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function section_links_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004050500 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to MySQL
|
||||
|
||||
function social_activities_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
//
|
||||
// This file is tailored to PostgreSQL
|
||||
|
||||
function social_activities_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
$result = true; //Nothing to do
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is required if the course format is to support AJAX.
|
||||
*/
|
||||
|
||||
|
||||
$CFG->ajaxcapable = true;
|
||||
$CFG->ajaxtestedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111);
|
||||
|
||||
?>
|
@ -1,301 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Display the whole course as "topics" made of of modules
|
||||
// Included from "view.php"
|
||||
/**
|
||||
* Evaluation topics format for course display - NO layout tables, for accessibility, etc.
|
||||
*
|
||||
* A duplicate course format to enable the Moodle development team to evaluate
|
||||
* CSS for the multi-column layout in place of layout tables.
|
||||
* Less risk for the Moodle 1.6 beta release.
|
||||
* 1. Straight copy of topics/format.php
|
||||
* 2. Replace <table> and <td> with DIVs; inline styles.
|
||||
* 3. Reorder columns so that in linear view content is first then blocks;
|
||||
* styles to maintain original graphical (side by side) view.
|
||||
*
|
||||
* Target: 3-column graphical view using relative widths for pixel screen sizes
|
||||
* 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
|
||||
*
|
||||
* http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
|
||||
* http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, and others.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package
|
||||
*/
|
||||
//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formattopicscss']
|
||||
|
||||
require_once($CFG->libdir.'/ajax/ajaxlib.php');
|
||||
|
||||
if (!empty($THEME->customcorners)) {
|
||||
require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
|
||||
}
|
||||
|
||||
$topic = optional_param('topic', -1, PARAM_INT);
|
||||
|
||||
if ($topic != -1) {
|
||||
$displaysection = course_set_display($course->id, $topic);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) {
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
|
||||
$course->marker = $marker;
|
||||
if (! set_field("course", "marker", $marker, "id", $course->id)) {
|
||||
error("Could not mark that topic for this course");
|
||||
}
|
||||
}
|
||||
|
||||
$streditsummary = get_string('editsummary');
|
||||
$stradd = get_string('add');
|
||||
$stractivities = get_string('activities');
|
||||
$strshowalltopics = get_string('showalltopics');
|
||||
$strtopic = get_string('topic');
|
||||
$strgroups = get_string('groups');
|
||||
$strgroupmy = get_string('groupmy');
|
||||
$editing = $PAGE->user_is_editing();
|
||||
|
||||
if ($editing) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strtopichide = get_string('topichide', '', $strstudents);
|
||||
$strtopicshow = get_string('topicshow', '', $strstudents);
|
||||
$strmarkthistopic = get_string('markthistopic');
|
||||
$strmarkedthistopic = get_string('markedthistopic');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
}
|
||||
|
||||
/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
|
||||
Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)
|
||||
*/
|
||||
?>
|
||||
|
||||
<!--[if IE]>
|
||||
<style type="text/css">
|
||||
.topicscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
|
||||
</style>
|
||||
<![endif]-->
|
||||
<?php
|
||||
/// Layout the whole page as three big columns (was, id="layout-table")
|
||||
echo '<div class="topicscss-format">';
|
||||
|
||||
/// The left column ...
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<div id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// The right column, BEFORE the middle-column.
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<div id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// Start main column
|
||||
echo '<div id="middle-column">';
|
||||
|
||||
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
||||
|
||||
echo skip_main_destination();
|
||||
|
||||
print_heading_block(get_string('topicoutline'), 'outline');
|
||||
|
||||
// Note, an ordered list would confuse - "1" could be the clipboard or summary.
|
||||
echo "<ul class='topicscss'>\n";
|
||||
|
||||
/// If currently moving a file then show the current clipboard
|
||||
if (ismoving($course->id)) {
|
||||
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
|
||||
$strcancel= get_string('cancel');
|
||||
echo '<li class="clipboard">';
|
||||
echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
/// Print Section 0 with general activities
|
||||
|
||||
$section = 0;
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
||||
|
||||
// Note, no need for a 'left side' cell or DIV.
|
||||
// Note, 'right side' is BEFORE content.
|
||||
echo '<li id="section-0" class="section main" >';
|
||||
echo '<div class="left side"> </div>';
|
||||
echo '<div class="right side" > </div>';
|
||||
echo '<div class="content">';
|
||||
echo '<div class="summary">';
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo '<a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
' class="icon edit" alt="'.$streditsummary.'" /></a>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
|
||||
/// Now all the normal modules by topic
|
||||
/// Everything below uses "section" terminology - each "section" is a topic.
|
||||
|
||||
$timenow = time();
|
||||
$section = 1;
|
||||
$sectionmenu = array();
|
||||
|
||||
while ($section <= $course->numsections) {
|
||||
|
||||
if (!empty($sections[$section])) {
|
||||
$thissection = $sections[$section];
|
||||
|
||||
} else {
|
||||
unset($thissection);
|
||||
$thissection->course = $course->id; // Create a new section structure
|
||||
$thissection->section = $section;
|
||||
$thissection->summary = '';
|
||||
$thissection->visible = 1;
|
||||
if (!$thissection->id = insert_record('course_sections', $thissection)) {
|
||||
notify('Error inserting new topic!');
|
||||
}
|
||||
}
|
||||
|
||||
$showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
|
||||
|
||||
if (!empty($displaysection) and $displaysection != $section) { // Check this topic is visible
|
||||
if ($showsection) {
|
||||
$strsummary = strip_tags(format_string($thissection->summary,true));
|
||||
if (strlen($strsummary) < 57) {
|
||||
$strsummary = ' - '.$strsummary;
|
||||
} else {
|
||||
$strsummary = ' - '.substr($strsummary, 0, 60).'...';
|
||||
}
|
||||
$sectionmenu['topic='.$section] = s($section.$strsummary);
|
||||
}
|
||||
$section++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($showsection) {
|
||||
|
||||
$currenttopic = ($course->marker == $section);
|
||||
|
||||
$currenttext = '';
|
||||
if (!$thissection->visible) {
|
||||
$sectionstyle = ' hidden';
|
||||
} else if ($currenttopic) {
|
||||
$sectionstyle = ' current';
|
||||
$currenttext = get_accesshide(get_string('currenttopic','access'));
|
||||
} else {
|
||||
$sectionstyle = '';
|
||||
}
|
||||
|
||||
echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side"> </div>';
|
||||
|
||||
echo '<div class="left side">'.$currenttext.$section.'</div>';
|
||||
// Note, 'right side' is BEFORE content.
|
||||
echo '<div class="right side">';
|
||||
|
||||
if ($displaysection == $section) { // Show the zoom boxes
|
||||
echo '<a href="view.php?id='.$course->id.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/all.gif" class="icon" alt="'.$strshowalltopics.'" /></a><br />';
|
||||
} else {
|
||||
$strshowonlytopic = get_string("showonlytopic", "", $section);
|
||||
echo '<a href="view.php?id='.$course->id.'&topic='.$section.'" title="'.$strshowonlytopic.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/one.gif" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
|
||||
if ($course->marker == $section) { // Show the "light globe" on/off
|
||||
echo '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$CFG->pixpath.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$CFG->pixpath.'/i/marker.gif" alt="'.$strmarkthistopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="content">';
|
||||
if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
|
||||
echo get_string('notavailable').'</div>';
|
||||
} else {
|
||||
echo '<div class="summary">';
|
||||
$summaryformatoptions->noclean = true;
|
||||
if ($thissection->summary) {
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
} else {
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
$section++;
|
||||
}
|
||||
echo "</ul>\n";
|
||||
|
||||
if (!empty($sectionmenu)) {
|
||||
echo '<div align="center" class="jumpmenu">';
|
||||
echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&', $sectionmenu,
|
||||
'sectionmenu', '', get_string('jumpto'), '', '', true);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
?>
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is required if the course format is to support AJAX.
|
||||
*/
|
||||
|
||||
|
||||
$CFG->ajaxcapable = true;
|
||||
$CFG->ajaxtestedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111);
|
||||
|
||||
?>
|
@ -1,276 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Display the whole course as "weeks" made of of modules
|
||||
// Included from "view.php"
|
||||
/**
|
||||
* Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
|
||||
*
|
||||
* A duplicate course format to enable the Moodle development team to evaluate
|
||||
* CSS for the multi-column layout in place of layout tables.
|
||||
* Less risk for the Moodle 1.6 beta release.
|
||||
* 1. Straight copy of weeks/format.php
|
||||
* 2. Replace <table> and <td> with DIVs; inline styles.
|
||||
* 3. Reorder columns so that in linear view content is first then blocks;
|
||||
* styles to maintain original graphical (side by side) view.
|
||||
*
|
||||
* Target: 3-column graphical view using relative widths for pixel screen sizes
|
||||
* 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
|
||||
*
|
||||
* http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
|
||||
* http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, and others.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package
|
||||
*/
|
||||
//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
|
||||
|
||||
$week = optional_param('week', -1, PARAM_INT);
|
||||
|
||||
if ($week != -1) {
|
||||
$displaysection = course_set_display($course->id, $week);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) {
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
$streditsummary = get_string('editsummary');
|
||||
$stradd = get_string('add');
|
||||
$stractivities = get_string('activities');
|
||||
$strshowallweeks = get_string('showallweeks');
|
||||
$strweek = get_string('week');
|
||||
$strgroups = get_string('groups');
|
||||
$strgroupmy = get_string('groupmy');
|
||||
$editing = $PAGE->user_is_editing();
|
||||
|
||||
if ($editing) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strweekhide = get_string('weekhide', '', $strstudents);
|
||||
$strweekshow = get_string('weekshow', '', $strstudents);
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
/* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
|
||||
Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)
|
||||
*/
|
||||
?>
|
||||
|
||||
<!--[if IE]>
|
||||
<style type="text/css">
|
||||
.weekscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
|
||||
</style>
|
||||
<![endif]-->
|
||||
<?php
|
||||
/// Layout the whole page as three big columns (was, id="layout-table")
|
||||
echo '<div class="weekscss-format">';
|
||||
|
||||
/// The left column ...
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<div id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// The right column, BEFORE the middle-column.
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<div id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// Start main column
|
||||
echo '<div id="middle-column">'. skip_main_destination();
|
||||
|
||||
print_heading_block(get_string('weeklyoutline'), 'outline');
|
||||
|
||||
// Note, an ordered list would confuse - "1" could be the clipboard or summary.
|
||||
echo "<ul class='weekscss'>\n";
|
||||
|
||||
/// If currently moving a file then show the current clipboard
|
||||
if (ismoving($course->id)) {
|
||||
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
|
||||
$strcancel= get_string('cancel');
|
||||
echo '<li class="clipboard">';
|
||||
echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
/// Print Section 0 with general activities
|
||||
|
||||
$section = 0;
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
||||
|
||||
// Note, no need for a 'left side' cell or DIV.
|
||||
// Note, 'right side' is BEFORE content.
|
||||
echo '<li id="section-0" class="section main" >';
|
||||
echo '<div class="right side" > </div>';
|
||||
echo '<div class="content">';
|
||||
|
||||
echo '<div class="summary">';
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo '<p><a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
|
||||
/// Now all the normal modules by week
|
||||
/// Everything below uses "section" terminology - each "section" is a week.
|
||||
|
||||
$timenow = time();
|
||||
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
|
||||
$weekdate += 7200; // Add two hours to avoid possible DST problems
|
||||
$section = 1;
|
||||
$sectionmenu = array();
|
||||
$weekofseconds = 604800;
|
||||
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
|
||||
|
||||
$strftimedateshort = ' '.get_string('strftimedateshort');
|
||||
|
||||
while ($weekdate < $course->enddate) {
|
||||
|
||||
$nextweekdate = $weekdate + ($weekofseconds);
|
||||
$weekday = userdate($weekdate, $strftimedateshort);
|
||||
$endweekday = userdate($weekdate+518400, $strftimedateshort);
|
||||
|
||||
if (!empty($sections[$section])) {
|
||||
$thissection = $sections[$section];
|
||||
|
||||
} else {
|
||||
unset($thissection);
|
||||
$thissection->course = $course->id; // Create a new week structure
|
||||
$thissection->section = $section;
|
||||
$thissection->summary = '';
|
||||
$thissection->visible = 1;
|
||||
if (!$thissection->id = insert_record('course_sections', $thissection)) {
|
||||
notify('Error inserting new week!');
|
||||
}
|
||||
}
|
||||
|
||||
$showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
|
||||
|
||||
if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
|
||||
if ($showsection) {
|
||||
$sectionmenu['week='.$section] = s("$strweek $section | $weekday - $endweekday");
|
||||
}
|
||||
$section++;
|
||||
$weekdate = $nextweekdate;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($showsection) {
|
||||
|
||||
$currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
|
||||
|
||||
$currenttext = '';
|
||||
if (!$thissection->visible) {
|
||||
$sectionstyle = ' hidden';
|
||||
} else if ($currentweek) {
|
||||
$sectionstyle = ' current';
|
||||
$currenttext = get_accesshide(get_string('currentweek','access'));
|
||||
} else {
|
||||
$sectionstyle = '';
|
||||
}
|
||||
|
||||
echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side"> </div>';
|
||||
|
||||
// Note, 'right side' is BEFORE content.
|
||||
echo '<div class="right side">';
|
||||
|
||||
if ($displaysection == $section) {
|
||||
echo '<a href="view.php?id='.$course->id.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
|
||||
} else {
|
||||
$strshowonlyweek = get_string("showonlyweek", "", $section);
|
||||
echo '<a href="view.php?id='.$course->id.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="content">';
|
||||
if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
|
||||
echo '<div class="weekdates">'.$currenttext.$weekday.' - '.$endweekday.' ('.get_string('notavailable').')</div>';
|
||||
|
||||
} else {
|
||||
echo '<div class="weekdates">'.$currenttext.$weekday.' - '.$endweekday.'</div>';
|
||||
|
||||
echo '<div class="summary">';
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
$section++;
|
||||
$weekdate = $nextweekdate;
|
||||
}
|
||||
echo "</ul>\n";
|
||||
|
||||
if (!empty($sectionmenu)) {
|
||||
echo '<div align="center" class="jumpmenu">';
|
||||
echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&', $sectionmenu,
|
||||
'sectionmenu', '', get_string('jumpto'), '', '', true);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
?>
|
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 43 KiB |
@ -1,410 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
define('AN_DELIM', '|');
|
||||
define('AN_ENCAP', '"');
|
||||
|
||||
define('AN_REASON_NOCCTYPE', 17);
|
||||
define('AN_REASON_NOCCTYPE2', 28);
|
||||
define('AN_REASON_NOACH', 18);
|
||||
define('AN_REASON_ACHONLY', 56);
|
||||
define('AN_REASON_NOACHTYPE', 245);
|
||||
define('AN_REASON_NOACHTYPE2', 246);
|
||||
|
||||
require_once($CFG->dirroot.'/enrol/authorize/const.php');
|
||||
require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
|
||||
|
||||
/**
|
||||
* Gets settlement date and time
|
||||
*
|
||||
* @param int $time Time processed, usually now.
|
||||
* @return int Settlement date and time
|
||||
*/
|
||||
function authorize_getsettletime($time)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
$cutoff = intval($CFG->an_cutoff);
|
||||
$mins = $cutoff % 60;
|
||||
$hrs = ($cutoff - $mins) / 60;
|
||||
$cutofftime = strtotime("$hrs:$mins", $time);
|
||||
if ($cutofftime < $time) {
|
||||
$cutofftime = strtotime("$hrs:$mins", $time + (24 * 3600));
|
||||
}
|
||||
return $cutofftime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is order settled? Status must be auth_captured or credited.
|
||||
*
|
||||
* @param object $order Order details
|
||||
* @return bool true, if settled, false otherwise.
|
||||
*/
|
||||
function authorize_settled($order)
|
||||
{
|
||||
return (($order->status == AN_STATUS_AUTHCAPTURE || $order->status == AN_STATUS_CREDIT) &&
|
||||
($order->settletime > 0) && ($order->settletime < time()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is order expired? 'Authorized/Pending Capture' transactions are expired after 30 days.
|
||||
*
|
||||
* @param object &$order Order details.
|
||||
* @return bool true, transaction is expired, false otherwise.
|
||||
*/
|
||||
function authorize_expired(&$order)
|
||||
{
|
||||
static $timediff30;
|
||||
|
||||
if ($order->status == AN_STATUS_EXPIRE) {
|
||||
return true;
|
||||
}
|
||||
elseif ($order->status != AN_STATUS_AUTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($timediff30)) {
|
||||
$timediff30 = authorize_getsettletime(time()) - (30 * 24 * 3600);
|
||||
}
|
||||
|
||||
$isexpired = (authorize_getsettletime($order->timecreated) < $timediff30);
|
||||
if ($isexpired) {
|
||||
$order->status = AN_STATUS_EXPIRE;
|
||||
update_record('enrol_authorize', $order);
|
||||
}
|
||||
return $isexpired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an action on authorize.net and updates/inserts records. If record update fails,
|
||||
* sends email to admin.
|
||||
*
|
||||
* @param object &$order Which transaction data will be sent. See enrol_authorize table.
|
||||
* @param string &$message Information about error message.
|
||||
* @param object &$extra Extra data that used for refunding and credit card information.
|
||||
* @param int $action Which action will be performed. See AN_ACTION_*
|
||||
* @param string $cctype Used internally to configure credit types automatically.
|
||||
* @return int AN_APPROVED Transaction was successful, AN_RETURNZERO otherwise. Use $message for reason.
|
||||
* @author Ethem Evlice <ethem a.t evlice d.o.t com>
|
||||
* @uses $CFG
|
||||
*/
|
||||
function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $cctype=NULL)
|
||||
{
|
||||
global $CFG;
|
||||
static $constpd;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
if (!isset($constpd)) {
|
||||
$mconfig = get_config('enrol/authorize');
|
||||
$constpd = array(
|
||||
'x_version' => '3.1',
|
||||
'x_delim_data' => 'True',
|
||||
'x_delim_char' => AN_DELIM,
|
||||
'x_encap_char' => AN_ENCAP,
|
||||
'x_relay_response' => 'FALSE',
|
||||
'x_login' => rc4decrypt($mconfig->an_login)
|
||||
);
|
||||
|
||||
if (!empty($mconfig->an_tran_key)) {
|
||||
$constpd['x_tran_key'] = rc4decrypt($mconfig->an_tran_key);
|
||||
}
|
||||
else {
|
||||
$constpd['x_password'] = rc4decrypt($mconfig->an_password);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($order) or empty($order->id)) {
|
||||
$message = "Check order->id!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
|
||||
$method = $order->paymentmethod;
|
||||
if (empty($method)) {
|
||||
$method = AN_METHOD_CC;
|
||||
}
|
||||
elseif ($method != AN_METHOD_CC && $method != AN_METHOD_ECHECK) {
|
||||
$message = "Invalid method: $method";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
|
||||
$action = intval($action);
|
||||
if ($method == AN_METHOD_ECHECK) {
|
||||
if ($action != AN_ACTION_AUTH_CAPTURE && $action != AN_ACTION_CREDIT) {
|
||||
$message = "Please perform AUTH_CAPTURE or CREDIT for echecks";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
}
|
||||
|
||||
$pd = $constpd;
|
||||
$pd['x_method'] = $method;
|
||||
$test = !empty($CFG->an_test);
|
||||
$pd['x_test_request'] = ($test ? 'TRUE' : 'FALSE');
|
||||
|
||||
switch ($action) {
|
||||
case AN_ACTION_AUTH_ONLY:
|
||||
case AN_ACTION_CAPTURE_ONLY:
|
||||
case AN_ACTION_AUTH_CAPTURE:
|
||||
{
|
||||
if ($order->status != AN_STATUS_NONE) {
|
||||
$message = "Order status must be AN_STATUS_NONE(0)!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
elseif (empty($extra)) {
|
||||
$message = "Need extra fields!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
elseif (($action == AN_ACTION_CAPTURE_ONLY) and empty($extra->x_auth_code)) {
|
||||
$message = "x_auth_code is required for capture only transactions!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
|
||||
$ext = (array)$extra;
|
||||
$pd['x_type'] = (($action==AN_ACTION_AUTH_ONLY)
|
||||
? 'AUTH_ONLY' :( ($action==AN_ACTION_CAPTURE_ONLY)
|
||||
? 'CAPTURE_ONLY' : 'AUTH_CAPTURE'));
|
||||
foreach($ext as $k => $v) {
|
||||
$pd[$k] = $v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AN_ACTION_PRIOR_AUTH_CAPTURE:
|
||||
{
|
||||
if ($order->status != AN_STATUS_AUTH) {
|
||||
$message = "Order status must be authorized!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
if (authorize_expired($order)) {
|
||||
$message = "Transaction must be captured within 30 days. EXPIRED!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
$pd['x_type'] = 'PRIOR_AUTH_CAPTURE';
|
||||
$pd['x_trans_id'] = $order->transid;
|
||||
break;
|
||||
}
|
||||
|
||||
case AN_ACTION_CREDIT:
|
||||
{
|
||||
if ($order->status != AN_STATUS_AUTHCAPTURE) {
|
||||
$message = "Order status must be authorized/captured!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
if (!authorize_settled($order)) {
|
||||
$message = "Order must be settled. Try VOID, check Cut-Off time if it fails!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
if (empty($extra->amount)) {
|
||||
$message = "No valid amount!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
$timenowsettle = authorize_getsettletime(time());
|
||||
$timediff = $timenowsettle - (120 * 3600 * 24);
|
||||
if ($order->settletime < $timediff) {
|
||||
$message = "Order must be credited within 120 days!";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
|
||||
$pd['x_type'] = 'CREDIT';
|
||||
$pd['x_trans_id'] = $order->transid;
|
||||
$pd['x_currency_code'] = $order->currency;
|
||||
$pd['x_invoice_num'] = $extra->orderid;
|
||||
$pd['x_amount'] = $extra->amount;
|
||||
if ($method == AN_METHOD_CC) {
|
||||
$pd['x_card_num'] = sprintf("%04d", intval($order->refundinfo));
|
||||
}
|
||||
elseif ($method == AN_METHOD_ECHECK && empty($order->refundinfo)) {
|
||||
$message = "Business checkings can be refunded only.";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AN_ACTION_VOID:
|
||||
{
|
||||
if (authorize_expired($order) || authorize_settled($order)) {
|
||||
$message = "The transaction cannot be voided due to the fact that it is expired or settled.";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
$pd['x_type'] = 'VOID';
|
||||
$pd['x_trans_id'] = $order->transid;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
$message = "Invalid action: $action";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
}
|
||||
|
||||
$headers = array('Connection' => 'close');
|
||||
if (! (empty($CFG->an_referer) || $CFG->an_referer == "http://")) {
|
||||
$headers['Referer'] = $CFG->an_referer;
|
||||
}
|
||||
|
||||
@ignore_user_abort(true);
|
||||
if (intval(ini_get('max_execution_time')) > 0) {
|
||||
@set_time_limit(300);
|
||||
}
|
||||
|
||||
$host = $test ? 'certification.authorize.net' : 'secure.authorize.net';
|
||||
$data = download_file_content("https://$host:443/gateway/transact.dll", $headers, $pd, false, 60);
|
||||
if (!$data) {
|
||||
$message = "No connection to https://$host:443";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
$response = explode(AN_ENCAP.AN_DELIM.AN_ENCAP, $data);
|
||||
if ($response === false) {
|
||||
$message = "response error";
|
||||
return AN_RETURNZERO;
|
||||
}
|
||||
$rcount = count($response) - 1;
|
||||
if ($response[0]{0} == AN_ENCAP) {
|
||||
$response[0] = substr($response[0], 1);
|
||||
}
|
||||
if (substr($response[$rcount], -1) == AN_ENCAP) {
|
||||
$response[$rcount] = substr($response[$rcount], 0, -1);
|
||||
}
|
||||
|
||||
$responsecode = intval($response[0]);
|
||||
if ($responsecode == AN_APPROVED || $responsecode == AN_REVIEW)
|
||||
{
|
||||
$transid = intval($response[6]);
|
||||
if ($test || $transid == 0) {
|
||||
return $responsecode; // don't update original transaction in test mode.
|
||||
}
|
||||
switch ($action) {
|
||||
case AN_ACTION_AUTH_ONLY:
|
||||
case AN_ACTION_CAPTURE_ONLY:
|
||||
case AN_ACTION_AUTH_CAPTURE:
|
||||
case AN_ACTION_PRIOR_AUTH_CAPTURE:
|
||||
{
|
||||
$order->transid = $transid;
|
||||
|
||||
if ($method == AN_METHOD_CC) {
|
||||
if ($action == AN_ACTION_AUTH_ONLY || $responsecode == AN_REVIEW) {
|
||||
$order->status = AN_STATUS_AUTH;
|
||||
} else {
|
||||
$order->status = AN_STATUS_AUTHCAPTURE;
|
||||
$order->settletime = authorize_getsettletime(time());
|
||||
}
|
||||
}
|
||||
elseif ($method == AN_METHOD_ECHECK) {
|
||||
$order->status = AN_STATUS_UNDERREVIEW;
|
||||
}
|
||||
|
||||
if (! update_record('enrol_authorize', $order)) {
|
||||
email_to_admin("Error while trying to update data " .
|
||||
"in table enrol_authorize. Please edit manually this record: ID=$order->id.", $order);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AN_ACTION_CREDIT:
|
||||
{
|
||||
// Credit generates new transaction id.
|
||||
// So, $extra must be updated, not $order.
|
||||
$extra->status = AN_STATUS_CREDIT;
|
||||
$extra->transid = $transid;
|
||||
$extra->settletime = authorize_getsettletime(time());
|
||||
if (! $extra->id = insert_record('enrol_authorize_refunds', $extra)) {
|
||||
unset($extra->id);
|
||||
email_to_admin("Error while trying to insert data " .
|
||||
"into table enrol_authorize_refunds. Please add manually this record:", $extra);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AN_ACTION_VOID:
|
||||
{
|
||||
$tableupdate = 'enrol_authorize';
|
||||
if ($order->status == AN_STATUS_CREDIT) {
|
||||
$tableupdate = 'enrol_authorize_refunds';
|
||||
unset($order->paymentmethod);
|
||||
}
|
||||
$order->status = AN_STATUS_VOID;
|
||||
if (! update_record($tableupdate, $order)) {
|
||||
email_to_admin("Error while trying to update data " .
|
||||
"in table $tableupdate. Please edit manually this record: ID=$order->id.", $order);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$reasonno = $response[2];
|
||||
$reasonstr = "reason" . $reasonno;
|
||||
$message = get_string($reasonstr, "enrol_authorize");
|
||||
if ($message == '[[' . $reasonstr . ']]') {
|
||||
$message = isset($response[3]) ? $response[3] : 'unknown error';
|
||||
}
|
||||
if ($method == AN_METHOD_CC && !empty($CFG->an_avs) && $response[5] != "P") {
|
||||
$avs = "avs" . strtolower($response[5]);
|
||||
$stravs = get_string($avs, "enrol_authorize");
|
||||
$message .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
|
||||
}
|
||||
if (!$test) { // Autoconfigure :)
|
||||
switch($reasonno) {
|
||||
// Credit card type isn't accepted
|
||||
case AN_REASON_NOCCTYPE:
|
||||
case AN_REASON_NOCCTYPE2:
|
||||
{
|
||||
if (!empty($cctype)) {
|
||||
$ccaccepts = get_list_of_creditcards();
|
||||
unset($ccaccepts[$cctype]);
|
||||
set_config('an_acceptccs', implode(',', array_keys($ccaccepts)));
|
||||
email_to_admin("$message ($cctype)" .
|
||||
"This is new config(an_acceptccs):", $ccaccepts);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Echecks only
|
||||
case AN_REASON_ACHONLY:
|
||||
{
|
||||
set_config('an_acceptmethods', AN_METHOD_ECHECK);
|
||||
email_to_admin("$message " .
|
||||
"This is new config(an_acceptmethods):", array(AN_METHOD_ECHECK));
|
||||
break;
|
||||
}
|
||||
// Echecks aren't accepted
|
||||
case AN_REASON_NOACH:
|
||||
{
|
||||
set_config('an_acceptmethods', AN_METHOD_CC);
|
||||
email_to_admin("$message " .
|
||||
"This is new config(an_acceptmethods):", array(AN_METHOD_CC));
|
||||
break;
|
||||
}
|
||||
// This echeck type isn't accepted
|
||||
case AN_REASON_NOACHTYPE:
|
||||
case AN_REASON_NOACHTYPE2:
|
||||
{
|
||||
if (!empty($extra->x_echeck_type)) {
|
||||
switch ($extra->x_echeck_type) {
|
||||
// CCD=BUSINESSCHECKING
|
||||
case 'CCD':
|
||||
{
|
||||
set_config('an_acceptechecktypes', 'CHECKING,SAVINGS');
|
||||
email_to_admin("$message " .
|
||||
"This is new config(an_acceptechecktypes):", array('CHECKING','SAVINGS'));
|
||||
}
|
||||
break;
|
||||
// WEB=CHECKING or SAVINGS
|
||||
case 'WEB':
|
||||
{
|
||||
set_config('an_acceptechecktypes', 'BUSINESSCHECKING');
|
||||
email_to_admin("$message " .
|
||||
"This is new config(an_acceptechecktypes):", array('BUSINESSCHECKING'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $responsecode;
|
||||
}
|
||||
|
||||
?>
|
@ -20,7 +20,7 @@ define('AN_METHOD_ECHECK', 'echeck');
|
||||
* CREDIT: Refunded.
|
||||
* VOID: Cancelled.
|
||||
* EXPIRE: Expired. Orders be expired unless be accepted within 30 days.
|
||||
*
|
||||
*
|
||||
* These are valid only for ECHECK:
|
||||
* UNDERREVIEW: Hold for review.
|
||||
* APPROVEDREVIEW: Approved review.
|
||||
@ -41,7 +41,7 @@ define('AN_STATUS_TEST', 0xff); // dummy status
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Actions used in authorize_action() function.
|
||||
* Actions used in AuthorizeNet::process() method.
|
||||
*
|
||||
* NONE: No action. Function always returns false.
|
||||
* AUTH_ONLY: Used to authorize only, don't capture.
|
||||
@ -75,7 +75,7 @@ define('AN_ACTION_VOID', 6);
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Return codes for authorize_action() function.
|
||||
* Return codes for AuthorizeNet::process() method.
|
||||
*
|
||||
* AN_RETURNZERO: No connection was made on authorize.net.
|
||||
* AN_APPROVED: The transaction was accepted.
|
||||
|
@ -1,145 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
// MySQL commands for upgrading this enrolment module
|
||||
|
||||
function enrol_authorize_upgrade($oldversion=0) {
|
||||
global $CFG, $THEME, $db;
|
||||
require_once("$CFG->dirroot/enrol/authorize/const.php");
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2005071600) {
|
||||
// Be sure, only last 4 digit is inserted.
|
||||
table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize', 'courseid', 'courseid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize', 'userid', 'userid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
// Add some indexes for speed.
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX courseid(courseid)", false);
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX userid(userid)", false);
|
||||
}
|
||||
|
||||
if ($oldversion && $oldversion < 2005071602) {
|
||||
notify("If you are using the authorize.net enrolment plugin for credit card
|
||||
handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005112100) {
|
||||
table_column('enrol_authorize', '', 'authcode', 'varchar', '6', '', '', '', 'avscode'); // CAPTURE_ONLY
|
||||
table_column('enrol_authorize', '', 'status', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
|
||||
table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
|
||||
table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
|
||||
// status index for speed.
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX status(status)");
|
||||
// defaults.
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
|
||||
$timenow = time();
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2005121200) {
|
||||
// new fields for refund and sales reports.
|
||||
$defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
|
||||
table_column('enrol_authorize', '', 'amount', 'varchar', '10', '', '0', 'not null', 'timeupdated');
|
||||
table_column('enrol_authorize', '', 'currency', 'varchar', '3', '', $defaultcurrency, 'not null', 'amount');
|
||||
modify_database("","CREATE TABLE prefix_enrol_authorize_refunds (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`orderid` int(10) unsigned NOT NULL default 0,
|
||||
`refundtype` int(1) unsigned NOT NULL default 0,
|
||||
`amount` varchar(10) NOT NULL default '',
|
||||
`transid` int(10) unsigned NULL default 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `orderid` (`orderid`));");
|
||||
// defaults.
|
||||
if (($courses = get_records_select('course', '', '', 'id, cost, currency'))) {
|
||||
foreach ($courses as $course) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize
|
||||
SET amount = '$course->cost', currency = '$course->currency'
|
||||
WHERE courseid = '$course->id'", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005122200) { // settletime
|
||||
table_column('enrol_authorize_refunds', 'refundtype', 'status', 'integer', '1', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize_refunds', '', 'settletime', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
|
||||
table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
if (($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime'))) {
|
||||
include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
|
||||
foreach ($settlements as $settlement) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
|
||||
authorize_getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005122800) { // no need anymore some fields.
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006010200) { // rename an_review_day
|
||||
if (isset($CFG->an_review_day)) {
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
|
||||
if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) {
|
||||
$an_cutoff_hour = intval($CFG->an_cutoff_hour);
|
||||
$an_cutoff_min = intval($CFG->an_cutoff_min);
|
||||
$an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min;
|
||||
if (set_config('an_cutoff', $an_cutoff)) {
|
||||
delete_records('config', 'name', 'an_cutoff_hour');
|
||||
delete_records('config', 'name', 'an_cutoff_min');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021500) { // transid is int
|
||||
table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006050400) { // Create transid indexes for backup & restore speed.
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX transid(transid)", false);
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize_refunds` ADD INDEX transid(transid)", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006060500) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
|
||||
}
|
||||
|
||||
if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
|
||||
if (isset($CFG->an_teachermanagepay)) {
|
||||
delete_records('config', 'name', 'an_teachermanagepay');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006083100) {
|
||||
// enums are lower case
|
||||
if (isset($CFG->an_acceptmethods)) {
|
||||
set_config('an_acceptmethods', strtolower($CFG->an_acceptmethods));
|
||||
}
|
||||
// new ENUM field: paymentmethod(cc,echeck)
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD paymentmethod enum('cc', 'echeck') NOT NULL default 'cc' AFTER `id`", true);
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
@ -1,157 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
// PostgreSQL commands for upgrading this enrolment module
|
||||
|
||||
function enrol_authorize_upgrade($oldversion=0) {
|
||||
global $CFG, $THEME, $db;
|
||||
require_once("$CFG->dirroot/enrol/authorize/const.php");
|
||||
|
||||
$result = true;
|
||||
|
||||
if (!$tables = $db->MetaColumns($CFG->prefix . 'enrol_authorize')) {
|
||||
$installfirst = true;
|
||||
}
|
||||
|
||||
if ($oldversion == 0 || !empty($installfirst)) { // First time install
|
||||
$result = modify_database("$CFG->dirroot/enrol/authorize/db/postgres7.sql");
|
||||
return $result; // RETURN, sql file contains last upgrades.
|
||||
}
|
||||
|
||||
// Authorize module was installed before. Upgrades must be applied to SQL file.
|
||||
|
||||
if ($oldversion && $oldversion < 2005071602) {
|
||||
notify("If you are using the authorize.net enrolment plugin for credit card
|
||||
handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005080200) {
|
||||
// Be sure, only last 4 digit is inserted.
|
||||
table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize', 'courseid', 'courseid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize', 'userid', 'userid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
// Add some indexes for speed.
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_courseid_idx ON {$CFG->prefix}enrol_authorize (courseid);", false);
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_userid_idx ON {$CFG->prefix}enrol_authorize (userid);", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2005112100) {
|
||||
table_column('enrol_authorize', '', 'authcode', 'varchar', '6', '', '', '', 'avscode'); // CAPTURE_ONLY
|
||||
table_column('enrol_authorize', '', 'status', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
|
||||
table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
|
||||
table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
|
||||
// status index for speed.
|
||||
modify_database('',"CREATE INDEX prefix_enrol_authorize_status_idx ON prefix_enrol_authorize (status);");
|
||||
// defaults.
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
|
||||
$timenow = time();
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2005121200) {
|
||||
// new fields for refund and sales reports.
|
||||
$defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
|
||||
table_column('enrol_authorize', '', 'amount', 'varchar', '10', '', '0', 'not null', 'timeupdated');
|
||||
table_column('enrol_authorize', '', 'currency', 'varchar', '3', '', $defaultcurrency, 'not null', 'amount');
|
||||
modify_database("","CREATE TABLE prefix_enrol_authorize_refunds (
|
||||
id SERIAL PRIMARY KEY,
|
||||
orderid INTEGER NOT NULL default 0,
|
||||
refundtype INTEGER NOT NULL default 0,
|
||||
amount varchar(10) NOT NULL default '',
|
||||
transid INTEGER NULL default 0
|
||||
);");
|
||||
modify_database("","CREATE INDEX prefix_enrol_authorize_refunds_orderid_idx ON prefix_enrol_authorize_refunds (orderid);");
|
||||
// defaults.
|
||||
if (($courses = get_records_select('course', '', '', 'id, cost, currency'))) {
|
||||
foreach ($courses as $course) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize
|
||||
SET amount = '$course->cost', currency = '$course->currency'
|
||||
WHERE courseid = '$course->id'", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005122200) { // settletime
|
||||
table_column('enrol_authorize_refunds', 'refundtype', 'status', 'integer', '1', 'unsigned', '0', 'not null');
|
||||
table_column('enrol_authorize_refunds', '', 'settletime', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
|
||||
table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
if (($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime'))) {
|
||||
include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
|
||||
foreach ($settlements as $settlement) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
|
||||
authorize_getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2005122800) { // no need anymore some fields.
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006010200) { // rename an_review_day
|
||||
if (isset($CFG->an_review_day)) {
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
|
||||
if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) {
|
||||
$an_cutoff_hour = intval($CFG->an_cutoff_hour);
|
||||
$an_cutoff_min = intval($CFG->an_cutoff_min);
|
||||
$an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min;
|
||||
if (set_config('an_cutoff', $an_cutoff)) {
|
||||
delete_records('config', 'name', 'an_cutoff_hour');
|
||||
delete_records('config', 'name', 'an_cutoff_min');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021500) { // transid is int
|
||||
table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006050400) { // Create transid indexes for backup & restore speed.
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_transid_idx ON {$CFG->prefix}enrol_authorize(transid);", false);
|
||||
execute_sql("CREATE INDEX {$CFG->prefix}enrol_authorize_refunds_transid_idx ON {$CFG->prefix}enrol_authorize_refunds(transid);", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006060500) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
|
||||
}
|
||||
|
||||
if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
|
||||
if (isset($CFG->an_teachermanagepay)) {
|
||||
delete_records('config', 'name', 'an_teachermanagepay');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006083100) {
|
||||
// enums are lower case
|
||||
if (isset($CFG->an_acceptmethods)) {
|
||||
set_config('an_acceptmethods', strtolower($CFG->an_acceptmethods));
|
||||
}
|
||||
// new ENUM field: paymentmethod(cc,echeck)
|
||||
table_column('enrol_authorize', '', 'paymentmethod', 'varchar', '6', '', 'cc', 'not null');
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize ADD CONSTRAINT enroauth_pay_ck CHECK (paymentmethod IN ('cc', 'echeck'))", true);
|
||||
}
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
@ -1,22 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
// MySQL commands for upgrading this enrolment module
|
||||
|
||||
function enrol_paypal_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG, $THEME, $db;
|
||||
|
||||
$result = true;
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,22 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
|
||||
//
|
||||
// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
|
||||
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
|
||||
|
||||
// PostgreSQL commands for upgrading this enrolment module
|
||||
|
||||
function enrol_paypal_upgrade($oldversion=0) {
|
||||
|
||||
global $CFG, $THEME, $db;
|
||||
|
||||
$result = true;
|
||||
|
||||
////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
|
||||
|
||||
require_once("../../config.php");
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
|
||||
|
||||
require_once("../../config.php");
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// If not, it obtains the corresponding TeX expression from the cache_tex db table
|
||||
// and uses mimeTeX to create the image file
|
||||
|
||||
$nomoodlecookie = true; // Because it interferes with caching
|
||||
define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/filter/tex/lib.php');
|
||||
|
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$nomoodlecookie = true; // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require '../../../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$nomoodlecookie = true; // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require '../../../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$nomoodlecookie = true; // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require '../../../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$nomoodlecookie = true; // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require '../../../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$nomoodlecookie = true; // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require '../../../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
@ -85,8 +85,8 @@
|
||||
}
|
||||
|
||||
|
||||
if (get_moodle_cookie() == '') {
|
||||
set_moodle_cookie('nobody'); // To help search for cookies on login page
|
||||
if ($SESSION->get_moodle_cookie() == '') {
|
||||
$SESSION->set_moodle_cookie('nobody'); // To help search for cookies on login page
|
||||
}
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
|
@ -36,14 +36,14 @@ $string['availabledbtypes']='Available db types';
|
||||
$string['availablelangs']='List of available languages';
|
||||
$string['bypassed'] = 'Bypassed';
|
||||
$string['cannotconnecttodb'] = 'Cannot connect to db';
|
||||
$string['cannotcreatelangdir'] = 'Cannot create lang dir.';
|
||||
$string['cannotcreatetempdir'] = 'Cannot create temp dir.';
|
||||
$string['cannotdownloadcomponents'] = 'Cannot download components.';
|
||||
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file.';
|
||||
$string['cannotfindcomponent'] = 'Cannot find component.';
|
||||
$string['cannotsavemd5file'] = 'Cannot save md5 file.';
|
||||
$string['cannotsavezipfile'] = 'Cannot save ZIP file.';
|
||||
$string['cannotunzipfile'] = 'Cannot unzip file.';
|
||||
$string['cannotcreatelangdir'] = 'Cannot create lang directory';
|
||||
$string['cannotcreatetempdir'] = 'Cannot create temp directory';
|
||||
$string['cannotdownloadcomponents'] = 'Cannot download components';
|
||||
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file';
|
||||
$string['cannotfindcomponent'] = 'Cannot find component';
|
||||
$string['cannotsavemd5file'] = 'Cannot save md5 file';
|
||||
$string['cannotsavezipfile'] = 'Cannot save ZIP file';
|
||||
$string['cannotunzipfile'] = 'Cannot unzip file';
|
||||
$string['caution'] = 'Caution';
|
||||
$string['check'] = 'Check';
|
||||
$string['checkingphpsettings']='Checking PHP Settings';
|
||||
@ -54,7 +54,7 @@ $string['closewindow'] = 'Close this window';
|
||||
$string['compatibilitysettings'] = 'Checking your PHP settings ...';
|
||||
$string['compatibilitysettingshead'] = 'Checking your PHP settings ...';
|
||||
$string['compatibilitysettingssub'] = 'Your server should pass all these tests to make Moodle run properly';
|
||||
$string['componentisuptodate'] = 'Component is up to date.';
|
||||
$string['componentisuptodate'] = 'Component is up-to-date';
|
||||
$string['configfilecreated'] = 'Configuration file successfully created';
|
||||
$string['configfiledoesnotexist'] = 'Configuration file does not exist !!!';
|
||||
$string['configfilenotwritten'] = 'The installer script was not able to automatically create a config.php file containing your chosen settings, probably because the Moodle directory is not writeable. You can manually copy the following code into a file named config.php within the root directory of Moodle.';
|
||||
@ -215,7 +215,7 @@ $string['dirroot'] = 'Moodle Directory';
|
||||
$string['dirrooterror'] = 'The \'Moodle Directory\' setting seems to be incorrect - we can\'t find a Moodle installation there. The value below has been reset.';
|
||||
$string['disagreelicense'] = 'Upgrade cannot proceed due to disagreement to GPL!';
|
||||
$string['download'] = 'Download';
|
||||
$string['downloadedfilecheckfailed'] = 'Downloaded file check failed.';
|
||||
$string['downloadedfilecheckfailed'] = 'Downloaded file check failed';
|
||||
$string['downloadlanguagebutton'] = 'Download the "$a" language pack';
|
||||
$string['downloadlanguagehead'] = 'Download language pack';
|
||||
$string['downloadlanguagenotneeded'] = 'You may continue the installation process using the default language pack, \"$a\".';
|
||||
@ -363,7 +363,7 @@ $string['phpversionhelp'] = '<p>Moodle requires a PHP version of at least 4.3.0
|
||||
<p>You must upgrade PHP or move to a host with a newer version of PHP!<br/>
|
||||
(In case of 5.0.x you could also downgrade to 4.4.x version)</p>';
|
||||
$string['postgres7'] = 'PostgreSQL (postgres7)';
|
||||
$string['prefixcannotbeempty'] = '<p>Error: database table prefix can not be empty ($a)</p>
|
||||
$string['prefixcannotbeempty'] = '<p>Error: database table prefix cannot be empty ($a)</p>
|
||||
<p>The site administrator must fix this problem.</p>';
|
||||
$string['prefixtoolong'] = '<p>Error: database table prefix is too long ($a->dbfamily)</p>
|
||||
<p>The site administrator must fix this problem. Maximum length for table prefixes in $a->dbfamily is $a->maxlength characters.</p>';
|
||||
@ -469,9 +469,9 @@ $string['welcomep60'] = 'The following pages will lead you through some easy to
|
||||
$string['welcomep70'] = 'Click the \"Next\" button below to continue with the set up of <strong>Moodle</strong>.';
|
||||
$string['welcometext']='---Welcome to moodle commandline installer---';
|
||||
$string['writetoconfigfilefaild'] = 'Error: Write to config file failed ';
|
||||
$string['wrongdestpath'] = 'Wrong destination path.';
|
||||
$string['wrongsourcebase'] = 'Wrong source URL base.';
|
||||
$string['wrongzipfilename'] = 'Wrong ZIP filename.';
|
||||
$string['wrongdestpath'] = 'Wrong destination path';
|
||||
$string['wrongsourcebase'] = 'Wrong source URL base';
|
||||
$string['wrongzipfilename'] = 'Wrong ZIP file name';
|
||||
$string['wwwroot'] = 'Web address';
|
||||
$string['wwwrooterror'] = 'The \'Web Address\' does not appear to be valid - this Moodle installation doesn\'t appear to be there. The value below has been reset.';
|
||||
$string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.';
|
||||
|
@ -12,4 +12,14 @@ $string['go'] = 'Go!';
|
||||
$string['bytes'] = ' bytes (0 stands for no limits)';
|
||||
$string['searchmoodle'] = 'Search Moodle';
|
||||
$string['usemoodleroot'] = 'Use moodle root for external converters';
|
||||
$string['wordhandling'] = 'Microsoft Word handling';
|
||||
$string['pdfhandling'] = 'Acrobat PDF handling';
|
||||
$string['handlingfor'] = 'Extra handling for';
|
||||
$string['searchdiscovery'] = 'Searchable items discovery';
|
||||
$string['configtypetotxtcmd'] = 'Converter\'s command line';
|
||||
$string['configtypetotxtenv'] = 'Environment define for converter';
|
||||
$string['modulessearchswitches'] = 'Indexer activation for modules';
|
||||
$string['blockssearchswitches'] = 'Indexer activation for blocks';
|
||||
$string['nosearchablemodules'] = 'No searchable modules';
|
||||
$string['nosearchableblocks'] = 'No searchable blocks';
|
||||
?>
|
Before Width: | Height: | Size: 991 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 30 KiB |
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../../weblib.php');
|
||||
|
||||
add_to_log(0, 'adodb', 'intrusion attempt', 'lib/adodb/tests/tmssql.php');
|
||||
trigger_error('SECURITY WARNING: intrusion attempt against lib/tests/tmssql.php from ' . getremoteaddr());
|
||||
error('SECURITY WARNING: logged intrusion attempt against lib/adodb/tests/tmssql.php');
|
||||
|
||||
?>
|
@ -84,9 +84,9 @@
|
||||
// $a = new stdClass();
|
||||
// $a->url = 'http://download.moodle.org/lang16/es_utf8.zip';
|
||||
// $a->dest= $CFG->dataroot.'/lang';
|
||||
// error(get_string($cd->get_error(), 'error', $a));
|
||||
// print_error($cd->get_error(), 'error', '', $a);
|
||||
// } else {
|
||||
// error(get_string($cd->get_error(), 'error'));
|
||||
// print_error($cd->get_error(), 'error');
|
||||
// }
|
||||
// break;
|
||||
// case COMPONENT_UPTODATE:
|
||||
|
@ -1,136 +0,0 @@
|
||||
<?php // $Id$
|
||||
/**
|
||||
* Enable cookieless sessions by including $CFG->usesid=true;
|
||||
* in config.php.
|
||||
* Based on code from php manual by Richard at postamble.co.uk
|
||||
* Attempts to use cookies if cookies not present then uses session ids attached to all urls and forms to pass session id from page to page.
|
||||
* If site is open to google, google is given guest access as usual and there are no sessions. No session ids will be attached to urls for googlebot.
|
||||
* This doesn't require trans_sid to be turned on but this is recommended for better performance
|
||||
* you should put :
|
||||
* session.use_trans_sid = 1
|
||||
* in your php.ini file and make sure that you don't have a line like this in your php.ini
|
||||
* session.use_only_cookies = 1
|
||||
* @author Richard at postamble.co.uk and Jamie Pratt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
/**
|
||||
* You won't call this function directly. This function is used to process
|
||||
* text buffered by php in an output buffer. All output is run through this function
|
||||
* before it is ouput.
|
||||
* @param string $buffer is the output sent from php
|
||||
* @return string the output sent to the browser
|
||||
*/
|
||||
function sid_ob_rewrite($buffer){
|
||||
$replacements = array(
|
||||
'/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*")([^"]*)(")/i',
|
||||
'/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*\')([^\']*)(\')/i');
|
||||
|
||||
$buffer = preg_replace_callback($replacements, "sid_rewrite_link_tag", $buffer);
|
||||
$buffer = preg_replace('/<form\s[^>]*>/i',
|
||||
'\0<input type="hidden" name="' . session_name() . '" value="' . session_id() . '"/>', $buffer);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
/**
|
||||
* You won't call this function directly. This function is used to process
|
||||
* text buffered by php in an output buffer. All output is run through this function
|
||||
* before it is ouput.
|
||||
* This function only processes absolute urls, it is used when we decide that
|
||||
* php is processing other urls itself but needs some help with internal absolute urls still.
|
||||
* @param string $buffer is the output sent from php
|
||||
* @return string the output sent to the browser
|
||||
*/
|
||||
function sid_ob_rewrite_absolute($buffer){
|
||||
$replacements = array(
|
||||
'/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*")((?:http|https)[^"]*)(")/i',
|
||||
'/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*\')((?:http|https)[^\']*)(\')/i');
|
||||
|
||||
$buffer = preg_replace_callback($replacements, "sid_rewrite_link_tag", $buffer);
|
||||
$buffer = preg_replace('/<form\s[^>]*>/i',
|
||||
'\0<input type="hidden" name="' . session_name() . '" value="' . session_id() . '"/>', $buffer);
|
||||
return $buffer;
|
||||
}
|
||||
/**
|
||||
* A function to process link, a and script tags found
|
||||
* by preg_replace_callback in {@link sid_ob_rewrite($buffer)}.
|
||||
*/
|
||||
function sid_rewrite_link_tag($matches){
|
||||
$url = $matches[4];
|
||||
$url=sid_process_url($url);
|
||||
return $matches[1]. $url.$matches[5];
|
||||
}
|
||||
/**
|
||||
* You can call this function directly. This function is used to process
|
||||
* urls to add a moodle session id to the url for internal links.
|
||||
* @param string $url is a url
|
||||
* @return string the processed url
|
||||
*/
|
||||
function sid_process_url($url) {
|
||||
global $CFG;
|
||||
if ((preg_match('/^(http|https):/i', $url)) // absolute url
|
||||
&& ((stripos($url, $CFG->wwwroot)!==0) && stripos($url, $CFG->httpswwwroot)!==0)) { // and not local one
|
||||
return $url; //don't attach sessid to non local urls
|
||||
}
|
||||
if ($url[0]=='#' || (stripos($url, 'javascript:')===0)) {
|
||||
return $url; //don't attach sessid to anchors
|
||||
}
|
||||
if (strpos($url, session_name())!==FALSE)
|
||||
{
|
||||
return $url; //don't attach sessid to url that already has one sessid
|
||||
}
|
||||
if (strpos($url, "?")===FALSE){
|
||||
$append="?".strip_tags(session_name() . '=' . session_id() );
|
||||
} else {
|
||||
$append="&".strip_tags(session_name() . '=' . session_id() );
|
||||
}
|
||||
//put sessid before any anchor
|
||||
$p = strpos($url, "#");
|
||||
if($p!==FALSE){
|
||||
$anch = substr($url, $p);
|
||||
$url = substr($url, 0, $p).$append.$anch ;
|
||||
} else {
|
||||
$url .= $append ;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this function before there has been any output to the browser to
|
||||
* buffer output and add session ids to all internal links.
|
||||
*/
|
||||
function sid_start_ob(){
|
||||
global $CFG;
|
||||
//don't attach sess id for bots
|
||||
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
if (!empty($CFG->opentogoogle)) {
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
||||
@ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
|
||||
$CFG->usesid=false;
|
||||
return;
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) {
|
||||
@ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
|
||||
$CFG->usesid=false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false ) {
|
||||
@ini_set('session.use_trans_sid', '0'); // try and turn off trans_sid
|
||||
$CFG->usesid=false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ini_set('session.use_trans_sid', '1'); // try and turn on trans_sid
|
||||
if (ini_get('session.use_trans_sid')!=0 ){
|
||||
// use trans sid as its available
|
||||
ini_set('url_rewriter.tags', 'a=href,area=href,script=src,link=href,'
|
||||
. 'frame=src,form=fakeentry');
|
||||
ob_start('sid_ob_rewrite_absolute');
|
||||
}else{
|
||||
//rewrite all links ourselves
|
||||
ob_start('sid_ob_rewrite');
|
||||
}
|
||||
}
|
||||
?>
|
2337
lib/db/mysql.php
1961
lib/db/postgres7.php
@ -555,7 +555,7 @@ function get_mimetype_description($mimetype,$capitalise=false) {
|
||||
* @param string $mimetype Include to specify the MIME type; leave blank to have it guess the type from $filename
|
||||
*/
|
||||
function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
|
||||
global $CFG, $COURSE;
|
||||
global $CFG, $COURSE, $SESSION;
|
||||
|
||||
// Use given MIME type if specified, otherwise guess it using mimeinfo.
|
||||
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
|
||||
@ -670,7 +670,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
|
||||
//cookieless mode - rewrite links
|
||||
@header('Content-Type: text/html');
|
||||
$path = $pathisstring ? $path : implode('', file($path));
|
||||
$path = sid_ob_rewrite($path);
|
||||
$path = $SESSION->sid_ob_rewrite($path);
|
||||
$filesize = strlen($path);
|
||||
$pathisstring = true;
|
||||
} else if ($mimetype == 'text/plain') {
|
||||
@ -696,7 +696,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
|
||||
$output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
|
||||
if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
|
||||
//cookieless mode - rewrite links
|
||||
$output = sid_ob_rewrite($output);
|
||||
$output = $SESSION->sid_ob_rewrite($output);
|
||||
}
|
||||
|
||||
@header('Content-Length: '.strlen($output));
|
||||
@ -712,7 +712,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
|
||||
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'</pre>';
|
||||
if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
|
||||
//cookieless mode - rewrite links
|
||||
$output = sid_ob_rewrite($output);
|
||||
$output = $SESSION->sid_ob_rewrite($output);
|
||||
}
|
||||
|
||||
@header('Content-Length: '.strlen($output));
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
global $CFG;
|
||||
require_once "$CFG->libdir/form/select.php";
|
||||
|
||||
/**
|
||||
* HTML class for a drop down element to select groupmode in an activity mod update form
|
||||
*
|
||||
* @author Jamie Pratt
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_modgroupmode extends MoodleQuickForm_select{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string Select name attribute
|
||||
* @param mixed Label(s) for the select
|
||||
* @param mixed Either a typical HTML attribute string or an associative array
|
||||
* @param mixed $options ignored
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function MoodleQuickForm_modgroupmode($elementName=null, $elementLabel=null, $attributes=null, $options=null)
|
||||
{
|
||||
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
|
||||
$this->_type = 'modgroupmode';
|
||||
|
||||
|
||||
} //end constructor
|
||||
|
||||
/**
|
||||
* Called by HTML_QuickForm whenever form event is made on this element
|
||||
*
|
||||
* @param string $event Name of event
|
||||
* @param mixed $arg event arguments
|
||||
* @param object $caller calling object
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
function onQuickFormEvent($event, $arg, &$caller)
|
||||
{
|
||||
switch ($event) {
|
||||
case 'createElement':
|
||||
$choices = array();
|
||||
|
||||
$choices[NOGROUPS] = get_string('groupsnone');
|
||||
$choices[SEPARATEGROUPS] = get_string('groupsseparate');
|
||||
$choices[VISIBLEGROUPS] = get_string('groupsvisible');
|
||||
|
||||
$this->setHelpButton(array('groupmode', get_string('groupmode')));
|
||||
$this->load($choices);
|
||||
break;
|
||||
}
|
||||
return parent::onQuickFormEvent($event, $arg, $caller);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,126 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once("HTML/QuickForm/link.php");
|
||||
|
||||
/**
|
||||
* HTML class for a multiple checkboxes state controller
|
||||
*
|
||||
* @author Nicolas Connault <nicolasconnault@gmail.com>
|
||||
* @version 1.0
|
||||
* @since PHP4.04pl1
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_selectallornone extends HTML_QuickForm_link {
|
||||
/**
|
||||
* The original state of the checkboxes controlled by this element. This determines whether the first click of this element will switch them all to
|
||||
* checked or to unchecked. It doesn't change the checked state of the original elements (there could be a mixed of checked/unchecked there), but
|
||||
* there has to be a decision as to which action will be taken by clicking "select all/select none" the first time.
|
||||
* @var int $originalValue
|
||||
*/
|
||||
var $_originalValue = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param string $elementName The name of the group of advcheckboxes this element controls
|
||||
* @param string $text The text of the link. Defaults to "select all/none"
|
||||
* @param array $attributes associative array of HTML attributes
|
||||
* @param int $originalValue The original general state of the checkboxes before the user first clicks this element
|
||||
*/
|
||||
function MoodleQuickForm_selectallornone($elementName=null, $text=null, $attributes=null, $originalValue=0) {
|
||||
if (is_null($originalValue)) {
|
||||
$originalValue = 0;
|
||||
}
|
||||
|
||||
global $FULLME;
|
||||
$this->_originalValue = $originalValue;
|
||||
|
||||
if (is_null($elementName)) {
|
||||
return;
|
||||
}
|
||||
$elementLabel = ' ';
|
||||
$strselectallornone = get_string('selectallornone', 'form');
|
||||
$attributes['onmouseover'] = "window.status='" . $strselectallornone . "';";
|
||||
$attributes['onmouseout'] = "window.status='';";
|
||||
$attributes['onclick'] = "html_quickform_toggle_checkboxes($elementName); return false;";
|
||||
$select_value = optional_param('select'. $elementName, $originalValue, PARAM_INT);
|
||||
|
||||
if ($select_value == 0) {
|
||||
$new_select_value = 1;
|
||||
} else {
|
||||
$new_select_value = 0;
|
||||
}
|
||||
|
||||
$old_selectstr = "&select$elementName=$select_value";
|
||||
$new_selectstr = "&select$elementName=$new_select_value";
|
||||
$new_fullme = str_replace($old_selectstr, '', $FULLME);
|
||||
|
||||
$href = "$new_fullme$new_selectstr";
|
||||
|
||||
if (empty($text)) {
|
||||
$text = $strselectallornone;
|
||||
}
|
||||
$this->HTML_QuickForm_link($elementName, $elementLabel, $href, $text, $attributes);
|
||||
}
|
||||
|
||||
function toHtml() {
|
||||
if (is_null($this->_originalValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group = $this->_attributes['name'];
|
||||
if ($this->_flagFrozen) {
|
||||
$js = '';
|
||||
} else {
|
||||
$js = "<script type=\"text/javascript\">\n//<![CDATA[\n";
|
||||
if (!defined('HTML_QUICKFORM_SELECTALLORNONE_EXISTS')) {
|
||||
$js .= <<<EOS
|
||||
function html_quickform_toggle_checkboxes(group) {
|
||||
var checkboxes = getElementsByClassName(document, 'input', 'checkboxgroup' + group);
|
||||
var newvalue = false;
|
||||
var global = eval('html_quickform_checkboxgroup' + group + ';');
|
||||
if (global == 1) {
|
||||
eval('html_quickform_checkboxgroup' + group + ' = 0;');
|
||||
newvalue = '';
|
||||
} else {
|
||||
eval('html_quickform_checkboxgroup' + group + ' = 1;');
|
||||
newvalue = 'checked';
|
||||
}
|
||||
|
||||
for (i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = newvalue;
|
||||
}
|
||||
}
|
||||
EOS;
|
||||
define('HTML_QUICKFORM_SELECTALLORNONE_EXISTS', true);
|
||||
}
|
||||
$js .= "var html_quickform_checkboxgroup$group=$this->_originalValue;";
|
||||
|
||||
$js .= "//]]>\n</script>";
|
||||
}
|
||||
return $js . parent::toHtml();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,125 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class grade_lib_wrapper {
|
||||
/*
|
||||
function get_records_sql($sql, $limitfrom='', $limitnum='') {
|
||||
return get_records_sql($sql, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
return get_records_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
return get_recordset($table, $field, $value, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_recordset_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
return get_recordset_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
|
||||
return get_recordset_sql($sql, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') {
|
||||
return get_record($table, $field1, $value1, $field2, $value2, $field3, $value3, $fields);
|
||||
}
|
||||
|
||||
function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
return get_records($table, $field, $value, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
return get_records_list($table, $field, $values, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
|
||||
return get_field($table, $return, $field1, $value1, $field2, $value2, $field3, $value3);
|
||||
}
|
||||
|
||||
function get_field_sql($sql) {
|
||||
return get_field_sql($sql);
|
||||
}
|
||||
|
||||
function get_field_select($table, $return, $select) {
|
||||
return get_field_select($table, $return, $select);
|
||||
}
|
||||
|
||||
function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
|
||||
return set_field($table, $newfield, $newvalue, $field1, $value1, $field2, $value2, $field3, $value3);
|
||||
}
|
||||
|
||||
function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
|
||||
return set_field_select($table, $newfield, $newvalue, $select, $localcall);
|
||||
}
|
||||
|
||||
function rs_fetch_next_record(&$rs) {
|
||||
return rs_fetch_next_record($rs);
|
||||
}
|
||||
|
||||
function execute_sql($command, $feedback=true) {
|
||||
return execute_sql($command, $feedback);
|
||||
}
|
||||
|
||||
function update_record($table, $dataobject) {
|
||||
return update_record($table, $dataobject);
|
||||
}
|
||||
|
||||
function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
|
||||
return insert_record($table, $dataobject, $returnid, $primarykey);
|
||||
}
|
||||
|
||||
function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
||||
return delete_records($table, $field1, $value1, $field2, $value2, $field3, $value3);
|
||||
}
|
||||
|
||||
function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
||||
return count_records($table, $field1, $value1, $field2, $value2, $field3, $value3);
|
||||
}
|
||||
|
||||
function count_records_sql($sql) {
|
||||
return count_records_sql($sql);
|
||||
}
|
||||
|
||||
function rs_close(&$rs) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
function get_coursemodule_from_instance($modulename, $instance, $courseid=0) {
|
||||
return get_coursemodule_from_instance($modulename, $instance, $courseid);
|
||||
}
|
||||
|
||||
function course_scale_used($courseid, $scaleid) {
|
||||
return course_scale_used($courseid, $scaleid);
|
||||
}
|
||||
|
||||
function site_scale_used($scaleid,&$courses) {
|
||||
return site_scale_used($scaleid, $courses);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
/// Searches modules, filters and blocks for any Javascript files
|
||||
/// that should be called on every page
|
||||
|
||||
$nomoodlecookie = true;
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
|
||||
include('../config.php');
|
||||
|
||||
|
@ -1,540 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'Console/Getopt.php';
|
||||
|
||||
$GLOBALS['_System_temp_files'] = array();
|
||||
|
||||
/**
|
||||
* System offers cross plattform compatible system functions
|
||||
*
|
||||
* Static functions for different operations. Should work under
|
||||
* Unix and Windows. The names and usage has been taken from its respectively
|
||||
* GNU commands. The functions will return (bool) false on error and will
|
||||
* trigger the error with the PHP trigger_error() function (you can silence
|
||||
* the error by prefixing a '@' sign after the function call).
|
||||
*
|
||||
* Documentation on this class you can find in:
|
||||
* http://pear.php.net/manual/
|
||||
*
|
||||
* Example usage:
|
||||
* if (!@System::rm('-r file1 dir1')) {
|
||||
* print "could not delete file1 or dir1";
|
||||
* }
|
||||
*
|
||||
* In case you need to to pass file names with spaces,
|
||||
* pass the params as an array:
|
||||
*
|
||||
* System::rm(array('-r', $file1, $dir1));
|
||||
*
|
||||
* @package System
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @version $Revision$
|
||||
* @access public
|
||||
* @see http://pear.php.net/manual/
|
||||
*/
|
||||
class System
|
||||
{
|
||||
/**
|
||||
* returns the commandline arguments of a function
|
||||
*
|
||||
* @param string $argv the commandline
|
||||
* @param string $short_options the allowed option short-tags
|
||||
* @param string $long_options the allowed option long-tags
|
||||
* @return array the given options and there values
|
||||
* @access private
|
||||
*/
|
||||
function _parseArgs($argv, $short_options, $long_options = null)
|
||||
{
|
||||
if (!is_array($argv) && $argv !== null) {
|
||||
$argv = preg_split('/\s+/', $argv);
|
||||
}
|
||||
return Console_Getopt::getopt2($argv, $short_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output errors with PHP trigger_error(). You can silence the errors
|
||||
* with prefixing a "@" sign to the function call: @System::mkdir(..);
|
||||
*
|
||||
* @param mixed $error a PEAR error or a string with the error message
|
||||
* @return bool false
|
||||
* @access private
|
||||
*/
|
||||
function raiseError($error)
|
||||
{
|
||||
if (PEAR::isError($error)) {
|
||||
$error = $error->getMessage();
|
||||
}
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory
|
||||
*
|
||||
* System::_dirToStruct('dir1', 0) =>
|
||||
* Array
|
||||
* (
|
||||
* [dirs] => Array
|
||||
* (
|
||||
* [0] => dir1
|
||||
* )
|
||||
*
|
||||
* [files] => Array
|
||||
* (
|
||||
* [0] => dir1/file2
|
||||
* [1] => dir1/file3
|
||||
* )
|
||||
* )
|
||||
* @param string $sPath Name of the directory
|
||||
* @param integer $maxinst max. deep of the lookup
|
||||
* @param integer $aktinst starting deep of the lookup
|
||||
* @return array the structure of the dir
|
||||
* @access private
|
||||
*/
|
||||
|
||||
function _dirToStruct($sPath, $maxinst, $aktinst = 0)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
if (($dir = @opendir($sPath)) === false) {
|
||||
System::raiseError("Could not open dir $sPath");
|
||||
return $struct; // XXX could not open error
|
||||
}
|
||||
$struct['dirs'][] = $sPath; // XXX don't add if '.' or '..' ?
|
||||
$list = array();
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$list[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
sort($list);
|
||||
if ($aktinst < $maxinst || $maxinst == 0) {
|
||||
foreach($list as $val) {
|
||||
$path = $sPath . DIRECTORY_SEPARATOR . $val;
|
||||
if (is_dir($path)) {
|
||||
$tmp = System::_dirToStruct($path, $maxinst, $aktinst+1);
|
||||
$struct = array_merge_recursive($tmp, $struct);
|
||||
} else {
|
||||
$struct['files'][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory and files
|
||||
*
|
||||
* @param array $files Array listing files and dirs
|
||||
* @return array
|
||||
* @see System::_dirToStruct()
|
||||
*/
|
||||
function _multipleToStruct($files)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
settype($files, 'array');
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
$tmp = System::_dirToStruct($file, 0);
|
||||
$struct = array_merge_recursive($tmp, $struct);
|
||||
} else {
|
||||
$struct['files'][] = $file;
|
||||
}
|
||||
}
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rm command for removing files.
|
||||
* Supports multiple files and dirs and also recursive deletes
|
||||
*
|
||||
* @param string $args the arguments for rm
|
||||
* @return mixed PEAR_Error or true for success
|
||||
* @access public
|
||||
*/
|
||||
function rm($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'rf'); // "f" do nothing but like it :-)
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
foreach($opts[0] as $opt) {
|
||||
if ($opt[0] == 'r') {
|
||||
$do_recursive = true;
|
||||
}
|
||||
}
|
||||
$ret = true;
|
||||
if (isset($do_recursive)) {
|
||||
$struct = System::_multipleToStruct($opts[1]);
|
||||
foreach($struct['files'] as $file) {
|
||||
if (!@unlink($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
foreach($struct['dirs'] as $dir) {
|
||||
if (!@rmdir($dir)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($opts[1] as $file) {
|
||||
$delete = (is_dir($file)) ? 'rmdir' : 'unlink';
|
||||
if (!@$delete($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make directories. Note that we use call_user_func('mkdir') to avoid
|
||||
* a problem with ZE2 calling System::mkDir instead of the native PHP func.
|
||||
*
|
||||
* @param string $args the name of the director(y|ies) to create
|
||||
* @return bool True for success
|
||||
* @access public
|
||||
*/
|
||||
function mkDir($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'pm:');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
$mode = 0777; // default mode
|
||||
foreach($opts[0] as $opt) {
|
||||
if ($opt[0] == 'p') {
|
||||
$create_parents = true;
|
||||
} elseif($opt[0] == 'm') {
|
||||
// if the mode is clearly an octal number (starts with 0)
|
||||
// convert it to decimal
|
||||
if (strlen($opt[1]) && $opt[1]{0} == '0') {
|
||||
$opt[1] = octdec($opt[1]);
|
||||
} else {
|
||||
// convert to int
|
||||
$opt[1] += 0;
|
||||
}
|
||||
$mode = $opt[1];
|
||||
}
|
||||
}
|
||||
$ret = true;
|
||||
if (isset($create_parents)) {
|
||||
foreach($opts[1] as $dir) {
|
||||
$dirstack = array();
|
||||
while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) {
|
||||
array_unshift($dirstack, $dir);
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
while ($newdir = array_shift($dirstack)) {
|
||||
if (!call_user_func('mkdir', $newdir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($opts[1] as $dir) {
|
||||
if (!@is_dir($dir) && !call_user_func('mkdir', $dir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate files
|
||||
*
|
||||
* Usage:
|
||||
* 1) $var = System::cat('sample.txt test.txt');
|
||||
* 2) System::cat('sample.txt test.txt > final.txt');
|
||||
* 3) System::cat('sample.txt test.txt >> final.txt');
|
||||
*
|
||||
* Note: as the class use fopen, urls should work also (test that)
|
||||
*
|
||||
* @param string $args the arguments
|
||||
* @return boolean true on success
|
||||
* @access public
|
||||
*/
|
||||
function &cat($args)
|
||||
{
|
||||
$ret = null;
|
||||
$files = array();
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args);
|
||||
}
|
||||
for($i=0; $i < count($args); $i++) {
|
||||
if ($args[$i] == '>') {
|
||||
$mode = 'wb';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} elseif ($args[$i] == '>>') {
|
||||
$mode = 'ab+';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} else {
|
||||
$files[] = $args[$i];
|
||||
}
|
||||
}
|
||||
if (isset($mode)) {
|
||||
if (!$outputfd = fopen($outputfile, $mode)) {
|
||||
$err = System::raiseError("Could not open $outputfile");
|
||||
return $err;
|
||||
}
|
||||
$ret = true;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if (!$fd = fopen($file, 'r')) {
|
||||
System::raiseError("Could not open $file");
|
||||
continue;
|
||||
}
|
||||
while ($cont = fread($fd, 2048)) {
|
||||
if (isset($outputfd)) {
|
||||
fwrite($outputfd, $cont);
|
||||
} else {
|
||||
$ret .= $cont;
|
||||
}
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
if (@is_resource($outputfd)) {
|
||||
fclose($outputfd);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates temporary files or directories. This function will remove
|
||||
* the created files when the scripts finish its execution.
|
||||
*
|
||||
* Usage:
|
||||
* 1) $tempfile = System::mktemp("prefix");
|
||||
* 2) $tempdir = System::mktemp("-d prefix");
|
||||
* 3) $tempfile = System::mktemp();
|
||||
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
|
||||
*
|
||||
* prefix -> The string that will be prepended to the temp name
|
||||
* (defaults to "tmp").
|
||||
* -d -> A temporary dir will be created instead of a file.
|
||||
* -t -> The target dir where the temporary (file|dir) will be created. If
|
||||
* this param is missing by default the env vars TMP on Windows or
|
||||
* TMPDIR in Unix will be used. If these vars are also missing
|
||||
* c:\windows\temp or /tmp will be used.
|
||||
*
|
||||
* @param string $args The arguments
|
||||
* @return mixed the full path of the created (file|dir) or false
|
||||
* @see System::tmpdir()
|
||||
* @access public
|
||||
*/
|
||||
function mktemp($args = null)
|
||||
{
|
||||
static $first_time = true;
|
||||
$opts = System::_parseArgs($args, 't:d');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
foreach($opts[0] as $opt) {
|
||||
if($opt[0] == 'd') {
|
||||
$tmp_is_dir = true;
|
||||
} elseif($opt[0] == 't') {
|
||||
$tmpdir = $opt[1];
|
||||
}
|
||||
}
|
||||
$prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp';
|
||||
if (!isset($tmpdir)) {
|
||||
$tmpdir = System::tmpdir();
|
||||
}
|
||||
if (!System::mkDir("-p $tmpdir")) {
|
||||
return false;
|
||||
}
|
||||
$tmp = tempnam($tmpdir, $prefix);
|
||||
if (isset($tmp_is_dir)) {
|
||||
unlink($tmp); // be careful possible race condition here
|
||||
if (!call_user_func('mkdir', $tmp, 0700)) {
|
||||
return System::raiseError("Unable to create temporary directory $tmpdir");
|
||||
}
|
||||
}
|
||||
$GLOBALS['_System_temp_files'][] = $tmp;
|
||||
if ($first_time) {
|
||||
PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
|
||||
$first_time = false;
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove temporary files created my mkTemp. This function is executed
|
||||
* at script shutdown time
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _removeTmpFiles()
|
||||
{
|
||||
if (count($GLOBALS['_System_temp_files'])) {
|
||||
$delete = $GLOBALS['_System_temp_files'];
|
||||
array_unshift($delete, '-r');
|
||||
System::rm($delete);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the temporal directory set in the system
|
||||
* by looking in its environments variables.
|
||||
* Note: php.ini-recommended removes the "E" from the variables_order setting,
|
||||
* making unavaible the $_ENV array, that s why we do tests with _ENV
|
||||
*
|
||||
* @return string The temporal directory on the system
|
||||
*/
|
||||
function tmpdir()
|
||||
{
|
||||
if (OS_WINDOWS) {
|
||||
if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
|
||||
return $var;
|
||||
}
|
||||
return getenv('SystemRoot') . '\temp';
|
||||
}
|
||||
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
|
||||
return $var;
|
||||
}
|
||||
return '/tmp';
|
||||
}
|
||||
|
||||
/**
|
||||
* The "which" command (show the full path of a command)
|
||||
*
|
||||
* @param string $program The command to search for
|
||||
* @return mixed A string with the full path or false if not found
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
*/
|
||||
function which($program, $fallback = false)
|
||||
{
|
||||
// is_executable() is not available on windows
|
||||
if (OS_WINDOWS) {
|
||||
$pear_is_executable = 'is_file';
|
||||
} else {
|
||||
$pear_is_executable = 'is_executable';
|
||||
}
|
||||
|
||||
// full path given
|
||||
if (basename($program) != $program) {
|
||||
return (@$pear_is_executable($program)) ? $program : $fallback;
|
||||
}
|
||||
|
||||
// XXX FIXME honor safe mode
|
||||
$path_delim = OS_WINDOWS ? ';' : ':';
|
||||
$exe_suffixes = OS_WINDOWS ? array('.exe','.bat','.cmd','.com') : array('');
|
||||
$path_elements = explode($path_delim, getenv('PATH'));
|
||||
foreach ($exe_suffixes as $suff) {
|
||||
foreach ($path_elements as $dir) {
|
||||
$file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
|
||||
if (@is_file($file) && @$pear_is_executable($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "find" command
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* System::find($dir);
|
||||
* System::find("$dir -type d");
|
||||
* System::find("$dir -type f");
|
||||
* System::find("$dir -name *.php");
|
||||
* System::find("$dir -name *.php -name *.htm*");
|
||||
* System::find("$dir -maxdepth 1");
|
||||
*
|
||||
* Params implmented:
|
||||
* $dir -> Start the search at this directory
|
||||
* -type d -> return only directories
|
||||
* -type f -> return only files
|
||||
* -maxdepth <n> -> max depth of recursion
|
||||
* -name <pattern> -> search pattern (bash style). Multiple -name param allowed
|
||||
*
|
||||
* @param mixed Either array or string with the command line
|
||||
* @return array Array of found files
|
||||
*
|
||||
*/
|
||||
function find($args)
|
||||
{
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$dir = array_shift($args);
|
||||
$patterns = array();
|
||||
$depth = 0;
|
||||
$do_files = $do_dirs = true;
|
||||
for ($i = 0; $i < count($args); $i++) {
|
||||
switch ($args[$i]) {
|
||||
case '-type':
|
||||
if (in_array($args[$i+1], array('d', 'f'))) {
|
||||
if ($args[$i+1] == 'd') {
|
||||
$do_files = false;
|
||||
} else {
|
||||
$do_dirs = false;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
break;
|
||||
case '-name':
|
||||
$patterns[] = "(" . preg_replace(array('/\./', '/\*/'),
|
||||
array('\.', '.*'),
|
||||
$args[$i+1])
|
||||
. ")";
|
||||
$i++;
|
||||
break;
|
||||
case '-maxdepth':
|
||||
$depth = $args[$i+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$path = System::_dirToStruct($dir, $depth);
|
||||
if ($do_files && $do_dirs) {
|
||||
$files = array_merge($path['files'], $path['dirs']);
|
||||
} elseif ($do_dirs) {
|
||||
$files = $path['dirs'];
|
||||
} else {
|
||||
$files = $path['files'];
|
||||
}
|
||||
if (count($patterns)) {
|
||||
$patterns = implode('|', $patterns);
|
||||
$ret = array();
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
if (preg_match("#^$patterns\$#", $files[$i])) {
|
||||
$ret[] = $files[$i];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
?>
|
@ -6,17 +6,10 @@
|
||||
/// set a new variable, and after that it will try to find it again.
|
||||
/// The random number is just to prevent browser caching.
|
||||
|
||||
session_start();
|
||||
require '../config.php';
|
||||
|
||||
if (!isset($_SESSION["test"])) { // First time you call it.
|
||||
echo "<p>No session found - starting a session now.";
|
||||
$_SESSION["test"] = "welcome back!";
|
||||
error('session test not reimplemented yet');
|
||||
|
||||
} else { // Subsequent times you call it
|
||||
echo "<p>Session found - ".$_SESSION["test"];
|
||||
echo "</p><p>Sessions are working correctly</p>";
|
||||
}
|
||||
|
||||
echo "<p><a href=\"session-test.php?random=".rand(1,10000)."\">Reload this page</a></p>";
|
||||
//TODO: add code that actually tests moodle sessions, the old one only tested PHP sessions used from installer, not the real moodle sessions
|
||||
|
||||
?>
|
||||
|
162
lib/setup.php
@ -44,7 +44,7 @@ global $CFG;
|
||||
* @global object(session) $SESSION
|
||||
*/
|
||||
global $SESSION;
|
||||
/**
|
||||
/**
|
||||
* Definition of shared memory cache
|
||||
*/
|
||||
global $MCACHE;
|
||||
@ -70,8 +70,8 @@ global $DB;
|
||||
global $THEME;
|
||||
|
||||
/**
|
||||
* HTTPSPAGEREQUIRED is a global to define if the page being displayed must run under HTTPS.
|
||||
*
|
||||
* HTTPSPAGEREQUIRED is a global to define if the page being displayed must run under HTTPS.
|
||||
*
|
||||
* It's primary goal is to allow 100% HTTPS pages when $CFG->loginhttps is enabled. Default to false.
|
||||
* It's enabled only by the httpsrequired() function and used in some pages to update some URLs
|
||||
*/
|
||||
@ -100,9 +100,9 @@ global $HTTPSPAGEREQUIRED;
|
||||
|
||||
require_once($CFG->libdir .'/setuplib.php'); // Functions that MUST be loaded first
|
||||
|
||||
/// Time to start counting
|
||||
init_performance_info();
|
||||
|
||||
/// Time to start counting
|
||||
init_performance_info();
|
||||
|
||||
|
||||
/// If there are any errors in the standard libraries we want to know!
|
||||
error_reporting(E_ALL);
|
||||
@ -110,7 +110,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
/// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
|
||||
/// http://www.google.com/webmasters/faq.html#prefetchblock
|
||||
if (!empty($_SERVER['HTTP_X_moz']) && $_SERVER['HTTP_X_moz'] === 'prefetch'){
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Prefetch Forbidden');
|
||||
trigger_error('Prefetch request forbidden.');
|
||||
exit;
|
||||
}
|
||||
@ -133,6 +133,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
require_once($CFG->libdir .'/moodlelib.php'); // Other general-purpose functions
|
||||
require_once($CFG->libdir .'/eventslib.php'); // Events functions
|
||||
require_once($CFG->libdir .'/grouplib.php'); // Groups functions
|
||||
require_once($CFG->libdir .'/sessionlib.php'); // All session and cookie related stuff
|
||||
|
||||
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
|
||||
//the problem is that we need specific version of quickforms and hacked excel files :-(
|
||||
@ -207,7 +208,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
$CFG->debug = $originaldatabasedebug;
|
||||
}
|
||||
if ($originalconfigdebug !== -1) {
|
||||
$CFG->debug = $originalconfigdebug;
|
||||
$CFG->debug = $originalconfigdebug;
|
||||
}
|
||||
unset($originalconfigdebug);
|
||||
unset($originaldatabasedebug);
|
||||
@ -265,7 +266,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
if (!init_eaccelerator()) {
|
||||
debugging("Error initialising eaccelerator cache");
|
||||
$CFG->cachetype = '';
|
||||
$CFG->rcache = false;
|
||||
$CFG->rcache = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,69 +310,13 @@ global $HTTPSPAGEREQUIRED;
|
||||
make_upload_directory('cache');
|
||||
}
|
||||
|
||||
/// Set up smarty template system
|
||||
//require_once($CFG->libdir .'/smarty/Smarty.class.php');
|
||||
//$smarty = new Smarty;
|
||||
//$smarty->template_dir = $CFG->dirroot .'/templates/'. $CFG->template;
|
||||
//if (!file_exists($CFG->dataroot .'/cache/smarty')) {
|
||||
// make_upload_directory('cache/smarty');
|
||||
//}
|
||||
//$smarty->compile_dir = $CFG->dataroot .'/cache/smarty';
|
||||
|
||||
/// Set up session handling
|
||||
if(empty($CFG->respectsessionsettings)) {
|
||||
if (empty($CFG->dbsessions)) { /// File-based sessions
|
||||
|
||||
// Some distros disable GC by setting probability to 0
|
||||
// overriding the PHP default of 1
|
||||
// (gc_probability is divided by gc_divisor, which defaults to 1000)
|
||||
if (ini_get('session.gc_probability') == 0) {
|
||||
ini_set('session.gc_probability', 1);
|
||||
}
|
||||
|
||||
if (!empty($CFG->sessiontimeout)) {
|
||||
ini_set('session.gc_maxlifetime', $CFG->sessiontimeout);
|
||||
}
|
||||
|
||||
if (!file_exists($CFG->dataroot .'/sessions')) {
|
||||
make_upload_directory('sessions');
|
||||
}
|
||||
ini_set('session.save_path', $CFG->dataroot .'/sessions');
|
||||
|
||||
} else { /// Database sessions
|
||||
ini_set('session.save_handler', 'user');
|
||||
|
||||
$ADODB_SESSION_DRIVER = $CFG->dbtype;
|
||||
$ADODB_SESSION_CONNECT = $CFG->dbhost;
|
||||
$ADODB_SESSION_USER = $CFG->dbuser;
|
||||
$ADODB_SESSION_PWD = $CFG->dbpass;
|
||||
$ADODB_SESSION_DB = $CFG->dbname;
|
||||
$ADODB_SESSION_TBL = $CFG->prefix.'sessions2';
|
||||
if (!empty($CFG->sessiontimeout)) {
|
||||
$ADODB_SESS_LIFE = $CFG->sessiontimeout;
|
||||
}
|
||||
|
||||
require_once($CFG->libdir. '/adodb/session/adodb-session2.php');
|
||||
}
|
||||
}
|
||||
/// Set sessioncookie and sessioncookiepath variable if it isn't already
|
||||
if (!isset($CFG->sessioncookie)) {
|
||||
$CFG->sessioncookie = '';
|
||||
}
|
||||
if (!isset($CFG->sessioncookiepath)) {
|
||||
$CFG->sessioncookiepath = '/';
|
||||
}
|
||||
|
||||
/// Configure ampersands in URLs
|
||||
|
||||
@ini_set('arg_separator.output', '&');
|
||||
|
||||
/// Work around for a PHP bug see MDL-11237
|
||||
|
||||
@ini_set('pcre.backtrack_limit', 20971520); // 20 MB
|
||||
@ini_set('pcre.backtrack_limit', 20971520); // 20 MB
|
||||
|
||||
/// Location of standard files
|
||||
|
||||
$CFG->wordlist = $CFG->libdir .'/wordlist.txt';
|
||||
$CFG->javascript = $CFG->libdir .'/javascript.php';
|
||||
$CFG->moddata = 'moddata';
|
||||
@ -415,60 +360,13 @@ global $HTTPSPAGEREQUIRED;
|
||||
}
|
||||
}
|
||||
|
||||
/// Load up global environment variables
|
||||
/// start session and prepare global $SESSION
|
||||
$SESSION = new moodle_session();
|
||||
|
||||
if (!isset($CFG->cookiesecure) or strpos($CFG->wwwroot, 'https://') !== 0) {
|
||||
$CFG->cookiesecure = false;
|
||||
}
|
||||
|
||||
if (!isset($CFG->cookiehttponly)) {
|
||||
$CFG->cookiehttponly = false;
|
||||
}
|
||||
|
||||
//discard session ID from POST, GET and globals to tighten security,
|
||||
//this session fixation prevention can not be used in cookieless mode
|
||||
if (empty($CFG->usesid) && !defined('MOODLE_SANE_INPUT')) {
|
||||
unset(${'MoodleSession'.$CFG->sessioncookie});
|
||||
unset($_GET['MoodleSession'.$CFG->sessioncookie]);
|
||||
unset($_POST['MoodleSession'.$CFG->sessioncookie]);
|
||||
}
|
||||
//compatibility hack for Moodle Cron, cookies not deleted, but set to "deleted" - should not be needed with $nomoodlecookie in cron.php now
|
||||
if (!empty($_COOKIE['MoodleSession'.$CFG->sessioncookie]) && $_COOKIE['MoodleSession'.$CFG->sessioncookie] == "deleted") {
|
||||
unset($_COOKIE['MoodleSession'.$CFG->sessioncookie]);
|
||||
}
|
||||
if (!empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie]) && $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] == "deleted") {
|
||||
unset($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie]);
|
||||
}
|
||||
if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
|
||||
require_once("$CFG->dirroot/lib/cookieless.php");
|
||||
sid_start_ob();
|
||||
}
|
||||
|
||||
if (empty($nomoodlecookie)) {
|
||||
session_name('MoodleSession'.$CFG->sessioncookie);
|
||||
session_set_cookie_params(0, $CFG->sessioncookiepath, '', $CFG->cookiesecure, $CFG->cookiehttponly);
|
||||
@session_start();
|
||||
if (! isset($_SESSION['SESSION'])) {
|
||||
$_SESSION['SESSION'] = new object;
|
||||
$_SESSION['SESSION']->session_test = random_string(10);
|
||||
if (!empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) {
|
||||
$_SESSION['SESSION']->has_timed_out = true;
|
||||
}
|
||||
setcookie('MoodleSessionTest'.$CFG->sessioncookie, $_SESSION['SESSION']->session_test, 0, $CFG->sessioncookiepath, '', $CFG->cookiesecure, $CFG->cookiehttponly);
|
||||
$_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] = $_SESSION['SESSION']->session_test;
|
||||
}
|
||||
if (! isset($_SESSION['USER'])) {
|
||||
$_SESSION['USER'] = new object;
|
||||
}
|
||||
|
||||
$SESSION = &$_SESSION['SESSION']; // Makes them easier to reference
|
||||
$USER = &$_SESSION['USER'];
|
||||
if (!isset($USER->id)) {
|
||||
$USER->id = 0; // to enable proper function of $CFG->notloggedinroleid hack
|
||||
}
|
||||
}
|
||||
else {
|
||||
$SESSION = NULL;
|
||||
/// set up global $USER
|
||||
if (!NO_MOODLE_COOKIES) {
|
||||
$USER = &$_SESSION['USER'];
|
||||
} else {
|
||||
$USER = new object();
|
||||
$USER->id = 0; // user not logged in when session disabled
|
||||
if (isset($CFG->mnet_localhost_id)) {
|
||||
@ -490,7 +388,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
$CFG->themedir = $CFG->dirroot.'/theme';
|
||||
$CFG->themewww = $CFG->wwwroot.'/theme';
|
||||
}
|
||||
$CFG->httpsthemewww = $CFG->themewww;
|
||||
$CFG->httpsthemewww = $CFG->themewww;
|
||||
|
||||
if (isset($_GET['theme'])) {
|
||||
if ($CFG->allowthemechangeonurl || confirm_sesskey()) {
|
||||
@ -507,27 +405,17 @@ global $HTTPSPAGEREQUIRED;
|
||||
}
|
||||
|
||||
/// now do a session test to prevent random user switching - observed on some PHP/Apache combinations,
|
||||
/// disable checks when working in cookieless mode
|
||||
if (empty($CFG->usesid) || !empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
|
||||
if ($SESSION != NULL) {
|
||||
if (empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) {
|
||||
report_session_error();
|
||||
} else if (isset($SESSION->session_test) && $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] != $SESSION->session_test) {
|
||||
report_session_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$SESSION->session_verify();
|
||||
|
||||
/// Set language/locale of printed times. If user has chosen a language that
|
||||
/// that is different from the site language, then use the locale specified
|
||||
/// in the language file. Otherwise, if the admin hasn't specified a locale
|
||||
/// then use the one from the default language. Otherwise (and this is the
|
||||
/// majority of cases), use the stored locale specified by admin.
|
||||
if ($SESSION !== NULL && isset($_GET['lang']) && ($lang = clean_param($_GET['lang'], PARAM_SAFEDIR))) {
|
||||
if (isset($_GET['lang']) && ($lang = clean_param($_GET['lang'], PARAM_SAFEDIR))) {
|
||||
if (file_exists($CFG->dataroot .'/lang/'. $lang) or file_exists($CFG->dirroot .'/lang/'. $lang)) {
|
||||
$SESSION->lang = $lang;
|
||||
} else if (file_exists($CFG->dataroot.'/lang/'.$lang.'_utf8') or
|
||||
} else if (file_exists($CFG->dataroot.'/lang/'.$lang.'_utf8') or
|
||||
file_exists($CFG->dirroot .'/lang/'.$lang.'_utf8')) {
|
||||
$SESSION->lang = $lang.'_utf8';
|
||||
}
|
||||
@ -544,12 +432,12 @@ global $HTTPSPAGEREQUIRED;
|
||||
$CFG->lang = $SESSION->lang;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set default locale and themes - might be changed again later from require_login()
|
||||
course_setup();
|
||||
|
||||
if (!empty($CFG->opentogoogle)) {
|
||||
if (empty($USER->id)) { // Ignore anyone logged in
|
||||
if (!NO_MOODLE_COOKIES and empty($USER->id)) { // Ignore anyone logged in, or scripts without cookies
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
||||
$USER = guest_user();
|
||||
@ -570,14 +458,14 @@ global $HTTPSPAGEREQUIRED;
|
||||
$USER = guest_user();
|
||||
}
|
||||
}
|
||||
if (!empty($USER)) {
|
||||
if (!empty($USER->id)) {
|
||||
load_all_capabilities();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') { // Temporary measure to help with XHTML validation
|
||||
if (isset($_SERVER['HTTP_USER_AGENT']) and empty($_SESSION['USER']->id)) { // Allow W3CValidator in as user called w3cvalidator (or guest)
|
||||
if (isset($_SERVER['HTTP_USER_AGENT']) and empty($USER->id)) { // Allow W3CValidator in as user called w3cvalidator (or guest)
|
||||
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) or
|
||||
(strpos($_SERVER['HTTP_USER_AGENT'], 'Cynthia') !== false )) {
|
||||
if ($USER = get_complete_user_data("username", "w3cvalidator")) {
|
||||
|
@ -1,345 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit tests for (some of) ../datalib.php.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package moodlecore
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/simpletestlib/web_tester.php');
|
||||
require_once($CFG->libdir . '/dmllib.php');
|
||||
|
||||
class datalib_test extends prefix_changing_test_case {
|
||||
var $table = 'table';
|
||||
var $data = array(
|
||||
array('id', 'textfield', 'numberfield'),
|
||||
array( 1, 'frog', 101),
|
||||
array( 2, 'toad', 102),
|
||||
array( 3, 'tadpole', 103),
|
||||
array( 4, 'tadpole', 104),
|
||||
array( 5, 'nothing', NULL),
|
||||
);
|
||||
var $objects = array();
|
||||
|
||||
function setUp() {
|
||||
global $CFG, $db;
|
||||
parent::setUp();
|
||||
load_test_table($CFG->prefix . $this->table, $this->data, $db);
|
||||
$keys = reset($this->data);
|
||||
foreach ($this->data as $row=>$datum) {
|
||||
if ($row == 0) {
|
||||
continue;
|
||||
}
|
||||
$this->objects[$datum[0]] = (object) array_combine($keys, $datum);
|
||||
}
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
global $CFG, $db;
|
||||
remove_test_table($CFG->prefix . $this->table, $db);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function test_where_clause() {
|
||||
$this->assertEqual(where_clause('f1', 'v1'), "WHERE f1 = 'v1'");
|
||||
$this->assertEqual(where_clause('f1', 'v1', 'f2', 2), "WHERE f1 = 'v1' AND f2 = '2'");
|
||||
$this->assertEqual(where_clause('f1', 'v1', 'f2', 1.75, 'f3', 'v3'), "WHERE f1 = 'v1' AND f2 = '1.75' AND f3 = 'v3'");
|
||||
$this->assertEqual(where_clause('f1', NULL), "WHERE f1 IS NULL");
|
||||
}
|
||||
|
||||
function test_record_exists() {
|
||||
$this->assertTrue(record_exists($this->table, 'numberfield', 101, 'id', 1));
|
||||
$this->assertFalse(record_exists($this->table, 'numberfield', 102, 'id', 1));
|
||||
$this->assertTrue(record_exists($this->table, 'numberfield', NULL));
|
||||
}
|
||||
|
||||
function test_record_exists_select() {
|
||||
$this->assertTrue(record_exists_select($this->table, 'numberfield = 101 AND id = 1'));
|
||||
$this->assertFalse(record_exists_select($this->table, 'numberfield = 102 AND id = 1'));
|
||||
$this->assertTrue(record_exists_select($this->table, 'numberfield IS NULL'));
|
||||
}
|
||||
|
||||
function test_record_exists_sql() {
|
||||
global $CFG;
|
||||
$this->assertTrue(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield = 101 AND id = 1"));
|
||||
$this->assertFalse(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield = 102 AND id = 1"));
|
||||
$this->assertTrue(record_exists_sql("SELECT * FROM {$CFG->prefix}$this->table WHERE numberfield IS NULL"));
|
||||
}
|
||||
|
||||
|
||||
function test_get_record() {
|
||||
// Get particular records.
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($this->objects[1]), get_record($this->table, 'id', 1));
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($this->objects[3]), get_record($this->table, 'textfield', 'tadpole', 'numberfield', 103));
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($this->objects[5]), get_record($this->table, 'numberfield', null));
|
||||
|
||||
// Abiguous get attempt, should return one, and print a warning in debug mode.
|
||||
global $CFG;
|
||||
$old_debug = $CFG->debug;
|
||||
$CFG->debug = 0;
|
||||
|
||||
ob_start();
|
||||
$record = get_record($this->table, 'textfield', 'tadpole');
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertEqual('', $result, '%s (No error ouside debug mode).');
|
||||
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
ob_start();
|
||||
$record = get_record($this->table, 'textfield', 'tadpole');
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
|
||||
|
||||
$CFG->debug = $old_debug;
|
||||
|
||||
// Return only specified fields
|
||||
$expected = new stdClass;
|
||||
$expected->id = 3;
|
||||
$expected->textfield = 'tadpole';
|
||||
$result = get_record($this->table, 'id', '3', '', '', '', '', 'id,textfield');
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
|
||||
$this->assertFalse(isset($result->numberfield));
|
||||
$expected = new stdClass;
|
||||
$expected->textfield = 'tadpole';
|
||||
$expected->numberfield = 103;
|
||||
$result = get_record($this->table, 'id', '3', '', '', '', '', 'textfield,numberfield');
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
|
||||
$this->assertFalse(isset($result->id));
|
||||
|
||||
// Attempting to get a non-existant records should return false.
|
||||
$this->assertFalse(get_record($this->table, 'textfield', 'not there'), 'attempt to get non-existant record');
|
||||
}
|
||||
|
||||
function test_get_record_sql() {
|
||||
global $CFG;
|
||||
// Get particular records.
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($this->objects[1]), get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE id = '1'", 'id = 1'));
|
||||
|
||||
// Abiguous get attempt, should return one, and print a warning in debug mode, unless $expectmultiple is used.
|
||||
$old_debug = $CFG->debug;
|
||||
$CFG->debug = 0;
|
||||
|
||||
ob_start();
|
||||
$record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'");
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertEqual('', $result, '%s (No error ouside debug mode).');
|
||||
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
ob_start();
|
||||
$record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'");
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
|
||||
|
||||
ob_start();
|
||||
$record = get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'tadpole'", true);
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertEqual('', $result, '%s (No error ouside debug mode).');
|
||||
|
||||
$CFG->debug = $old_debug;
|
||||
|
||||
// Attempting to get a non-existant records should return false.
|
||||
$this->assertFalse(get_record_sql("SELECT * FROM {$CFG->prefix}" . $this->table . " WHERE textfield = 'not there'"), 'attempt to get non-existant record');
|
||||
}
|
||||
|
||||
function test_get_record_select() {
|
||||
// Get particular records.
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($this->objects[2]), get_record_select($this->table, 'id > 1 AND id < 3'), 'id > 1 AND id < 3');
|
||||
|
||||
// Abiguous get attempt, should return one, and print a warning in debug mode.
|
||||
global $CFG;
|
||||
$old_debug = $CFG->debug;
|
||||
$CFG->debug = 0;
|
||||
|
||||
ob_start();
|
||||
$record = get_record_select($this->table, "textfield = 'tadpole'");
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertEqual('', $result, '%s (No error ouside debug mode).');
|
||||
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
ob_start();
|
||||
$record = get_record_select($this->table, "textfield = 'tadpole'");
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assert(new TextExpectation('Error:'), $result, 'Error in debug mode.');
|
||||
|
||||
$CFG->debug = $old_debug;
|
||||
|
||||
// Return only specified fields
|
||||
$expected = new stdClass;
|
||||
$expected->id = 1;
|
||||
$expected->textfield = 'frog';
|
||||
$result = get_record_select($this->table, "textfield = 'frog'", 'id,textfield');
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($expected), $result);
|
||||
$this->assertFalse(isset($result->numberfield));
|
||||
|
||||
// Attempting to get a non-existant records should return false.
|
||||
$this->assertFalse(get_record_select($this->table, 'id > 666'), 'attempt to get non-existant record');
|
||||
}
|
||||
|
||||
function test_get_field() {
|
||||
$this->assertEqual(get_field($this->table, 'numberfield', 'id', 1), 101);
|
||||
$this->assertEqual(get_field($this->table, 'textfield', 'numberfield', 102), 'toad');
|
||||
$this->assertEqual(get_field($this->table, 'numberfield', 'textfield', 'tadpole', 'id', 4), 104);
|
||||
$this->assertEqual(get_field($this->table, 'numberfield + id', 'textfield', 'tadpole', 'id', 4), 108);
|
||||
$this->assertNull(get_field($this->table, 'numberfield', 'id', 5));
|
||||
}
|
||||
|
||||
function test_get_field_select() {
|
||||
$this->assertEqual(get_field_select($this->table, 'numberfield', 'id = 1'), 101);
|
||||
}
|
||||
|
||||
function test_get_field_sql() {
|
||||
global $CFG;
|
||||
$this->assertEqual(get_field_sql("SELECT numberfield FROM {$CFG->prefix}$this->table WHERE id = 1"), 101);
|
||||
}
|
||||
|
||||
function test_set_field() {
|
||||
set_field($this->table, 'numberfield', 12345, 'id', 1);
|
||||
$this->assertEqual(get_field($this->table, 'numberfield', 'id', 1), 12345);
|
||||
|
||||
set_field($this->table, 'textfield', 'newvalue', 'numberfield', 102);
|
||||
$this->assertEqual(get_field($this->table, 'textfield', 'numberfield', 102), 'newvalue');
|
||||
|
||||
set_field($this->table, 'numberfield', -1, 'textfield', 'tadpole', 'id', 4);
|
||||
$this->assertEqual(get_field($this->table, 'numberfield', 'textfield', 'tadpole', 'id', 4), -1);
|
||||
|
||||
set_field($this->table, 'textfield', null, 'id', 5);
|
||||
$this->assertNull(get_field($this->table, 'textfield', 'id', 5));
|
||||
}
|
||||
|
||||
function test_delete_records() {
|
||||
delete_records($this->table, 'id', 666);
|
||||
$this->assertEqual(count_records($this->table), 5);
|
||||
delete_records($this->table, 'id', 1);
|
||||
$this->assertEqual(count_records($this->table), 4);
|
||||
delete_records($this->table, 'textfield', 'tadpole');
|
||||
$this->assertEqual(count_records($this->table), 2);
|
||||
delete_records($this->table, 'numberfield', NULL);
|
||||
$this->assertEqual(count_records($this->table), 1);
|
||||
}
|
||||
|
||||
function test_delete_records2() {
|
||||
delete_records($this->table, 'textfield', 'tadpole', 'id', 4);
|
||||
$this->assertEqual(count_records($this->table), 4);
|
||||
delete_records($this->table);
|
||||
$this->assertEqual(count_records($this->table), 0);
|
||||
}
|
||||
|
||||
function test_delete_records_select() {
|
||||
delete_records_select($this->table, "textfield LIKE 't%'");
|
||||
$this->assertEqual(count_records($this->table), 2);
|
||||
delete_records_select($this->table, "'1' = '1'");
|
||||
$this->assertEqual(count_records($this->table), 0);
|
||||
}
|
||||
|
||||
function test_update_record() {
|
||||
global $CFG;
|
||||
|
||||
// Simple update
|
||||
$obj = new stdClass;
|
||||
$obj->id = 1;
|
||||
$obj->textfield = 'changed entry';
|
||||
$obj->numberfield = 123;
|
||||
$this->assertTrue(update_record($this->table, $obj));
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Simple incomplete update
|
||||
$obj = new stdClass;
|
||||
$obj->id = 2;
|
||||
$obj->numberfield = 123;
|
||||
$this->assertTrue(update_record($this->table, $obj));
|
||||
$obj->textfield = 'toad';
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Simple incomplete update
|
||||
$obj = new stdClass;
|
||||
$obj->id = 3;
|
||||
$obj->numberfield = 123;
|
||||
$obj->textfield = null;
|
||||
$this->assertTrue(update_record($this->table, $obj));
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple update (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
}
|
||||
|
||||
//function insert_record($table, $dataobject, $returnid=true, $primarykey='id', $feedback=true) {
|
||||
function test_insert_record() {
|
||||
global $CFG;
|
||||
|
||||
// Simple insert with $returnid
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'new entry';
|
||||
$obj->numberfield = 123;
|
||||
$this->assertEqual(insert_record($this->table, $obj), 6);
|
||||
$obj->id = 6;
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert with returnid (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Simple insert without $returnid
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'newer entry';
|
||||
$obj->numberfield = 321;
|
||||
$this->assertEqual(insert_record($this->table, $obj, false), true);
|
||||
$obj->id = 7;
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert without returnid (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Insert with missing columns - should get defaults.
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'partial entry';
|
||||
$this->assertEqual(insert_record($this->table, $obj), 8);
|
||||
$obj->id = 8;
|
||||
$obj->numberfield = 0xDefa;
|
||||
$got = get_record($this->table, 'id', 8);
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Insert with missing columns - should get defaults (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Insert with extra columns - should be ingnored.
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'entry with extra';
|
||||
$obj->numberfield = 747;
|
||||
$obj->unused = 666;
|
||||
$this->assertEqual(insert_record($this->table, $obj), 9);
|
||||
$obj->id = 9;
|
||||
unset($obj->unused);
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Insert with extra columns - should be ingnored (%s)'), get_record($this->table, 'id', $obj->id));
|
||||
|
||||
// Simple insert with $returnid and NULL values
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = null;
|
||||
$obj->numberfield = null;
|
||||
$this->assertEqual(insert_record($this->table, $obj), 10);
|
||||
$obj->id = 10;
|
||||
$new = get_record($this->table, 'id', $obj->id);
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($obj, 'Simple insert with returnid (%s)'), $new);
|
||||
$this->assertNull($new->textfield);
|
||||
$this->assertNull($new->numberfield);
|
||||
|
||||
// Insert into nonexistant table - should fail.
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'new entry';
|
||||
$obj->numberfield = 123;
|
||||
$this->assertFalse(insert_record('nonexistant_table', $obj), 'Insert into nonexistant table');
|
||||
|
||||
// Insert bad data - error should be printed - mysql not tested
|
||||
if ($CFG->dbfamily != 'mysql') {
|
||||
$obj = new stdClass;
|
||||
$obj->textfield = 'new entry';
|
||||
$obj->numberfield = 'not a number';
|
||||
ob_start();
|
||||
$this->assertFalse(insert_record($this->table, $obj), 'Insert bad data - should fail.');
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assert(new TextExpectation('ERROR:'), $result, 'Insert bad data - error should have been printed. This is known not to work on MySQL.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|