diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2006-07-18 14:18:00 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2006-07-18 14:18:00 +0000 |
| commit | d2d3d5e18f7273bd4a5f4b3ebf5150e1ee518536 (patch) | |
| tree | ee7b9634ff0ba24650c9f87a8e5805b9fc53ec64 /content_permissions_inc.php | |
| parent | 212fd1e9c1b71e88f6800553a8f64f3cc44cbe7c (diff) | |
| download | liberty-d2d3d5e18f7273bd4a5f4b3ebf5150e1ee518536.tar.gz liberty-d2d3d5e18f7273bd4a5f4b3ebf5150e1ee518536.tar.bz2 liberty-d2d3d5e18f7273bd4a5f4b3ebf5150e1ee518536.zip | |
try to clean up some of the obejct permission code - make it easy to assign object permissions using liberty/content_permissions_inc.php
Diffstat (limited to 'content_permissions_inc.php')
| -rw-r--r-- | content_permissions_inc.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/content_permissions_inc.php b/content_permissions_inc.php new file mode 100644 index 0000000..39891fa --- /dev/null +++ b/content_permissions_inc.php @@ -0,0 +1,59 @@ +<?php +if( !empty( $verify_permission ) ) { + $gBitSystem->verifyPermission( $verify_permission ); +} else { + $gBitSystem->verifyPermission( 'p_admin' ); +} + +// If we haven't got any content loaded yet, load it +if( empty( $gContent ) ) { + // make sure we have a content_id we can work with + if( empty( $_REQUEST["content_id"] ) || $_REQUEST["content_id"] < 1 ) { + $gBitSmarty->assign( 'msg', tra( "No valid content id given." ) ); + $gBitSystem->display( 'error.tpl' ); +die; + } + + $gContent = new LibertyContent(); + $gContent = $gContent->getLibertyObject( $_REQUEST['content_id'] ); +} +$gBitSmarty->assign_by_ref( 'gContent', $gContent ); + +// Process the form +// send the user to the content page if he wants to +if( !empty( $_REQUEST['back'] ) ) { + header( "Location: ".$gContent->getDisplayUrl() ); + die; +} + +// Update database if needed +if( !empty( $_REQUEST["group_id"] ) && !empty( $gContent->mContentId ) && !empty( $_REQUEST["perm"] ) ) { + if( isset( $_REQUEST["assign"] ) ) { + $gContent->storePermission( $_REQUEST["group_id"], $_REQUEST["perm"], $gContent->mContentId ); + } + + if( isset( $_REQUEST["action"] ) ) { + if( $_REQUEST["action"] == 'remove' ) { + $gContent->removePermission( $_REQUEST["group_id"], $_REQUEST["perm"] ); + } + } +} + +// Now we have to get the individual object permissions if any +$gContent->loadPermissions(); + +// Get a list of groups +$listHash = array( 'sort_mode' => 'group_name_asc' ); +$userGroups = $gBitUser->getAllGroups( $listHash ); +$gBitSmarty->assign_by_ref( 'userGroups', $userGroups["data"] ); + +// Get a list of permissions +if( empty( $assignPerms ) ) { + if( !empty( $gContent->mType['handler_package'] ) ) { + $assignPerms = $gBitUser->getGroupPermissions( NULL, $gContent->mType['handler_package'] ); + } else { + $assignPerms = $gBitUser->mPerms; + } +} +$gBitSmarty->assign_by_ref( 'assignPerms', $assignPerms ); +?> |
