/
PermissionsInheritanceField.php
47 lines (38 loc) · 1.44 KB
/
PermissionsInheritanceField.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
45
46
47
<?php
namespace Concrete\Core\Page\Search\Field\Field;
use Concrete\Core\File\FileList;
use Concrete\Core\File\Type\Type;
use Concrete\Core\Search\Field\AbstractField;
use Concrete\Core\Search\Field\FieldInterface;
use Concrete\Core\Search\ItemList\ItemList;
class PermissionsInheritanceField extends AbstractField
{
protected $requestVariables = [
'cInheritPermissionsFrom',
];
public function getKey()
{
return 'permissions_inheritance';
}
public function getDisplayName()
{
return t('Permissions Inheritance');
}
/**
* @param FileList $list
* @param $request
*/
public function filterList(ItemList $list)
{
$list->filter('cInheritPermissionsFrom', $this->getData('cInheritPermissionsFrom'));
}
public function renderSearchField()
{
$html = '<select name="cInheritPermissionsFrom" class="form-select">';
$html .= '<option value="PARENT"' . ($this->getData('cInheritPermissionsFrom') == 'PARENT' ? ' selected' : '') . '>' . t('Parent Page') . '</option>';
$html .= '<option value="TEMPLATE"' . ($this->getData('cInheritPermissionsFrom') == 'TEMPLATE' ? ' selected' : '') . '>' . t('Page Type') . '</option>';
$html .= '<option value="OVERRIDE"' . ($this->getData('cInheritPermissionsFrom') == 'OVERRIDE' ? ' selected' : '') . '>' . t('Itself (Override)') . '</option>';
$html .= '</select>';
return $html;
}
}