Elgg  Version 5.1
unmute.php
Go to the documentation of this file.
1 <?php
6 $entity_guid = (int) get_input('guid');
8 
9 $forward_url = get_input('forward_url');
10 $show_success = (bool) get_input('show_success', true);
11 
13 if (!$entity instanceof \ElggEntity) {
14  return elgg_error_response(elgg_echo('error:missing_data'));
15 }
16 
18 if (!$user instanceof \ElggUser || !$user->canEdit()) {
19  return elgg_error_response(elgg_echo('actionunauthorized'));
20 }
21 
22 $display_name = $entity->getDisplayName() ?: elgg_echo('item');
23 
24 if (!$entity->unmuteNotifications($user->guid)) {
25  return elgg_error_response(elgg_echo('entity:unmute:fail', [$display_name]));
26 }
27 
29  "entity:unmute:{$entity->type}:{$entity->subtype}:success",
30  "entity:unmute:{$entity->type}:success",
31  'entity:unmute:success',
32 ];
33 
34 $message = '';
35 if ($show_success) {
36  foreach ($success_keys as $success_key) {
37  if (elgg_language_key_exists($success_key)) {
38  $message = elgg_echo($success_key, [$display_name]);
39  break;
40  }
41  }
42 }
43 
if(!$entity->unmuteNotifications($user->guid)) $success_keys
Definition: unmute.php:28
$entity_guid
Handle unmuting notifications about an entity.
Definition: unmute.php:6
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(!$user instanceof\ElggUser||!$user->canEdit()) $display_name
Definition: unmute.php:22
canEdit(int $user_guid=0)
Can a user edit this entity?
Definition: ElggEntity.php:946
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:67
$entity
Definition: unmute.php:12
$user_guid
Definition: unmute.php:7
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
$show_success
Definition: unmute.php:10
if(!$entity instanceof\ElggEntity) $user
Definition: unmute.php:17
$forward_url
Definition: unmute.php:9
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34
$message
Definition: unmute.php:34