|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverCommerce\ContactAdmin\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Forms\TextField; |
|
6
|
|
|
use SilverStripe\Dev\CsvBulkLoader; |
|
7
|
|
|
use SilverStripe\TagField\TagField; |
|
8
|
|
|
use SilverStripe\Control\Controller; |
|
9
|
|
|
use SilverStripe\Core\Config\Config; |
|
10
|
|
|
use Colymba\BulkManager\BulkManager; |
|
11
|
|
|
use SilverStripe\Forms\CheckboxField; |
|
12
|
|
|
use TractorCow\AutoComplete\AutoCompleteField; |
|
13
|
|
|
use SilverCommerce\ContactAdmin\Model\Contact; |
|
14
|
|
|
use Colymba\BulkManager\BulkAction\UnlinkHandler; |
|
15
|
|
|
use SilverCommerce\ContactAdmin\Model\ContactTag; |
|
16
|
|
|
use SilverCommerce\ContactAdmin\Model\ContactList; |
|
17
|
|
|
use SilverStripe\Forms\GridField\GridFieldPrintButton; |
|
18
|
|
|
use SilverStripe\Forms\GridField\GridFieldExportButton; |
|
19
|
|
|
use SilverCommerce\ContactAdmin\BulkActions\AddTagsHandler; |
|
20
|
|
|
use SilverCommerce\ContactAdmin\BulkActions\AddToListHandler; |
|
21
|
|
|
use SilverCommerce\ContactAdmin\Forms\ModelAdminAutoCompleteField; |
|
|
|
|
|
|
22
|
|
|
use ilateral\SilverStripe\ModelAdminPlus\ModelAdminPlus; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Management interface for contacts |
|
26
|
|
|
* |
|
27
|
|
|
* @author ilateral |
|
28
|
|
|
* @package Contacts |
|
29
|
|
|
*/ |
|
30
|
|
|
class ContactAdmin extends ModelAdminPlus |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
private static $menu_priority = 0; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
private static $managed_models = [ |
|
|
|
|
|
|
36
|
|
|
Contact::class, |
|
37
|
|
|
ContactTag::class, |
|
38
|
|
|
ContactList::class |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
private static $url_segment = 'contacts'; |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
private static $menu_title = 'Contacts'; |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
private static $model_importers = [ |
|
|
|
|
|
|
46
|
|
|
Contact::class => CSVBulkLoader::class, |
|
47
|
|
|
ContactTag::class => CSVBulkLoader::class, |
|
48
|
|
|
ContactList::class => CSVBulkLoader::class |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
private static $allowed_actions = [ |
|
|
|
|
|
|
52
|
|
|
"SearchForm" |
|
53
|
|
|
]; |
|
54
|
|
|
|
|
55
|
|
|
public $showImportForm = [ |
|
56
|
|
|
Contact::class, |
|
57
|
|
|
ContactTag::class, |
|
58
|
|
|
ContactList::class |
|
59
|
|
|
]; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
private static $menu_icon_class = 'font-icon-torso'; |
|
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
public function getSearchContext() |
|
67
|
|
|
{ |
|
68
|
|
|
$context = parent::getSearchContext(); |
|
69
|
|
|
|
|
70
|
|
|
if ($this->modelClass == Contact::class) { |
|
71
|
|
|
$context |
|
72
|
|
|
->getFields() |
|
73
|
|
|
->push(new CheckboxField('q[Flagged]', _t("Contacts.ShowFlaggedOnly", 'Show flagged only'))); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $context; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getList() |
|
80
|
|
|
{ |
|
81
|
|
|
$list = parent::getList(); |
|
82
|
|
|
|
|
83
|
|
|
// use this to access search parameters |
|
84
|
|
|
$params = $this->request->requestVar('q'); |
|
85
|
|
|
|
|
86
|
|
|
if ($this->modelClass == Contact::class && isset($params['Flagged']) && $params['Flagged']) { |
|
87
|
|
|
$list = $list->filter( |
|
88
|
|
|
"Notes.Flag", |
|
89
|
|
|
true |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return $list; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getEditForm($id = null, $fields = null) |
|
97
|
|
|
{ |
|
98
|
|
|
$form = parent::getEditForm($id, $fields); |
|
99
|
|
|
$class = $this->sanitiseClassName($this->modelClass); |
|
100
|
|
|
$gridField = $form->Fields()->fieldByName($class); |
|
101
|
|
|
$config = $gridField->getConfig(); |
|
102
|
|
|
|
|
103
|
|
|
// Add bulk editing to gridfield |
|
104
|
|
|
$manager = $config->getComponentByType(BulkManager::class); |
|
105
|
|
|
|
|
106
|
|
|
if ($this->modelClass == Contact::class) { |
|
107
|
|
|
$manager->addBulkAction(AddTagsHandler::class); |
|
108
|
|
|
$manager->addBulkAction(AddToListHandler::class); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$this->extend("updateEditForm", $form); |
|
112
|
|
|
|
|
113
|
|
|
return $form; |
|
114
|
|
|
} |
|
115
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths