Commit 257f72f0 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge changes I4c33d9e5,I00d6c619

* changes:
  Bug 1574941: Adding bulk delete validation
  Bug 1574941: Getting tab nav to remember open tab
parents e78b7b87 2bac8857
......@@ -298,6 +298,21 @@ function suspend_submit(Pieform $form, $values) {
function delete_validate(Pieform $form, $values) {
global $SESSION, $USER;
$users = $values['users'];
// Not allowed to bulk delete yourself
if (is_array($users) && in_array($USER->get('id'), $users)) {
$form->set_error(null, get_string('unabletodeleteself', 'admin'));
// Not allowed to remove all site admins
$siteadmins = count_records_sql("SELECT COUNT(admin) FROM {usr}
WHERE id NOT IN (" . join(',', array_map('db_quote', $users)) . ") AND admin = 1", array());
if (!$siteadmins) {
$form->set_error(null, get_string('unabletodeletealladmins', 'admin'));
function delete_submit(Pieform $form, $values) {
global $users, $editable, $SESSION;
......@@ -1147,6 +1147,8 @@ $string['selectedusers'] = 'Selected users';
$string['remoteuser'] = 'Remote username';
$string['userreports'] = 'User reports';
$string['userreportsdescription'] = 'View or download information about the users you selected on the search page.';
$string['unabletodeleteself'] = 'Unable to bulk delete yourself';
$string['unabletodeletealladmins'] = 'Not allowed to bulk delete all the site admins';
// general stuff
$string['notificationssaved'] = 'Notification settings saved';
......@@ -4,24 +4,38 @@ jQuery(function($) {
"use strict";
function setupTab() {
// if we have one form with many div tabs within it - eg profile page
if ($('.pieform.jstabs .pieform-fieldset').length) {
setupTabContext($('.pieform.jstabs .pieform-fieldset').parent(), '.pieform.jstabs', true);
// if we have many forms each in their own div/tab - eg user bulk actions
if ($('.bulk.jstabs').length) {
setupTabContext($('.bulk.jstabs .tabcontent'), '.bulk.jstabs', false);
function setupTabContext(tabcontent,ident,createmenu) {
var i,
tabcontent = $('.pieform.jstabs .pieform-fieldset').parent();
$('.pieform.jstabs').prepend('<ul class="nav nav-tabs" role="tablist"></ul>');
mahara.tabnav = $('.pieform.jstabs').find('.nav-tabs');
if (createmenu) {
$(ident).prepend('<ul class="nav nav-tabs" role="tablist"></ul>');
mahara.tabnav = $(ident).find('.nav-tabs');
// Remove class collasped that has been generated by pieform
$('.pieform.jstabs .pieform-fieldset').removeClass('collapsed');
if ($(ident + ' .pieform-fieldset').length) {
$(ident + ' .pieform-fieldset').removeClass('collapsed');
// Add div and bootstrap class on tabcontent to show and hide
tabcontent.addClass('tab-pane').attr('role', 'tabpanel').wrapAll('<div class="tab-content">');
// Set up tab navigation
for(i = 0; i < tabcontent.length; i = i + 1){
for (i = 0; i < tabcontent.length; i = i + 1) {
// get id and title from div (tabcontent)
id = $(tabcontent[i]).attr('id');
heading = $(tabcontent[i]).find('legend h4').first().text();
{include file="header.tpl"}
<div class="panel panel-default">
<div id="edit-users" class="panel-body admin-edit-users">
<div id="edit-users" class="panel-body admin-edit-users bulk jstabs">
<p class="lead">{str tag=editselectedusersdescription1 section=admin}</p>
<ul class="nav nav-tabs" role="tablist">
<li id="suspend-user-tab" class="active" role="presentation" aria-hidden="true">
......@@ -13,7 +13,7 @@ Scenario: Meta test testing Behat's functionality (Bug #1387836)
| First name | test first name |
| Last name | test last name |
And I press "Save profile"
And I follow "Portfolio"
And I choose "Pages" in "Portfolio"
# Creating a page
And I press "Create page"
And I set the field "Page title" to "test page name 1"
......@@ -37,11 +37,11 @@ Scenario: Meta test testing Behat's functionality (Bug #1387836)
And I follow "Done"
And I hover "Delete collection" "link"
And I go to the homepage
And I go to "Export"
And I choose "Export" in "Portfolio"
And I move backward one page
And I wait "3" seconds
And I move forward one page
And I follow "Content"
And I choose "Profile" in "Content"
And the "First name" field should not contain "Jinelle"
And the "First name" field should contain "test first name"
Supports Markdown
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