- required_param calls - added parameter type.
- put 'require' first.
- use @header, added charset.
(Bug MDL-7380 "groups".)
<?php
-/**********************************************
- * Adds an existing group to a grouping
- **********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
+/**
+ * Adds an existing group to a grouping.
+ *
+ * @copyright © 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');
-$courseid = required_param('courseid', PARAM_INT);
+$groups = required_param('groups', PARAM_SEQUENCE); //TODO: check.
require_login($courseid);
/**********************************************
* Adds users to a group
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
require_once('../../config.php');
require_once('../lib/lib.php');
-$groupid = required_param('groupid', PARAM_INT);
-$users = required_param('users');
+@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);
* Sets up an automatic grouping
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
-
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);
+$courseid = required_param('courseid', PARAM_INT);
$noofstudents = required_param('noofstudents', PARAM_INT);
$noofgroups = required_param('noofgroups', PARAM_INT);
-$distribevenly = required_param('distribevenly');
-$alphabetical = required_param('alphabetical');
-$generationtype = required_param('generationtype');
+$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');
-$groupingsettings->description = required_param('description');
+$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') {
<div id="creategroupform" class="popup">
<h3><?php print_string('creategroup', 'group'); ?> <span id="selectedgroupingforcreatinggroup"></span></h3>
<form action="">
- <p><?php print_string('groupname', 'groups');?></p>
+ <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", 'groups') ?><br />
+ <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', 'groups') ?></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', 'groups') ?></p>
- <p><?php $options = NULL; $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu ($options, "newgrouphidepicture", $group->hidepicture, "");?>
- ></p>
+ <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", 'groups') ?></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'); ?>
/**********************************************
* Adds a new group to a grouping
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
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');
-$courseid = required_param('courseid', PARAM_INT);
-$groupsettings->description = required_param('description');
-$groupsettings->enrolmentkey = required_param('enrolmentkey', PARAM_ALPHANUM);
-$groupsettings->hidepicture = optional_param('hidepicture');
+$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);
/**********************************************
* Adds a new grouping
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
require_once('../../config.php');
require_once('../lib/lib.php');
-$courseid= required_param('courseid', PARAM_INT);
+@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');
-$groupingsettings->description = required_param('description');
+$groupingsettings->name = required_param('groupingname', PARAM_ALPHANUM);
+$groupingsettings->description= required_param('description', PARAM_ALPHANUM);
require_login($courseid);
/**********************************************
* Deletes a group
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
require_once('../../config.php');
require_once('../lib/lib.php');
-$groupid = required_param('groupid', PARAM_INT);
+@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);
* Deletes a specified grouping
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
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);
+$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
/**********************************************
* Adds a new grouping
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
require_once('../../config.php');
require_once('../lib/lib.php');
-$groupingid = required_param('groupingid');
-$courseid = required_param('courseid', PARAM_INT);
-$groupingsettings->viewowngroup = required_param('viewowngroup');
-$groupingsettings->viewallgroupsmembers = required_param('viewallgroupsmembers');
-$groupingsettings->viewallgroupsactivities = required_param('viewallgroupsactivities');
-$groupingsettings->teachersgroupmark = required_param('teachersgroupmark');
-$groupingsettings->teachersgroupview = required_param('teachersgroupview');
-$groupingsettings->teachersoverride = required_param('teachersoverride');
+@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);
/**********************************************
* Adds a new grouping
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
require_once('../../config.php');
require_once('../lib/lib.php');
-$groupingid = required_param('groupingid');
-$courseid = required_param('courseid', PARAM_INT);
-$groupingsettings->name =required_param('groupingname');
-$groupingsettings->description = required_param('description');
+@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);
* Adds a new grouping
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
require_once('../../config.php');
require_once('../lib/lib.php');
-$groupid = required_param('groupid');
-$groupname = required_param('groupname');
-$description = required_param('description');
-$enrolmentkey = required_param('enrolmentkey');
-$hidepicture = required_param('hidepicture');
-$courseid = required_param('courseid', PARAM_INT);
+
+@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);
* them in an XML format
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
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);
+$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
require_login($courseid);
* and returns them in an XML format
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
+require_once('../../config.php');
+require_once('../lib/lib.php');
-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);
* Fetches the settings of a grouping and returns
* them in an XML format
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
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);
+$courseid = required_param('courseid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
require_login($courseid);
* Fetches the settings of a grouping and returns
* them in an XML format
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-
-require_once("../../config.php");
-require_once("../lib/lib.php");
+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);
+$groupid = required_param('groupid', PARAM_INT);
+
require_login($courseid);
if (confirm_sesskey() and isteacheredit($courseid)) {
/**********************************************
* Adds an existing group to a grouping
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-require_once("../../config.php");
-require_once("../lib/lib.php");
+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);
+$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
* Gets the groups not in a grouping for a course
* and returns them in an XML format
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-require_once("../lib/lib.php");
-require_once("../../config.php");
+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');
-$courseid = required_param('courseid');
+$groupingid = required_param('groupingid', PARAM_INT);
+$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
* Gets the members of a group and returns them
* in an XMl format
**********************************************/
-
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-require_once("../../config.php");
-require_once("../lib/lib.php");
+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);
+$groupid = required_param('groupid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
* their detailsin an XML format.
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
-require_once("../../config.php");
-require_once("../lib/lib.php");
+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);
+$groupid = required_param('groupid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
-$courseid = required_param('courseid', PARAM_INT);
-$showall = required_param('showall', PARAM_INT);
+$courseid = required_param('courseid', PARAM_INT);
+$showall = required_param('showall', PARAM_INT);
require_login($courseid);
* (but does not delete the group)
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
+require_once('../../config.php');
+require_once('../lib/lib.php');
-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);
+$groupid = required_param('groupid', PARAM_INT);
$groupingid = required_param('groupingid', PARAM_INT);
-$courseid = required_param('courseid', PARAM_INT);
+$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);
<?php
-
/**********************************************
* Takes a groupid and comma-separated list of
* userids, and removes each of those userids
* from the specified group
**********************************************/
-header("Content-Type: text/xml");
-echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
-echo '<groupsresponse>';
+require_once('../../config.php');
+require_once('../lib/lib.php');
-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');
+$groupid = required_param('groupid', PARAM_INT);
+$users = required_param('users', PARAM_SEQUENCE);
$courseid = required_param('courseid', PARAM_INT);
require_login($courseid);