-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: Finn Thomas <[email protected]> Co-authored-by: SirDisappointing <[email protected]> Co-authored-by: Yana Lazareva <[email protected]> Co-authored-by: Jumanah <[email protected]> Co-authored-by: bako <[email protected]> Co-authored-by: 493611 <[email protected]> Co-authored-by: finndthomas <[email protected]> Co-authored-by: SirDisappointing <[email protected]>
- Loading branch information
1 parent
8807978
commit 2074ab7
Showing
64 changed files
with
2,419 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
/vendor | ||
|
||
# don't ignore bundled plugins | ||
!/mod/bin | ||
!/mod/activity | ||
!/mod/blog/ | ||
!/mod/bookmarks/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
/** | ||
* Action for choosing destination to restore a post to. | ||
* | ||
*/ | ||
|
||
$guid = (int) get_input('entity_guid'); | ||
$deleter_guid = (int) get_input('deleter_guid'); | ||
$destination_container_guid = (int) get_input('destination_container_guid'); | ||
|
||
$entity = elgg_call(ELGG_SHOW_SOFT_DELETED_ENTITIES, function () use ($guid){ | ||
return get_entity($guid); | ||
}); | ||
if (!$entity instanceof \ElggEntity) { | ||
return elgg_error_response(elgg_echo('entity:restore:item_not_found')); | ||
} | ||
|
||
set_time_limit(0); | ||
|
||
// determine what name to show on success | ||
$display_name = $entity->getDisplayName() ?: elgg_echo('entity:restore:item'); | ||
|
||
|
||
$soft_deletable_entities = elgg_entity_types_with_capability('soft_deletable'); | ||
|
||
|
||
if ($entity->getSoftDeleted() === 'yes') { | ||
// restore-and-move: move the entity to new container. Currently NOT fail-safe against fail restore. | ||
if (!$entity->restore(false)) { | ||
return elgg_error_response(elgg_echo('entity:restore:fail', [$display_name])); | ||
} | ||
|
||
if (!($entity->overrideEntityContainerID($entity->guid, $entity->type, $entity->subtype, $destination_container_guid))) { | ||
return elgg_error_response(elgg_echo('entity:restore:fail', [$display_name])); | ||
} | ||
} | ||
|
||
$type = $entity->getType(); | ||
$subtype = $entity->getSubtype(); | ||
$container = $entity->getContainerEntity(); | ||
|
||
// determine forward URL | ||
$forward_url = get_input('forward_url'); | ||
if (!empty($forward_url)) { | ||
$forward_url = elgg_normalize_site_url((string) $forward_url); | ||
} | ||
|
||
if (empty($forward_url)) { | ||
$forward_url = REFERRER; | ||
$referrer_url = elgg_extract('HTTP_REFERER', $_SERVER, ''); | ||
$site_url = elgg_get_site_url(); | ||
|
||
$find_forward_url = function (\ElggEntity $container = null) use ($type, $subtype) { | ||
$routes = _elgg_services()->routes; | ||
|
||
// check if there is a collection route (eg. blog/owner/username) | ||
$route_name = false; | ||
if ($container instanceof \ElggUser) { | ||
$route_name = "collection:{$type}:{$subtype}:owner"; | ||
} elseif ($container instanceof \ElggGroup) { | ||
$route_name = "collection:{$type}:{$subtype}:group"; | ||
} | ||
|
||
if ($route_name && $routes->get($route_name)) { | ||
$params = $routes->resolveRouteParameters($route_name, $container); | ||
|
||
return elgg_generate_url($route_name, $params); | ||
} | ||
|
||
// no route found, fallback to container url | ||
if ($container instanceof \ElggEntity) { | ||
return $container->getURL(); | ||
} | ||
|
||
// no container | ||
return ''; | ||
}; | ||
|
||
if (!empty($referrer_url) && elgg_strpos($referrer_url, $site_url) === 0) { | ||
// referer is on current site | ||
$referrer_path = elgg_substr($referrer_url, elgg_strlen($site_url)); | ||
$segments = explode('/', $referrer_path); | ||
|
||
if (in_array($guid, $segments)) { | ||
// referrer URL contains a reference to the entity that will be deleted | ||
$forward_url = $find_forward_url($container); | ||
} | ||
} elseif ($container instanceof \ElggEntity) { | ||
$forward_url = $find_forward_url($container); | ||
} | ||
} | ||
|
||
$success_keys = [ | ||
"entity:restore:{$type}:{$subtype}:success", | ||
"entity:restore:{$type}:success", | ||
'entity:restore:success', | ||
]; | ||
|
||
$message = ''; | ||
if (get_input('show_success', true)) { | ||
foreach ($success_keys as $success_key) { | ||
if (elgg_language_key_exists($success_key)) { | ||
$message = elgg_echo($success_key, [$display_name]); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return elgg_ok_response('', $message, $forward_url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/** | ||
* Default entity restore action | ||
*/ | ||
|
||
$guid = (int) get_input('guid'); | ||
$deleter_guid = (int) get_input('deleter_guid'); | ||
$recursive = (bool) get_input('recursive', true); | ||
|
||
$entity = elgg_call(ELGG_SHOW_SOFT_DELETED_ENTITIES, function () use ($guid){ | ||
return get_entity($guid); | ||
}); | ||
if (!$entity instanceof \ElggEntity) { | ||
return elgg_error_response(elgg_echo('entity:restore:item_not_found')); | ||
} | ||
|
||
set_time_limit(0); | ||
|
||
// determine what name to show on success | ||
$display_name = $entity->getDisplayName() ?: elgg_echo('entity:restore:item'); | ||
|
||
$type = $entity->getType(); | ||
$subtype = $entity->getSubtype(); | ||
$container = $entity->getContainerEntity(); | ||
|
||
$soft_deletable_entities = elgg_entity_types_with_capability('soft_deletable'); | ||
|
||
|
||
|
||
if ($entity->getSoftDeleted() === 'yes') { | ||
if (!$entity->restore($recursive)) { | ||
return elgg_error_response(elgg_echo('entity:restore:fail', [$display_name])); | ||
} | ||
} | ||
|
||
// determine forward URL | ||
$forward_url = get_input('forward_url'); | ||
if (!empty($forward_url)) { | ||
$forward_url = elgg_normalize_site_url((string) $forward_url); | ||
} | ||
|
||
if (empty($forward_url)) { | ||
$forward_url = REFERRER; | ||
$referrer_url = elgg_extract('HTTP_REFERER', $_SERVER, ''); | ||
$site_url = elgg_get_site_url(); | ||
|
||
$find_forward_url = function (\ElggEntity $container = null) use ($type, $subtype) { | ||
$routes = _elgg_services()->routes; | ||
|
||
// check if there is a collection route (eg. blog/owner/username) | ||
$route_name = false; | ||
if ($container instanceof \ElggUser) { | ||
$route_name = "collection:{$type}:{$subtype}:owner"; | ||
} elseif ($container instanceof \ElggGroup) { | ||
$route_name = "collection:{$type}:{$subtype}:group"; | ||
} | ||
|
||
if ($route_name && $routes->get($route_name)) { | ||
$params = $routes->resolveRouteParameters($route_name, $container); | ||
|
||
return elgg_generate_url($route_name, $params); | ||
} | ||
|
||
// no route found, fallback to container url | ||
if ($container instanceof \ElggEntity) { | ||
return $container->getURL(); | ||
} | ||
|
||
// no container | ||
return ''; | ||
}; | ||
|
||
if (!empty($referrer_url) && elgg_strpos($referrer_url, $site_url) === 0) { | ||
// referer is on current site | ||
$referrer_path = elgg_substr($referrer_url, elgg_strlen($site_url)); | ||
$segments = explode('/', $referrer_path); | ||
|
||
if (in_array($guid, $segments)) { | ||
// referrer URL contains a reference to the entity that will be deleted | ||
$forward_url = $find_forward_url($container); | ||
} | ||
} elseif ($container instanceof \ElggEntity) { | ||
$forward_url = $find_forward_url($container); | ||
} | ||
} | ||
|
||
$success_keys = [ | ||
"entity:restore:{$type}:{$subtype}:success", | ||
"entity:restore:{$type}:success", | ||
'entity:restore:success', | ||
]; | ||
|
||
$message = ''; | ||
if (get_input('show_success', true)) { | ||
foreach ($success_keys as $success_key) { | ||
if (elgg_language_key_exists($success_key)) { | ||
$message = elgg_echo($success_key, [$display_name]); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return elgg_ok_response('', $message, $forward_url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.