Commit 35b9a03d authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add view notification setting to groups (bug #603010)


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent d3f4388f
......@@ -77,6 +77,12 @@ $elements['usersautoadded'] = array(
'defaultvalue' => 'no',
'help' => true,
'ignore' => !$USER->get('admin'));
$elements['viewnotify'] = array(
'type' => 'checkbox',
'title' => get_string('viewnotify', 'group'),
'description' => get_string('viewnotifydescription', 'group'),
'defaultvalue' => 1
);
$elements['submit'] = array(
'type' => 'submitcancel',
'value' => array(get_string('savegroup', 'group'), get_string('cancel')));
......@@ -122,6 +128,7 @@ function creategroup_submit(Pieform $form, $values) {
'public' => intval($values['public']),
'usersautoadded' => intval($values['usersautoadded']),
'members' => array($USER->get('id') => 'admin'),
'viewnotify' => intval($values['viewnotify']),
));
$USER->reset_grouproles();
......
......@@ -35,7 +35,7 @@ define('TITLE', get_string('editgroup', 'group'));
$id = param_integer('id');
define('GROUP', $id);
$group_data = get_record_sql("SELECT g.id, g.name, g.description, g.grouptype, g.jointype, g.public, g.usersautoadded, g.category
$group_data = get_record_sql("SELECT g.*
FROM {group} g
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')
WHERE g.id = ?
......@@ -100,6 +100,12 @@ $elements['usersautoadded'] = array(
'defaultvalue' => $group_data->usersautoadded,
'help' => true,
'ignore' => !$USER->get('admin'));
$elements['viewnotify'] = array(
'type' => 'checkbox',
'title' => get_string('viewnotify', 'group'),
'description' => get_string('viewnotifydescription', 'group'),
'defaultvalue' => $group_data->viewnotify
);
$elements['id'] = array(
'type' => 'hidden',
'value' => $id);
......@@ -149,6 +155,7 @@ function editgroup_submit(Pieform $form, $values) {
'mtime' => $now,
'usersautoadded' => intval($values['usersautoadded']),
'public' => intval($values['public']),
'viewnotify' => intval($values['viewnotify']),
),
'id'
);
......
......@@ -81,6 +81,8 @@ $string['hasrequestedmembership'] = 'has requested membership of this group';
$string['hasbeeninvitedtojoin'] = 'has been invited to join this group';
$string['groupinvitesfrom'] = 'Invited to join:';
$string['requestedmembershipin'] = 'Requested membership in:';
$string['viewnotify'] = 'View notifications';
$string['viewnotifydescription'] = 'If checked, a notification will be sent to every group member whenever a member shares one of their Views with the group. Enabling this setting in very large groups can produce a lot of notifications.';
$string['editgroupmembership'] = 'Edit group membership';
$string['editmembershipforuser'] = 'Edit membership for %s';
......
......@@ -238,7 +238,7 @@ function activity_get_viewaccess_users($view, $owner, $type) {
UNION SELECT m.member
FROM {group_member} m
JOIN {view_access} vg ON vg.group = m.group
JOIN {group} g ON (g.id = vg.group AND g.deleted = 0)
JOIN {group} g ON (g.id = vg.group AND g.deleted = 0 AND g.viewnotify = 1)
JOIN {group_member} og ON (g.id = og.group AND og.member = ?)
WHERE vg.view = ? AND (vg.role IS NULL OR vg.role = m.role)
) AS userlist
......
......@@ -294,6 +294,7 @@
<FIELD NAME="usersautoadded" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="category" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="viewnotify" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
......@@ -2085,5 +2085,12 @@ function xmldb_core_upgrade($oldversion=0) {
change_field_enum($table, $field);
}
if ($oldversion < 2010071900) {
$table = new XMLDBTable('group');
$field = new XMLDBField('viewnotify');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 1);
add_field($table, $field);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010071600;
$config->version = 2010071900;
$config->release = '1.3.0beta3dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.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