Commit 04a1b39f authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Add config for participation reports, default to off (bug #1018711)"

parents cc4e8534 4f58c448
......@@ -71,6 +71,7 @@ else {
'hidden' => 0,
'hidemembers' => 0,
'hidemembersfrommembers' => 0,
'groupparticipationreports' => 0,
'invitefriends' => 0,
'suggestfriends' => 0,
'urlid' => null,
......@@ -305,6 +306,13 @@ else {
);
}
$elements['groupparticipationreports'] = array(
'type' => 'checkbox',
'title' => get_string('groupparticipationreports', 'group'),
'description' => get_string('groupparticipationreportsdesc', 'group'),
'defaultvalue' => $group_data->groupparticipationreports,
);
$elements['general'] = array(
'type' => 'html',
'title' => get_string('general'),
......@@ -418,6 +426,7 @@ function editgroup_submit(Pieform $form, $values) {
'hidden' => intval($values['hidden']),
'hidemembers' => intval(!empty($values['hidemembersfrommembers']) || !empty($values['hidemembers'])),
'hidemembersfrommembers' => intval($values['hidemembersfrommembers']),
'groupparticipationreports' => intval($values['groupparticipationreports']),
'invitefriends' => intval($values['invitefriends']),
'suggestfriends' => intval($values['suggestfriends']),
);
......
......@@ -380,3 +380,5 @@ $string['nnonmembers'] = array(
);
$string['membercommenters'] = "Members involved";
$string['extcommenters'] = "Non-members involved";
$string['groupparticipationreports'] = "Participation report";
$string['groupparticipationreportsdesc'] = "If checked, the group admin can access a report displaying all group and shared pages and who has commented on them";
......@@ -354,6 +354,7 @@
<FIELD NAME="hidden" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="hidemembers" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="hidemembersfrommembers" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="groupparticipationreports" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="invitefriends" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="suggestfriends" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="urlid" TYPE="char" LENGTH="30" NOTNULL="false" />
......
......@@ -3059,5 +3059,12 @@ function xmldb_core_upgrade($oldversion=0) {
)');
}
if ($oldversion < 2012070300) {
$table = new XMLDBTable('group');
$field = new XMLDBField('groupparticipationreports');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
return $status;
}
......@@ -212,6 +212,10 @@ function group_role_can_moderate_views($group, $role) {
function group_role_can_access_report($group, $role) {
global $USER;
if (!$group->groupparticipationreports) {
return false;
}
if (group_user_access($group->id) && ($role == 'admin' || $USER->get('admin') || $USER->is_institutional_admin() || $USER->is_institutional_staff())) {
return true;
}
......@@ -318,6 +322,7 @@ function group_create($data) {
$data['hidden'] = (isset($data['hidden'])) ? intval($data['hidden']) : 0;
$data['hidemembers'] = (isset($data['hidemembers'])) ? intval($data['hidemembers']) : 0;
$data['hidemembersfrommembers'] = (isset($data['hidemembersfrommembers'])) ? intval($data['hidemembersfrommembers']) : 0;
$data['groupparticipationreports'] = (isset($data['groupparticipationreports'])) ? intval($data['groupparticipationreports']) : 0;
$data['usersautoadded'] = (isset($data['usersautoadded'])) ? intval($data['usersautoadded']) : 0;
$data['quota'] = get_config_plugin('artefact', 'file', 'defaultgroupquota');
......@@ -407,6 +412,7 @@ function group_create($data) {
'hidden' => $data['hidden'],
'hidemembers' => $data['hidemembers'],
'hidemembersfrommembers' => $data['hidemembersfrommembers'],
'groupparticipationreports' => $data['groupparticipationreports'],
'invitefriends' => $data['invitefriends'],
'suggestfriends' => $data['suggestfriends'],
),
......@@ -531,7 +537,7 @@ function group_update($new, $create=false) {
unset($new->shortname);
foreach (array('id', 'grouptype', 'public', 'request', 'submittableto', 'editroles',
'hidden', 'hidemembers', 'hidemembersfrommembers') as $f) {
'hidden', 'hidemembers', 'hidemembersfrommembers', 'groupparticipationreports') as $f) {
if (!isset($new->$f)) {
$new->$f = $old->$f;
}
......@@ -1930,11 +1936,11 @@ function group_get_associated_groups($userid, $filter='all', $limit=20, $offset=
$sql = '
SELECT g1.id, g1.name, g1.description, g1.public, g1.jointype, g1.request, g1.grouptype, g1.submittableto,
g1.hidemembers, g1.hidemembersfrommembers, g1.urlid, g1.membershiptype, g1.reason, g1.role, g1.membercount,
g1.hidemembers, g1.hidemembersfrommembers, g1.groupparticipationreports, g1.urlid, g1.membershiptype, g1.reason, g1.role, g1.membercount,
COUNT(gmr.member) AS requests
FROM (
SELECT g.id, g.name, g.description, g.public, g.jointype, g.request, g.grouptype, g.submittableto,
g.hidemembers, g.hidemembersfrommembers, g.urlid, t.membershiptype, t.reason, t.role,
g.hidemembers, g.hidemembersfrommembers, g.groupparticipationreports, g.urlid, t.membershiptype, t.reason, t.role,
COUNT(gm.member) AS membercount
FROM {group} g
LEFT JOIN {group_member} gm ON (gm.group = g.id)' .
......@@ -1942,11 +1948,11 @@ function group_get_associated_groups($userid, $filter='all', $limit=20, $offset=
WHERE g.deleted = ?' .
$catsql . '
GROUP BY g.id, g.name, g.description, g.public, g.jointype, g.request, g.grouptype, g.submittableto,
g.hidemembers, g.hidemembersfrommembers, g.urlid, t.membershiptype, t.reason, t.role
g.hidemembers, g.hidemembersfrommembers, g.groupparticipationreports, g.urlid, t.membershiptype, t.reason, t.role
) g1
LEFT JOIN {group_member_request} gmr ON (gmr.group = g1.id)
GROUP BY g1.id, g1.name, g1.description, g1.public, g1.jointype, g1.request, g1.grouptype, g1.submittableto,
g1.hidemembers, g1.hidemembersfrommembers, g1.urlid, g1.membershiptype, g1.reason, g1.role, g1.membercount
g1.hidemembers, g1.hidemembersfrommembers, g1.groupparticipationreports, g1.urlid, g1.membershiptype, g1.reason, g1.role, g1.membercount
ORDER BY g1.name';
$groups = get_records_sql_array($sql, $values, $offset, $limit);
......
......@@ -30,7 +30,7 @@ defined('INTERNAL') || die();
$config = new StdClass;
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2012070200;
$config->version = 2012070300;
$config->release = '1.6.0dev';
$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