1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Notifications; |
4
|
|
|
|
5
|
|
|
use SMW\PropertyRegistry as SemanticMediaWikiPropertyRegistry; |
6
|
|
|
use SMW\Notifications\DataValues\NotificationGroupValue; |
7
|
|
|
|
8
|
|
|
define( 'SMW_NOTIFICATIONS_ON', 'Notifications on' ); |
9
|
|
|
define( 'SMW_NOTIFICATIONS_TO_GROUP', 'Notifications to group' ); |
10
|
|
|
define( 'SMW_NOTIFICATIONS_GROUP_MEMBER_OF', 'Notifications group member of' ); |
11
|
|
|
define( 'SMW_NOTIFICATIONS_TO', 'Notifications to' ); |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @license GNU GPL v2+ |
15
|
|
|
* @since 1.0 |
16
|
|
|
* |
17
|
|
|
* @author mwjames |
18
|
|
|
*/ |
19
|
|
|
class PropertyRegistry { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Marking a property to be watched |
23
|
|
|
*/ |
24
|
|
|
const NOTIFICATIONS_ON = "__notifications_on"; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Group assigned to the property to can point recipients |
28
|
|
|
*/ |
29
|
|
|
const NOTIFICATIONS_TO_GROUP = "__notifications_to_group"; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Users assigned to a group |
33
|
|
|
*/ |
34
|
|
|
const NOTIFICATIONS_GROUP_MEMBER_OF = "__notifications_group_member"; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* List of individuals that can be listed directly |
38
|
|
|
*/ |
39
|
|
|
const NOTIFICATIONS_TO = "__notifications_to"; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @since 1.0 |
43
|
|
|
* |
44
|
|
|
* @param SemanticMediaWikiPropertyRegistry $propertyRegistry |
45
|
|
|
* |
46
|
|
|
* @return boolean |
47
|
|
|
*/ |
48
|
1 |
|
public function registerTo( SemanticMediaWikiPropertyRegistry $propertyRegistry ) { |
49
|
|
|
|
50
|
|
|
$propertyDefinitions = array( |
51
|
|
|
|
52
|
1 |
|
self::NOTIFICATIONS_ON => array( |
53
|
1 |
|
'label' => SMW_NOTIFICATIONS_ON, |
54
|
1 |
|
'type' => '_txt', |
55
|
1 |
|
'alias' => array( wfMessage( 'smw-notifications-property-alias-notifications-on' )->text() ), |
56
|
1 |
|
'msgkey' => 'smw-notifications-property-alias-notifications-on', |
57
|
1 |
|
'visible' => true, |
58
|
|
|
'annotable' => true |
59
|
1 |
|
), |
60
|
|
|
|
61
|
1 |
|
self::NOTIFICATIONS_TO_GROUP => array( |
62
|
1 |
|
'label' => SMW_NOTIFICATIONS_TO_GROUP, |
63
|
1 |
|
'type' => '_txt', |
64
|
1 |
|
'alias' => array( wfMessage( 'smw-notifications-property-alias-notifications-to-group' )->text() ), |
65
|
1 |
|
'msgkey' => 'smw-notifications-property-alias-notifications-to-group', |
66
|
1 |
|
'visible' => true, |
67
|
|
|
'annotable' => true |
68
|
1 |
|
), |
69
|
|
|
|
70
|
1 |
|
self::NOTIFICATIONS_GROUP_MEMBER_OF => array( |
71
|
1 |
|
'label' => SMW_NOTIFICATIONS_GROUP_MEMBER_OF, |
72
|
1 |
|
'type' => NotificationGroupValue::TYPE_ID, |
73
|
1 |
|
'alias' => array( wfMessage( 'smw-notifications-property-alias-notifications-group-member-of' )->text() ), |
74
|
1 |
|
'msgkey' => 'smw-notifications-property-alias-notifications-group', |
75
|
1 |
|
'visible' => true, |
76
|
|
|
'annotable' => true |
77
|
1 |
|
), |
78
|
|
|
|
79
|
1 |
|
self::NOTIFICATIONS_TO => array( |
80
|
1 |
|
'label' => SMW_NOTIFICATIONS_TO, |
81
|
1 |
|
'type' => '_wpg', |
82
|
1 |
|
'alias' => array( wfMessage( 'smw-notifications-property-alias-notifications-to' )->text() ), |
83
|
1 |
|
'msgkey' => 'smw-notifications-property-alias-notifications-to', |
84
|
1 |
|
'visible' => true, |
85
|
|
|
'annotable' => true |
86
|
1 |
|
) |
87
|
1 |
|
); |
88
|
|
|
|
89
|
1 |
|
foreach ( $propertyDefinitions as $id => $definition ) { |
90
|
1 |
|
$this->addPropertyDefinition( $propertyRegistry, $id, $definition ); |
91
|
1 |
|
} |
92
|
|
|
|
93
|
1 |
|
foreach ( $propertyDefinitions as $id => $definition ) { |
94
|
|
|
// 2.4+ |
95
|
1 |
|
if ( method_exists( $propertyRegistry, 'registerPropertyAliasByMsgKey' ) ) { |
96
|
1 |
|
$propertyRegistry->registerPropertyAliasByMsgKey( |
97
|
1 |
|
$id, |
98
|
1 |
|
$definition['msgkey'] |
99
|
1 |
|
); |
100
|
1 |
|
} |
101
|
1 |
|
} |
102
|
|
|
|
103
|
1 |
|
return true; |
104
|
|
|
} |
105
|
|
|
|
106
|
1 |
|
private function addPropertyDefinition( $propertyRegistry, $id, $definition ) { |
107
|
|
|
|
108
|
1 |
|
$propertyRegistry->registerProperty( |
109
|
1 |
|
$id, |
110
|
1 |
|
$definition['type'], |
111
|
1 |
|
$definition['label'], |
112
|
1 |
|
$definition['visible'], |
113
|
1 |
|
$definition['annotable'] |
114
|
1 |
|
); |
115
|
|
|
|
116
|
1 |
|
foreach ( $definition['alias'] as $alias ) { |
117
|
1 |
|
$propertyRegistry->registerPropertyAlias( |
118
|
1 |
|
$id, |
119
|
|
|
$alias |
120
|
1 |
|
); |
121
|
1 |
|
} |
122
|
1 |
|
} |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|