Last active
August 29, 2015 13:58
-
-
Save imarklee/9988529 to your computer and use it in GitHub Desktop.
EasySocial Access Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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