Completed
Push — master ( f480bf...21d5d4 )
by Patrick
03:35
created
themes/api/v1/index.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -95,6 +95,9 @@
 block discarded – undo
95 95
     echo json_encode($objs);
96 96
 }
97 97
 
98
+/**
99
+ * @param boolean $field
100
+ */
98 101
 function obj_list_with_filter($field)
99 102
 {
100 103
     global $app;
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 
28 28
 function validate_user_is_admin($user)
29 29
 {
30
-   return $user->isInGroupNamed('ThemeAdmins');
30
+    return $user->isInGroupNamed('ThemeAdmins');
31 31
 }
32 32
 
33 33
 function validate_user_has_access($user, $obj)
34 34
 {
35
-   if($user->isInGroupNamed('ThemeAdmins'))
36
-   {
37
-       return true;
38
-   }
39
-   return in_array($user->getUid(), $obj['registrars']);
35
+    if($user->isInGroupNamed('ThemeAdmins'))
36
+    {
37
+        return true;
38
+    }
39
+    return in_array($user->getUid(), $obj['registrars']);
40 40
 }
41 41
 
42 42
 function list_obj()
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
     $params = $app->request->params();
50 50
     if(isset($params['fmt']))
51 51
     {
52
-       unset($params['fmt']);
52
+        unset($params['fmt']);
53 53
     }
54 54
     if(isset($params['_']))
55 55
     {
56
-       unset($params['_']);
56
+        unset($params['_']);
57 57
     }
58 58
     $logo_urls = false;
59 59
     $db = new ThemeDB();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         {
145 145
             if(!validate_user_is_admin($app->user))
146 146
             {
147
-               trim_obj($obj);
147
+                trim_obj($obj);
148 148
             }
149 149
             else if($field === false)
150 150
             {
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('class.FlipREST.php');
3 3
 require_once('class.ThemeDB.php');
4 4
 
5
-if($_SERVER['REQUEST_URI'][0] == '/' && $_SERVER['REQUEST_URI'][1] == '/')
5
+if ($_SERVER['REQUEST_URI'][0] == '/' && $_SERVER['REQUEST_URI'][1] == '/')
6 6
 {
7 7
     $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 1);
8 8
 }
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 
13 13
 function trim_obj(&$obj)
14 14
 {
15
-    foreach($obj as $key=>$value)
15
+    foreach ($obj as $key=>$value)
16 16
     {
17
-        if($key == '_id')
17
+        if ($key == '_id')
18 18
         {
19
-            $obj['_id'] = (string)$obj['_id'];
19
+            $obj['_id'] = (string) $obj['_id'];
20 20
         }
21
-        else if(is_object($value) || is_array($value))
21
+        else if (is_object($value) || is_array($value))
22 22
         {
23 23
             unset($obj[$key]);
24 24
         }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 function validate_user_has_access($user, $obj)
34 34
 {
35
-   if($user->isInGroupNamed('ThemeAdmins'))
35
+   if ($user->isInGroupNamed('ThemeAdmins'))
36 36
    {
37 37
        return true;
38 38
    }
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
 function list_obj()
43 43
 {
44 44
     global $app;
45
-    if(!$app->user)
45
+    if (!$app->user)
46 46
     {
47 47
         throw new Exception('Must be logged in', ACCESS_DENIED);
48 48
     }
49 49
     $params = $app->request->params();
50
-    if(isset($params['fmt']))
50
+    if (isset($params['fmt']))
51 51
     {
52 52
        unset($params['fmt']);
53 53
     }
54
-    if(isset($params['_']))
54
+    if (isset($params['_']))
55 55
     {
56 56
        unset($params['_']);
57 57
     }
58 58
     $logo_urls = false;
59 59
     $db = new ThemeDB();
60 60
     $fields = false;
61
-    if(isset($params['no_logo']))
61
+    if (isset($params['no_logo']))
62 62
     {
63 63
         $fields = array('logo' => false);
64 64
         unset($params['no_logo']);
65 65
     }
66
-    if(isset($params['logo_url']))
66
+    if (isset($params['logo_url']))
67 67
     {
68 68
         $logo_urls = true;
69 69
         unset($params['logo_url']);
70 70
     }
71
-    if(count($params))
71
+    if (count($params))
72 72
     {
73 73
         $objs = $db->searchFromCollection('themes', $params, $fields);
74 74
     }
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $objs = $db->getAllFromCollection('themes', false, false, $fields);
78 78
     }
79
-    if(!validate_user_is_admin($app->user))
79
+    if (!validate_user_is_admin($app->user))
80 80
     {
81 81
         $count = count($objs);
82
-        for($i = 0; $i < $count; $i++)
82
+        for ($i = 0; $i < $count; $i++)
83 83
         {
84 84
             trim_obj($objs[$i]);
85 85
         }
86 86
     }
87 87
     $count = count($objs);
88
-    for($i = 0; $i < $count; $i++)
88
+    for ($i = 0; $i < $count; $i++)
89 89
     {
90
-        if($logo_urls && isset($objs[$i]['logo']))
90
+        if ($logo_urls && isset($objs[$i]['logo']))
91 91
         {
92 92
             $objs[$i]['logo'] = $app->request->getUrl().$app->request->getPath().'/'.$objs[$i]['_id'].'/logo';
93 93
         }
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 function obj_list_with_filter($field)
99 99
 {
100 100
     global $app;
101
-    if(!$app->user)
101
+    if (!$app->user)
102 102
     {
103 103
         throw new Exception('Must be logged in', ACCESS_DENIED);
104 104
     }
105
-    if(!validate_user_is_admin($app->user, $collection))
105
+    if (!validate_user_is_admin($app->user, $collection))
106 106
     {
107 107
         throw new Exception('User not admin', ACCESS_DENIED);
108 108
     }
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
     $objs = $db->getAllFromCollection('themes');
111 111
     $res = array();
112 112
     $count = count($objs);
113
-    for($i = 0; $i < $count; $i++)
113
+    for ($i = 0; $i < $count; $i++)
114 114
     {
115
-        if(isset($objs[$i][$field]))
115
+        if (isset($objs[$i][$field]))
116 116
         {
117 117
             array_push($res, $objs[$i][$field]);
118 118
         }
@@ -123,36 +123,36 @@  discard block
 block discarded – undo
123 123
 function obj_view($id, $field = FALSE)
124 124
 {
125 125
     global $app;
126
-    if(!$app->user)
126
+    if (!$app->user)
127 127
     {
128 128
         throw new Exception('Must be logged in', ACCESS_DENIED);
129 129
     }
130 130
     $db = new ThemeDB();
131
-    if($id === '*')
131
+    if ($id === '*')
132 132
     {
133 133
         obj_list_with_filter($field);
134 134
         return;
135 135
     }
136 136
     $obj = $db->getObjectFromCollectionByID('themes', $id);
137
-    if($obj === FALSE)
137
+    if ($obj === FALSE)
138 138
     {
139 139
         throw new Exception('Unable to obtain object!', INTERNAL_ERROR);
140 140
     }
141 141
     else
142 142
     {
143
-        if($app->request->params('full') === null)
143
+        if ($app->request->params('full') === null)
144 144
         {
145
-            if(!validate_user_is_admin($app->user))
145
+            if (!validate_user_is_admin($app->user))
146 146
             {
147 147
                trim_obj($obj);
148 148
             }
149
-            else if($field === false)
149
+            else if ($field === false)
150 150
             {
151 151
                 trim_obj($obj);
152 152
             }
153
-            if($field !== FALSE)
153
+            if ($field !== FALSE)
154 154
             {
155
-                if(!is_array($obj[$field]) && strncmp($obj[$field], 'data:', 5) === 0)
155
+                if (!is_array($obj[$field]) && strncmp($obj[$field], 'data:', 5) === 0)
156 156
                 {
157 157
                     $app->fmt = 'passthru';
158 158
                     $str = substr($obj[$field], 5);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         }
172 172
         else
173 173
         {
174
-            if(validate_user_has_access($app->user, $obj) === FALSE)
174
+            if (validate_user_has_access($app->user, $obj) === FALSE)
175 175
             {
176 176
                 throw new Exception('Cannot edit object that is not yours', ACCESS_DENIED);
177 177
             }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 function obj_add()
184 184
 {
185 185
     global $app;
186
-    if(!$app->user)
186
+    if (!$app->user)
187 187
     {
188 188
         throw new Exception('Must be logged in', ACCESS_DENIED);
189 189
     }
@@ -193,17 +193,17 @@  discard block
 block discarded – undo
193 193
     $obj  = json_decode($body);
194 194
     $obj  = get_object_vars($obj);
195 195
     //Ensure minimum fields are set...
196
-    if(!isset($obj['name']))
196
+    if (!isset($obj['name']))
197 197
     {
198 198
         throw new Exception('Missing one or more required parameters!', INTERNAL_ERROR);
199 199
     }
200 200
     $obj['year'] = $db->getCurrentYear();
201
-    if(!isset($obj['registrars']))
201
+    if (!isset($obj['registrars']))
202 202
     {
203 203
         $obj['registrars'] = array();
204 204
     }
205 205
     array_push($obj['registrars'], $app->user->getUid());
206
-    if(isset($obj['_id']) && strlen($obj['_id']) > 0)
206
+    if (isset($obj['_id']) && strlen($obj['_id']) > 0)
207 207
     {
208 208
         $app->redirect('themes/'.$obj['_id'], 307);
209 209
         return;
@@ -212,61 +212,61 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $res = $db->addObjectToCollection('themes', $obj);
214 214
     }
215
-    if($res === FALSE)
215
+    if ($res === FALSE)
216 216
     {
217 217
         throw new Exception('Unable to add theme!', INTERNAL_ERROR);
218 218
     }
219 219
     else
220 220
     {
221
-        echo json_encode(array('_id'=>(string)$res, 'url'=>$app->request->getUrl().$app->request->getPath().'/'.(string)$res));
221
+        echo json_encode(array('_id'=>(string) $res, 'url'=>$app->request->getUrl().$app->request->getPath().'/'.(string) $res));
222 222
     }
223 223
 }
224 224
 
225 225
 function obj_edit($id)
226 226
 {
227 227
     global $app;
228
-    if(!$app->user)
228
+    if (!$app->user)
229 229
     {
230 230
         throw new Exception('Must be logged in', ACCESS_DENIED);
231 231
     }
232 232
     $db = new ThemeDB();
233 233
     $old_obj = $db->getObjectFromCollectionByID('themes', $id);
234
-    if(validate_user_has_access($app->user, $old_obj) === FALSE)
234
+    if (validate_user_has_access($app->user, $old_obj) === FALSE)
235 235
     {
236 236
         throw new Exception('Cannot edit object that is not yours', ACCESS_DENIED);
237 237
     }
238 238
     $obj = $app->request->params();
239
-    if($obj === null || count($obj) === 0)
239
+    if ($obj === null || count($obj) === 0)
240 240
     {
241 241
         $body = $app->request->getBody();
242 242
         $obj  = json_decode($body);
243 243
         $obj  = get_object_vars($obj);
244 244
     }
245 245
     //Ensure minimum fields are set...
246
-    if(!isset($obj['name']))
246
+    if (!isset($obj['name']))
247 247
     {
248 248
         throw new Exception('Missing one or more required parameters!', INTERNAL_ERROR);
249 249
     }
250 250
     $obj['year'] = $db->getCurrentYear();
251
-    if(!isset($obj['registrars']))
251
+    if (!isset($obj['registrars']))
252 252
     {
253 253
         $obj['registrars'] = array();
254 254
     }
255 255
     $obj['registrars'] = array_merge($obj['registrars'], $old_obj['registrars']);
256
-    if(validate_user_is_admin($app->user) === FALSE)
256
+    if (validate_user_is_admin($app->user) === FALSE)
257 257
     {
258 258
         $uid = $app->user->getUid();
259
-        if(!in_array($uid, $obj['registrars']))
259
+        if (!in_array($uid, $obj['registrars']))
260 260
         {
261 261
             array_push($obj['registrars'], $app->user->getUid());
262 262
         }
263 263
     }
264
-    if(!isset($obj['_id']))
264
+    if (!isset($obj['_id']))
265 265
     {
266 266
         $obj['_id'] = $id;
267 267
     }
268 268
     $res = $db->updateObjectInCollection('themes', $obj);
269
-    if($res === FALSE)
269
+    if ($res === FALSE)
270 270
     {
271 271
         throw new Exception('Unable to update object!', INTERNAL_ERROR);
272 272
     }
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
 function obj_delete($id)
280 280
 {
281 281
     global $app;
282
-    if(!$app->user)
282
+    if (!$app->user)
283 283
     {
284 284
         throw new Exception('Must be logged in', ACCESS_DENIED);
285 285
     }
286 286
     $db = new ThemeDB();
287 287
     $old_obj = $db->getObjectFromCollectionByID('themes', $id);
288
-    if(validate_user_has_access($app->user, $old_obj) === FALSE)
288
+    if (validate_user_has_access($app->user, $old_obj) === FALSE)
289 289
     {
290 290
         throw new Exception('Cannot delete object that is not yours', ACCESS_DENIED);
291 291
     }
292 292
     $res = $db->deleteObjectFromCollection('themes', $old_obj);
293
-    if($res === false)
293
+    if ($res === false)
294 294
     {
295 295
         throw new Exception('Unable to delete object!', INTERNAL_ERROR);
296 296
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@  discard block
 block discarded – undo
17 17
         if($key == '_id')
18 18
         {
19 19
             $obj['_id'] = (string)$obj['_id'];
20
-        }
21
-        else if(is_object($value) || is_array($value))
20
+        } else if(is_object($value) || is_array($value))
22 21
         {
23 22
             unset($obj[$key]);
24 23
         }
@@ -71,8 +70,7 @@  discard block
 block discarded – undo
71 70
     if(count($params))
72 71
     {
73 72
         $objs = $db->searchFromCollection('themes', $params, $fields);
74
-    }
75
-    else
73
+    } else
76 74
     {
77 75
         $objs = $db->getAllFromCollection('themes', false, false, $fields);
78 76
     }
@@ -137,16 +135,14 @@  discard block
 block discarded – undo
137 135
     if($obj === FALSE)
138 136
     {
139 137
         throw new Exception('Unable to obtain object!', INTERNAL_ERROR);
140
-    }
141
-    else
138
+    } else
142 139
     {
143 140
         if($app->request->params('full') === null)
144 141
         {
145 142
             if(!validate_user_is_admin($app->user))
146 143
             {
147 144
                trim_obj($obj);
148
-            }
149
-            else if($field === false)
145
+            } else if($field === false)
150 146
             {
151 147
                 trim_obj($obj);
152 148
             }
@@ -161,15 +157,13 @@  discard block
 block discarded – undo
161 157
                     $str = strtok("\0");
162 158
                     print(base64_decode($str));
163 159
                     $app->response->headers->set('Content-Type', $type);
164
-                }
165
-                else
160
+                } else
166 161
                 {
167 162
                     echo json_encode($obj[$field]);
168 163
                 }
169 164
                 return;
170 165
             }
171
-        }
172
-        else
166
+        } else
173 167
         {
174 168
             if(validate_user_has_access($app->user, $obj) === FALSE)
175 169
             {
@@ -207,16 +201,14 @@  discard block
 block discarded – undo
207 201
     {
208 202
         $app->redirect('themes/'.$obj['_id'], 307);
209 203
         return;
210
-    }
211
-    else
204
+    } else
212 205
     {
213 206
         $res = $db->addObjectToCollection('themes', $obj);
214 207
     }
215 208
     if($res === FALSE)
216 209
     {
217 210
         throw new Exception('Unable to add theme!', INTERNAL_ERROR);
218
-    }
219
-    else
211
+    } else
220 212
     {
221 213
         echo json_encode(array('_id'=>(string)$res, 'url'=>$app->request->getUrl().$app->request->getPath().'/'.(string)$res));
222 214
     }
@@ -269,8 +261,7 @@  discard block
 block discarded – undo
269 261
     if($res === FALSE)
270 262
     {
271 263
         throw new Exception('Unable to update object!', INTERNAL_ERROR);
272
-    }
273
-    else
264
+    } else
274 265
     {
275 266
         echo json_encode(array('update'=>TRUE));
276 267
     }
@@ -293,8 +284,7 @@  discard block
 block discarded – undo
293 284
     if($res === false)
294 285
     {
295 286
         throw new Exception('Unable to delete object!', INTERNAL_ERROR);
296
-    }
297
-    else
287
+    } else
298 288
     {
299 289
         echo json_encode(array('delete'=>TRUE));
300 290
     }
Please login to merge, or discard this patch.
themes/class.ThemeDB.php 4 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -24,6 +24,9 @@  discard block
 block discarded – undo
24 24
         return $data[0]['value'];
25 25
     }
26 26
 
27
+    /**
28
+     * @param string $collection
29
+     */
27 30
     function getAllFromCollection($collection, $year = false, $uid = false, $fields = false)
28 31
     {
29 32
         if($year === false)
@@ -48,6 +51,9 @@  discard block
 block discarded – undo
48 51
         return $data;
49 52
     }
50 53
 
54
+    /**
55
+     * @param string $collection
56
+     */
51 57
     function searchFromCollection($collection, $criteria, $fields = false)
52 58
     {
53 59
         $col = $this->db->selectCollection($collection);
@@ -71,6 +77,9 @@  discard block
 block discarded – undo
71 77
         return $ret;
72 78
     }
73 79
 
80
+    /**
81
+     * @param string $collection
82
+     */
74 83
     function getObjectFromCollectionByID($collection, $id)
75 84
     {
76 85
         $table = $this->dataSet[$collection];
@@ -82,6 +91,9 @@  discard block
 block discarded – undo
82 91
         return $data[0];
83 92
     }
84 93
 
94
+    /**
95
+     * @param string $collection
96
+     */
85 97
     function addObjectToCollection($collection, $obj)
86 98
     {
87 99
          unset($obj['_id']);
@@ -94,6 +106,9 @@  discard block
 block discarded – undo
94 106
          return false;
95 107
     }
96 108
 
109
+    /**
110
+     * @param string $collection
111
+     */
97 112
     function updateObjectInCollection($collection, $obj)
98 113
     {
99 114
         $id = $obj['_id'];
@@ -107,6 +122,9 @@  discard block
 block discarded – undo
107 122
         return false;
108 123
     }
109 124
 
125
+    /**
126
+     * @param string $collection
127
+     */
110 128
     function deleteObjectFromCollection($collection, $obj)
111 129
     {
112 130
         $id = $obj['_id'];
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 
85 85
     function addObjectToCollection($collection, $obj)
86 86
     {
87
-         unset($obj['_id']);
88
-         $table = $this->dataSet[$collection];
89
-         $res = $table->create($obj);
90
-         if($res !== false)
91
-         {
92
-             return $res;
93
-         }
94
-         return false;
87
+            unset($obj['_id']);
88
+            $table = $this->dataSet[$collection];
89
+            $res = $table->create($obj);
90
+            if($res !== false)
91
+            {
92
+                return $res;
93
+            }
94
+            return false;
95 95
     }
96 96
 
97 97
     function updateObjectInCollection($collection, $obj)
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 
138 138
     function addTheme($theme)
139 139
     {
140
-         unset($theme['_id']);
141
-         $res = $this->db->themes->insert($theme);
142
-         if($res['ok'] === true)
143
-         {
144
-             return $theme['_id'];
145
-         }
146
-         return false;
140
+            unset($theme['_id']);
141
+            $res = $this->db->themes->insert($theme);
142
+            if($res['ok'] === true)
143
+            {
144
+                return $theme['_id'];
145
+            }
146
+            return false;
147 147
     }
148 148
 
149 149
     function updateTheme($theme)
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
     function getCurrentYear()
14 14
     {
15
-        if(!isset($this->tables['vars']))
15
+        if (!isset($this->tables['vars']))
16 16
         {
17 17
             $this->tables['vars'] = $this->dataSet['vars'];
18 18
         }
19 19
         $data = $this->tables['vars']->read(new \Data\Filter('name eq year'));
20
-        if(empty($data))
20
+        if (empty($data))
21 21
         {
22 22
             return false;
23 23
         }
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
26 26
 
27 27
     function getAllFromCollection($collection, $year = false, $uid = false, $fields = false)
28 28
     {
29
-        if($year === false)
29
+        if ($year === false)
30 30
         {
31 31
             $year = $this->getCurrentYear();
32 32
         }
33 33
         $table = $this->dataSet[$collection];
34 34
         $filter = false;
35
-        if($year !== '*' && $uid !== false)
35
+        if ($year !== '*' && $uid !== false)
36 36
         {
37 37
             $filter = new \Data\Filter("year eq $year and registrars eq $uid");
38 38
         }
39
-        else if($year !== '*')
39
+        else if ($year !== '*')
40 40
         {
41 41
             $filter = new \Data\Filter("year eq $year");
42 42
         }
43
-        else if($uid !== false)
43
+        else if ($uid !== false)
44 44
         {
45 45
             $filter = new \Data\Filter("registrars eq $uid");
46 46
         }
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
     function searchFromCollection($collection, $criteria, $fields = false)
52 52
     {
53 53
         $col = $this->db->selectCollection($collection);
54
-        foreach($criteria as $key=>$value)
54
+        foreach ($criteria as $key=>$value)
55 55
         {
56
-            if($value[0] === '/')
56
+            if ($value[0] === '/')
57 57
             {
58 58
                 $criteria[$key] = array('$regex'=>new MongoRegex("$value"));
59 59
             }
60 60
         }
61 61
         $cursor = $col->find($criteria);
62
-        if($fields !== false)
62
+        if ($fields !== false)
63 63
         {
64 64
             $cursor->fields($fields);
65 65
         }
66
-        $ret    = array();
67
-        foreach($cursor as $doc)
66
+        $ret = array();
67
+        foreach ($cursor as $doc)
68 68
         {
69 69
             array_push($ret, $doc);
70 70
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $table = $this->dataSet[$collection];
77 77
         $data = $table->read(new \Data\Filter("_id eq $id"));
78
-        if(empty($data))
78
+        if (empty($data))
79 79
         {
80 80
             return false;
81 81
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
          unset($obj['_id']);
88 88
          $table = $this->dataSet[$collection];
89 89
          $res = $table->create($obj);
90
-         if($res !== false)
90
+         if ($res !== false)
91 91
          {
92 92
              return $res;
93 93
          }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         unset($obj['_id']);
101 101
         $table = $this->dataSet[$collection];
102 102
         $res = $table->update(new \Data\Filter("_id eq $id"), $obj);
103
-        if($res !== false)
103
+        if ($res !== false)
104 104
         {
105 105
             return true;
106 106
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     {
140 140
          unset($theme['_id']);
141 141
          $res = $this->db->themes->insert($theme);
142
-         if($res['ok'] === true)
142
+         if ($res['ok'] === true)
143 143
          {
144 144
              return $theme['_id'];
145 145
          }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $id = new MongoId($theme['_id']);
152 152
         unset($theme['_id']);
153 153
         $res = $this->db->themes->update(array('_id' => $id), $theme);
154
-        if($res['ok'] === true)
154
+        if ($res['ok'] === true)
155 155
         {
156 156
             return true;
157 157
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,12 +35,10 @@
 block discarded – undo
35 35
         if($year !== '*' && $uid !== false)
36 36
         {
37 37
             $filter = new \Data\Filter("year eq $year and registrars eq $uid");
38
-        }
39
-        else if($year !== '*')
38
+        } else if($year !== '*')
40 39
         {
41 40
             $filter = new \Data\Filter("year eq $year");
42
-        }
43
-        else if($uid !== false)
41
+        } else if($uid !== false)
44 42
         {
45 43
             $filter = new \Data\Filter("registrars eq $uid");
46 44
         }
Please login to merge, or discard this patch.
themes/view.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 $page->addWellKnownCSS(CSS_DATATABLE);
10 10
 $page->add_js_from_src('js/view.js');
11 11
 
12
-if(!FlipSession::isLoggedIn())
12
+if (!FlipSession::isLoggedIn())
13 13
 {
14 14
 $page->body .= '
15 15
     <div id="content">
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
20 20
         </div>
21 21
     </div>
22 22
 ';
23
-}
24
-else
23
+} else
25 24
 {
26 25
 $page->body .= '
27 26
 <div id="content">
Please login to merge, or discard this patch.
themes/class.ThemePage.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
     function add_links()
17 17
     {
18 18
         $dir = $this->theme_root;
19
-        if(!FlipSession::isLoggedIn())
19
+        if (!FlipSession::isLoggedIn())
20 20
         {
21 21
             $this->add_link('Login', 'http://profiles.burningflipside.com/login.php?return='.$this->current_url());
22 22
         }
23 23
         else
24 24
         {
25
-            if($this->user->isInGroupNamed('ThemeAdmins'))
25
+            if ($this->user->isInGroupNamed('ThemeAdmins'))
26 26
             { 
27 27
                 $this->add_link('Admin', $dir.'/_admin/');
28 28
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
         if(!FlipSession::isLoggedIn())
20 20
         {
21 21
             $this->add_link('Login', 'http://profiles.burningflipside.com/login.php?return='.$this->current_url());
22
-        }
23
-        else
22
+        } else
24 23
         {
25 24
             if($this->user->isInGroupNamed('ThemeAdmins'))
26 25
             { 
Please login to merge, or discard this patch.
class.SecurePage.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,28 +14,28 @@  discard block
 block discarded – undo
14 14
         $root = $_SERVER['DOCUMENT_ROOT'];
15 15
         $script_dir = dirname(__FILE__);
16 16
         $this->secure_root = substr($script_dir, strlen($root));
17
-        if($this->secure_root === false || strlen($this->secure_root) === 0)
17
+        if ($this->secure_root === false || strlen($this->secure_root) === 0)
18 18
         {
19 19
             $this->secure_root = '/';
20 20
         }
21
-        else if($this->secure_root[strlen($this->secure_root)-1] !== '/')
21
+        else if ($this->secure_root[strlen($this->secure_root)-1] !== '/')
22 22
         {
23
-            $this->secure_root.= '/';
23
+            $this->secure_root .= '/';
24 24
         }
25 25
         $this->add_secure_css();
26 26
         $this->add_secure_script();
27 27
         $this->add_login_form();
28
-        $this->body_tags='data-login-url="'.$this->secure_root.'api/v1/login"';
28
+        $this->body_tags = 'data-login-url="'.$this->secure_root.'api/v1/login"';
29 29
         $plugin_files = glob($script_dir.'/*/plugin.php');
30 30
         $count = count($plugin_files);
31
-        for($i = 0; $i < $count; $i++)
31
+        for ($i = 0; $i < $count; $i++)
32 32
         {
33 33
             include($plugin_files[$i]);
34 34
         }
35 35
         $this->plugins = array();
36
-        foreach(get_declared_classes() as $class)
36
+        foreach (get_declared_classes() as $class)
37 37
         {
38
-            if(is_subclass_of($class, 'SecurePlugin'))
38
+            if (is_subclass_of($class, 'SecurePlugin'))
39 39
             {
40 40
                 $this->plugins[] = new $class();
41 41
             }
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 
57 57
     function add_links()
58 58
     {
59
-        if($this->user !== false)
59
+        if ($this->user !== false)
60 60
         {
61 61
             $secure_menu = array();
62
-            for($i = 0; $i < $this->plugin_count; $i++)
62
+            for ($i = 0; $i < $this->plugin_count; $i++)
63 63
             {
64 64
                 $ret = $this->plugins[$i]->get_secure_menu_entries($this, $this->user);
65
-                if($ret !== false)
65
+                if ($ret !== false)
66 66
                 {
67 67
                     $ret["<hr id='hr_$i'/>"] = false;
68 68
                     $secure_menu = array_merge($secure_menu, $ret);
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
     function get_secure_child_entry_points()
77 77
     {
78 78
         $entry_points = '';
79
-        for($i = 0; $i < $this->plugin_count; $i++)
79
+        for ($i = 0; $i < $this->plugin_count; $i++)
80 80
         {
81 81
             $ret = $this->plugins[$i]->get_plugin_entry_point();
82
-            if($ret !== false)
82
+            if ($ret !== false)
83 83
             {
84
-                $entry_points .= '<li>'.$this->createLink($ret['name'],$ret['link']).'</li>';
84
+                $entry_points .= '<li>'.$this->createLink($ret['name'], $ret['link']).'</li>';
85 85
             }
86 86
         }
87 87
         return $entry_points;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
         if($this->secure_root === false || strlen($this->secure_root) === 0)
18 18
         {
19 19
             $this->secure_root = '/';
20
-        }
21
-        else if($this->secure_root[strlen($this->secure_root)-1] !== '/')
20
+        } else if($this->secure_root[strlen($this->secure_root)-1] !== '/')
22 21
         {
23 22
             $this->secure_root.= '/';
24 23
         }
Please login to merge, or discard this patch.