summaryrefslogtreecommitdiff
path: root/content_permissions.php
diff options
context:
space:
mode:
Diffstat (limited to 'content_permissions.php')
-rw-r--r--content_permissions.php57
1 files changed, 54 insertions, 3 deletions
diff --git a/content_permissions.php b/content_permissions.php
index 3e60a9a..b694116 100644
--- a/content_permissions.php
+++ b/content_permissions.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @package liberty
* @subpackage functions
*/
@@ -9,7 +9,58 @@
* bit setup
*/
require_once( '../bit_setup_inc.php' );
-require_once( LIBERTY_PKG_PATH.'content_permissions_inc.php' );
-$gBitSystem->display( 'bitpackage:liberty/content_permissions.tpl', tra( 'Content Permissions' ) );
+$gBitSystem->verifyPermission( 'p_liberty_assign_content_perms' );
+
+// 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( @BitBase::verifyId( $_REQUEST["group_id"] ) && @BitBase::verifyId( $gContent->mContentId ) && !empty( $_REQUEST["perm"] ) && !empty( $_REQUEST['action'] )) {
+ $gBitUser->verifyTicket( TRUE );
+ if( $_REQUEST["action"] == 'assign' ) {
+ $gContent->storePermission( $_REQUEST["group_id"], $_REQUEST["perm"], $gContent->mContentId );
+ } elseif( $_REQUEST["action"] == 'remove' ) {
+ $gContent->removePermission( $_REQUEST["group_id"], $_REQUEST["perm"] );
+ }
+}
+
+// Now we have to get the individual object permissions if any
+$contentPerms['assigned'] = $gContent->loadAllObjectPermissions( $_REQUEST );
+
+// Get a list of groups
+$listHash = array( 'sort_mode' => 'group_name_asc' );
+$userGroups = $gBitUser->getAllGroups( $listHash );
+$contentPerms['groups'] = $userGroups["data"];
+
+// Get a list of permissions
+if( empty( $assignPerms )) {
+ if( !empty( $gContent->mType['handler_package'] )) {
+ $contentPerms['assignable'] = $gBitUser->getGroupPermissions( NULL, $gContent->mType['handler_package'] );
+ } else {
+ // this is a last resort and will dump all perms a user has
+ $contentPerms['assignable'] = $gBitUser->mPerms;
+ }
+}
+$gBitSmarty->assign( 'contentPerms', $contentPerms );
+
+$gBitSystem->display( 'bitpackage:liberty/content_permissions.tpl', tra( 'Content Permissions' ));
?>