Source for file content_role_permissions.php
Documentation is available at content_role_permissions.php
require_once( '../kernel/setup_inc.php' );
require_once( LIBERTY_PKG_PATH. 'lookup_content_inc.php' );
if( $gContent == null ) {
$gBitSystem->fatalError('Could not find the requested content.', NULL, NULL, HttpStatusCodes::HTTP_GONE );
// send the user to the content page if he wants to
if( !empty( $_REQUEST['back'] )) {
// Update database if needed
if( !empty( $_REQUEST['action'] ) && @BitBase::verifyId( $gContent->mContentId )) {
if( $_REQUEST["action"] == 'expunge' ) {
if( $gContent->expungeContentPermissions() ) {
$feedback['success'] = tra( 'The content permissions were successfully removed.' );
$feedback['error'] = tra( 'The content permissions were not removed.' );
if( @BitBase::verifyId( $_REQUEST["role_id"] ) && !empty( $_REQUEST["perm"] )) {
$gBitUser->verifyTicket( TRUE );
if( $_REQUEST["action"] == 'assign' ) {
$gContent->storePermission( $_REQUEST["role_id"], $_REQUEST["perm"] );
} elseif( $_REQUEST["action"] == 'negate' ) {
$gContent->storePermission( $_REQUEST["role_id"], $_REQUEST["perm"], TRUE );
} elseif( $_REQUEST["action"] == 'remove' ) {
$gContent->removePermission( $_REQUEST["role_id"], $_REQUEST["perm"] );
$listHash = array( 'sort_mode' => 'role_id_asc', 'visible' => 1 );
$contentPerms['roles'] = $gBitUser->getAllRoles( $listHash );
if( !empty( $gContent->mType['handler_package'] )) {
$contentPerms['assignable'] = $gBitUser->getRolePermissions( array( 'package' => $gContent->mType['handler_package'] ));
// this is a last resort and will dump all perms a user has
$contentPerms['assignable'] = $gBitUser->mPerms;
// Now we have to get the individual object permissions if any
if( $contentPerms['assigned'] = $gContent->getContentPermissionsList() ) {
// merge assigned permissions with rol permissions
foreach( array_keys( $contentPerms['roles'] ) as $roleId ) {
if( !empty( $contentPerms['assigned'][$roleId] )) {
$contentPerms['roles'][$roleId]['perms'] = array_merge( $contentPerms['roles'][$roleId]['perms'], $contentPerms['assigned'][$roleId] );
$gBitSmarty->assign( 'contentPerms', $contentPerms );
// if we've called this page as part of an ajax update, we output the appropriate data
if( $gBitThemes->isAjaxRequest() ) {
if( count( $contentPerms['roles'] <= 10 )) {
$gid = $_REQUEST['role_id'];
$perm = $_REQUEST['perm'];
// we're applying the same logic as in the template. if you fix / change anything here, please update the template as well.
'iname' => $size. 'media-playback-stop',
if( !empty( $contentPerms['roles'][$gid]['perms'][$perm] )) {
$biticon['iname'] = $size. 'dialog-ok';
if( !empty( $contentPerms['assigned'][$gid][$perm] )) {
$assigned = $contentPerms['assigned'][$gid][$perm];
$biticon['iname'] = $size. 'list-add';
if( !empty( $assigned['is_revoked'] )) {
$biticon['iname'] = $size. 'list-remove';
$gBitSmarty->loadPlugin( 'smarty_function_biticon' );
$ret = '<a title="'. $contentPerms['roles'][$gid]['role_name']. " :: ". $perm. '" '.
'href="javascript:void(0);" onclick="BitAjax.updater('.
"'action={$action}&content_id={$gContent->mContentId}&perm={ $perm}&role_id={ $gid}' ".
$gBitSystem->display( 'bitpackage:liberty/content_role_permissions.tpl', tra( 'Content Permissions' ), array( 'display_mode' => 'display' ));
|