diff options
| -rw-r--r-- | page_permissions.php | 103 | ||||
| -rw-r--r-- | templates/page_permissions.tpl | 107 |
2 files changed, 59 insertions, 151 deletions
diff --git a/page_permissions.php b/page_permissions.php index 7e22d70..233ee22 100644 --- a/page_permissions.php +++ b/page_permissions.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_wiki/Attic/page_permissions.php,v 1.7 2006/04/11 13:10:33 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_wiki/Attic/page_permissions.php,v 1.8 2006/07/18 14:18:01 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: page_permissions.php,v 1.7 2006/04/11 13:10:33 squareing Exp $ + * $Id: page_permissions.php,v 1.8 2006/07/18 14:18:01 squareing Exp $ * @package wiki * @subpackage functions */ @@ -23,79 +23,46 @@ include_once( KERNEL_PKG_PATH.'notification_lib.php' ); include_once( WIKI_PKG_PATH.'lookup_page_inc.php' ); include_once( WIKI_PKG_PATH.'page_setup_inc.php' ); - $gBitSystem->verifyPackage( 'wiki' ); - // Get the page from the request var or default it to HomePage - if( !$gContent->isValid() ) { - $gBitSmarty->assign('msg', tra("No page indicated")); - $gBitSystem->display( 'error.tpl' ); - die; - } - - // Let creator set permissions - if( $gBitSystem->isFeatureActive( 'wiki_creator_admin' ) && $gContent->isOwner() ) { - $gBitUser->setPreference( 'p_wiki_admin', TRUE ); - } +$gBitSystem->verifyPackage( 'wiki' ); - // Now check permissions to access this page - if (!$gBitUser->hasPermission( 'p_wiki_admin' )) { - $gBitSmarty->assign('msg', tra("Permission denied you cannot assign permissions for this page")); - $gBitSystem->display( 'error.tpl' ); - die; - } - if (isset($_REQUEST["addemail"])) { - - $notificationlib->add_mail_event('wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId, $_REQUEST["email"]); - } - if (isset($_REQUEST["removeemail"])) { - - $notificationlib->remove_mail_event('wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId, $_REQUEST["removeemail"]); - } - - $emails = $notificationlib->get_mail_events('wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId); - $gBitSmarty->assign('emails', $emails); +// Make sure $gContent is set +if( !$gContent->isValid() ) { + $gBitSmarty->assign('msg', tra( "No page indicated" ) ); + $gBitSystem->display( 'error.tpl' ); + die; +} -// Process the form to assign a new permission to this page -if (isset($_REQUEST["assign"])) { - $gBitUser->assign_object_permission($_REQUEST["group_id"], $gContent->mContentId, $gContent->mInfo['content_type_guid'], $_REQUEST["perm"]); +// Let creator set permissions +if( $gBitSystem->isFeatureActive( 'wiki_creator_admin' ) && $gContent->isOwner() ) { + $gBitUser->setPreference( 'p_wiki_admin', TRUE ); } -/* TODO: CURRENTLY CANNOT ADD PERMISSIONS TO NEW STYLE STRUCTURES -// Process the form to assign a new permission to this structure -if(isset($_REQUEST["assignstructure"])) { - $gBitUser->assign_object_permission($_REQUEST["group"],$gContent->mPageId,'wiki page',$_REQUEST["perm"]); - $pages=$structlib->get_structure_pages($gContent->mPageId); - foreach($pages as $subpage) { - $gBitUser->assign_object_permission($_REQUEST["group"],$subpage,'wiki page',$_REQUEST["perm"]); - } + +// Now check permissions to access this page +if( !$gBitUser->hasPermission( 'p_wiki_admin' ) ) { + $gBitSmarty->assign( 'msg', tra( "Permission denied you cannot assign permissions for this page" ) ); + $gBitSystem->display( 'error.tpl' ); + die; } -*/ -// Process the form to remove a permission from the page -if (isset($_REQUEST["action"])) { - if ($_REQUEST["action"] == 'remove') { - $gBitUser->remove_object_permission($_REQUEST["group_id"], $gContent->mContentId, $gContent->mInfo['content_type_guid'], $_REQUEST["perm"]); - } -/* TODO: CURRENTLY CANNOT ADD PERMISSIONS TO NEW STYLE STRUCTURES - if($_REQUEST["action"] == 'removestructure') { - $gBitUser->remove_object_permission($_REQUEST["group"],$gContent->mPageId,'wiki page',$_REQUEST["perm"]); - $pages=$structlib->get_structure_pages($gContent->mPageId); - foreach($pages as $subpage) { - $gBitUser->remove_object_permission($_REQUEST["group"],$subpage,'wiki page',$_REQUEST["perm"]); + +if( isset( $_REQUEST["addemail"] ) ) { + $notificationlib->add_mail_event( 'wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId, $_REQUEST["email"] ); +} +if( isset( $_REQUEST["removeemail"] ) ) { + $notificationlib->remove_mail_event( 'wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId, $_REQUEST["removeemail"] ); +} + +$emails = $notificationlib->get_mail_events( 'wiki_page_changes', $gContent->mInfo['content_type_guid'] . $gContent->mContentId ); +$gBitSmarty->assign( 'emails', $emails ); + +if( !$gBitUser->isAdmin() ) { + foreach( $gBitUser->mPerms as $key => $perm ) { + if( $perm['package'] == 'wiki' ) { + $assignPerms[$key] = $perm; } } -*/ } -// Now we have to get the individual page permissions if any -$page_perms = $gBitUser->get_object_permissions( $gContent->mContentId, $gContent->mInfo['content_type_guid'] ); -$gBitSmarty->assign_by_ref('page_perms', $page_perms); -// Get a list of groups -$listHash = array( 'sort_mode' => 'group_name_asc' ); -$groups = $gBitUser->getAllGroups( $listHash ); -$gBitSmarty->assign_by_ref('groups', $groups["data"]); -// Get a list of permissions -$perms = $gBitUser->getGroupPermissions( '', WIKI_PKG_NAME ); -$gBitSmarty->assign_by_ref('perms', $perms); - -$gBitSmarty->assign( (!empty( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : 'permissions').'TabSelect', 'tdefault' ); +require_once( LIBERTY_PKG_PATH.'content_permissions_inc.php' ); -$gBitSystem->display( 'bitpackage:wiki/page_permissions.tpl'); +$gBitSystem->display( 'bitpackage:wiki/page_permissions.tpl', tra( 'Page Permissions' ) ); ?> diff --git a/templates/page_permissions.tpl b/templates/page_permissions.tpl index 911b16e..661c301 100644 --- a/templates/page_permissions.tpl +++ b/templates/page_permissions.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_wiki/templates/page_permissions.tpl,v 1.5 2006/06/09 16:56:24 sylvieg Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_wiki/templates/page_permissions.tpl,v 1.6 2006/07/18 14:18:01 squareing Exp $ *} {strip} <div class="floaticon">{bithelp}</div> @@ -8,92 +8,33 @@ </div> <div class="body"> - {jstabs} - {jstab title="Permissions"} - {form legend="Assign permissions"} - <input type="hidden" name="page_id" value="{$gContent->mInfo.page_id}" /> + {form legend="Notify via email when updated"} + <input type="hidden" name="page_id" value="{$gContent->mInfo.page_id}" /> + <input type="hidden" name="tab" value="email" /> - <div class="row"> - {formlabel label="Group"} - {forminput} - <select name="group_id"> - {foreach from=$groups key=groupId item=group} - <option value="{$groupId}">{$group.group_name}</option> - {/foreach} - </select> - {formhelp note="Select the group that should be gived specific permissions."} - {/forminput} - </div> + <div class="row"> + {formlabel label="Email"} + {forminput} + <input type="text" name="email" size="35" /> + {formhelp note="Enter the email address where you want to have notifications sent, as soon as there are changes made to this page."} + {/forminput} + </div> - <div class="row"> - {formlabel label="Permission"} - {forminput} - <select name="perm"> - {foreach from=$perms key=permName item=perm} - <option value="{$permName}">{$perm.perm_desc}</option> - {/foreach} - </select> - {formhelp note="Select what permission you want to give the group."} - {/forminput} - </div> + <div class="row submit"> + <input type="submit" name="addemail" value="{tr}Add email address{/tr}" /> + </div> + {/form} - <div class="row submit"> - <input type="submit" name="assign" value="{tr}Assign permission{/tr}" /> - </div> - {/form} + {if count( $emails ) gt 0 } + <h2>{tr}Existing requests for email notification{/tr}</h2> + <ul> + {section name=ix loop=$emails} + <li>{$emails[ix]} <a href="{$smarty.const.WIKI_PKG_URL}page_permissions.php?page_id={$gContent->mInfo.page_id}&removeemail={$emails[ix]}&tab=email">{biticon ipackage=liberty iname="delete_small" iexplain="delete"}</a></li> + {/section} + </ul> + {/if} - <h2>{tr}Current permissions for{/tr} {$gContent->mInfo.title|escape}</h2> - <table class="data" summary="{tr}Table describing permissions for the page {$gContent->mInfo.title|escape}{/tr}"> - <tr> - <th scope="col">{tr}Group{/tr}</th> - <th scope="col">{tr}Permissions{/tr}</th> - <th scope="col">{tr}Actions{/tr}</th> - </tr> - {section name=pg loop=$page_perms} - <tr class="{cycle values="even,odd"}"> - <td>{$page_perms[pg].group_name}</td> - <td>{$page_perms[pg].perm_name}</td> - <td class="actionicon"><a href="{$smarty.const.WIKI_PKG_URL}page_permissions.php?action=remove&content_id={$gContent->mContentId}&object_type={$gContent->mInfo.content_type_guid}&perm={$page_perms[pg].perm_name}&group_id={$page_perms[pg].group_id}">{biticon ipackage=liberty iname="delete" iexplain="remove from this page"}</a></td> - </tr> - {sectionelse} - <tr class="norecords"> - <td colspan="3"> - {tr}No individual permissions set<br />global permissions apply{/tr} - </td> - </tr> - {/section} - </table> - {/jstab} - - {jstab title="Email Notifications"} - - {form legend="Notify via email when updated"} - <input type="hidden" name="page_id" value="{$gContent->mInfo.page_id}" /> - <input type="hidden" name="tab" value="email" /> - - <div class="row"> - {formlabel label="Email"} - {forminput} - <input type="text" name="email" size="35" /> - {formhelp note="Enter the email address where you want to have notifications sent, as soon as there are changes made to this page."} - {/forminput} - </div> - - <div class="row submit"> - <input type="submit" name="addemail" value="{tr}Add email address{/tr}" /> - </div> - {/form} - - {if count( $emails ) gt 0 } - <h2>{tr}Existing requests for email notification{/tr}</h2> - <ul> - {section name=ix loop=$emails} - <li>{$emails[ix]} <a href="{$smarty.const.WIKI_PKG_URL}page_permissions.php?page_id={$gContent->mInfo.page_id}&removeemail={$emails[ix]}&tab=email">{biticon ipackage=liberty iname="delete_small" iexplain="delete"}</a></li> - {/section} - </ul> - {/if} - {/jstab} - {/jstabs} + {include file="bitpackage:liberty/content_permissions_inc.tpl"} </div><!-- end .body --> </div><!-- end .wiki --> |
