1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Removes a config setting. |
5
|
|
|
* |
6
|
|
|
* @param string $name The name of the field. |
7
|
|
|
* |
8
|
|
|
* @return bool Success or failure |
9
|
|
|
* |
10
|
|
|
* @see get_config() |
11
|
|
|
* @see set_config() |
12
|
|
|
* |
13
|
|
|
* @deprecated Use elgg_remove_config() |
14
|
|
|
*/ |
15
|
|
|
function unset_config($name) { |
16
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_remove_config().', '3.0'); |
17
|
|
|
return elgg_remove_config($name); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Add or update a config setting. |
22
|
|
|
* |
23
|
|
|
* Plugin authors should use elgg_set_config(). |
24
|
|
|
* |
25
|
|
|
* If the config name already exists, it will be updated to the new value. |
26
|
|
|
* |
27
|
|
|
* @param string $name The name of the configuration value |
28
|
|
|
* @param mixed $value Its value |
29
|
|
|
* |
30
|
|
|
* @return bool |
31
|
|
|
* @see unset_config() |
32
|
|
|
* @see get_config() |
33
|
|
|
* @access private |
34
|
|
|
* |
35
|
|
|
* @deprecated Use elgg_save_config() |
36
|
|
|
*/ |
37
|
|
|
function set_config($name, $value) { |
38
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_save_config().', '3.0'); |
39
|
|
|
return elgg_save_config($name, $value); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Gets a configuration value |
44
|
|
|
* |
45
|
|
|
* Plugin authors should use elgg_get_config(). |
46
|
|
|
* |
47
|
|
|
* @param string $name The name of the config value |
48
|
|
|
* |
49
|
|
|
* @return mixed|null |
50
|
|
|
* @see set_config() |
51
|
|
|
* @see unset_config() |
52
|
|
|
* @access private |
53
|
|
|
* |
54
|
|
|
* @deprecated Use elgg_get_config() |
55
|
|
|
*/ |
56
|
|
|
function get_config($name) { |
57
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_config().', '3.0'); |
58
|
|
|
return elgg_get_config($name); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Add an admin area section or child section. |
63
|
|
|
* This is a wrapper for elgg_register_menu_item(). |
64
|
|
|
* |
65
|
|
|
* Used in conjuction with http://elgg.org/admin/section_id/child_section style |
66
|
|
|
* page handler. See the documentation at the top of this file for more details |
67
|
|
|
* on that. |
68
|
|
|
* |
69
|
|
|
* The text of the menu item is obtained from elgg_echo(admin:$parent_id:$menu_id) |
70
|
|
|
* |
71
|
|
|
* This function handles registering the parent if it has not been registered. |
72
|
|
|
* |
73
|
|
|
* @param string $section The menu section to add to |
74
|
|
|
* @param string $menu_id The unique ID of section |
75
|
|
|
* @param string $parent_id If a child section, the parent section id |
76
|
|
|
* @param int $priority The menu item priority |
77
|
|
|
* |
78
|
|
|
* @return bool |
79
|
|
|
* @since 1.8.0 |
80
|
|
|
* |
81
|
|
|
* @deprecated Use elgg_remove_config() |
82
|
|
|
*/ |
83
|
|
|
function elgg_register_admin_menu_item($section, $menu_id, $parent_id = null, $priority = 100) { |
84
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_register_menu_item().', '3.0'); |
85
|
|
|
// make sure parent is registered |
86
|
|
|
if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) { |
|
|
|
|
87
|
|
|
elgg_register_admin_menu_item($section, $parent_id); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
// in the admin section parents never have links |
91
|
|
|
if ($parent_id) { |
|
|
|
|
92
|
|
|
$href = "admin/$parent_id/$menu_id"; |
93
|
|
|
} else { |
94
|
|
|
$href = "admin/$menu_id"; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
$name = $menu_id; |
98
|
|
|
if ($parent_id) { |
|
|
|
|
99
|
|
|
$name = "$parent_id:$name"; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return elgg_register_menu_item('page', [ |
103
|
|
|
'name' => $name, |
104
|
|
|
'href' => $href, |
105
|
|
|
'text' => elgg_echo("admin:$name"), |
106
|
|
|
'context' => 'admin', |
107
|
|
|
'parent_name' => $parent_id, |
108
|
|
|
'priority' => $priority, |
109
|
|
|
'section' => $section |
110
|
|
|
]); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Mark entities with a particular type and subtype as having access permissions |
115
|
|
|
* that can be changed independently from their parent entity |
116
|
|
|
* |
117
|
|
|
* @param string $type The type - object, user, etc |
118
|
|
|
* @param string $subtype The subtype; all subtypes by default |
119
|
|
|
* |
120
|
|
|
* @return void |
121
|
|
|
* |
122
|
|
|
* @deprecated |
123
|
|
|
*/ |
124
|
|
|
function register_metadata_as_independent($type, $subtype = '*') { |
|
|
|
|
125
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0'); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Determines whether entities of a given type and subtype should not change |
130
|
|
|
* their metadata in line with their parent entity |
131
|
|
|
* |
132
|
|
|
* @param string $type The type - object, user, etc |
133
|
|
|
* @param string $subtype The entity subtype |
134
|
|
|
* |
135
|
|
|
* @return bool |
136
|
|
|
* |
137
|
|
|
* @deprecated |
138
|
|
|
*/ |
139
|
|
|
function is_metadata_independent($type, $subtype) { |
|
|
|
|
140
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0'); |
141
|
|
|
|
142
|
|
|
return false; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Gets entities based upon attributes in secondary tables. |
147
|
|
|
* Also accepts all options available to elgg_get_entities(), |
148
|
|
|
* elgg_get_entities_from_metadata(), and elgg_get_entities_from_relationship(). |
149
|
|
|
* |
150
|
|
|
* @warning requires that the entity type be specified and there can only be one |
151
|
|
|
* type. |
152
|
|
|
* |
153
|
|
|
* @see elgg_get_entities |
154
|
|
|
* @see elgg_get_entities_from_metadata |
155
|
|
|
* @see elgg_get_entities_from_relationship |
156
|
|
|
* |
157
|
|
|
* @param array $options Array in format: |
158
|
|
|
* |
159
|
|
|
* attribute_name_value_pairs => ARR ( |
160
|
|
|
* 'name' => 'name', |
161
|
|
|
* 'value' => 'value', |
162
|
|
|
* 'operand' => '=', (optional) |
163
|
|
|
* 'case_sensitive' => false (optional) |
164
|
|
|
* ) |
165
|
|
|
* If multiple values are sent via |
166
|
|
|
* an array ('value' => array('value1', 'value2') |
167
|
|
|
* the pair's operand will be forced to "IN". |
168
|
|
|
* |
169
|
|
|
* attribute_name_value_pairs_operator => null|STR The operator to use for combining |
170
|
|
|
* (name = value) OPERATOR (name = value); default is AND |
171
|
|
|
* |
172
|
|
|
* @return \ElggEntity[]|mixed If count, int. If not count, array. false on errors. |
173
|
|
|
* @since 1.9.0 |
174
|
|
|
* @throws InvalidArgumentException |
175
|
|
|
* @deprecated Use elgg_get_entities_from_metadata() |
176
|
|
|
*/ |
177
|
|
|
function elgg_get_entities_from_attributes(array $options = []) { |
178
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_metadata.', '3.0'); |
179
|
|
|
|
180
|
|
|
$options['metadata_name_value_pairs'] = elgg_extract('attribute_name_value_pairs', $options, []); |
181
|
|
|
$options['metadata_name_value_pairs_operator'] = elgg_extract('attribute_name_value_pairs_operator', $options, []); |
182
|
|
|
|
183
|
|
|
unset($options['attribute_name_value_pairs']); |
184
|
|
|
unset($options['attribute_name_value_pairs_operator']); |
185
|
|
|
|
186
|
|
|
return elgg_get_entities_from_relationship($options); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Ban a user |
191
|
|
|
* |
192
|
|
|
* @param int $user_guid The user guid |
193
|
|
|
* @param string $reason A reason |
194
|
|
|
* |
195
|
|
|
* @return bool |
196
|
|
|
* |
197
|
|
|
* @deprecated Use \ElggUser->ban() |
198
|
|
|
*/ |
199
|
|
View Code Duplication |
function ban_user($user_guid, $reason = "") { |
|
|
|
|
200
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::ban()', '3.0'); |
201
|
|
|
|
202
|
|
|
$user = get_user($user_guid); |
203
|
|
|
if (!$user) { |
204
|
|
|
return false; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
return $user->ban($reason); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Unban a user. |
212
|
|
|
* |
213
|
|
|
* @param int $user_guid Unban a user. |
214
|
|
|
* |
215
|
|
|
* @return bool |
216
|
|
|
* |
217
|
|
|
* @deprecated Use \ElggUser->unban() |
218
|
|
|
*/ |
219
|
|
View Code Duplication |
function unban_user($user_guid) { |
|
|
|
|
220
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::unban()', '3.0'); |
221
|
|
|
|
222
|
|
|
$user = get_user($user_guid); |
223
|
|
|
if (!$user) { |
224
|
|
|
return false; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
return $user->unban(); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Makes user $guid an admin. |
232
|
|
|
* |
233
|
|
|
* @param int $user_guid User guid |
234
|
|
|
* |
235
|
|
|
* @return bool |
236
|
|
|
* |
237
|
|
|
* @deprecated Use \ElggUser->makeAdmin() |
238
|
|
|
*/ |
239
|
|
View Code Duplication |
function make_user_admin($user_guid) { |
|
|
|
|
240
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::makeAdmin()', '3.0'); |
241
|
|
|
|
242
|
|
|
$user = get_user($user_guid); |
243
|
|
|
if (!$user) { |
244
|
|
|
return false; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $user->makeAdmin(); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Removes user $guid's admin flag. |
252
|
|
|
* |
253
|
|
|
* @param int $user_guid User GUID |
254
|
|
|
* |
255
|
|
|
* @return bool |
256
|
|
|
* |
257
|
|
|
* @deprecated Use \ElggUser->removeAdmin() |
258
|
|
|
*/ |
259
|
|
View Code Duplication |
function remove_user_admin($user_guid) { |
|
|
|
|
260
|
|
|
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::removeAdmin()', '3.0'); |
261
|
|
|
|
262
|
|
|
$user = get_user($user_guid); |
263
|
|
|
if (!$user) { |
264
|
|
|
return false; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
return $user->removeAdmin(); |
268
|
|
|
} |
269
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: