1
1
<?php
2
2
3
3
/**
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
5
5
* @package GiBi PizzaBox
6
6
* @author GiBiLogic <[email protected] >
7
7
* @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
10
10
*/
11
- defined ('_JEXEC ' ) or die ('The way is shut! ' );
12
-
11
+ defined ('_JEXEC ' ) or die ();
13
12
jimport ('joomla.application.component.controller ' );
14
13
14
+ /**
15
+ * PizzaboxControllerOrders class
16
+ */
15
17
class PizzaboxControllerOrders extends JControllerLegacy
16
18
{
17
19
18
20
public $ _controllerUrl = '' ;
19
21
public $ _model = NULL ;
20
22
23
+ /**
24
+ *
25
+ * @param array $default
26
+ */
21
27
public function __construct ($ default = array ())
22
28
{
23
- if (!JRequest::getCmd ('view ' )) {
29
+ if (!JRequest::getCmd ('view ' ))
30
+ {
24
31
JRequest::setVar ('view ' , 'orders ' );
25
32
}
26
33
@@ -42,51 +49,72 @@ public function __construct($default = array())
42
49
$ this ->_deliveryControllerUrl = JRoute::_ ('index.php?option=com_pizzabox&controller=delivery ' , false );
43
50
}
44
51
52
+ /**
53
+ *
54
+ * @param string $tpl
55
+ */
45
56
public function display ($ tpl = null )
46
57
{
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
+ {
49
61
$ user = JFactory::getUser ();
50
- if ($ user ->guest ) {
62
+ if ($ user ->guest )
63
+ {
51
64
$ msg = JText::_ ('PIZZABOX_REGISTERED_ONLY ' );
52
65
$ link = JRoute::_ ('index.php?option=com_users&task=register ' , false );
53
66
$ this ->setRedirect ($ link , $ msg , 'error ' );
54
67
}
55
68
}
56
69
57
- if (JRequest::getVar ('change_status ' ) == TRUE ) {
70
+ if (JRequest::getVar ('change_status ' ) == TRUE )
71
+ {
58
72
$ this ->changeStatus ();
59
73
}
60
74
61
- $ view = & $ this ->getView ('orders ' , 'html ' );
75
+ $ view = $ this ->getView ('orders ' , 'html ' );
62
76
$ view ->setModel ($ this ->_model , true );
63
77
$ view ->display ($ tpl );
64
78
}
65
79
80
+ /**
81
+ *
82
+ */
66
83
public function edit ()
67
84
{
68
- if ($ this ->_model ->checkout ()) {
85
+ if ($ this ->_model ->checkout ())
86
+ {
69
87
$ this ->display ('form ' );
70
88
}
71
- else {
72
- $ this ->_setDefaultRedirect ();
89
+ else
90
+ {
91
+ $ msg = JText::_ ('Access denied ' );
92
+ $ this ->setRedirect ($ this ->_controllerUrl , $ msg , 'error ' );
73
93
}
74
94
}
75
95
96
+ /**
97
+ *
98
+ */
76
99
public function changeStatus ()
77
100
{
78
101
JRequest::checkToken () or die ('PIZZABOX_INVALID_TOKEN ' );
79
102
80
- if ($ this ->_model ->changeStatus ()) {
103
+ if ($ this ->_model ->changeStatus ())
104
+ {
81
105
$ msg = JText::sprintf ('PIZZABOX_CHANGE_STATUS_SUCCESS ' , count ($ this ->_model ->getCid ()));
82
106
$ this ->setRedirect ($ this ->_controllerUrl , $ msg );
83
107
}
84
- else {
108
+ else
109
+ {
85
110
$ msg = JText::_ ('PIZZABOX_CHANGE_STATUS_ERROR ' );
86
111
$ this ->setRedirect ($ this ->_controllerUrl , $ msg , 'error ' );
87
112
}
88
113
}
89
114
115
+ /**
116
+ *
117
+ */
90
118
public function setStatus ()
91
119
{
92
120
$ task = JRequest::getVar ('task ' );
@@ -95,50 +123,67 @@ public function setStatus()
95
123
$ this ->changeStatus ();
96
124
}
97
125
126
+ /**
127
+ *
128
+ */
98
129
public function save ()
99
130
{
100
131
JRequest::checkToken () or die ('PIZZABOX_INVALID_TOKEN ' );
101
132
$ result = $ this ->_model ->save ();
102
- if (false === $ result ) {
133
+ if (false === $ result )
134
+ {
103
135
$ msg = JText::_ ('PIZZABOX_SAVE_ERROR ' );
104
136
$ type = 'error ' ;
105
137
}
106
- else {
138
+ else
139
+ {
107
140
$ msg = JText::_ ('PIZZABOX_SAVE_OK ' );
108
141
$ type = '' ;
109
142
}
110
143
$ this ->setRedirect ($ this ->_controllerUrl , $ msg , $ type );
111
144
}
112
145
146
+ /**
147
+ *
148
+ */
113
149
public function remove ()
114
150
{
115
151
JRequest::checkToken () or die ('PIZZABOX_INVALID_TOKEN ' );
116
152
117
- if ($ this ->_model ->remove ()) {
153
+ if ($ this ->_model ->remove ())
154
+ {
118
155
$ msg = JText::sprintf ('PIZZABOX_REMOVE_SUCCESS ' , count ($ this ->_model ->getCid ()));
119
156
$ this ->setRedirect ($ this ->_controllerUrl , $ msg );
120
157
}
121
- else {
158
+ else
159
+ {
122
160
$ msg = JText::_ ('PIZZABOX_REMOVE_ERROR ' );
123
161
$ this ->setRedirect ($ this ->_controllerUrl , $ msg , 'error ' );
124
162
}
125
163
}
126
164
165
+ /**
166
+ *
167
+ * @return type
168
+ */
127
169
public function repeat ()
128
170
{
129
171
$ id = JRequest::getInt ('id ' );
130
- if (!$ id ) {
172
+ if (!$ id )
173
+ {
131
174
$ msg = JText::_ ('PIZZABOX_REPEAT_ERROR_NO_ID ' );
132
175
$ this ->setRedirect ($ this ->_controllerUrl , $ msg , 'error ' );
133
176
return ;
134
177
}
135
178
$ this ->_model ->setId ($ id );
136
179
$ new_id = $ this ->_model ->copy ();
137
- if (!$ new_id ) {
180
+ if (!$ new_id )
181
+ {
138
182
$ msg = JText::_ ('PIZZABOX_REPEAT_ERROR_COPY ' );
139
183
$ this ->setRedirect ($ this ->_controllerUrl , $ msg , 'error ' );
140
184
}
141
- else {
185
+ else
186
+ {
142
187
// set default status and empty delivery for new order
143
188
$ this ->_model ->setId ($ new_id );
144
189
$ this ->_model ->setDefaultStatus ();
0 commit comments