| 1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Mapper;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
8 |
use Laminas\Db\Sql\Expression;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use LeadersLinked\Mapper\Common\MapperCommon;
|
|
|
11 |
use LeadersLinked\Model\Feed;
|
|
|
12 |
use LeadersLinked\Model\Topic;
|
|
|
13 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
|
|
14 |
use Laminas\Paginator\Paginator;
|
|
|
15 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
16 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
17 |
use LeadersLinked\Mapper\TopicMapper;
|
|
|
18 |
use LeadersLinked\Model\FastSurvey;
|
|
|
19 |
|
|
|
20 |
class FeedMapper extends MapperCommon
|
|
|
21 |
{
|
|
|
22 |
const _TABLE = 'tbl_feeds';
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
*
|
|
|
27 |
* @var FeedMapper
|
|
|
28 |
*/
|
|
|
29 |
private static $_instance;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
*
|
|
|
33 |
* @param AdapterInterface $adapter
|
|
|
34 |
*/
|
|
|
35 |
private function __construct($adapter)
|
|
|
36 |
{
|
|
|
37 |
parent::__construct($adapter);
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
*
|
|
|
42 |
* @param AdapterInterface $adapter
|
|
|
43 |
* @return \LeadersLinked\Mapper\FeedMapper
|
|
|
44 |
*/
|
|
|
45 |
public static function getInstance($adapter)
|
|
|
46 |
{
|
|
|
47 |
if(self::$_instance == null) {
|
|
|
48 |
self::$_instance = new FeedMapper($adapter);
|
|
|
49 |
}
|
|
|
50 |
return self::$_instance;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/*
|
|
|
54 |
public function fetchCountSharesByFeedId(int $shared_feed_id)
|
|
|
55 |
{
|
|
|
56 |
$select = $this->sql->select(self::_TABLE);
|
|
|
57 |
$select->columns(['total' => new Expression('COUNT(*)') ]);
|
|
|
58 |
$select->where->equalTo('shared_feed_id', $shared_feed_id);
|
|
|
59 |
|
|
|
60 |
$record = $this->executeFetchOneArray($select);
|
|
|
61 |
return $record['total'];
|
|
|
62 |
}*/
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
*
|
|
|
66 |
* @param int $id
|
|
|
67 |
* @return Feed
|
|
|
68 |
*/
|
|
|
69 |
public function fetchOne($id)
|
|
|
70 |
{
|
|
|
71 |
$prototype = new Feed();
|
|
|
72 |
$select = $this->sql->select(self::_TABLE);
|
|
|
73 |
$select->where->equalTo('id', $id);
|
|
|
74 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
75 |
//$select->getSqlString($this->adapter->platform);
|
|
|
76 |
|
|
|
77 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
*
|
|
|
83 |
* @param int $id
|
|
|
84 |
* @param int $network_id
|
|
|
85 |
* @return Feed
|
|
|
86 |
*/
|
|
|
87 |
public function fetchOneByIdAndNetworkId($id, $network_id)
|
|
|
88 |
{
|
|
|
89 |
$prototype = new Feed();
|
|
|
90 |
$select = $this->sql->select(self::_TABLE);
|
|
|
91 |
$select->where->equalTo('id', $id);
|
|
|
92 |
$select->where->equalTo('network_id', $network_id);
|
|
|
93 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
94 |
//$select->getSqlString($this->adapter->platform);
|
|
|
95 |
|
|
|
96 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
*
|
|
|
101 |
* @param int $id
|
|
|
102 |
* @return Feed
|
|
|
103 |
*/
|
|
|
104 |
public function fetchOneNonDeleted($id)
|
|
|
105 |
{
|
|
|
106 |
$select = $this->sql->select(self::_TABLE);
|
|
|
107 |
$select->where->equalTo('id', $id);
|
|
|
108 |
$select->where->equalTo('type', Feed::TYPE_MYT_QUESTION);
|
|
|
109 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
110 |
|
|
|
111 |
$prototype = new Feed();
|
|
|
112 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
*
|
|
|
117 |
* @param int $id
|
|
|
118 |
* @return Feed
|
|
|
119 |
*/
|
|
|
120 |
public function fetchOneAnyStatus($id)
|
|
|
121 |
{
|
|
|
122 |
$prototype = new Feed();
|
|
|
123 |
$select = $this->sql->select(self::_TABLE);
|
|
|
124 |
$select->where->equalTo('id', $id);
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
/**
|
|
|
131 |
*
|
|
|
132 |
* @param int $feed_uuid
|
|
|
133 |
* @return Feed
|
|
|
134 |
*/
|
|
|
135 |
public function fetchOneByUuid($uuid)
|
|
|
136 |
{
|
|
|
137 |
$prototype = new Feed();
|
|
|
138 |
$select = $this->sql->select(self::_TABLE);
|
|
|
139 |
$select->where->equalTo('uuid', $uuid);
|
|
|
140 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
141 |
//$select->getSqlString($this->adapter->platform);
|
|
|
142 |
|
|
|
143 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
*
|
|
|
148 |
* @param int $feed_uuid
|
|
|
149 |
* @return Feed
|
|
|
150 |
*/
|
|
|
151 |
public function fetchOneByUuidAndNetworkId($uuid, $network_id)
|
|
|
152 |
{
|
|
|
153 |
$prototype = new Feed();
|
|
|
154 |
$select = $this->sql->select(self::_TABLE);
|
|
|
155 |
$select->where->equalTo('uuid', $uuid);
|
|
|
156 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
157 |
//$select->getSqlString($this->adapter->platform);
|
|
|
158 |
|
|
|
159 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
/**
|
|
|
164 |
*
|
|
|
165 |
* @param string $feed_uuid
|
|
|
166 |
* @return Feed
|
|
|
167 |
*/
|
|
|
168 |
public function fetchOneByUuidAnyStatus($uuid)
|
|
|
169 |
{
|
|
|
170 |
$prototype = new Feed();
|
|
|
171 |
$select = $this->sql->select(self::_TABLE);
|
|
|
172 |
$select->where->equalTo('uuid', $uuid);
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
/**
|
|
|
180 |
*
|
|
|
181 |
* @param string $feed_uuid
|
|
|
182 |
* @param int $network_id
|
|
|
183 |
* @return Feed
|
|
|
184 |
*/
|
|
|
185 |
public function fetchOneByUuidAndNetworkIdAnyStatus($uuid, $network_id)
|
|
|
186 |
{
|
|
|
187 |
$prototype = new Feed();
|
|
|
188 |
$select = $this->sql->select(self::_TABLE);
|
|
|
189 |
$select->where->equalTo('uuid', $uuid);
|
|
|
190 |
$select->where->equalTo('network_id', $network_id);
|
|
|
191 |
|
|
|
192 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
/**
|
|
|
198 |
*
|
|
|
199 |
* @return Feed[]
|
|
|
200 |
*/
|
|
|
201 |
public function fetchAllTypeVideo()
|
|
|
202 |
{
|
|
|
203 |
$select = $this->sql->select(self::_TABLE);
|
|
|
204 |
$select->where->equalTo('file_type', Feed::FILE_TYPE_VIDEO);
|
|
|
205 |
|
|
|
206 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
207 |
|
|
|
208 |
$prototype = new Feed();
|
|
|
209 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
public function fetchAllTypeCalendar($highPerformanceTeamsGroups_id)
|
|
|
213 |
{
|
|
|
214 |
$select = $this->sql->select(self::_TABLE);
|
|
|
215 |
$select->where->equalTo('file_type', Feed::FILE_TYPE_MEETING);
|
|
|
216 |
|
|
|
217 |
$select->where->equalTo('high_performance_group_id',$highPerformanceTeamsGroups_id);
|
|
|
218 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
219 |
|
|
|
220 |
$prototype = new Feed();
|
|
|
221 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
/*
|
|
|
225 |
public function fetchAllDataTableForo($search, $page = 1, $records_per_page = 10, $order_field= 'added_on', $order_direction = 'DESC', $topic_id)
|
|
|
226 |
{
|
|
|
227 |
$prototype = new Feed();
|
|
|
228 |
$select = $this->sql->select(self::_TABLE);
|
|
|
229 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
230 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED);
|
|
|
231 |
if($search) {
|
|
|
232 |
$select->where->like('title', '%' . $search . '%');
|
|
|
233 |
}
|
|
|
234 |
$select->order($order_field . ' ' . $order_direction);
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
239 |
$resultset = new HydratingResultSet($hydrator, $prototype);
|
|
|
240 |
|
|
|
241 |
$adapter = new DbSelect($select, $this->sql, $resultset);
|
|
|
242 |
$paginator = new Paginator($adapter);
|
|
|
243 |
$paginator->setItemCountPerPage($records_per_page);
|
|
|
244 |
$paginator->setCurrentPageNumber($page);
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
return $paginator;
|
|
|
248 |
}*/
|
|
|
249 |
|
|
|
250 |
public function fetchFiveForoJoinTopic($group_id,$topic_type)
|
|
|
251 |
{
|
|
|
252 |
$prototype = new Feed();
|
|
|
253 |
$select = $this->sql->select();
|
|
|
254 |
$select->from(['f' => self::_TABLE]);
|
|
|
255 |
$select->join(['t' => TopicMapper::_TABLE], 't.id = f.topic_id ', []);
|
|
|
256 |
$select->where->equalTo('f.high_performance_group_id', $group_id);
|
|
|
257 |
$select->where->equalTo('f.status', Feed::STATUS_PUBLISHED);
|
|
|
258 |
$select->where->equalTo('f.type', Feed::TYPE_HPTG);
|
|
|
259 |
$select->where->equalTo('t.type', $topic_type);
|
|
|
260 |
$select->where->equalTo('t.status', Topic::STATUS_ACTIVE);
|
|
|
261 |
|
|
|
262 |
$select->order('added_on DESC');
|
|
|
263 |
|
|
|
264 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
265 |
$resultset = new HydratingResultSet($hydrator, $prototype);
|
|
|
266 |
|
|
|
267 |
$adapter = new DbSelect($select, $this->sql, $resultset);
|
|
|
268 |
$paginator = new Paginator($adapter);
|
|
|
269 |
$paginator->setItemCountPerPage(5);
|
|
|
270 |
$paginator->setCurrentPageNumber(1);
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
return $paginator;
|
|
|
274 |
}
|
|
|
275 |
/**
|
|
|
276 |
*
|
|
|
277 |
* @param int $shared_feed_id
|
|
|
278 |
* @return int
|
|
|
279 |
*/
|
|
|
280 |
public function fetchCountSharedByFeedId($shared_feed_id)
|
|
|
281 |
{
|
|
|
282 |
$select = $this->sql->select(self::_TABLE);
|
|
|
283 |
$select->columns(['total' => new Expression('COUNT(*)') ]);
|
|
|
284 |
$select->where->equalTo('shared_feed_id', $shared_feed_id);
|
|
|
285 |
|
|
|
286 |
$record = $this->executeFetchOneArray($select);
|
|
|
287 |
return $record['total'];
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
|
|
|
291 |
/**
|
|
|
292 |
*
|
|
|
293 |
* @param Feed $feed
|
|
|
294 |
* @return boolean
|
|
|
295 |
*/
|
|
|
296 |
public function update($feed)
|
|
|
297 |
{
|
|
|
298 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
299 |
$values = $hydrator->extract($feed);
|
|
|
300 |
$values = $this->removeEmpty($values);
|
|
|
301 |
|
|
|
302 |
$update = $this->sql->update(self::_TABLE);
|
|
|
303 |
$update->set($values);
|
|
|
304 |
$update->where->equalTo('id', $feed->id);
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
return $this->executeUpdate($update);
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
/**
|
|
|
312 |
*
|
|
|
313 |
* @param Feed $feed
|
|
|
314 |
* @return boolean
|
|
|
315 |
*/
|
|
|
316 |
public function insert($feed)
|
|
|
317 |
{
|
|
|
318 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
319 |
$values = $hydrator->extract($feed);
|
|
|
320 |
$values = $this->removeEmpty($values);
|
|
|
321 |
|
|
|
322 |
$insert = $this->sql->insert(self::_TABLE);
|
|
|
323 |
$insert->values($values);
|
|
|
324 |
//echo $insert->getSqlString($this->adapter->platform); exit;
|
|
|
325 |
|
|
|
326 |
$response = $this->executeInsert($insert);
|
|
|
327 |
if($response) {
|
|
|
328 |
$feed->id = $this->lastInsertId;
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
return $values;
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
/**
|
|
|
335 |
*
|
|
|
336 |
* @param int $id
|
|
|
337 |
* @return int
|
|
|
338 |
*/
|
|
|
339 |
public function fetchTotalComments($id)
|
|
|
340 |
{
|
|
|
341 |
$select = $this->sql->select(self::_TABLE);
|
|
|
342 |
$select->columns(['total_comments']);
|
|
|
343 |
$select->where->equalTo('id', $id);
|
|
|
344 |
|
|
|
345 |
$record = $this->executeFetchOneArray($select);
|
|
|
346 |
return $record['total_comments'];
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
/**
|
|
|
350 |
*
|
|
|
351 |
* @param int $feed_id
|
|
|
352 |
* @return boolean
|
|
|
353 |
*/
|
|
|
354 |
/*
|
|
|
355 |
public function incTotalComments($id)
|
|
|
356 |
{
|
|
|
357 |
|
|
|
358 |
$update = $this->sql->update(self::_TABLE);
|
|
|
359 |
$update->set(['total_comments' => new Expression('total_comments + 1')]);
|
|
|
360 |
$update->where->equalTo('id', $id);
|
|
|
361 |
|
|
|
362 |
return $this->executeUpdate($update);
|
|
|
363 |
}
|
|
|
364 |
*/
|
|
|
365 |
|
|
|
366 |
/**
|
|
|
367 |
*
|
|
|
368 |
* @param int $feed_id
|
|
|
369 |
* @return boolean
|
|
|
370 |
*/
|
|
|
371 |
public function incTotalShared($id)
|
|
|
372 |
{
|
|
|
373 |
$update = $this->sql->update(self::_TABLE);
|
|
|
374 |
$update->set(['total_shared' => new Expression('total_shared + 1')]);
|
|
|
375 |
$update->where->equalTo('id', $id);
|
|
|
376 |
|
|
|
377 |
return $this->executeUpdate($update);
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
/**
|
|
|
381 |
*
|
|
|
382 |
* @param int $id
|
|
|
383 |
* @return int
|
|
|
384 |
*/
|
|
|
385 |
public function fetchTotalShared($id)
|
|
|
386 |
{
|
|
|
387 |
$select = $this->sql->select(self::_TABLE);
|
|
|
388 |
$select->columns(['total_shared']);
|
|
|
389 |
$select->where->equalTo('id', $id);
|
|
|
390 |
|
|
|
391 |
$record = $this->executeFetchOneArray($select);
|
|
|
392 |
return $record['total_shared'];
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
/**
|
|
|
396 |
*
|
|
|
397 |
* @param FastSurvey $fastSurvey
|
|
|
398 |
* @return boolean
|
|
|
399 |
*/
|
|
|
400 |
public function deleteByFastSurvey($fastSurvey)
|
|
|
401 |
{
|
|
|
402 |
$delete = $this->sql->delete(self::_TABLE);
|
|
|
403 |
$delete->where->equalTo('fast_survey_id', $fastSurvey->id);
|
|
|
404 |
|
|
|
405 |
return $this->executeDelete($delete);
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
/**
|
|
|
410 |
*
|
|
|
411 |
* @param int $feed_id
|
|
|
412 |
* @return boolean
|
|
|
413 |
*/
|
|
|
414 |
public function delete($feed_id)
|
|
|
415 |
{
|
|
|
416 |
$update = $this->sql->update(self::_TABLE);
|
|
|
417 |
$update->set([
|
|
|
418 |
'status' => Feed::STATUS_DELETED
|
|
|
419 |
]);
|
|
|
420 |
$update->where->equalTo('id', $feed_id);
|
|
|
421 |
|
|
|
422 |
return $this->executeUpdate($update);
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
/**
|
|
|
426 |
*
|
|
|
427 |
* @return Feed
|
|
|
428 |
*/
|
|
|
429 |
public function fetchAllByMytQuestion()
|
|
|
430 |
{
|
|
|
431 |
$prototype = new Feed();
|
|
|
432 |
|
|
|
433 |
$select = $this->sql->select(self::_TABLE);
|
|
|
434 |
$select->where->equalTo('type', Feed::TYPE_MYT_QUESTION);
|
|
|
435 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
436 |
$select->order('added_on DESC');
|
|
|
437 |
|
|
|
438 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
/**
|
|
|
442 |
*
|
|
|
443 |
* @return Feed
|
|
|
444 |
*/
|
|
|
445 |
public function fetchAllByMytAnswer($related_feed)
|
|
|
446 |
{
|
|
|
447 |
$prototype = new Feed();
|
|
|
448 |
|
|
|
449 |
$select = $this->sql->select(self::_TABLE);
|
|
|
450 |
$select->where->equalTo('related_feed', $related_feed);
|
|
|
451 |
$select->where->equalTo('type', Feed::TYPE_MYT_ANSWER);
|
|
|
452 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
453 |
$select->order('title');
|
|
|
454 |
|
|
|
455 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
/**
|
|
|
459 |
*
|
|
|
460 |
* @return Feed
|
|
|
461 |
*/
|
|
|
462 |
public function fetchAllByTopicId($topic_id)
|
|
|
463 |
{
|
|
|
464 |
$prototype = new Feed();
|
|
|
465 |
|
|
|
466 |
$select = $this->sql->select(self::_TABLE);
|
|
|
467 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
468 |
$select->order('title');
|
|
|
469 |
|
|
|
470 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
/**
|
|
|
474 |
*
|
|
|
475 |
* @return Feed
|
|
|
476 |
*/
|
|
|
477 |
public function fetchAllByMytAnswerComented()
|
|
|
478 |
{
|
|
|
479 |
$prototype = new Feed();
|
|
|
480 |
|
|
|
481 |
$select = $this->sql->select(self::_TABLE);
|
|
|
482 |
$select->where->equalTo('type', Feed::TYPE_MYT_ANSWER);
|
|
|
483 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
484 |
$select->order('title');
|
|
|
485 |
|
|
|
486 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
/**
|
|
|
490 |
*
|
|
|
491 |
* @return Feed
|
|
|
492 |
*/
|
|
|
493 |
public function fetchAllByDevelop()
|
|
|
494 |
{
|
|
|
495 |
$prototype = new Feed();
|
|
|
496 |
|
|
|
497 |
$select = $this->sql->select(self::_TABLE);
|
|
|
498 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
499 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
500 |
$select->order('added_on DESC');
|
|
|
501 |
|
|
|
502 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
public function fetchAllByDevelopContentPublished()
|
|
|
506 |
{
|
|
|
507 |
$prototype = new Feed();
|
|
|
508 |
|
|
|
509 |
$select = $this->sql->select(self::_TABLE);
|
|
|
510 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
511 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
512 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED);
|
|
|
513 |
$select->order('added_on DESC');
|
|
|
514 |
|
|
|
515 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
516 |
}
|
|
|
517 |
/**
|
|
|
518 |
*
|
|
|
519 |
* @return Feed
|
|
|
520 |
*/
|
|
|
521 |
public function fetchAllByDevelopContentByCategoryId($id)
|
|
|
522 |
{
|
|
|
523 |
$prototype = new Feed();
|
|
|
524 |
|
|
|
525 |
$select = $this->sql->select(self::_TABLE);
|
|
|
526 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
527 |
$select->where->equalTo('topic_id', $id);
|
|
|
528 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
529 |
|
|
|
530 |
$select->order('added_on DESC');
|
|
|
531 |
|
|
|
532 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
/**
|
|
|
536 |
*
|
|
|
537 |
* @return Feed
|
|
|
538 |
*/
|
|
|
539 |
public function fetchAllByDevelopContentPublishedByCategoryId($id)
|
|
|
540 |
{
|
|
|
541 |
$prototype = new Feed();
|
|
|
542 |
|
|
|
543 |
$select = $this->sql->select(self::_TABLE);
|
|
|
544 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
545 |
$select->where->equalTo('topic_id', $id);
|
|
|
546 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
547 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED);
|
|
|
548 |
|
|
|
549 |
$select->order('added_on DESC');
|
|
|
550 |
|
|
|
551 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
|
|
|
555 |
|
|
|
556 |
/**
|
|
|
557 |
*
|
|
|
558 |
* @return Feed
|
|
|
559 |
*/
|
|
|
560 |
public function fetchAllByDevelopAndCategoryIdCount($id)
|
|
|
561 |
{
|
|
|
562 |
$select = $this->sql->select(self::_TABLE);
|
|
|
563 |
$select->columns(['total' => new Expression('COUNT(id)')]);
|
|
|
564 |
$select->where->equalTo('topic_id', $id);
|
|
|
565 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
566 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
567 |
$record = $this->executeFetchOneArray($select);
|
|
|
568 |
return $record['total'];
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
|
|
|
572 |
/**
|
|
|
573 |
*
|
|
|
574 |
* @return Feed
|
|
|
575 |
*/
|
|
|
576 |
public function fetchAllByDevelopInternContent()
|
|
|
577 |
{
|
|
|
578 |
$prototype = new Feed();
|
|
|
579 |
|
|
|
580 |
$select = $this->sql->select(self::_TABLE);
|
|
|
581 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
582 |
//$select->where->equalTo('link_media', 'cesa');
|
|
|
583 |
$select->where->isNotNull('file_type');
|
|
|
584 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
585 |
$select->order('title');
|
|
|
586 |
//echo $insert->getSqlString($this->adapter->platform); exit;
|
|
|
587 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
/**
|
|
|
591 |
*
|
|
|
592 |
* @return Feed
|
|
|
593 |
*/
|
|
|
594 |
public function fetchAllByDevelopExternContent()
|
|
|
595 |
{
|
|
|
596 |
$prototype = new Feed();
|
|
|
597 |
|
|
|
598 |
$select = $this->sql->select(self::_TABLE);
|
|
|
599 |
$select->where->equalTo('type', Feed::TYPE_DC);
|
|
|
600 |
$select->where->notEqualTo('status', Feed::STATUS_DELETED);
|
|
|
601 |
$select->where->notEqualTo('link_media', 'cesa');
|
|
|
602 |
$select->order('title');
|
|
|
603 |
|
|
|
604 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
|
|
|
608 |
|
|
|
609 |
/**
|
|
|
610 |
*
|
|
|
611 |
* @param int $feed_id
|
|
|
612 |
* @return boolean
|
|
|
613 |
*/
|
|
|
614 |
public function incTotalExternalShared($id)
|
|
|
615 |
{
|
|
|
616 |
$update = $this->sql->update(self::_TABLE);
|
|
|
617 |
$update->set(['total_external_shared' => new Expression('total_external_shared + 1')]);
|
|
|
618 |
$update->where->equalTo('id', $id);
|
|
|
619 |
|
|
|
620 |
return $this->executeUpdate($update);
|
|
|
621 |
}
|
|
|
622 |
|
|
|
623 |
/**
|
|
|
624 |
*
|
|
|
625 |
* @param int $id
|
|
|
626 |
* @return int
|
|
|
627 |
*/
|
|
|
628 |
public function fetchTotalExternalShared($id)
|
|
|
629 |
{
|
|
|
630 |
$select = $this->sql->select(self::_TABLE);
|
|
|
631 |
$select->columns(['total_external_shared']);
|
|
|
632 |
$select->where->equalTo('id', $id);
|
|
|
633 |
|
|
|
634 |
$record = $this->executeFetchOneArray($select);
|
|
|
635 |
return $record['total_external_shared'];
|
|
|
636 |
}
|
|
|
637 |
|
|
|
638 |
}
|