Skip to content

Instantly share code, notes, and snippets.

@imarklee
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imarklee/9988529 to your computer and use it in GitHub Desktop.
Save imarklee/9988529 to your computer and use it in GitHub Desktop.
EasySocial Access Example
<?php
require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php');
// Retrieve current logged in user.
$my = Foundry::user();
// Retrieve @SocialAccess object
$access = $my->getAccess();
// To check if the user has permissions
if ($access->allowed('comments.delete')) {
// Do some super tasks here
}
// To check if the user exceeded certain limits
// Here you need to write own logics to compute how many items the user has already created.
$totalCreated = 10;
if ($access->exceeded('comments.create', $totalCreated)) {
// User did not exceed limits
}
// Shorthand for retrieving access
if ($my->getAccess()->allowed('comments.delete')) {
// Do something here
}
if ($my->getAccess()->exceeded('comments.create', $totalCreated)) {
// Do something here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment