@@ -48,20 +48,23 @@ public function listAction()
48
48
{
49
49
$ this ->disableLayout ();
50
50
51
- /** @var int $commId */
52
- $ commId = $ this ->getParam ('communityId ' );
53
- if (!isset ($ commId )) {
54
- throw new Zend_Exception ('Must pass communityId parameter ' );
51
+ /** @var int $communityId */
52
+ $ communityId = $ this ->getParam ('communityId ' );
53
+
54
+ if (!isset ($ communityId )) {
55
+ throw new Zend_Exception ('The required communityId parameter is missing ' );
55
56
}
56
57
57
- /** @var CommunityDao $comm */
58
- $ comm = $ this ->Community ->load ($ commId );
59
- if (!$ comm || !$ this ->Community ->policyCheck ($ comm , $ this ->userSession ->Dao , MIDAS_POLICY_READ )
58
+ /** @var CommunityDao $communityDao */
59
+ $ communityDao = $ this ->Community ->load ($ communityId );
60
+
61
+ if ($ communityDao === false || $ this ->Community ->policyCheck ($ communityDao , $ this ->userSession ->Dao , MIDAS_POLICY_READ ) === false
60
62
) {
61
- throw new Zend_Exception ('Read permission required on the community ' , 403 );
63
+ throw new Zend_Exception ('The community does not exist or you do not have the necessary permission ' , 403 );
62
64
}
63
- $ this ->view ->community = $ comm ;
64
- $ this ->view ->producers = $ this ->Tracker_Producer ->getByCommunityId ($ commId );
65
+
66
+ $ this ->view ->community = $ communityDao ;
67
+ $ this ->view ->producers = $ this ->Tracker_Producer ->getByCommunityId ($ communityId );
65
68
}
66
69
67
70
/**
@@ -76,27 +79,36 @@ public function viewAction()
76
79
{
77
80
/** @var int $producerId */
78
81
$ producerId = $ this ->getParam ('producerId ' );
82
+
79
83
if (!isset ($ producerId )) {
80
- throw new Zend_Exception ('Must pass producerId parameter ' );
84
+ throw new Zend_Exception ('The required producerId parameter is missing ' );
81
85
}
82
86
83
- /** @var Tracker_ProducerDao $producer */
84
- $ producer = $ this ->Tracker_Producer ->load ($ producerId );
85
- $ comm = $ producer -> getCommunity ();
86
- if (! $ producer || ! $ this ->Community ->policyCheck ($ comm , $ this ->userSession ->Dao , MIDAS_POLICY_READ )
87
+ /** @var Tracker_ProducerDao $producerDao */
88
+ $ producerDao = $ this ->Tracker_Producer ->load ($ producerId );
89
+
90
+ if ($ this ->Tracker_Producer ->policyCheck ($ producerDao , $ this ->userSession ->Dao , MIDAS_POLICY_READ ) === false
87
91
) {
88
- throw new Zend_Exception ('Read permission required on the community ' , 403 );
89
- }
90
- $ this ->view ->producer = $ producer ;
91
- $ this ->view ->trendGroups = $ this ->Tracker_Trend ->getTrendsGroupByDatasets ($ producer );
92
- $ this ->view ->isAdmin = $ this ->Community ->policyCheck ($ comm , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN );
93
- $ this ->view ->json ['tracker ' ]['producer ' ] = $ producer ;
94
-
95
- $ breadcrumbs = array (array ('type ' => 'community ' , 'object ' => $ comm , 'tab ' => 'Trackers ' ));
96
- $ breadcrumbs [] = array (
97
- 'type ' => 'custom ' ,
98
- 'text ' => $ producer ->getDisplayName (),
99
- 'icon ' => $ this ->view ->coreWebroot .'/public/images/icons/cog_go.png ' ,
92
+ throw new Zend_Exception ('The producer does not exist or you do not have the necessary permission on its community ' , 403 );
93
+ }
94
+
95
+ $ this ->view ->producer = $ producerDao ;
96
+ $ this ->view ->trendGroups = $ this ->Tracker_Trend ->getTrendsGroupByDatasets ($ producerDao );
97
+ $ this ->view ->isAdmin = $ this ->Tracker_Producer ->policyCheck ($ producerDao , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN );
98
+ $ this ->view ->json ['tracker ' ]['producer ' ] = $ producerDao ;
99
+
100
+ $ breadcrumbs = array (
101
+ array (
102
+ 'type ' => 'community ' ,
103
+ 'object ' => $ producerDao ->getCommunity (),
104
+ 'tab ' => 'Trackers ' ,
105
+ ),
106
+ array (
107
+ 'type ' => 'custom ' ,
108
+ 'text ' => $ producerDao ->getDisplayName (),
109
+ 'icon ' => $ this ->view ->baseUrl ('core/public/images/icons/cog_go.png ' ),
110
+ ),
111
+
100
112
);
101
113
$ this ->Component ->Breadcrumb ->setBreadcrumbHeader ($ breadcrumbs , $ this ->view );
102
114
}
@@ -116,18 +128,20 @@ public function deleteAction()
116
128
117
129
/** @var int $producerId */
118
130
$ producerId = $ this ->getParam ('producerId ' );
131
+
119
132
if (!isset ($ producerId )) {
120
- throw new Zend_Exception ('Must pass producerId parameter ' );
133
+ throw new Zend_Exception ('The required producerId parameter is missing ' );
121
134
}
122
135
123
- /** @var Tracker_ProducerDao $producer */
124
- $ producer = $ this ->Tracker_Producer ->load ($ producerId );
125
- $ comm = $ producer -> getCommunity ();
126
- if (! $ producer || ! $ this ->Community ->policyCheck ($ comm , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN )
136
+ /** @var Tracker_ProducerDao $producerDao */
137
+ $ producerDao = $ this ->Tracker_Producer ->load ($ producerId );
138
+
139
+ if ($ this ->Tracker_Producer ->policyCheck ($ producerDao , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN ) === false
127
140
) {
128
- throw new Zend_Exception ('Admin permission required on the community ' , 403 );
141
+ throw new Zend_Exception ('The producer does not exist or you do not have the necessary permission on its community ' , 403 );
129
142
}
130
- $ this ->Tracker_Producer ->delete ($ producer );
143
+
144
+ $ this ->Tracker_Producer ->delete ($ producerDao );
131
145
}
132
146
133
147
/**
@@ -141,20 +155,19 @@ public function editAction()
141
155
$ producerId = $ this ->getParam ('producerId ' );
142
156
143
157
if (!isset ($ producerId )) {
144
- throw new Zend_Exception ('Must pass producerId parameter ' );
158
+ throw new Zend_Exception ('The required producerId parameter is missing ' );
145
159
}
146
160
147
- /** @var Tracker_ProducerDao $producer */
148
- $ producer = $ this ->Tracker_Producer ->load ($ producerId );
149
- if (!$ producer ) {
150
- throw new Zend_Exception ('Invalid producerId ' , 404 );
151
- }
152
- if (!$ this ->Community ->policyCheck ($ producer ->getCommunity (), $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN )
161
+ /** @var Tracker_ProducerDao $producerDao */
162
+ $ producerDao = $ this ->Tracker_Producer ->load ($ producerId );
163
+
164
+ if ($ this ->Tracker_Producer ->policyCheck ($ producerDao , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN ) === false
153
165
) {
154
- throw new Zend_Exception ('Admin permission required on the community ' , 403 );
166
+ throw new Zend_Exception ('The producer does not exist or you do not have the necessary permission on its community ' , 403 );
155
167
}
168
+
156
169
$ this ->disableLayout ();
157
- $ this ->view ->producer = $ producer ;
170
+ $ this ->view ->producer = $ producerDao ;
158
171
}
159
172
160
173
/**
@@ -177,34 +190,50 @@ public function editsubmitAction()
177
190
throw new Zend_Exception ('Must pass producerId parameter ' );
178
191
}
179
192
180
- /** @var Tracker_ProducerDao $producer */
181
- $ producer = $ this ->Tracker_Producer ->load ($ producerId );
182
- if (!$ this ->Community ->policyCheck ($ producer ->getCommunity (), $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN )
193
+ /** @var Tracker_ProducerDao $producerDao */
194
+ $ producerDao = $ this ->Tracker_Producer ->load ($ producerId );
195
+
196
+ if ($ this ->Tracker_Producer ->policyCheck ($ producerDao , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN ) === false
183
197
) {
184
- throw new Zend_Exception ('Admin permission required on the community ' , 403 );
198
+ throw new Zend_Exception ('The producer does not exist or you do not have the necessary permission on its community ' , 403 );
185
199
}
200
+
201
+ /** @var string $displayName */
186
202
$ displayName = $ this ->getParam ('displayName ' );
187
- $ description = $ this ->getParam ('description ' );
188
- $ repository = $ this ->getParam ('repository ' );
189
- $ revisionUrl = $ this ->getParam ('revisionUrl ' );
190
- $ executableName = $ this ->getParam ('executableName ' );
191
203
192
204
if (isset ($ displayName )) {
193
- $ producer ->setDisplayName ($ displayName );
205
+ $ producerDao ->setDisplayName ($ displayName );
194
206
}
207
+
208
+ /** @var string $description */
209
+ $ description = $ this ->getParam ('description ' );
210
+
195
211
if (isset ($ description )) {
196
- $ producer ->setDescription ($ description );
212
+ $ producerDao ->setDescription ($ description );
197
213
}
214
+
215
+ /** @var string $repository */
216
+ $ repository = $ this ->getParam ('repository ' );
217
+
198
218
if (isset ($ repository )) {
199
- $ producer ->setRepository ($ repository );
200
- }
201
- if (isset ($ executableName )) {
202
- $ producer ->setExecutableName ($ executableName );
219
+ $ producerDao ->setRepository ($ repository );
203
220
}
221
+
222
+ /** @var string $revisionUrl */
223
+ $ revisionUrl = $ this ->getParam ('revisionUrl ' );
224
+
204
225
if (isset ($ revisionUrl )) {
205
- $ producer ->setRevisionUrl ($ revisionUrl );
226
+ $ producerDao ->setRevisionUrl ($ revisionUrl );
206
227
}
207
- $ this ->Tracker_Producer ->save ($ producer );
208
- echo JsonComponent::encode (array ('status ' => 'ok ' , 'message ' => 'Changes saved ' , 'producer ' => $ producer ));
228
+
229
+ /** @var string $executableName */
230
+ $ executableName = $ this ->getParam ('executableName ' );
231
+
232
+ if (isset ($ executableName )) {
233
+ $ producerDao ->setExecutableName ($ executableName );
234
+ }
235
+
236
+ $ this ->Tracker_Producer ->save ($ producerDao );
237
+ echo JsonComponent::encode (array ('status ' => 'ok ' , 'message ' => 'Changes saved ' , 'producer ' => $ producerDao ));
209
238
}
210
239
}
0 commit comments