mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'wip-MDL-25451-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
cd7b48a2e7
@ -4,17 +4,31 @@ Feature: Add and configure blocks throughout the site
|
||||
As a manager
|
||||
I need to set and configure blocks throughout the site
|
||||
|
||||
Scenario: Add and configure a block throughtout the site
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| manager1 | Manager | 1 | manager1@example.com |
|
||||
| teacher1 | teacher | 1 | teacher@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "system role assigns" exist:
|
||||
| user | course | role |
|
||||
| manager1 | Acceptance test site | manager |
|
||||
And I log in as "manager1"
|
||||
# Allow at least one role assignment in the block context:
|
||||
And I log in as "admin"
|
||||
And I navigate to "Define roles" node in "Site administration > Users > Permissions"
|
||||
And I follow "Edit Non-editing teacher role"
|
||||
And I set the following fields to these values:
|
||||
| Block | 1 |
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
|
||||
Scenario: Add and configure a block throughtout the site
|
||||
Given I log in as "manager1"
|
||||
And I am on site homepage
|
||||
And I follow "Turn editing on"
|
||||
And I add the "Comments" block
|
||||
@ -35,25 +49,13 @@ Feature: Add and configure blocks throughout the site
|
||||
And I should see "Comments" in the "//*[@id='region-pre' or @id='block-region-side-pre']/descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' block ')]" "xpath_element"
|
||||
|
||||
Scenario: Blocks on the dashboard page cannot have roles assigned to them
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| manager1 | Manager | 1 | manager1@example.com |
|
||||
And I log in as "manager1"
|
||||
Given I log in as "manager1"
|
||||
And I click on "Dashboard" "link" in the "Navigation" "block"
|
||||
When I press "Customise this page"
|
||||
Then I should not see "Assign roles in Navigation block"
|
||||
|
||||
Scenario: Blocks on courses can have roles assigned to them
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | teacher | 1 | teacher@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Turn editing on"
|
||||
Then I should see "Assign roles in Search forums block"
|
||||
|
@ -257,7 +257,7 @@ $string['noneinthisxmatching'] = 'No users matching \'{$a->search}\' in this {$a
|
||||
$string['norole'] = 'No role';
|
||||
$string['noroles'] = 'No roles';
|
||||
$string['noroleassignments'] = 'This user does not have any role assignments anywhere in this site.';
|
||||
$string['notabletoassignroleshere'] = 'You are not able to assign any roles here';
|
||||
$string['notabletoassignroleshere'] = 'Assigning of roles in this context has not been enabled by an administrator.';
|
||||
$string['notabletooverrideroleshere'] = 'You are not able to override the permissions on any roles here';
|
||||
$string['notes:manage'] = 'Manage notes';
|
||||
$string['notes:view'] = 'View notes';
|
||||
|
@ -1092,24 +1092,39 @@ class block_manager {
|
||||
$controls[] = new action_menu_link_secondary($url, $icon, $str, $attributes);
|
||||
}
|
||||
|
||||
// Assign roles icon.
|
||||
if ($this->page->pagetype != 'my-index' && has_capability('moodle/role:assign', $block->context)) {
|
||||
//TODO: please note it is sloppy to pass urls through page parameters!!
|
||||
// it is shortened because some web servers (e.g. IIS by default) give
|
||||
// a 'security' error if you try to pass a full URL as a GET parameter in another URL.
|
||||
$return = $this->page->url->out(false);
|
||||
$return = str_replace($CFG->wwwroot . '/', '', $return);
|
||||
// Display either "Assign roles" or "Permissions" or "Change permissions" icon (whichever first is available).
|
||||
if ($this->page->pagetype != 'my-index') {
|
||||
$rolesurl = null;
|
||||
|
||||
$rolesurl = new moodle_url('/admin/roles/assign.php', array('contextid'=>$block->context->id,
|
||||
'returnurl'=>$return));
|
||||
// Delete icon.
|
||||
$str = new lang_string('assignrolesinblock', 'block', $blocktitle);
|
||||
$controls[] = new action_menu_link_secondary(
|
||||
$rolesurl,
|
||||
new pix_icon('t/assignroles', $str, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$str,
|
||||
array('class' => 'editing_roles')
|
||||
);
|
||||
if (get_assignable_roles($block->context, ROLENAME_SHORT)) {
|
||||
$rolesurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $block->context->id));
|
||||
$str = new lang_string('assignrolesinblock', 'block', $blocktitle);
|
||||
$icon = 'i/assignroles';
|
||||
} else if (has_capability('moodle/role:review', $block->context) or get_overridable_roles($block->context)) {
|
||||
$rolesurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $block->context->id));
|
||||
$str = get_string('permissions', 'role');
|
||||
$icon = 'i/permissions';
|
||||
} else if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:assign'), $block->context)) {
|
||||
$rolesurl = new moodle_url('/admin/roles/check.php', array('contextid' => $block->context->id));
|
||||
$str = get_string('checkpermissions', 'role');
|
||||
$icon = 'i/checkpermissions';
|
||||
}
|
||||
|
||||
if ($rolesurl) {
|
||||
//TODO: please note it is sloppy to pass urls through page parameters!!
|
||||
// it is shortened because some web servers (e.g. IIS by default) give
|
||||
// a 'security' error if you try to pass a full URL as a GET parameter in another URL.
|
||||
$return = $this->page->url->out(false);
|
||||
$return = str_replace($CFG->wwwroot . '/', '', $return);
|
||||
$rolesurl->param('returnurl', $return);
|
||||
|
||||
$controls[] = new action_menu_link_secondary(
|
||||
$rolesurl,
|
||||
new pix_icon($icon, $str, 'moodle', array('class' => 'iconsmall', 'title' => '')),
|
||||
$str,
|
||||
array('class' => 'editing_roles')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->user_can_delete_block($block)) {
|
||||
|
@ -4509,18 +4509,23 @@ class settings_navigation extends navigation_node {
|
||||
$blocknode->force_open();
|
||||
|
||||
// Assign local roles
|
||||
$assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING);
|
||||
if (get_assignable_roles($this->context, ROLENAME_ORIGINAL)) {
|
||||
$assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $this->context->id));
|
||||
$blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING, null,
|
||||
'roles', new pix_icon('i/assignroles', ''));
|
||||
}
|
||||
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $this->context) or count(get_overridable_roles($this->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
|
||||
$blocknode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING, null,
|
||||
'permissions', new pix_icon('i/permissions', ''));
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $this->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
|
||||
$blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null,
|
||||
'checkpermissions', new pix_icon('i/checkpermissions', ''));
|
||||
}
|
||||
|
||||
return $blocknode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user