Commit b3ea79ae authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Bug 1582039: Show submissions by default for 'allow submissions' groups"

parents bee7a714 c29c173b
......@@ -4427,5 +4427,37 @@ function xmldb_core_upgrade($oldversion=0) {
, array('mahara', 2, 0, 1));
}
if ($oldversion < 2016051600) {
// Get all the group view blocks from groups that have 'Allow submissions' set to true.
$sql = "SELECT bi.id, bi.configdata
FROM {block_instance} bi
INNER JOIN {view} v ON v.id = bi.view
INNER JOIN {group} g ON g.id = v.group
WHERE bi.blocktype = 'groupviews'
AND v.type = 'grouphomepage'
AND g.submittableto = 1";
$groupviews = get_records_sql_array($sql, array());
if ($groupviews) {
log_debug("Processing 'Group page' blocks to set the allow submitted configuration if not already set");
$count = 0;
$limit = 1000;
$total = count($groupviews);
foreach ($groupviews as $groupview) {
$configdata = unserialize($groupview->configdata);
if (!isset($configdata['showsubmitted'])) {
$configdata['showsubmitted'] = 1;
set_field('block_instance', 'configdata', serialize($configdata), 'id', $groupview->id);
}
$count++;
if (($count % $limit) == 0 || $count == $total) {
log_debug("$count/$total");
set_time_limit(30);
}
}
}
}
return $status;
}
......@@ -524,6 +524,24 @@ function group_create($data) {
else {
throw new NotFoundException("group_create: group homepage is not found");
}
// If 'Allow submissions' is true we need to update the 'Group pages' block to show
// the 'Submissions to this group' section by default
if ($data['submittableto']) {
$groupview = get_record_sql("SELECT bi.id, bi.configdata
FROM {block_instance} bi
INNER JOIN {view} v ON v.id = bi.view
WHERE bi.blocktype = 'groupviews'
AND v.id = ?", array($homepage->get('id')));
if ($groupview) {
$configdata = unserialize($groupview->configdata);
if (!isset($configdata['showsubmitted'])) {
$configdata['showsubmitted'] = 1;
set_field('block_instance', 'configdata', serialize($configdata), 'id', $groupview->id);
}
}
}
insert_record('view_access', (object) array(
'view' => $homepage->get('id'),
'accesstype' => $data['public'] ? 'public' : 'loggedin',
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2016042100;
$config->version = 2016051600;
$config->series = '16.10';
$config->release = '16.10dev';
$config->minupgradefrom = 2012080604;
......
......@@ -106,7 +106,7 @@ These list must take into account the sort option choosen in the block config (B
And I should not see "Page Group Z_06" in the "ul#groupviewlist" "css_element"
#And I follow "Next page" in the "div#groupviews_pagination" "css_element"
And I jump to next page of the list "groupviews_pagination"
And I wait "10" seconds
And I wait "2" seconds
And I should see "Page Group Z_06" in the "ul#groupviewlist" "css_element"
And I should see "Page Group Z_08" in the "ul#groupviewlist" "css_element"
And I should not see "Page Group Z_05" in the "ul#groupviewlist" "css_element"
......@@ -135,10 +135,23 @@ These list must take into account the sort option choosen in the block config (B
And I should see "Collection userA_06" in the "ul#sharedcollectionlist" "css_element"
And I should not see "Collection userA_05" in the "ul#sharedcollectionlist" "css_element"
And I log out
# Check that we can see submitted pages before editing/saving the configuration for group pages block
Given I log in as "userB" with password "Kupuhipa1"
And I should see "Group Z"
And I choose "My groups" in "Groups"
And I follow "Group Z"
And I select "Page userB_01" from "group_view_submission_form_2_options"
And I press "Submit"
And I press "Yes"
And I select "Page userB_02" from "group_view_submission_form_2_options"
And I press "Submit"
And I press "Yes"
And I log out
# Change the sort options in the "Group pages" block
Given I log in as "userA" with password "Kupuhipa1"
And I should see "Group Z"
And I follow "Group Z"
And I should see "Page userB_01"
And I follow "Pages" in the "ul.nav-inpage" "css_element"
And I click on "Edit \"Group homepage\""
And I scroll to the id "column-container"
......@@ -213,28 +226,17 @@ These list must take into account the sort option choosen in the block config (B
And I press "Submit"
And I press "Yes"
And I log out
Given I log in as "userB" with password "Kupuhipa1"
And I should see "Group Z"
And I choose "My groups" in "Groups"
And I follow "Group Z"
And I select "Page userB_01" from "group_view_submission_form_2_options"
And I press "Submit"
And I press "Yes"
And I select "Page userB_02" from "group_view_submission_form_2_options"
And I press "Submit"
And I press "Yes"
And I log out
# Check the list of submitted pages/collections
Given I log in as "userA" with password "Kupuhipa1"
And I choose "My groups" in "Groups"
And I follow "Group Z"
And I should see "Page userB_02" in the "ul#allsubmissionlist" "css_element"
And I should see "Page userB_01" in the "ul#allsubmissionlist" "css_element"
And I should see "Page userA_03" in the "ul#allsubmissionlist" "css_element"
And I should see "Page userA_02" in the "ul#allsubmissionlist" "css_element"
And I should see "Collection userA_03" in the "ul#allsubmissionlist" "css_element"
And I should not see "Page userA_03" in the "ul#allsubmissionlist" "css_element"
And I should not see "Page userB_01" in the "ul#allsubmissionlist" "css_element"
#And I follow "2" in the "div#allsubmitted_pagination" "css_element"
And I jump to page "2" of the list "allsubmitted_pagination"
And I should see "Page userA_03" in the "ul#allsubmissionlist" "css_element"
And I should see "Page userA_01" in the "ul#allsubmissionlist" "css_element"
And I should not see "Page userB_02" in the "ul#allsubmissionlist" "css_element"
And I should see "Page userB_01" in the "ul#allsubmissionlist" "css_element"
And I should not see "Page userA_02" in the "ul#allsubmissionlist" "css_element"
And I log out
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