Skip to content

Commit 72faebf

Browse files
author
zanardi
committed
Refs #12130
1 parent 403a101 commit 72faebf

File tree

3 files changed

+125
-53
lines changed

3 files changed

+125
-53
lines changed

component/backend/models/abstract.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,15 @@ public function publish($bool)
154154

155155
public function checkout()
156156
{
157-
$user = & JFactory::getUser();
158-
$row = & $this->getRow();
157+
$user = JFactory::getUser();
158+
if ($user->guest)
159+
{
160+
return false;
161+
}
159162

163+
$row = $this->getRow();
160164
if ($row->isCheckedOut($user->get('id'), $row->checked_out))
161165
{
162-
$msg = 'Record locked';
163-
JError::raiseWarning(200, $msg);
164166
return false;
165167
}
166168

component/frontend/controllers/orders.php

+68-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
<?php
22

33
/**
4-
* @version frontend/controllers/orders.php 2013-07-07 1954:00Z zanardi
4+
* @version frontend/controllers/orders.php 2014-11-10 17:00:00 UTC zanardi
55
* @package GiBi PizzaBox
66
* @author GiBiLogic <[email protected]>
77
* @authorUrl http://www.gibilogic.com
8-
* @copyright (C) 2011-2013 GiBiLogic. All rights reserved.
9-
* @license GNU/GPL v2 or later
8+
* @copyright (C) 2011-2014 GiBiLogic. All rights reserved.
9+
* @license GNU/GPL v3 or later
1010
*/
11-
defined('_JEXEC') or die('The way is shut!');
12-
11+
defined('_JEXEC') or die();
1312
jimport('joomla.application.component.controller');
1413

14+
/**
15+
* PizzaboxControllerOrders class
16+
*/
1517
class PizzaboxControllerOrders extends JControllerLegacy
1618
{
1719

1820
public $_controllerUrl = '';
1921
public $_model = NULL;
2022

23+
/**
24+
*
25+
* @param array $default
26+
*/
2127
public function __construct($default = array())
2228
{
23-
if (!JRequest::getCmd('view')) {
29+
if (!JRequest::getCmd('view'))
30+
{
2431
JRequest::setVar('view', 'orders');
2532
}
2633

@@ -42,51 +49,72 @@ public function __construct($default = array())
4249
$this->_deliveryControllerUrl = JRoute::_('index.php?option=com_pizzabox&controller=delivery', false);
4350
}
4451

52+
/**
53+
*
54+
* @param string $tpl
55+
*/
4556
public function display($tpl = null)
4657
{
47-
$params = & JComponentHelper::getParams('com_pizzabox');
48-
if ($params->get('registered_users_only', 1) == 1) {
58+
$params = JComponentHelper::getParams('com_pizzabox');
59+
if ($params->get('registered_users_only', 1) == 1)
60+
{
4961
$user = JFactory::getUser();
50-
if ($user->guest) {
62+
if ($user->guest)
63+
{
5164
$msg = JText::_('PIZZABOX_REGISTERED_ONLY');
5265
$link = JRoute::_('index.php?option=com_users&task=register', false);
5366
$this->setRedirect($link, $msg, 'error');
5467
}
5568
}
5669

57-
if (JRequest::getVar('change_status') == TRUE) {
70+
if (JRequest::getVar('change_status') == TRUE)
71+
{
5872
$this->changeStatus();
5973
}
6074

61-
$view = & $this->getView('orders', 'html');
75+
$view = $this->getView('orders', 'html');
6276
$view->setModel($this->_model, true);
6377
$view->display($tpl);
6478
}
6579

80+
/**
81+
*
82+
*/
6683
public function edit()
6784
{
68-
if ($this->_model->checkout()) {
85+
if ($this->_model->checkout())
86+
{
6987
$this->display('form');
7088
}
71-
else {
72-
$this->_setDefaultRedirect();
89+
else
90+
{
91+
$msg = JText::_('Access denied');
92+
$this->setRedirect($this->_controllerUrl, $msg, 'error');
7393
}
7494
}
7595

96+
/**
97+
*
98+
*/
7699
public function changeStatus()
77100
{
78101
JRequest::checkToken() or die('PIZZABOX_INVALID_TOKEN');
79102

80-
if ($this->_model->changeStatus()) {
103+
if ($this->_model->changeStatus())
104+
{
81105
$msg = JText::sprintf('PIZZABOX_CHANGE_STATUS_SUCCESS', count($this->_model->getCid()));
82106
$this->setRedirect($this->_controllerUrl, $msg);
83107
}
84-
else {
108+
else
109+
{
85110
$msg = JText::_('PIZZABOX_CHANGE_STATUS_ERROR');
86111
$this->setRedirect($this->_controllerUrl, $msg, 'error');
87112
}
88113
}
89114

115+
/**
116+
*
117+
*/
90118
public function setStatus()
91119
{
92120
$task = JRequest::getVar('task');
@@ -95,50 +123,67 @@ public function setStatus()
95123
$this->changeStatus();
96124
}
97125

126+
/**
127+
*
128+
*/
98129
public function save()
99130
{
100131
JRequest::checkToken() or die('PIZZABOX_INVALID_TOKEN');
101132
$result = $this->_model->save();
102-
if (false === $result) {
133+
if (false === $result)
134+
{
103135
$msg = JText::_('PIZZABOX_SAVE_ERROR');
104136
$type = 'error';
105137
}
106-
else {
138+
else
139+
{
107140
$msg = JText::_('PIZZABOX_SAVE_OK');
108141
$type = '';
109142
}
110143
$this->setRedirect($this->_controllerUrl, $msg, $type);
111144
}
112145

146+
/**
147+
*
148+
*/
113149
public function remove()
114150
{
115151
JRequest::checkToken() or die('PIZZABOX_INVALID_TOKEN');
116152

117-
if ($this->_model->remove()) {
153+
if ($this->_model->remove())
154+
{
118155
$msg = JText::sprintf('PIZZABOX_REMOVE_SUCCESS', count($this->_model->getCid()));
119156
$this->setRedirect($this->_controllerUrl, $msg);
120157
}
121-
else {
158+
else
159+
{
122160
$msg = JText::_('PIZZABOX_REMOVE_ERROR');
123161
$this->setRedirect($this->_controllerUrl, $msg, 'error');
124162
}
125163
}
126164

165+
/**
166+
*
167+
* @return type
168+
*/
127169
public function repeat()
128170
{
129171
$id = JRequest::getInt('id');
130-
if (!$id) {
172+
if (!$id)
173+
{
131174
$msg = JText::_('PIZZABOX_REPEAT_ERROR_NO_ID');
132175
$this->setRedirect($this->_controllerUrl, $msg, 'error');
133176
return;
134177
}
135178
$this->_model->setId($id);
136179
$new_id = $this->_model->copy();
137-
if (!$new_id) {
180+
if (!$new_id)
181+
{
138182
$msg = JText::_('PIZZABOX_REPEAT_ERROR_COPY');
139183
$this->setRedirect($this->_controllerUrl, $msg, 'error');
140184
}
141-
else {
185+
else
186+
{
142187
// set default status and empty delivery for new order
143188
$this->_model->setId($new_id);
144189
$this->_model->setDefaultStatus();

0 commit comments

Comments
 (0)