1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Firesphere\SolrSearch\Models; |
5
|
|
|
|
6
|
|
|
use SilverStripe\Control\Director; |
7
|
|
|
use SilverStripe\ORM\DataObject; |
8
|
|
|
use SilverStripe\Security\Member; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class \Firesphere\SolrSearch\Models\SolrError |
12
|
|
|
* |
13
|
|
|
* @property string $Timestamp |
14
|
|
|
* @property string $Message |
15
|
|
|
* @property string $Index |
16
|
|
|
* @property string $Type |
17
|
|
|
* @property string $Level |
18
|
|
|
*/ |
19
|
|
|
class SolrLog extends DataObject |
20
|
|
|
{ |
21
|
|
|
private static $table_name = 'SolrLog'; |
22
|
|
|
|
23
|
|
|
private static $db = [ |
24
|
|
|
'Timestamp' => 'Varchar(50)', |
25
|
|
|
'Message' => 'Text', |
26
|
|
|
'Index' => 'Varchar(255)', |
27
|
|
|
'Type' => 'Enum("Config,Index,Query")', |
28
|
|
|
'Level' => 'Varchar(10)' |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
private static $summary_fields = [ |
|
|
|
|
32
|
|
|
'Timestamp', |
33
|
|
|
'Index', |
34
|
|
|
'Type', |
35
|
|
|
'Level' |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
private static $searchable_fields = [ |
|
|
|
|
39
|
|
|
'Created', |
40
|
|
|
'Index', |
41
|
|
|
'Type', |
42
|
|
|
'Level' |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
private static $indexes = [ |
|
|
|
|
46
|
|
|
'Timestamp' => true, |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
private static $sort = 'Created DESC'; |
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return mixed |
53
|
|
|
*/ |
54
|
|
|
public function getLastErrorLine() |
55
|
|
|
{ |
56
|
|
|
$lines = explode("\n", $this->Message); |
57
|
|
|
|
58
|
|
|
return $lines[0]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param null|Member $member |
63
|
|
|
* @return bool|mixed |
64
|
|
|
*/ |
65
|
|
|
public function canCreate($member = null, $context = []) |
66
|
|
|
{ |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param null|Member $member |
72
|
|
|
* @return bool|mixed |
73
|
|
|
*/ |
74
|
|
|
public function canEdit($member = null) |
75
|
|
|
{ |
76
|
|
|
return false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param null|Member $member |
81
|
|
|
* @return bool|mixed |
82
|
|
|
*/ |
83
|
26 |
|
public function canView($member = null) |
84
|
|
|
{ |
85
|
26 |
|
return parent::canView($member); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param null|Member $member |
90
|
|
|
* @return bool|mixed |
91
|
|
|
*/ |
92
|
|
|
public function canDelete($member = null) |
93
|
|
|
{ |
94
|
|
|
if ($member) { |
95
|
|
|
return $member->inGroup('administrators') || Director::isDev(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return parent::canDelete($member) || Director::isDev(); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|