Total Complexity | 6 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
7 | class PublicLikesAnnotations implements Batch { |
||
8 | |||
9 | /** |
||
10 | * {@inheritdoc} |
||
11 | */ |
||
12 | public function getVersion() { |
||
13 | return 2017120700; |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * {@inheritdoc} |
||
18 | */ |
||
19 | public function needsIncrementOffset() { |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function shouldBeSkipped() { |
||
27 | return empty($this->countItems()); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function countItems() { |
||
34 | $dbprefix = elgg_get_config('dbprefix'); |
||
35 | $public = ACCESS_PUBLIC; |
||
36 | |||
37 | $query = "SELECT COUNT(*) as total |
||
38 | FROM {$dbprefix}annotations |
||
39 | WHERE name = 'likes' |
||
40 | AND access_id != {$public} |
||
41 | "; |
||
42 | |||
43 | $row = get_data_row($query); |
||
44 | if (empty($row)) { |
||
45 | return 0; |
||
46 | } |
||
47 | |||
48 | return (int) $row->total; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | public function run(Result $result, $offset) { |
||
69 | } |
||
70 | } |