Permalink
Browse files

deprecate(entities): deprecate can_write_to_container

In favor of `ElggEntity::canWriteToContainer()`
  • Loading branch information...
mrclay committed Apr 19, 2016
1 parent 1b29c97 commit ee473b371949b475e2cdafbbe53cb93965a22735
Showing with 5 additions and 28 deletions.
  1. +1 −0 docs/guides/upgrading.rst
  2. +4 −28 engine/lib/entities.php
@@ -19,6 +19,7 @@ Deprecated APIs
* ``elgg.ui.popupOpen()`` and ``elgg.ui.popupClose()`` methods in ``elgg.ui`` JS library: Use ``elgg/popup`` module instead.
* ``lightbox.js`` library: Do not use ``elgg_load_js('lightbox.js');`` unless your code references deprecated ``elgg.ui.lightbox`` namespace. Use ``elgg/lightbox`` AMD module instead.
* Accessing ``icons_sizes`` config value directly: Use ``elgg_get_icon_sizes()``
* ``can_write_to_container()``: Use ``ElggEntity::canWriteToContainer()``
Deprecated Views
----------------
View
@@ -271,43 +271,19 @@ function update_subtype($type, $subtype, $class = '') {
* @param string $subtype The subtype of the entity we want to create (default: 'all')
*
* @return bool
* @deprecated 2.2
*/
function can_write_to_container($user_guid = 0, $container_guid = 0, $type = 'all', $subtype = 'all') {
$container_guid = (int)$container_guid;
elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use ElggEntity::canWriteToContainer()', '2.2');
if (!$container_guid) {
$container_guid = elgg_get_page_owner_guid();
}
$container = get_entity($container_guid);
try {
$user = _elgg_services()->entityTable->getUserForPermissionsCheck($user_guid);
} catch (UserFetchFailureException $e) {
if (!$container) {
return false;
}
if ($user) {
$user_guid = $user->guid;
}
$return = false;
if ($container) {
// If the user can edit the container, they can also write to it
if ($container->canEdit($user_guid)) {
$return = true;
}
}
// See if anyone else has anything to say
return elgg_trigger_plugin_hook(
'container_permissions_check',
$type,
array(
'container' => $container,
'user' => $user,
'subtype' => $subtype
),
$return);
return $container->canWriteToContainer($user_guid, $type, $subtype);
}
/**

0 comments on commit ee473b3

Please sign in to comment.