Elgg  Version 2.3
actions.php
Go to the documentation of this file.
1 <?php
12 
21 function _elgg_action_handler(array $segments) {
22  return _elgg_services()->actions->execute(implode('/', $segments));
23 }
24 
53 function action($action, $forwarder = "") {
54  $response = _elgg_services()->actions->execute($action, $forwarder);
55  if ($response instanceof ResponseBuilder) {
56  // in case forward() wasn't called in the action
57  _elgg_services()->responseFactory->respond($response);
58  }
59  _elgg_services()->responseFactory->redirect(REFERRER, 'csrf');
60 }
61 
96 function elgg_register_action($action, $filename = "", $access = 'logged_in') {
97  return _elgg_services()->actions->register($action, $filename, $access);
98 }
99 
108  return _elgg_services()->actions->unregister($action);
109 }
110 
119  return _elgg_services()->crypto->getHmac($data);
120 }
121 
138 function validate_action_token($visible_errors = true, $token = null, $ts = null) {
139  return _elgg_services()->actions->validateActionToken($visible_errors, $token, $ts);
140 }
141 
157  return _elgg_services()->actions->gatekeeper($action);
158 }
159 
178  return _elgg_services()->actions->generateActionToken($timestamp);
179 }
180 
192 function init_site_secret() {
193  return _elgg_services()->siteSecret->init();
194 }
195 
205 function get_site_secret() {
206  return _elgg_services()->siteSecret->get();
207 }
208 
216  return _elgg_services()->siteSecret->getStrength();
217 }
218 
228  return _elgg_services()->actions->exists($action);
229 }
230 
237 function elgg_is_xhr() {
238  return _elgg_services()->request->isXmlHttpRequest();
239 }
240 
268 function ajax_forward_hook($hook, $type, $reason, $params) {
269  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated and is no longer used as a plugin hook handler', '2.3');
270  _elgg_services()->actions->ajaxForwardHook($hook, $type, $reason, $params);
271 }
272 
279 function ajax_action_hook() {
280  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated and is no longer used as a plugin hook handler', '2.3');
281  _elgg_services()->actions->ajaxActionHook();
282 }
283 
291  return _elgg_services()->actions->handleTokenRefreshRequest();
292 }
293 
298 function actions_init() {
299  elgg_register_page_handler('action', '_elgg_action_handler');
300  elgg_register_page_handler('refresh_token', '_elgg_csrf_token_refresh');
301 
302  elgg_register_simplecache_view('languages/en.js');
303 }
304 
305 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
306  $events->registerHandler('init', 'system', 'actions_init');
307 };
HTTP response builder interface.
$action
Definition: full.php:133
elgg_is_xhr()
Checks whether the request was requested via ajax.
Definition: actions.php:237
action($action, $forwarder="")
Perform an action.
Definition: actions.php:53
action_gatekeeper($action)
Validates the presence of action tokens.
Definition: actions.php:156
elgg_action_exists($action)
Check if an action is registered and its script exists.
Definition: actions.php:227
elgg_register_simplecache_view($view_name)
Registers a view to simple cache.
Definition: cache.php:108
$data
Definition: opendd.php:13
init_site_secret()
Initialise the site secret (32 bytes: "z" to indicate format + 186-bit key in Base64 URL)...
Definition: actions.php:192
$timestamp
Definition: date.php:33
$params
Definition: login.php:72
const REFERRER
Definition: elgglib.php:2113
generate_action_token($timestamp)
Generate an action token.
Definition: actions.php:177
actions_init()
Initialize some ajaxy actions features private.
Definition: actions.php:298
elgg_build_hmac($data)
Get an HMAC token builder/validator object.
Definition: actions.php:118
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
Definition: pagehandler.php:34
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
ajax_forward_hook($hook, $type, $reason, $params)
Catch calls to forward() in ajax request and force an exit.
Definition: actions.php:268
get_site_secret()
Returns the site secret.
Definition: actions.php:205
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
$token
_elgg_action_handler(array $segments)
Handle a request for an action.
Definition: actions.php:21
validate_action_token($visible_errors=true, $token=null, $ts=null)
Validate an action token.
Definition: actions.php:138
_elgg_get_site_secret_strength()
Get the strength of the site secret.
Definition: actions.php:215
$filename
_elgg_csrf_token_refresh()
Send an updated CSRF token, provided the page&#39;s current tokens were not fake.
Definition: actions.php:290
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:96
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5
$access
Definition: save.php:15
ajax_action_hook()
Buffer all output echo&#39;d directly in the action for inclusion in the returned JSON.
Definition: actions.php:279
if(!$display_name) $type
Definition: delete.php:27
elgg_unregister_action($action)
Unregisters an action.
Definition: actions.php:107