Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TagConnectionProposalsRenderer
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 renderItem
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3App::uses('DataTableRenderer', 'Utility');
4
5class TagConnectionProposalsRenderer extends DataTableRenderer
6{
7    public function __construct($urlParams)
8    {
9        $this->count = ClassRegistry::init('TagConnection')->find('count', ['conditions' => ['approved' => 0]]);
10        parent::__construct($urlParams, 'tag_connection_proposals_page', 'New Tags');
11        $this->data = Util::query("
12SELECT
13    tag_connection.id as tag_connection_id,
14    tag.id as tag_id,
15    tag.name as tag_name,
16    tsumego.id as tsumego_id,
17    user.id AS user_id,
18    user.name AS user_name,
19    user.picture AS user_picture,
20    user.external_id AS user_external_id,
21    user.rating AS user_rating,
22    set_connection.id AS set_connection_id,
23    set_connection.num AS num,
24    tsumego_status.status AS status,
25    CONCAT(`set`.title, ' ', `set`.title2) AS set_title,
26    tag_connection.created as created
27FROM
28    tag_connection
29    JOIN tag ON tag_connection.tag_id = tag.id
30    JOIN tsumego ON tag_connection.tsumego_id = tsumego.id
31    JOIN set_connection ON set_connection.tsumego_id = tag_connection.tsumego_id
32    JOIN user ON tag_connection.user_id = user.id
33    JOIN `set` ON `set`.id = set_connection.set_id
34    LEFT JOIN tsumego_status ON tsumego_status.user_id = ? AND tsumego_status.tsumego_id = tsumego.id
35WHERE tag_connection.approved = FALSE
36ORDER BY tag_connection.created, tag.id
37LIMIT " . self::$PAGE_SIZE . "
38OFFSET " . $this->offset, [Auth::getUserID()]);
39    }
40
41    public function renderItem(int $index, array $item): void
42    {
43        echo '<td>' . ($index + 1) + ($this->page - 1) * self::$PAGE_SIZE . '</td><td class="adminpanel-table-text">' . User::renderLink($item) . ' added ';
44        echo '<a class="adminpanel-link" href="/tags/view/' . $item['tag_id'] . '">' . $item['tag_name'];
45        echo '</a> for <a class="adminpanel-link" href="/' . $item['set_connection_id'] . '">' . $item['set_title'] . ' - ' . $item['num'] . '</a></td>';
46        echo '<td>';
47        new TsumegoButton($item['tsumego_id'], $item['set_connection_id'], $item['num'], $item['status'])->render();
48        echo '</td>';
49        echo '<td>';
50        echo '<a class="new-button-default2" href="/users/acceptTagConnectionProposal/' . $item['tag_connection_id'] . '" id="tag-connection-accept-' . $item['tag_connection_id'] . '">Accept</a>';
51        echo '<a class="new-button-default2" href="/users/rejectTagConnectionProposal/' . $item['tag_connection_id'] . '" id="tag-connection-reject-' . $item['tag_connection_id'] . '">Reject</a>';
52        echo '</td>';
53        echo '<td style="font-size:13px">' . $item['created'] . '</td>';
54    }
55}