/
NameColumn.php
44 lines (36 loc) · 1.32 KB
/
NameColumn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Concrete\Core\User\Group\Search\ColumnSet\Column;
use Concrete\Core\Database\Query\AndWhereNotExistsTrait;
use Concrete\Core\Search\Column\Column;
use Concrete\Core\Search\Column\PagerColumnInterface;
use Concrete\Core\Search\ItemList\Pager\PagerProviderInterface;
use Concrete\Core\User\Group\Group;
class NameColumn extends Column implements PagerColumnInterface
{
use AndWhereNotExistsTrait;
public function getColumnKey()
{
return 'name';
}
public function getColumnName()
{
return t('Name');
}
public function getColumnCallback()
{
return ['\Concrete\Core\User\Group\Search\ColumnSet\Available', 'getGroupName'];
}
public function filterListAtOffset(PagerProviderInterface $itemList, $mixed)
{
$query = $itemList->getQueryObject();
$sort = $this->getColumnSortDirection() == 'desc' ? '<' : '>';
$where = sprintf('(if(nt.treeNodeTypeHandle=\'group\', g.gName, n.treeNodeName), n.treeNodeID) %s (:sortName, :sortID)', $sort);
$name = '';
if ($mixed->getTreeNodeDisplayName()) {
$name = $mixed->getTreeNodeDisplayName();
}
$query->setParameter('sortName', $name);
$query->setParameter('sortID', $mixed->getTreeNodeID());
$this->andWhereNotExists($query, $where);
}
}