/** * 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 **/ function getList(&$pListHash) { global $gBitSystem, $gBitUser, $gBitDbType; LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $where = $order = $join = $select = ''; if (@BitBase::verifyId($pListHash['root_structure_id'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " ls.`root_structure_id`=? "; $bindVars[] = $pListHash['root_structure_id']; } if (!empty($pListHash['load_only_root'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " ls.`structure_id`=ls.`root_structure_id` "; } if (!empty($pListHash['find'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " UPPER( lc.`title` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } if (!empty($pListHash['title'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' lc.`title` = ?'; $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` = ? '; $bindVars[] = $pListHash['parent_id']; } if (!empty($pListHash['parent_content_id'])) { $join .= 'INNER JOIN `' . BIT_DB_PREFIX . 'liberty_structures` lsf ON (ls.`parent_id` = lsf.`structure_id`'; if (!empty($pListHash['load_also_root'])) { $join .= ' OR ls.`structure_id`= lsf.`structure_id`'; } $join .= ')'; $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' lsf.`content_id` = ? '; $bindVars[] = $pListHash['parent_content_id']; } if (!empty($pListHash['sort_mode'])) { $order .= " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } else { // default sort mode makes list look nice $order .= " ORDER BY ls.`root_structure_id`, ls.`structure_id` ASC"; } // only use subselect for old crappy mysql if ($gBitDbType != 'mysql') { $subselect = ", (\n\t\t\t\tSELECT COUNT( pm.`content_id` )\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm\n\t\t\t\tWHERE pm.`parent_id`=pig.`content_id`\n\t\t\t) AS members_count"; } else { $subselect = ""; } $query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`, lc.`user_id`, lc.`content_type_guid`, lc.`format_guid`,\n\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$select} {$subselect}\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where} {$order}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); 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['display_link'] = Pigeonholes::getDisplayLink($aux['title'], $aux); // get member count for mysql - haha if ($gBitDbType == 'mysql') { $aux['members_count'] = $this->mDb->getOne("SELECT COUNT( pm.`content_id` ) FROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm WHERE pm.`parent_id`=?", array($aux['content_id'])); } if (!empty($pListHash['parse_data']) && !empty($aux['data'])) { $aux['parsed_data'] = $this->parseData($aux['data'], $aux['format_guid']); } if (!empty($pListHash['force_extras']) || !empty($pListHash['load_extras']) && $aux['structure_id'] == @$pListHash['structure_id']) { $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('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); $aux['members'] = $this->getMemberList($memberListHash); $aux['listInfo'] = $memberListHash['listInfo']; //$aux['members_count'] = count( $aux['members'] ); if ($gBitSystem->getConfig('pigeonholes_list_style') == 'table') { $this->alphabetiseMembers($aux['members']); } } $ret[$aux['structure_id']] = $aux; } $query = "SELECT COUNT( lc.`title` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return $ret; }