From bd3da2b27d914f8e8bdf3b58b662dee3b62217c8 Mon Sep 17 00:00:00 2001 From: Max Kremmel Date: Wed, 8 Feb 2006 21:51:14 +0000 Subject: php: introduce new method: getPref( $package, $pref, $defaut ) (order is open for discussion tpl: $gBitPref.package.pref applied package name to all saves - should make database more organised and should allow more reliable uninstalls in the future --- Pigeonholes.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'Pigeonholes.php') diff --git a/Pigeonholes.php b/Pigeonholes.php index 02914ab..5a2abf9 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ - * @version $Revision: 1.40 $ + * @version $Revision: 1.41 $ * @package pigeonholes */ @@ -402,17 +402,19 @@ class Pigeonholes extends LibertyAttachable { * @return a nicely grouped set of pigeonhole members in a set of columns and starting letters. * @access public **/ - function checkPathPermissions( &$pPath ) { + function checkPathPermissions( $pPath ) { global $gBitUser; - foreach( $pPath as $key => $path ) { - // load preferences for this node, if it's not loaded yet - if( empty( $path['preferences'] ) ) { - $pPath[$key]['preferences'] = $this->loadPreferences( $path['content_id'] ); - } - $group_id = !empty( $pPath[$key]['preferences']['group_id'] ) ? $pPath[$key]['preferences']['group_id'] : NULL; - $permission = !empty( $pPath[$key]['preferences']['permission'] ) ? $pPath[$key]['preferences']['permission'] : NULL; - if( ( !empty( $group_id ) && !$gBitUser->isInGroup( $group_id ) ) || ( !empty( $permission ) && !$gBitUser->hasPermission( $permission ) ) ) { - return FALSE; + foreach( $pPath as $path ) { + $contentIds[] = $path['content_id']; + } + if( !empty( $contentIds ) ) { + $query = "SELECT `name`, `value` FROM `".BIT_DB_PREFIX."liberty_content_prefs` WHERE `content_id` IN( ".preg_replace( "/,$/", "", str_repeat( "?,", count( $contentIds ) ) )." ) "; + $result = $this->mDb->query( $query, $contentIds ); + while( $aux = $result->fetchRow() ) { + ${$aux['name']} = $aux['value']; + if( ( !empty( $group_id ) && !$gBitUser->isInGroup( $group_id ) ) || ( !empty( $permission ) && !$gBitUser->hasPermission( $permission ) ) ) { + return FALSE; + } } } return TRUE; -- cgit v1.3