diff options
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/classes/ElggEntity.php | 10 | ||||
| -rw-r--r-- | engine/lib/entities.php | 16 | 
2 files changed, 13 insertions, 13 deletions
| diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index ef38bee6b..66aca035e 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -651,14 +651,16 @@ abstract class ElggEntity extends ElggData implements  	}  	/** -	 * Can a user write to this entity's container. +	 * Can a user write to this entity  	 *  	 * @param int $user_guid The user. -	 * +	 * @param string $type The type of entity we're looking to write  + 	 * @param string $subtype The subtype of the entity we're looking to write + 	 *   	 * @return bool  	 */ -	public function canWriteToContainer($user_guid = 0) { -		return can_write_to_container($user_guid, $this->getGUID()); +	public function canWriteToContainer($user_guid = 0, $type = 'all', $subtype = 'all') { +		return can_write_to_container($user_guid, $this->guid, $type, $subtype);  	}  	/** diff --git a/engine/lib/entities.php b/engine/lib/entities.php index d497fe466..5a5643da4 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -444,9 +444,7 @@ function update_entity($guid, $owner_guid, $access_id, $container_guid = null) {   * @return bool   * @link http://docs.elgg.org/DataModel/Containers   */ -function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_type = 'all') { -	global $CONFIG; - +function can_write_to_container($user_guid = 0, $container_guid = 0, $type = 'all', $subtype = 'all') {  	$user_guid = (int)$user_guid;  	$user = get_entity($user_guid);  	if (!$user) { @@ -482,8 +480,8 @@ function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_typ  	}  	// See if anyone else has anything to say -	return trigger_plugin_hook('container_permissions_check', $entity_type, -		array('container' => $container, 'user' => $user), $return); +	return trigger_plugin_hook('container_permissions_check', $type, +		array('container' => $container, 'user' => $user, 'subtype' => $subtype), $return);  }  /** @@ -515,7 +513,7 @@ $container_guid = 0) {  	global $CONFIG;  	$type = sanitise_string($type); -	$subtype = add_subtype($type, $subtype); +	$subtype_id = add_subtype($type, $subtype);  	$owner_guid = (int)$owner_guid;  	$access_id = (int)$access_id;  	$time = time(); @@ -528,11 +526,11 @@ $container_guid = 0) {  	}  	$user = get_loggedin_user(); -	if (!can_write_to_container($user->guid, $owner_guid, $type)) { +	if (!can_write_to_container($user->guid, $owner_guid, $type, $subtype)) {  		return false;  	}  	if ($owner_guid != $container_guid) { -		if (!can_write_to_container($user->guid, $container_guid, $type)) { +		if (!can_write_to_container($user->guid, $container_guid, $type, $subtype)) {  			return false;  		}  	} @@ -544,7 +542,7 @@ $container_guid = 0) {  		(type, subtype, owner_guid, site_guid, container_guid,  			access_id, time_created, time_updated, last_action)  		values -		('$type',$subtype, $owner_guid, $site_guid, $container_guid, +		('$type',$subtype_id, $owner_guid, $site_guid, $container_guid,  			$access_id, $time, $time, $time)");  } | 
