Elgg  Version 7.1
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 
30  '#type' => 'submit',
31  'text' => elgg_echo('save'),
32  'confirm' => elgg_echo('restoreandmoveconfirm'),
33 ]);
34 
36 $owner = $entity->getOwnerEntity();
37 if (!$owner instanceof \ElggUser && $actor->getGroups(['count' => true])) {
38  echo elgg_view('output/longtext', [
39  'value' => elgg_echo('trash:restore:container:choose'),
40  ]);
41 
42  echo elgg_view_field([
43  '#type' => 'grouppicker',
44  '#label' => elgg_echo('trash:restore:group'),
45  '#help' => elgg_echo('trash:restore:group:help'),
46  'name' => 'destination_container_guid',
47  'options' => [
48  'match_target' => $actor->guid,
49  'match_membership' => !$actor->isAdmin(),
50  ],
51  'limit' => 1,
52  'save_as_array' => false,
53  ]);
54 } elseif ($owner instanceof \ElggUser && $owner->getGroups(['count' => true])) {
55  echo elgg_view('output/longtext', [
56  'value' => elgg_echo('trash:restore:container:choose'),
57  ]);
58 
59  echo elgg_view_field([
60  '#type' => 'radio',
61  'name' => 'destination_container_guid',
62  'value' => 'group',
63  'options_values' => [
64  'group' => elgg_echo('trash:restore:container:group'),
65  ],
66  ]);
67 
68  echo elgg_view_field([
69  '#type' => 'grouppicker',
70  '#label' => elgg_echo('trash:restore:group'),
71  '#help' => elgg_echo('trash:restore:group:help'),
72  'name' => 'destination_container_guid',
73  'options' => [
74  'match_target' => $owner->guid,
75  'match_membership' => !$actor->isAdmin(),
76  ],
77  'limit' => 1,
78  'save_as_array' => false,
79  ]);
80 
81  if ($owner->canWriteToContainer($owner->guid, $entity->type, $entity->subtype)) {
82  echo elgg_view_field([
83  '#type' => 'radio',
84  'name' => 'destination_container_guid',
85  'options_values' => [
86  $owner->guid => elgg_echo('trash:restore:owner', [$owner->getDisplayName()]),
87  ],
88  ]);
89  }
90 } elseif ($owner?->canWriteToContainer($owner->guid, $entity->type, $entity->subtype)) {
91  echo elgg_view('output/longtext', [
92  'value' => elgg_echo('trash:restore:container:owner'),
93  ]);
94 
95  echo elgg_view_field([
96  '#type' => 'hidden',
97  'name' => 'destination_container_guid',
98  'value' => $owner->guid,
99  ]);
100 } else {
101  echo elgg_view('output/longtext', [
102  'value' => elgg_echo('trash:restore:container:unknown'),
103  ]);
104 
106  '#type' => 'reset',
107  'text' => elgg_echo('cancel'),
108  'onclick' => '$.colorbox.close();',
109  ]);
110 }
111 
if(empty($guid)||empty($destination_container_guid)) $entity
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
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
Definition: item.php:48
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:300
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
Definition: gatekeepers.php:53
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:68
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1164
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:1105
elgg_view(string $view, array $vars=[], string $viewtype='')
Return a parsed view.
Definition: views.php:156
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:24