aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-24 09:56:16 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-24 09:56:16 +0000
commitfb7050beab5a676e6a1071502dab16ae4104d37e (patch)
tree3bf1167df0839a508d771a159c687d4727763b92 /engine/lib/entities.php
parentb7873357beebe405d3df679fc5dba86ea9660acd (diff)
downloadelgg-fb7050beab5a676e6a1071502dab16ae4104d37e.tar.gz
elgg-fb7050beab5a676e6a1071502dab16ae4104d37e.tar.bz2
Improvements for container overrides.
git-svn-id: https://code.elgg.org/elgg/trunk@2302 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index ba376917b..92ef5a84e 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -458,9 +458,9 @@
* @param int $user_guid The user.
* @return bool
*/
- public function canWriteToContainer($user_guid = 0)
+ public function canWriteToContainer($user_guid = 0, $entity = null)
{
- return can_write_to_container($user_guid, $this->getGUID());
+ return can_write_to_container($user_guid, $this->getGUID(), 'all', $entity);
}
/**
@@ -1160,9 +1160,11 @@
* Determine whether a given user is able to write to a given container.
*
* @param int $user_guid The user guid, or 0 for $_SESSION['user']->getGUID()
- * @param int $container_guid The container, or 0 for the current page owner.
+ * @param int $container_guid The container, or 0 for the current page owner.
+ * @param string $entity_type The type of entity, or all for all
+ * @param ElggEntity $entity Optionally, the entity
*/
- function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_type = 'all')
+ function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_type = 'all', $entity = null)
{
global $CONFIG;
@@ -1192,7 +1194,7 @@
}
// See if anyone else has anything to say
- return trigger_plugin_hook('container_permissions_check',$entity_type,array('container' => $container, 'user' => $user), false);
+ return trigger_plugin_hook('container_permissions_check',$entity_type,array('container' => $container, 'user' => $user, 'entity' => $entity), false);
}
@@ -1222,8 +1224,18 @@
$site_guid = $CONFIG->site_guid;
$site_guid = (int) $site_guid;
if ($container_guid == 0) $container_guid = $owner_guid;
-
- if (!can_write_to_container($owner_guid, $container_guid, $type)) return false;
+
+ $temptity = new ElggEntity();
+ $temptity->type = $type;
+ $temptity->subtype = $subtype;
+ $temptity->owner_guid = $owner_guid;
+ $temptity->access_id = $access_id;
+ $temptity->site_guid = $site_guid;
+ $temptity->container_guid = $container_guid;
+ $temptity->time_created = $time;
+ $temptity->time_updated = $time;
+
+ if (!can_write_to_container($owner_guid, $container_guid, $type, $temptity)) return false;
if ($type=="") throw new InvalidParameterException(elgg_echo('InvalidParameterException:EntityTypeNotSet'));