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="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 --> <!-- Layout -->
{$form|safe} {$form|safe}
......
<div id="toolbar-buttons" class="btn-group btn-toolbar btn-group-top"> <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}" 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}"> title="{if $edittitle}{str tag=settings section=view}{else}{str tag=editlayout section=view}{/if}">
<span class="icon icon-lg icon-cogs"></span> <span class="icon icon-lg icon-cogs"></span>
......
...@@ -68,11 +68,8 @@ if (!$USER->can_edit_view($view)) { ...@@ -68,11 +68,8 @@ if (!$USER->can_edit_view($view)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
// Make sure we can edit view title for this type. $caneditonlylayout = !$view->can_edit_title();
// 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'));
}
// If the view has been submitted, disallow editing // If the view has been submitted, disallow editing
if ($view->is_submitted()) { if ($view->is_submitted()) {
$submittedto = $view->submitted_to(); $submittedto = $view->submitted_to();
...@@ -129,12 +126,12 @@ $smarty->assign('PAGEHEADING', $state); ...@@ -129,12 +126,12 @@ $smarty->assign('PAGEHEADING', $state);
$smarty->display('view/editlayout.tpl'); $smarty->display('view/editlayout.tpl');
function create_settings_pieform(){ function create_settings_pieform(){
global $view, $new, $pieformname; global $view, $new, $pieformname, $caneditonlylayout;
$inlinejavascript = ''; $inlinejavascript = '';
$issiteview = $view->get('institution') == 'mahara'; $issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false); $issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canedittitle = $view->get('type') != 'profile'; $canedittitle = !$caneditonlylayout;
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && $view->get('type') != 'profile'; $canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && !$caneditonlylayout;
//get elements for each section of the form //get elements for each section of the form
if ($canedittitle) { if ($canedittitle) {
...@@ -540,10 +537,10 @@ JAVASCRIPT; ...@@ -540,10 +537,10 @@ JAVASCRIPT;
} }
function settings_validate(Pieform $form, $values) { function settings_validate(Pieform $form, $values) {
global $view; global $view, $caneditonlylayout;
$issiteview = $view->get('institution') == 'mahara'; $issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false); $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(); $layoutrows = $view->get_layoutrows();
if (!isset($layoutrows[$values['currentlayoutselect']]) ) { if (!isset($layoutrows[$values['currentlayoutselect']]) ) {
...@@ -571,11 +568,11 @@ function settings_validate(Pieform $form, $values) { ...@@ -571,11 +568,11 @@ function settings_validate(Pieform $form, $values) {
} }
function settings_submit(Pieform $form, $values) { function settings_submit(Pieform $form, $values) {
global $view, $SESSION, $new; global $view, $SESSION, $new, $caneditonlylayout;
$issiteview = $view->get('institution') == 'mahara'; $issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false); $issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canedittitle = $view->get('type') != 'profile'; $canedittitle = !$caneditonlylayout;
$canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && $view->get('type') != 'profile'; $canuseskins = !$issitetemplate && can_use_skins(null, false, $issiteview) && !$caneditonlylayout;
if ($canedittitle) { if ($canedittitle) {
set_view_title_and_description($form, $values); set_view_title_and_description($form, $values);
......
...@@ -9,10 +9,11 @@ Given the following "users" exist: ...@@ -9,10 +9,11 @@ Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role | | username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuhipa1 | UserA@example.org | Angela | User | mahara | internal | member | | UserA | Kupuhipa1 | UserA@example.org | Angela | User | mahara | internal | member |
| UserB | Kupuhipa1 | UserB@example.org | Bob | 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: Given the following "groups" exist:
| name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff | | 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: Given the following "pages" exist:
| title | description | ownertype | ownername | | title | description | ownertype | ownername |
...@@ -37,3 +38,17 @@ Scenario: Copying a group page retains title (Bug 1519374) ...@@ -37,3 +38,17 @@ Scenario: Copying a group page retains title (Bug 1519374)
And the following fields match these values: And the following fields match these values:
| Page title | Page GroupA_01 | | Page title | Page GroupA_01 |
Then I press "Save" 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) ...@@ -77,3 +77,34 @@ Scenario: Clicking ID's (Bug 1428456)
Then I should see "4 rows" Then I should see "4 rows"
And I press "Save" And I press "Save"
Then I should see "Page saved successfully" 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