Commit 6a9447d3 authored by Nigel McNie's avatar Nigel McNie
Browse files

Add setting to group create/edit pages to allow changing the 'public' setting.

This also adds a database column to store the setting.

Whether this setting is even settable is controled by the site setting added in the previous commit.

Changes to each group file to make them visible to the public are coming in the next commit.
parent bcc6034b
......@@ -55,6 +55,16 @@ $creategroup = pieform(array(
'defaultvalue' => 'standard.open',
'help' => true,
),
'public' => array(
'type' => 'select',
'title' => get_string('publiclyviewablegroup', 'group'),
'description' => get_string('publiclyviewablegroupdescription', 'group'),
'options' => array(true => get_string('yes'),
false => get_string('no')),
'defaultvalue' => 'no',
'help' => true,
'ignore' => !(get_config('createpublicgroups') == 'all' || get_config('createpublicgroups') == 'admins' && $USER->get('admin')),
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('savegroup', 'group'), get_string('cancel')),
......@@ -85,12 +95,14 @@ function creategroup_submit(Pieform $form, $values) {
global $SESSION;
list($grouptype, $jointype) = explode('.', $values['grouptype']);
$values['public'] = (isset($values['public'])) ? $values['public'] : 0;
$id = group_create(array(
'name' => $values['name'],
'description' => $values['description'],
'grouptype' => $grouptype,
'jointype' => $jointype,
'public' => intval($values['public']),
'members' => array($USER->get('id') => 'admin'),
));
......
......@@ -34,7 +34,7 @@ define('TITLE', get_string('editgroup', 'group'));
$id = param_integer('id');
define('GROUP', $id);
$group_data = get_record_sql("SELECT g.name, g.description, g.grouptype, g.jointype
$group_data = get_record_sql("SELECT g.name, g.description, g.grouptype, g.jointype, g.public
FROM {group} g
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')
WHERE g.id = ?
......@@ -71,6 +71,16 @@ $editgroup = pieform(array(
'defaultvalue' => $group_data->grouptype . '.' . $group_data->jointype,
'help' => true,
),
'public' => array(
'type' => 'select',
'title' => get_string('publiclyviewablegroup', 'group'),
'description' => get_string('publiclyviewablegroupdescription', 'group'),
'options' => array(true => get_string('yes'),
false => get_string('no')),
'defaultvalue' => $group_data->public,
'help' => true,
'ignore' => !(get_config('createpublicgroups') == 'all' || get_config('createpublicgroups') == 'admins' && $USER->get('admin')),
),
'id' => array(
'type' => 'hidden',
'value' => $id,
......@@ -103,6 +113,7 @@ function editgroup_submit(Pieform $form, $values) {
$now = db_format_timestamp(time());
list($grouptype, $jointype) = explode('.', $values['grouptype']);
$values['public'] = (isset($values['public'])) ? $values['public'] : 0;
update_record(
'group',
......@@ -113,6 +124,7 @@ function editgroup_submit(Pieform $form, $values) {
'grouptype' => $grouptype,
'jointype' => $jointype,
'mtime' => $now,
'public' => intval($values['public']),
),
'id'
);
......
......@@ -59,6 +59,8 @@ $string['Created'] = 'Created';
$string['groupadmins'] = 'Group admins';
$string['Admin'] = 'Admin';
$string['grouptype'] = 'Group Type';
$string['publiclyviewablegroup'] = 'Publicly Viewable Group?';
$string['publiclyviewablegroupdescription'] = 'Allow anyone (including people who aren\'t members of this site) to view this group, including the forums?';
$string['hasrequestedmembership'] = 'has requested membership of this group';
$string['hasbeeninvitedtojoin'] = 'has been invited to join this group';
......
......@@ -265,6 +265,7 @@
<FIELD NAME="jointype" TYPE="char" LENGTH="20" NOTNULL="true" ENUM="true" ENUMVALUES="'controlled', 'invite', 'request', 'open'" DEFAULT="open" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="mtime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="public" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
</FIELDS>
<KEYS>
......
......@@ -1444,6 +1444,15 @@ function xmldb_core_upgrade($oldversion=0) {
table_column('artefact_feedback', null, 'authorname', 'text', null, null, null, '');
}
if ($oldversion < 2008110700) {
$table = new XMLDBTable('group');
$field = new XMLDBField('public');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
set_config('createpublicgroups', 'admins');
}
return $status;
}
......
......@@ -241,6 +241,7 @@ function group_create($data) {
'jointype' => $data['jointype'],
'ctime' => $data['ctime'],
'mtime' => $data['ctime'],
'public' => intval($data['public']),
),
'id',
true
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008102400;
$config->version = 2008110700;
$config->release = '1.1.0beta2dev';
$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