Elgg  Version master
chooserestoredestination.php
Go to the documentation of this file.
1 <?php
8 
10 
11 $entity_guid = (int) get_input('entity_guid');
13  return get_entity($entity_guid);
14 });
15 if (!$entity instanceof \ElggEntity) {
16  throw new EntityNotFoundException();
17 }
18 
19 if (!$entity->canEdit()) {
20  throw new EntityPermissionsException();
21 }
22 
23 echo elgg_view_field([
24  '#type' => 'hidden',
25  'name' => 'entity_guid',
26  'value' => $entity->guid,
27 ]);
28 
29 $owner = $entity->getOwnerEntity();
30 if ($owner instanceof \ElggUser && $owner->getGroups(['count' => true])) {
31  echo elgg_view('output/longtext', [
32  'value' => elgg_echo('trash:restore:container:choose'),
33  ]);
34 
35  echo elgg_view_field([
36  '#type' => 'radio',
37  'name' => 'destination_container_guid',
38  'value' => 'group',
39  'options_values' => [
40  'group' => elgg_echo('trash:restore:container:group'),
41  ],
42  ]);
43 
44  echo elgg_view_field([
45  '#type' => 'grouppicker',
46  '#label' => elgg_echo('trash:restore:group'),
47  '#help' => elgg_echo('trash:restore:group:help'),
48  'name' => 'destination_container_guid',
49  'options' => [
50  'match_target' => $owner->guid,
51  'match_membership' => !elgg_is_admin_logged_in(),
52  ],
53  'limit' => 1,
54  ]);
55 
56  echo elgg_view_field([
57  '#type' => 'radio',
58  'name' => 'destination_container_guid',
59  'options_values' => [
60  $owner->guid => elgg_echo('trash:restore:owner', [$owner->getDisplayName()]),
61  ],
62  ]);
63 } else {
64  echo elgg_view('output/longtext', [
65  'value' => elgg_echo('trash:restore:container:owner'),
66  ]);
67  echo elgg_view_field([
68  '#type' => 'hidden',
69  'name' => 'destination_container_guid',
70  'value' => $owner->guid,
71  ]);
72 }
73 
74 // form footer
76  '#type' => 'submit',
77  'text' => elgg_echo('save'),
78  'confirm' => elgg_echo('restoreandmoveconfirm'),
79 ]);
80 
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
Definition: elgglib.php:304
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
if(empty($guid)||empty($destination_container_guid)) $entity
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_set_form_footer(string $footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1046
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:70
Thrown when entity can not be edited or container permissions do not allow it to be written...
const ELGG_SHOW_DELETED_ENTITIES
Definition: constants.php:127
Aggregate action for saving settings.
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
Definition: gatekeepers.php:64