*/
$success = (bool)$groupid = groups_create_group($courseid); //$groupsettings);
- if ($groupingid != GROUP_NOT_IN_GROUPING) {
- $success = groups_add_group_to_grouping($groupid, $groupingid);
- }
}
elseif ($groupingid != $newgrouping) { //OK, move group.
// Allow groups to be created outside of groupings
"-> $strgroups", '', '', true, '', user_login_string($course, $USER));
$usehtmleditor = false;
-?>
-<h3 class="main"><?php echo $strheading ?></h3>
-<form action="group.php" method="post" enctype="multipart/form-data" class="mform notmform" id="groupform">
+ echo '<h3 class="main">' . $strheading . '</h3>'."\n";
+
+ echo '<form action="group.php" method="post" enctype="multipart/form-data" class="mform notmform" id="groupform">'."\n";
+ echo '<div>'."\n";
+ echo '<input type="hidden" name="sesskey" value="' . s(sesskey()) . '" />'."\n";
+ echo '<input type="hidden" name="courseid" value="' . s($courseid) . '" />'."\n";
+ echo '<input type="hidden" name="grouping" value="' . s($groupingid) . '" />'."\n";
-<input type="hidden" name="sesskey" value="<?php p(sesskey()); ?>" />
-<input type="hidden" name="courseid" value="<?php p($courseid); ?>" />
-<input type="hidden" name="grouping" value="<?php p($groupingid); ?>" />
-<?php
if ($groupid) {
- echo '<input type="hidden" name="group" value="'. $groupid .'" />';
+ echo '<input type="hidden" name="group" value="'. $groupid .'" />'."\n";
}
if ($delete) {
/*echo 'Are you sure you want to delete group X ?';
choose_from_menu_yesno('confirmdelete', false, '', true);*/
-?>
- <p><?php print_string('deletegroupconfirm', 'group', $strname); ?></p>
- <input type="hidden" name="delete" value="1" />
- <input type="submit" name="confirmdelete" value="<?php print_string('yes'); ?>" />
- <input type="submit" name="cancel" value="<?php print_string('no'); ?>" />
-<?php
+ echo '<p>' . get_string('deletegroupconfirm', 'group', $strname) . '</p>'."\n";
+ echo '<input type="hidden" name="delete" value="1" />'."\n";
+ echo '<input type="submit" name="confirmdelete" value="' . get_string('yes') . '" />'."\n";
+ echo '<input type="submit" name="cancel" value="' . get_string('no') . '" />'."\n";
} else {
-?>
-
-<div class="fitem">
-<p><label for="groupname"><?php
- print_string('groupname', 'group');
- if (isset($err['name'])) {
- echo' ';
- formerr($err['name']);
- } ?> </label></p>
-<p class="felement"><input id="groupname" name="name" type="text" size="40" value="<?php echo $strname; ?>" /></p>
-</div>
-
-<p><label for="edit-description"><?php print_string('groupdescription', 'group'); ?> </label></p>
-<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, 'description', $strdesc); ?></p>
-
-<p><label for="enrolmentkey"><?php print_string('enrolmentkey', 'group'); ?> </label></p>
-<p><input id="enrolmentkey" name="enrolmentkey" type="text" size="25" /></p>
-
-<?php if ($printuploadpicture) { ?>
- <p><label for="menuhidepicture"><?php print_string('hidepicture', 'group'); ?> </label></p>
- <p><?php $options = array();
- $options[0] = get_string('no');
- $options[1] = get_string('yes');
- choose_from_menu($options, 'hidepicture', isset($group)? $group->hidepicture: 1, '');?></p>
-
- <p><label ><?php /* for="imagefile" */ print_string('newpicture', 'group');
- helpbutton('picture', get_string('helppicture'));
- print_string('maxsize', '', display_size($maxbytes), 'group');
- if (isset($err['imagefile'])) formerr($err['imagefile']);
- ?> </label></p>
- <p><?php upload_print_form_fragment(1, array('imagefile'), null,false,null,0,0,false); ?></p>
-<?php
- }
-
- if ($groupid) { //OK, editing - option to move grouping.
-?>
- <p><label for="groupings"><?php print_string('addgroupstogrouping', 'group'); ?></label></p>
- <select name="newgrouping" id="groupings" class="select">
-<?php
- $groupingids = groups_get_groupings($courseid);
- if (GROUP_NOT_IN_GROUPING == $groupingid) {
- $groupingids[] = GROUP_NOT_IN_GROUPING;
- }
- if ($groupingids) {
- // Put the groupings into a hash and sort them
- foreach($groupingids as $id) {
- $listgroupings[$id] = groups_get_grouping_displayname($id, $courseid);
- }
- natcasesort($listgroupings);
+ echo '<div class="fitem">'."\n";
+ echo '<p><label for="groupname">' . get_string('groupname', 'group');
- // Print out the HTML
- $count = 1;
- foreach($listgroupings as $id => $name) {
- $select = '';
- if ($groupingid == $id) {
- $select = ' selected="selected"';
+ if (isset($err['name'])) {
+ echo ' ';
+ formerr($err['name']);
+ }
+
+ echo ' </label></p>'."\n";
+ echo '<p class="felement"><input id="groupname" name="name" type="text" size="40" value="' . $strname . '" /></p>'."\n";
+ echo '</div>'."\n";
+
+ echo '<p><label for="edit-description">' . get_string('groupdescription', 'group') . ' </label></p>'."\n";
+ echo '<p>' . print_textarea($usehtmleditor, 5, 45, 200, 400, 'description', $strdesc, 0, true) . '</p>'."\n";
+
+ echo '<p><label for="enrolmentkey">' . get_string('enrolmentkey', 'group') . ' </label></p>'."\n";
+ echo '<p><input id="enrolmentkey" name="enrolmentkey" type="text" size="25" /></p>'."\n";
+
+ if ($printuploadpicture) {
+ echo '<p><label for="menuhidepicture">' . get_string('hidepicture', 'group') . ' </label></p>'."\n";
+ echo '<p>';
+ $options = array();
+ $options[0] = get_string('no');
+ $options[1] = get_string('yes');
+ choose_from_menu($options, 'hidepicture', isset($group)? $group->hidepicture: 1, '');
+ echo '</p>'."\n";
+
+ echo '<p><label >' . get_string('newpicture', 'group');
+ helpbutton('picture', get_string('helppicture'));
+ echo get_string('maxsize', '', display_size($maxbytes), 'group');
+
+ if (isset($err['imagefile'])) {
+ formerr($err['imagefile']);
}
- echo "<option value=\"$id\"$select>$name</option>\n";
- $count++;
+
+ echo ' </label></p>'."\n";
+ echo '<p>' . upload_print_form_fragment(1, array('imagefile'), null,false,null,0,0,true) . '</p>'."\n";
}
- }
-?>
- </select>
-<?php } //IF($groupid) ?>
-<p class="fitem">
- <label for="id_submit"> </label>
- <span class="f--element fsubmit">
- <input type="submit" name="update" id="id_submit" value="<?php echo $strbutton; ?>" />
- <input type="submit" name="cancel" value="<?php print_string('cancel', 'group'); ?>" />
- </span>
-</p>
+ if ($groupid) { //OK, editing - option to move grouping.
-<?php } //IF($delete) ?>
+ echo '<p><label for="groupings">' . get_string('addgroupstogrouping', 'group'). '</label></p>'."\n";
+ echo '<select name="newgrouping" id="groupings" class="select">'."\n";
-<span class="clearer"> </span>
+ $groupingids = groups_get_groupings($courseid);
+ if (GROUP_NOT_IN_GROUPING == $groupingid) {
+ $groupingids[] = GROUP_NOT_IN_GROUPING;
+ }
+ if ($groupingids) {
+ // Put the groupings into a hash and sort them
+ foreach($groupingids as $id) {
+ $listgroupings[$id] = groups_get_grouping_displayname($id, $courseid);
+ }
+ natcasesort($listgroupings);
+
+ // Print out the HTML
+ $count = 1;
+ foreach($listgroupings as $id => $name) {
+ $select = '';
+ if ($groupingid == $id) {
+ $select = ' selected="selected"';
+ }
+ echo "<option value=\"$id\"$select>$name</option>\n";
+ $count++;
+ }
+ }
+
+ echo '</select>'."\n";
+ } //IF($groupid)
+
+ echo '<p class="fitem">'."\n";
+ echo '<label for="id_submit"> </label>'."\n";
+ echo '<span class="f--element fsubmit">'."\n";
+ echo '<input type="submit" name="update" id="id_submit" value="' . $strbutton . '" />'."\n";
+ echo '<input type="submit" name="cancel" value="' . get_string('cancel', 'group') . '" />'."\n";
+ echo '</span>'."\n";
+ echo '</p>'."\n";
+
+ } //IF($delete)
+
+ echo '<span class="clearer"> </span>'."\n";
+ echo '</div>';
+ echo '</form>'."\n";
-</form>
-<?php
print_footer($course);
}
*/
redirect(groups_group_edit_url($courseid, null, $groupingid, false));
break;
+ case 'showcreateorphangroupform':
+ redirect(groups_group_edit_url($courseid, null, null, false));
+ break;
case 'addgroupstogroupingform':
break;
case 'updategroups': //Currently reloading.
"-> $strgroups", '', '', true, '', user_login_string($course, $USER));
$usehtmleditor = false;
- //TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finised.
- $shownotdone = false;
+ //TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finished.
+ $shownotdone = false;
+ $disabled = 'disabled="disabled"';
+
+ // Pre-disable buttons based on URL variables
+ if (isset($groupingid) && $groupingid > -1) {
+ $showeditgroupsettingsform_disabled = '';
+ $showeditgroupingsettingsform_disabled = '';
+ $deletegroup_disabled = '';
+ $deletegrouping_disabled = '';
+ $printerfriendly_disabled = '';
+ $showcreategroupform_disabled = '';
+ } else {
+ $showeditgroupsettingsform_disabled = $disabled;
+ $showeditgroupingsettingsform_disabled = $disabled;
+ $deletegroup_disabled = $disabled;
+ $deletegrouping_disabled = $disabled;
+ $printerfriendly_disabled = $disabled;
+ $showcreategroupform_disabled = $disabled;
+ }
+
+ if (isset($groupid)) {
+ $showaddmembersform_disabled = '';
+ $showeditgroupsettingsform_disabled = '';
+ $deletegroup_disabled = '';
+ } else {
+ $deletegroup_disabled = $disabled;
+ $showeditgroupsettingsform_disabled = $disabled;
+ $showaddmembersform_disabled = $disabled;
+ }
print_heading(format_string($course->shortname) .' '.$strgroups, 'center', 3);
echo '<form id="groupeditform" action="index.php" method="post">'."\n";
}
echo '</select>'."\n";
+
echo '<p><input type="submit" name="act_updategroups" id="updategroups" value="'
. get_string('showgroupsingrouping', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" name="act_showgroupingsettingsform" id="showeditgroupingsettingsform" value="'
+ echo '<p><input type="submit" ' . $showeditgroupingsettingsform_disabled . ' name="act_showgroupingsettingsform" id="showeditgroupingsettingsform" value="'
. get_string('editgroupingsettings', 'group') . '" /></p>'."\n";
if ($shownotdone) {
- echo '<p><input type="submit" disabled="disabled" name="act_showgroupingpermsform" '
+ echo '<p><input type="submit" '.$disabled.' name="act_showgroupingpermsform" '
. 'id="showeditgroupingpermissionsform" value="'
. get_string('editgroupingpermissions', 'group') . '" /></p>'."\n";
}
- echo '<p><input type="submit" name="act_deletegrouping" id="deletegrouping" value="'
+ echo '<p><input type="submit" ' . $deletegrouping_disabled . ' name="act_deletegrouping" id="deletegrouping" value="'
. get_string('deletegrouping', 'group') . '" /></p>'."\n";
echo '<p><input type="submit" name="act_showcreategroupingform" id="showcreategroupingform" value="'
. get_string('creategrouping', 'group') . '" /></p>'."\n";
if ($shownotdone) {
- echo '<p><input type="submit" disabled="disabled" name="act_createautomaticgroupingform" '
+ echo '<p><input type="submit" '.$disabled.' name="act_createautomaticgroupingform" '
. 'id="showcreateautomaticgroupingform" value="'
. get_string('createautomaticgrouping', 'group') . '" /></p>'."\n";
}
- echo '<p><input type="submit" name="act_printerfriendly" id="printerfriendly" value="'
+ 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 '<p><label for="groups" id="groupslabel">' .get_string('groupsinselectedgrouping', 'group') . '</label></p>'."\n";
echo '</select>'."\n";
echo '<p><input type="submit" name="act_updatemembers" id="updatemembers" value="'
. get_string('showmembersforgroup', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" name="act_showgroupsettingsform" id="showeditgroupsettingsform" value="'
+ echo '<p><input type="submit" '. $showeditgroupsettingsform_disabled . ' name="act_showgroupsettingsform" id="showeditgroupsettingsform" value="'
. get_string('editgroupsettings', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" name="act_deletegroup" onclick="onDeleteGroup()" id="deletegroup" value="'
+ echo '<p><input type="submit" '. $deletegroup_disabled . ' name="act_deletegroup" onclick="onDeleteGroup()" id="deletegroup" value="'
. get_string('deleteselectedgroup', 'group') . '" /></p>'."\n";
if ($shownotdone) {
- echo '<p><input type="submit" disabled="disabled" name="act_removegroup" '
+ echo '<p><input type="submit" '.$disabled.' name="act_removegroup" '
. 'id="removegroup" value="' . get_string('removegroupfromselectedgrouping', 'group') . '" /></p>'."\n";
}
- echo '<p><input type="submit" name="act_showcreategroupform" id="showcreategroupform" value="'
+ echo '<p><input type="submit" ' . $showcreategroupform_disabled . ' name="act_showcreategroupform" id="showcreategroupform" value="'
. get_string('creategroupinselectedgrouping', 'group') . '" /></p>'."\n";
-
+
+ echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
+ . get_string('createorphangroup', 'group') . '" /></p>'."\n";
+
if ($shownotdone) {
- echo '<p><input type="submit" disabled="disabled" name="act_addgroupstogroupingform" '
+ echo '<p><input type="submit" '.$disabled.' name="act_addgroupstogroupingform" '
. 'id="showaddgroupstogroupingform" value="' . get_string('addgroupstogrouping', 'group') . '" /></p>'."\n";
}
echo '</select>'."\n";
if ($shownotdone) {
- echo '<p><input type="submit" disabled="disabled" name="act_removemembers" '
+ echo '<p><input type="submit" '.$disabled.' name="act_removemembers" '
. 'id="removemembers" value="' . get_string('removeselectedusers', 'group') . '"/></p>'."\n";
}
- echo '<p><input type="submit" name="act_showaddmembersform" '
+ echo '<p><input type="submit" ' . $showaddmembersform_disabled . ' name="act_showaddmembersform" '
. 'id="showaddmembersform" value="' . get_string('adduserstogroup', 'group'). '" /></p>'."\n";
echo '</td>'."\n";
echo '</tr>'."\n";
selectEl.removeChild(selectEl.firstChild);
}
}
+
+ if (groupingId > -1) {
+ document.getElementById("showaddmembersform").disabled = true;
+ document.getElementById("showeditgroupingsettingsform").disabled = false;
+ document.getElementById("deletegrouping").disabled = false;
+ document.getElementById("printerfriendly").disabled = false;
+ document.getElementById("showeditgroupsettingsform").disabled = true;
+ document.getElementById("deletegroup").disabled = true;
+ document.getElementById("showcreategroupform").disabled = false;
+ } else {
+ document.getElementById("showeditgroupingsettingsform").disabled = true;
+ document.getElementById("deletegrouping").disabled = true;
+ document.getElementById("showcreategroupform").disabled = true;
+ }
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&grouping="+groupingId+"&act_ajax_getgroupsingrouping";
YAHOO.util.Connect.asyncRequest('GET', sUrl, this.connectCallback, null);
/**
* When a group is selected, we need to update the members.
+ * The Add/Remove Users button also needs to be disabled/enabled
+ * depending on whether or not a group is selected
*/
UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
// Add the loader gif image.
selectEl.removeChild(selectEl.firstChild);
}
}
-
+
+ document.getElementById("showaddmembersform").disabled = false;
+ document.getElementById("showeditgroupsettingsform").disabled = false;
+ document.getElementById("deletegroup").disabled = false;
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&group="+groupId+"&act_ajax_getmembersingroup";
YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
};