1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Service; |
4
|
|
|
|
5
|
|
|
use Zend\Stdlib\ErrorHandler; |
6
|
|
|
use ZfcDatagrid\Column; |
7
|
|
|
use ZfcDatagrid\Action; |
8
|
|
|
use ZfcDatagrid\Column\Formatter; |
9
|
|
|
use ZfcDatagrid\Column\Type; |
10
|
|
|
use ZfcDatagrid\Column\Style; |
11
|
|
|
use ZfcDatagrid\Filter; |
12
|
|
|
use Doctrine\ORM\Query\Expr; |
13
|
|
|
|
14
|
|
|
class PostVote extends Game |
15
|
|
|
{ |
16
|
|
|
protected $postvoteMapper; |
17
|
|
|
protected $postvoteformMapper; |
18
|
|
|
protected $postVotePostMapper; |
19
|
|
|
protected $postVoteVoteMapper; |
20
|
|
|
protected $postVoteCommentMapper; |
21
|
|
|
protected $postVotePostElementMapper; |
22
|
|
|
protected $postVoteShareMapper; |
23
|
|
|
protected $postVoteViewMapper; |
24
|
|
|
|
25
|
|
|
public function getGameEntity() |
26
|
|
|
{ |
27
|
|
|
return new \PlaygroundGame\Entity\PostVote; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getPath($post) |
31
|
|
|
{ |
32
|
|
|
$path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR; |
33
|
|
|
$path .= 'game' . $post->getPostVote()->getId() . DIRECTORY_SEPARATOR; |
34
|
|
|
if (!is_dir($path)) { |
35
|
|
|
mkdir($path, 0777, true); |
36
|
|
|
} |
37
|
|
|
$path .= 'post'. $post->getId() . DIRECTORY_SEPARATOR; |
38
|
|
|
if (!is_dir($path)) { |
39
|
|
|
mkdir($path, 0777, true); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return $path; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
View Code Duplication |
public function getMediaUrl($post) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$media_url = $this->getOptions()->getMediaUrl() . '/'; |
48
|
|
|
$media_url .= 'game' . $post->getPostVote()->getId() . '/' . 'post'. $post->getId() . '/'; |
49
|
|
|
|
50
|
|
|
return $media_url; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param boolean $entry |
55
|
|
|
*/ |
56
|
|
|
public function checkPost($entry) |
57
|
|
|
{ |
58
|
|
|
$post = $this->getPostVotePostMapper()->findOneBy(array('entry' => $entry)); |
59
|
|
|
|
60
|
|
|
if (! $post) { |
61
|
|
|
$post = new \PlaygroundGame\Entity\PostVotePost(); |
62
|
|
|
$post->setPostvote($entry->getGame()); |
|
|
|
|
63
|
|
|
$post->setUser($entry->getUser()); |
|
|
|
|
64
|
|
|
$post->setEntry($entry); |
65
|
|
|
$post = $this->getPostVotePostMapper()->insert($post); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $post; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function uploadFileToPost($data, $game, $user) |
72
|
|
|
{ |
73
|
|
|
$result = false; |
74
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
75
|
|
|
|
76
|
|
|
if (!$entry) { |
77
|
|
|
return '0'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$post = $this->checkPost($entry); |
81
|
|
|
$path = $this->getPath($post); |
82
|
|
|
$media_url = $this->getMediaUrl($post); |
83
|
|
|
|
84
|
|
|
$key = key($data); |
85
|
|
|
$uploadFile = $this->uploadFile($path, $data[$key]); |
86
|
|
|
|
87
|
|
|
if ($uploadFile) { |
88
|
|
|
$postElement = $this->getPostVotePostElementMapper()->findOneBy(array('post' => $post, 'name' => $key)); |
89
|
|
|
if (! $postElement) { |
90
|
|
|
$postElement = new \PlaygroundGame\Entity\PostVotePostElement(); |
91
|
|
|
} |
92
|
|
|
$postElement->setName($key); |
93
|
|
|
$postElement->setPosition(0); |
94
|
|
|
$postElement->setValue($media_url.$uploadFile); |
95
|
|
|
$postElement->setPost($post); |
96
|
|
|
$postElement = $this->getPostVotePostElementMapper()->insert($postElement); |
|
|
|
|
97
|
|
|
|
98
|
|
|
$result = $media_url.$uploadFile; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $result; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function deleteFilePosted($data, $game, $user) |
105
|
|
|
{ |
106
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
107
|
|
|
$postVotePostElementMapper = $this->getPostVotePostElementMapper(); |
108
|
|
|
|
109
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
110
|
|
|
|
111
|
|
|
if (!$entry) { |
112
|
|
|
return 'falsefin0'; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
$post = $postvotePostMapper->findOneBy(array('entry' => $entry)); |
116
|
|
|
$element = $postVotePostElementMapper->findOneBy(array('post' => $post->getId(), 'name' => $data['name'])); |
117
|
|
|
|
118
|
|
|
if ($element) { |
119
|
|
|
$element = $postVotePostElementMapper->remove($element); |
120
|
|
|
if ($element) { |
121
|
|
|
return true; |
122
|
|
|
} else { |
123
|
|
|
return false; |
124
|
|
|
} |
125
|
|
|
} else { |
126
|
|
|
return false; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* |
132
|
|
|
* @param array $data |
133
|
|
|
* @return \PlaygroundGame\Entity\Game |
134
|
|
|
*/ |
135
|
|
|
public function createPost(array $data, $game, $user, $form) |
136
|
|
|
{ |
137
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
138
|
|
|
$postVotePostElementMapper = $this->getPostVotePostElementMapper(); |
139
|
|
|
|
140
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
141
|
|
|
|
142
|
|
|
if (!$entry) { |
143
|
|
|
return false; |
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
$post = $this->checkPost($entry); |
147
|
|
|
$path = $this->getPath($post); |
148
|
|
|
$media_url = $this->getMediaUrl($post); |
149
|
|
|
$position=1; |
150
|
|
|
|
151
|
|
|
foreach ($data as $name => $value) { |
152
|
|
|
$postElement = $postVotePostElementMapper->findOneBy(array('post' => $post, 'name' => $name)); |
153
|
|
|
if (! $postElement) { |
154
|
|
|
$postElement = new \PlaygroundGame\Entity\PostVotePostElement(); |
155
|
|
|
} |
156
|
|
|
$postElement->setName($name); |
157
|
|
|
foreach($form as $e) { |
158
|
|
|
if ($e->getName() == $name) { |
159
|
|
|
$postElement->setLabel($e->getLabel()); |
160
|
|
|
break; |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
$postElement->setPosition($position); |
164
|
|
|
|
165
|
|
|
if (is_array($value) && isset($value['tmp_name'])) { |
166
|
|
|
// The file upload has been done in ajax but some weird bugs remain without it |
167
|
|
|
|
168
|
|
|
if (! $value['error']) { |
169
|
|
|
ErrorHandler::start(); |
170
|
|
|
$value['name'] = $this->fileNewname($path, $value['name'], true); |
171
|
|
|
move_uploaded_file($value['tmp_name'], $path . $value['name']); |
172
|
|
|
|
173
|
|
|
if (getimagesize($path . $value['name'])) { |
174
|
|
|
$image = $this->serviceLocator->get('playgroundcore_image_service'); |
175
|
|
|
$image->setImage($path . $value['name']); |
176
|
|
|
|
177
|
|
|
if ($image->canCorrectOrientation()) { |
178
|
|
|
$image->correctOrientation()->save(); |
179
|
|
|
} |
180
|
|
|
$postElement->setValue($media_url . $value['name']); |
181
|
|
|
|
182
|
|
|
if (class_exists("Imagick")) { |
183
|
|
|
$ext = pathinfo($value['name'], PATHINFO_EXTENSION); |
184
|
|
|
$img = new \Imagick($path . $value['name']); |
185
|
|
|
$img->cropThumbnailImage(100, 100); |
186
|
|
|
$img->setImageCompression(\Imagick::COMPRESSION_JPEG); |
187
|
|
|
$img->setImageCompressionQuality(75); |
188
|
|
|
// Strip out unneeded meta data |
189
|
|
|
$img->stripImage(); |
190
|
|
|
$img->writeImage($path . str_replace('.'.$ext, '-thumbnail.'.$ext, $value['name'])); |
191
|
|
|
ErrorHandler::stop(true); |
192
|
|
|
} |
193
|
|
|
} else { |
194
|
|
|
$postElement->setValue($media_url . $value['name']); |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
} elseif (is_array($value) || $form->get($name) instanceof \Zend\Form\Element\Select) { |
198
|
|
|
$arValues = $form->get($name)->getValueOptions(); |
199
|
|
|
$postElement->setValue($arValues[$value[0]]); |
200
|
|
|
} elseif (!empty($value)) { |
201
|
|
|
$postElement->setValue($value); |
202
|
|
|
} |
203
|
|
|
$post->addPostElement($postElement); |
204
|
|
|
// $postElement->setPost($post); |
205
|
|
|
// $postVotePostElementMapper->insert($postElement); |
206
|
|
|
$position++; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
$postvotePostMapper->update($post); |
210
|
|
|
|
211
|
|
|
// If a preview step is not proposed, I confirmPost on this step |
212
|
|
|
$steps = $game->getStepsArray(); |
213
|
|
|
$previewKey = array_search('preview', $steps); |
214
|
|
|
if (!$previewKey) { |
215
|
|
|
$post = $this->confirmPost($game, $user); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
$this->getEventManager()->trigger( |
219
|
|
|
__FUNCTION__ . '.post', |
220
|
|
|
$this, |
221
|
|
|
[ |
222
|
|
|
'user' => $user, |
223
|
|
|
'game' => $game, |
224
|
|
|
'post' => $post, |
225
|
|
|
'entry' => $entry, |
226
|
|
|
] |
227
|
|
|
); |
228
|
|
|
|
229
|
|
|
return $post; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* |
234
|
|
|
* @return \PlaygroundGame\Entity\Game |
235
|
|
|
*/ |
236
|
|
|
public function confirmPost($game, $user) |
237
|
|
|
{ |
238
|
|
|
$postvotePostMapper = $this->getPostVotePostMapper(); |
239
|
|
|
|
240
|
|
|
$entryMapper = $this->getEntryMapper(); |
241
|
|
|
$entry = $this->findLastActiveEntry($game, $user); |
242
|
|
|
|
243
|
|
|
if (!$entry) { |
244
|
|
|
return false; |
|
|
|
|
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
$post = $postvotePostMapper->findOneBy(array('entry' => $entry)); |
248
|
|
|
|
249
|
|
|
if (! $post) { |
250
|
|
|
return false; |
|
|
|
|
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
// The post is confirmed by user. I update the status and close the associated entry |
254
|
|
|
// Post are validated by default, unless pre-moderation is enable for the game |
255
|
|
|
if ($game->getModerationType()) { |
256
|
|
|
$post->setStatus(1); |
257
|
|
|
} else { |
258
|
|
|
$post->setStatus(2); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
$post = $postvotePostMapper->update($post); |
262
|
|
|
|
263
|
|
|
$entry->setActive(0); |
|
|
|
|
264
|
|
|
$entryMapper->update($entry); |
265
|
|
|
|
266
|
|
|
$this->getEventManager()->trigger( |
267
|
|
|
__FUNCTION__ . '.post', |
268
|
|
|
$this, |
269
|
|
|
[ |
270
|
|
|
'user' => $user, |
271
|
|
|
'game' => $game, |
272
|
|
|
'entry' => $entry, |
273
|
|
|
'post' => $post, |
274
|
|
|
] |
275
|
|
|
); |
276
|
|
|
|
277
|
|
|
return $post; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* This service moderate a post depending on the status |
282
|
|
|
*/ |
283
|
|
|
public function moderatePost($post, $status = null) |
284
|
|
|
{ |
285
|
|
|
if ($status && strtolower($status) === 'validation') { |
286
|
|
|
$post->setStatus(2); |
287
|
|
|
$this->getPostVotePostMapper()->update($post); |
288
|
|
|
|
289
|
|
|
$this->getEventManager()->trigger( |
290
|
|
|
__FUNCTION__ .'.validation', |
291
|
|
|
$this, |
292
|
|
|
array('user' => $post->getUser(), 'game' => $post->getPostvote(), 'entry' => $post->getEntry(), 'post' => $post) |
293
|
|
|
); |
294
|
|
|
//} elseif ($status && strtolower($status) === 'rejection' && $post->getStatus() !== 9) { |
295
|
|
|
} elseif ($status && strtolower($status) === 'rejection') { |
296
|
|
|
// We reject the $post |
297
|
|
|
$post->setStatus(9); |
298
|
|
|
$this->getPostVotePostMapper()->update($post); |
299
|
|
|
|
300
|
|
|
// We signal we want to remove the initial points earned from the $post |
301
|
|
|
$entry = $post->getEntry(); |
302
|
|
|
$entry->setPoints(-$entry->getPoints()); |
303
|
|
|
|
304
|
|
|
$this->getEventManager()->trigger( |
305
|
|
|
__FUNCTION__ .'.rejection', |
306
|
|
|
$this, |
307
|
|
|
array('user' => $post->getUser(), 'game' => $post->getPostvote(), 'entry' => $entry, 'post' => $post) |
308
|
|
|
); |
309
|
|
|
|
310
|
|
|
// We set the points from the $entry to 0; |
311
|
|
|
$entry->setPoints(0); |
312
|
|
|
$entryMapper = $this->getEntryMapper(); |
313
|
|
|
$entryMapper->update($entry); |
314
|
|
|
} |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* |
319
|
|
|
* This service is ready for all types of games |
320
|
|
|
* |
321
|
|
|
* @param array $data |
322
|
|
|
* @return \PlaygroundGame\Entity\Game |
323
|
|
|
*/ |
324
|
|
View Code Duplication |
public function createForm(array $data, $game, $form = null) |
|
|
|
|
325
|
|
|
{ |
326
|
|
|
$title =''; |
327
|
|
|
$description = ''; |
328
|
|
|
|
329
|
|
|
if ($data['form_jsonified']) { |
330
|
|
|
$jsonPV = json_decode($data['form_jsonified']); |
331
|
|
|
foreach ($jsonPV as $element) { |
332
|
|
|
if ($element->form_properties) { |
333
|
|
|
$attributes = $element->form_properties[0]; |
334
|
|
|
$title = $attributes->title; |
335
|
|
|
$description = $attributes->description; |
336
|
|
|
|
337
|
|
|
break; |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
} |
341
|
|
|
if (!$form) { |
342
|
|
|
$form = new \PlaygroundGame\Entity\PostVoteForm(); |
343
|
|
|
} |
344
|
|
|
$form->setPostvote($game); |
345
|
|
|
$form->setTitle($title); |
346
|
|
|
$form->setDescription($description); |
347
|
|
|
$form->setForm($data['form_jsonified']); |
348
|
|
|
$form->setFormTemplate($data['form_template']); |
349
|
|
|
|
350
|
|
|
$form = $this->getPostVoteFormMapper()->insert($form); |
351
|
|
|
|
352
|
|
|
return $form; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
public function findArrayOfValidatedPosts($game, $user, $filter, $search = '') |
356
|
|
|
{ |
357
|
|
|
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default'); |
358
|
|
|
$qb = $em->createQueryBuilder(); |
359
|
|
|
$and = $qb->expr()->andx(); |
360
|
|
|
|
361
|
|
|
$and->add($qb->expr()->eq('p.status', 2)); |
362
|
|
|
|
363
|
|
|
$and->add($qb->expr()->eq('g.id', ':game')); |
364
|
|
|
$qb->setParameter('game', $game); |
365
|
|
|
|
366
|
|
|
if ($search != '') { |
367
|
|
|
$and->add( |
368
|
|
|
$qb->expr()->orX( |
369
|
|
|
$qb->expr()->like('u.username', $qb->expr()->literal('%:search%')), |
370
|
|
|
$qb->expr()->like('u.firstname', $qb->expr()->literal('%:search%')), |
371
|
|
|
$qb->expr()->like('u.lastname', $qb->expr()->literal('%:search%')), |
372
|
|
|
$qb->expr()->like('e.value', $qb->expr()->literal('%:search%')), |
373
|
|
|
$qb->expr()->isNull('g.publicationDate') |
374
|
|
|
) |
375
|
|
|
); |
376
|
|
|
$qb->setParameter('search', $search); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
if ('push' == $filter) { |
380
|
|
|
$and->add( |
381
|
|
|
$qb->expr()->andX( |
382
|
|
|
$qb->expr()->eq('p.pushed', 1) |
383
|
|
|
) |
384
|
|
|
); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
$qb->select('p, SUM(CASE WHEN (e.position = 1) THEN v.note ELSE 0 END) AS votesCount, SUM(CASE WHEN (e.position = 1 AND v.user = :user) THEN v.note ELSE 0 END) AS voted') |
388
|
|
|
->from('PlaygroundGame\Entity\PostVotePost', 'p') |
389
|
|
|
->innerJoin('p.postvote', 'g') |
390
|
|
|
->leftJoin('p.user', 'u') |
391
|
|
|
->innerJoin('p.postElements', 'e') |
392
|
|
|
->leftJoin('p.votes', 'v') |
393
|
|
|
->leftJoin('p.votes', 'av', 'WITH', 'av.user = :user') |
394
|
|
|
->where($and) |
395
|
|
|
->groupBy('p.id'); |
396
|
|
|
|
397
|
|
|
if ($user) { |
398
|
|
|
$qb->setParameter('user', $user); |
399
|
|
|
} else { |
400
|
|
|
$qb->setParameter('user', null); |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
switch ($filter) { |
404
|
|
|
case 'random': |
405
|
|
|
$qb->orderBy('e.value', 'ASC'); |
406
|
|
|
break; |
407
|
|
|
case 'vote': |
408
|
|
|
$qb->orderBy('votesCount', 'DESC'); |
409
|
|
|
break; |
410
|
|
|
case 'date': |
411
|
|
|
$qb->orderBy('p.createdAt', 'DESC'); |
412
|
|
|
break; |
413
|
|
|
case 'push': |
414
|
|
|
$qb->orderBy('p.createdAt', 'DESC'); |
415
|
|
|
break; |
416
|
|
|
case 'id': |
417
|
|
|
$qb->orderBy('p.createdAt', 'ASC'); |
418
|
|
|
break; |
419
|
|
|
default: |
420
|
|
|
$qb->orderBy('p.createdAt', 'ASC'); |
421
|
|
|
break; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
$query = $qb->getQuery(); |
425
|
|
|
// echo $query->getSql(); |
426
|
|
|
$posts = $query->getResult(); |
427
|
|
|
$arrayPosts = array(); |
428
|
|
|
$i=0; |
429
|
|
|
foreach ($posts as $postRaw) { |
430
|
|
|
$data = array(); |
431
|
|
|
$post = $postRaw[0]; |
432
|
|
|
if ($post) { |
433
|
|
|
foreach ($post->getPostElements() as $element) { |
434
|
|
|
$data[$element->getPosition()] = $element->getValue(); |
435
|
|
|
} |
436
|
|
|
$arrayPosts[$i]['post'] = $post; |
437
|
|
|
$arrayPosts[$i]['data'] = $data; |
438
|
|
|
$arrayPosts[$i]['votes'] = count($post->getVotes()); |
439
|
|
|
$arrayPosts[$i]['voted'] = $postRaw['voted']; |
440
|
|
|
$arrayPosts[$i]['votesCount'] = $postRaw['votesCount']; |
441
|
|
|
$arrayPosts[$i]['id'] = $post->getId(); |
442
|
|
|
$arrayPosts[$i]['user'] = $post->getUser(); |
443
|
|
|
$arrayPosts[$i]['createdAt'] = $post->getCreatedAt(); |
444
|
|
|
$i++; |
445
|
|
|
} |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
return $arrayPosts; |
449
|
|
|
} |
450
|
|
|
|
451
|
|
View Code Duplication |
public function toggleVote($user, $ipAddress, $post, $comment = null, $note = 1) |
|
|
|
|
452
|
|
|
{ |
453
|
|
|
$postvoteVoteMapper = $this->getPostVoteVoteMapper(); |
454
|
|
|
$postId = $post->getId(); |
455
|
|
|
$commentId = ($comment !== null) ? $comment->getId() : null; |
456
|
|
|
$vote = null; |
|
|
|
|
457
|
|
|
$game = $post->getPostvote(); |
458
|
|
|
|
459
|
|
|
if ($user) { |
460
|
|
|
if ($comment == null) { |
461
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId))); |
462
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId)); |
463
|
|
|
} else { |
464
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId))); |
465
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId)); |
466
|
|
|
} |
467
|
|
|
} else { |
468
|
|
|
if ($comment == null) { |
469
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId))); |
470
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId)); |
471
|
|
|
} else { |
472
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId))); |
473
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId)); |
474
|
|
|
} |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
if ($entryUser && $entryUser > 0) { |
478
|
|
|
$postvoteVoteMapper->remove($vote); |
479
|
|
|
|
480
|
|
|
return 0; |
481
|
|
|
} else { |
482
|
|
|
$vote = new \PlaygroundGame\Entity\PostVoteVote(); |
483
|
|
|
$vote->setPost($post); |
484
|
|
|
$vote->setIp($ipAddress); |
485
|
|
|
$vote->setNote($note); |
486
|
|
|
// If the vote is for a comment |
487
|
|
|
if ($comment != null) { |
488
|
|
|
$vote->setPostComment($comment); |
489
|
|
|
$vote->setPostvote($post->getPostvote()); |
490
|
|
|
// else if the vote is for the post itself |
491
|
|
|
} else { |
492
|
|
|
$vote->setPostvote($post->getPostvote(), true); |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
if ($user) { |
496
|
|
|
$vote->setUser($user); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
$postvoteVoteMapper->insert($vote); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
$this->getEventManager()->trigger( |
503
|
|
|
__FUNCTION__ .'.post', |
504
|
|
|
$this, |
505
|
|
|
array('user' => $user, 'game' => $game, 'post' => $post, 'vote' => $vote) |
506
|
|
|
); |
507
|
|
|
|
508
|
|
|
return 1; |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
public function removeVote($user, $ipAddress, $post) |
512
|
|
|
{ |
513
|
|
|
$postvoteVoteMapper = $this->getPostVoteVoteMapper(); |
514
|
|
|
$postId = $post->getId(); |
515
|
|
|
$commentId = ($comment !== null) ? $comment->getId() : null; |
|
|
|
|
516
|
|
|
$vote = null; |
|
|
|
|
517
|
|
|
$game = $post->getPostvote(); |
518
|
|
|
|
519
|
|
|
if ($user) { |
520
|
|
|
if ($comment == null) { |
521
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId))); |
|
|
|
|
522
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId)); |
523
|
|
|
} else { |
524
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId))); |
|
|
|
|
525
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId)); |
526
|
|
|
} |
527
|
|
|
} else { |
528
|
|
|
if ($comment == null) { |
529
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId))); |
|
|
|
|
530
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId)); |
531
|
|
|
} else { |
532
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId))); |
|
|
|
|
533
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId)); |
534
|
|
|
} |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
$this->getEventManager()->trigger( |
538
|
|
|
__FUNCTION__ .'.post', |
539
|
|
|
$this, |
540
|
|
|
array('user' => $user, 'game' => $game, 'post' => $post, 'vote' => $vote) |
541
|
|
|
); |
542
|
|
|
|
543
|
|
|
return true; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
View Code Duplication |
public function addVote($user, $ipAddress, $post) |
|
|
|
|
547
|
|
|
{ |
548
|
|
|
$postvoteVoteMapper = $this->getPostVoteVoteMapper(); |
549
|
|
|
$postId = $post->getId(); |
550
|
|
|
$commentId = ($comment !== null) ? $comment->getId() : null; |
|
|
|
|
551
|
|
|
$vote = null; |
|
|
|
|
552
|
|
|
$game = $post->getPostvote(); |
|
|
|
|
553
|
|
|
|
554
|
|
|
if ($user) { |
555
|
|
|
if ($comment == null) { |
556
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId))); |
557
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId)); |
|
|
|
|
558
|
|
|
} else { |
559
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId))); |
560
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('user' => $user, 'post' => $postId, 'postComment' => $commentId)); |
|
|
|
|
561
|
|
|
} |
562
|
|
|
} else { |
563
|
|
|
if ($comment == null) { |
564
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId))); |
565
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId)); |
|
|
|
|
566
|
|
|
} else { |
567
|
|
|
$entryUser = count($postvoteVoteMapper->findBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId))); |
568
|
|
|
$vote = $postvoteVoteMapper->findOneBy(array('ip' => $ipAddress, 'post' => $postId, 'postComment' => $commentId)); |
|
|
|
|
569
|
|
|
} |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
if ($entryUser && $entryUser > 0) { |
573
|
|
|
return false; |
574
|
|
|
} else { |
575
|
|
|
$vote = new \PlaygroundGame\Entity\PostVoteVote(); |
576
|
|
|
$vote->setPost($post); |
577
|
|
|
$vote->setIp($ipAddress); |
578
|
|
|
$vote->setNote(1); |
579
|
|
|
// If the vote is for a comment |
580
|
|
|
if ($comment != null) { |
581
|
|
|
$vote->setPostComment($comment); |
582
|
|
|
$vote->setPostvote($post->getPostvote()); |
583
|
|
|
// else if the vote is for the post itself |
584
|
|
|
} else { |
585
|
|
|
$vote->setPostvote($post->getPostvote(), true); |
586
|
|
|
} |
587
|
|
|
if ($user) { |
588
|
|
|
$vote->setUser($user); |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
$postvoteVoteMapper->insert($vote); |
592
|
|
|
$game = $post->getPostvote(); |
593
|
|
|
$this->getEventManager()->trigger( |
594
|
|
|
__FUNCTION__ .'.post', |
595
|
|
|
$this, |
596
|
|
|
array('user' => $user, 'game' => $game, 'post' => $post, 'vote' => $vote) |
597
|
|
|
); |
598
|
|
|
|
599
|
|
|
return true; |
600
|
|
|
} |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
public function addComment($user, $ipAddress, $post, $message = '', $category = null) |
604
|
|
|
{ |
605
|
|
|
$postvoteCommentMapper = $this->getPostVoteCommentMapper(); |
606
|
|
|
$game = $post->getPostvote(); |
607
|
|
|
$comment = new \PlaygroundGame\Entity\PostVoteComment(); |
608
|
|
|
$comment->setPost($post); |
609
|
|
|
$comment->setIp($ipAddress); |
610
|
|
|
$message = strip_tags($message); |
611
|
|
|
$comment->setMessage($message); |
612
|
|
|
if ($category !== null) { |
613
|
|
|
$comment->setCategory($category); |
614
|
|
|
} |
615
|
|
|
$comment->setPostvote($game); |
616
|
|
|
if ($user) { |
617
|
|
|
$comment->setUser($user); |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
$postvoteCommentMapper->insert($comment); |
621
|
|
|
|
622
|
|
|
$this->getEventManager()->trigger( |
623
|
|
|
__FUNCTION__ .'.post', |
624
|
|
|
$this, |
625
|
|
|
array('user' => $user, 'game' => $game, 'post' => $post, 'comment' => $comment) |
626
|
|
|
); |
627
|
|
|
|
628
|
|
|
return true; |
629
|
|
|
} |
630
|
|
|
|
631
|
|
View Code Duplication |
public function addView($user, $ipAddress, $post) |
|
|
|
|
632
|
|
|
{ |
633
|
|
|
$postvoteViewMapper = $this->getPostVoteViewMapper(); |
634
|
|
|
$postView = new \PlaygroundGame\Entity\PostVoteView(); |
635
|
|
|
$postView->setPost($post) |
636
|
|
|
->setPostvote($post->getPostvote()) |
637
|
|
|
->setUser($user) |
638
|
|
|
->setIp($ipAddress); |
639
|
|
|
$postvoteViewMapper->insert($postView); |
640
|
|
|
|
641
|
|
|
$this->getEventManager()->trigger( |
642
|
|
|
__FUNCTION__ . '.post', |
643
|
|
|
$this, |
644
|
|
|
array( |
645
|
|
|
'post' => $post |
646
|
|
|
) |
647
|
|
|
); |
648
|
|
|
|
649
|
|
|
return true; |
650
|
|
|
} |
651
|
|
|
|
652
|
|
View Code Duplication |
public function addShare($post, $user) |
|
|
|
|
653
|
|
|
{ |
654
|
|
|
$postvoteShareMapper = $this->getPostVoteShareMapper(); |
655
|
|
|
$postShare = new \PlaygroundGame\Entity\PostVoteShare(); |
656
|
|
|
$postShare->setPost($post) |
657
|
|
|
->setPostvote($post->getPostvote()) |
658
|
|
|
->setUser($user) |
659
|
|
|
->setOrigin('mail'); |
660
|
|
|
$postvoteShareMapper->insert($postShare); |
661
|
|
|
|
662
|
|
|
$this->getEventManager()->trigger( |
663
|
|
|
__FUNCTION__ . '.post', |
664
|
|
|
$this, |
665
|
|
|
array( |
666
|
|
|
'post' => $post |
667
|
|
|
) |
668
|
|
|
); |
669
|
|
|
|
670
|
|
|
return true; |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* Get all comments for this game |
675
|
|
|
*/ |
676
|
|
|
public function getCommentsForPostvote($postvote) |
677
|
|
|
{ |
678
|
|
|
$postvoteCommentMapper = $this->getPostVoteCommentMapper(); |
679
|
|
|
$comments = $postvoteCommentMapper->findBy(array('postvote' => $postvote), array('createdAt' => 'DESC')); |
680
|
|
|
|
681
|
|
|
return $comments ; |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
public function removeComment($user, $ipAddress, $messageId) |
|
|
|
|
685
|
|
|
{ |
686
|
|
|
$postvoteCommentMapper = $this->getPostVoteCommentMapper(); |
687
|
|
|
$comment = $postvoteCommentMapper->findOneBy(array('id' => $messageId)); |
688
|
|
|
if ($comment->getUser()->getId() === $user->getId()) { |
689
|
|
|
$postvoteCommentMapper->remove($comment); |
690
|
|
|
$this->getEventManager()->trigger( |
691
|
|
|
'remove_comment_postvote.post', |
692
|
|
|
$this, |
693
|
|
|
array('user' => $user, 'comment' => $comment) |
694
|
|
|
); |
695
|
|
|
|
696
|
|
|
return true; |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
return false; |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
/** |
703
|
|
|
* DEPRECATED |
704
|
|
|
*/ |
705
|
|
|
public function getEntriesHeader($game) |
706
|
|
|
{ |
707
|
|
|
$header = parent::getEntriesHeader($game); |
708
|
|
|
if ($game->getForm()) { |
709
|
|
|
$form = json_decode($game->getForm()->getForm(), true); |
710
|
|
View Code Duplication |
foreach ($form as $element) { |
|
|
|
|
711
|
|
|
foreach ($element as $k => $v) { |
712
|
|
|
if ($k !== 'form_properties') { |
713
|
|
|
$header[$v[0]['name']] = 1; |
714
|
|
|
} |
715
|
|
|
} |
716
|
|
|
} |
717
|
|
|
} |
718
|
|
|
if ($game->getVoteActive()) { |
719
|
|
|
$header['p.votes'] = 1; |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
$header['p.views'] = 1; |
723
|
|
|
$header['p.shares'] = 1; |
724
|
|
|
|
725
|
|
|
return $header; |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
public function getGrid($game) |
729
|
|
|
{ |
730
|
|
|
$qb = $this->getEntriesQuery($game); |
731
|
|
|
// echo $qb->getQuery()->getSQL(); |
732
|
|
|
// die('---'); |
733
|
|
|
|
734
|
|
|
/* @var $grid \ZfcDatagrid\Datagrid */ |
735
|
|
|
$grid = $this->serviceLocator->get('ZfcDatagrid\Datagrid'); |
736
|
|
|
$grid->setTitle('Entries'); |
737
|
|
|
$grid->setDataSource($qb); |
738
|
|
|
$grid->setDefaultItemsPerPage(50); |
739
|
|
|
|
740
|
|
|
$col = new Column\Select('id', 'p'); |
741
|
|
|
$col->setLabel('Id'); |
742
|
|
|
$col->setIdentity(true); |
743
|
|
|
$grid->addColumn($col); |
744
|
|
|
|
745
|
|
|
$colType = new Type\DateTime( |
746
|
|
|
'Y-m-d H:i:s', |
747
|
|
|
\IntlDateFormatter::MEDIUM, |
748
|
|
|
\IntlDateFormatter::MEDIUM |
749
|
|
|
); |
750
|
|
|
$colType->setSourceTimezone('UTC'); |
751
|
|
|
|
752
|
|
|
$col = new Column\Select('created_at', 'u'); |
753
|
|
|
$col->setLabel('Created'); |
754
|
|
|
$col->setType($colType); |
755
|
|
|
$grid->addColumn($col); |
756
|
|
|
|
757
|
|
|
$col = new Column\Select('username', 'u'); |
758
|
|
|
$col->setLabel('Username'); |
759
|
|
|
$grid->addColumn($col); |
760
|
|
|
|
761
|
|
|
$col = new Column\Select('email', 'u'); |
762
|
|
|
$col->setLabel('Email'); |
763
|
|
|
$grid->addColumn($col); |
764
|
|
|
|
765
|
|
|
$col = new Column\Select('firstname', 'u'); |
766
|
|
|
$col->setLabel('Firstname'); |
767
|
|
|
$grid->addColumn($col); |
768
|
|
|
|
769
|
|
|
$col = new Column\Select('lastname', 'u'); |
770
|
|
|
$col->setLabel('Lastname'); |
771
|
|
|
$grid->addColumn($col); |
772
|
|
|
|
773
|
|
|
$col = new Column\Select('winner', 'e'); |
774
|
|
|
$col->setLabel('Status'); |
775
|
|
|
$col->setReplaceValues( |
776
|
|
|
[ |
777
|
|
|
0 => 'looser', |
778
|
|
|
1 => 'winner', |
779
|
|
|
] |
780
|
|
|
); |
781
|
|
|
$grid->addColumn($col); |
782
|
|
|
|
783
|
|
|
$imageFormatter = new Formatter\Image(); |
784
|
|
|
//Set the prefix of the image path and the prefix of the link |
785
|
|
|
$imageFormatter->setPrefix('/'); |
786
|
|
|
$imageFormatter->setAttribute('width', '120'); |
787
|
|
|
$imageFormatter->setLinkAttribute('class', 'pop'); |
788
|
|
|
|
789
|
|
|
if ($game->getForm()) { |
790
|
|
|
$form = json_decode($game->getForm()->getForm(), true); |
791
|
|
|
foreach ($form as $element) { |
792
|
|
|
foreach ($element as $k => $v) { |
793
|
|
|
if ($k !== 'form_properties') { |
794
|
|
|
$querySelect = new Expr\Select("MAX(CASE WHEN f.name = '".$v[0]['name']."' THEN f.value ELSE '' END)"); |
795
|
|
|
if ($v[0]['type'] == 'file') { |
796
|
|
|
// print_r($v[0]['data']['fileextension']); |
797
|
|
|
// die('---'); |
798
|
|
|
$col = new Column\Select($querySelect, $v[0]['name']); |
799
|
|
|
//$col->setType(new Type\Image()); |
800
|
|
View Code Duplication |
if (strpos($v[0]['data']['fileextension'], 'png') !== false) { |
|
|
|
|
801
|
|
|
$col->addFormatter($imageFormatter); |
802
|
|
|
} |
803
|
|
View Code Duplication |
if (strpos($v[0]['data']['fileextension'], 'mp4') !== false) { |
|
|
|
|
804
|
|
|
$col->addFormatter(new Formatter\Link()); |
805
|
|
|
} |
806
|
|
View Code Duplication |
if (strpos($v[0]['data']['fileextension'], 'pdf') !== false) { |
|
|
|
|
807
|
|
|
$col->addFormatter(new Formatter\Link()); |
808
|
|
|
} |
809
|
|
|
} else { |
810
|
|
|
$col = new Column\Select($querySelect, $v[0]['name']); |
811
|
|
|
} |
812
|
|
|
$col->setLabel($v[0]['name']); |
813
|
|
|
$col->setUserFilterDisabled(true); |
814
|
|
|
$grid->addColumn($col); |
815
|
|
|
} |
816
|
|
|
} |
817
|
|
|
} |
818
|
|
|
} |
819
|
|
|
|
820
|
|
|
if ($game->getVoteActive()) { |
821
|
|
|
$querySelect = new Expr\Select("COUNT(vo.id)"); |
822
|
|
|
$col = new Column\Select($querySelect, "votes"); |
823
|
|
|
$col->setLabel("Votes"); |
824
|
|
|
$col->setUserFilterDisabled(true); |
825
|
|
|
$grid->addColumn($col); |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
$querySelect = new Expr\Select("COUNT(v.id)"); |
829
|
|
|
$col = new Column\Select($querySelect, "views"); |
830
|
|
|
$col->setLabel("Views"); |
831
|
|
|
$col->setUserFilterDisabled(true); |
832
|
|
|
$grid->addColumn($col); |
833
|
|
|
|
834
|
|
|
$querySelect = new Expr\Select("COUNT(s.id)"); |
835
|
|
|
$col = new Column\Select($querySelect, "shares"); |
836
|
|
|
$col->setLabel("Shares"); |
837
|
|
|
$col->setUserFilterDisabled(true); |
838
|
|
|
$grid->addColumn($col); |
839
|
|
|
|
840
|
|
|
$actions = new Column\Action(); |
841
|
|
|
$actions->setLabel(''); |
842
|
|
|
|
843
|
|
|
$viewAction = new Column\Action\Button(); |
844
|
|
|
$viewAction->setLabel('Moderate'); |
845
|
|
|
$rowId = $viewAction->getRowIdPlaceholder(); |
846
|
|
|
$viewAction->setLink('/admin/game/postvote-moderation-edit/'.$rowId); |
847
|
|
|
$actions->addAction($viewAction); |
848
|
|
|
|
849
|
|
|
$grid->addColumn($actions); |
850
|
|
|
|
851
|
|
|
// $action = new Action\Mass(); |
852
|
|
|
// $action->setTitle('This is incredible'); |
853
|
|
|
// $action->setLink('/admin/game/postvote-mod-list'); |
854
|
|
|
// $action->setConfirm(true); |
855
|
|
|
// $grid->addMassAction($action); |
856
|
|
|
|
857
|
|
|
return $grid; |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
public function getEntriesQuery($game) |
861
|
|
|
{ |
862
|
|
|
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default'); |
863
|
|
|
|
864
|
|
|
$qb = $em->createQueryBuilder(); |
865
|
|
|
|
866
|
|
|
$selectString = ''; |
867
|
|
|
|
868
|
|
|
if ($game->getForm()) { |
869
|
|
|
$form = json_decode($game->getForm()->getForm(), true); |
870
|
|
|
foreach ($form as $element) { |
871
|
|
|
foreach ($element as $k => $v) { |
872
|
|
|
if ($k !== 'form_properties') { |
873
|
|
|
$selectString .= "MAX(CASE WHEN f.name = '".$v[0]['name']."' THEN f.value ELSE '' END) AS " .$v[0]['name']. ","; |
874
|
|
|
} |
875
|
|
|
} |
876
|
|
|
} |
877
|
|
|
} |
878
|
|
|
$selectString .= 'p, u, e'; |
879
|
|
|
$qb->select($selectString) |
880
|
|
|
->from('PlaygroundGame\Entity\PostVotePost', 'p') |
881
|
|
|
->leftJoin('p.votes', 'vo') |
882
|
|
|
->leftJoin('p.shares', 's') |
883
|
|
|
->leftJoin('p.views', 'v') |
884
|
|
|
->innerJoin('p.postElements', 'f') |
885
|
|
|
->innerJoin('p.entry', 'e') |
886
|
|
|
->leftJoin('p.user', 'u') |
887
|
|
|
->where($qb->expr()->eq('e.game', ':game')) |
888
|
|
|
->groupBy('p.id'); |
889
|
|
|
|
890
|
|
|
$qb->setParameter('game', $game); |
891
|
|
|
|
892
|
|
|
return $qb; |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* DEPRECATED |
897
|
|
|
* getGameEntries : All entries of a game |
898
|
|
|
* |
899
|
|
|
* @return Array of PlaygroundGame\Entity\Game |
900
|
|
|
*/ |
901
|
|
|
public function getGameEntries($header, $entries, $game) |
902
|
|
|
{ |
903
|
|
|
$results = array(); |
904
|
|
|
|
905
|
|
|
foreach ($entries as $k => $entry) { |
906
|
|
|
$entryData = json_decode($entry['playerData'], true); |
907
|
|
|
$postElements = $entry[0]->getPostElements(); |
908
|
|
|
|
909
|
|
|
foreach ($header as $key => $v) { |
910
|
|
|
if (isset($entryData[$key]) && $key !=='id') { |
911
|
|
|
$results[$k][$key] = (is_array($entryData[$key]))?implode(', ', $entryData[$key]):$entryData[$key]; |
912
|
|
|
} elseif (array_key_exists($key, $entry)) { |
913
|
|
|
$results[$k][$key] = ($entry[$key] instanceof \DateTime)?$entry[$key]->format('Y-m-d'):$entry[$key]; |
914
|
|
|
} else { |
915
|
|
|
$results[$k][$key] = ''; |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
foreach ($postElements as $e) { |
919
|
|
|
if ($key === $e->getName()) { |
920
|
|
|
$results[$k][$key] = (is_array($e->getValue()))?implode(', ', $e->getValue()):$e->getValue(); |
921
|
|
|
break; |
922
|
|
|
} |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
if ($key === 'votes') { |
926
|
|
|
$results[$k][$key] = count($entry[0]->getVotes()); |
927
|
|
|
} |
928
|
|
|
if ($key === 'views') { |
929
|
|
|
$results[$k][$key] = count($entry[0]->getViews()); |
930
|
|
|
} |
931
|
|
|
if ($key === 'shares') { |
932
|
|
|
$results[$k][$key] = count($entry[0]->getShares()); |
933
|
|
|
} |
934
|
|
|
} |
935
|
|
|
} |
936
|
|
|
|
937
|
|
|
return $results; |
938
|
|
|
} |
939
|
|
|
|
940
|
|
|
public function getPostVoteFormMapper() |
941
|
|
|
{ |
942
|
|
|
if (null === $this->postvoteformMapper) { |
943
|
|
|
$this->postvoteformMapper = $this->serviceLocator->get('playgroundgame_postvoteform_mapper'); |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
return $this->postvoteformMapper; |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
public function setPostVoteFormMapper($postvoteformMapper) |
950
|
|
|
{ |
951
|
|
|
$this->postvoteformMapper = $postvoteformMapper; |
952
|
|
|
|
953
|
|
|
return $this; |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
public function getPostVotePostElementMapper() |
957
|
|
|
{ |
958
|
|
|
if (null === $this->postVotePostElementMapper) { |
959
|
|
|
$this->postVotePostElementMapper = $this->serviceLocator->get( |
960
|
|
|
'playgroundgame_postvotepostelement_mapper' |
961
|
|
|
); |
962
|
|
|
} |
963
|
|
|
|
964
|
|
|
return $this->postVotePostElementMapper; |
965
|
|
|
} |
966
|
|
|
|
967
|
|
|
public function setPostVotePostElementMapper($postVotePostElementMapper) |
968
|
|
|
{ |
969
|
|
|
$this->postVotePostElementMapper = $postVotePostElementMapper; |
970
|
|
|
|
971
|
|
|
return $this; |
972
|
|
|
} |
973
|
|
|
|
974
|
|
|
public function getPostVoteVoteMapper() |
975
|
|
|
{ |
976
|
|
|
if (null === $this->postVoteVoteMapper) { |
977
|
|
|
$this->postVoteVoteMapper = $this->serviceLocator->get('playgroundgame_postvotevote_mapper'); |
978
|
|
|
} |
979
|
|
|
|
980
|
|
|
return $this->postVoteVoteMapper; |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
public function setPostVoteVoteMapper($postVoteVoteMapper) |
984
|
|
|
{ |
985
|
|
|
$this->postVoteVoteMapper = $postVoteVoteMapper; |
986
|
|
|
|
987
|
|
|
return $this; |
988
|
|
|
} |
989
|
|
|
|
990
|
|
|
public function getPostVoteCommentMapper() |
991
|
|
|
{ |
992
|
|
|
if (null === $this->postVoteCommentMapper) { |
993
|
|
|
$this->postVoteCommentMapper = $this->serviceLocator->get('playgroundgame_postvotecomment_mapper'); |
994
|
|
|
} |
995
|
|
|
|
996
|
|
|
return $this->postVoteCommentMapper; |
997
|
|
|
} |
998
|
|
|
|
999
|
|
|
public function setPostVoteCommentMapper($postVoteCommentMapper) |
1000
|
|
|
{ |
1001
|
|
|
$this->postVoteCommentMapper = $postVoteCommentMapper; |
1002
|
|
|
|
1003
|
|
|
return $this; |
1004
|
|
|
} |
1005
|
|
|
|
1006
|
|
|
public function getPostVotePostMapper() |
1007
|
|
|
{ |
1008
|
|
|
if (null === $this->postVotePostMapper) { |
1009
|
|
|
$this->postVotePostMapper = $this->serviceLocator->get('playgroundgame_postvotepost_mapper'); |
1010
|
|
|
} |
1011
|
|
|
|
1012
|
|
|
return $this->postVotePostMapper; |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
public function getPostVoteShareMapper() |
1016
|
|
|
{ |
1017
|
|
|
if (null === $this->postVoteShareMapper) { |
1018
|
|
|
$this->postVoteShareMapper = $this->serviceLocator->get('playgroundgame_postvoteshare_mapper'); |
1019
|
|
|
} |
1020
|
|
|
|
1021
|
|
|
return $this->postVoteShareMapper; |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
public function getPostVoteViewMapper() |
1025
|
|
|
{ |
1026
|
|
|
if (null === $this->postVoteViewMapper) { |
1027
|
|
|
$this->postVoteViewMapper = $this->serviceLocator->get('playgroundgame_postvoteview_mapper'); |
1028
|
|
|
} |
1029
|
|
|
|
1030
|
|
|
return $this->postVoteViewMapper; |
1031
|
|
|
} |
1032
|
|
|
|
1033
|
|
|
public function setPostVotePostMapper($postVotePostMapper) |
1034
|
|
|
{ |
1035
|
|
|
$this->postVotePostMapper = $postVotePostMapper; |
1036
|
|
|
|
1037
|
|
|
return $this; |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
public function getPostVoteMapper() |
1041
|
|
|
{ |
1042
|
|
|
if (null === $this->postvoteMapper) { |
1043
|
|
|
$this->postvoteMapper = $this->serviceLocator->get('playgroundgame_postvote_mapper'); |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
return $this->postvoteMapper; |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
/** |
1050
|
|
|
* setQuizQuestionMapper |
1051
|
|
|
* |
1052
|
|
|
* @return PostVote |
1053
|
|
|
*/ |
1054
|
|
|
public function setPostVoteMapper($postvoteMapper) |
1055
|
|
|
{ |
1056
|
|
|
$this->postvoteMapper = $postvoteMapper; |
1057
|
|
|
|
1058
|
|
|
return $this; |
1059
|
|
|
} |
1060
|
|
|
} |
1061
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.