1<?php
2/**
3 * Lists all function deprecated in Elgg 3.3
4 */
5
6/**
7 * Deletes all cached views in the simplecache
8 *
9 * @return bool
10 * @since 1.7.4
11 * @deprecated 3.3
12 */
13function elgg_invalidate_simplecache() {
14	elgg_deprecated_notice(__METHOD__ . ' is deprecated. Use elgg_clear_caches()', '3.3');
15
16	_elgg_services()->simpleCache->clear();
17}
18
19/**
20 * Flush all the registered caches
21 *
22 * @return void
23 * @since 1.11
24 * @deprecated 3.3 use elgg_clear_caches()
25 */
26function elgg_flush_caches() {
27	// this event sequence could take while, make sure there is no timeout
28	set_time_limit(0);
29
30	elgg_invalidate_caches();
31	elgg_clear_caches();
32
33	_elgg_services()->events->triggerDeprecatedSequence(
34		'cache:flush',
35		'system',
36		null,
37		null,
38		"The 'cache:flush' sequence has been deprecated, please use 'cache:clear'.",
39		'3.3'
40	);
41}
42
43/**
44 * Queue a query for running during shutdown that writes to the database
45 *
46 * @param string   $query    The query to execute
47 * @param callable $callback The optional callback for processing. The callback will receive a
48 *                           \Doctrine\DBAL\Driver\Statement object
49 * @param array    $params   Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve']
50 *
51 * @return boolean
52 * @deprecated 3.3 use elgg()->db->registerDelayedQuery()
53 */
54function execute_delayed_write_query($query, $callback = null, array $params = []) {
55	elgg_deprecated_notice(__METHOD__ . ' is deprecated. Use elgg()->db->registerDelayedQuery()', '3.3');
56
57	return _elgg_services()->db->registerDelayedQuery($query, 'write', $callback, $params);
58}
59
60/**
61 * Queue a query for running during shutdown that reads from the database
62 *
63 * @param string   $query    The query to execute
64 * @param callable $callback The optional callback for processing. The callback will receive a
65 *                           \Doctrine\DBAL\Driver\Statement object
66 * @param array    $params   Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve']
67 *
68 * @return boolean
69 * @deprecated 3.3 use elgg()->db->registerDelayedQuery()
70 */
71function execute_delayed_read_query($query, $callback = null, array $params = []) {
72	elgg_deprecated_notice(__METHOD__ . ' is deprecated. Use elgg()->db->registerDelayedQuery()', '3.3');
73
74	return _elgg_services()->db->registerDelayedQuery($query, 'read', $callback, $params);
75}
76
77/**
78 * Runs a full database script from disk.
79 *
80 * The file specified should be a standard SQL file as created by
81 * mysqldump or similar.  Statements must be terminated with ;
82 * and a newline character (\n or \r\n) with only one statement per line.
83 *
84 * The special string 'prefix_' is replaced with the database prefix
85 * as defined in {@link $CONFIG->dbprefix}.
86 *
87 * @warning Errors do not halt execution of the script.  If a line
88 * generates an error, the error message is saved and the
89 * next line is executed.  After the file is run, any errors
90 * are displayed as a {@link DatabaseException}
91 *
92 * @param string $scriptlocation The full path to the script
93 *
94 * @return void
95 * @throws DatabaseException
96 * @deprecated 3.3
97 */
98function run_sql_script($scriptlocation) {
99	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
100
101	_elgg_services()->db->runSqlScript($scriptlocation);
102}
103
104/**
105 * Enable the MySQL query cache
106 *
107 * @return void
108 *
109 * @since 2.0.0
110 * @deprecated 3.3
111 */
112function elgg_enable_query_cache() {
113	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
114
115	_elgg_services()->queryCache->enable();
116}
117
118/**
119 * Disable the MySQL query cache
120 *
121 * @note Elgg already manages the query cache sensibly, so you probably don't need to use this.
122 *
123 * @return void
124 *
125 * @since 2.0.0
126 * @deprecated 3.3
127 */
128function elgg_disable_query_cache() {
129	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
130
131	_elgg_services()->queryCache->disable();
132}
133
134/**
135 * Check if a menu item has been registered
136 *
137 * @param string $menu_name The name of the menu
138 * @param string $item_name The unique identifier for this menu item
139 *
140 * @return bool
141 * @since 1.8.0
142 * @deprecated 3.3
143 */
144function elgg_is_menu_item_registered($menu_name, $item_name) {
145	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
146
147	$menus = _elgg_config()->menus;
148	if (empty($menus)) {
149		return false;
150	}
151
152	if (!isset($menus[$menu_name])) {
153		return false;
154	}
155
156	foreach ($menus[$menu_name] as $menu_object) {
157		/* @var \ElggMenuItem $menu_object */
158		if ($menu_object->getName() == $item_name) {
159			return true;
160		}
161	}
162
163	return false;
164}
165
166/**
167 * Get a menu item registered for a menu
168 *
169 * @param string $menu_name The name of the menu
170 * @param string $item_name The unique identifier for this menu item
171 *
172 * @return ElggMenuItem|null
173 * @since 1.9.0
174 * @deprecated 3.3
175 */
176function elgg_get_menu_item($menu_name, $item_name) {
177	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
178
179	$menus = _elgg_config()->menus;
180	if (empty($menus)) {
181		return null;
182	}
183
184	if (!isset($menus[$menu_name])) {
185		return null;
186	}
187
188	foreach ($menus[$menu_name] as $index => $menu_object) {
189		/* @var \ElggMenuItem $menu_object */
190		if ($menu_object->getName() == $item_name) {
191			return $menus[$menu_name][$index];
192		}
193	}
194
195	return null;
196}
197
198/**
199 * Converts an associative array into a string of well-formed HTML/XML attributes
200 * Returns a concatenated string of HTML attributes to be inserted into a tag (e.g., <tag $attrs>)
201 *
202 * @param array $attrs Attributes
203 *                     An array of attribute => value pairs
204 *                     Attribute value can be a scalar value, an array of scalar values, or true
205 *                     <code>
206 *                     $attrs = array(
207 *                         'class' => ['elgg-input', 'elgg-input-text'], // will be imploded with spaces
208 *                         'style' => ['margin-left:10px;', 'color: #666;'], // will be imploded with spaces
209 *                         'alt' => 'Alt text', // will be left as is
210 *                         'disabled' => true, // will be converted to disabled="disabled"
211 *                         'data-options' => json_encode(['foo' => 'bar']), // will be output as an escaped JSON string
212 *                         'batch' => <\ElggBatch>, // will be ignored
213 *                         'items' => [<\ElggObject>], // will be ignored
214 *                     );
215 *                     </code>
216 *
217 * @return string
218 *
219 * @see elgg_format_element()
220 * @deprecated 3.3 Use elgg_format_element()
221 */
222function elgg_format_attributes(array $attrs = []) {
223	elgg_deprecated_notice(__METHOD__ . ' is deprecated. Use elgg_format_element()', '3.3');
224
225	return _elgg_services()->html_formatter->formatAttributes($attrs);
226}
227
228/**
229 * List all views in a viewtype
230 *
231 * @param string $viewtype Viewtype
232 *
233 * @return string[]
234 *
235 * @since 2.0
236 * @deprecated 3.3
237 */
238function elgg_list_views($viewtype = 'default') {
239	elgg_deprecated_notice(__METHOD__ . ' is deprecated.', '3.3');
240
241	return _elgg_services()->views->listViews($viewtype);
242}
243
244/**
245 * Unsets all plugin settings for a plugin.
246 *
247 * @param string $plugin_id The plugin ID (Required)
248 *
249 * @return bool
250 * @since 1.8.0
251 * @deprecated 3.3 use \ElggPlugin::unsetAllSettings()
252 */
253function elgg_unset_all_plugin_settings($plugin_id) {
254	elgg_deprecated_notice(__METHOD__ . ' has been deprecated, use \ElggPlugin::unsetAllSettings()', '3.3');
255
256	$plugin = _elgg_services()->plugins->get($plugin_id);
257	if (!$plugin) {
258		return false;
259	}
260
261	return $plugin->unsetAllSettings();
262}
263
264/**
265 * Returns the category of a file from its MIME type
266 *
267 * @param string $mime_type The MIME type
268 *
269 * @return string 'document', 'audio', 'video', or 'general' if the MIME type was unrecognized
270 * @since 1.10
271 * @deprecated 3.3 use elgg()->mimetype->getSimpleType()
272 */
273function elgg_get_file_simple_type($mime_type) {
274	elgg_deprecated_notice(__METHOD__ . ' has been deprecated, use elgg()->mimetype->getSimpleType()', '3.3');
275
276	return elgg()->mimetype->getSimpleType($mime_type);
277}
278
279/**
280 * Display a plugin-specified rendered list of annotations for an entity.
281 *
282 * This displays the output of functions registered to the entity:annotation,
283 * $entity_type plugin hook.
284 *
285 * This is called automatically by the framework from {@link elgg_view_entity()}
286 *
287 * @param \ElggEntity $entity    Entity
288 * @param bool        $full_view Display full view?
289 *
290 * @return mixed string or false on failure
291 * @deprecated 3.3
292 */
293function elgg_view_entity_annotations(\ElggEntity $entity, $full_view = true) {
294
295	$entity_type = $entity->getType();
296
297	return elgg_trigger_deprecated_plugin_hook('entity:annotate', $entity_type,
298		[
299			'entity' => $entity,
300			'full_view' => $full_view,
301		],
302		null,
303		'Using the "entity:annotate" hook to add annotations to the view of a full entity is deprecated.',
304		'3.3'
305	);
306}
307
308/**
309 * Returns an ordered array of hook handlers registered for $hook and $type.
310 *
311 * @param string $hook Hook name
312 * @param string $type Hook type
313 *
314 * @return array
315 *
316 * @since 2.0.0
317 *
318 * @deprecated 3.3 Use elgg()->hooks->getOrderedHandlers()
319 */
320function elgg_get_ordered_hook_handlers($hook, $type) {
321	elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg()->hooks->getOrderedHandlers()', '3.3');
322
323	return elgg()->hooks->getOrderedHandlers($hook, $type);
324}
325
326/**
327 * Returns an ordered array of event handlers registered for $event and $type.
328 *
329 * @param string $event Event name
330 * @param string $type  Object type
331 *
332 * @return array
333 *
334 * @since 2.0.0
335 *
336 * @deprecated 3.3 use elgg()->events->getOrderedHandlers()
337 */
338function elgg_get_ordered_event_handlers($event, $type) {
339	elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg()->events->getOrderedHandlers()', '3.3');
340
341	return elgg()->events->getOrderedHandlers($event, $type);
342}
343
344/**
345 * Generate an action token.
346 *
347 * Action tokens are based on timestamps as returned by {@link time()}.
348 * They are valid for one hour.
349 *
350 * Action tokens should be passed to all actions name __elgg_ts and __elgg_token.
351 *
352 * @warning Action tokens are required for all actions.
353 *
354 * @param int $timestamp Unix timestamp
355 *
356 * @see @elgg_view input/securitytoken
357 * @see @elgg_view input/form
358 *
359 * @return string|false
360 *
361 * @deprecated use elgg()->csrf->generateActionToken()
362 */
363function generate_action_token($timestamp) {
364	elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg()->csrf->generateActionToken()', '3.3');
365
366	return elgg()->csrf->generateActionToken($timestamp);
367}
368
369/**
370 * Wrapper function for mb_split(). Falls back to split() if
371 * mb_split() isn't available.  Parameters are passed to the
372 * wrapped function in the same order they are passed to this
373 * function.
374 *
375 * @return string
376 * @since 1.7.0
377 * @deprecated
378 */
379function elgg_split() {
380	elgg_deprecated_notice(__METHOD__ . ' has been deprecated', '3.3');
381
382	$args = func_get_args();
383	if (is_callable('mb_split')) {
384		return call_user_func_array('mb_split', $args);
385	}
386	return call_user_func_array('split', $args);
387}
388