summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pigeonholes.php51
-rw-r--r--edit_pigeonholes.php39
-rw-r--r--templates/edit_pigeonholes.tpl4
3 files changed, 57 insertions, 37 deletions
diff --git a/Pigeonholes.php b/Pigeonholes.php
index 41bf536..8e36763 100644
--- a/Pigeonholes.php
+++ b/Pigeonholes.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.94 2007/07/16 17:07:59 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.95 2007/08/04 18:27:42 squareing Exp $
*
* +----------------------------------------------------------------------+
* | Copyright ( c ) 2004, bitweaver.org
@@ -17,7 +17,7 @@
* Pigeonholes class
*
* @author xing <xing@synapse.plus.com>
- * @version $Revision: 1.94 $
+ * @version $Revision: 1.95 $
* @package pigeonholes
*/
@@ -372,7 +372,7 @@ class Pigeonholes extends LibertyAttachable {
/**
* Converts a structure path into valid html links
- * @param $pPath path given by getPigenholePath()
+ * @param $pPath path given by getPigeonholePath()
* @return the link to display the page.
*/
function getDisplayPath( $pPath ) {
@@ -523,7 +523,7 @@ class Pigeonholes extends LibertyAttachable {
**/
function checkPathPermissions( $pPath ) {
global $gBitUser, $gBitSystem;
- if( $gBitSystem->getConfig( 'pigeonholes_permissions' ) || $gBitSystem->getConfig( 'pigeonholes_groups' ) ) {
+ if( !empty( $pPath ) && is_array( $pPath )) {
foreach( $pPath as $path ) {
$contentIds[] = $path['content_id'];
}
@@ -928,24 +928,43 @@ function pigeonholes_pathlist_sorter( $aa, $ab ) {
function pigeonholes_content_display( &$pObject ) {
global $gBitSystem, $gBitSmarty, $gBitUser, $gBitThemes;
- if( $gBitSystem->isFeatureActive( 'pigeonholes_display_members' ) || $gBitSystem->isFeatureActive( 'pigeonholes_display_path' ) ) {
- $pigeonholes = new Pigeonholes();
- if( $gBitUser->hasPermission( 'p_pigeonholes_view' ) ) {
- if( $pigeons = $pigeonholes->getPigeonholesFromContentId( $pObject->mContentId ) ) {
- foreach( $pigeons as $pigeon ) {
+ $pigeonholes = new Pigeonholes();
+
+ // first we need to check permissions
+ if( $gBitSystem->isFeatureActive( 'pigeonhole_permissions' ) || $gBitSystem->isFeatureActive( 'pigeonholes_groups' )) {
+ if( $pigeons = $pigeonholes->getPigeonholesFromContentId( $pObject->mContentId )) {
+ foreach( $pigeons as $pigeon ) {
+ // we will loop through here until we get one pigeonhole that allows access
+ if( empty( $access_granted )) {
+ if( $pigeonholes->checkPathPermissions( $pigeonholes->getPigeonholePath( $pigeon['structure_id'] ))) {
+ $access_granted = TRUE;
+ } else {
+ $access_granted = FALSE;
+ }
+ }
+ }
+ }
+
+ // we need to check all pigeonholes in the path, load the prefs and work out if the user is allowed to view the page
+ if( isset( $access_granted ) && $access_granted === FALSE ) {
+ $msg = tra( "This content is part of a category to which you have no access to. Please log in or request the appropriate permission from the site administrator." );
+ $gBitSystem->fatalPermission( NULL, $msg );
+ }
+ }
+
+ if( $gBitSystem->isFeatureActive( 'pigeonholes_display_members' ) || $gBitSystem->isFeatureActive( 'pigeonholes_display_path' )) {
+ if( $gBitUser->hasPermission( 'p_pigeonholes_view' )) {
+ if( $pigeons = $pigeonholes->getPigeonholesFromContentId( $pObject->mContentId )) {
+ foreach( $pigeons as $key => $pigeon ) {
$pigeonholes->mContentId = $pigeon['content_id'];
$pigeonholes->load( TRUE, FALSE );
- //$pigeonholes->loadPreferences();
$pigeonData[] = $pigeonholes->mInfo;
+
// set the theme chosen for this page - virtually random if page is part of multiple themes
- if( $gBitSystem->isFeatureActive( 'pigeonholes_themes' ) ) {
+ if( $gBitSystem->isFeatureActive( 'pigeonholes_themes' )) {
+ // loadPreferences is called by getPreference if needed
$gBitThemes->setStyle( $pigeonholes->getPreference( 'style' ));
}
- // we need to check all pigeonholes in the path, load the prefs and work out if the user is allowed to view the page
- if( !$pigeonholes->checkPathPermissions( $pigeonholes->getField( 'path' ) ) ) {
- $msg = tra( "This content is part of a category to which you have no access to. Please log in or request the appropriate permission from the site administrator." );
- $gBitSystem->fatalPermission( NULL, $msg );
- }
}
$gBitSmarty->assign( 'pigeonData', !empty( $pigeonData ) ? $pigeonData : FALSE );
}
diff --git a/edit_pigeonholes.php b/edit_pigeonholes.php
index ae8a133..8d0755e 100644
--- a/edit_pigeonholes.php
+++ b/edit_pigeonholes.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_pigeonholes.php,v 1.27 2007/07/10 19:01:24 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_pigeonholes.php,v 1.28 2007/08/04 18:27:42 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: edit_pigeonholes.php,v 1.27 2007/07/10 19:01:24 squareing Exp $
+ * $Id: edit_pigeonholes.php,v 1.28 2007/08/04 18:27:42 squareing Exp $
* @package pigeonholes
* @subpackage functions
*/
@@ -39,10 +39,8 @@ if( !empty( $_REQUEST["structure_id"] ) && ( empty( $_REQUEST['action'] ) || $_R
global $gStructure;
// store the form if we need to
if( !empty( $_REQUEST['pigeonhole_store'] ) ) {
- if( ( empty( $_REQUEST['pigeonhole']['title'] ) ) ) {
- $gBitSmarty->assign( 'msg', tra( "You must specify a title." ) );
- $gBitSystem->display( 'error.tpl' );
- die;
+ if(( empty( $_REQUEST['pigeonhole']['title'] ))) {
+ $gBitSystem->fatalError( tra( "You must specify a title." ));
}
// we need to get the root structure id
@@ -51,13 +49,10 @@ if( !empty( $_REQUEST['pigeonhole_store'] ) ) {
$pigeonStore = new Pigeonholes();
$pigeonStore->mContentId = !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL;
$pigeonStore->load();
- if( $pigeonStore->store( $_REQUEST['pigeonhole'] ) ) {
+ if( $pigeonStore->store( $_REQUEST['pigeonhole'] )) {
header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$pigeonStore->mStructureId.( !empty( $_REQUEST['action'] ) ? '&action='.$_REQUEST['action'] : '' )."&success=".urlencode( tra( "The category was successfully stored" ) ) );
} else {
- vd( $gContent->mErrors );
- $gBitSmarty->assign( 'msg', tra( "There was a problem trying to store the pigeonhole." ) );
- $gBitSystem->display( 'error.tpl' );
- die;
+ $feedback['error'] = $gContent->mErrors;
}
}
@@ -75,10 +70,9 @@ if( !empty( $_REQUEST['action'] ) || isset( $_REQUEST["confirm"] ) ) {
if( $_REQUEST["action"] == 'remove' || isset( $_REQUEST["confirm"] ) ) {
if( isset( $_REQUEST["confirm"] ) ) {
if( $gContent->expunge( $_REQUEST["structure_id"] ) ) {
- header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$gContent->mInfo["parent_id"] );
- die;
+ bit_redirect( $_SERVER['PHP_SELF'].'?structure_id='.$gContent->mInfo["parent_id"] );
} else {
- vd( $gContent->mErrors );
+ $feedback['error'] = $gContent->mErrors;
}
}
$gBitSystem->setBrowserTitle( 'Confirm removal of '.$gContent->mInfo['title'] );
@@ -124,11 +118,17 @@ if ( $gBitSystem->isFeatureActive( 'pigeonholes_permissions' ) ) {
}
// get available groups ready that we can assign the pigoenhole to one of them
-$gBitUser->mGroups;
if ( $gBitSystem->isFeatureActive( 'pigeonholes_groups' ) ) {
- $groups[''] = tra( 'None' );
- foreach( $gBitUser->mGroups as $group_id => $group ) {
- $groups[$group_id] = $group['group_name'];
+ $listHash = array(
+ 'only_root_groups' => TRUE,
+ 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : 'group_name_asc'
+ );
+ $allGroups = $gBitUser->getAllGroups( $listHash );
+
+ // create a usable array for group selection
+ $groups[0] = tra( 'None' );
+ foreach( $allGroups as $group ) {
+ $groups[$group['group_id']] = $group['group_name'];
}
$gBitSmarty->assign( 'groups', $groups );
}
@@ -148,7 +148,8 @@ if ( $gBitSystem->isFeatureActive( 'pigeonholes_themes' ) ) {
$gBitSmarty->assign( 'styles', $styles );
}
-$gBitThemes->loadAjax( 'prototype' );
+// not sure what this is here for
+//$gBitThemes->loadAjax( 'prototype' );
// Display the template
if ( !empty( $gStructure ) ) {
diff --git a/templates/edit_pigeonholes.tpl b/templates/edit_pigeonholes.tpl
index 1cf79c0..ded6c5c 100644
--- a/templates/edit_pigeonholes.tpl
+++ b/templates/edit_pigeonholes.tpl
@@ -75,9 +75,9 @@
{if $gBitSystem->isFeatureActive( 'pigeonholes_groups' )}
<div class="row">
- {formlabel label="Group" for="group"}
+ {formlabel label="Group" for="group_id"}
{forminput}
- {html_options name="pigeonhole[prefs][group]" id="group" options=$groups selected=`$gContent->mPrefs.group_id`}
+ {html_options name="pigeonhole[prefs][group_id]" id="group_id" options=$groups selected=`$gContent->mPrefs.group_id`}
{formhelp note="Users of only this group can view the content of this category." warning="Setting is inherited from parent category."}
{/forminput}
</div>