From 7f7d658ddf04bad83f17867d1e4d952e9446a1f3 Mon Sep 17 00:00:00 2001 From: Nick Palmer Date: Mon, 5 Mar 2007 02:19:54 +0000 Subject: Fix issues with assign content I broke before. Add forbid insert feature. Fix bug with insert when there are no checks on the page. Need to add better security on insert still but the interface doesn't offer it now. --- Pigeonholes.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'Pigeonholes.php') diff --git a/Pigeonholes.php b/Pigeonholes.php index 797b4fe..450afe2 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ - * @version $Revision: 1.81 $ + * @version $Revision: 1.82 $ * @package pigeonholes */ @@ -260,9 +260,21 @@ class Pigeonholes extends LibertyContent { * @TODO We need to sort the returned values that successive pigoenholes are grouped together. */ function getPigeonholesPathList( $pContentId=NULL, $pTruncate = FALSE ) { + global $gBitSystem; + $where = $join = ''; + + if ($gBitSystem->isFeatureActive('pigeonholes_allow_forbid_insertion')) { + $where .= empty( $where ) ? ' WHERE ' : ' AND '; + $where .= ' lcp.`pref_value` IS NULL OR lcp.`pref_value` != \'on\' '; + $join .= ' LEFT JOIN `'.BIT_DB_PREFIX.'liberty_content_prefs` lcp ON (pig.`content_id` = lcp.`content_id` AND lcp.`pref_name` = \'no_insert\') '; + } + + $query = "SELECT pig.`content_id`, pig.`structure_id` FROM `".BIT_DB_PREFIX."pigeonholes` pig INNER JOIN `".BIT_DB_PREFIX."liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` ) + $join + $where ORDER BY ls.`root_structure_id`, ls.`structure_id` ASC"; $result = $this->mDb->query( $query ); $pigeonholes = $result->getRows(); @@ -379,7 +391,7 @@ class Pigeonholes extends LibertyContent { LibertyContent::prepGetList( $pListHash ); $ret = $bindVars = array(); - $where = $order = $join = ''; + $where = $order = $join = $select = ''; if( @BitBase::verifyId( $pListHash['root_structure_id'] ) ) { $where .= empty( $where ) ? ' WHERE ' : ' AND '; @@ -404,6 +416,13 @@ class Pigeonholes extends LibertyContent { $bindVars[] = $pListHash['title']; } + if ($gBitSystem->isFeatureActive('pigeonholes_allow_forbid_insertion') && !empty( $pListHash['insertable'] ) ) { + $where .= empty( $where ) ? ' WHERE ' : ' AND '; + $where .= ' lcp.`pref_value` IS NULL OR lcp.`pref_value` != \'on\' '; + $join .= ' LEFT JOIN `'.BIT_DB_PREFIX.'liberty_content_prefs` lcp ON (lc.`content_id` = lcp.`content_id` AND lcp.`pref_name` = \'no_insert\') '; + $select .= ' , lcp.`pref_value` as no_insert '; + } + if( isset( $pListHash['parent_id'] ) ) { $where .= empty( $where ) ? ' WHERE ' : ' AND '; $where .= ' ls.`parent_id` = ? '; @@ -430,7 +449,7 @@ class Pigeonholes extends LibertyContent { $query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`, lc.`user_id`, lc.`content_type_guid`, uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, - uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name + uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name $select FROM `".BIT_DB_PREFIX."pigeonholes` pig INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON ( lc.`content_id` = pig.`content_id` ) LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` ) @@ -650,6 +669,10 @@ class Pigeonholes extends LibertyContent { } // individual pigeonhole preference store + global $gBitSystem; + if( $gBitSystem->isFeatureActive('pigeonholes_allow_forbid_insertion') && empty( $pParamHash['prefs']['no_insert'] ) ) { + $pParamHash['prefs']['no_insert'] = '0'; + } $pParamHash['preferences_store'] = !empty( $pParamHash['prefs'] ) ? $pParamHash['prefs'] : NULL; // structure store -- cgit v1.3