Commit 4ec5cdb4 authored by Richard Mansfield's avatar Richard Mansfield

Pass new param correctly on edit view pages & remove cancel buttons

Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 16a4e207
......@@ -5,7 +5,7 @@
<h1>{$viewtitle}</h1>
{/if}
{include file="view/editviewtabs.tpl" selected='content'}
{include file="view/editviewtabs.tpl" selected='content' new=$new}
<div class="subpage rel">
{if $columns}
......@@ -59,19 +59,6 @@
</form>
<div id="view-wizard-controls" class="center">
{if $new}
<form action="" method="POST">
<input type="hidden" name="id" value="{$view}">
<input type="hidden" name="new" value="1">
<input type="submit" name="cancel" class="cancel" value="{str tag='cancel'}" onclick="return confirm('{str tag='confirmcancelcreatingview' section='view'}');">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
</form>
<form action="{$WWWROOT}view/edit.php" method="GET">
<input type="hidden" name="id" value="{$view}">
<input type="hidden" name="new" value="1">
<input type="submit" class="submit" value="{str tag=next}: {str tag='edittitleanddescription' section=view}">
</form>
{else}
<form action="{$WWWROOT}{if $groupid}{if $viewtype == 'grouphomepage'}group/view.php{else}view/groupviews.php{/if}{elseif $institution}view/institutionviews.php{else}view{/if}" method="GET">
{if $groupid}
{if $viewtype == 'grouphomepage'}
......@@ -84,7 +71,6 @@
{/if}
<input class="submit" type="submit" value="{str tag='done'}">
</form>
{/if}
</div>
{elseif $block}
......
......@@ -5,7 +5,7 @@
<h1>{$viewtitle}</h1>
{/if}
{include file="view/editviewtabs.tpl" selected='title'}
{include file="view/editviewtabs.tpl" selected='title' new=$new}
<div class="subpage rel">
{$editview|safe}
</div>
......
<ul class="in-page-tabs edit-view-tabs">
<li><a{if $selected == 'content'} class="current-tab"{/if} href="{$WWWROOT}view/blocks.php?id={$viewid}">{str tag=editcontent section=view}</a></li>
{if $edittitle}<li><a{if $selected == 'title'} class="current-tab"{/if} href="{$WWWROOT}view/edit.php?id={$viewid}">{str tag=edittitleanddescription section=view}</a></li>{/if}
<li><a{if $selected == 'layout'} class="current-tab"{/if} href="{$WWWROOT}view/layout.php?id={$viewid}">{str tag=editlayout section=view}</a></li>
<li class="fr"><a id="btn-displaymyview" href="{$displaylink}">{str tag=displaymyview section=view} &raquo;</a></li>
<li><a{if $selected == 'content'} class="current-tab"{/if} href="{$WWWROOT}view/blocks.php?id={$viewid}{if $new}&new=1{/if}">{str tag=editcontent section=view}</a></li>
{if $edittitle}<li><a{if $selected == 'title'} class="current-tab"{/if} href="{$WWWROOT}view/edit.php?id={$viewid}{if $new}&new=1{/if}">{str tag=edittitleanddescription section=view}</a></li>{/if}
<li><a{if $selected == 'layout'} class="current-tab"{/if} href="{$WWWROOT}view/layout.php?id={$viewid}{if $new}&new=1{/if}">{str tag=editlayout section=view}</a></li>
<li class="fr"><a id="btn-displaymyview" href="{$displaylink}{if $new}&new=1{/if}">{str tag=displaymyview section=view} &raquo;</a></li>
</ul>
......@@ -5,7 +5,7 @@
<h1>{$viewtitle}</h1>
{/if}
{include file="view/editviewtabs.tpl" selected='layout'}
{include file="view/editviewtabs.tpl" selected='layout' new=$new}
<div class="subpage rel">
<p>{str tag='viewlayoutpagedescription' section='view'}</p>
......
......@@ -73,16 +73,6 @@ if ($view->is_submitted()) {
$group = $view->get('group');
$institution = $view->get('institution');
// check if cancel was selected
if ($new && isset($_POST['cancel'])) {
if ($view->get('type') == 'profile' || $view->get('type') == 'dashboard') {
throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
}
form_validate(param_variable('sesskey', null));
$view->delete();
$view->post_edit_redirect();
}
// If a block was configured & submitted, build the form now so it can
// be processed without having to render the other blocks.
if ($blockid = param_integer('blockconfig', 0)) {
......@@ -95,7 +85,6 @@ if ($blockid = param_integer('blockconfig', 0)) {
}
$view->set_edit_nav();
$displaylink = $view->get_url();
if ($view->get('type') == 'profile') {
$profile = true;
......@@ -112,7 +101,6 @@ else if ($view->get('type') == 'grouphomepage') {
define('TITLE', $title . ': ' . get_string('editcontent', 'view'));
}
else if ($new) {
$displaylink .= '&new=1';
define('TITLE', get_string('editcontent', 'view'));
}
else {
......@@ -192,7 +180,7 @@ foreach (array_keys($_POST + $_GET) as $key) {
$viewid = $view->get('id');
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $displaylink);
$smarty->assign('displaylink', $view->get_url());
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category);
$smarty->assign('new', $new);
......
......@@ -133,53 +133,26 @@ if (!($group || $institution)) {
);
}
if ($new) {
$editview['elements']['submit'] = array(
'type' => 'cancelbackcreate',
'value' => array(get_string('cancel'), get_string('back','view'), get_string('next') . ': ' . get_string('editaccess', 'view')),
'confirm' => array(get_string('confirmcancelcreatingview', 'view'), null, null),
);
}
else {
$editview['elements']['submit'] = array(
'type' => 'submit',
'value' => get_string('done'),
);
}
$editview['elements']['submit'] = array(
'type' => 'submit',
'value' => get_string('save'),
);
$editview = pieform($editview);
function editview_cancel_submit() {
global $view, $new, $group, $institution;
if ($new) {
$view->delete();
}
$view->post_edit_redirect();
}
$editview = pieform($editview);
function editview_submit(Pieform $form, $values) {
global $new, $view, $SESSION;
if (param_boolean('back')) {
redirect('/view/blocks.php?id=' . $view->get('id') . '&new=' . $new);
}
$view->set('title', $values['title']);
$view->set('description', $values['description']);
$view->set('tags', $values['tags']);
if (isset($values['ownerformat']) && $view->get('owner')) {
$view->set('ownerformat', $values['ownerformat']);
}
$SESSION->add_ok_msg(get_string('viewsavedsuccessfully', 'view'));
$view->commit();
if (empty($new)) {
$SESSION->add_ok_msg(get_string('viewsavedsuccessfully', 'view'));
}
else {
$SESSION->add_ok_msg(get_string('viewcreatedsuccessfullyshare', 'view'));
}
$view->post_edit_redirect($values['new']);
redirect('/view/blocks.php?id=' . $view->get('id'));
}
$smarty = smarty(array(), array(), array(), array('sidebars' => false));
......@@ -188,6 +161,7 @@ $smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $view->get_url());
$smarty->assign('new', $new);
if (get_config('viewmicroheaders')) {
$smarty->assign('microheaders', true);
$smarty->assign('microheadertitle', $view->display_title(true, false));
......
......@@ -39,15 +39,8 @@ $new = param_boolean('new');
$view = new View($id);
$numcolumns = $view->get('numcolumns');
$currentlayout = $view->get('layout');
$back = !$USER->get_account_preference('addremovecolumns');
$group = $view->get('group');
$institution = $view->get('institution');
$view->set_edit_nav();
$view->set_user_theme();
$goto = get_config('wwwroot') . 'view/blocks.php?id=' . $view->get('id');
if ($new) {
$goto .= '&new=1';
}
if (!$USER->can_edit_view($view)) {
throw new AccessDeniedException();
......@@ -84,11 +77,11 @@ $smarty->assign('currentlayout', $currentlayout);
$smarty->assign('form', $layoutform);
$smarty->assign('form_start_tag', $layoutform->get_form_tag());
$smarty->assign('options', $options);
$smarty->assign('back', $back);
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $view->get_url());
$smarty->assign('new', $new);
if (get_config('viewmicroheaders')) {
$smarty->assign('microheaders', true);
$smarty->assign('microheadertitle', $view->display_title(true, false));
......@@ -103,7 +96,7 @@ function viewlayout_validate(Pieform $form, $values) {
}
function viewlayout_submit(Pieform $form, $values) {
global $view, $SESSION, $goto, $layouts;
global $view, $SESSION, $new, $layouts;
$oldcolumns = $view->get('numcolumns');
$newcolumns = $layouts[$values['layout']]->columns;
......@@ -126,7 +119,7 @@ function viewlayout_submit(Pieform $form, $values) {
if ($dbcolumns != $newcolumns) {
db_rollback();
$SESSION->add_error_msg(get_string('changecolumnlayoutfailed', 'view'));
redirect(get_config('wwwroot') . 'view/layout.php?' . $params);
redirect(get_config('wwwroot') . 'view/layout.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
}
db_commit();
......@@ -134,5 +127,5 @@ function viewlayout_submit(Pieform $form, $values) {
$view->set('layout', $values['layout']);
$view->commit();
$SESSION->add_ok_msg(get_string('viewlayoutchanged', 'view'));
redirect($goto);
redirect('/view/blocks.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
}
\ No newline at end of file
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