Commit 4d7135da authored by Richard Mansfield's avatar Richard Mansfield

Fix joining of open groups

parent 33de3a0e
......@@ -60,6 +60,10 @@ class GroupTypeCourse extends GroupType {
return array('tutor');
}
public static function default_role() {
return 'member';
}
}
?>
......@@ -55,6 +55,7 @@ abstract class GroupType {
insert_record('grouptype', (object) array(
'name' => $type,
'submittableto' => !empty($assessingroles),
'defaultrole' => $this->default_role(),
));
$roles = $this->get_roles();
if (!in_array('admin', $roles)) {
......
......@@ -54,6 +54,10 @@ class GroupTypeStandard extends GroupType {
return array();
}
public static function default_role() {
return 'member';
}
}
?>
......@@ -223,7 +223,8 @@
<TABLE NAME="grouptype">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="20" NOTNULL="true" />
<FIELD NAME="takesviewsubmissions" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="submittableto" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="defaultrole" TYPE="char" LENGTH="255" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
......
......@@ -1187,6 +1187,12 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2008062308) {
execute_sql('ALTER TABLE {grouptype} ADD COLUMN defaultrole VARCHAR(255)');
execute_sql("UPDATE {grouptype} SET defaultrole = 'member'");
execute_sql('ALTER TABLE {grouptype} ALTER COLUMN defaultrole SET NOT NULL');
}
return $status;
}
......
......@@ -271,13 +271,18 @@ function group_user_can_edit_views($groupid, $userid=null) {
*
* @param int $groupid
* @param int $userid
* @param string $role
*/
function group_add_member($groupid, $userid) {
function group_add_member($groupid, $userid, $role=null) {
$cm = new StdClass;
$cm->member = $userid;
$cm->group = $groupid;
$cm->ctime = db_format_timestamp(time());
$cm->tutor = 0;
if (!$role) {
$role = get_field_sql('SELECT gt.defaultrole FROM {grouptype} gt, {group} g WHERE g.id = ? AND g.grouptype = gt.name', array($groupid));
}
$cm->role = $role;
insert_record('group_member', $cm);
$user = optional_userobj($userid);
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008062307;
$config->version = 2008062308;
$config->release = '1.1.0alpha';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment