cvsimport fixups

This commit is contained in:
Martin Langhoff 2007-07-07 14:18:30 +12:00
parent 99a1bf3d9c
commit 08103c9364
205 changed files with 306 additions and 21666 deletions

View File

@ -501,19 +501,7 @@
/// Check if the guest user exists. If not, create one.
if (! record_exists("user", "username", "guest")) {
$guest->auth = "manual";
$guest->username = "guest";
$guest->password = md5("guest");
$guest->firstname = addslashes(get_string("guestuser"));
$guest->lastname = " ";
$guest->email = "root@localhost";
$guest->description = addslashes(get_string("guestuserinfo"));
$guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified= time();
if (! $guest->id = insert_record("user", $guest)) {
if (! $guest = create_guest_record()) {
notify("Could not create guest user record !!!");
}
}

View File

@ -1,91 +0,0 @@
AUTHENTICATION PLUGINS
----------------------
Each authentication plugin is now contained in a subfolder as a class definition
in the auth.php file. For instance, the LDAP authentication plugin is the class
called auth_plugin_ldap defined in:
/auth/ldap/auth.php
To instantiate the class, there is a function in lib/moodlelib called
get_auth_plugin() that does the work for you:
$ldapauth = get_auth_plugin('ldap');
Auth plugin classes are pretty basic. They contain the same functions that were
previously in each plugin's lib.php file, but refactored to become class
methods, and tweaked to reference the plugin's instantiated config to get at the
settings, rather than the global $CFG variable.
Configuration
-----------------
All auth plugins must have a config property that contains the name value pairs
from the config_plugins table. This is populated using the get_config() function
in the constructor. The settings keys have also had the "auth_" prefix, as well
as the auth plugin name, trimmed. For instance, what used to be
echo $CFG->auth_ldapversion;
is now accessed as
echo $ldapauth->config->version;
Authentication settings have been moved to the config_plugins database table,
with the plugin field set to "auth/foo" (for instance, "auth/ldap").
Method Names
-----------------
When the functions from lib.php were ported to methods in auth.php, the "auth_"
prefix was dropped. For instance, calls to
auth_user_login($user, $pass);
now become
$ldapauth->user_login($user, $pass);
this also avoids having to worry about which auth/lib file to include since
Moodle takes care of it for you when you create an instance with
get_auth_plugin().
Code Use
-----------------
Code calling auth plugins can use method_exists() to determine plugin
functionality, much in the same way that function_exists() was used until now.
In addition, auth plugins provide some methods by default that can be called:
user_login($username, $password)
This is the primary method that is used by the authenticate_user_login()
function in moodlelib.php. This method should return a boolean indicating
whether or not the username and password authenticate successfully.
Both parameter must have magic quotes applied.
is_internal()
Returns true if this authentication plugin is "internal" (which means that
Moodle stores the users' passwords and other details in the local Moodle
database).
can_change_password()
Returns true if the plugin can change the users' passwords.
change_password_url()
Returns the URL for changing the users' passwords, or false if the default
URL can be used.
Other Methods
-----------------
get_userinfo($username)
This method should return an array of fields from the authentication source
for the given username. Username parameter must have magic quotes applied.
The returned array does not have magic quotes applied.
Upgrading from Moodle 1.7
-----------------------------
Moodle will upgrade the old auth settings (in $CFG->auth_foobar where foo is the
auth plugin and bar is the setting) to the new style in the config_plugin
database table.

View File

@ -1,48 +0,0 @@
<?php
/** auth_ldap_sync_users.php
* Modified for cas Module
*
* This script is meant to be called from a cronjob to sync moodle with the LDAP
* backend in those setups where the LDAP backend acts as 'master'.
*
* Recommended cron entry:
* # 5 minutes past 4am
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
*
* Notes:
* - If you have a large number of users, you may want to raise the memory limits
* by passing -d momory_limit=256M
* - For debugging & better logging, you are encouraged to use in the command line:
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
*
* Performance notes:
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
* we have seen this take 10 minutes.
*
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
error_log("should not be called from web server!");
exit;
}
$nomoodlecookie = true; // cookie not needed
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/lib/blocklib.php');
require_once($CFG->dirroot.'/mod/resource/lib.php');
require_once($CFG->dirroot.'/mod/forum/lib.php');
require_once($CFG->dirroot.'/lib/moodlelib.php');
if (!is_enabled_auth('cas')) {
echo "Plugin not enabled!";
die;
}
$casauth = get_auth_plugin('cas');
$casauth->sync_users(1000, true);
?>

View File

@ -1,8 +0,0 @@
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center" style="font-size: small">
<tr>
<td width="50%" class="required" class="headingblock">
<p align="center"><b><font size="3"><?php formerr($errormsg) ?></font></b></p>
</td>
</tr>
</table>

View File

@ -1,18 +0,0 @@
<?php
// version $Id$
// Page for forbidden access from CAS
require("../../config.php");
if (!$site = get_site()) {
print_error('nosite', '', '', NULL, true);
}
$loginsite = get_string("loginsite");
$errormsg = get_string("auth_cas_invalidcaslogin", "auth");
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite);
include("forbidden.html");
print_footer();
exit;
?>

View File

@ -1,85 +0,0 @@
<table width="90%" border="0" cellspacing="10" cellpadding="5" >
<tr>
<?php if ($show_instructions) { ?>
<td width="50%" class="headingblock">
<p><b><?php print_string("returningtosite") ?></b></p>
</td>
<td width="50%" class="headingblock">
<p><b><?php print_string("firsttime") ?></b></p>
</td>
<?php } ?>
</tr>
<tr>
<td width="50%" align="center" valign="top" class="generalbox">
<p><?php print_string("loginusing") ?>:<br />
(<?php print_string("cookiesenabled");?>)
<?php helpbutton("cookies", get_string("cookiesenabled"))?><br /><?php formerr($errormsg) ?>
</p>
<form action="index.php" method="post" id="login">
<div>
<table border="0" style="font-size: small">
<tr>
<td width="100%">
<input type="hidden" name="username" id="username" value="cas" />
<input type="hidden" name="password" id="password" value="cas" />
<input type="submit" value="<?php print_string("auth_cas_logincas", "auth") ?>" />
</td>
</tr>
</table>
</div>
</form>
<?php if ($CFG->guestloginbutton) { ?>
<hr width="80%" />
<p><?php print_string("someallowguest") ?>:</p>
<form action="index.php" method="post" id="guestlogin">
<div>
<input type="hidden" name="username" value="guest" />
<input type="hidden" name="password" value="guest" />
<input type="submit" value="<?php print_string("loginguest") ?>" />
</div>
</form>
<?php } ?>
<?php if (is_internal_auth() ) {
$changepassword = "forgot_password.php";
$changebuttonname = get_string("senddetails");
?>
<hr width="80%" />
<p><?php print_string("forgotten") ?></p>
<form action="<?php p($changepassword) ?>" method="get" id="changepassword">
<div><input type="submit" value="<?php p($changebuttonname) ?>" /></div>
</form>
<?php } ?>
</td>
<?php if ($show_instructions) { ?>
<td width="50%" valign="top" class="generalbox">
<?php switch ($CFG->auth) {
case "email":
print_string("loginsteps", "", "signup.php");
?>
<form action="signup.php" method="get" id="signup">
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
</form>
<?php break;
case "none":
print_string("loginstepsnone");
break;
default:
$authplugin = get_auth_plugin($CFG->auth);
echo format_text($CFG->auth_instructions);
if (!empty($authplugin->config->user_create) and method_exists($authplugin, 'user_create')) {
?>
<form action="signup.php" method="get" id="signup">
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
</form>
<?php }
}
?>
</td></tr>
<?php } ?>
</table>

View File

@ -1,313 +0,0 @@
<?php
// $Id$
// author: romualdLorthioir $
//CHANGELOG:
//05.03.2005 replace /login/index.php
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
//Define variables used in page
if (!$site = get_site()) {
print_error('nosite', '', '', NULL, true);
}
if (empty($CFG->langmenu)) {
$langmenu = "";
} else {
$currlang = current_language();
$langs = get_list_of_languages();
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {
$wwwroot = str_replace('http:','https:',$CFG->wwwroot);
}
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
}
$loginsite = get_string("loginsite");
$casauth = get_auth_plugin('cas');
$ldapauth = get_auth_plugin('ldap');
$frm = false;
$user = false;
if ((!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl,'username=guest')) or $loginguest) {
/// Log in as guest automatically (idea from Zbigniew Fiedorowicz)
$frm->username = 'guest';
$frm->password = 'guest';
} else if (!empty($SESSION->wantsurl) && file_exists($CFG->dirroot.'/login/weblinkauth.php')) {
// Handles the case of another Moodle site linking into a page on this site
include($CFG->dirroot.'/login/weblinkauth.php');
if (function_exists(weblink_auth)) {
$user = weblink_auth($SESSION->wantsurl);
}
if ($user) {
$frm->username = $user->username;
} else {
$frm = data_submitted();
}
} else {
$frm = data_submitted();
}
if ($frm and (get_moodle_cookie() == '')) { // Login without cookie
$errormsg = get_string("cookiesnotenabled");
} else if ($frm) { // Login WITH cookies
$frm->username = trim(moodle_strtolower($frm->username));
if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) {
$user = false; /// Can't log in as guest if guest button is disabled
$frm = false;
} else if (!$user) {
if ($CFG->auth == "cas" && $frm->username != 'guest') { /// Cas SSO case
$user = $casauth->authenticate_user_login($frm->username, $frm->password);
}else{
$user = authenticate_user_login($frm->username, $frm->password);
}
}
update_login_count();
if ($user) {
if (! $user->confirmed ) { // they never confirmed via email
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
print_heading(get_string("mustconfirm"));
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
print_footer();
die;
}
$USER = $user;
if (!empty($USER->description)) {
$USER->description = true; // No need to cart all of it around
}
$USER->loggedin = true;
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
sesskey(); // for added security, used to check script parameters
if ($USER->username == "guest") {
$USER->lang = $CFG->lang; // Guest language always same as site
$USER->firstname = get_string("guestuser"); // Name always in current language
$USER->lastname = " ";
}
if (!update_user_login_times()) {
error("Wierd error: could not update login records");
}
set_moodle_cookie($USER->username);
unset($SESSION->lang);
$SESSION->justloggedin = true;
// Restore the calendar filters, if saved
if (intval(get_user_preferences('calendar_persistflt', 0))) {
include_once($CFG->dirroot.'/calendar/lib.php');
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
}
//Select password change url
$userauth = get_auth_plugin($USER->auth);
if (method_exists($userauth, 'can_change_password') and $userauth->can_change_password()) {
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
}
// check whether the user should be changing password
if (get_user_preferences('auth_forcepasswordchange', false)) {
if (isset($passwordchangeurl)) {
redirect($passwordchangeurl);
} else {
print_error('auth_cas_broken_password','auth');
}
}
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
if (user_not_fully_set_up($USER)) {
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.SITEID;
// We don't delete $SESSION->wantsurl yet, so we get there later
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
unset($SESSION->wantsurl);
} else {
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
unset($SESSION->wantsurl); /// Just in case
}
// check if user password has expired
// Currently supported only for ldap-authentication module
if ($ldapauth->config->expiration == 1) {
$days2expire = $ldapauth->password_expire($USER->username);
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
print_footer();
exit;
} elseif (intval($days2expire) < 0 ) {
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
print_footer();
exit;
}
}
reset_login_count();
load_all_capabilities(); /// This is what lets the user do anything on the site :-)
redirect($urltogo);
exit;
} else {
if ($CFG->auth == "cas" ) { /// CAS error login
$errormsg = get_string("invalidcaslogin");
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
}else{
$errormsg = get_string("invalidlogin");
}
}
}
$user = $casauth->automatic_authenticate($user);
if ($user) {
if (! $user->confirmed ) { // they never confirmed via email
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
print_heading(get_string("mustconfirm"));
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
print_footer();
die;
}
$USER = $user;
if (!empty($USER->description)) {
$USER->description = true; // No need to cart all of it around
}
$USER->loggedin = true;
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
sesskey(); // for added security, used to check script parameters
if ($USER->username == "guest") {
$USER->lang = $CFG->lang; // Guest language always same as site
$USER->firstname = get_string("guestuser"); // Name always in current language
$USER->lastname = " ";
}
if (!update_user_login_times()) {
error("Wierd error: could not update login records");
}
set_moodle_cookie($USER->username);
unset($SESSION->lang);
$SESSION->justloggedin = true;
// Restore the calendar filters, if saved
if (intval(get_user_preferences('calendar_persistflt', 0))) {
include_once($CFG->dirroot.'/calendar/lib.php');
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
}
//Select password change url
$userauth = get_auth_plugin($USER->auth);
if (method_exists($userauth, 'can_change_password') and $userauth->can_change_password()) {
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
}
// check whether the user should be changing password
if (get_user_preferences('auth_forcepasswordchange', false)) {
if (isset($passwordchangeurl)) {
redirect($passwordchangeurl);
} else {
print_error('auth_cas_broken_password','auth');
}
}
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
if (user_not_fully_set_up($USER)) {
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.SITEID;
// We don't delete $SESSION->wantsurl yet, so we get there later
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
unset($SESSION->wantsurl);
} else {
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
unset($SESSION->wantsurl); /// Just in case
}
// check if user password has expired
// Currently supported only for ldap-authentication module
if ($ldapauth->config->expiration == 1) {
$days2expire = $ldapauth->password_expire($USER->username);
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
print_footer();
exit;
} elseif (intval($days2expire) < 0 ) {
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div class=\"langmenu\">$langmenu</div>");
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
print_footer();
exit;
}
}
reset_login_count();
load_all_capabilities(); /// This is what lets the user do anything on the site :-)
redirect($urltogo);
exit;
} else {
if (!$CFG->guestloginbutton) {
$errormsg = get_string("invalidcaslogin");
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
}
}
if (empty($errormsg)) {
$errormsg = "";
}
if (empty($SESSION->wantsurl)) {
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot.'/';
}
if (get_moodle_cookie() == '') {
set_moodle_cookie('nobody'); // To help search for cookies
}
if (empty($frm->username)) {
$frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
$frm->password = "";
}
if (!empty($frm->username)) {
$focus = "login.password";
} else {
$focus = "login.username";
}
if ($CFG->auth == "email" or $CFG->auth == "none" or chop($CFG->auth_instructions) <> "" ) {
$show_instructions = true;
} else {
$show_instructions = false;
}
print_header("$site->fullname: $loginsite", $site->fullname, $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
include($CFG->dirroot.'/auth/cas/index_form.html');
print_footer();
exit;
// No footer on this page
?>

View File

@ -1,15 +0,0 @@
<?php
// $Id$
// logout the user from CAS server (destroy the ticket)
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
global $CFG;
if ($CFG->cas_logout) {
require_once($CFG->dirroot.'/config.php');
include_once($CFG->dirroot.'/lib/cas/CAS.php');
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(int)$CFG->cas_port,$CFG->cas_baseuri);
$backurl = $CFG->wwwroot;
phpCAS::logout($backurl);
}
?>

View File

@ -1,7 +1,7 @@
<?php
/**
* @author Martin Dougiamas
* @author Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodle multiauth
*
@ -19,7 +19,7 @@ if (!defined('MOODLE_INTERNAL')) {
require_once($CFG->libdir.'/authlib.php');
/**
* Plugin for no authentication.
* Plugin for no authentication - disabled user.
*/
class auth_plugin_nologin extends auth_plugin_base {
@ -32,10 +32,10 @@ class auth_plugin_nologin extends auth_plugin_base {
}
/**
* Do not allow any login
* Do not allow any login.
*
*/
function user_login ($username, $password) {
function user_login($username, $password) {
return false;
}
@ -47,18 +47,17 @@ class auth_plugin_nologin extends auth_plugin_base {
}
/**
* Returns true if this authentication plugin is 'internal'.
* No external data sync.
*
* @return bool
*/
function is_internal() {
//we do not know if it was internal or external originally
return false;
return true;
}
/**
* Returns true if this authentication plugin can change the user's
* password.
* No changing of password.
*
* @return bool
*/
@ -67,21 +66,10 @@ class auth_plugin_nologin extends auth_plugin_base {
}
/**
* Prints a form for configuring this authentication plugin.
*
* This function is called from admin/auth.php, and outputs a full page with
* a form for configuring this plugin.
*
* @param array $page An object containing all the data for this page.
* No password resetting.
*/
function config_form($config, $err, $user_fields) {
}
/**
* Processes and stores configuration data for this authentication plugin.
*/
function process_config($config) {
return true;
function can_reset_password() {
return false;
}
}

View File

@ -1,75 +0,0 @@
#
# Table structure for table `prefix_backup_files`
#
CREATE TABLE `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 `backup_files_uk` (`backup_code`,`file_type`,`path`)
) TYPE=MyISAM COMMENT='To store and recode ids to user and course files.';
# --------------------------------------------------------
#
# Table structure for table `prefix_backup_ids`
#
CREATE TABLE `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 NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `backup_ids_uk` (`backup_code` ,`table_name`,`old_id`)
) TYPE=MyISAM COMMENT='To store and convert ids in backup/restore';
# --------------------------------------------------------
#
# Table structure for table `prefix_backup_config`
#
CREATE TABLE `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';
# --------------------------------------------------------
#
# Table structure for table `prefix_backup_courses`
#
CREATE TABLE `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';
# --------------------------------------------------------
#
# Table structure for table `prefix_backup_log`
#
CREATE TABLE `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';
# --------------------------------------------------------

View File

@ -1,67 +0,0 @@
#
# Table structure for table prefix_backup_files
#
CREATE TABLE 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 prefix_backup_files_uk UNIQUE (backup_code, file_type, path)
);
#
# Table structure for table prefix_backup_ids
#
CREATE TABLE 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 prefix_backup_ids_uk UNIQUE (backup_code, table_name, old_id)
);
#
# Table structure for table prefix_backup_config
#
CREATE TABLE prefix_backup_config (
id SERIAL PRIMARY KEY,
name varchar(255) UNIQUE NOT NULL default '',
value varchar(255) NOT NULL default ''
);
#
# Table structure for table prefix_backup_courses
#
CREATE TABLE prefix_backup_courses (
id SERIAL PRIMARY KEY,
courseid integer UNIQUE NOT NULL default '0',
laststarttime integer NOT NULL default '0',
lastendtime integer NOT NULL default '0',
laststatus varchar(1) NOT NULL default '0',
nextstarttime integer NOT NULL default '0'
);
#
# Table structure for table prefix_backup_log
#
CREATE TABLE prefix_backup_log (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
time integer NOT NULL default '0',
laststarttime integer NOT NULL default '0',
info varchar(255) NOT NULL default ''
);

View File

@ -132,7 +132,7 @@ class block_blog_tags extends block_base {
case BLOG_GROUP_LEVEL:
$filtertype = 'group';
$filterselect = get_current_group($this->instance->pageid);
$filterselect = get_and_set_current_group($COURSE, groupmode($COURSE));
break;
case BLOG_COURSE_LEVEL:

View File

@ -1,45 +0,0 @@
# $Id$
#
# Table structure for table `blocks`
#
CREATE TABLE `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`)
) TYPE=MyISAM;
CREATE TABLE `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(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`),
INDEX pageid(`pageid`),
INDEX pagetype(`pagetype`)
) TYPE=MyISAM;
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`),
INDEX pagetype(`pagetype`)
) TYPE=MyISAM;
# --------------------------------------------------------

View File

@ -1,41 +0,0 @@
# $Id$
#
# Table structure for table blocks
#
CREATE TABLE 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'
) ;
CREATE TABLE prefix_block_instance (
id SERIAL8 PRIMARY KEY,
blockid INT8 not null default '0',
pageid 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 ''
) ;
CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid);
CREATE INDEX prefix_block_instance_pagetype_idx ON prefix_block_instance (pagetype);
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
) ;
CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);
# --------------------------------------------------------

View File

@ -29,46 +29,29 @@ class block_news_items extends block_base {
$text = '';
if (!$forum = forum_get_course_forum($COURSE->id, 'news')) {
return $this->content;
return '';
}
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
return '';
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// First work out whether we can post to this group and if so, include a link
$groupmode = groupmode($COURSE, $cm);
$currentgroup = get_and_set_current_group($COURSE, $groupmode);
if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { /// Teachers can always post
$visiblegroups = -1;
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$text .= '<div class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
get_string('addanewtopic', 'forum').'</a>...</div>';
} else { /// Check the group situation
$currentgroup = get_current_group($COURSE->id);
if (forum_user_can_post_discussion($forum, $currentgroup)) {
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
get_string('addanewtopic', 'forum').'</a>...</div>';
}
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
$this->content->text = $text;
return $this->content;
}
$groupmode = groupmode($COURSE, $cm);
/// Decides if current user is allowed to see ALL the current discussions or not
if (!$currentgroup and ($groupmode != SEPARATEGROUPS) ) {
$visiblegroups = -1;
} else {
$visiblegroups = $currentgroup;
}
}
/// Get all the recent discussions we're allowed to see
if (! $discussions = forum_get_discussions($forum->id, 'p.modified DESC', 0, false,
$visiblegroups, $COURSE->newsitems) ) {
$currentgroup, $COURSE->newsitems) ) {
$text .= '('.get_string('nonews', 'forum').')';
$this->content->text = $text;
return $this->content;

View File

@ -43,7 +43,7 @@ class block_online_users extends block_base {
&& !has_capability('moodle/site:accessallgroups', $context));
//Get the user current group
$currentgroup = $isseparategroups ? get_current_group($COURSE->id) : NULL;
$currentgroup = $isseparategroups ? get_and_set_current_group($COURSE, groupmode($COURSE)) : NULL;
$groupmembers = "";
$groupselect = "";
@ -51,7 +51,7 @@ class block_online_users extends block_base {
//Add this to the SQL to show only group users
if ($currentgroup !== NULL) {
$groupmembers = ', '.groups_members_from_sql(); //TODO: ", {$CFG->prefix}groups_members gm ";
$groupselect .= groups_members_where_sql($currentgroup, 'u.id'); //" AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
$groupselect = ' AND '.groups_members_where_sql($currentgroup, 'u.id'); //" AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
}
if ($COURSE->id == SITEID) { // Site-level

View File

@ -1,23 +0,0 @@
# $Id$
# This file contains a complete database schema for all the
# tables used by this module, written in SQL
# It may also contain INSERT statements for particular data
# that may be used, especially new entries in the table log_display
# --------------------------------------------------------
#
# Table structure for table `prefix_block_rss_client`
#
CREATE TABLE prefix_block_rss_client (
`id` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`title` text NOT NULL default '',
`preferredtitle` varchar(64) NOT NULL default '',
`description` text NOT NULL default '',
`shared` int(2) NOT NULL default '0',
`url` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Remote news feed information. Contains the news feed id, the userid of the user who added the feed, the title of the feed itself and a description of the feed contents along with the url used to access the remote feed. Preferredtitle is a field for future use - intended to allow for custom titles rather than those found in the feed.';

View File

@ -1,20 +0,0 @@
# $Id$
# This file contains a complete database schema for all the
# tables used by this module, written in SQL
# It may also contain INSERT statements for particular data
# that may be used, especially new entries in the table log_display
#
# Table structure for table `block_rss_client`
#
CREATE TABLE prefix_block_rss_client (
id SERIAL PRIMARY KEY,
userid INTEGER NOT NULL default '0',
title text NOT NULL default '',
preferredtitle varchar(64) NOT NULL default '',
description text NOT NULL default '',
shared INTEGER NOT NULL default '0',
url varchar(255) NOT NULL default ''
);

View File

@ -22,11 +22,8 @@
$stractivityreport = get_string("activityreport");
/// Check to see if groups are being used in this course
if ($groupmode = groupmode($course)) { // Groups are being used
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
} else {
$currentgroup = false;
}
$groupmode = groupmode($course);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
/// Get a list of all students
if ($currentgroup) {
@ -308,7 +305,6 @@
$options["download"] = "xls";
print_single_button("grades.php", $options, get_string("downloadexcel"));
echo "<td>";
$options = array();
$options["download"] = "txt";
print_single_button("grades.php", $options, get_string("downloadtext"));
echo "</table>";

View File

@ -1,63 +0,0 @@
<form method="post" enctype="multipart/form-data" action="group.php">
<table cellpadding="9" cellspacing="0" align="center">
<tr valign="top">
<td align="right"><?php print_string("name") ?>:</td>
<td><input type="text" name="name" size="30" value="<?php p($group->name) ?>" />
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><?php print_string("description") ?>:<br />
<?php helpbutton("text", get_string("helptext")) ?>
</td>
<td><?php
print_textarea($usehtmleditor, 8, 35, 660, 200, "description", $group->description);
if (isset($err["description"])) formerr($err["description"]);
?>
</td>
</tr>
<tr valign="top">
<td align="right"><?php print_string('enrolmentkey') ?>:</td>
<td><input type="text" name="password" size="25" value="<?php echo $group->password ?>" alt="<?php print_string('enrolmentkey') ?>" /></td>
</tr>
<tr valign="top">
<td align="right"><?php print_string("hidepicture") ?>:</td>
<td><?php
$options = NULL;
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "hidepicture", $group->hidepicture, "");
?>
</td>
</tr>
<?php
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
if (!empty($CFG->gdversion) and $maxbytes) {
?>
<tr valign="top">
<td align="right"><?php print_string("newpicture") ?>:<br />(<?php
print_string("maxsize", "", display_size($maxbytes));
echo ') ';
helpbutton("picture", get_string("helppicture"));
?></td>
<td>
<?php
require_once($CFG->dirroot.'/lib/uploadlib.php');
upload_print_form_fragment(1,array('imagefile'),null,false,null,0,0,false);
if (isset($err["imagefile"])) formerr($err["imagefile"]);
?>
</td>
</tr>
<?php } ?>
<tr>
<td></td>
<td><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
</table>
<input type="hidden" name="group" value="<?php p($group->id) ?>" />
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
</form>

View File

@ -1,85 +0,0 @@
<?php // $Id$
/// Shows current group, and allows editing of the group
/// icon and other settings related to that group
/// This script appears within a popup window
require_once('../config.php');
require_once('lib.php');
$id = required_param('id', PARAM_INT); // Course id
$group = optional_param('group', 0, PARAM_INT); // Optionally look at other groups
if (! $course = get_record('course', 'id', $id) ) {
error("That's an invalid course id");
}
require_login($course->id);
if (! $group = get_record("groups", "id", $group, "courseid", $course->id)) {
notice('Specified group could not be found!', "#");
close_window_button();
}
// this is fine since group inherits course settings, this allows 1) teacher to edit all groups
// 2 someone with a role with a cap to modify a specific group
$context = get_context_instance(CONTEXT_GROUP, $group->id);
// this is really weird
if (!has_capability('moodle/course:managegroups', $context)) {
close_window();
}
/// Print the headers of the page
print_header(get_string('groupinfoedit').' : '.$group->name);
/// If data submitted, then process and store.
if ($form = data_submitted() and confirm_sesskey()) {
if (empty($form->name)) {
$err['name'] = get_string("missingname");
} else {
require_once($CFG->dirroot.'/lib/uploadlib.php');
$um = new upload_manager('imagefile',false,false,null,false,0,true,true);
if ($um->preprocess_files()) {
require_once("$CFG->libdir/gdlib.php");
if (save_profile_image($group->id, $um, 'groups')) {
$group->picture = 1;
}
}
// Setting a new object in order to avoid updating other columns for the record,
// which could lead to SQL injection vulnerabilities.
// Be VERY sure to sanitize all parameters that go into $dataobj!
$dataobj = new stdClass;
$dataobj->id = $group->id;
$dataobj->name = clean_text($form->name);
$dataobj->description = clean_text($form->description);
$dataobj->hidepicture = empty($form->hidepicture) ? 0 : 1;
$dataobj->password = required_param('password', PARAM_ALPHANUM);
$dataobj->picture = $group->picture;
if (!update_record('groups', $dataobj)) {
notify("A strange error occurred while trying to save");
} else {
notify(get_string('changessaved'));
}
close_window(3);
}
}
$usehtmleditor = false;
include('group-edit.html');
echo "</body></html>";
?>

View File

@ -1,182 +0,0 @@
<script type="text/javascript">
//<![CDATA[
<?php
$roleoptions = array(0 => get_string('all'));
$roles = get_all_roles();
foreach ($roles as $rolex) {
$roleoptions[$rolex->id] = $rolex->name;
}
foreach ($listmembers as $groupid => $listmember) {
echo "group$groupid = new Object();\n";
$useridstring = "group$groupid.userid = new Array(";
$usernamestring = "group$groupid.username = new Array(";
$max = count($listmember);
$count = 0;
foreach ($listmember as $userid => $username) {
$count++;
$useridstring .= "\"$userid\"";
$usernamestring .= '"'.addslashes($username).'"';
if ($count < $max) {
$useridstring .= ', ';
$usernamestring .= ', ';
}
}
$useridstring .= ");\n";
$usernamestring .= ");\n";
echo $useridstring;
echo $usernamestring;
}
?>
function updateGroup() {
document.getElementById("form1").groupid.value = document.getElementById("form2").groups.value;
document.getElementById("form3").groupid.value = document.getElementById("form2").groups.value;
}
function updateMembers(selectgroup) {
eval('group=group'+selectgroup.value);
username = group.username;
userid = group.userid;
document.getElementById("form3")['members[]'].length = username.length;
for (i=0;i<username.length;i++) {
document.getElementById("form3")['members[]'].options[i].value = userid[i];
document.getElementById("form3")['members[]'].options[i].text = username[i];
}
updateGroup();
}
function userWindow(selectuser) {
num = 0;
for (var i=0; i<selectuser.options.length; i++) {
if (selectuser.options[i].selected) {
num++;
user = selectuser.options[i].value;
openpopup('/user/view.php?id='+user+'&course=<?php echo $courseid ?>','userinfo'+num,'','');
}
}
return false;
}
function groupWindow(selectgroup) {
num = 0;
for (var i=0; i<selectgroup.options.length; i++) {
if (selectgroup.options[i].selected) {
num++;
group = selectgroup.options[i].value;
openpopup('/course/group.php?id=<?php echo $courseid ?>&group='+group,'groupinfo'+num,'menubar=0,directory=0,location=0,scrollbars,resizable,width=600,height=480','');
}
}
return false;
}
//]]>
</script>
<form id="rolesform1" action="groups.php" method="get">
<input type="hidden" name="id" value="<?php echo $courseid ?>" />
<div align="center"><?php echo get_string('currentrole', 'role') ?>:
<?php choose_from_menu ($roleoptions, 'roleid', $roleid, '', 'document.getElementById(\'rolesform1\').submit()') ?>
</div></form>
<table cellspacing="0" cellpadding="10" align="center" class="generaltable generalbox">
<tr align="center" valign="top">
<td class="generalboxcontent">
<label for="nonmembers"><?php p($strmemberincourse) ?></label>
<form id="form1" method="post" action="groups.php">
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
<input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
<select name="nonmembers[]" size="15" id="nonmembers" multiple="multiple">
<?php
if (!empty($nonmembers)) {
foreach ($nonmembers as $id => $nonmembername) {
if (!is_array($ugroups = user_group($course->id, $id))) {
$numgroups = 0;
}
else {
$numgroups = count($ugroups);
}
echo "<option value=\"$id\" title=\"$nonmembername is in $numgroups groups\">$nonmembername ($numgroups)</option>\n";
}
}
?>
</select>
<br />
<input type="submit" name="nonmembersadd" value="<?php p($strgroupaddusers) ?> -&gt;"
onclick="updateGroup()" />
<br />
<!--
<input type="submit" name="nonmembersrandom" value="<?php p($strgrouprandomassign) ?> -&gt;" />
<br /> -->
<input type="submit" name="nonmembersinfo" value="<?php p($strgroupinfopeople) ?>"
onclick="return userWindow(document.getElementById('form1')['nonmembers[]']);" />
</form>
</td>
<td class="generalboxcontent">
<label for="groups"><?php p($strgroups) ?></label>
<form id="form2" method="post" action="groups.php">
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
<select name="groups" size="15" id="groups" onchange="updateMembers(this)">
<?php
if (!empty($listgroups)) {
foreach ($listgroups as $id => $listgroup) {
$selected = '';
if ($id == $selectedgroup) {
$selected = 'selected="selected"';
}
echo "<option $selected value=\"$id\">$listgroup</option>";
}
}
?>
</select>
<br />
<input type="submit" name="groupsinfo" value="<?php p($strgroupinfoedit) ?>"
onclick="return groupWindow(document.getElementById('form2').groups);" />
<br />
<input type="submit" name="groupsremove" value="<?php p($strgroupremove) ?>" />
<br />
<label for="groupadd" class="accesshide"><?php p($strgroupadd) ?></label>
<input name="newgroupname" id="groupadd" type="text" size="10" />
<input type="submit" name="groupsadd" value="<?php p($strgroupadd) ?>" />
</form>
</td>
<td class="generalboxcontent">
<label for="members"><?php p($strgroupmembersselected) ?></label>
<form id="form3" method="post" action="groups.php">
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
<input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
<select name="members[]" size="15" id="members" multiple="multiple">
<?php
if (!empty($members)) {
foreach ($members as $id => $membername) {
echo "<option value=\"$id\">$membername</option>";
}
}
?>
</select>
<br />
<input type="submit" name="membersinfo" value="<?php p($strgroupinfomembers) ?>"
onclick="return userWindow(document.getElementById('form3')['members[]']);" />
<br />
<input type="submit" name="membersremove" value="<?php p($strgroupremovemembers) ?>"
onclick="updateGroup()" />
</form>
</td>
</tr>
</table>

View File

@ -1,230 +0,0 @@
<?php // $Id$
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999-2004 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 //
// //
///////////////////////////////////////////////////////////////////////////
/// Editing interface to edit all the groups in a course
require_once('../config.php');
require_once('lib.php');
$courseid = required_param('id', PARAM_INT); // Course id
$selectedgroup = optional_param('group', NULL, PARAM_INT); // Current group id
$roleid = optional_param('roleid', 0, PARAM_INT); // Current role id
if (! $course = get_record('course', 'id', $courseid) ) {
error("That's an invalid course id");
}
require_login($course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/course:managegroups', $context)) {
redirect("group.php?id=$course->id"); // Not allowed to see all groups
}
/// Get the current list of groups and check the selection is valid
$groups = get_groups($course->id);
if ($selectedgroup and !isset($groups[$selectedgroup])) {
$selectedgroup = NULL;
}
/// Print the header of the page
$strgroup = get_string('group');
$strgroups = get_string('groups');
$streditgroupprofile = get_string('editgroupprofile');
$strgroupmembers = get_string('groupmembers');
$strgroupmemberssee = get_string('groupmemberssee');
$strparticipants = get_string('participants');
print_header("$course->shortname: $strgroups", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> ".
"-> $strgroups", "", "", true, '', user_login_string($course, $USER));
/// First, process any inputs there may be.
if ($data = data_submitted() and confirm_sesskey()) {
// Clean ALL incoming parameters which go in SQL queries here for good measure
$data->id = required_param('id', PARAM_INT);
$data->groups = optional_param('groups', 0, PARAM_INT);
$data->groupid = optional_param('groupid', 0, PARAM_INT);
$data->members = optional_param('members', array(), PARAM_INT);
if (!empty($data->nonmembersadd)) { /// Add people to a group
if (!empty($data->nonmembers) and !empty($data->groupid)) {
$groupmodified = false;
foreach ($data->nonmembers as $userid) {
//since we allow people to be in more than 1 group, this has to go.
if (!ismember($data->groupid,$userid)) {// Just to make sure (another teacher could be editing)
$record->groupid = $data->groupid;
$record->userid = $userid;
$record->timeadded = time();
if (!insert_record('groups_members', $record)) {
notify("Error occurred while adding user $userid to group $data->groupid");
}
$groupmodified = true;
}
}
if ($groupmodified) {
set_field('groups', 'timemodified', time(), 'id', $data->groupid);
}
}
$selectedgroup = $data->groupid;
} else if (!empty($data->nonmembersrandom)) { /// Add all non members to groups
notify("Random adding of people into groups is not functional yet.");
} else if (!empty($data->nonmembersinfo)) { /// Return info about the selected users
notify("You must turn Javascript on");
} else if (!empty($data->groupsremove)) { /// Remove a group, all members become nonmembers
if (!empty($data->groups)) {
if(!isset($groups[$data->groups])) {
error("This is not a valid group to remove");
}
delete_records("groups", "id", $data->groups);
delete_records("groups_members", "groupid", $data->groups);
unset($groups[$data->groups]);
}
} else if (!empty($data->groupsinfo)) { /// Display full info for a group
notify("You must turn Javascript on");
} else if (!empty($data->groupsadd)) { /// Create a new group
if (!empty($data->newgroupname)) {
$newgroup->name = $data->newgroupname;
$newgroup->courseid = $course->id;
$newgroup->lang = current_language();
$newgroup->timecreated = time();
$newgroup->description = ''; // can not be null MDL-7300
if (!insert_record("groups", $newgroup)) {
notify("Could not insert the new group '$newgroup->name'");
}
$groups = get_groups($course->id);
}
} else if (!empty($data->membersremove)) { /// Remove selected people from a particular group
if (!empty($data->members) and !empty($data->groupid)) {
foreach ($data->members as $userid) {
delete_records('groups_members', 'userid', $userid, "groupid", $data->groupid);
}
set_field('groups', 'timemodified', time(), 'id', $data->groupid);
}
$selectedgroup = $data->groupid;
} else if (!empty($data->membersinfo)) { /// Return info about the selected users
notify("You must turn Javascript on");
}
}
/// Calculate data ready to create the editing interface
$strmemberincourse = get_string('memberincourse');
$strgroupnonmembers = get_string('groupnonmembers');
$strgroupmembersselected = get_string('groupmembersselected');
$strgroupremovemembers = get_string('groupremovemembers');
$strgroupinfomembers = get_string('groupinfomembers');
$strgroupadd = get_string('groupadd');
$strgroupremove = get_string('groupremove');
$strgroupinfo = get_string('groupinfo');
$strgroupinfoedit = get_string('groupinfoedit');
$strgroupinfopeople = get_string('groupinfopeople');
$strgrouprandomassign = get_string('grouprandomassign');
$strgroupaddusers = get_string('groupaddusers');
$courseid = $course->id;
$listgroups = array();
$listmembers = array();
$nonmembers = array();
$groupcount = count($groups);
/// First, get everyone into the nonmembers array
if ($contextusers = get_role_users($roleid, $context)) {
foreach ($contextusers as $contextuser) {
$nonmembers[$contextuser->id] = fullname($contextuser, true);
}
}
unset($contextusers);
/// Pull out all the members into little arrays
if ($groups) {
foreach ($groups as $group) {
$countusers = 0;
$listmembers[$group->id] = array();
if ($groupusers = get_group_users($group->id, 'u.lastname ASC, u.firstname ASC')) {
foreach ($groupusers as $key=>$groupuser) {
if (!array_key_exists($groupuser->id, $nonmembers)) {
// group member with another role
unset($groupusers[$key]);
} else {
$listmembers[$group->id][$groupuser->id] = $nonmembers[$groupuser->id];
//we do not remove people from $nonmembers, everyone is displayed
//this is to enable people to be registered in multiple groups
//unset($nonmembers[$groupuser->id]);
$countusers++;
}
}
}
$listgroups[$group->id] = $group->name." ($countusers)";
}
natcasesort($listgroups);
}
if (empty($selectedgroup)) { // Choose the first group by default
if ($selectedgroup = array_shift($temparr = array_keys($listgroups))) {
$members = $listmembers[$selectedgroup];
}
} else {
$members = $listmembers[$selectedgroup];
}
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
//TODO:
if (debugging()) {
echo '<p>[ <a href="../group/index.php?id='. $courseid .'">New groups</a> - debugging. ]</p>';
}
/// Print out the complete form
print_heading(get_string('groups'));
include('groups-edit.html');
print_footer($course);
?>

View File

@ -65,6 +65,7 @@ class moodleform_mod extends moodleform {
$mform =& $this->_form;
$mform->addElement('header', 'modstandardelshdr', get_string('modstandardels', 'form'));
if ($supportsgroups){
// TODO: we must define this as mod property!
$mform->addElement('modgroupmode', 'groupmode', get_string('groupmode'));
}
$mform->addElement('modvisible', 'visible', get_string('visible'));

View File

@ -1,31 +0,0 @@
CREATE TABLE `prefix_enrol_authorize` (
`id` int(10) unsigned NOT NULL auto_increment,
`paymentmethod` enum('cc', 'echeck') NOT NULL default 'cc',
`cclastfour` int(4) unsigned NOT NULL default '0',
`ccname` varchar(255) NOT NULL default '',
`courseid` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`transid` int(10) unsigned NOT NULL default '0',
`status` int(10) unsigned NOT NULL default '0',
`timecreated` int(10) unsigned NOT NULL default '0',
`settletime` int(10) unsigned NOT NULL default '0',
`amount` varchar(10) NOT NULL default '',
`currency` varchar(3) NOT NULL default 'USD',
PRIMARY KEY (`id`),
KEY `courseid` (`courseid`),
KEY `userid` (`userid`),
KEY `status` (`status`),
KEY `transid` (`transid`)
) TYPE=MyISAM COMMENT='Holds all known information about authorize.net transactions';
CREATE TABLE `prefix_enrol_authorize_refunds` (
`id` int(10) unsigned NOT NULL auto_increment,
`orderid` int(10) unsigned NOT NULL default '0',
`status` int(1) unsigned NOT NULL default '0',
`amount` varchar(10) NOT NULL default '',
`transid` int(10) unsigned default '0',
`settletime` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `orderid` (`orderid`),
KEY `transid` (`transid`)
) TYPE=MyISAM COMMENT='Authorize.net refunds';

View File

@ -1,32 +0,0 @@
CREATE TABLE prefix_enrol_authorize (
id SERIAL PRIMARY KEY,
paymentmethod varchar(6) default 'cc' NOT NULL,
cclastfour integer DEFAULT 0 NOT NULL,
ccname varchar(255) DEFAULT '',
courseid integer DEFAULT 0 NOT NULL,
userid integer DEFAULT 0 NOT NULL,
transid integer DEFAULT 0 NOT NULL,
status integer DEFAULT 0 NOT NULL,
timecreated integer DEFAULT 0 NOT NULL,
settletime integer DEFAULT 0 NOT NULL,
amount varchar(10) DEFAULT '0' NOT NULL,
currency varchar(3) DEFAULT 'USD' NOT NULL,
CONSTRAINT enroauth_pay_ck CHECK (paymentmethod IN ('cc', 'echeck'))
);
CREATE INDEX prefix_enrol_authorize_courseid_idx ON prefix_enrol_authorize(courseid);
CREATE INDEX prefix_enrol_authorize_userid_idx ON prefix_enrol_authorize(userid);
CREATE INDEX prefix_enrol_authorize_status_idx ON prefix_enrol_authorize(status);
CREATE INDEX prefix_enrol_authorize_transid_idx ON prefix_enrol_authorize(transid);
CREATE TABLE prefix_enrol_authorize_refunds (
id SERIAL PRIMARY KEY,
orderid integer DEFAULT 0 NOT NULL,
status integer DEFAULT 0 NOT NULL,
amount varchar(10) DEFAULT '' NOT NULL,
transid integer DEFAULT 0,
settletime integer DEFAULT 0 NOT NULL
);
CREATE INDEX prefix_enrol_authorize_refunds_orderid_idx ON prefix_enrol_authorize_refunds(orderid);
CREATE INDEX prefix_enrol_authorize_refunds_transid_idx ON prefix_enrol_authorize_refunds(transid);

View File

@ -1,23 +0,0 @@
CREATE TABLE `prefix_enrol_paypal` (
`id` int(10) unsigned NOT NULL auto_increment,
`business` varchar(255) NOT NULL default '',
`receiver_email` varchar(255) NOT NULL default '',
`receiver_id` varchar(255) NOT NULL default '',
`item_name` varchar(255) NOT NULL default '',
`courseid` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`memo` varchar(255) NOT NULL default '',
`tax` varchar(255) NOT NULL default '',
`option_name1` varchar(255) NOT NULL default '',
`option_selection1_x` varchar(255) NOT NULL default '',
`option_name2` varchar(255) NOT NULL default '',
`option_selection2_x` varchar(255) NOT NULL default '',
`payment_status` varchar(255) NOT NULL default '',
`pending_reason` varchar(255) NOT NULL default '',
`reason_code` varchar(30) NOT NULL default '',
`txn_id` varchar(255) NOT NULL default '',
`parent_txn_id` varchar(255) NOT NULL default '',
`payment_type` varchar(30) NOT NULL default '',
`timeupdated` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Holds all known information about PayPal transactions' ;

View File

@ -1,22 +0,0 @@
CREATE TABLE prefix_enrol_paypal (
id SERIAL PRIMARY KEY,
business varchar(255) NOT NULL default '',
receiver_email varchar(255) NOT NULL default '',
receiver_id varchar(255) NOT NULL default '',
item_name varchar(255) NOT NULL default '',
courseid integer NOT NULL default '0',
userid integer NOT NULL default '0',
memo varchar(255) NOT NULL default '',
tax varchar(255) NOT NULL default '',
option_name1 varchar(255) NOT NULL default '',
option_selection1_x varchar(255) NOT NULL default '',
option_name2 varchar(255) NOT NULL default '',
option_selection2_x varchar(255) NOT NULL default '',
payment_status varchar(255) NOT NULL default '',
pending_reason varchar(255) NOT NULL default '',
reason_code varchar(30) NOT NULL default '',
txn_id varchar(255) NOT NULL default '',
parent_txn_id varchar(255) NOT NULL default '',
payment_type varchar(30) NOT NULL default '',
timeupdated integer NOT NULL default '0'
);

View File

@ -1,117 +0,0 @@
# phpMyAdmin SQL Dump
# version 2.8.1
# http://www.phpmyadmin.net
#
# Host: localhost
# Generation Time: Oct 24, 2006 at 05:23 PM
# Server version: 5.0.21
# PHP Version: 4.4.2-pl1
#
# Database: `moodle`
#
# --------------------------------------------------------
#
# Table structure for table `mdl_groups_courses_groupings`
#
CREATE TABLE `prefix_groups_courses_groupings` (
`id` int(10) unsigned NOT NULL auto_increment,
`courseid` int(10) unsigned NOT NULL default '0',
`groupingid` mediumint(9) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `courseid` (`courseid`)
) ENGINE=MyISAM ;
# --------------------------------------------------------
#
# Table structure for table `prefix_groups_courses_groups`
#
CREATE TABLE `prefix_groups_courses_groups` (
`id` int(10) unsigned NOT NULL auto_increment,
`courseid` int(10) unsigned NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `courseid` (`courseid`)
) ENGINE=MyISAM ;
# --------------------------------------------------------
#
# Table structure for table `prefix_groups_groupings`
#
CREATE TABLE `prefix_groups_groupings` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(254) NOT NULL,
`description` text NOT NULL default '',
`timecreated` int(10) unsigned NOT NULL default '0',
`viewowngroup` tinyint(1) NOT NULL default 1,
`viewallgroupsmembers` tinyint(1) NOT NULL default 0,
`viewallgroupsactivities` tinyint(1) NOT NULL default 0,
`teachersgroupmark` tinyint(1) NOT NULL default 0,
`teachersgroupview` binary(1) NOT NULL default 0,
`teachersoverride` binary(1) NOT NULL default 0,
`teacherdeletable` binary(1) NOT NULL default 0,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM ;
# --------------------------------------------------------
#
# Table structure for table `prefix_groups_groupings_groups`
#
CREATE TABLE `prefix_groups_groupings_groups` (
`id` int(10) unsigned NOT NULL auto_increment,
`groupingid` int(10) unsigned default '0',
`groupid` int(10) NOT NULL default '0',
`timeadded` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `courseid` (`groupingid`)
) ENGINE=MyISAM AUTO_INCREMENT=67 ;
# --------------------------------------------------------
#
# Table structure for table `prefix_groups`
#
CREATE TABLE `prefix_groups` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`description` text NOT NULL default '',
`enrolmentkey` varchar(50) NOT NULL default '',
`lang` varchar(10) NOT NULL default 'en',
`theme` varchar(50) NOT NULL default '',
`picture` int(10) unsigned NOT NULL default '0',
`hidepicture` int(1) unsigned NOT NULL default '0',
`timecreated` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM ;
# --------------------------------------------------------
#
# Table structure for table `prefix_groups_members`
#
CREATE TABLE `prefix_groups_members` (
`id` int(10) unsigned NOT NULL auto_increment,
`groupid` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`timeadded` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `groupid` (`groupid`),
KEY `userid` (`userid`)
) ENGINE=MyISAM ;

View File

@ -1,65 +0,0 @@
CREATE TABLE prefix_groups_courses_groupings (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default 0,
groupingid integer NOT NULL default 0
);
CREATE INDEX prefix_groups_courses_groupings_courseid_idx ON prefix_groups_courses_groupings (courseid);
COMMENT ON TABLE prefix_groups_courses_groupings IS 'New groupings (OU).';
CREATE TABLE prefix_groups_courses_groups (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
groupid integer NOT NULL default '0'
);
CREATE INDEX prefix_groups_courses_groups_courseid_idx ON prefix_groups_courses_groups (courseid);
CREATE TABLE prefix_groups_groupings (
id SERIAL PRIMARY KEY,
name varchar(254) NOT NULL,
description text NOT NULL default '',
timecreated integer NOT NULL default 0,
viewowngroup integer NOT NULL default 1,
viewallgroupsmembers integer NOT NULL default 0,
viewallgroupsactivities integer NOT NULL default 0,
teachersgroupmark integer NOT NULL default 0,
teachersgroupview integer NOT NULL default 0,
teachersoverride integer NOT NULL default 0
);
CREATE TABLE prefix_groups_groupings_groups (
id SERIAL PRIMARY KEY,
groupingid integer NOT NULL default 0,
groupid integer NOT NULL default 0,
timeadded integer NOT NULL default 0
);
CREATE INDEX prefix_groups_groupings_groups_groupingid_idx ON prefix_groups_groupings_groups (groupingid);
CREATE TABLE prefix_groups (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
description text NOT NULL default '',
enrolmentkey varchar(50) NOT NULL default '',
lang varchar(10) NOT NULL default 'en',
theme varchar(50) NOT NULL default '',
picture integer NOT NULL default '0',
hidepicture integer NOT NULL default '0',
timecreated integer NOT NULL default '0',
timemodified integer NOT NULL default '0'
);
CREATE TABLE prefix_groups_members (
id SERIAL PRIMARY KEY,
groupid integer NOT NULL default '0',
userid integer NOT NULL default '0',
timeadded integer NOT NULL default '0'
);
CREATE INDEX prefix_groups_members_groupid_idx ON prefix_groups_members (groupid);
CREATE INDEX prefix_groups_members_userid_idx ON prefix_groups_members (userid);
COMMENT ON TABLE prefix_groups_members IS 'New groupings (OU).';

View File

@ -16,12 +16,17 @@ require_once('lib.php');
require_once('edit_form.php');
/// get url variables
$courseid = required_param('courseid', PARAM_INT);
$id = optional_param('id', false, PARAM_INT);
$groupingid = optional_param('grouping', false, PARAM_INT);
$newgrouping = optional_param('newgrouping', false, PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$delete = optional_param('delete', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$delete = optional_param('delete', false, PARAM_BOOL);
if (empty($CFG->enablegroupings)) {
// NO GROUPINGS YET!
$groupingid = GROUP_NOT_IN_GROUPING;
}
/// Course must be valid
if (!$course = get_record('course', 'id', $courseid)) {
@ -33,6 +38,18 @@ if ($delete && !$id) {
error(get_string('errorinvalidgroup'));
}
if ($delete && !$confirm) {
print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group'));
$optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1);
$optionsno = array('id'=>$courseid);
if (!$group = get_record('groups', 'id', $id)) {
error('Group ID was incorrect');
}
notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
print_footer();
die;
}
/// basic access control checks
if ($id) {
if (!$group = get_record('groups', 'id', $id)) {
@ -62,6 +79,9 @@ if (!empty($group)) {
// Process delete action
if ($delete) {
if (!confirm_sesskey()) {
error('Sesskey error');
}
if (groups_delete_group($id)) {
redirect(groups_home_url($course->id, null, $groupingid, false));
} else {

View File

@ -47,12 +47,16 @@ class group_edit_form extends moodleform {
$mform->setHelpButton('imagefile', array ('picture', get_string('helppicture')), true);
}
if ($group) {
$buttonstr = get_string('save', 'group');
$mform->addElement('hidden','id', null);
$mform->setType('id', PARAM_INT);
if (empty($CFG->enablegroupings)) {
// NO GROUPINGS YET!
$mform->addElement('hidden', 'newgrouping', GROUP_NOT_IN_GROUPING);
$mform->setType('newgrouping', PARAM_INT);
} else {
// Options to move group to another grouping
$groupingids = groups_get_groupings($courseid);
@ -67,8 +71,9 @@ class group_edit_form extends moodleform {
$mform->addElement('select', 'newgrouping', get_string('addgroupstogrouping', 'group'), $listgroupings);
$mform->setDefault('newgrouping', $groupingid);
}
}
}
if($groupingid) {
$mform->addElement('hidden', 'grouping', $groupingid);
$mform->setType('grouping', PARAM_INT);

View File

@ -18,6 +18,11 @@ $id = optional_param('id', false, PARAM_INT);
$delete = optional_param('delete', false, PARAM_BOOL);
if (empty($CFG->enablegroupings)) {
// NO GROUPIGS YET!
error('No groupings yet');
}
// Get the course information so we can print the header and
// check the course id is valid
$course = groups_get_course_info($courseid);

View File

@ -1,9 +0,0 @@
<div id="addgroupstogroupingform" class="popup">
<h3><?php print_string('addgroupstogrouping', 'group'); ?> <span id="selectedgroupingforaddinggroups"></span>
</h3>
<form action="">
<p><select id="groupsnotingrouping" size="15" multiple="multiple" class="select"></select></p>
<p><input type="button" id="addgroupstogrouping" value="<?php print_string('addgroupstogrouping', 'group'); ?>" /></p>
<p><input type="button" id="canceladdgroupstogrouping" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,73 +0,0 @@
function onAddGroupsToGrouping() {
hideAllForms();
showElement("groupeditform");
addGroupsToGrouping();
setText('selectedgroupingforaddinggroups', "");
return false;
}
/*
* Adds the selected groups to the selected groupings
*/
function addGroupsToGrouping() {
//alert("Called addGroupsToGrouping");
selectedgroups = getMultipleSelect("groupsnotingrouping");
if (selectedgroups != '') {
var url = "addgroupstogrouping-xml.php";
var requeststring = "groupingid="+selectedgroupingid
+"&groups="+selectedgroups;
sendPostRequest(request, url, requeststring, addGroupsToGroupingResponse);
}
}
/**
* The callback for the response to the request sent in addGroupsToGrouping()
*/
function addGroupsToGroupingResponse() {
if (checkAjaxResponse(request)) {
//alert("addGroupsToGrouping called");
//alert(request.responseText);
// Need XML sent back with groupingid
// Really want to set this to be the grouping before
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
updateGroupings();
hideElement("addgroupstogroupingform");
}
}
/**
* Updates the groups not in the selected grouping for the form for adding groups to a grouping
*/
function updateGroupsNotInGrouping() {
//alert("updateNonMembers called");
var url="getgroupsnotingrouping-xml.php";
var requeststring = "groupingid="+selectedgroupingid;
sendPostRequest(request, url, requeststring, updateGroupsNotInGroupingResponse);
}
/**
* The callback for the response to the request sent in updateGroupsNotInGrouping()
*/
function updateGroupsNotInGroupingResponse() {
if (checkAjaxResponse(request)) {
//alert("updateGroupsNotInGroupingResponse");
var xmlDoc = request.responseXML;
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
addOptionsFromXML("groupsnotingrouping", xmlDoc);
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* Adds an existing group to a grouping.
*
* @copyright &copy; 2006 The Open University
* @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
$groups = required_param('groups', PARAM_SEQUENCE); //TODO: check.
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupids = explode(',', $groups);
if ($groupids != false) {
foreach($groupids as $groupid) {
$groupadded = groups_add_group_to_grouping($groupid, $groupingid);
if (!$groupadded) {
echo '<error>Failed to add group $groupid to grouping</error>';
}
}
}
}
echo '</groupsresponse>';
?>

View File

@ -1,9 +0,0 @@
<div id="addmembersform" class="popup">
<h3><?php print_string('adduserstogroup', 'group'); ?> <span id="selectedgroup"></span></h3>
<form action="">
<p><input type="checkbox" id="showall" /><?php print_string('showusersalreadyingroup', 'group'); ?> </p>
<p><select id="nonmembers" size="15" multiple="multiple" class="select"></select></p>
<p><input type="button" id="addmembers" value="<?php print_string('adduserstogroup', 'group'); ?>" /></p>
<p><input type="button" id="canceladdmembers" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,79 +0,0 @@
function onAddMembers() {
hideAllForms();
showElement("groupeditform");
addMembers();
return false;
}
function onShowAll() {
updateNonMembers();
return false;
}
/*
* Adds the selected users to the selected group
*/
function addMembers() {
//alert("Called addMembers");
users = getMultipleSelect("nonmembers");
if (users != '') {
var url = "addmembers-xml.php";
var requeststring = "groupid="+selectedgroupid+"&users="+users;
sendPostRequest(request, url, requeststring, addMembersResponse);
}
}
/**
* The callback for the response to the request sent in addMembers()
*/
function addMembersResponse() {
if (checkAjaxResponse(request)) {
//alert("addMembersResponse called");
//alert(request.responseText);
// Need XML sent back with groupingid
// Really want to set this to be the grouping before
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
updateSelectedGrouping();
hideElement("addmembersform");
}
}
/**
* Updates the list of non members of a group in the form for adding members to a group
*/
function updateNonMembers() {
//alert("updateNonMembers called");
var url="getnonmembers-xml.php";
// showall indicates if we should show users already in groups in the grouping
// we have to turn it into a variable that we can put in a post
var showall = getCheckBoxValue('showall');;
var requeststring = "groupid="+selectedgroupid
+"&groupingid="+selectedgroupingid
+"&showall="+showall;
sendPostRequest(request, url, requeststring, updateNonMembersResponse);
}
/**
* The callback for the response to the request sent in updateNonMembers()
*/
function updateNonMembersResponse() {
if (checkAjaxResponse(request)) {
//alert("updateNonMembersResponse");
var xmlDoc = request.responseXML;
// alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
addOptionsFromXML("nonmembers", xmlDoc);
}
}

View File

@ -1,33 +0,0 @@
<?php
/**********************************************
* Adds users to a group
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
$users = required_param('users', PARAM_SEQUENCE);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$userids = explode(',', $users);
if ($userids != false) {
foreach($userids as $userid) {
$useradded = groups_add_member($groupid, $userid);
if (!$useradded) {
echo '<error>Failed to add user $userid to group</error>';
}
}
}
}
echo '</groupsresponse>';
?>

View File

@ -1,77 +0,0 @@
/***********************************************************************************************************
* Contains functions for creating and sending Ajax requests.
* This code needs to be a bit more careful about creating separate requests for different events - if
* somebody presses a button several times in quick succession (such as the delete grouping button) then
* we get an error.
* There also seems to a problem with IE - need to check this out
***********************************************************************************************************/
<?php
echo "var courseid = $courseid;";
echo "var sesskey = '$sesskey';";
?>
/*
* Creates an XMLHttpRequest object
* @return The XMLHttpRequest object created.
*/
function createRequest() {
var newrequest = null;
try {
newrequest = new XMLHttpRequest();
} catch (trymicrosoft) {
// Deal with Microsoft browsers
try {
newrequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
newrequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
newrequest = null;
}
}
}
if (newrequest == null) {
alert("Error creating request object!");
} else {
return newrequest;
}
}
/*
* Sends an Ajax post request
* @param request - The XMLHttpRequest object
* @param url - The URL to send the request to
* @param requeststring - The string containing the variables to send in the post request - the format
* is basically the same as a GET string
* @callbackfunction - The function to call when the response to the request is received
*/
function sendPostRequest(postrequest, url, requeststring, callbackfunction) {
// Add on the date and time to get round caching problem
url = url + "?dummy=" + new Date().getTime();
// Add the course id and sesskey so we can check these on the server
requeststring = 'courseid='+courseid+'&'+'sesskey='+sesskey+'&'+requeststring;
postrequest.abort();
postrequest.open('post', url, true);
postrequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
postrequest.onreadystatechange = callbackfunction;
postrequest.send(requeststring);
}
function checkAjaxResponse(request) {
process = false;
if (request.readyState == 4 && request.status == 200) {
process = true;
}
if (request.readyState == 4 && request.status != 200) {
alert('An error has occurred - the page returned a '+ request.status + ' error');
}
return process;
}
var responseFailure = function(o){
alert("Failure callback");
}

View File

@ -1,775 +0,0 @@
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 0.11.0
*/
/**
* The Connection Manager provides a simplified interface to the XMLHttpRequest
* object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
* interactive states and server response, returning the results to a pre-defined
* callback you create.
* @ class
*/
YAHOO.util.Connect =
{
/**
* Array of MSFT ActiveX ids for XMLHttpRequest.
* @private
* @type array
*/
_msxml_progid:[
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP'
],
/**
* Object literal of HTTP header(s)
* @private
* @type object
*/
_http_header:{},
/**
* Determines if HTTP headers are set.
* @private
* @type boolean
*/
_has_http_headers:false,
/**
* Determines if a default header of
* Content-Type of 'application/x-www-form-urlencoded'
* will be added to any client HTTP headers sent for POST
* transactions.
* @private
* @type boolean
*/
_default_post_header:true,
/**
* Property modified by setForm() to determine if the data
* should be submitted as an HTML form.
* @private
* @type boolean
*/
_isFormSubmit:false,
/**
* Property modified by setForm() to determine if a file(s)
* upload is expected.
* @private
* @type boolean
*/
_isFileUpload:false,
/**
* Property modified by setForm() to set a reference to the HTML
* form node if the desired action is file upload.
* @private
* @type object
*/
_formNode:null,
/**
* Property modified by setForm() to set the HTML form data
* for each transaction.
* @private
* @type string
*/
_sFormData:null,
/**
* Collection of polling references to the polling mechanism in handleReadyState.
* @private
* @type string
*/
_poll:[],
/**
* Queue of timeout values for each transaction callback with a defined timeout value.
* @private
* @type string
*/
_timeOut:[],
/**
* The polling frequency, in milliseconds, for HandleReadyState.
* when attempting to determine a transaction's XHR readyState.
* The default is 50 milliseconds.
* @private
* @type int
*/
_polling_interval:50,
/**
* A transaction counter that increments the transaction id for each transaction.
* @private
* @type int
*/
_transaction_id:0,
/**
* Member to add an ActiveX id to the existing xml_progid array.
* In the event(unlikely) a new ActiveX id is introduced, it can be added
* without internal code modifications.
* @public
* @param string id The ActiveX id to be added to initialize the XHR object.
* @return void
*/
setProgId:function(id)
{
this._msxml_progid.unshift(id);
},
/**
* Member to enable or disable the default POST header.
* @public
* @param boolean b Set and use default header - true or false .
* @return void
*/
setDefaultPostHeader:function(b)
{
this._default_post_header = b;
},
/**
* Member to modify the default polling interval.
* @public
* @param {int} i The polling interval in milliseconds.
* @return void
*/
setPollingInterval:function(i)
{
if(typeof i == 'number' && isFinite(i)){
this._polling_interval = i;
}
},
/**
* Instantiates a XMLHttpRequest object and returns an object with two properties:
* the XMLHttpRequest instance and the transaction id.
* @private
* @param {int} transactionId Property containing the transaction id for this transaction.
* @return connection object
*/
createXhrObject:function(transactionId)
{
var obj,http;
try
{
// Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
http = new XMLHttpRequest();
// Object literal with http and tId properties
obj = { conn:http, tId:transactionId };
}
catch(e)
{
for(var i=0; i<this._msxml_progid.length; ++i){
try
{
// Instantiates XMLHttpRequest for IE and assign to http.
http = new ActiveXObject(this._msxml_progid[i]);
// Object literal with http and tId properties
obj = { conn:http, tId:transactionId };
break;
}
catch(e){}
}
}
finally
{
return obj;
}
},
/**
* This method is called by asyncRequest to create a
* valid connection object for the transaction. It also passes a
* transaction id and increments the transaction id counter.
* @private
* @return object
*/
getConnectionObject:function()
{
var o;
var tId = this._transaction_id;
try
{
o = this.createXhrObject(tId);
if(o){
this._transaction_id++;
}
}
catch(e){}
finally
{
return o;
}
},
/**
* Method for initiating an asynchronous request via the XHR object.
* @public
* @param {string} method HTTP transaction method
* @param {string} uri Fully qualified path of resource
* @param callback User-defined callback function or object
* @param {string} postData POST body
* @return {object} Returns the connection object
*/
asyncRequest:function(method, uri, callback, postData)
{
var o = this.getConnectionObject();
if(!o){
return null;
}
else{
if(this._isFormSubmit){
if(this._isFileUpload){
this.uploadFile(o.tId, callback, uri);
this.releaseObject(o);
return;
}
//If the specified HTTP method is GET, setForm() will return an
//encoded string that is concatenated to the uri to
//create a querystring.
if(method == 'GET'){
uri += "?" + this._sFormData;
}
else if(method == 'POST'){
postData = this._sFormData;
}
this._sFormData = '';
}
o.conn.open(method, uri, true);
if(this._isFormSubmit || (postData && this._default_post_header)){
this.initHeader('Content-Type','application/x-www-form-urlencoded');
if(this._isFormSubmit){
this._isFormSubmit = false;
}
}
//Verify whether the transaction has any user-defined HTTP headers
//and set them.
if(this._has_http_headers){
this.setHeader(o);
}
this.handleReadyState(o, callback);
postData?o.conn.send(postData):o.conn.send(null);
return o;
}
},
/**
* This method serves as a timer that polls the XHR object's readyState
* property during a transaction, instead of binding a callback to the
* onreadystatechange event. Upon readyState 4, handleTransactionResponse
* will process the response, and the timer will be cleared.
*
* @private
* @param {object} o The connection object
* @param callback User-defined callback object
* @return void
*/
handleReadyState:function(o, callback)
{
var timeOut = callback.timeout;
var oConn = this;
try
{
if(timeOut !== undefined){
this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true) }, timeOut);
}
this._poll[o.tId] = window.setInterval(
function(){
if(o.conn && o.conn.readyState == 4){
window.clearInterval(oConn._poll[o.tId]);
oConn._poll.splice(o.tId);
if(timeOut){
oConn._timeOut.splice(o.tId);
}
oConn.handleTransactionResponse(o, callback);
}
}
,this._polling_interval);
}
catch(e)
{
window.clearInterval(oConn._poll[o.tId]);
oConn._poll.splice(o.tId);
if(timeOut){
oConn._timeOut.splice(o.tId);
}
oConn.handleTransactionResponse(o, callback);
}
},
/**
* This method attempts to interpret the server response and
* determine whether the transaction was successful, or if an error or
* exception was encountered.
*
* @private
* @param {object} o The connection object
* @param {object} callback - User-defined callback object
* @param {boolean} determines if the transaction was aborted.
* @return void
*/
handleTransactionResponse:function(o, callback, isAbort)
{
// If no valid callback is provided, then do not process any callback handling.
if(!callback){
this.releaseObject(o);
return;
}
var httpStatus, responseObject;
try
{
if(o.conn.status !== undefined && o.conn.status != 0){
httpStatus = o.conn.status;
}
else{
httpStatus = 13030;
}
}
catch(e){
// 13030 is the custom code to indicate the condition -- in Mozilla/FF --
// when the o object's status and statusText properties are
// unavailable, and a query attempt throws an exception.
httpStatus = 13030;
}
if(httpStatus >= 200 && httpStatus < 300){
responseObject = this.createResponseObject(o, callback.argument);
if(callback.success){
if(!callback.scope){
callback.success(responseObject);
}
else{
// If a scope property is defined, the callback will be fired from
// the context of the object.
callback.success.apply(callback.scope, [responseObject]);
}
}
}
else{
switch(httpStatus){
// The following case labels are wininet.dll error codes that may be encountered.
// Server timeout
case 12002:
// 12029 to 12031 correspond to dropped connections.
case 12029:
case 12030:
case 12031:
// Connection closed by server.
case 12152:
// See above comments for variable status.
case 13030:
responseObject = this.createExceptionObject(o.tId, callback.argument, isAbort);
if(callback.failure){
if(!callback.scope){
callback.failure(responseObject);
}
else{
callback.failure.apply(callback.scope, [responseObject]);
}
}
break;
default:
responseObject = this.createResponseObject(o, callback.argument);
if(callback.failure){
if(!callback.scope){
callback.failure(responseObject);
}
else{
callback.failure.apply(callback.scope, [responseObject]);
}
}
}
}
this.releaseObject(o);
},
/**
* This method evaluates the server response, creates and returns the results via
* its properties. Success and failure cases will differ in the response
* object's property values.
* @private
* @param {object} o The connection object
* @param {} callbackArg User-defined argument or arguments to be passed to the callback
* @return object
*/
createResponseObject:function(o, callbackArg)
{
var obj = {};
var headerObj = {};
try
{
var headerStr = o.conn.getAllResponseHeaders();
var header = headerStr.split('\n');
for(var i=0; i < header.length; i++){
var delimitPos = header[i].indexOf(':');
if(delimitPos != -1){
headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+1);
}
}
}
catch(e){}
obj.tId = o.tId;
obj.status = o.conn.status;
obj.statusText = o.conn.statusText;
obj.getResponseHeader = headerObj;
obj.getAllResponseHeaders = headerStr;
obj.responseText = o.conn.responseText;
obj.responseXML = o.conn.responseXML;
if(typeof callbackArg !== undefined){
obj.argument = callbackArg;
}
return obj;
},
/**
* If a transaction cannot be completed due to dropped or closed connections,
* there may be not be enough information to build a full response object.
* The failure callback will be fired and this specific condition can be identified
* by a status property value of 0.
*
* If an abort was successful, the status property will report a value of -1.
*
* @private
* @param {int} tId Transaction Id
* @param callbackArg The user-defined arguments
* @param isAbort Determines if the exception is an abort.
* @return object
*/
createExceptionObject:function(tId, callbackArg, isAbort)
{
var COMM_CODE = 0;
var COMM_ERROR = 'communication failure';
var ABORT_CODE = -1;
var ABORT_ERROR = 'transaction aborted';
var obj = {};
obj.tId = tId;
if(isAbort){
obj.status = ABORT_CODE;
obj.statusText = ABORT_ERROR;
}
else{
obj.status = COMM_CODE;
obj.statusText = COMM_ERROR;
}
if(callbackArg){
obj.argument = callbackArg;
}
return obj;
},
/**
* Public method that stores the custom HTTP headers for each transaction.
* @public
* @param {string} label The HTTP header label
* @param {string} value The HTTP header value
* @return void
*/
initHeader:function(label,value)
{
if(this._http_header[label] === undefined){
this._http_header[label] = value;
}
else{
this._http_header[label] = value + "," + this._http_header[label];
}
this._has_http_headers = true;
},
/**
* Accessor that sets the HTTP headers for each transaction.
* @private
* @param {object} o The connection object for the transaction.
* @return void
*/
setHeader:function(o)
{
for(var prop in this._http_header){
if(this._http_header.propertyIsEnumerable){
o.conn.setRequestHeader(prop, this._http_header[prop]);
}
}
delete this._http_header;
this._http_header = {};
this._has_http_headers = false;
},
/**
* This method assembles the form label and value pairs and
* constructs an encoded string.
* asyncRequest() will automatically initialize the
* transaction with a HTTP header Content-Type of
* application/x-www-form-urlencoded.
* @public
* @param {string || object} form id or name attribute, or form object.
* @param {string} optional boolean to indicate SSL environment.
* @param {string} optional qualified path of iframe resource for SSL in IE.
* @return void
*/
setForm:function(formId, isUpload, secureUri)
{
this._sFormData = '';
if(typeof formId == 'string'){
// Determine if the argument is a form id or a form name.
// Note form name usage is deprecated by supported
// here for legacy reasons.
var oForm = (document.getElementById(formId) || document.forms[formId]);
}
else if(typeof formId == 'object'){
var oForm = formId;
}
else{
return;
}
// If the isUpload argument is true, setForm will call createFrame to initialize
// an iframe as the form target.
//
// The argument secureURI is also required by IE in SSL environments
// where the secureURI string is a fully qualified HTTP path, used to set the source
// of the iframe, to a stub resource in the same domain.
if(isUpload){
(typeof secureUri == 'string')?this.createFrame(secureUri):this.createFrame();
this._isFormSubmit = true;
this._isFileUpload = true;
this._formNode = oForm;
return;
}
var oElement, oName, oValue, oDisabled;
var hasSubmit = false;
// Iterate over the form elements collection to construct the
// label-value pairs.
for (var i=0; i<oForm.elements.length; i++){
oDisabled = oForm.elements[i].disabled;
// If the name attribute is not populated, the form field's
// value will not be submitted.
oElement = oForm.elements[i];
oName = oForm.elements[i].name;
oValue = oForm.elements[i].value;
// Do not submit fields that are disabled or
// do not have a name attribute value.
if(!oDisabled && oName)
{
switch (oElement.type)
{
case 'select-one':
case 'select-multiple':
for(var j=0; j<oElement.options.length; j++){
if(oElement.options[j].selected){
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].value || oElement.options[j].text) + '&';
}
}
break;
case 'radio':
case 'checkbox':
if(oElement.checked){
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
}
break;
case 'file':
// stub case as XMLHttpRequest will only send the file path as a string.
case undefined:
// stub case for fieldset element which returns undefined.
case 'reset':
// stub case for input type reset button.
case 'button':
// stub case for input type button elements.
break;
case 'submit':
if(hasSubmit == false){
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
hasSubmit = true;
}
break;
default:
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
break;
}
}
}
this._isFormSubmit = true;
this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
},
/**
* Creates an iframe to be used for form file uploads. It is remove from the
* document upon completion of the upload transaction.
*
* @private
* @param {string} optional qualified path of iframe resource for SSL in IE.
* @return void
*/
createFrame:function(secureUri){
// IE does not allow the setting of id and name attributes as DOM
// properties. A different iframe creation pattern is required for IE.
if(window.ActiveXObject){
var io = document.createElement('<IFRAME name="ioFrame" id="ioFrame">');
if(secureUri){
// IE will throw a security exception in an SSL environment if the
// iframe source isn't set to a valid resource.
io.src = secureUri;
}
}
else{
var io = document.createElement('IFRAME');
io.id = 'ioFrame';
io.name = 'ioFrame';
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';
document.body.appendChild(io);
},
/**
* Uploads HTML form, including files/attachments, targeting the
* iframe created in createFrame.
*
* @private
* @param {int} id The transaction id.
* @param {object} callback - User-defined callback object.
* @param {string} uri Fully qualified path of resource.
* @return void
*/
uploadFile:function(id, callback, uri){
// Initialize the HTML form properties in case they are
// not defined in the HTML form.
this._formNode.action = uri;
this._formNode.enctype = 'multipart/form-data';
this._formNode.method = 'POST';
this._formNode.target = 'ioFrame';
this._formNode.submit();
// Reset form status properties.
this._formNode = null;
this._isFileUpload = false;
this._isFormSubmit = false;
// Create the upload callback handler that fires when the iframe
// receives the load event. Subsequently, the event handler is detached
// and the iframe removed from the document.
var uploadCallback = function()
{
var oResponse =
{
tId: id,
responseText: document.getElementById("ioFrame").contentWindow.document.body.innerHTML,
argument: callback.argument
}
if(callback.upload && !callback.scope){
callback.upload(oResponse);
}
else{
callback.upload.apply(callback.scope, [oResponse]);
}
YAHOO.util.Event.removeListener("ioFrame", "load", uploadCallback);
window.ioFrame.location.replace('#');
setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);
};
// Bind the onload handler to the iframe to detect the file upload response.
YAHOO.util.Event.addListener("ioFrame", "load", uploadCallback);
},
/**
* Public method to terminate a transaction, if it has not reached readyState 4.
* @public
* @param {object} o The connection object returned by asyncRequest.
* @param {object} callback User-defined callback object.
* @param {string} isTimeout boolean to indicate if abort was a timeout.
* @return void
*/
abort:function(o, callback, isTimeout)
{
if(this.isCallInProgress(o)){
window.clearInterval(this._poll[o.tId]);
this._poll.splice(o.tId);
if(isTimeout){
this._timeOut.splice(o.tId);
}
o.conn.abort();
this.handleTransactionResponse(o, callback, true);
return true;
}
else{
return false;
}
},
/**
* Public method to check if the transaction is still being processed.
* @public
* @param {object} o The connection object returned by asyncRequest
* @return boolean
*/
isCallInProgress:function(o)
{
// if the XHR object assigned to the transaction has not been dereferenced,
// then check its readyState status. Otherwise, return false.
if(o.conn){
return o.conn.readyState != 4 && o.conn.readyState != 0;
}
else{
//The XHR object has been destroyed.
return false;
}
},
/**
* Dereference the XHR instance and the connection object after the transaction is completed.
* @private
* @param {object} o The connection object
* @return void
*/
releaseObject:function(o)
{
//dereference the XHR instance.
o.conn = null;
//dereference the connection object.
o = null;
}
};

View File

@ -1,54 +0,0 @@
<div id="createautomaticgroupingform" class="popupwide">
<h3><?php print_string('createautomaticgrouping', 'group'); ?></h3>
<form name="automaticgroupingform" action="">
<table cellpadding="10">
<tr>
<td valign="top">
<p><?php print_string('groupingname', 'group'); ?></p>
<p><input id="automaticgroupingname" type="text" size="40" value="<?php print_string('defaultgroupingname', 'group'); ?>" /></p>
<p><?php print_string('groupingdescription', 'group'); ?></p>
<p><?php print_textarea($usehtmleditor, 4, 45, 150, 400, 'automaticgroupingdescription'); ?></p>
<p> <?php print_string('prefixforgroupnames', 'group'); ?> </p>
<p><input id="groupprefix" type="text" size="40 " value="<?php print_string('defaultgroupname', 'group'); ?> " /></p>
<p><?php print_string('defaultgroupdescription', 'group'); ?></p>
<p><?php print_textarea($usehtmleditor, 4, 45, 150, 400, 'defaultgroupdescription'); ?></p>
</td>
<td valign="top">
<p><input type="checkbox" id="alphabetical" /> <?php print_string('distributealphabetically', 'group'); ?></p>
<table>
<tr>
<td><input type="radio" name ="generationtype" id="nostudents" value="nostudents" checked />
</td>
<td> <?php print_string('selectnumberineachgroup', 'group'); ?>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><?php print_string('numberofstudents', 'group'); ?> </p><p><input id="noofstudents" type="text" size="5" /></p>
<p><input type="checkbox" id="distribevenly" checked /> <?php print_string('distributeevenly', 'group'); ?></p>
</td>
</tr>
</table>
<table>
<tr>
<td><input type="radio" name ="generationtype" id="nogroups" value="nogroups" /></td>
<td><?php print_string('selectnumberofgroups', 'group'); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><?php print_string('numberofgroups', 'group'); ?></p><p> <input id="noofgroups" type="text" size="5" /></p>
</td>
</tr>
</table>
<p><input type="button" id="createautomaticgrouping" value=" <?php print_string('creategrouping', 'group'); ?>" />&nbsp;
<input type="button" id="cancelcreateautomaticgrouping" value=" <?php print_string('cancel', 'group'); ?>" /></p>
</td>
</tr>
</table>
</form>
</div>

View File

@ -1,79 +0,0 @@
function onCreateAutomaticGrouping() {
valid = validateAutomaticGroupingForm();
if (valid) {
hideAllForms();
showElement("groupeditform");
createAutomaticGrouping();
}
return false;
}
/**
* Adds an automatically generated grouping with the details as specified in the form
*/
function createAutomaticGrouping() {
//alert("Called createAutomaticGrouping");
var url = "createautomaticgrouping-xml.php";
var requeststring = "noofstudents="+getTextInputValue('noofstudents')
+"&noofgroups="+getTextInputValue('noofgroups')
+"&distribevenly="+getCheckBoxValue('distribevenly')
+"&alphabetical="+getCheckBoxValue('alphabetical')
+"&generationtype="+getRadioValue(document.automaticgroupingform.generationtype)
+"&name="+getTextInputValue('automaticgroupingname')
+"&description="+getTextInputValue('edit-automaticgroupingdescription')
+"&prefix="+getTextInputValue('groupprefix')
+"&defaultgroupdescription="+getTextInputValue('edit-defaultgroupdescription');
// alert(requeststring);
sendPostRequest(request, url, requeststring, createAutomaticGroupingResponse);
}
/**
* The callback for the response to the request sent in createAutomaticGrouping()
* It sets the new grouping to be selected in the form.
*/
function createAutomaticGroupingResponse() {
if (checkAjaxResponse(request)) {
//alert("createAutomaticGroupingResponse");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
selectedgroupingid = getFromXML(request.responseXML, 'groupingid');
selectedgroupid = null;
updateGroupings();
hideElement("createautomaticgroupingform");
}
}
function validateAutomaticGroupingForm() {
valid = true;
generationtype = getRadioValue(document.automaticgroupingform.generationtype);
noofstudents = getTextInputValue('noofstudents');
noofgroups = getTextInputValue('noofgroups');
groupingname = getTextInputValue('automaticgroupingname');
if (generationtype == 'nostudents') {
if (!isPositiveInt(noofstudents)) {
alert('The number of students is not valid.');
valid = false;
}
} else {
if (!isPositiveInt(noofgroups)) {
alert('The number of groups is not valid.');
valid = false;
}
}
if (groupingname == '') {
alert('You must enter a name for the new grouping');
valid = false;
}
return valid;
}

View File

@ -1,46 +0,0 @@
<?php
/**********************************************
* Sets up an automatic grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
require_login($courseid);
groups_seed_random_number_generator();
$courseid = required_param('courseid', PARAM_INT);
$noofstudents = required_param('noofstudents', PARAM_INT);
$noofgroups = required_param('noofgroups', PARAM_INT);
$distribevenly = required_param('distribevenly', PARAM_INT); //TODO: PARAM_BOOL ?
$alphabetical = required_param('alphabetical', PARAM_INT);
$generationtype = required_param('generationtype', PARAM_ALPHA);
$groupingsettings->name = required_param('name', PARAM_ALPHANUM);
$groupingsettings->description = required_param('description', PARAM_ALPHANUM);
$groupingsettings->prefix = required_param('prefix');
$groupingsettings->defaultgroupdescription = required_param('defaultgroupdescription');
if (confirm_sesskey() and isteacheredit($courseid)) {
if ($generationtype == 'nogroups') {
$noofstudents = false;
}
$groupingid = groups_create_automatic_grouping($courseid, $noofstudents, $noofgroups,
$distribevenly, $groupingsettings, false, $alphabetical);
if (!$groupingid) {
echo '<error>Failed to create grouping</error>';
} else {
echo '<groupingid>'.$groupingid.'</groupingid>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,31 +0,0 @@
<div id="creategroupform" class="popup">
<h3><?php print_string('creategroup', 'group'); ?> <span id="selectedgroupingforcreatinggroup"></span></h3>
<form action="">
<p><label for="newgroupname"><?php print_string('groupname', 'group'); ?></label></p>
<p><input id="newgroupname" type="text" size="40" value="<?php print_string('defaultgroupname', 'group'); ?>" />
<p><?php print_string('groupingdescription', 'group'); ?><br />
<?php helpbutton("text", get_string("helptext")) ?></p>
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "newgroupdescription");?></p>
<p><?php print_string('enrolmentkey', 'group'); ?></p>
<p><input type="text" id="newgroupenrolmentkey" size="25" /></p>
<?php if ($printuploadpicture) { ?>
<p><?php print_string('hidepicture', 'group'); ?></p>
<p><?php $options = NULL; $options[0] = get_string("no");
$options[1] = get_string("yes");
$group->hidepicture = 1;
choose_from_menu ($options, "newgrouphidepicture", isset($group)? $group->hidepicture: 1, '');?></p>
<p><?php print_string('newpicture', 'group'); ?></p>
<p><?php upload_print_form_fragment(1,array('newgroupicon'),null,false,null,0,0,false);
helpbutton("picture", get_string("helppicture"));
print_string("maxsize", "", display_size($maxbytes), 'group'); ?>
</p>
<?php
}
?>
</table>
<p><input type="button" id="creategroup" value="<?php print_string('creategroup', 'group'); ?>" /></p>
<p><input type="button" id="cancelcreategroup" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,61 +0,0 @@
function onCreateGroup() {
valid = validateCreateGroupForm();
if (valid) {
hideAllForms();
showElement("groupeditform");
createGroup();
replaceText('selectedgroupingforcreatinggroup', "");
}
return false;
}
/*
* Adds a group with the name specified in the form to the selected grouping.
*/
function createGroup() {
//alert("Called createGroup");
var url = "creategroup-xml.php";
var requeststring = "groupname="+getTextInputValue('newgroupname')
+"&groupingid="+selectedgroupingid
+"&description="+getTextInputValue('edit-newgroupdescription')
+"&enrolmentkey="+getTextInputValue('newgroupenrolmentkey');
// The picture fields aren't displayed if the right library isn't present
if (document.getElementById('menunewgrouphidepicture')) {
requeststring = requeststring+"&hidepicture="+getTextInputValue('menunewgrouphidepicture');
}
sendPostRequest(request, url, requeststring, createGroupResponse);
}
/**
* The callback for the response to the request sent in createGroup()
* The function sets the new group as selected in the form.
*/
function createGroupResponse() {
if (checkAjaxResponse(request)) {
//alert("createGroupResponse called");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
selectedgroupid = getFromXML(request.responseXML, 'groupid');
updateGroupings();
hideElement("creategroupform");
}
}
function validateCreateGroupForm() {
valid = true;
groupname = getTextInputValue('newgroupname');
if (groupname == '') {
alert('You must enter a name for the new group');
valid = false;
}
return valid;
}

View File

@ -1,55 +0,0 @@
<?php
/**********************************************
* Adds a new group to a grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
$groupsettings->name = required_param('groupname', PARAM_ALPHANUM);
$groupsettings->description = required_param('description', PARAM_ALPHANUM);
$groupsettings->enrolmentkey= required_param('enrolmentkey', PARAM_ALPHANUM);
$groupsettings->hidepicture = optional_param('hidepicture', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupid = groups_create_group($courseid, $groupsettings);
if (!$groupid) {
echo '<error>Failed to create group</error>';
} else {
$groupadded = groups_add_group_to_grouping($groupid, $groupingid);
if (!$groupadded) {
echo '<error>Failed to add group to grouping</error>';
} else {
// Upload a picture file if there was one - note that we don't remove any previous icons
require_once($CFG->libdir.'/uploadlib.php');
$um = new upload_manager('newgroupicon', false, false, null, false, 0, true, true);
if ($um->preprocess_files()) {
require_once("$CFG->libdir/gdlib.php");
if (save_profile_image($groupid, $um, 'groups')) {
$groupsettings->picture = 1;
$infoset = groups_set_group_settings($groupid, $groupsettings);
if (!$infoset) {
echo '<error>Failed to save the fact that the group image was uploaded</error>';
}
}
}
echo '<groupid>'.$groupid.'</groupid>';
}
}
}
echo '</groupsresponse>';
?>

View File

@ -1,11 +0,0 @@
<div id="creategroupingform" class="popup">
<h3><?php print_string('creategrouping', 'group'); ?></h3>
<form action="">
<p><?php print_string('groupingname', 'group'); ?></p>
<p><input id="newgroupingname" type="text" size="40" value="<?php print_string('defaultgroupingname', 'group'); ?>" /></p>
<p><?php print_string('groupingdescription', 'group'); ?></p>
<p><?php print_textarea($usehtmleditor,5, 45, 200, 400, "newgroupingdescription");?></p>
<p><input type="button" id="creategrouping" value="<?php print_string('creategrouping', 'group'); ?>" /></p>
<p><input type="button" id="cancelcreategrouping" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,56 +0,0 @@
function onCreateGrouping() {
valid = validateCreateGroupingForm();
if (valid) {
hideAllForms();
showElement("groupeditform");
createGrouping();
}
return false;
}
/**
* Creates a new grouping for the course.
*/
function createGrouping() {
// alert("Called createGrouping");
var url = "creategrouping-xml.php";
var requeststring = "groupingname="+getTextInputValue('newgroupingname')
+"&description="+getTextInputValue('edit-newgroupingdescription');
sendPostRequest(request, url, requeststring, createGroupingResponse);
}
/**
* The callback for the response to the request sent in createGrouping()
* It sets the new grouping as selected in the form.
*/
function createGroupingResponse() {
if (checkAjaxResponse(request)) {
// alert("createGroupingResponse");
// alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
selectedgroupingid = getFromXML(request.responseXML, 'groupingid');
selectedgroupid = null;
updateGroupings();
hideElement("creategroupingform");
}
}
function validateCreateGroupingForm() {
valid = true;
groupingname = getTextInputValue('newgroupingname');
if (groupingname == '') {
alert('You must enter a name for the new grouping');
valid = false;
}
return valid;
}

View File

@ -1,31 +0,0 @@
<?php
/**********************************************
* Adds a new grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupingsettings->name = required_param('groupingname', PARAM_ALPHANUM);
$groupingsettings->description= required_param('description', PARAM_ALPHANUM);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingid = groups_create_grouping($courseid, $groupingsettings);
if (!$groupingid) {
echo '<error>Failed to create grouping</error>';
} else {
echo '<groupingid>'.$groupingid.'</groupingid>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,27 +0,0 @@
<?php
/**********************************************
* Deletes a group
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupremoved = groups_delete_group($groupid);
if ($groupremoved == false) {
echo "<error>Could not delete group $groupid</error>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,35 +0,0 @@
function onDeleteGroup() {
hideAllForms()
showElement("groupeditform");
deleteGroup();
return false;
}
/**
* Deletes the selected group
*/
function deleteGroup() {
//alert("Called deleteGroup");
var url = "deletegroup-xml.php";
var requeststring = "groupid="+selectedgroupid;
sendPostRequest(request, url, requeststring, deleteGroupResponse);
}
/**
* The callback for the response to the request sent in updateSelectedGrouping()
*/
function deleteGroupResponse() {
if (checkAjaxResponse(request)) {
//alert("deleteGroupResponse called");
// alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
// Need XML sent back with groupingid
// Really want to set this to be the grouping before
selectedgroupid = null;
updateGroupings();
}
}

View File

@ -1,26 +0,0 @@
<?php
/**********************************************
* Deletes a specified grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingremoved = groups_delete_grouping($groupingid);
if (!$groupingremoved) {
echo '<error>Failed to delete grouping</error>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,37 +0,0 @@
function onDeleteGrouping() {
hideAllForms()
showElement("groupeditform");
deleteGrouping();
return false;
}
/*
* Deletes the selected grouping
*/
function deleteGrouping() {
//alert("Called deleteGrouping");
var url = "deletegrouping-xml.php";
var requeststring = "groupingid="+selectedgroupingid;
confirm('Are you sure you want to delete this grouping and the groups that it contains?');
sendPostRequest(request, url, requeststring, deleteGroupingResponse);
}
/**
* The callback for the response to the request sent in deleteGrouping()
*/
function deleteGroupingResponse() {
if (checkAjaxResponse(request)) {
//alert("deleteGroupingResponse called");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
selectedgroupingid = null;
selectedgroupid = null;
updateGroupings();
}
}

View File

@ -1,13 +0,0 @@
<div id="editgroupingpermissionsform" class="popup">
<h3><?php print_string('editgroupingpermissions', 'group'); ?> for <span id="editperm-groupingname"></span></h3>
<form action="">
<p><input type="checkbox" id="edit-viewowngroup" checked /><?php print_string('viewowngroup', 'group'); ?></p>
<p><input type="checkbox" id="edit-viewallgroupsmembers" checked /><?php print_string('viewallgroupsmembers', 'group'); ?></p>
<p><input type="checkbox" id="edit-viewallgroupsactivities" checked /><?php print_string('viewallgroupsactivities', 'group'); ?></p>
<p><input type="checkbox" id="edit-teachersgroupmark" /><?php print_string('teachersgroupmark', 'group'); ?></p>
<p><input type="checkbox" id="edit-teachersgroupview" /><?php print_string('teachersgroupview', 'group'); ?></p>
<p><input type="checkbox" id="edit-teachersoverride" /><?php print_string('teachersoverride', 'group'); ?></p>
<p><input type="button" id="editgroupingpermissions" value="<?php print_string('save', 'group'); ?>" /></p>
<p><input type="button" id="canceleditgroupingpermissions" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,66 +0,0 @@
function onEditGroupingPermissionsSave() {
hideAllForms();
showElement("groupeditform");
editGroupingPermissions() ;
return false;
}
/**
* Creates a new grouping for the course.
*/
function editGroupingPermissions() {
var url = "editgroupingpermissions-xml.php";
var requeststring = "groupingid=" + selectedgroupingid
+"&viewowngroup=" + getCheckBoxValue('edit-viewowngroup')
+"&viewallgroupsmembers=" + getCheckBoxValue('edit-viewallgroupsmembers')
+"&viewallgroupsactivities=" + getCheckBoxValue('edit-viewallgroupsactivities')
+"&teachersgroupmark=" + getCheckBoxValue('edit-teachersgroupmark')
+"&teachersgroupview=" + getCheckBoxValue('edit-teachersgroupview')
+"&teachersoverride=" + getCheckBoxValue('edit-teachersoverride');
sendPostRequest(request, url, requeststring, editGroupingPermissionsResponse);
}
/**
* The callback for the response to the request sent in editgroupingpermissions()
* It sets the new grouping as selected in the form.
*/
function editGroupingPermissionsResponse() {
if (checkAjaxResponse(request)) {
//alert("editGroupingPermissionsResponse called");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
updateGroupings();
hideElement("editgroupingpermissionsform");
}
}
function getGroupingPermissions() {
//alert("Called getgroupingpermissions");
var url = "getgroupingpermissions-xml.php";
var requeststring = "groupingid="+selectedgroupingid;
sendPostRequest(request, url, requeststring, getGroupingPermissionsResponse);
}
function getGroupingPermissionsResponse() {
if (checkAjaxResponse(request)) {
//alert("getgroupingpermissionsResponse");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
xml = request.responseXML;
replaceText('editperm-groupingname', getFromXML(xml, 'name'));
setCheckBoxValue('edit-viewowngroup', boolStringToBool(getFromXML(xml, 'viewowngroup')));
setCheckBoxValue('edit-viewallgroupsmembers', boolStringToBool(getFromXML(xml, 'viewallgroupsmembers')));
setCheckBoxValue('edit-viewallgroupsactivities', boolStringToBool(getFromXML(xml, 'viewallgroupsactivities')));
setCheckBoxValue('edit-teachersgroupmark', boolStringToBool(getFromXML(xml, 'teachersgroupmark')));
setCheckBoxValue('edit-teachersgroupview', boolStringToBool(getFromXML(xml, 'teachersgroupview')));
setCheckBoxValue('edit-teachersoverride', boolStringToBool(getFromXML(xml, 'teachersoverride')));
}
}

View File

@ -1,30 +0,0 @@
<?php
/**********************************************
* Adds a new grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$groupingsettings->viewowngroup = required_param('viewowngroup', PARAM_INT); //TODO: PARAM_BOOL ??
$groupingsettings->viewallgroupsmembers = required_param('viewallgroupsmembers', PARAM_INT);
$groupingsettings->viewallgroupsactivities = required_param('viewallgroupsactivities', PARAM_INT);
$groupingsettings->teachersgroupmark = required_param('teachersgroupmark', PARAM_INT);
$groupingsettings->teachersgroupview = required_param('teachersgroupview', PARAM_INT);
$groupingsettings->teachersoverride = required_param('teachersoverride', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingid = groups_set_grouping_settings($groupingid, $groupingsettings);
}
echo '</groupsresponse>';
?>

View File

@ -1,11 +0,0 @@
<div id="editgroupingsettingsform" class="popup">
<h3><?php print_string('editgroupingsettings', 'group'); ?></h3>
<form action="">
<p><?php print_string('groupingname', 'group'); ?></p>
<p><input id="edit-groupingname" type="text" size="40" /></p>
<p><?php print_string('groupingdescription', 'group'); ?></p>
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "edit-groupingdescription");?></p>
<p><input type="button" id="editgroupingsettings" value="<?php print_string('save', 'group'); ?>" /></p>
<p><input type="button" id="canceleditgroupingsettings" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,72 +0,0 @@
function onEditGroupingSettingsSave() {
valid = validateEditGroupingSettingsForm();
if (valid) {
hideAllForms();
showElement("groupeditform");
editGroupingSettings() ;
return false;
}
}
/**
* Creates a new grouping for the course.
*/
function editGroupingSettings() {
var url = "editgroupingsettings-xml.php";
var requeststring = "groupingid="+selectedgroupingid
+"&groupingname="+getTextInputValue('edit-groupingname')
+"&description="+getTextInputValue('edit-edit-groupingdescription');
sendPostRequest(request, url, requeststring, editGroupingSettingsResponse);
}
/**
* The callback for the response to the request sent in editgroupingsettings()
* It sets the new grouping as selected in the form.
*/
function editGroupingSettingsResponse() {
if (checkAjaxResponse(request)) {
//alert("editGroupingSettingsResponse called");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
updateGroupings();
hideElement("editgroupingsettingsform");
}
}
function getGroupingSettings() {
//alert("Called getgroupingsettings");
var url = "getgroupingsettings-xml.php";
var requeststring = "groupingid="+selectedgroupingid;
sendPostRequest(request, url, requeststring, getGroupingSettingsResponse);
}
function getGroupingSettingsResponse() {
if (checkAjaxResponse(request)) {
//alert("getgroupingsettingsResponse");
//alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
xml = request.responseXML;
setTextInputValue('edit-groupingname', getFromXML(xml, 'name'));
setTextInputValue('edit-edit-groupingdescription', getFromXML(xml, 'description'));
}
}
function validateEditGroupingSettingsForm() {
valid = true;
groupingname = getTextInputValue('edit-groupingname');
if (groupingname == '') {
alert('You must enter a name for the new grouping');
valid = false;
}
return valid;
}

View File

@ -1,26 +0,0 @@
<?php
/**********************************************
* Adds a new grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$groupingsettings->name = required_param('groupingname', PARAM_ALPHANUM);
$groupingsettings->description= required_param('description', PARAM_ALPHANUM);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingid = groups_set_grouping_settings($groupingid, $groupingsettings);
}
echo '</groupsresponse>';
?>

View File

@ -1,22 +0,0 @@
<div id="editgroupsettingsform" class="popup">
<h3><?php print_string('editgroupsettings', 'group'); ?></h3>
<form action="">
<p><?php print_string('groupname', 'group'); ?></p>
<p><input id="groupname" type="text" size="40" /></p>
<p><?php print_string("description") ?><br />
<?php helpbutton("text", get_string("helptext")) ?></p>
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "groupdescription");?> </p>
<p><?php print_string('enrolmentkey') ?></p>
<p><input type="text" id="enrolmentkey" size="25" /></p>
<?php if ($printuploadpicture) { ?>
<p><?php print_string("hidepicture") ?></p>
<p><?php $options = NULL; $options[0] = get_string("no"); $options[1] = get_string("yes");
choose_from_menu ($options, "hidepicture", $group->hidepicture, ""); ?></p>
<p><?php print_string("newpicture") ?></p>
<p><?php upload_print_form_fragment(1,array('groupicon'),null,false,null,0,0,false);
helpbutton("picture", get_string("helppicture"));
print_string("maxsize", "", display_size($maxbytes), 'group'); ?></p>
<?php } ?>
<p><input type="button" id="editgroupsettings" value="<?php print_string('save', 'group'); ?>" />&nbsp;<input type="button" id="canceleditgroupsettings" value="<?php print_string('cancel', 'group'); ?>" /></p>
</form>
</div>

View File

@ -1,78 +0,0 @@
function onEditGroupSettingsSave() {
valid = validateEditgroupsettingsForm();
if (valid) {
editgroupsettings() ;
hideAllForms();
showElement("groupeditform");
}
return false;
}
/**
* Creates a new group for the course.
*/
function editGroupSettings() {
// alert("Called editgroupsettings");
var url = "editgroupsettings-xml.php";
var requeststring = "groupid="+selectedgroupid
+"&groupname="+getTextInputValue('groupname')
+"&description="+getTextInputValue('edit-groupdescription')
+"&enrolmentkey="+getTextInputValue('enrolmentkey')
+"&hidepicture="+hidepicture;
// The picture fields aren't displayed if the right library isn't present
if (document.getElementById('menuhidepicture')) {
requeststring = requeststring+"&hidepicture="+getTextInputValue('menuhidepicture');
}
sendPostRequest(request, url, requeststring, editGroupSettingsResponse);
}
/**
* The callback for the response to the request sent in editgroupsettings(()
*/
function editGroupSettingsResponse() {
if (checkAjaxResponse(request)) {
// alert("editgroupsettingsResponse");
// alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
updateSelectedGrouping();
hideElement("editgroupsettingsform");
}
}
function getGroupSettings() {
// alert("Called getgroupsettings");
groupid = getSelectedGroup();
var url = "getgroupsettings-xml.php";
var requeststring = "groupid="+groupid;
sendPostRequest(request, url, requeststring, getGroupSettingsResponse);
}
function getGroupSettingsResponse() {
if (checkAjaxResponse(request)) {
// alert("getgroupsettingsResponse");
// alert(request.responseText);
error = getFromXML(request.responseXML, 'error');
if (error != null) {
alert(error);
}
xml = request.responseXML;
setTextInputValue('groupname', getFromXML(xml, 'name'));
setTextInputValue('edit-groupdescription', getFromXML(xml, 'description'));
setTextInputValue('enrolmentkey', getFromXML(xml, 'enrolmentkey'));
}
}
function validateEditgroupsettingsForm() {
valid = true;
groupname = getTextInputValue('groupname');
if (groupname == '') {
alert('You must enter a name for the new group');
valid = false;
}
return valid;
}

View File

@ -1,49 +0,0 @@
<?php
/**********************************************
* Adds a new grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$groupname = required_param('groupname', PARAM_ALPHANUM);
$description = required_param('description', PARAM_ALPHANUM);
$enrolmentkey= required_param('enrolmentkey', PARAM_ALPHANUM);
$hidepicture = required_param('hidepicture', PARAM_INT); //TODO: PARAM_BOOL ??
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupsettings->name = $groupname;
$groupsettings->description = $description;
$groupsettings->enrolmentkey = $enrolmentkey;
$groupsettings->hidepicture = $hidepicture;
// Upload the group icon if there is one - note that we don't remove any previous icons
require_once($CFG->libdir.'/uploadlib.php');
$um = new upload_manager('groupicon', false, false, null, false, 0, true, true);
if ($um->preprocess_files()) {
require_once("$CFG->libdir/gdlib.php");
if (save_profile_image($groupid, $um, 'groups')) {
$groupsettings->picture = 1;
} else {
echo '<error>Failed to save group image</error>';
}
} else {
$groupsettings->picture = 0;
}
$infoset = groups_set_group_settings($groupid, $groupsettings);
if (!$infoset) {
echo "<error>Failed to set new group settings</error>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,52 +0,0 @@
.popup
{
position:absolute;
left:300px;
top:80px;
width:550px;
border-style:solid;
border-color: grey;
border-width: 1px;
background-color: white;
padding:10px;
z-index:1;
visibility: hidden;
}
.popupwide
{
position:absolute;
left:200px;
top:80px;
width:900px;
border-style:solid;
border-color: grey;
border-width: 1px;
background-color: white;
padding:10px;
z-index:1;
visibility: hidden;
}
.select
{
overflow: visible;
clip: auto;
width:200px;
}
.groupmanagementtable
{
padding: 10px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.groupmanagementtableheader
{
width: 300px;
}

View File

@ -1,42 +0,0 @@
<link rel="stylesheet" type="text/css" href="form.css" />
<script type="text/javascript" src="yahoo.js"></script>
<script type="text/javascript" src="connection.js"></script>
<script type="text/javascript">
<!-- Begin
<?php include('ajax.js'); ?>
// end hiding script -->
</script>
<script type="text/javascript" src="util-form.js"></script>
<script type="text/javascript" src="main-buttons-form.js"></script>
<script type="text/javascript" src="main-selects-form.js"></script>
<script type="text/javascript" src="creategroup-form.js"></script>
<script type="text/javascript" src="creategrouping-form.js"></script>
<script type="text/javascript" src="editgroupingsettings-form.js"></script>
<script type="text/javascript" src="editgroupingpermissions-form.js"></script>
<script type="text/javascript" src="editgroupsettings-form.js"></script>
<script type="text/javascript" src="createautomaticgrouping-form.js"></script>
<script type="text/javascript" src="addmembers-form.js"></script>
<script type="text/javascript" src="addgroupstogrouping-form.js"></script>
<script type="text/javascript" src="main-init-form.js"></script>
<script type="text/javascript" src="deletegroup.js"></script>
<script type="text/javascript" src="deletegrouping.js"></script>
<script type="text/javascript" src="removegroupfromgrouping.js"></script>
<script type="text/javascript" src="removemembers.js"></script>
<noscript>
<?php notify(get_string('javascriptrequired')); ?>
</noscript>
<?php include('main-form.html'); ?>
<?php include('creategroup-form.html'); ?>
<?php include('editgroupsettings-form.html'); ?>
<?php include('creategrouping-form.html'); ?>
<?php include('editgroupingsettings-form.html'); ?>
<?php include('editgroupingpermissions-form.html'); ?>
<?php include('addgroupstogrouping-form.html'); ?>
<?php include('addmembers-form.html'); ?>
<?php include('createautomaticgrouping-form.html'); ?>

View File

@ -1,62 +0,0 @@
<?php
/**********************************************
* Fetches the settings of a grouping and returns
* them in an XML format
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingsettings = groups_get_grouping_settings($groupingid);
echo '<name>'.$groupingsettings->name.'</name>';
if ($groupingsettings->viewowngroup) {
echo '<viewowngroup>true</viewowngroup>';
} else {
echo '<viewowngroup>false</viewowngroup>';
}
if ($groupingsettings->viewallgroupsmembers) {
echo '<viewallgroupsmembers>true</viewallgroupsmembers>';
} else {
echo '<viewallgroupsmembers>false</viewallgroupsmembers>';
}
if ($groupingsettings->viewallgroupsactivities) {
echo '<viewallgroupsactivities>true</viewallgroupsactivities>';
} else {
echo '<viewallgroupsactivities>false</viewallgroupsactivities>';
}
if ($groupingsettings->teachersgroupmark) {
echo '<teachersgroupmark>true</teachersgroupmark>';
} else {
echo '<teachersgroupmark>false</teachersgroupmark>';
}
if ($groupingsettings->teachersgroupview) {
echo '<teachersgroupview>true</teachersgroupview>';
} else {
echo '<teachersgroupview>false</teachersgroupview>';
}
if ($groupingsettings->teachersoverride) {
echo '<teachersoverride>true</teachersoverride>';
} else {
echo '<teachersoverride>false</teachersoverride>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,41 +0,0 @@
<?php
/**********************************************
* Fetches the settings of the groupings for a course
* and returns them in an XML format
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingids = groups_get_groupings($courseid);
if ($groupingids != false) {
// Put the groupings into a hash and sort them
foreach($groupingids as $groupingid) {
$listgroupings[$groupingid] = groups_get_grouping_displayname($groupingid);
}
natcasesort($listgroupings);
// Print out the XML
echo '<option>';
foreach($listgroupings as $value=>$name) {
echo "<name>$name</name>";
echo "<value>$value</value>";
}
echo '</option>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,27 +0,0 @@
<?php
/**********************************************
* Fetches the settings of a grouping and returns
* them in an XML format
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingsettings = groups_get_grouping_settings($groupingid);
echo '<name>'.$groupingsettings->name.'</name>';
echo '<description>'.$groupingsettings->description.'</description>';
}
echo '</groupsresponse>';
?>

View File

@ -1,36 +0,0 @@
<?php
/**********************************************
* Fetches the settings of a grouping and returns
* them in an XML format
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$courseid = required_param('courseid', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupsettings = groups_get_group_settings($groupid);
if (!$groupsettings) {
echo '<error>Failed to get group details</error>';
} else {
echo '<name>'.$groupsettings->name.'</name>';
echo '<description>'.$groupsettings->description.'</description>';
echo '<enrolmentkey>'.$groupsettings->enrolmentkey.'</enrolmentkey>';
echo '<hidepicture>'.$groupsettings->hidepicture.'</hidepicture>';
echo '<picture>'.$groupsettings->picture.'</picture>';
echo '<lang>'.$groupinkfo->lang.'</lang>';
echo '<theme>'.$groupsettings->theme.'</theme>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,40 +0,0 @@
<?php
/**********************************************
* Adds an existing group to a grouping
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupids = groups_get_groups_in_grouping($groupingid);
if ($groupids != false) {
// Put the groupings into a hash and sort them
foreach($groupids as $groupid) {
$listgroups[$groupid] = groups_get_group_displayname($groupid);
}
natcasesort($listgroups);
// Print out the XML
echo "<option>";
foreach($listgroups as $value=>$name) {
echo "<name>$name</name>";
echo "<value>$value</value>";
}
echo "</option>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,40 +0,0 @@
<?php
/**********************************************
* Gets the groups not in a grouping for a course
* and returns them in an XML format
**********************************************/
require_once('../lib/lib.php');
require_once('../../config.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupids = groups_get_groups_not_in_grouping($groupingid, $courseid);
if ($groupids != false) {
// Put the groupings into a hash and sort them
foreach($groupids as $groupid) {
$listgroups[$groupid] = groups_get_group_displayname($groupid);
}
natcasesort($listgroups);
// Print out the XML
echo "<option>";
foreach($listgroups as $value=>$name) {
echo "<name>$name</name>";
echo "<value>$value</value>";
}
echo "</option>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,43 +0,0 @@
<?php
/**********************************************
* Gets the members of a group and returns them
* in an XMl format
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$userids = groups_get_members($groupid);
if ($userids != false) {
// Put the groupings into a hash and sort them
foreach($userids as $userid) {
$listmembers[$userid] = groups_get_user_displayname($userid, $courseid);
}
natcasesort($listmembers);
// Print out the XML
echo "<option>";
foreach($listmembers as $value=>$name) {
echo "<name>$name</name>";
echo "<value>$value</value>";
}
echo "</option>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,49 +0,0 @@
<?php
/**********************************************
* Gets the users registered for a course that
* don't belong to a specified group and prints
* their detailsin an XML format.
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$showall = required_param('showall', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
echo "$groupingid $groupid";
if ($showall == 0) {
$userids = groups_get_users_not_in_any_group_in_grouping($courseid,$groupingid, $groupid);
} else {
$userids = groups_get_users_not_in_group($courseid, $groupid);
}
if ($userids != false) {
// Put the groupings into a hash and sorts them
foreach($userids as $userid) {
$listmembers[$userid] = groups_get_user_displayname($userid, $courseid);
}
natcasesort($listmembers);
// Print out the XML
echo "<option>";
foreach($listmembers as $value=>$name) {
echo "<name>$name</name>";
echo "<value>$value</value>";
}
echo "</option>";
}
}
echo '</groupsresponse>';
?>

View File

@ -1,64 +0,0 @@
<?php // $Id$
/**
* The main group management user interface.
*
* @copyright &copy; 2006 The Open University
* @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
require_once('../../config.php');
require_once('../lib/lib.php');
//require_once('../../course/lib.php');
require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/uploadlib.php');
$error = false;
$courseid = required_param('id', PARAM_INTEGER);
// Get the course information so we can print the header and check the course id
// is valid
$course = groups_get_course_info($courseid);
if (!$course) {
$error = true;
print_error('The course id is invalid');
}
if (!$error) {
// Make sure that the user is a teacher with edit permission for this course
require_login($courseid);
if (!isteacheredit($courseid)) {
redirect();
}
// Set the session key so we can check this later
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
if (!empty($CFG->gdversion)) { //TODO: and $maxbytes)
$printuploadpicture = true;
} else {
$printuploadpicture = false;
}
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
$strgroups = get_string('groups');
$strparticipants = get_string('participants');
// Print the page and form
print_header("$course->shortname: $strgroups",
$course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
"-> $strgroups", "", "", true, '', user_login_string($course, $USER));
//TODO: set to false in /course/group.php
$usehtmleditor = false;
require_once('form.html');
print_footer($course);
}
?>

View File

@ -1,66 +0,0 @@
function onShowAddMembersForm() {
hideAllForms();
showElement("addmembersform");
updateNonMembers();
groupname = getSelectedGroupName();
replaceText('selectedgroup', groupname);
return false;
}
function onShowAddGroupsToGroupingForm() {
hideAllForms();
showElement("addgroupstogroupingform");
updateGroupsNotInGrouping();
groupingname = getSelectedGroupingName();
replaceText('selectedgroupingforaddinggroups', groupingname);
return false;
}
function onShowCreateGroupingForm() {
hideAllForms();
showElement("creategroupingform");
return false;
}
function onShowCreateGroupForm() {
hideAllForms();
showElement("creategroupform");
groupingname = getSelectedGroupingName();
replaceText('selectedgroupingforcreatinggroup', groupingname);
return false;
}
function onShowEditGroupSettingsForm() {
hideAllForms();
showElement("editgroupsettingsform");
getGroupSettings();
return false;
}
function onShowEditGroupingPermissionsForm() {
hideAllForms();
showElement("editgroupingpermissionsform");
getGroupingPermissions();
return false;
}
function onShowEditGroupingSettingsForm() {
hideAllForms();
showElement("editgroupingsettingsform");
getGroupingSettings();
return false;
}
function onShowAutomaticGroupingForm() {
hideAllForms();
showElement("createautomaticgroupingform");
return false;
}
function onPrinterFriendly() {
document.location.href = "printgrouping.php?courseid="+courseid+"&groupingid="+selectedgroupingid;
return false;
}

View File

@ -1,41 +0,0 @@
<form name="groupeditform" id="groupeditform" action="">
<table cellpadding="10" class="generaltable generalbox groupmanagementtable">
<tr>
<th class="header groupmanagementtableheader" scope="col"><?php print_string('groupings', 'group'); ?></th>
<th class="header groupmanagementtableheader" scope="col"><?php print_string('groupsinselectedgrouping', 'group'); ?></th>
<th class="header groupmanagementtableheader" scope="col"><?php print_string('membersofselectedgroup', 'group'); ?></th>
</tr>
<tr>
<td class="generalboxcontent">
<select id="groupings" size="15" class="select"></select>
</td>
<td>
<select id="groups" size="15" class="select"></select>
</td>
<td>
<select id="members" size="15" multiple="multiple" class="select"></select>
</td>
</tr>
<tr>
<td>
<p><input type="button" id="showeditgroupingsettingsform" value="<?php print_string('editgroupingsettings', 'group'); ?>" /></p>
<p><input type="button" id="showeditgroupingpermissionsform" value="<?php print_string('editgroupingpermissions', 'group'); ?>" /></p>
<p><input type="button" id="deletegrouping" value="<?php print_string('deletegrouping', 'group'); ?>" /></p>
<p><input type="button" id="showcreategroupingform" value="<?php print_string('creategrouping', 'group'); ?>" /></p>
<p><input type="button" id="showcreateautomaticgroupingform" value="<?php print_string('createautomaticgrouping', 'group'); ?>" /></p>
<p><input type="button" id="printerfriendly" value="<?php print_string('printerfriendly', 'group'); ?>" /></p>
</td>
<td>
<p><input type="button" id="showeditgroupsettingsform" value="<?php print_string('editgroupsettings', 'group'); ?>" /></p>
<p><input type="button" id="deletegroup" value="<?php print_string('deleteselectedgroup', 'group'); ?>" /></p>
<p><input type="button" id="removegroup" value="<?php print_string('removegroupfromselectedgrouping', 'group'); ?>" /></p>
<p><input type="button" id="showcreategroupform" value="<?php print_string('creategroupinselectedgrouping', 'group'); ?>" /></p>
<p><input type="button" id="showaddgroupstogroupingform" value="<?php print_string('addexistinggroupstogrouping', 'group'); ?>" /></p>
</td>
<td>
<p><input type="button" id="removemembers" value="<?php print_string('removeselectedusers', 'group'); ?>"/></p>
<p><input type="button" id="showaddmembersform" value="<?php print_string('adduserstogroup', 'group'); ?>" /></p>
</td>
</tr>
</table>
</form>

View File

@ -1,71 +0,0 @@
/*
* This file contains all the functions called when the pages loads and also all the functions that are called
* on events such as clicking buttons in the forms for the form.html page.
*
* This script requires functions from ajax.js and form-access.js
*
* This code also assumes you have a basic understanding of how Ajax works - if
* you don't, it won't make much sense!
*/
// Create XMLHttpRequest objects to use
var request = createRequest();
var updategroupingsrequest = createRequest();
var updateselectedgroupingsrequest = createRequest();
var updateselectedgrouprequest = createRequest();
// The selectedgroupingid should always be set to the current selected groupingid and the
// selectedgroupid should always be set to the current selected groupid. We initialise them to
// be null at the start, but they'll get set when the page loads.
var selectedgroupingid = null;
var selectedgroupid = null;
// When the page has loaded called the initPage function
window.onload = initPage;
/**
* The initPage function updates the groupings, groups and members in all the selects appropriately
*and adds the right javascript events to all the buttons etc.
*/
function initPage() {
// Check that we're using a recent enough version of javascript
if (!document.getElementById) {
return false;
}
updateGroupings();
addEvent('groupings', 'change', onGroupingChange);
addEvent('groups', 'change', onGroupChange);
addEvent('deletegrouping', 'click', onDeleteGrouping);
addEvent('deletegroup', 'click', onDeleteGroup);
addEvent('removegroup', 'click', onRemoveGroup);
addEvent('removemembers', 'click', onRemoveMembers);
addEvent('showaddmembersform', 'click', onShowAddMembersForm);
addEvent('showaddgroupstogroupingform', 'click', onShowAddGroupsToGroupingForm);
addEvent('showcreategroupingform', 'click', onShowCreateGroupingForm);
addEvent('showcreategroupform', 'click', onShowCreateGroupForm);
addEvent('showeditgroupsettingsform', 'click', onShowEditGroupSettingsForm);
addEvent('showeditgroupingsettingsform', 'click', onShowEditGroupingSettingsForm);
addEvent('showeditgroupingpermissionsform', 'click', onShowEditGroupingPermissionsForm);
addEvent('showcreateautomaticgroupingform', 'click', onShowAutomaticGroupingForm);
addEvent('printerfriendly', 'click', onPrinterFriendly);
addEvent('createautomaticgrouping', 'click', onCreateAutomaticGrouping);
addEvent('cancelcreateautomaticgrouping', 'click', onCancel);
addEvent('addgroupstogrouping', 'click', onAddGroupsToGrouping);
addEvent('canceladdgroupstogrouping', 'click', onCancel);
addEvent('creategroup', 'click', onCreateGroup);
addEvent('cancelcreategroup', 'click', onCancel);
addEvent('creategrouping', 'click', onCreateGrouping);
addEvent('cancelcreategrouping', 'click', onCancel);
addEvent('addmembers', 'click', onAddMembers);
addEvent('canceladdmembers', 'click', onCancel);
addEvent('showall', 'change', onShowAll);
addEvent('editgroupsettings', 'click', onEditGroupSettingsSave);
addEvent('canceleditgroupsettings', 'click', onCancel);
addEvent('editgroupingsettings', 'click', onEditGroupingSettingsSave);
addEvent('canceleditgroupingsettings', 'click', onCancel);
addEvent('editgroupingpermissions', 'click', onEditGroupingPermissionsSave);
addEvent('canceleditgroupingpermissions', 'click', onCancel);
}

View File

@ -1,238 +0,0 @@
/**
* This file contains various utility functions, primarily to get and set information on form.html
* and to take information from XML documents and either return information from them or modifiy the
* form appropriately.
*/
function onGroupingChange() {
hideAllForms();
showElement("groupeditform");
if (!document.getElementById('groupings')) {
alert('No groupings id element');
} else {
groupingselect = document.getElementById('groupings');
selectedgroupingid = groupingselect.value;
selectedgroupid = null;
updateSelectedGrouping();
}
return false;
}
function onGroupChange() {
hideAllForms();
showElement("groupeditform");
selectedgroupid = getSelectedGroup();
updateSelectedGroup();
return false;
}
function getSelectedGroupingName() {
if (!document.getElementById('groupings')) {
alert('No groupings id element');
value = null;
} else {
groupingselect = document.getElementById('groupings');
value = groupingselect.options[groupingselect.selectedIndex].firstChild.nodeValue;
}
return value;
}
function getSelectedGroupName() {
if (!document.getElementById('groups')) {
alert('No groups id element');
value = null;
} else {
groupselect = document.getElementById('groups');
value = groupselect.options[groupselect.selectedIndex].firstChild.nodeValue;
}
return value;
}
/*
* Set the selected grouping on the form to the grouping whose id is selectedgroupingid
*/
function setSelectedGrouping() {
if (selectedgroupingid == null) {
selectedgroupingid = getFirstOption("groupings");
}
if (selectedgroupingid != null) {
if (!document.getElementById('groupings')) {
alert('No groupings id element');
} else {
groupingselect = document.getElementById('groupings');
groupingselect.value = selectedgroupingid
}
}
}
/*
* Get the id of the group that is currently selected
*/
function getSelectedGroup() {
if (!document.getElementById('groups')) {
alert('No groups id element');
value = null;
} else {
groupselect = document.getElementById('groups');
value = groupselect.value;
}
return value;
}
/*
* Set the selected group on the form to the group whose id is selectedgroupid
*/
function setSelectedGroup() {
if (selectedgroupid == null) {
selectedgroupid = getFirstOption("groups");
}
if (selectedgroupid != null) {
if (!document.getElementById('groups')) {
alert('No groups id element');
} else {
groupselect = document.getElementById('groups');
groupselect.value = selectedgroupid;
}
}
}
/*
* Get the selected users to delete
*/
function getSelectedUsers() {
return getMultipleSelect("members")
}
/***************************************************************
* Functions that just display information (and don't change the data in the database)
**********************************************/
/**
* Updates the list of groupings, setting either a specified grouping as selected or
* the first grouping as selected.
*/
function updateGroupings() {
alert("updateGroupings called");
var url = "getgroupings-xml.php";
requeststring = 'courseid='+courseid+'&'+'sesskey='+sesskey;
var transaction = YAHOO.util.Connect.asyncRequest('POST', url,
updateGroupingsResponseCallback, requeststring);
//sendPostRequest(updategroupingsrequest, url, requeststring, updateGroupingsResponse);
}
var updateGroupingsResponseCallback =
{
success:function(o) {
// alert("updateGroupingsResponse called");
var xmlDoc = o.responseXML;
error = getFromXML(o.responseXML, 'error');
if (error != null) {
alert(error);
}
// alert(o.responseXML);
var noofoptions = addOptionsFromXML("groupings", xmlDoc);
// If the selected grouping is not set, set it to the first grouping in the list
if(selectedgroupingid == null) {
selectedgroupingid = getFirstOption("groupings");
selectedgroupid = null;
}
// If there are no groupings, make sure the rest of the form is set up appropriately
// i.e. there should be any groups or members shown and various buttons should be disabled
// If there are groupings, update the one that is selected and enable any buttons that
// might have been disabled.
if (noofoptions == 0) {
removeOptions("groups");
removeOptions("members");
disableButton("showaddmembersform");
disableButton("showcreategroupform");
disableButton("showaddgroupstogroupingform");
} else {
updateSelectedGrouping();
enableButton("showaddmembersform");
enableButton("showcreategroupform");
enableButton("showaddgroupstogroupingform");
}
},
failure:responseFailure,
};
/**
* Updates the list of groups when groupingid is marked as selected
* groupid can be null or a specified group - this is the group that gets marked as
* selectedgroupingid cannot be null.
*/
function updateSelectedGrouping() {
//alert("UpdateSelectedGrouping called");
setSelectedGrouping();
var url = "getgroupsingrouping-xml.php";
requeststring = "groupingid="+selectedgroupingid;
sendPostRequest(updateselectedgroupingsrequest, url, requeststring, updateSelectedGroupingResponse);
}
/**
* The callback for the response to the request sent in updateSelectedGrouping()
*/
function updateSelectedGroupingResponse() {
if (checkAjaxResponse(updateselectedgroupingsrequest)) {
//alert("updateSelectedGroupingResponse called");
var xmlDoc = updateselectedgroupingsrequest.responseXML;
error = getFromXML(updateselectedgroupingsrequest.responseXML, 'error');
if (error != null) {
alert(error);
}
// alert(updateselectedgroupingsrequest.responseText);
var noofoptions = addOptionsFromXML("groups", xmlDoc);
if (selectedgroupid == null) {
selectedgroupid = getFirstOption("groups");
}
if (noofoptions == 0) {
removeOptions("members");
disableButton("showaddmembersform");
} else {
updateSelectedGroup(selectedgroupid);
enableButton("showaddmembersform");
}
}
}
/**
* Updates the members for the selected group - currently none marked as selected
*/
function updateSelectedGroup() {
//alert("updateSelectedGroup");
setSelectedGroup();
var url = "getmembers-xml.php";
var requeststring = "groupid="+selectedgroupid;
sendPostRequest(updateselectedgrouprequest, url, requeststring, updateSelectedGroupResponse);
}
/**
* The callback for the response to the request sent in updateSelectedGroup()
*/
function updateSelectedGroupResponse() {
if (checkAjaxResponse(updateselectedgrouprequest)) {
var xmlDoc = updateselectedgrouprequest.responseXML;
//alert("updateSelectedGroupResponse");
error = getFromXML(xmlDoc, 'error');
if (error != null) {
alert(error);
}
//alert(request.responseText);
var noofoptions = addOptionsFromXML("members", xmlDoc);
}
}

View File

@ -1,88 +0,0 @@
<?php
/**
* Print groups in groupings, and members of groups.
*
* @copyright &copy; 2006 The Open University
* @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
require_once('../../config.php');
require_once('../lib.php');
$success = true;
$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
// Get the course information so we can print the header and
// check the course id is valid
$course = groups_get_course_info($courseid);
if (! $course) {
$success = false;
print_error('invalidcourse');
}
if ($success) {
// Make sure that the user has permissions to manage groups.
require_login($courseid);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
if (! has_capability('moodle/course:managegroups', $context)) {
redirect();
}
//( confirm_sesskey checks that this is a POST request.)
// Print the page and form
$strgroups = get_string('groups');
$strparticipants = get_string('participants');
print_header("$course->shortname: $strgroups", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
"-> <a href=\"$CFG->wwwroot/group/groupui/index.php?id=$courseid\">$strgroups</a>".
"-> Display grouping", "", "", true, '', user_login_string($course, $USER));
$groupingname = groups_get_grouping_name($groupingid);
if (! $groupingname) {
print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
} else {
// Print the name of the grouping
echo "<h1>$groupingname</h1>\n";
}
// Get the groups and group members for the grouping.
if (GROUP_NOT_IN_GROUPING == $groupingid) {
$groupids = groups_get_groups_not_in_any_grouping($courseid);
} else {
$groupids = groups_get_groups_in_grouping($groupingid);
}
if ($groupids) {
// Make sure the groups are in the right order
$group_names = groups_groupids_to_group_names($groupids);
// Go through each group in turn and print the group name and then the members
foreach ($group_names as $group) {
echo "<h2>{$group->name}</h2>\n";
$userids = groups_get_members($group->id);
if ($userids != false) {
// Make sure the users are in the right order
$user_names = groups_userids_to_user_names($userids, $courseid);
echo "<ol>\n";
foreach ($user_names as $user) {
echo "<li>{$user->name}</li>\n";
}
echo "</ol>\n";
}
}
}
print_footer($course);
}
?>

View File

@ -1,28 +0,0 @@
<?php
/**********************************************
* Removes a specified group from a specified grouping
* (but does not delete the group)
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
$groupingremoved = groups_remove_group_from_grouping($groupid, $groupingid);
if (!$groupingremoved) {
echo '<error>Failed to remove group from grouping</error>';
}
}
echo '</groupsresponse>';
?>

View File

@ -1,34 +0,0 @@
function onRemoveGroup() {
hideAllForms();
showElement("groupeditform");
removeGroupFromGrouping();
return false;
}
/**
* Removes the selected group from the selected grouping, does not delete the group (so it can e.g. be added to
* another grouping
*/
function removeGroupFromGrouping() {
//alert("Called removeGroupFromGrouping");
var url = "removegroupfromgrouping-xml.php";
var requeststring = "groupid="+selectedgroupid+"&groupingid="+selectedgroupingid;
sendPostRequest(request, url, requeststring, removeGroupFromGroupingResponse);
}
/**
* The callback for the response to the request sent in removeGroupFromGrouping()
*/
function removeGroupFromGroupingResponse() {
if (checkAjaxResponse(request)) {
//alert("removeGroupFromGroupingResponse called");
var xmlDoc= request.responseXML;
// Need XML sent back with groupingid
// Really want to set this to be the grouping before
selectedgroupid = null;
updateGroupings();
}
}

View File

@ -1,38 +0,0 @@
<?php
/**********************************************
* Takes a groupid and comma-separated list of
* userids, and removes each of those userids
* from the specified group
**********************************************/
require_once('../../config.php');
require_once('../lib/lib.php');
@header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<groupsresponse>';
$groupid = required_param('groupid', PARAM_INT);
$users = required_param('users', PARAM_SEQUENCE);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
// Change the comma-separated string of the userids into an array of the userids
$userids = explode(',', $users);
if ($userids != false) {
// Remove each user in turn from the group.
foreach($userids as $userid) {
$useradded = groups_remove_member($groupid, $userid);
if (!$useradded) {
echo "<error>Failed to adduser $userid</error>";
}
}
}
}
echo '</groupsresponse>';
?>

View File

@ -1,33 +0,0 @@
function onRemoveMembers() {
hideAllForms();
showElement("groupeditform");
removeMembers();
return false;
}
/**
* Removes the selected members from the selected group
*/
function removeMembers() {
//alert("Called removeMembers");
users = getSelectedUsers();
var url = "removemembers-xml.php";
var requeststring = "groupid="+selectedgroupid+"&users="+users;
sendPostRequest(request, url, requeststring, removeMembersResponse);
}
/**
* The callback for the response to the request sent in removeMembers()
*/
function removeMembersResponse() {
if (checkAjaxResponse(request)) {
//alert("removeMembersResponse called");
//alert(request.responseText);
updateSelectedGroup();
}
}

View File

@ -1,358 +0,0 @@
/**
* This file contains various utility functions, primarily to get and set information on form.html
* and to take information from XML documents and either return information from them or modifiy the
* form appropriately.
*/
/*
* Disable the button with the specified id
*/
function disableButton(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
} else {
var node = document.getElementById(id);
node.disabled = true;
}
}
/**
* Enable the button with the specified id
*/
function enableButton(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
} else {
var node = document.getElementById(id);
node.disabled = false;
}
}
/**
* Show the form with the specified id
*/
function showElement(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
} else {
document.getElementById(id).style.visibility = "visible";
}
}
/**
* Hide the form with the specified id
*/
function hideElement(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
} else {
var node = document.getElementById(id);
node.style.visibility = "hidden";
}
}
/**
* Hides all the extra forms in form.html
*/
function hideAllForms() {
hideElement("addmembersform");
hideElement("addgroupstogroupingform");
hideElement("creategroupingform");
hideElement("createautomaticgroupingform");
hideElement("creategroupform");
hideElement("editgroupingsettingsform");
hideElement("editgroupingpermissionsform");
hideElement("editgroupsettingsform");
hideElement("groupeditform");
}
function onCancel() {
hideAllForms();
showElement("groupeditform");
return false;
}
function addEvent(id, eventtype, fn){
if (!document.getElementById(id)) {
alert('No ' + id + ' element');
return false;
} else {
obj = document.getElementById(id);
}
if (obj.addEventListener) {
obj.addEventListener(eventtype, fn, false );
} else if (obj.attachEvent) {
obj["e"+ eventtype +fn] = fn;
obj[eventtype+fn] = function() { obj["e"+ eventtype +fn]( window.event ); }
obj.attachEvent( "on"+ eventtype , obj[eventtype+fn] );
} else {
obj["on"+type] = obj["e"+ eventtype +fn];
}
}
/**
* Gets the value of the first option in a select
*/
function getFirstOption(id) {
if (document.getElementById(id)) {
var node = document.getElementById(id);
if (node.hasChildNodes()) {
var children
firstoption = node.firstChild;
if (firstoption.value) {
value = firstoption.value;
} else {
value = null;
}
} else {
value = null;
}
} else {
value = null;
}
return value;
}
/*
*Turn the values from a multiple select to a comma-separated list
*/
function getMultipleSelect(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
} else {
node = document.getElementById(id);
}
var selected = ""
for (var i = 0; i < node.options.length; i++) {
if (node.options[i].selected) {
selected = selected + node.options[ i ].value + ",";
}
}
// Remove the last comma - there must be a nicer way of doing this!
// Maybe easier with regular expressions?
var length = selected.length;
if (selected.charAt(length - 1) == ',') {
selected = selected.substring(0, length -1);
}
return selected;
}
/*
* Creates an option in a select element with the specified id with the given name and value.
*/
function createOption(id, value, name) {
var node = document.getElementById(id);
var option = document.createElement("option");
option.setAttribute("value", value);
node.appendChild(option);
var namenode = document.createTextNode(name);
option.appendChild(namenode);
}
/*
* Removes all the options from a select with a given id
*/
function removeOptions(id) {
var node = document.getElementById(id);
while (node.hasChildNodes())
{
node.removeChild(node.firstChild);
}
}
/*
* Takes an XML doc of the form <option><name></name><value></value><name></name><value></value></option>
* And adds an option to the selected with the specified id
* @param id The id of the select
* @param xmlDoc The XML document
* @return The number of options added
*/
function addOptionsFromXML(id, xmlDoc) {
// Clear any options that are already there.
removeOptions(id);
var optionelements = xmlDoc.getElementsByTagName('option');
var nameelements = xmlDoc.getElementsByTagName('name');
var valueelements = xmlDoc.getElementsByTagName('value');
if (nameelements != null) {
for (var i = 0; i < nameelements.length; i++) {
var name = nameelements[i].firstChild.nodeValue;
var value = valueelements[i].firstChild.nodeValue;
createOption(id, value, name);
}
noofoptions = nameelements.length;
} else {
noofoptions = 0;
}
return noofoptions;
}
/*
* Gets an error from an XML doc contain a tag of the form <error></error>
* If it contains more than one such tag, it only return the value from the first one.
*/
function getErrorFromXML(xmlDoc) {
alert(xmlDoc.getElementsByTagName('error'));
if (!xmlDoc.getElementsByTagName('error')) {
value = null;
} else {
var errorelement = xmlDoc.getElementsByTagName('error')[0];
var value = errorelement.firstChild.nodeValue;
}
return value;
}
function addChildrenFromXML(parentnode, xmlparentnode) {
xmlChildNodes = xmlparentnode.childNodes;
length = xmlChildNodes.length;
for (i = 0; i < length; i++) {
child = parentnode.appendChild(parentnode, xmlChildNodes[i]);
addChildrenFromXML(child, xmlChildNodes[i])
}
}
function getTextInputValue(id) {
if (!document.getElementById(id)) {
showNoElementError(id)
value = null;
} else {
textinput = document.getElementById(id);
value = textinput.value;
}
return value;
}
function setTextInputValue(id, value) {
if (!document.getElementById(id)) {
showNoElementError(id);
value = null;
} else {
textinput = document.getElementById(id);
textinput.value = value;
}
}
function getCheckBoxValue(id) {
if (!document.getElementById(id)) {
showNoElementError(id);
value= null;
} else {
checkbox = document.getElementById(id);
value = checkbox.checked;
}
return boolToInt(value);
}
function boolStringToBool(boolstring) {
if (boolstring == 'true') {
return true;
} else {
return false;
}
}
function boolToInt(boolean) {
if (boolean) {
return '1';
} else if (boolean == false) {
return '0';
} else {
return boolean;
}
}
function setCheckBoxValue(id, checked) {
if (!document.getElementById(id)) {
showNoElementError(id);
} else {
checkbox = document.getElementById(id);
checkbox.checked = checked;
}
}
function replaceText(id, text) {
if (!document.getElementById(id)) {
showNoElementError(id)
value = null;
} else {
element = document.getElementById(id);
if (element.childNodes) {
for (var i = 0; i < element.childNodes.length; i++) {
var childNode = element.childNodes[i];
element.removeChild(childNode);
}
}
var textnode = document.createTextNode(text);
element.appendChild(textnode);
}
}
function getRadioValue(radioelement) {
value = "";
if (!radioelement) {
value = "";
}
for(var i = 0; i < radioelement.length; i++) {
if(radioelement[i].checked) {
value = radioelement[i].value;
}
}
return value;
}
/*
* Gets the groupid from an XML doc contain a tag of the form <groupid></groupid>
* If it contains more than one such tag, it only return the value from the first one.
*/
function getFromXML(xmlDoc, id) {
if (!xmlDoc.getElementsByTagName(id)) {
var value = null;
} else if (xmlDoc.getElementsByTagName(id).length == 0) {
var value = null;
} else {
var element = xmlDoc.getElementsByTagName(id)[0];
if (!element.firstChild) {
var value = '';
} else {
var value = element.firstChild.nodeValue;
}
}
return value;
}
function showNoElementError(id) {
alert('Error: No ' + id +' element');
}
function isPositiveInt(str) {
isPosInt = true;
var i = parseInt (str);
if (isNaN (i)) {
isPosInt = false;
}
if (i < 0) {
isPosInt = false;
// Check not characters at the end of the number
}
if (i.toString() != str) {
isPosInt = false;
}
return isPosInt ;
}

View File

@ -1,84 +0,0 @@
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 0.11.0
*/
/**
* The Yahoo global namespace
* @constructor
*/
var YAHOO = window.YAHOO || {};
/**
* Returns the namespace specified and creates it if it doesn't exist
*
* YAHOO.namespace("property.package");
* YAHOO.namespace("YAHOO.property.package");
*
* Either of the above would create YAHOO.property, then
* YAHOO.property.package
*
* @param {String} ns The name of the namespace
* @return {Object} A reference to the namespace object
*/
YAHOO.namespace = function(ns) {
if (!ns || !ns.length) {
return null;
}
var levels = ns.split(".");
var nsobj = YAHOO;
// YAHOO is implied, so it is ignored if it is included
for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
nsobj[levels[i]] = nsobj[levels[i]] || {};
nsobj = nsobj[levels[i]];
}
return nsobj;
};
/**
* Uses YAHOO.widget.Logger to output a log message, if the widget is available.
*
* @param {string} sMsg The message to log.
* @param {string} sCategory The log category for the message. Default
* categories are "info", "warn", "error", time".
* Custom categories can be used as well. (opt)
* @param {string} sSource The source of the the message (opt)
* @return {boolean} True if the log operation was successful.
*/
YAHOO.log = function(sMsg, sCategory, sSource) {
var l = YAHOO.widget.Logger;
if(l && l.log) {
return l.log(sMsg, sCategory, sSource);
} else {
return false;
}
};
/**
* Utility to set up the prototype, constructor and superclass properties to
* support an inheritance strategy that can chain constructors and methods.
*
* @param {Function} subclass the object to modify
* @param {Function} superclass the object to inherit
*/
YAHOO.extend = function(subclass, superclass) {
var f = function() {};
f.prototype = superclass.prototype;
subclass.prototype = new f();
subclass.prototype.constructor = subclass;
subclass.superclass = superclass.prototype;
if (superclass.prototype.constructor == Object.prototype.constructor) {
superclass.prototype.constructor = superclass;
}
};
YAHOO.namespace("util");
YAHOO.namespace("widget");
YAHOO.namespace("example");

View File

@ -27,6 +27,11 @@ $groupid = optional_param('group', false, PARAM_INT);
$userid = optional_param('user', false, PARAM_INT);
$action = groups_param_action();
if (empty($CFG->enablegroupings)) {
// NO GROUPINGS YET!
$groupingid = GROUP_NOT_IN_GROUPING;
}
if ($groupid) {
$groupingsforgroup = groups_get_groupings_for_group($groupid);
if ($groupingsforgroup) {
@ -100,7 +105,7 @@ if ($success) {
redirect(groups_grouping_edit_url($courseid, null, false));
break;
case 'printerfriendly':
redirect('groupui/printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid);
redirect('printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid);
break;
case 'showgroupsettingsform':
@ -201,6 +206,11 @@ if ($success) {
*/
echo '<table cellpadding="6" class="generaltable generalbox groupmanagementtable boxaligncenter" summary="">'."\n";
echo '<tr>'."\n";
if (empty($CFG->enablegroupings)) {
// NO GROUPIGS YET!
$sel_groupingid = -1;
} else {
echo '<td class="generalboxcontent">'."\n";
echo '<p><label for="groupings">' . get_string('groupings', 'group') . '<span id="dummygrouping">&nbsp;</span></label></p>'."\n";
echo '<select name="grouping" id="groupings" size="15" class="select"';
@ -265,8 +275,15 @@ if ($success) {
echo '<p><input type="submit" ' . $printerfriendly_disabled . ' name="act_printerfriendly" id="printerfriendly" value="'
. get_string('printerfriendly', 'group') . '" /></p>'."\n";
echo "</td>\n<td>\n";
echo "</td>\n";
}
echo "<td>\n";
if (empty($CFG->enablegroupings)) {
// NO GROUPINGS YET!
echo '<p><label for="groups"><span id="groupslabel">'.get_string('groups').':</span><span id="thegrouping">&nbsp;</span></label></p>'."\n";
} else {
echo '<p><label for="groups"><span id="groupslabel">'.get_string('groupsinselectedgrouping', 'group').' </span><span id="thegrouping">'.get_string('grouping', 'group').'</span></label></p>'."\n";
}
echo '<select name="group" id="groups" size="15" class="select" onchange="membersCombo.refreshMembers(this.options[this.selectedIndex].value);"'."\n";
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
@ -307,7 +324,14 @@ if ($success) {
echo '<p><input type="submit" '.$disabled.' name="act_removegroup" '
. 'id="removegroup" value="' . get_string('removegroupfromselectedgrouping', 'group') . '" /></p>'."\n";
}
if (empty($CFG->enablegroupings)) {
// NO GROUPIGS YET!
echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
. get_string('creategroup', 'group') . '" /></p>'."\n";
echo '<p><input type="submit" name="act_printerfriendly" id="printerfriendly" value="'
. get_string('printerfriendly', 'group') . '" /></p>'."\n";
} else {
echo '<p><input type="submit" ' . $showcreategroupform_disabled . ' name="act_showcreategroupform" id="showcreategroupform" value="'
. get_string('creategroupinselectedgrouping', 'group') . '" /></p>'."\n";
@ -318,10 +342,11 @@ if ($success) {
echo '<p><input type="submit" '.$disabled.' name="act_addgroupstogroupingform" '
. 'id="showaddgroupstogroupingform" value="' . get_string('addgroupstogrouping', 'group') . '" /></p>'."\n";
}
}
echo '</td>'."\n";
echo '<td>'."\n";
echo '<p><label for="members"><span id="memberslabel">'.get_string('membersofselectedgroup', 'group').' </span><span id="thegroup">'.get_string('group', 'group').'</span></label></p>'."\n";
echo '<p><label for="members"><span id="memberslabel">'.get_string('membersofselectedgroup', 'group').' </span><span id="thegroup">&nbsp;</span></label></p>'."\n";
//NOTE: the SELECT was, multiple="multiple" name="user[]" - not used and breaks onclick.
echo '<select name="user" id="members" size="15" class="select"'."\n";
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";

View File

@ -161,7 +161,7 @@ function groupmode($course, $cm=null) {
return $cm->groupmode;
}
return $course->groupmode;
/*if ($cm and !$course->groupingid) {
//TODO: was $coursemodule
return groups_has_groups_setup_for_instance($cm);
@ -201,25 +201,29 @@ function set_current_group($courseid, $groupid) {
function get_current_group($courseid, $full = false) {
global $SESSION;
if (isset($SESSION->currentgroup[$courseid])) {
if ($full) {
return groups_get_group($SESSION->currentgroup[$courseid], false);
} else {
return $SESSION->currentgroup[$courseid];
}
}
$mygroupid = mygroupid($courseid);
if (is_array($mygroupid)) {
$mygroupid = array_shift($mygroupid);
}
if (isset($SESSION->currentgroup[$courseid])) {
$currentgroup = $SESSION->currentgroup[$courseid];
} else {
$currentgroup = $mygroupid;
}
if ($currentgroup) {
$SESSION->currentgroup[$courseid] = $mygroupid;
set_current_group($courseid, $mygroupid);
if ($full) {
return groups_get_group($mygroupid, false);
} else {
return $mygroupid;
}
}
if ($full) {
return groups_groupid_to_group($currentgroup);
return false;
} else {
return $currentgroup;
return 0;
}
}
@ -265,12 +269,11 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) {
/*)}else {
$currentgroupid = $group->id;*/
} elseif ($groupmode == SEPARATEGROUPS) { // student in separate groups switching
if (ismember($group->id)) { //check if is a member
if (ismember($groupid)) { //check if is a member
$currentgroupid = set_current_group($course->id, $groupid); //might need to set_current_group?
}
else {
echo($group->id);
notify('You do not belong to this group!', 'error');
notify('You do not belong to this group! ('.$groupid.')', 'error');
}
}
}
@ -280,8 +283,8 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) {
if (has_capability('moodle/site:accessallgroups', $context)) { // Sets current default group
$currentgroupid = set_current_group($course->id, 0);
} elseif ($groupmode == VISIBLEGROUPS) { // All groups are visible
$currentgroupid = 0;
} else if ($groupmode == VISIBLEGROUPS) { // All groups are visible
$currentgroupid = set_current_group($course->id, 0);
}
}
@ -317,31 +320,52 @@ function setup_and_print_groups($course, $groupmode, $urlroot) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if ($groupmode == VISIBLEGROUPS
or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) {
groups_instance_print_grouping_selector();
}//added code here to allow non-editting teacher to swap in-between his own groups
//added code for students in separategrous to swtich groups
else if ($groupmode == SEPARATEGROUPS and has_capability('moodle/course:view', $context)) {
groups_instance_print_group_selector();
if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
//we are in separate groups and the current group is group 0, as last set.
//this can mean that either, this guy has no group
//or, this guy just came from a visible all forum, and he left when he set his current group to 0 (show all)
if ($usergroups = user_group($course->id, $USER->id)){
//for the second situation, we need to perform the trick and get him a group.
$first = reset($usergroups);
$currentgroup = get_and_set_current_group($course, $groupmode, $first->id);
} else {
//else he has no group in this course
print_heading(get_string('notingroup'));
print_footer($course);
exit;
}
}
if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) {
if ($groups = get_groups($course->id)) {
echo '<div class="groupselector">';
print_group_menu($groups, $groupmode, $currentgroup, $urlroot, 1);
echo '</div>';
}
} else if ($groupmode == SEPARATEGROUPS and has_capability('moodle/course:view', $context)) {
//get all the groups this guy is in in this course
if ($usergroups = user_group($course->id, $USER->id)){
echo '<div class="groupselector">';
//print them in the menu
print_group_menu($usergroups, $groupmode, $currentgroup, $urlroot, 0);
echo '</div>';
}
}
return $currentgroup;
}
function groups_instance_print_grouping_selector() {
//TODO: ??
}
function groups_instance_print_group_selector() {
//TODO: ??
}
function oldgroups_print_user_group_info($currentgroup, $isseparategroups, $courseid) {
global $CFG;
$context = get_context_instance(CONTEXT_COURSE, $courseid);
if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group
if ($group = get_record('groups', 'id', $currentgroup)) {
if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {

File diff suppressed because it is too large Load Diff

View File

@ -1,190 +0,0 @@
<?php
/**
* @file CAS/PGTStorage/pgt-db.php
* Basic class for PGT database storage
*/
// include phpDB library (the test was introduced in release 0.4.8 for
// the integration into Tikiwiki).
if (!class_exists('DB')) {
include_once('DB.php');
}
/**
* @class PGTStorageDB
* The PGTStorageDB class is a class for PGT database storage. An instance of
* this class is returned by CASClient::SetPGTStorageDB().
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorageDB
*/
class PGTStorageDB extends PGTStorage
{
/**
* @addtogroup internalPGTStorageDB
* @{
*/
/**
* a string representing a PEAR DB URL to connect to the database. Written by
* PGTStorageDB::PGTStorageDB(), read by getURL().
*
* @hideinitializer
* @private
*/
var $_url='';
/**
* This method returns the PEAR DB URL to use to connect to the database.
*
* @return a PEAR DB URL
*
* @private
*/
function getURL()
{
return $this->_url;
}
/**
* The handle of the connection to the database where PGT's are stored. Written by
* PGTStorageDB::init(), read by getLink().
*
* @hideinitializer
* @private
*/
var $_link = null;
/**
* This method returns the handle of the connection to the database where PGT's are
* stored.
*
* @return a handle of connection.
*
* @private
*/
function getLink()
{
return $this->_link;
}
/**
* The name of the table where PGT's are stored. Written by
* PGTStorageDB::PGTStorageDB(), read by getTable().
*
* @hideinitializer
* @private
*/
var $_table = '';
/**
* This method returns the name of the table where PGT's are stored.
*
* @return the name of a table.
*
* @private
*/
function getTable()
{
return $this->_table;
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageType()
{
return "database";
}
/**
* This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @public
*/
function getStorageInfo()
{
return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
}
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The class constructor, called by CASClient::SetPGTStorageDB().
*
* @param $cas_parent the CASClient instance that creates the object.
* @param $user the user to access the data with
* @param $password the user's password
* @param $database_type the type of the database hosting the data
* @param $hostname the server hosting the database
* @param $port the port the server is listening on
* @param $database the name of the database
* @param $table the name of the table storing the data
*
* @public
*/
function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
{
phpCAS::traceBegin();
// call the ancestor's constructor
$this->PGTStorage($cas_parent);
if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
// build and store the PEAR DB URL
$this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$server.':'.$port.'/'.$database;
// XXX should use setURL and setTable
phpCAS::traceEnd();
}
// ########################################################################
// INITIALIZATION
// ########################################################################
/**
* This method is used to initialize the storage. Halts on error.
*
* @public
*/
function init()
{
phpCAS::traceBegin();
// if the storage has already been initialized, return immediatly
if ( $this->isInitialized() )
return;
// call the ancestor's method (mark as initialized)
parent::init();
// try to connect to the database
$this->_link = DB::connect($this->getURL());
if ( DB::isError($this->_link) ) {
phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
}
var_dump($this->_link);
phpCAS::traceBEnd();
}
/** @} */
}
?>

View File

@ -1,237 +0,0 @@
<?php
/**
* @file CAS/PGTStorage/pgt-file.php
* Basic class for PGT file storage
*/
/**
* @class PGTStorageFile
* The PGTStorageFile class is a class for PGT file storage. An instance of
* this class is returned by CASClient::SetPGTStorageFile().
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorageFile
*/
class PGTStorageFile extends PGTStorage
{
/**
* @addtogroup internalPGTStorageFile
* @{
*/
/**
* a string telling where PGT's should be stored on the filesystem. Written by
* PGTStorageFile::PGTStorageFile(), read by getPath().
*
* @private
*/
var $_path;
/**
* This method returns the name of the directory where PGT's should be stored
* on the filesystem.
*
* @return the name of a directory (with leading and trailing '/')
*
* @private
*/
function getPath()
{
return $this->_path;
}
/**
* a string telling the format to use to store PGT's (plain or xml). Written by
* PGTStorageFile::PGTStorageFile(), read by getFormat().
*
* @private
*/
var $_format;
/**
* This method returns the format to use when storing PGT's on the filesystem.
*
* @return a string corresponding to the format used (plain or xml).
*
* @private
*/
function getFormat()
{
return $this->_format;
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageType()
{
return "file";
}
/**
* This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageInfo()
{
return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
}
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The class constructor, called by CASClient::SetPGTStorageFile().
*
* @param $cas_parent the CASClient instance that creates the object.
* @param $format the format used to store the PGT's (`plain' and `xml' allowed).
* @param $path the path where the PGT's should be stored
*
* @public
*/
function PGTStorageFile($cas_parent,$format,$path)
{
phpCAS::traceBegin();
// call the ancestor's constructor
$this->PGTStorage($cas_parent);
if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
// check that the path is an absolute path
if ( $path[0] != '/' ) {
phpCAS::error('an absolute path is needed for PGT storage to file');
}
// store the path (with a leading and trailing '/')
$path = preg_replace('|[/]*$|','/',$path);
$path = preg_replace('|^[/]*|','/',$path);
$this->_path = $path;
// check the format and store it
switch ($format) {
case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
case CAS_PGT_STORAGE_FILE_FORMAT_XML:
$this->_format = $format;
break;
default:
phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
}
phpCAS::traceEnd();
}
// ########################################################################
// INITIALIZATION
// ########################################################################
/**
* This method is used to initialize the storage. Halts on error.
*
* @public
*/
function init()
{
phpCAS::traceBegin();
// if the storage has already been initialized, return immediatly
if ( $this->isInitialized() )
return;
// call the ancestor's method (mark as initialized)
parent::init();
phpCAS::traceEnd();
}
// ########################################################################
// PGT I/O
// ########################################################################
/**
* This method returns the filename corresponding to a PGT Iou.
*
* @param $pgt_iou the PGT iou.
*
* @return a filename
* @private
*/
function getPGTIouFilename($pgt_iou)
{
phpCAS::traceBegin();
return $this->getPath().$pgt_iou.'.'.$this->getFormat();
phpCAS::traceEnd();
}
/**
* This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
* warning on error.
*
* @param $pgt the PGT
* @param $pgt_iou the PGT iou
*
* @public
*/
function write($pgt,$pgt_iou)
{
phpCAS::traceBegin();
$fname = $this->getPGTIouFilename($pgt_iou);
if ( $f=fopen($fname,"w") ) {
if ( fputs($f,$pgt) === FALSE ) {
phpCAS::error('could not write PGT to `'.$fname.'\'');
}
fclose($f);
} else {
phpCAS::error('could not open `'.$fname.'\'');
}
phpCAS::traceEnd();
}
/**
* This method reads a PGT corresponding to a PGT Iou and deletes the
* corresponding file.
*
* @param $pgt_iou the PGT iou
*
* @return the corresponding PGT, or FALSE on error
*
* @public
*/
function read($pgt_iou)
{
phpCAS::traceBegin();
$pgt = FALSE;
$fname = $this->getPGTIouFilename($pgt_iou);
if ( !($f=fopen($fname,"r")) ) {
phpCAS::trace('could not open `'.$fname.'\'');
} else {
if ( ($pgt=fgets($f)) === FALSE ) {
phpCAS::trace('could not read PGT from `'.$fname.'\'');
}
fclose($f);
}
// delete the PGT file
@unlink($fname);
phpCAS::traceEnd($pgt);
return $pgt;
}
/** @} */
}
?>

View File

@ -1,188 +0,0 @@
<?php
/**
* @file CAS/PGTStorage/pgt-main.php
* Basic class for PGT storage
*/
/**
* @class PGTStorage
* The PGTStorage class is a generic class for PGT storage. This class should
* not be instanciated itself but inherited by specific PGT storage classes.
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorage
*/
class PGTStorage
{
/**
* @addtogroup internalPGTStorage
* @{
*/
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The constructor of the class, should be called only by inherited classes.
*
* @param $cas_parent the CASclient instance that creates the current object.
*
* @protected
*/
function PGTStorage($cas_parent)
{
phpCAS::traceBegin();
if ( !$cas_parent->isProxy() ) {
phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
}
phpCAS::traceEnd();
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This virtual method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @public
*/
function getStorageType()
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/**
* This virtual method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @public
*/
function getStorageInfo()
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
// ########################################################################
// ERROR HANDLING
// ########################################################################
/**
* string used to store an error message. Written by PGTStorage::setErrorMessage(),
* read by PGTStorage::getErrorMessage().
*
* @hideinitializer
* @private
* @deprecated not used.
*/
var $_error_message=FALSE;
/**
* This method sets en error message, which can be read later by
* PGTStorage::getErrorMessage().
*
* @param $error_message an error message
*
* @protected
* @deprecated not used.
*/
function setErrorMessage($error_message)
{
$this->_error_message = $error_message;
}
/**
* This method returns an error message set by PGTStorage::setErrorMessage().
*
* @return an error message when set by PGTStorage::setErrorMessage(), FALSE
* otherwise.
*
* @public
* @deprecated not used.
*/
function getErrorMessage()
{
return $this->_error_message;
}
// ########################################################################
// INITIALIZATION
// ########################################################################
/**
* a boolean telling if the storage has already been initialized. Written by
* PGTStorage::init(), read by PGTStorage::isInitialized().
*
* @hideinitializer
* @private
*/
var $_initialized = FALSE;
/**
* This method tells if the storage has already been intialized.
*
* @return a boolean
*
* @protected
*/
function isInitialized()
{
return $this->_initialized;
}
/**
* This virtual method initializes the object.
*
* @protected
*/
function init()
{
$this->_initialized = TRUE;
}
// ########################################################################
// PGT I/O
// ########################################################################
/**
* This virtual method stores a PGT and its corresponding PGT Iuo.
* @note Should never be called.
*
* @param $pgt the PGT
* @param $pgt_iou the PGT iou
*
* @protected
*/
function write($pgt,$pgt_iou)
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/**
* This virtual method reads a PGT corresponding to a PGT Iou and deletes
* the corresponding storage entry.
* @note Should never be called.
*
* @param $pgt_iou the PGT iou
*
* @protected
*/
function read($pgt_iou)
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/** @} */
}
// include specific PGT storage classes
include_once(dirname(__FILE__).'/pgt-file.php');
include_once(dirname(__FILE__).'/pgt-db.php');
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,277 +0,0 @@
<?php
/**
* @file domxml-php4-php5.php
* Require PHP5, uses built-in DOM extension.
* To be used in PHP4 scripts using DOMXML extension.
* Allows PHP4/DOMXML scripts to run on PHP5/DOM.
* (Requires PHP5/XSL extension for domxml_xslt functions)
*
* Typical use:
* <pre>
* {
* if (version_compare(PHP_VERSION,'5','>='))
* require_once('domxml-php4-to-php5.php');
* }
* </pre>
*
* Version 1.5.5, 2005-01-18, http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*
* ------------------------------------------------------------------<br>
* Written by Alexandre Alapetite, http://alexandre.alapetite.net/cv/
*
* Copyright 2004, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
* http://creativecommons.org/licenses/by-sa/2.0/fr/
* http://alexandre.alapetite.net/divers/apropos/#by-sa
* - Attribution. You must give the original author credit
* - Share Alike. If you alter, transform, or build upon this work,
* you may distribute the resulting work only under a license identical to this one
* - The French law is authoritative
* - Any of these conditions can be waived if you get permission from Alexandre Alapetite
* - Please send to Alexandre Alapetite the modifications you make,
* in order to improve this file for the benefit of everybody
*
* If you want to distribute this code, please do it as a link to:
* http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*/
function domxml_new_doc($version) {return new php4DOMDocument('');}
function domxml_open_file($filename) {return new php4DOMDocument($filename);}
function domxml_open_mem($str)
{
$dom=new php4DOMDocument('');
$dom->myDOMNode->loadXML($str);
return $dom;
}
function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->query($eval_str,$contextnode);}
function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
class php4DOMAttr extends php4DOMNode
{
function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;}
function Name() {return $this->myDOMNode->name;}
function Specified() {return $this->myDOMNode->specified;}
function Value() {return $this->myDOMNode->value;}
}
class php4DOMDocument extends php4DOMNode
{
function php4DOMDocument($filename='')
{
$this->myDOMNode=new DOMDocument();
if ($filename!='') $this->myDOMNode->load($filename);
}
function create_attribute($name,$value)
{
$myAttr=$this->myDOMNode->createAttribute($name);
$myAttr->value=$value;
return new php4DOMAttr($myAttr,$this);
}
function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
function create_text_node($content) {return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);}
function document_element() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
function dump_file($filename,$compressionmode=false,$format=false) {return $this->myDOMNode->save($filename);}
function dump_mem($format=false,$encoding=false) {return $this->myDOMNode->saveXML();}
function get_element_by_id($id) {return new php4DOMElement($this->myDOMNode->getElementById($id),$this);}
function get_elements_by_tagname($name)
{
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this);
$i++;
}
return $nodeSet;
}
function html_dump_mem() {return $this->myDOMNode->saveHTML();}
function root() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
}
class php4DOMElement extends php4DOMNode
{
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
function get_elements_by_tagname($name)
{
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);}
function tagname() {return $this->myDOMNode->tagName;}
}
class php4DOMNode
{
var $myDOMNode;
var $myOwnerDocument;
function php4DOMNode($aDomNode,$aOwnerDocument)
{
$this->myDOMNode=$aDomNode;
$this->myOwnerDocument=$aOwnerDocument;
}
function __get($name)
{
if ($name=='type') return $this->myDOMNode->nodeType;
elseif ($name=='tagname') return $this->myDOMNode->tagName;
elseif ($name=='content') return $this->myDOMNode->textContent;
else
{
$myErrors=debug_backtrace();
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
return false;
}
}
function append_child($newnode) {return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
function append_sibling($newnode) {return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
function attributes()
{
$myDOMNodeList=$this->myDOMNode->attributes;
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function child_nodes()
{
$myDOMNodeList=$this->myDOMNode->childNodes;
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function children() {return $this->child_nodes();}
function clone_node($deep=false) {return new php4DOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
function first_child() {return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
function get_content() {return $this->myDOMNode->textContent;}
function has_attributes() {return $this->myDOMNode->hasAttributes();}
function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
function insert_before($newnode,$refnode) {return new php4DOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);}
function is_blank_node()
{
$myDOMNodeList=$this->myDOMNode->childNodes;
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
if (($node->nodeType==XML_ELEMENT_NODE)||
(($node->nodeType==XML_TEXT_NODE)&&!ereg('^([[:cntrl:]]|[[:space:]])*$',$node->nodeValue)))
return false;
$i++;
}
return true;
}
function last_child() {return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
function new_child($name,$content)
{
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
$this->myDOMNode->appendChild($mySubNode);
return new php4DOMElement($mySubNode,$this->myOwnerDocument);
}
function next_sibling() {return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
function node_name() {return $this->myDOMNode->localName;}
function node_type() {return $this->myDOMNode->nodeType;}
function node_value() {return $this->myDOMNode->nodeValue;}
function owner_document() {return $this->myOwnerDocument;}
function parent_node() {return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
function prefix() {return $this->myDOMNode->prefix;}
function previous_sibling() {return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
function remove_child($oldchild) {return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
function replace_child($oldnode,$newnode) {return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);}
function set_content($text)
{
if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
$this->myDOMNode->removeChild($this->myDOMNode->firstChild);
return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
}
}
class php4DOMNodelist
{
var $myDOMNodelist;
var $nodeset;
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
{
$this->myDOMNodelist=$aDOMNodelist;
$this->nodeset=array();
$i=0;
if (isset($this->myDOMNodelist))
while ($node=$this->myDOMNodelist->item($i))
{
$this->nodeset[]=new php4DOMElement($node,$aOwnerDocument);
$i++;
}
}
}
class php4DOMXPath
{
var $myDOMXPath;
var $myOwnerDocument;
function php4DOMXPath($dom_document)
{
$this->myOwnerDocument=$dom_document;
$this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
}
function query($eval_str,$contextnode)
{
if (isset($contextnode)) return new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument);
else return new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);
}
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
}
if (extension_loaded('xsl'))
{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
class php4DomXsltStylesheet
{
var $myxsltProcessor;
function php4DomXsltStylesheet($dom_document)
{
$this->myxsltProcessor=new xsltProcessor();
$this->myxsltProcessor->importStyleSheet($dom_document);
}
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
{
foreach ($xslt_parameters as $param=>$value)
$this->myxsltProcessor->setParameter('',$param,$value);
$myphp4DOMDocument=new php4DOMDocument();
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
return $myphp4DOMDocument;
}
function result_dump_file($dom_document,$filename)
{
$html=$dom_document->myDOMNode->saveHTML();
file_put_contents($filename,$html);
return $html;
}
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
}
}
?>

View File

@ -1,27 +0,0 @@
<?php
/**
* @file languages/english.php
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'using server',
CAS_STR_AUTHENTICATION_WANTED
=> 'CAS Authentication wanted!',
CAS_STR_LOGOUT
=> 'CAS logout wanted!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'You should already have been redirected to the CAS server. Click <a href="%s">here</a> to continue.',
CAS_STR_AUTHENTICATION_FAILED
=> 'CAS Authentication failed!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>You were not authenticated.</p><p>You may submit your request again by clicking <a href="%s">here</a>.</p><p>If the problem persists, you may contact <a href="mailto:%s">the administrator of this site</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'The service `<b>%s</b>\' is not available (<b>%s</b>).'
);
?>

View File

@ -1,28 +0,0 @@
<?php
/**
* @file languages/english.php
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'utilisant le serveur',
CAS_STR_AUTHENTICATION_WANTED
=> 'Authentication CAS nécessaire&nbsp;!',
CAS_STR_LOGOUT
=> 'Déconnexion demandée&nbsp;!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Vous auriez du etre redirigé(e) vers le serveur CAS. Cliquez <a href="%s">ici</a> pour continuer.',
CAS_STR_AUTHENTICATION_FAILED
=> 'Authentification CAS infructueuse&nbsp;!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Vous n\'avez pas été authentifié(e).</p><p>Vous pouvez soumettre votre requete à nouveau en cliquant <a href="%s">ici</a>.</p><p>Si le problème persiste, vous pouvez contacter <a href="mailto:%s">l\'administrateur de ce site</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'Le service `<b>%s</b>\' est indisponible (<b>%s</b>)'
);
?>

View File

@ -1,27 +0,0 @@
<?php
/**
* @file languages/greek.php
* @author Vangelis Haniotakis <haniotak at ucnet.uoc.gr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> '÷ñçóéìïðïéåßôáé ï åîõðçñåôçôÞò',
CAS_STR_AUTHENTICATION_WANTED
=> 'Áðáéôåßôáé ç ôáõôïðïßçóç CAS!',
CAS_STR_LOGOUT
=> 'Áðáéôåßôáé ç áðïóýíäåóç áðü CAS!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Èá Ýðñåðå íá åß÷áôå áíáêáôåõèõíèåß óôïí åîõðçñåôçôÞ CAS. ÊÜíôå êëßê <a href="%s">åäþ</a> ãéá íá óõíå÷ßóåôå.',
CAS_STR_AUTHENTICATION_FAILED
=> 'Ç ôáõôïðïßçóç CAS áðÝôõ÷å!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Äåí ôáõôïðïéçèÞêáôå.</p><p>Ìðïñåßôå íá îáíáðñïóðáèÞóåôå, êÜíïíôáò êëßê <a href="%s">åäþ</a>.</p><p>Åáí ôï ðñüâëçìá åðéìåßíåé, åëÜôå óå åðáöÞ ìå ôïí <a href="mailto:%s">äéá÷åéñéóôÞ</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'Ç õðçñåóßá `<b>%s</b>\' äåí åßíáé äéáèÝóéìç (<b>%s</b>).'
);
?>

View File

@ -1,24 +0,0 @@
<?php
/**
* @file languages/languages.php
* Internationalization constants
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
//@{
/**
* a phpCAS string index
*/
define("CAS_STR_USING_SERVER", 1);
define("CAS_STR_AUTHENTICATION_WANTED", 2);
define("CAS_STR_LOGOUT", 3);
define("CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED", 4);
define("CAS_STR_AUTHENTICATION_FAILED", 5);
define("CAS_STR_YOU_WERE_NOT_AUTHENTICATED", 6);
define("CAS_STR_SERVICE_UNAVAILABLE", 7);
//@}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,789 +0,0 @@
CREATE TABLE prefix_config (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
value text NOT NULL default '',
CONSTRAINT prefix_config_name_uk UNIQUE (name)
);
CREATE TABLE prefix_config_plugins (
id SERIAL PRIMARY KEY,
plugin varchar(100) NOT NULL default 'core',
name varchar(100) NOT NULL default '',
value text NOT NULL default '',
CONSTRAINT prefix_config_plugins_plugin_name_uk UNIQUE (plugin, name)
);
CREATE TABLE prefix_course (
id SERIAL PRIMARY KEY,
category integer NOT NULL default '0',
sortorder integer NOT NULL default '0',
password varchar(50) NOT NULL default '',
fullname varchar(254) NOT NULL default '',
shortname varchar(15) NOT NULL default '',
idnumber varchar(100) NOT NULL default '',
summary text NOT NULL default '',
format varchar(10) NOT NULL default 'topics',
showgrades integer NOT NULL default '1',
modinfo text,
newsitems integer NOT NULL default '1',
teacher varchar(100) NOT NULL default 'Teacher',
teachers varchar(100) NOT NULL default 'Teachers',
student varchar(100) NOT NULL default 'Student',
students varchar(100) NOT NULL default 'Students',
guest integer NOT NULL default '0',
startdate integer NOT NULL default '0',
enrolperiod integer NOT NULL default '0',
numsections integer NOT NULL default '1',
marker integer NOT NULL default '0',
maxbytes integer NOT NULL default '0',
showreports integer NOT NULL default '0',
visible integer NOT NULL default '1',
hiddensections integer NOT NULL default '0',
groupmode integer NOT NULL default '0',
groupmodeforce integer NOT NULL default '0',
lang varchar(10) NOT NULL default '',
theme varchar(50) NOT NULL default '',
cost varchar(10) NOT NULL default '',
currency varchar(3) NOT NULL default 'USD',
timecreated integer NOT NULL default '0',
timemodified integer NOT NULL default '0',
metacourse integer NOT NULL default '0',
requested integer NOT NULL default '0',
restrictmodules integer NOT NULL default '0',
expirynotify integer NOT NULL default '0',
expirythreshold integer NOT NULL default '0',
notifystudents integer NOT NULL default '0',
enrollable integer NOT NULL default '1',
enrolstartdate integer NOT NULL default '0',
enrolenddate integer NOT NULL default '0',
enrol varchar(20) NOT NULL default '',
defaultrole integer NOT NULL default '0'
);
CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course (category,sortorder);
CREATE INDEX prefix_course_idnumber_idx ON prefix_course (idnumber);
CREATE INDEX prefix_course_shortname_idx ON prefix_course (shortname);
CREATE TABLE prefix_course_categories (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
description text,
parent integer NOT NULL default '0',
sortorder integer NOT NULL default '0',
coursecount integer NOT NULL default '0',
visible integer NOT NULL default '1',
timemodified integer NOT NULL default '0',
depth integer NOT NULL default '0',
path varchar(255) NOT NULL default ''
);
CREATE TABLE prefix_course_display (
id SERIAL PRIMARY KEY,
course integer NOT NULL default '0',
userid integer NOT NULL default '0',
display integer NOT NULL default '0'
);
CREATE INDEX prefix_course_display_courseuserid_idx ON prefix_course_display (course,userid);
CREATE TABLE prefix_course_meta (
id SERIAL primary key,
parent_course integer NOT NULL,
child_course integer NOT NULL
);
CREATE INDEX prefix_course_meta_parent_idx ON prefix_course_meta (parent_course);
CREATE INDEX prefix_course_meta_child_idx ON prefix_course_meta (child_course);
CREATE TABLE prefix_course_modules (
id SERIAL PRIMARY KEY,
course integer NOT NULL default '0',
module integer NOT NULL default '0',
instance integer NOT NULL default '0',
section integer NOT NULL default '0',
added integer NOT NULL default '0',
score integer NOT NULL default '0',
indent integer NOT NULL default '0',
visible integer NOT NULL default '1',
visibleold integer NOT NULL default '1',
groupmode integer NOT NULL default '0'
);
CREATE INDEX prefix_course_modules_visible_idx ON prefix_course_modules (visible);
CREATE INDEX prefix_course_modules_course_idx ON prefix_course_modules (course);
CREATE INDEX prefix_course_modules_module_idx ON prefix_course_modules (module);
CREATE INDEX prefix_course_modules_instance_idx ON prefix_course_modules (instance);
CREATE TABLE prefix_course_sections (
id SERIAL PRIMARY KEY,
course integer NOT NULL default '0',
section integer NOT NULL default '0',
summary text,
sequence text,
visible integer NOT NULL default '1'
);
CREATE INDEX prefix_course_sections_coursesection_idx ON prefix_course_sections (course,section);
CREATE TABLE prefix_course_request (
id SERIAL PRIMARY KEY,
fullname varchar(254) NOT NULL default '',
shortname varchar(15) NOT NULL default '',
summary text NOT NULL default '',
reason text NOT NULL default '',
requester INTEGER NOT NULL default 0,
password varchar(50) NOT NULL default ''
);
CREATE INDEX prefix_course_request_shortname_idx ON prefix_course_request (shortname);
CREATE TABLE prefix_course_allowed_modules (
id SERIAL PRIMARY KEY,
course INTEGER NOT NULL default 0,
module INTEGER NOT NULL default 0
);
CREATE INDEX prefix_course_allowed_modules_course_idx ON prefix_course_allowed_modules (course);
CREATE INDEX prefix_course_allowed_modules_module_idx ON prefix_course_allowed_modules (module);
CREATE TABLE prefix_event (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
description text,
format integer NOT NULL default '0',
courseid integer NOT NULL default '0',
groupid integer NOT NULL default '0',
userid integer NOT NULL default '0',
repeatid integer NOT NULL default '0',
modulename varchar(20) NOT NULL default '',
instance integer NOT NULL default '0',
eventtype varchar(20) NOT NULL default '',
timestart integer NOT NULL default '0',
timeduration integer NOT NULL default '0',
visible integer NOT NULL default '1',
uuid char(36) NOT NULL default '',
sequence integer NOT NULL default '1',
timemodified integer NOT NULL default '0'
);
CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);
CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);
CREATE INDEX prefix_event_timestart_idx ON prefix_event (timestart);
CREATE INDEX prefix_event_timeduration_idx ON prefix_event (timeduration);
CREATE TABLE prefix_grade_category (
id SERIAL PRIMARY KEY,
name varchar(64) default NULL,
courseid integer NOT NULL default '0',
drop_x_lowest integer NOT NULL default '0',
bonus_points integer NOT NULL default '0',
hidden integer NOT NULL default '0',
weight decimal(5,2) default '0.00'
);
CREATE INDEX prefix_grade_category_courseid_idx ON prefix_grade_category (courseid);
CREATE TABLE prefix_grade_exceptions (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
grade_itemid integer NOT NULL default '0',
userid integer NOT NULL default '0'
);
CREATE INDEX prefix_grade_exceptions_courseid_idx ON prefix_grade_exceptions (courseid);
CREATE TABLE prefix_grade_item (
id SERIAL PRIMARY KEY,
courseid integer default NULL,
category integer default NULL,
modid integer default NULL,
cminstance integer default NULL,
scale_grade float(11) default '1.0000000000',
extra_credit integer NOT NULL default '0',
sort_order integer NOT NULL default '0'
);
CREATE INDEX prefix_grade_item_courseid_idx ON prefix_grade_item (courseid);
CREATE TABLE prefix_grade_letter (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
letter varchar(8) NOT NULL default 'NA',
grade_high decimal(6,2) NOT NULL default '100.00',
grade_low decimal(6,2) NOT NULL default '0.00'
);
CREATE INDEX prefix_grade_letter_courseid_idx ON prefix_grade_letter (courseid);
CREATE TABLE prefix_grade_preferences (
id SERIAL PRIMARY KEY,
courseid integer default NULL,
preference integer NOT NULL default '0',
value integer NOT NULL default '0'
);
CREATE UNIQUE INDEX prefix_grade_prefs_courseidpref_uk ON prefix_grade_preferences (courseid,preference);
CREATE TABLE prefix_log (
id SERIAL PRIMARY KEY,
time integer NOT NULL default '0',
userid integer NOT NULL default '0',
ip varchar(15) NOT NULL default '',
course integer NOT NULL default '0',
module varchar(20) NOT NULL default '',
cmid integer NOT NULL default '0',
action varchar(40) NOT NULL default '',
url varchar(100) NOT NULL default '',
info varchar(255) NOT NULL default ''
);
CREATE INDEX prefix_log_coursemoduleaction_idx ON prefix_log (course,module,action);
CREATE INDEX prefix_log_timecoursemoduleaction_idx ON prefix_log (time,course,module,action);
CREATE INDEX prefix_log_courseuserid_idx ON prefix_log (course,userid);
CREATE INDEX prefix_log_userid_idx ON prefix_log (userid);
CREATE INDEX prefix_log_info_idx ON prefix_log (info);
CREATE TABLE prefix_log_display (
id SERIAL PRIMARY KEY,
module varchar(20) NOT NULL default '',
action varchar(40) NOT NULL default '',
mtable varchar(30) NOT NULL default '',
field varchar(200) NOT NULL default ''
);
CREATE INDEX prefix_log_display_moduleaction ON prefix_log_display (module,action);
CREATE TABLE prefix_message (
id SERIAL PRIMARY KEY,
useridfrom integer NOT NULL default '0',
useridto integer NOT NULL default '0',
message text,
format integer NOT NULL default '0',
timecreated integer NOT NULL default '0',
messagetype varchar(50) NOT NULL default ''
);
CREATE INDEX prefix_message_useridfrom_idx ON prefix_message (useridfrom);
CREATE INDEX prefix_message_useridto_idx ON prefix_message (useridto);
CREATE TABLE prefix_message_read (
id SERIAL PRIMARY KEY,
useridfrom integer NOT NULL default '0',
useridto integer NOT NULL default '0',
message text,
format integer NOT NULL default '0',
timecreated integer NOT NULL default '0',
timeread integer NOT NULL default '0',
messagetype varchar(50) NOT NULL default '',
mailed integer NOT NULL default '0'
);
CREATE INDEX prefix_message_read_useridfrom_idx ON prefix_message_read (useridfrom);
CREATE INDEX prefix_message_read_useridto_idx ON prefix_message_read (useridto);
CREATE TABLE prefix_message_contacts (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0',
contactid integer NOT NULL default '0',
blocked integer NOT NULL default '0'
);
CREATE INDEX prefix_message_contacts_useridcontactid_idx ON prefix_message_contacts (userid,contactid);
CREATE TABLE prefix_modules (
id SERIAL PRIMARY KEY,
name varchar(20) NOT NULL default '',
version integer NOT NULL default '0',
cron integer NOT NULL default '0',
lastcron integer NOT NULL default '0',
search varchar(255) NOT NULL default '',
visible integer NOT NULL default '1'
);
CREATE INDEX prefix_modules_name_idx ON prefix_modules (name);
CREATE TABLE prefix_scale (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
userid integer NOT NULL default '0',
name varchar(255) NOT NULL default '',
scale text,
description text,
timemodified integer NOT NULL default '0'
);
CREATE TABLE prefix_sessions2 (
sesskey VARCHAR(255) NOT NULL default '',
expiry TIMESTAMP NOT NULL,
expireref VARCHAR(255),
created TIMESTAMP NOT NULL,
modified TIMESTAMP NOT NULL,
sessdata TEXT,
CONSTRAINT prefix_sess_ses_pk PRIMARY KEY (sesskey)
);
CREATE INDEX prefix_sess_exp_ix ON prefix_sessions2 (expiry);
CREATE INDEX prefix_sess_exp2_ix ON prefix_sessions2 (expireref);
CREATE TABLE prefix_timezone (
id SERIAL PRIMARY KEY,
name varchar(100) NOT NULL default '',
year integer NOT NULL default '0',
tzrule varchar(20) NOT NULL default '',
gmtoff integer NOT NULL default '0',
dstoff integer NOT NULL default '0',
dst_month integer NOT NULL default '0',
dst_startday integer NOT NULL default '0',
dst_weekday integer NOT NULL default '0',
dst_skipweeks integer NOT NULL default '0',
dst_time varchar(5) NOT NULL default '00:00',
std_month integer NOT NULL default '0',
std_startday integer NOT NULL default '0',
std_weekday integer NOT NULL default '0',
std_skipweeks integer NOT NULL default '0',
std_time varchar(5) NOT NULL default '00:00'
);
CREATE TABLE prefix_cache_filters (
id SERIAL PRIMARY KEY,
filter varchar(32) NOT NULL default '',
version integer NOT NULL default '0',
md5key varchar(32) NOT NULL default '',
rawtext text,
timemodified integer NOT NULL default '0'
);
CREATE INDEX prefix_cache_filters_filtermd5key_idx ON prefix_cache_filters (filter,md5key);
CREATE INDEX prefix_scale_courseid_idx ON prefix_scale (courseid);
CREATE TABLE prefix_cache_text (
id SERIAL PRIMARY KEY,
md5key varchar(32) NOT NULL default '',
formattedtext text,
timemodified integer NOT NULL default '0'
);
CREATE INDEX prefix_cache_text_md5key_idx ON prefix_cache_text (md5key);
--
-- Table structure for table `user`
--
-- When updating field length, modify
-- truncate_userinfo() in moodlelib.php
--
CREATE TABLE prefix_user (
id SERIAL PRIMARY KEY,
auth varchar(20) NOT NULL default 'manual',
confirmed integer NOT NULL default '0',
policyagreed integer NOT NULL default '0',
deleted integer NOT NULL default '0',
username varchar(100) NOT NULL default '',
password varchar(32) NOT NULL default '',
idnumber varchar(64) default NULL,
firstname varchar(20) NOT NULL default '',
lastname varchar(20) NOT NULL default '',
email varchar(100) NOT NULL default '',
emailstop integer NOT NULL default '0',
icq varchar(15) default NULL,
skype varchar(50) default NULL,
yahoo varchar(50) default NULL,
aim varchar(50) default NULL,
msn varchar(50) default NULL,
phone1 varchar(20) default NULL,
phone2 varchar(20) default NULL,
institution varchar(40) default NULL,
department varchar(30) default NULL,
address varchar(70) default NULL,
city varchar(20) default NULL,
country char(2) default NULL,
lang varchar(10) NOT NULL default '',
theme varchar(50) NOT NULL default '',
timezone varchar(100) NOT NULL default '99',
firstaccess integer NOT NULL default '0',
lastaccess integer NOT NULL default '0',
lastlogin integer NOT NULL default '0',
currentlogin integer NOT NULL default '0',
lastip varchar(15) default NULL,
secret varchar(15) default NULL,
picture integer default NULL,
url varchar(255) default NULL,
description text,
mailformat integer NOT NULL default '1',
maildigest integer NOT NULL default '0',
maildisplay integer NOT NULL default '2',
htmleditor integer NOT NULL default '1',
ajax integer NOT NULL default '1',
autosubscribe integer NOT NULL default '1',
trackforums integer NOT NULL default '0',
timemodified integer NOT NULL default '0'
);
CREATE UNIQUE INDEX prefix_user_username_uk ON prefix_user (username);
CREATE INDEX prefix_user_idnumber_idx ON prefix_user (idnumber);
CREATE INDEX prefix_user_auth_idx ON prefix_user (auth);
CREATE INDEX prefix_user_deleted_idx ON prefix_user (deleted);
CREATE INDEX prefix_user_confirmed_idx ON prefix_user (confirmed);
CREATE INDEX prefix_user_firstname_idx ON prefix_user (firstname);
CREATE INDEX prefix_user_lastname_idx ON prefix_user (lastname);
CREATE INDEX prefix_user_city_idx ON prefix_user (city);
CREATE INDEX prefix_user_country_idx ON prefix_user (country);
CREATE INDEX prefix_user_lastaccess_idx ON prefix_user (lastaccess);
CREATE INDEX prefix_user_email_idx ON prefix_user (email);
CREATE TABLE prefix_user_admins (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0'
);
CREATE INDEX prefix_user_admins_userid_idx ON prefix_user_admins (userid);
CREATE TABLE prefix_user_preferences (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0',
name varchar(50) NOT NULL default '',
value varchar(255) NOT NULL default ''
);
CREATE INDEX prefix_user_preferences_useridname_idx ON prefix_user_preferences (userid,name);
CREATE TABLE prefix_user_students (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0',
course integer NOT NULL default '0',
timestart integer NOT NULL default '0',
timeend integer NOT NULL default '0',
time integer NOT NULL default '0',
timeaccess integer NOT NULL default '0',
enrol varchar (20) NOT NULL default ''
);
CREATE UNIQUE INDEX prefix_user_students_courseuserid_uk ON prefix_user_students (course,userid);
CREATE INDEX prefix_user_students_userid_idx ON prefix_user_students (userid);
CREATE INDEX prefix_user_students_enrol_idx ON prefix_user_students (enrol);
CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);
CREATE TABLE prefix_user_teachers (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0',
course integer NOT NULL default '0',
authority integer NOT NULL default '3',
role varchar(40) NOT NULL default '',
editall integer NOT NULL default '1',
timestart integer NOT NULL default '0',
timeend integer NOT NULL default '0',
timemodified integer NOT NULL default '0',
timeaccess integer NOT NULL default '0',
enrol varchar (20) NOT NULL default ''
);
CREATE UNIQUE INDEX prefix_user_teachers_courseuserid_uk ON prefix_user_teachers (course,userid);
CREATE INDEX prefix_user_teachers_userid_idx ON prefix_user_teachers (userid);
CREATE INDEX prefix_user_teachers_enrol_idx ON prefix_user_teachers (enrol);
CREATE TABLE prefix_user_coursecreators (
id SERIAL8 PRIMARY KEY,
userid int8 NOT NULL default '0'
);
CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);
CREATE TABLE adodb_logsql (
created timestamp NOT NULL,
sql0 varchar(250) NOT NULL,
sql1 text NOT NULL,
params text NOT NULL,
tracer text NOT NULL,
timer decimal(16,6) NOT NULL
);
CREATE TABLE prefix_stats_daily (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
stattype varchar(20) NOT NULL default 'activity',
stat1 INTEGER NOT NULL default 0,
stat2 INTEGER NOT NULL default 0,
CHECK (stattype::text = 'enrolments' OR stattype::text = 'activity' OR stattype::text = 'logins')
);
CREATE INDEX prefix_stats_daily_courseid_idx ON prefix_stats_daily (courseid);
CREATE INDEX prefix_stats_daily_timeend_idx ON prefix_stats_daily (timeend);
CREATE TABLE prefix_stats_weekly (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
stattype varchar(20) NOT NULL default 'activity',
stat1 INTEGER NOT NULL default 0,
stat2 INTEGER NOT NULL default 0,
CHECK (stattype::text = 'enrolments' OR stattype::text = 'activity' OR stattype::text = 'logins')
);
CREATE INDEX prefix_stats_weekly_courseid_idx ON prefix_stats_weekly (courseid);
CREATE INDEX prefix_stats_weekly_timeend_idx ON prefix_stats_weekly (timeend);
CREATE TABLE prefix_stats_monthly (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
stattype varchar(20) NOT NULL default 'activity',
stat1 INTEGER NOT NULL default 0,
stat2 INTEGER NOT NULL default 0,
CHECK (stattype::text = 'enrolments' OR stattype::text = 'activity' OR stattype::text = 'logins')
);
CREATE INDEX prefix_stats_monthly_courseid_idx ON prefix_stats_monthly (courseid);
CREATE INDEX prefix_stats_monthly_timeend_idx ON prefix_stats_monthly (timeend);
CREATE TABLE prefix_stats_user_daily (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
userid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
statsreads INTEGER NOT NULL default 0,
statswrites INTEGER NOT NULL default 0,
stattype varchar(30) NOT NULL default ''
);
CREATE INDEX prefix_stats_user_daily_courseid_idx ON prefix_stats_user_daily (courseid);
CREATE INDEX prefix_stats_user_daily_userid_idx ON prefix_stats_user_daily (userid);
CREATE INDEX prefix_stats_user_daily_roleid_idx ON prefix_stats_user_daily (roleid);
CREATE INDEX prefix_stats_user_daily_timeend_idx ON prefix_stats_user_daily (timeend);
CREATE TABLE prefix_stats_user_weekly (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
userid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
statsreads INTEGER NOT NULL default 0,
statswrites INTEGER NOT NULL default 0,
stattype varchar(30) NOT NULL default ''
);
CREATE INDEX prefix_stats_user_weekly_courseid_idx ON prefix_stats_user_weekly (courseid);
CREATE INDEX prefix_stats_user_weekly_userid_idx ON prefix_stats_user_weekly (userid);
CREATE INDEX prefix_stats_user_weekly_roleid_idx ON prefix_stats_user_weekly (roleid);
CREATE INDEX prefix_stats_user_weekly_timeend_idx ON prefix_stats_user_weekly (timeend);
CREATE TABLE prefix_stats_user_monthly (
id SERIAL PRIMARY KEY,
courseid INTEGER NOT NULL default 0,
userid INTEGER NOT NULL default 0,
roleid INTEGER NOT NULL default 0,
timeend INTEGER NOT NULL default 0,
statsreads INTEGER NOT NULL default 0,
statswrites INTEGER NOT NULL default 0,
stattype varchar(30) NOT NULL default ''
);
CREATE INDEX prefix_stats_user_monthly_courseid_idx ON prefix_stats_user_monthly (courseid);
CREATE INDEX prefix_stats_user_monthly_userid_idx ON prefix_stats_user_monthly (userid);
CREATE INDEX prefix_stats_user_monthly_roleid_idx ON prefix_stats_user_monthly (roleid);
CREATE INDEX prefix_stats_user_monthly_timeend_idx ON prefix_stats_user_monthly (timeend);
CREATE TABLE prefix_post (
id SERIAL PRIMARY KEY,
module varchar(20) NOT NULL default '',
userid INTEGER NOT NULL default 0,
courseid INTEGER NOT NULL default 0,
groupid INTEGER NOT NULL default 0,
moduleid INTEGER NOT NULL default 0,
coursemoduleid INTEGER NOT NULL default 0,
subject varchar(128) NOT NULL default '',
summary text,
content text,
uniquehash varchar(128) NOT NULL default '',
rating INTEGER NOT NULL default 0,
format INTEGER NOT NULL default 0,
publishstate varchar(10) CHECK (publishstate IN ('draft','site','public')) NOT NULL default 'draft',
lastmodified INTEGER NOT NULL default '0',
created INTEGER NOT NULL default '0'
);
CREATE INDEX prefix_id_user_idx ON prefix_post (id, courseid);
CREATE INDEX prefix_post_lastmodified_idx ON prefix_post (lastmodified);
CREATE INDEX prefix_post_module_idx ON prefix_post (moduleid);
CREATE INDEX prefix_post_subject_idx ON prefix_post (subject);
CREATE TABLE prefix_tags (
id SERIAL PRIMARY KEY,
type varchar(255) NOT NULL default 'official',
userid INTEGER NOT NULL default 0,
text varchar(255) NOT NULL default ''
);
CREATE INDEX prefix_tags_typeuserid_idx ON prefix_tags (type, userid);
CREATE INDEX prefix_tags_text_idx ON prefix_tags (text);
CREATE TABLE prefix_blog_tag_instance (
id SERIAL PRIMARY KEY,
entryid integer NOT NULL default 0,
tagid integer NOT NULL default 0,
groupid integer NOT NULL default 0,
courseid integer NOT NULL default 0,
userid integer NOT NULL default 0,
timemodified integer NOT NULL default 0
);
CREATE INDEX prefix_bti_entryid_idx ON prefix_blog_tag_instance (entryid);
CREATE INDEX prefix_bti_tagid_idx ON prefix_blog_tag_instance (tagid);
# Roles tables
CREATE TABLE prefix_role (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
shortname varchar(100) NOT NULL default '',
description text NOT NULL default '',
sortorder integer NOT NULL default '0'
);
CREATE INDEX prefix_role_sortorder_idx ON prefix_role (sortorder);
CREATE TABLE prefix_context (
id SERIAL PRIMARY KEY,
contextlevel integer NOT NULL default 0,
instanceid integer NOT NULL default 0
);
CREATE INDEX prefix_context_instanceid_idx ON prefix_context (instanceid);
CREATE UNIQUE INDEX prefix_context_contextlevelinstanceid_idx ON prefix_context (contextlevel, instanceid);
CREATE TABLE prefix_role_assignments (
id SERIAL PRIMARY KEY,
roleid integer NOT NULL default 0,
contextid integer NOT NULL default 0,
userid integer NOT NULL default 0,
hidden integer NOT NULL default 0,
timestart integer NOT NULL default 0,
timeend integer NOT NULL default 0,
timemodified integer NOT NULL default 0,
modifierid integer NOT NULL default 0,
enrol varchar(20) NOT NULL default '',
sortorder integer NOT NULL default '0'
);
CREATE INDEX prefix_role_assignments_roleid_idx ON prefix_role_assignments (roleid);
CREATE INDEX prefix_role_assignments_contextidid_idx ON prefix_role_assignments (contextid);
CREATE INDEX prefix_role_assignments_userid_idx ON prefix_role_assignments (userid);
CREATE UNIQUE INDEX prefix_role_assignments_contextidroleiduserid_idx ON prefix_role_assignments (contextid, roleid, userid);
CREATE INDEX prefix_role_assignments_sortorder_idx ON prefix_role_assignments (sortorder);
CREATE TABLE prefix_role_capabilities (
id SERIAL PRIMARY KEY,
contextid integer NOT NULL default 0,
roleid integer NOT NULL default 0,
capability varchar(255) NOT NULL default '',
permission integer NOT NULL default 0,
timemodified integer NOT NULL default 0,
modifierid integer NOT NULL default 0
);
CREATE INDEX prefix_role_capabilities_roleid_idx ON prefix_role_capabilities (roleid);
CREATE INDEX prefix_role_capabilities_contextid_idx ON prefix_role_capabilities (contextid);
CREATE INDEX prefix_role_capabilities_modifierid_idx ON prefix_role_capabilities (modifierid);
CREATE UNIQUE INDEX prefix_role_capabilities_roleidcontextidcapability_idx ON prefix_role_capabilities (roleid, contextid, capability);
CREATE TABLE prefix_role_allow_assign (
id SERIAL PRIMARY KEY,
roleid integer NOT NULL default '0',
allowassign integer NOT NULL default '0'
);
CREATE INDEX prefix_role_allow_assign_roleid_idx ON prefix_role_allow_assign (roleid);
CREATE INDEX prefix_role_allow_assign_allowassign_idx ON prefix_role_allow_assign (allowassign);
CREATE UNIQUE INDEX prefix_role_allow_assign_roleidallowassign_idx ON prefix_role_allow_assign (roleid, allowassign);
CREATE TABLE prefix_role_allow_override (
id SERIAL PRIMARY KEY,
roleid integer NOT NULL default '0',
allowoverride integer NOT NULL default '0'
);
CREATE INDEX prefix_role_allow_override_roleid_idx ON prefix_role_allow_override (roleid);
CREATE INDEX prefix_role_allow_override_allowoverride_idx ON prefix_role_allow_override (allowoverride);
CREATE UNIQUE INDEX prefix_role_allow_override_roleidallowoverride_idx ON prefix_role_allow_override (roleid, allowoverride);
CREATE TABLE prefix_capabilities (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL default '',
captype varchar(50) NOT NULL default '',
contextlevel integer NOT NULL default 0,
component varchar(100) NOT NULL default '',
riskbitmask integer NOT NULL default 0
);
CREATE UNIQUE INDEX prefix_capabilities_name_idx ON prefix_capabilities (name);
CREATE TABLE prefix_role_names (
id SERIAL PRIMARY KEY,
roleid integer NOT NULL default 0,
contextid integer NOT NULL default 0,
text text NOT NULL default ''
);
CREATE INDEX prefix_role_names_roleid_idx ON prefix_role_names (roleid);
CREATE INDEX prefix_role_names_contextid_idx ON prefix_role_names (contextid);
CREATE UNIQUE INDEX prefix_role_names_roleidcontextid_idx ON prefix_role_names (roleid, contextid);
CREATE TABLE prefix_user_lastaccess (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default 0,
courseid integer NOT NULL default 0,
timeaccess integer NOT NULL default 0
);
CREATE INDEX prefix_user_lastaccess_userid_idx ON prefix_user_lastaccess (userid);
CREATE INDEX prefix_user_lastaccess_courseid_idx ON prefix_user_lastaccess (courseid);
CREATE UNIQUE INDEX prefix_user_lastaccess_useridcourseid_idx ON prefix_user_lastaccess (userid, courseid);
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('user', 'view', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'view', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'update', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'enrol', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'report log', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'report live', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'report outline', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'report participation', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('course', 'report stats', 'course', 'fullname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'write', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'read', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'add contact', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'firstname||\' \'||lastname');
CREATE TABLE prefix_user_info_field (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
datatype VARCHAR(255) NOT NULL default '',
categoryid BIGINT NOT NULL default 0,
sortorder BIGINT NOT NULL default 0,
required SMALLINT NOT NULL default 0,
locked SMALLINT NOT NULL default 0,
visible SMALLINT NOT NULL default 0,
defaultdata TEXT,
CONSTRAINT prefix_userinfofiel_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_field IS 'Customisable user profile fields';
CREATE TABLE prefix_user_info_category (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
sortorder BIGINT NOT NULL default 0,
CONSTRAINT prefix_userinfocate_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_category IS 'Customisable fields categories';
CREATE TABLE prefix_user_info_data (
id BIGSERIAL,
userid BIGINT NOT NULL default 0,
fieldid BIGINT NOT NULL default 0,
data TEXT NOT NULL,
CONSTRAINT prefix_userinfodata_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_data IS 'Data for the customisable user fields';

View File

@ -1391,6 +1391,10 @@ function xmldb_main_upgrade($oldversion=0) {
}
if ($result && $oldversion < 2007070603) {
// Small update of guest user to be 100% sure it has the correct mnethostid (MDL-10375)
set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'username', 'guest');
}
return $result;
}

Some files were not shown because too many files have changed in this diff Show More