summaryrefslogtreecommitdiff
path: root/includes/classes/Pigeonholes.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/classes/Pigeonholes.php')
-rwxr-xr-x[-rw-r--r--]includes/classes/Pigeonholes.php408
1 files changed, 193 insertions, 215 deletions
diff --git a/includes/classes/Pigeonholes.php b/includes/classes/Pigeonholes.php
index 558fca9..a267b91 100644..100755
--- a/includes/classes/Pigeonholes.php
+++ b/includes/classes/Pigeonholes.php
@@ -24,8 +24,12 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyMime.php' );
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php' );
+namespace Bitweaver\Pigeonholes;
+use Bitweaver\BitBase;
+use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\Liberty\LibertyMime;
+use Bitweaver\Liberty\LibertyStructure;
+use Bitweaver\Users\RoleUser;
/**
* Pigeonholes
@@ -38,10 +42,12 @@ class Pigeonholes extends LibertyMime {
* @param $pContentId content id of the pigeonhole - use either one of the ids.
* @param $pStructureId structure id of the pigeonhole - use either one of the ids.
* @param $pMembersList hash with optional values to tweak the getMemberList loading sql. Used keys are Order, Select, Join and Where.
- * @return none
- * @access public
+ * @return void
**/
- function Pigeonholes( $pStructureId=NULL, $pContentId=NULL, $pMemberList=Null ) {
+
+ public $mMemberList;
+
+ public function __construct( $pStructureId=null, $pContentId=null, $pMemberList=Null ) {
parent::__construct();
$this->registerContentType( PIGEONHOLES_CONTENT_TYPE_GUID, array(
'content_type_guid' => PIGEONHOLES_CONTENT_TYPE_GUID,
@@ -70,14 +76,13 @@ class Pigeonholes extends LibertyMime {
/**
* load the pigeonhole
* @param $pExtras boolean - if set to true, pigeonhole content is added as well
- * @return bool TRUE on success, FALSE if it's not valid
- * @access public
+ * @return bool true on success, false if it's not valid
**/
- function load( $pExtras=FALSE, $pLoadAttachable=TRUE ) {
- if( @BitBase::verifyId( $this->mContentId ) || @BitBase::verifyId( $this->mStructureId ) ) {
+ public function load( $pExtras=false, $pLoadAttachable=true ) {
+ if( BitBase::verifyId( $this->mContentId ) || BitBase::verifyId( $this->mStructureId ) ) {
global $gBitSystem;
- $lookupColumn = ( @BitBase::verifyId( $this->mContentId ) ? 'lc.`content_id`' : 'ls.`structure_id`' );
- $lookupId = ( @BitBase::verifyId( $this->mContentId ) ? $this->mContentId : $this->mStructureId );
+ $lookupColumn = BitBase::verifyId( $this->mContentId ) ? 'lc.`content_id`' : 'ls.`structure_id`';
+ $lookupId = BitBase::verifyId( $this->mContentId ) ? $this->mContentId : $this->mStructureId;
$query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`,
lc.`user_id`, lc.`content_type_guid`, lc.`format_guid`,
uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,
@@ -95,9 +100,9 @@ class Pigeonholes extends LibertyMime {
$this->mContentId = $row['content_id'];
$this->mStructureId = $row['structure_id'];
$this->mInfo['user'] = $row['creator_user'];
- $this->mInfo['real_name'] = ( isset( $row['creator_real_name'] ) ? $row['creator_real_name'] : $row['creator_user'] );
- $this->mInfo['display_name'] = BitUser::getTitleFromHash( $this->mInfo );
- $this->mInfo['editor'] = ( isset( $row['modifier_real_name'] ) ? $row['modifier_real_name'] : $row['modifier_user'] );
+ $this->mInfo['real_name'] = isset( $row['creator_real_name'] ) ? $row['creator_real_name'] : $row['creator_user'];
+ $this->mInfo['display_name'] = RoleUser::getTitleFromHash( $this->mInfo );
+ $this->mInfo['editor'] = isset( $row['modifier_real_name'] ) ? $row['modifier_real_name'] : $row['modifier_user'];
$this->mInfo['display_link'] = $this->getDisplayLink();
$this->mInfo['display_url'] = $this->getDisplayUrl();
$this->parseData();
@@ -116,25 +121,24 @@ class Pigeonholes extends LibertyMime {
$this->mInfo['members_count'] = count( $this->mInfo['members'] );
}
}
- return( count( $this->mInfo ) );
+ return count( $this->mInfo );
}
/**
* get all content inserted in a given pigeonhole. if no id is given, it gets all content for all pigeonholes
* @param $pContentId content id of the pigeonhole
* @return array of pigeonhole members with according title and content type guid
- * @access public
**/
- function getMemberList( &$pListHash ) {
+ public function getMemberList( &$pListHash ) {
global $gBitUser, $gLibertySystem, $gBitSystem;
- $ret = FALSE;
+ $ret = false;
LibertyContent::prepGetList( $pListHash );
$select = $where = $join = '';
- $bindVars = array();
- if( @BitBase::verifyId( $this->mContentId ) || @BitBase::verifyId( $pListHash['content_id'] ) ) {
+ $bindVars = [];
+ if( BitBase::verifyId( $this->mContentId ?? 0 ) || BitBase::verifyId( $pListHash['content_id'] ?? 0 ) ) {
$where = " WHERE pig.`content_id` = ? ";
- $bindVars[] = @BitBase::verifyId( $pListHash['content_id'] ) ? $pListHash['content_id'] : $this->mContentId;
+ $bindVars[] = BitBase::verifyId( $pListHash['content_id'] ?? 0 ) ? $pListHash['content_id'] : $this->mContentId;
}
if( !empty( $pListHash['content_type_guid'] ) ) {
@@ -171,7 +175,7 @@ class Pigeonholes extends LibertyMime {
}
- $ret = array();
+ $ret = [];
$query = "
SELECT pigm.*,
lc.`content_id`, lc.`last_modified`, lc.`user_id`, lc.`title`, lc.`content_type_guid`, lc.`created`,
@@ -186,7 +190,7 @@ class Pigeonholes extends LibertyMime {
LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_attachments` latt ON ( latt.`content_id` = lc.`content_id` AND latt.`is_primary` = 'y' )
LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_files` lf ON ( lf.`file_id` = latt.`foreign_id` )
$join $where $order";
- $result = $this->mDb->query( $query, $bindVars, @BitBase::verifyId( $pListHash['max_records'] ) ? $pListHash['max_records'] : NULL, @BitBase::verifyId( $pListHash['offset'] ) ? $pListHash['offset'] : NULL );
+ $result = $this->mDb->query( $query, $bindVars, BitBase::verifyId( $pListHash['max_records'] ?? 0 ) ? $pListHash['max_records'] : null, BitBase::verifyId( $pListHash['offset'] ?? 0 ) ? $pListHash['offset'] : null );
$contentTypes = $gLibertySystem->mContentTypes;
while( $aux = $result->fetchRow() ) {
if( !empty( $contentTypes[$aux['content_type_guid']] ) ) {
@@ -199,7 +203,7 @@ class Pigeonholes extends LibertyMime {
$aux['display_url'] = $type['content_object']->getDisplayUrlFromHash( $aux );
$aux['display_link'] = $type['content_object']->getDisplayLink( $aux );
$aux['title'] = $type['content_object']->getTitleFromHash( $aux );
- // needs updating to bw3 $aux['thumbnail_url'] = liberty_fetch_thumbnails( array());
+ // needs updating to bw3 $aux['thumbnail_url'] = liberty_fetch_thumbnails( []);
$ret[] = $aux;
}
}
@@ -221,29 +225,28 @@ class Pigeonholes extends LibertyMime {
LibertyContent::postGetList($pListHash);
- return( !empty( $this->mErrors ) ? $this->mErrors : $ret );
+ return !empty( $this->mErrors ) ? $this->mErrors : $ret;
}
/**
* get all items that are not part of a pigeonhole yet
* @return array of content not in any pigeonhole yet
- * @access public
**/
- function getAssignableContent( &$pListHash ) {
+ public function getAssignableContent( &$pListHash ) {
global $gBitUser, $gLibertySystem, $gBitSystem;
$where = '';
- $bindVars = array();
+ $bindVars = [];
LibertyContent::prepGetList( $pListHash );
if( empty( $pListHash['include_members'] ) ) {
- $where .= "WHERE pigm.`content_id` IS NULL";
+ $where .= "WHERE pigm.`content_id` IS null";
}
if( !empty( $pListHash['find'] ) && is_string( $pListHash['find'] ) ) {
$where .= empty( $where ) ? ' WHERE ' : ' AND ';
$where .= " UPPER( lc.`title` ) LIKE ?";
- $bindVars[] = ( '%'.strtoupper( $pListHash['find'] ).'%');
+ $bindVars[] = '%'.strtoupper( $pListHash['find'].'%');
}
if( !empty( $pListHash['content_type'] ) ) {
@@ -267,7 +270,7 @@ class Pigeonholes extends LibertyMime {
LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pigm ON ( pigm.`content_id` = lc.`content_id` )
LEFT JOIN `".BIT_DB_PREFIX."users_users` uu ON ( uu.`user_id` = lc.`user_id` )
$where $order";
- $result = $this->mDb->query( $query, $bindVars, @BitBase::verifyId( $pListHash['max_records'] ) ? $pListHash['max_records'] : NULL , $pListHash['offset']);
+ $result = $this->mDb->query( $query, $bindVars, BitBase::verifyId( $pListHash['max_records'] ?? 0 ) ? $pListHash['max_records'] : null , $pListHash['offset']);
$query = "SELECT COUNT(lc.`content_id`)
FROM `".BIT_DB_PREFIX."liberty_content` lc
@@ -284,7 +287,7 @@ class Pigeonholes extends LibertyMime {
$type = &$contentTypes[$row['content_type_guid']];
if( empty( $type['content_object'] ) ) {
// create *one* object for each object *type* to call virtual methods.
- include_once( $gBitSystem->mPackages[$type['handler_package']]['path'].$type['handler_file'] );
+ include_once $gBitSystem->mPackages[$type['handler_package']]['path'].$type['handler_file'];
$type['content_object'] = new $type['handler_class']();
}
$ret[$i]['display_link'] = $type['content_object']->getDisplayLink( $row['title'], $row );
@@ -292,7 +295,7 @@ class Pigeonholes extends LibertyMime {
}
// generate a map of what items are assigned to what pigeonholes
- if( !empty( $pListHash['include_members'] ) && @BitBase::verifyId( $row['parent_id'] ) ) {
+ if( !empty( $pListHash['include_members'] ) && BitBase::verifyId( $row['parent_id'] ) ) {
$map[$i][] = $row['parent_id'];
}
}
@@ -300,31 +303,30 @@ class Pigeonholes extends LibertyMime {
// complete the output
if( !empty( $pListHash['include_members'] ) && !empty( $ret ) ) {
foreach( $ret as $i => $r ) {
- $ret[$i]['assigned'] = !empty( $map[$i] ) ? $map[$i] : NULL;
+ $ret[$i]['assigned'] = !empty( $map[$i] ) ? $map[$i] : null;
}
}
LibertyContent::postGetList( $pListHash );
- return( !empty( $ret ) ? $ret : NULL );
+ return !empty( $ret ) ? $ret : null;
}
/**
* get an array of paths for all pigeonholes. used for pages where data can be inserted into pigeonholes
*
- * @param numeric $pContentId content id of pigeonhole.
- * @param numeric $pTruncate Setting this to a number will do some smart truncations depending on how many parents there are
+ * @param int $pContentId content id of pigeonhole.
+ * @param int $pTruncate Setting this to a number will do some smart truncations depending on how many parents there are
* setting it to 60 will allow 30 chars for all parents combined and 30 for the actual title
- * @access public
- * @return TRUE on success, FALSE if there is no pigeonhole
+ * @return array|null if there is no pigeonhole
* @TODO We need to sort the returned values that successive pigoenholes are grouped together.
*/
- function getPigeonholesPathList( $pContentId=NULL, $pTruncate = FALSE, $pShowAll = FALSE ) {
+ public function getPigeonholesPathList( $pContentId=null, $pTruncate = false, $pShowAll = false ) {
global $gBitSystem;
$where = $join = '';
if( $gBitSystem->isFeatureActive( 'pigeonholes_allow_forbid_insertion' ) && !$pShowAll ) {
$where .= empty( $where ) ? ' WHERE ' : ' AND ';
- $where .= ' lcp.`pref_value` IS NULL OR lcp.`pref_value` != \'on\' ';
+ $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\') ';
}
@@ -362,46 +364,44 @@ class Pigeonholes extends LibertyMime {
// sort the pathlist to make the display nicer
uasort( $ret, 'pigeonholes_pathlist_sorter' );
- if( @BitBase::verifyId( $pContentId ) && $assigned = $this->getPigeonholesFromContentId( $pContentId ) ) {
+ if( BitBase::verifyId( $pContentId ) && $assigned = $this->getPigeonholesFromContentId( $pContentId ) ) {
foreach( $assigned as $a ) {
- $ret[$a['content_id']][0]['selected'] = TRUE;
+ $ret[$a['content_id']][0]['selected'] = true;
}
}
}
- return( !empty( $ret ) ? $ret : array() );
+ return !empty( $ret ) ? $ret : null;
}
/**
* get all pigeonholes where the contenent has been inserted
- * @param $pContentId content id of item in question
- * @return basic information about item requested
- * @access public
+ * @param int $pContentId content id of item in question
+ * @return array|null basic information about item requested
**/
- function getPigeonholesFromContentId( $pContentId ) {
- if( @BitBase::verifyId( $pContentId ) ) {
+ public function getPigeonholesFromContentId( $pContentId ) {
+ if( BitBase::verifyId( $pContentId ) ) {
$query = "SELECT ls.*
FROM `".BIT_DB_PREFIX."pigeonhole_members` pigm
INNER JOIN `".BIT_DB_PREFIX."pigeonholes` pig ON ( pig.`content_id` = pigm.`parent_id` )
INNER JOIN `".BIT_DB_PREFIX."liberty_structures` ls ON ( pig.`structure_id` = ls.`structure_id` )
WHERE pigm.`content_id`=?";
- $ret = $this->mDb->getAll( $query, array( $pContentId ) );
+ $ret = $this->mDb->getAll( $query, [ $pContentId ] );
}
- return( !empty( $ret ) ? $ret : FALSE );
+ return !empty( $ret ) ? $ret : null;
}
/**
* get the path of a pigeonhole
- * @param $pStructureId structure id of pigeonhole, if no id is given, it gets the id from $this->mStructureId
- * @return path in form of an array
- * @access public
+ * @param int|null $pStructureId structure id of pigeonhole, if no id is given, it gets the id from $this->mStructureId
+ * @return array|null path in form of an array
**/
- function getPigeonholePath( $pStructureId=NULL ) {
- if( !@BitBase::verifyId( $pStructureId ) ) {
+ public function getPigeonholePath( $pStructureId = null ) {
+ if( !BitBase::verifyId( $pStructureId ) ) {
$pStructureId = $this->mStructureId;
}
- if( @BitBase::verifyId( $pStructureId ) ) {
+ if( BitBase::verifyId( $pStructureId ) ) {
global $gStructure;
// create new object if needed
if( empty( $gStructure ) ) {
@@ -410,21 +410,21 @@ class Pigeonholes extends LibertyMime {
// get the structure path
$ret = $gStructure->getPath( $pStructureId );
}
- return( !empty( $ret ) ? $ret : FALSE );
+ return !empty( $ret ) ? $ret : null;
}
/**
* Converts a structure path into valid html links
* @param $pPath path given by getPigeonholePath()
- * @return the link to display the page.
+ * @return string the link to display the page.
*/
- function getDisplayPath( $pPath ) {
+ public function getDisplayPath( $pPath ) {
global $gBitSystem;
$ret = '';
if( !empty( $pPath ) && is_array( $pPath ) ) {
foreach( $pPath as $node ) {
$title = htmlspecialchars( $node['title'] );
- $ret .= ( @BitBase::verifyId( $node['parent_id'] ) ? '&nbsp;&raquo;&nbsp;' : '' ).'<a title="'.$title.'" href="'.$this->getDisplayUrlFromHash( $node ).'">'.preg_replace('/ /','&nbsp;',$title).'</a>';
+ $ret .= ( BitBase::verifyId( $node['parent_id'] ) ? '&nbsp;&raquo;&nbsp;' : '' ).'<a title="'.$title.'" href="'.$this->getDisplayUrlFromHash( $node ).'">'.preg_replace('/ /','&nbsp;',$title).'</a>';
}
}
@@ -432,29 +432,28 @@ class Pigeonholes extends LibertyMime {
}
/**
- * get list of all pigeonholes
- * @param $pListHash contains array of items used to limit search results
- * @param $pListHash[sort_mode] column and orientation by which search results are sorted
- * @param $pListHash[find] search for a pigeonhole title - case insensitive
- * @param $pListHash[max_records] maximum number of rows to return
- * @param $pListHash[offset] number of results data is offset by
- * @param $pListHash[title] pigeonhole name
- * @param $pListHash[parent_id] pigeonhole parent_id, optional
- * @param $pListHash[root_structure_id] only load the pigoenhole this root_structure_id is part of
- * @param $pListHash[load_only_root] only load top most items
- * @param $pListHash[parent_content_id] all the sons of the pigeonhole parent content_id , optional
- * @param $pListHash[load_also_root] if parent_content_id is set load also the father, optionnal
- * @return array of pigeonholes in 'data' and count of pigeonholes in 'cant'
- * @access public
+ * get list of all pigeonholes
+ * @param $pListHash contains array of items used to limit search results
+ * @var string [sort_mode] column and orientation by which search results are sorted
+ * @var string [find] search for a pigeonhole title - case insensitive
+ * @var int [max_records] maximum number of rows to return
+ * @var int [offset] number of results data is offset by
+ * @var string [title] pigeonhole name
+ * @var int [parent_id] pigeonhole parent_id, optional
+ * @var int [root_structure_id] only load the pigoenhole this root_structure_id is part of
+ * @var bool [load_only_root] only load top most items
+ * @var int [parent_content_id] all the sons of the pigeonhole parent content_id , optional
+ * @var bool [load_also_root] if parent_content_id is set load also the father, optional
+ * @return array of pigeonholes in 'data' and count of pigeonholes in 'cant'
**/
- function getList( &$pListHash ) {
+ public function getList( &$pListHash ) {
global $gBitSystem, $gBitUser, $gBitDbType;
LibertyContent::prepGetList( $pListHash );
- $ret = $bindVars = array();
+ $ret = $bindVars = [];
$where = $order = $join = $select = '';
- if( @BitBase::verifyId( $pListHash['root_structure_id'] ) ) {
+ if( BitBase::verifyId( $pListHash['root_structure_id'] ?? 0 ) ) {
$where .= empty( $where ) ? ' WHERE ' : ' AND ';
$where .= " ls.`root_structure_id`=? ";
$bindVars[] = $pListHash['root_structure_id'];
@@ -479,7 +478,7 @@ class Pigeonholes extends LibertyMime {
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\' ';
+ $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 ';
}
@@ -534,9 +533,9 @@ class Pigeonholes extends LibertyMime {
while( $aux = $result->fetchRow() ) {
//$content_ids[] = $aux['content_id'];
$aux['user'] = $aux['creator_user'];
- $aux['real_name'] = ( isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'] );
- $aux['display_name'] = BitUser::getDisplayNameFromHash( FALSE, $aux );
- $aux['editor'] = ( isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'] );
+ $aux['real_name'] = isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'];
+ $aux['display_name'] = RoleUser::getDisplayNameFromHash( $aux );
+ $aux['editor'] = isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'];
$aux['display_link'] = Pigeonholes::getDisplayLink( $aux['title'], $aux );
// get member count for mysql - haha
if( $gBitDbType == 'mysql' ) {
@@ -551,14 +550,14 @@ class Pigeonholes extends LibertyMime {
$aux['path'] = $this->getPigeonholePath( $aux['structure_id'] );
$aux['display_path'] = Pigeonholes::getDisplayPath( $aux['path'] );
// Move all the members data into the right place
- $memberListHash = array (
+ $memberListHash = [
'content_id' => $aux['content_id'],
- 'content_type_guid' => !empty( $pListHash['content_type_guid'] ) ? $pListHash['content_type_guid'] : NULL,
- 'max_records' => !empty( $pListHash['members_max_records'] ) ? $pListHash['members_max_records'] : NULL,
- 'list_page' => !empty( $pListHash['members_list_page'] ) ? $pListHash['members_list_page'] : NULL,
- 'sort_mode' => !empty( $pListHash['members_sort_mode'] ) ? $pListHash['members_sort_mode'] : NULL,
- 'find' => !empty( $pListHash['members_find'] ) ? $pListHash['members_find'] : NULL,
- );
+ 'content_type_guid' => !empty( $pListHash['content_type_guid'] ) ? $pListHash['content_type_guid'] : null,
+ 'max_records' => !empty( $pListHash['members_max_records'] ) ? $pListHash['members_max_records'] : null,
+ 'list_page' => !empty( $pListHash['members_list_page'] ) ? $pListHash['members_list_page'] : null,
+ 'sort_mode' => !empty( $pListHash['members_sort_mode'] ) ? $pListHash['members_sort_mode'] : null,
+ 'find' => !empty( $pListHash['members_find'] ) ? $pListHash['members_find'] : null,
+ ];
$aux['members'] = $this->getMemberList( $memberListHash );
$aux['listInfo'] = $memberListHash['listInfo'];
@@ -586,10 +585,9 @@ class Pigeonholes extends LibertyMime {
/**
* Check permissions of all nodes that lead to this
- * @return a nicely grouped set of pigeonhole members in a set of columns and starting letters.
- * @access public
+ * @return bool a nicely grouped set of pigeonhole members in a set of columns and starting letters.
**/
- function checkPathPermissions( $pPath ) {
+ public function checkPathPermissions( $pPath ) {
global $gBitUser, $gBitSystem;
if( !empty( $pPath ) && is_array( $pPath )) {
foreach( $pPath as $path ) {
@@ -599,22 +597,21 @@ class Pigeonholes extends LibertyMime {
$query = "SELECT `pref_name`, `pref_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['pref_name']} = $aux['pref_value'];
+ $aux['pref_name'] = $aux['pref_value'];
if( ( !empty( $group_id ) && !$gBitUser->isInGroup( $group_id ) ) || ( !empty( $permission ) && !$gBitUser->hasPermission( $permission ) ) ) {
- return FALSE;
+ return false;
}
}
}
}
- return TRUE;
+ return true;
}
/**
* Alphabetise all member items
- * @return a nicely grouped set of pigeonhole members in a set of columns and starting letters.
- * @access public
+ * @return void array a nicely grouped set of pigeonhole members in a set of columns and starting letters.
**/
- function alphabetiseMembers( &$pMememberHash ) {
+ public function alphabetiseMembers( &$pMememberHash ) {
global $gBitSystem;
if( !empty( $pMememberHash ) ) {
usort( $pMememberHash, "pigeonholes_alphabetiser" );
@@ -636,17 +633,16 @@ class Pigeonholes extends LibertyMime {
}
/**
- * Store pigeonhole data
- * @param $pParamHash contains all data to store the pigeonholes
- * @param $pParamHash[title] title of the new pigeonhole
- * @param $pParamHash[edit] description of the pigeonhole
- * @param $pParamHash[members] array of content_ids that are associated with this pigeonhole
- * @param $pParamHash[root_structure_id] if this is set, it will add the pigeonhole to this structure. if it's not set, a new structure / top level pigeonhole is created
- * @param $pParamHash[parent_id] set the structure_id that will server as the parent in the structure
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
- * @access public
+ * Store pigeonhole data
+ * @param $pParamHash contains all data to store the pigeonholes
+ * @var string [title] title of the new pigeonhole
+ * @var string [edit] description of the pigeonhole
+ * @var array [members] array of content_ids that are associated with this pigeonhole
+ * @var int [root_structure_id] if this is set, it will add the pigeonhole to this structure. if it's not set, a new structure / top level pigeonhole is created
+ * @var int [parent_id] set the structure_id that will server as the parent in the structure
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
**/
- function store( &$pParamHash ) {
+ public function store( array &$pParamHash): bool {
$this->mDb->StartTrans();
if( $this->verify( $pParamHash ) && LibertyMime::store( $pParamHash ) ) {
$table = BIT_DB_PREFIX."pigeonholes";
@@ -689,19 +685,19 @@ class Pigeonholes extends LibertyMime {
$this->mDb->CompleteTrans();
$this->load();
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* verify, clean up and prepare data to be stored
* @param $pParamHash all information that is being stored. will update $pParamHash by reference with fixed array of itmes
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
* @access private
**/
- function verify( &$pParamHash ) {
+ public function verify( array &$pParamHash ): bool {
// make sure we're all loaded up if everything is valid
if( $this->isValid() && empty( $this->mInfo ) ) {
- $this->load( TRUE );
+ $this->load( true );
}
// It is possible a derived class set this to something different
@@ -709,22 +705,22 @@ class Pigeonholes extends LibertyMime {
$pParamHash['content_type_guid'] = $this->mContentTypeGuid;
}
- if( @BitBase::verifyId( $this->mContentId ) ) {
+ if( BitBase::verifyId( $this->mContentId ) ) {
$pParamHash['content_id'] = $this->mContentId;
- $pParamHash['update'] = TRUE;
+ $pParamHash['update'] = true;
}
// content store
// check for name issues, first truncate length if too long
if( !empty( $pParamHash['title'] ) ) {
- if( !@BitBase::verifyId( $this->mContentId ) ) {
+ if( !BitBase::verifyId( $this->mContentId ) ) {
if( empty( $pParamHash['title'] ) ) {
$this->mErrors['title'] = 'You must enter a name for this category.';
} else {
$pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, 160 );
}
} else {
- $pParamHash['content_store']['title'] = ( isset( $pParamHash['title'] ) ) ? substr( $pParamHash['title'], 0, 160 ) : $this->mInfo['title'];
+ $pParamHash['content_store']['title'] = isset( $pParamHash['title'] ) ? substr( $pParamHash['title'], 0, 160 ) : $this->mInfo['title'];
}
} elseif( empty( $pParamHash['title'] ) ) {
// no name specified
@@ -757,22 +753,22 @@ class Pigeonholes extends LibertyMime {
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;
+ $pParamHash['preferences_store'] = !empty( $pParamHash['prefs'] ) ? $pParamHash['prefs'] : null;
// structure store
- if( @BitBase::verifyId( $pParamHash['root_structure_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['root_structure_id'] ?? 0 ) ) {
$pParamHash['structure_store']['root_structure_id'] = $pParamHash['root_structure_id'];
} else {
- $pParamHash['structure_store']['root_structure_id'] = NULL;
+ $pParamHash['structure_store']['root_structure_id'] = null;
}
- if( @BitBase::verifyId( $pParamHash['parent_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['parent_id'] ?? 0 ) ) {
$pParamHash['structure_store']['parent_id'] = $pParamHash['parent_id'];
} else {
- $pParamHash['structure_store']['parent_id'] = NULL;
+ $pParamHash['structure_store']['parent_id'] = null;
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
@@ -780,10 +776,9 @@ class Pigeonholes extends LibertyMime {
* @param $pParamHash an array of content to be stored.
* @param $pParamHash[parent_id] id of pigeonhole it belongs to, default is $this->mContentId
* @param $pParamHash[content_id] content_id of the item to be stored
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
- * @access public
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
**/
- function insertPigeonholeMember( &$pParamHash ) {
+ public function insertPigeonholeMember( &$pParamHash ) {
if( $this->verifyPigeonholeMember( $pParamHash ) ) {
foreach( $pParamHash['member_store'] as $item ) {
$result = $this->mDb->associateInsert( BIT_DB_PREFIX."pigeonhole_members", $item );
@@ -791,28 +786,28 @@ class Pigeonholes extends LibertyMime {
} else {
error_log( "Error inserting pigeonhole: " . vc($this->mErrors));
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* verify, clean up and prepare data to be stored
* @param $pParamHash all information that is being stored. will update $pParamHash by reference with fixed array of itmes
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
* @access private
**/
- function verifyPigeonholeMember( &$pParamHash ) {
+ public function verifyPigeonholeMember( &$pParamHash ) {
$this->mDb->StartTrans();
foreach( $pParamHash as $key => $item ) {
- if( isset( $item['parent_id'] ) && @BitBase::verifyId( $item['parent_id'] ) ) {
+ if( isset( $item['parent_id'] ) && BitBase::verifyId( $item['parent_id'] ) ) {
$tmp['member_store'][$key]['parent_id'] = $item['parent_id'];
- } elseif( @BitBase::verifyId( $this->mContentId ) ) {
+ } elseif( BitBase::verifyId( $this->mContentId ) ) {
$tmp['member_store'][$key]['parent_id'] = $this->mContentId;
$pParamHash[$key]['parent_id'] = $this->mContentId;
} else {
$this->mErrors['store_members'] = tra( 'The content could not be inserted because the parent_id was missing.' );
}
- if( isset( $item['content_id'] ) && @BitBase::verifyId( $item['content_id'] ) ) {
+ if( isset( $item['content_id'] ) && BitBase::verifyId( $item['content_id'] ) ) {
$tmp['member_store'][$key]['content_id'] = $item['content_id'];
} else {
$this->mErrors['store_members'] = 'The content id is not valid.';
@@ -821,7 +816,7 @@ class Pigeonholes extends LibertyMime {
$this->mDb->CompleteTrans();
$pParamHash = $tmp;
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
@@ -830,20 +825,19 @@ class Pigeonholes extends LibertyMime {
* @param $pParamHash['member_id'] content_id of content to be deleted
* @param $pParamHash['deletables'] array of content_ids to check against when deleting. makes sure that only members of a given structure are removed
* Note if only one of the 2 ids is given, all items with that id will be removed. if both are given, only that one particular entry is removed
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
- * @access public
+ * @return bool true on success, false if store could not occur. If false, $this->mErrors will have reason why
**/
- function expungePigeonholeMember( $pParamHash ) {
- if( @BitBase::verifyId( $pParamHash['parent_id'] ) || @BitBase::verifyId( $pParamHash['member_id'] ) ) {
+ public function expungePigeonholeMember( $pParamHash ) {
+ if( BitBase::verifyId( $pParamHash['parent_id'] ) || BitBase::verifyId( $pParamHash['member_id'] ?? 0 ) ) {
$where = '';
- $bindVars = array();
+ $bindVars = [];
- if( @BitBase::verifyId( $pParamHash['parent_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['parent_id'] ?? 0 ) ) {
$where .= " WHERE `parent_id`=? ";
$bindVars[] = $pParamHash['parent_id'];
}
- if( @BitBase::verifyId( $pParamHash['member_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['member_id'] ?? 0 ) ) {
$where .= ( empty( $where ) ? " WHERE " : " AND " )." `content_id`=? ";
$bindVars[] = $pParamHash['member_id'];
}
@@ -860,26 +854,22 @@ class Pigeonholes extends LibertyMime {
} else {
$this->mErrors['members_store'] = 'The category member(s) could not be removed.';
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* Expunge currently loaded pigeonhole
- * @return bool TRUE on success, FALSE if store could not occur.
- * @access public
+ * @return void
**/
- function expunge( $pStructureId = NULL ) {
- $ret = FALSE;
+ public function expunge(): bool {
// if we have a custom structure id we want to remove, load it
- if( @BitBase::verifyId( $pStructureId ) ) {
- $this->mStructureId = $pStructureId;
+ if( BitBase::verifyId( $this->mStructureId ) ) {
$this->load();
}
if( $this->isValid() ) {
$this->mDb->StartTrans();
// get all items that are part of the sub tree
- require_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php' );
$struct = new LibertyStructure();
// include the current structure id as well
@@ -907,7 +897,7 @@ class Pigeonholes extends LibertyMime {
// remove all entries from content tables
$this->mContentId = $id['content_id'];
if( LibertyMime::expunge() ) {
- $ret = TRUE;
+ $ret = true;
$this->mDb->CompleteTrans();
} else {
$this->mDb->RollbackTrans();
@@ -915,27 +905,25 @@ class Pigeonholes extends LibertyMime {
}
// finally nuke the structure in liberty_structures
- $struct->removeStructureNode( $this->mStructureId, FALSE );
+ $struct->removeStructureNode( $this->mStructureId, false );
}
- return $ret;
+ return true;
}
/**
* Generates the URL to this pigeonhole
- * @param $pContentId is the pigeonhole id we want to see
- * @return the link to display the page.
+ * @param array $pParamHash is the pigeonhole id we want to see
+ * @return string the link to display the page.
*/
public static function getDisplayUrlFromHash( &$pParamHash ) {
global $gBitSystem;
- $ret = NULL;
+ $ret = null;
- if( @BitBase::verifyId( $$pParamHash['content_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['content_id'] ) ) {
$rewrite_tag = $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ? 'view/' : '';
- if( $gBitSystem->isFeatureActive( 'pretty_urls' ) || $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
- $ret = PIGEONHOLES_PKG_URL.$rewrite_tag.$pContentId;
- }else{
- $ret = PIGEONHOLES_PKG_URL.'view.php?content_id='.$pContentId;
- }
+ $ret = $gBitSystem->isFeatureActive( 'pretty_urls' ) || $gBitSystem->isFeatureActive( 'pretty_urls_extended' )
+ ? PIGEONHOLES_PKG_URL.$rewrite_tag.$pParamHash['content_id']
+ : PIGEONHOLES_PKG_URL.'view.php?content_id='.$pParamHash['content_id'];
}
return $ret;
@@ -943,11 +931,12 @@ class Pigeonholes extends LibertyMime {
/**
* Returns HTML link to display a pigeonhole
- * @param $pTitle is the pigeonhole we want to see
- * @param $pContentId content id of the pigeonhole in question
- * @return the link to display the page.
+ * @param string $pLinkText is the pigeonhole we want to see
+ * @param array $pMixed content id of the pigeonhole in question
+ * @param $pAnchor
+ * @return string the link to display the page.
*/
- function getDisplayLink( $pLinkText = NULL, $pMixed = NULL, $pAnchor = NULL ) {
+ public function getDisplayLink( $pLinkText = null, $pMixed = null, $pAnchor = null ) {
global $gBitSystem;
if( empty( $pLinkText ) && !empty( $this ) ) {
$ppLinkText = $this->getTitle();
@@ -972,12 +961,11 @@ class Pigeonholes extends LibertyMime {
*
* @param array $pContentId of the pigoenhole
* @param array $pStructureId of the pigeonhole
- * @access public
* @return array of child pigeonholes on success, empty array on failure
*/
- function getSubPigeonholes( $pContentId = NULL, $pStructureId = NULL ) {
+ public function getSubPigeonholes( $pContentId = null, $pStructureId = null ) {
global $gStructure;
- $ret = array();
+ $ret = [];
if( empty( $gStructure )) {
$struct = new LibertyStructure();
@@ -985,12 +973,12 @@ class Pigeonholes extends LibertyMime {
$struct = &$gStructure;
}
- if( @BitBase::verifyId( $pContentId ) && !@BitBase::verifyId( $pStructureId )) {
- $pigeon = $struct->getNode( NULL, $pContentId );
+ if( BitBase::verifyId( $pContentId ) && !BitBase::verifyId( $pStructureId )) {
+ $pigeon = $struct->getNode( null, $pContentId );
$pStructureId = $pigeon['structure_id'];
}
- if( @BitBase::verifyId( $pStructureId )) {
+ if( BitBase::verifyId( $pStructureId )) {
$tree = $struct->getSubTree( $pStructureId );
// weed out duplicates
@@ -1031,7 +1019,7 @@ function pigeonholes_pathlist_sorter( $aa, $ab ) {
*
* @param array $pObject
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return bool true on success, false on failure - mErrors will contain reason for failure
*/
function pigeonholes_content_display( &$pObject ) {
global $gBitSystem, $gBitSmarty, $gBitUser, $gBitThemes;
@@ -1043,19 +1031,15 @@ function pigeonholes_content_display( &$pObject ) {
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;
- }
+ $access_granted = $pigeonholes->checkPathPermissions( $pigeonholes->getPigeonholePath( $pigeon['structure_id'] ) ) ? true : 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 ) {
+ 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 );
+ $gBitSystem->fatalPermission( null, $msg );
}
}
@@ -1064,7 +1048,7 @@ function pigeonholes_content_display( &$pObject ) {
if( $pigeons = $pigeonholes->getPigeonholesFromContentId( $pObject->mContentId )) {
foreach( $pigeons as $key => $pigeon ) {
$pigeonholes->mContentId = $pigeon['content_id'];
- $pigeonholes->load( TRUE, FALSE );
+ $pigeonholes->load( true, false );
$pigeonData[] = $pigeonholes->mInfo;
// set the theme chosen for this page - virtually random if page is part of multiple themes
@@ -1073,7 +1057,7 @@ function pigeonholes_content_display( &$pObject ) {
$gBitThemes->setStyle( $pigeonholes->getPreference( 'style' ));
}
}
- $gBitSmarty->assign( 'pigeonData', !empty( $pigeonData ) ? $pigeonData : FALSE );
+ $gBitSmarty->assign( 'pigeonData', !empty( $pigeonData ) ? $pigeonData : false );
}
}
}
@@ -1084,25 +1068,25 @@ function pigeonholes_content_display( &$pObject ) {
*
* @param array $pObject
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return bool true on success, false on failure - mErrors will contain reason for failure
*/
-function pigeonholes_content_edit( $pObject=NULL ) {
+function pigeonholes_content_edit( $pObject=null ) {
global $gBitSmarty, $gBitUser, $gBitSystem;
- $pigeonPathList = array();
+ $pigeonPathList = [];
if( is_object($pObject) && isset($pObject->mContentTypeGuid) &&
!$gBitSystem->isFeatureActive('pigeonhole_no_'.$pObject->mContentTypeGuid) &&
$gBitUser->hasPermission( 'p_pigeonholes_insert_member' ) ) {
$pigeonholes = new Pigeonholes();
- $gBitSmarty->assign('editPigeonholesEnabled', TRUE);
+ $gBitSmarty->assign('editPigeonholesEnabled', true);
// get pigeonholes path list
- if( $pigeonPathList = $pigeonholes->getPigeonholesPathList(( !empty( $pObject->mContentId ) ? $pObject->mContentId : NULL ), ( $gBitSystem->isFeatureActive( 'pigeonholes_use_jstab' ) ? FALSE : 100 ))) {
+ if( $pigeonPathList = $pigeonholes->getPigeonholesPathList(!empty( $pObject->mContentId ) ? $pObject->mContentId : null, $gBitSystem->isFeatureActive( 'pigeonholes_use_jstab' ) ? false : 100 )) {
$gBitSmarty->assign( 'pigeonPathList', $pigeonPathList );
}
} else {
- $gBitSmarty->assign('editPigeonholesEnabled', FALSE);
+ $gBitSmarty->assign('editPigeonholesEnabled', false);
}
}
@@ -1111,22 +1095,21 @@ function pigeonholes_content_edit( $pObject=NULL ) {
*
* @param array $pObject
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return bool true on success, false on failure - mErrors will contain reason for failure
*/
-function pigeonholes_content_expunge( $pObject=NULL ) {
+function pigeonholes_content_expunge( $pObject=null ) {
$pigeonholes = new Pigeonholes();
- $pigeonholes->expungePigeonholeMember( array( 'member_id' => $pObject->mContentId ) );
+ $pigeonholes->expungePigeonholeMember( [ 'member_id' => $pObject->mContentId ] );
}
/**
* pigeonholes_content_preview
*
- * @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
-function pigeonholes_content_preview( $pObject=NULL, $pParamHash ) {
+function pigeonholes_content_preview( $pObject=null, $pParamHash ) {
global $gBitSmarty, $gBitUser, $gBitSystem;
- $pigeonPathList = array();
+ $pigeonPathList = [];
if( is_object($pObject) && isset($pObject->mContentTypeGuid) &&
!$gBitSystem->isFeatureActive('pigeonhole_no_'.$pObject->mContentTypeGuid) &&
@@ -1136,11 +1119,7 @@ function pigeonholes_content_preview( $pObject=NULL, $pParamHash ) {
// get pigeonholes path list
if( $pigeonPathList = $pigeonholes->getPigeonholesPathList() ) {
foreach( $pigeonPathList as $key => $path ) {
- if( !empty( $pParamHash['pigeonholes']['pigeonhole'] ) && in_array( $key, $pParamHash['pigeonholes']['pigeonhole'] ) ) {
- $pigeonPathList[$key][0]['selected'] = TRUE;
- } else {
- $pigeonPathList[$key][0]['selected'] = FALSE;
- }
+ $pigeonPathList[$key][0]['selected'] = !empty( $pParamHash['pigeonholes']['pigeonhole'] ) && in_array( $key, $pParamHash['pigeonholes']['pigeonhole'] ) ? true : false;
}
$gBitSmarty->assign( 'pigeonPathList', $pigeonPathList );
}
@@ -1153,7 +1132,7 @@ function pigeonholes_content_preview( $pObject=NULL, $pParamHash ) {
* @param array $pObject
* @param array $pParamHash
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
function pigeonholes_content_store( $pObject, $pParamHash ) {
global $gBitSmarty, $gBitUser, $gBitSystem;
@@ -1172,7 +1151,7 @@ function pigeonholes_content_store( $pObject, $pParamHash ) {
// here we need to work out if we need to save at all
// get all originally selected items
- $selectedItem = array();
+ $selectedItem = [];
if( !empty( $pigeonPathList ) ) {
foreach( $pigeonPathList as $path ) {
if( !empty( $path[0]['selected'] ) ) {
@@ -1184,30 +1163,30 @@ function pigeonholes_content_store( $pObject, $pParamHash ) {
// quick and dirty check to start off with
if( empty( $pParamHash['pigeonholes'] ) || count( $pParamHash['pigeonholes']['pigeonhole'] ) != count( $selectedItem ) ) {
- $modified = TRUE;
+ $modified = true;
} else {
// more thorough check
foreach( $selectedItem as $item ) {
if( !in_array( $item, $pParamHash['pigeonholes']['pigeonhole'] ) ) {
- $modified = TRUE;
+ $modified = true;
}
}
}
if( !empty( $modified ) ) {
// first remove all entries with this content_id
- if( $pigeonholes->expungePigeonholeMember( array( 'member_id' => $pParamHash['content_id'] ) ) && !empty( $pParamHash['pigeonholes'] ) ) {
+ if( $pigeonholes->expungePigeonholeMember( [ 'member_id' => $pParamHash['content_id'] ] ) && !empty( $pParamHash['pigeonholes'] ) ) {
// insert the content into the desired pigeonholes
foreach( $pParamHash['pigeonholes']['pigeonhole'] as $p_id ) {
- $memberHash[] = array(
+ $memberHash[] = [
'parent_id' => $p_id,
'content_id' => $pParamHash['content_id']
- );
+ ];
}
if( !$pigeonholes->insertPigeonholeMember( $memberHash ) ) {
$gBitSmarty->assign( 'msg', tra( "There was a problem inserting the content into the pigeonholes." ) );
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ] );
die;
}
}
@@ -1224,7 +1203,7 @@ function pigeonholes_content_store( $pObject, $pParamHash ) {
* @access public
* @return void
*/
-function pigeonholes_content_list( &$pObject, $pParamHash = NULL ) {
+function pigeonholes_content_list( &$pObject, $pParamHash = null ) {
global $gBitSystem, $gBitSmarty;
if( $gBitSystem->isFeatureActive( 'pigeonholes_list_filter' )) {
$pigeonholes = new Pigeonholes();
@@ -1232,10 +1211,10 @@ function pigeonholes_content_list( &$pObject, $pParamHash = NULL ) {
'sort_mode' => array(
'root_structure_id_asc', 'title_asc'
),
- 'insertable' => TRUE,
+ 'insertable' => true,
);
$pigeonList = $pigeonholes->getList( $listHash );
- $list = array();
+ $list = [];
foreach( $pigeonList as $pigeon ) {
$list[$pigeon['content_id']] = $pigeon['display_link'];
}
@@ -1247,12 +1226,12 @@ function pigeonholes_content_list( &$pObject, $pParamHash = NULL ) {
* filter the search with pigeonholes
* @param $pParamHash['pigeonholes']['filter'] - a pigeonhole or an array of pigeonhole content_id
**/
-function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) {
+function pigeonholes_content_list_sql( &$pObject, $pParamHash = null ) {
global $gBitSystem;
- $ret = array();
+ $ret = [];
if( !empty( $pParamHash['pigeonholes']['no_filter'] )) {
- $pParamHash['pigeonholes']['filter'] = array();
+ $pParamHash['pigeonholes']['filter'] = [];
} else {
if( !empty( $pParamHash['pigeonholes']['filter'] )) {
$pParamHash['liberty_categories'] = $pParamHash['pigeonholes']['filter'];
@@ -1266,7 +1245,7 @@ function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) {
// if we want to allow items in subcategories, we get those and include them in the query
if( !empty( $pParamHash['pigeonholes']['sub_holes'] )) {
$pigeonholes = new Pigeonholes();
- $contentIds = array();
+ $contentIds = [];
foreach( $pParamHash['liberty_categories'] as $pigeonhole ) {
$pigeons = $pigeonholes->getSubPigeonholes( $pigeonhole );
$contentIds = array_merge( $contentIds, array_keys( $pigeons ));
@@ -1293,7 +1272,7 @@ function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) {
// if we want to allow items in subcategories, we get those and include them in the query
if( !empty( $pParamHash['pigeonholes']['root_sub_holes'] )) {
$pigeonholes = new Pigeonholes();
- $contentIds = array();
+ $contentIds = [];
foreach( $pParamHash['liberty_root_categories'] as $pigeonhole ) {
$pigeons = $pigeonholes->getSubPigeonholes( $pigeonhole );
$contentIds = array_merge( $contentIds, array_keys( $pigeons ));
@@ -1310,5 +1289,4 @@ function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) {
}
return $ret;
-}
-?>
+} \ No newline at end of file