Skip to content

Instantly share code, notes, and snippets.

@cash
Created June 24, 2013 03:35
Show Gist options
  • Save cash/5847607 to your computer and use it in GitHub Desktop.
Save cash/5847607 to your computer and use it in GitHub Desktop.
An idea for a simpler API for access
<?php
/**
* Can the user create this content?
*
* @param string $type
* @param string $subtype
* @param ElggEntity $container The container for the new content (null = logged in user)
* @param ElggUser $owner The owner of the new content (null = logged in user)
* @param ElggUser $user The user we're asking permission for (null = logged in user)
* @return bool
*/
function elgg_can_create($type, $subtype, $container = null, $owner = null, $user = null) {
// figure out default answer and then trigger plugin hook
// how does this relate to $container->canWriteToContainer()?
}
/**
* Can user edit this content?
*
* @param ElggEntity $entity The entity to be edited
* @param ElggUser $user The user we're asking permission for (null = logged in user)
*/
function elgg_can_edit($entity, $user = null) {
// wrapper for $entity->canEdit()
}
/**
* Can user delete this content?
*
* @param ElggEntity $entity The entity to be deleted
* @param ElggUser $user The user we're asking permission for (null = logged in user)
*/
function elgg_can_delete($entity, $user = null) {
// wrapper for $entity->canDelete()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment