Commit b9f8fadc authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1718806: Display correct edit options for pages

Can only edit layout for Groups homepage, profiles and dashboards

behatnotneeded

Change-Id: I5f0a703f165852bc256fb102cb8ec88afe01b04d
parent e85d5c7e
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='layout' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='editlayout' new=$new issiteview=$issiteview}
<!-- Layout -->
{$form|safe}
......
<div id="toolbar-buttons" class="btn-group btn-toolbar btn-group-top">
<a class="btn btn-default editviews editlayout {if $selected == 'layout'}active{/if}"
<a class="btn btn-default editviews editlayout {if $selected == 'layout' or $selected == 'editlayout'}active{/if}"
href="{$WWWROOT}view/editlayout.php?id={$viewid}{if $new}&new=1{/if}"
title="{if $edittitle}{str tag=settings section=view}{else}{str tag=editlayout section=view}{/if}">
<span class="icon icon-lg icon-cogs"></span>
......
......@@ -68,11 +68,8 @@ if (!$USER->can_edit_view($view)) {
throw new AccessDeniedException();
}
// Make sure we can edit view title for this type.
// If not, then we probably meant to edit blocks
if (!$view->can_edit_title() && $view->get('type') != 'profile') {
redirect('/view/blocks.php?id=' . $view->get('id'));
}
$caneditonlylayout = !$view->can_edit_title();
// If the view has been submitted, disallow editing
if ($view->is_submitted()) {
$submittedto = $view->submitted_to();
......@@ -129,12 +126,12 @@ $smarty->assign('PAGEHEADING', $state);
$smarty->display('view/editlayout.tpl');
function create_settings_pieform(){
global $view, $new, $pieformname;
global $view, $new, $pieformname, $caneditonlylayout;
$inlinejavascript = '';
$issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canedittitle = $view->get('type') != 'profile';
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && $view->get('type') != 'profile';
$canedittitle = !$caneditonlylayout;
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && !$caneditonlylayout;
//get elements for each section of the form
if ($canedittitle) {
......@@ -540,10 +537,10 @@ JAVASCRIPT;
}
function settings_validate(Pieform $form, $values) {
global $view;
global $view, $caneditonlylayout;
$issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && $view->get('type') != 'profile';
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && !$caneditonlylayout;
$layoutrows = $view->get_layoutrows();
if (!isset($layoutrows[$values['currentlayoutselect']]) ) {
......@@ -571,11 +568,11 @@ function settings_validate(Pieform $form, $values) {
}
function settings_submit(Pieform $form, $values) {
global $view, $SESSION, $new;
global $view, $SESSION, $new, $caneditonlylayout;
$issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canedittitle = $view->get('type') != 'profile';
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && $view->get('type') != 'profile';
$canedittitle = !$caneditonlylayout;
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && !$caneditonlylayout;
if ($canedittitle) {
set_view_title_and_description($form, $values);
......
......@@ -9,10 +9,11 @@ Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuhipa1 | UserA@example.org | Angela | User | mahara | internal | member |
| UserB | Kupuhipa1 | UserB@example.org | Bob | User | mahara | internal | member |
| UserC | Kupuhipa1 | UserC@example.org | Cecilia | User | mahara | internal | member |
Given the following "groups" exist:
| name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff |
| GroupA | admin | Group A owned by admin | standard | ON | ON | all | ON | ON | UserA, UserB | |
| GroupA | admin | Group A owned by admin | standard | ON | ON | all | ON | ON | UserA, UserB | UserC |
Given the following "pages" exist:
| title | description | ownertype | ownername |
......@@ -37,3 +38,17 @@ Scenario: Copying a group page retains title (Bug 1519374)
And the following fields match these values:
| Page title | Page GroupA_01 |
Then I press "Save"
Scenario: Group homepage basic settings and skins can't be edited - Bug 1718806
Given I log in as "UserC" with password "Kupuhipa1"
When I go to group "GroupA"
And I should see "Edit this page"
And I follow "Edit this page"
And I should not see "Settings"
And I should see "Edit layout"
When I follow "Edit layout"
And I should see "Layout"
And I should not see "Basics"
And I should not see "Skin"
And I press "Save"
And I should see "Page saved successfully"
......@@ -77,3 +77,34 @@ Scenario: Clicking ID's (Bug 1428456)
Then I should see "4 rows"
And I press "Save"
Then I should see "Page saved successfully"
Scenario: Profile and dashboard pages basic settings and skins can't be edited - Bug 1718806
# Check we can edit layout for dashboard and profile page views
# but not be able to change title or skin
Given I log in as "admin" with password "Kupuhipa1"
# Profile page
And I choose "Portfolio" from main menu
And I follow "Profile page"
And I follow "Edit this page"
And I should not see "Settings"
And I should see "Edit layout"
When I follow "Edit layout"
And I should see "Layout"
And I should not see "Basics"
And I should not see "Skin"
And I press "Save"
And I should see "Page saved successfully"
# Dashboard page
And I choose "Dashboard" from main menu
And I follow "Edit dashboard"
And I should not see "Settings"
And I should see "Edit layout"
When I follow "Edit layout"
And I should see "Layout"
And I should not see "Basics"
And I should not see "Skin"
And I press "Save"
And I should see "Page saved successfully"
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