Skip to content

Commit

Permalink
Fix undefined variable; use Horde_Url#redirect() (Bug #13293).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jun 30, 2014
1 parent aa1ab53 commit 191fb50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
33 changes: 19 additions & 14 deletions sesha/admin.php
Expand Up @@ -201,7 +201,7 @@
$vars->set('actionID', $actionID);
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_Property($vars);
$form->setTitle(_("Add a new property"));
$form->setTitle($title);
if ($form->validate($vars)) {
// Save property details.
$form->getInfo($vars, $info);
Expand All @@ -220,16 +220,16 @@

default:
case 'list_categories':
$url = Horde::url($baseUrl . '/admin.php')->add('actionID', 'edit_category');
$url = Horde::url($baseUrl . '/admin.php', true)
->add('actionID', 'edit_category');
$vars->set('actionID', 'edit_category');
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_CategoryList($vars, 'admin.php', 'post');
$valid = $form->validate($vars);
if ($valid) {
// Redirect to the category list form.
$url = Horde::url($url, true)->add('category_id', $vars->get('category_id'));
header('Location: ' . $url);
exit;
$url->add('category_id', $vars->get('category_id'));
$url->redirect();
}
$vars2 = Horde_Variables::getDefaultVariables();
$form2 = new Sesha_Form_Category($vars2, 'admin.php', 'post');
Expand All @@ -238,10 +238,11 @@
$valid = $form2->validate($vars2);
if ($valid) {
// Redirect to the category form.
$url = Horde::url($baseUrl . '/admin.php')->add('actionID', 'list_categories');
header('Location: ' . Horde::url($url, true));
exit;
$url = Horde::url($baseUrl . '/admin.php', true)
->add('actionID', 'list_categories')
->redirect();
}
$title = _("List Categories");
break;

case 'list_properties':
Expand All @@ -251,9 +252,12 @@
$valid = $form->validate($vars);
if ($valid) {
// Redirect to the property list form.
$url = Horde::url($baseUrl . '/admin.php')->add('actionID', 'edit_property')->add('property_id', $vars->get('property_id'));
header('Location: ' . Horde::url($url, true));
exit;
Horde::url($baseUrl . '/admin.php', true)
->add(array(
'actionID' => 'edit_property',
'property_id' => $vars->get('property_id')
))
->redirect();
}
$vars2 = Horde_Variables::getDefaultVariables();
$vars2->set('actionID', 'add_property');
Expand All @@ -262,10 +266,11 @@
$valid = $form2->validate($vars2);
if ($valid) {
// Redirect to the property form.
$url = Horde::url($baseUrl . '/admin.php', true)->add('actionID', 'list_properties');
header('Location: ' . $url);
exit;
Horde::url($baseUrl . '/admin.php', true)
->add('actionID', 'list_properties')
->redirect();
}
$title = _("List Properties");
break;
}

Expand Down
11 changes: 7 additions & 4 deletions sesha/stock.php
Expand Up @@ -43,7 +43,7 @@
$params = array('varrenderer_driver' => array('sesha', 'Stockedit_Html'));
$renderer = new Horde_Form_Renderer($params);
$form = new Sesha_Form_Stock($vars);
$form->setTitle(_("Add Stock To Inventory"));
$title = _("Add Stock To Inventory");

$valid = $form->validate($vars);
if ($valid && $form->isSubmitted()) {
Expand Down Expand Up @@ -94,10 +94,13 @@

case 'view_stock':
$active = false;
// Fall through.

case 'update_stock':
if (!$active) {
$form_title = _("View Inventory Item");
if ($active) {
$title = _("Edit Inventory Item");
} else {
$title = _("View Inventory Item");
}
// Get the stock item.
$stock = $sesha_driver->fetch($stock_id);
Expand Down Expand Up @@ -134,7 +137,6 @@
$params = array('varrenderer_driver' => array('sesha', 'stockedit_Html'));
$renderer = new Horde_Form_Renderer($params);
$form = new Sesha_Form_Stock($vars);
$form->setTitle((!isset($form_title) ? _("Edit Inventory Item") : $form_title));
if (!$active) {
$form->setExtra('<span class="smallheader">' . Horde::link(Horde::url('stock.php')->add(array('stock_id' => $vars->get('stock_id'), 'actionId' => 'update_stock'))) . _("Edit") . '</a></span>');
}
Expand Down Expand Up @@ -180,6 +182,7 @@
}

// Begin page display.
$form->setTitle($title);
$page_output->header(array(
'title' => $title
));
Expand Down

0 comments on commit 191fb50

Please sign in to comment.