Commit 988ef71e authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 975746: Fields for Shared Page notifications and Group category...

Merge "Bug 975746: Fields for Shared Page notifications and Group category missing on Add groups by CSV"
parents 4d638c0e 64a099ba
......@@ -148,6 +148,8 @@ function uploadcsv_validate(Pieform $form, $values) {
if (isset($formatkeylookup['editroles'])) {
$editroles = $line[$formatkeylookup['editroles']];
}
$viewnotify = isset($formatkeylookup['viewnotify']) && !empty($line[$formatkeylookup['viewnotify']]);
$category = isset($formatkeylookup['category']) && !empty($line[$formatkeylookup['category']]);
// Make sure these three mandatory fields are populated.
if (empty($shortname)) {
......@@ -229,6 +231,26 @@ function uploadcsv_validate(Pieform $form, $values) {
if ($open && $request) {
$csverrors->add($i, get_string('uploadgroupcsverroropenrequest', 'admin', $i));
}
if ($viewnotify) {
$vn = $line[$formatkeylookup['viewnotify']];
if (!is_numeric($vn) || !($vn >= GROUP_ROLES_NONE && $vn <= GROUP_ROLES_ADMIN)) {
$csverrors->add($i, get_string('uploadgroupcsverrorviewnotifyrequest', 'admin', $i, GROUP_ROLES_NONE, GROUP_ROLES_ADMIN));
}
}
if ($category) {
if (!get_config('allowgroupcategories')) {
$csverrors->add($i, get_string('uploadgroupcsverrordoesnotallowgroupcategory', 'admin', $i));
}
$categorytitle = $line[$formatkeylookup['category']];
// Check if this is a valid category name
if ($categoryid = get_field('group_category', 'id', 'title', $categorytitle)) {
// Make sure we store the id of the category and not the category name in the DB.
$csvdata->data[$key][$formatkeylookup['category']] = $categoryid;
}
else {
$csverrors->add($i, get_string('uploadgroupcsverrorcategorydoesnotexist', 'admin', $i, $categorytitle));
}
}
if ($values['updategroups']) {
......@@ -301,6 +323,12 @@ function uploadcsv_submit(Pieform $form, $values) {
$group->quota = get_real_size($record[$formatkeylookup[$field]]);
continue;
}
if ($field == 'category') {
if (!empty($record[$formatkeylookup[$field]])) {
$group->category = $record[$formatkeylookup[$field]];
}
continue;
}
$group->{$field} = $record[$formatkeylookup[$field]];
}
......@@ -369,7 +397,7 @@ $grouptypes .= get_string('uploadgroupcsveditrolesdescription', 'admin', get_hel
$fields = "<ul class='fieldslist column-list'>\n";
foreach ($ALLOWEDKEYS as $type) {
$helplink = '';
if ($type == 'public' || $type == 'usersautoadded' || $type == 'hidemembers') {
if ($type == 'public' || $type == 'usersautoadded' || $type == 'hidemembers' || $type == 'viewnotify' || $type == 'category') {
$helplink = get_help_icon('core', 'groups', 'editgroup', $type);
}
$fields .= '<li>' . hsc($type) . $helplink . "</li>\n";
......
......@@ -305,7 +305,6 @@ if ($cancreatecontrolled) {
'description' => get_string('hidemembersdescription', 'group'),
'defaultvalue' => ($group_data->hidemembersfrommembers ? $group_data->hidemembersfrommembers : ($group_data->hidemembers ? $group_data->hidemembers : 0)),
'disabled' => $group_data->hidemembersfrommembers,
'help' => true,
);
$elements['hidemembersfrommembers'] = array(
'type' => 'select',
......
......@@ -691,6 +691,7 @@ $string['uploadcsvpagedescription6'] = '<p>Here you can upload new users via a <
%s';
$string['uploadcsverrortoomanyusers'] = 'You have too many lines in your CSV file. Your file should not contain more than %s.';
$string['uploadcsverrordatamustbenumeric'] = 'Line %s: The value for category must be numeric';
$string['uploadgroupcsverrordisplaynamealreadyexists'] = 'Error on line %s of your file: The displayname "%s" already exists.';
$string['uploadgroupcsverrorinvalidshortname'] = 'Error on line %s of your file: The shortname "%s" is invalid.';
$string['uploadgroupcsverrorshortnamemissing'] = 'Error on line %s of your file: The group with the shortname "%s" does not exist.';
......@@ -700,6 +701,9 @@ $string['uploadgroupcsverrorshortnamealreadytaken1'] = 'Error on line %s of your
$string['uploadgroupcsverrorusernamesnotlastfield'] = 'The "usernames" field must be the last field in the header.';
$string['uploadgroupcsverroropencontrolled'] = 'Line %s: Groups cannot have both open and controlled membership.';
$string['uploadgroupcsverroropenrequest'] = 'Line %s: Groups with open membership cannot allow membership requests.';
$string['uploadgroupcsverrorviewnotifyrequest'] = 'Line %s: The value for viewnotify must be numerical in range %s-%s.';
$string['uploadgroupcsverrordoesnotallowgroupcategory'] = 'Line %s: This site does not allow for group categories. Please review the Group settings in Configure site -> Site options.';
$string['uploadgroupcsverrorcategorydoesnotexist'] = 'Line %s: The category "%s" does not exist.';
$string['uploadgroupcsvpagedescription2'] = '<p>You may use this facility to upload new groups via a <acronym title="Comma Separated Values">CSV</acronym> file.</p>
<p>The first row of your CSV file should specify the format of your CSV data. For example, it should look like this:</p>
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Category</h3>
<p>Add the group to a category</p>
<p>
The site must allow for group categories. This setting can be enabled via <i>Administration menu -> Groups -> Group categories -> Enable group categories</i> or in <i>Site options -> Group settings -> Allow group categories</i>.
</p>
<p>
The value in this field must correspond to an already existing category.
</p>
<p>
Entering an unknown category name here will <strong>not</strong> create a new category.
To add a new category, please go to <i>Administration menu -> Groups -> Group categories -> Add categories</i>.
</p>
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Hide membership</h3>
<p>Hide the group's membership listing from non-members.</p>
<ul>Options are:
<li><em>0</em> = No</li>
<li><em>1</em> = Hide members</li>
<li><em>2</em> = Hide tutors</li>
</ul>
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Shared page notifications</h3>
<p>Select which group members should receive a notification when a new group page is created and when a group member shares one of their pages with the group.</p>
<p>The group member sharing the page will not receive this notification. For very large groups it would be best to limit this to non ordinary members as it can produce a lot of notifications.</p>
<ul>Options are:
<li><em>0</em> = None</li>
<li><em>1</em> = All group members</li>
<li><em>2</em> = Everyone except ordinary members</li>
<li><em>3</em> = Group administrators</li>
</ul>
......@@ -12,6 +12,7 @@
defined('INTERNAL') || die();
// Constants for the different group roles
define ('GROUP_ROLES_NONE', 0);
define('GROUP_ROLES_ALL', 1);
define('GROUP_ROLES_NONMEMBER', 2);
define('GROUP_ROLES_ADMIN', 3);
......@@ -450,7 +451,7 @@ function group_create($data) {
'description' => isset($data['description']) ? $data['description'] : null,
'urlid' => isset($data['urlid']) ? $data['urlid'] : null,
'grouptype' => $data['grouptype'],
'category' => isset($data['category']) ? intval($data['category']) : null,
'category' => isset($data['category']) && !empty($data['category']) ? intval($data['category']) : null,
'jointype' => $jointype,
'ctime' => $data['ctime'],
'mtime' => $data['ctime'],
......@@ -472,7 +473,7 @@ function group_create($data) {
'editwindowstart' => $data['editwindowstart'],
'editwindowend' => $data['editwindowend'],
'sendnow' => isset($data['sendnow']) ? $data['sendnow'] : null,
'viewnotify' => isset($data['viewnotify']) ? $data['viewnotify'] : null,
'viewnotify' => !empty($data['viewnotify']) ? $data['viewnotify'] : null,
'feedbacknotify' => isset($data['feedbacknotify']) ? $data['feedbacknotify'] : null,
),
'id',
......@@ -2850,6 +2851,8 @@ function group_get_allowed_group_csv_keys() {
'hidemembersfrommembers',
'invitefriends',
'suggestfriends',
'viewnotify',
'category',
);
if ($USER->get('admin')) {
......
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