static function trashList($params = false, $asCount = false) { if ($params === false) { $params = array('Offset' => false, 'Limit' => false, 'SortBy' => false, 'AttributeFilter' => false); } $offset = isset($params['Offset']) && is_numeric($params['Offset']) ? $params['Offset'] : false; $limit = isset($params['Limit']) && is_numeric($params['Limit']) ? $params['Limit'] : false; $asObject = isset($params['AsObject']) ? $params['AsObject'] : true; $objectNameFilter = isset($params['ObjectNameFilter']) ? $params['ObjectNameFilter'] : false; $sortBy = isset($params['SortBy']) && is_array($params['SortBy']) ? $params['SortBy'] : array(array('name')); if ($asCount) { $sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings(false); } else { $sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings($sortBy, 'ezcot'); } $attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings($params['AttributeFilter'], $sortingInfo); if ($attributeFilter === false) { return null; } $objectNameFilterSQL = eZContentObjectTreeNode::createObjectNameFilterConditionSQLString($objectNameFilter); $limitation = isset($params['Limitation']) && is_array($params['Limitation']) ? $params['Limitation'] : false; $limitationList = eZContentObjectTreeNode::getLimitationList($limitation); $sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList, 'ezcontentobject_trash', 'ezcot'); if ($asCount) { $query = "SELECT count(*) as count "; } else { $query = "SELECT\n ezcontentobject.*,\n ezcot.*,\n ezcontentclass.serialized_name_list as class_serialized_name_list,\n ezcontentclass.identifier as class_identifier,\n ezcontentobject_name.name as name,\n ezcontentobject_name.real_translation\n {$sortingInfo['attributeTargetSQL']} "; } $query .= "FROM\n ezcontentobject_trash ezcot\n INNER JOIN ezcontentobject ON ezcot.contentobject_id = ezcontentobject.id\n INNER JOIN ezcontentclass ON ezcontentclass.version = 0 AND ezcontentclass.id = ezcontentobject.contentclass_id\n INNER JOIN ezcontentobject_name ON (\n ezcot.contentobject_id = ezcontentobject_name.contentobject_id AND\n ezcot.contentobject_version = ezcontentobject_name.content_version\n )\n {$sortingInfo['attributeFromSQL']}\n {$attributeFilter['from']}\n {$sqlPermissionChecking['from']}\n WHERE\n {$sortingInfo['attributeWhereSQL']}\n {$attributeFilter['where']}\n " . eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject') . "\n {$sqlPermissionChecking['where']}\n {$objectNameFilterSQL}\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject'); if (!$asCount && $sortingInfo['sortingFields'] && strlen($sortingInfo['sortingFields']) > 5) { $query .= " ORDER BY {$sortingInfo['sortingFields']}"; } $db = eZDB::instance(); if (!$offset && !$limit) { $trashRowsArray = $db->arrayQuery($query); } else { $trashRowsArray = $db->arrayQuery($query, array('offset' => $offset, 'limit' => $limit)); } // cleanup temp tables $db->dropTempTableList($sqlPermissionChecking['temp_tables']); if ($asCount) { return $trashRowsArray[0]['count']; } else { if ($asObject) { $retTrashNodes = array(); foreach (array_keys($trashRowsArray) as $key) { $trashRow =& $trashRowsArray[$key]; $retTrashNodes[] = new eZContentObjectTrashNode($trashRow); } return $retTrashNodes; } else { return $trashRowsArray; } } }
static function subTreeCountByNodeID($params = array(), $nodeID) { if (!is_numeric($nodeID) and !is_array($nodeID)) { return null; } $language = isset($params['Language']) ? $params['Language'] : false; if ($language) { if (!is_array($language)) { $language = array($language); } eZContentLanguage::setPrioritizedLanguages($language); } $depth = isset($params['Depth']) && is_numeric($params['Depth']) ? $params['Depth'] : false; $depthOperator = isset($params['DepthOperator']) ? $params['DepthOperator'] : false; $pathStringCond = ''; $notEqParentString = ''; // If the node(s) doesn't exist we return null. if (!eZContentObjectTreeNode::createPathConditionAndNotEqParentSQLStrings($pathStringCond, $notEqParentString, $nodeID, $depth, $depthOperator)) { return null; } $db = eZDB::instance(); $ini = eZINI::instance(); // Check for class filtering $classCondition = ''; if (isset($params['ClassFilterType']) and isset($params['ClassFilterArray']) and ($params['ClassFilterType'] == 'include' or $params['ClassFilterType'] == 'exclude') and count($params['ClassFilterArray']) > 0) { $classCondition = ' '; $i = 0; $classCount = count($params['ClassFilterArray']); $classIDArray = array(); foreach ($params['ClassFilterArray'] as $classID) { $originalClassID = $classID; // Check if classes are recerenced by identifier if (is_string($classID) && !is_numeric($classID)) { $classID = eZContentClass::classIDByIdentifier($classID); } if (is_numeric($classID)) { $classIDArray[] = $classID; } else { eZDebugSetting::writeWarning('kernel-content-class', "Invalid class identifier in subTree() classfilterarray, classID : " . $originalClassID); } } if (count($classIDArray) > 0) { $classCondition .= " ezcontentobject.contentclass_id "; if ($params['ClassFilterType'] == 'include') { $classCondition .= " IN "; } else { $classCondition .= " NOT IN "; } $classIDString = implode(', ', $classIDArray); $classCondition .= ' ( ' . $classIDString . ' ) AND'; } } // Main node check $mainNodeOnlyCond = ''; if (isset($params['MainNodeOnly']) && $params['MainNodeOnly'] === true) { $mainNodeOnlyCond = 'ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id AND'; } $languageFilter = ' AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject'); $objectNameLanguageFilter = eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject'); if ($language) { eZContentLanguage::clearPrioritizedLanguages(); } $objectNameFilter = isset($params['ObjectNameFilter']) ? $params['ObjectNameFilter'] : false; $attributeFilterParam = isset($params['AttributeFilter']) ? $params['AttributeFilter'] : false; $sortingInfo = array('sortCount' => 0, 'attributeJoinCount' => 0); $attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings($attributeFilterParam, $sortingInfo, $language); if ($attributeFilter === false) { return null; } $objectNameFilterSQL = eZContentObjectTreeNode::createObjectNameFilterConditionSQLString($objectNameFilter); $extendedAttributeFilter = eZContentObjectTreeNode::createExtendedAttributeFilterSQLStrings($params['ExtendedAttributeFilter']); // Determine whether we should show invisible nodes. $ignoreVisibility = isset($params['IgnoreVisibility']) ? $params['IgnoreVisibility'] : false; $showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(!$ignoreVisibility); $limitation = isset($params['Limitation']) && is_array($params['Limitation']) ? $params['Limitation'] : false; $limitationList = eZContentObjectTreeNode::getLimitationList($limitation); $sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList); $query = "SELECT\n count( DISTINCT ezcontentobject_tree.node_id ) as count\n FROM\n ezcontentobject_tree\n INNER JOIN ezcontentobject ON (ezcontentobject.id = ezcontentobject_tree.contentobject_id)\n INNER JOIN ezcontentclass ON (ezcontentclass.id = ezcontentobject.contentclass_id)\n INNER JOIN ezcontentobject_name ON (\n ezcontentobject_name.contentobject_id = ezcontentobject_tree.contentobject_id AND\n ezcontentobject_name.content_version = ezcontentobject_tree.contentobject_version\n )\n {$attributeFilter['from']}\n {$extendedAttributeFilter['tables']}\n {$sqlPermissionChecking['from']}\n WHERE {$pathStringCond}\n {$extendedAttributeFilter['joins']}\n {$mainNodeOnlyCond}\n {$classCondition}\n {$attributeFilter['where']}\n ezcontentclass.version=0 AND\n {$notEqParentString}\n {$objectNameLanguageFilter}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$objectNameFilterSQL}\n {$languageFilter} "; $server = count($sqlPermissionChecking['temp_tables']) > 0 ? eZDBInterface::SERVER_SLAVE : false; $nodeListArray = $db->arrayQuery($query, array(), $server); // cleanup temp tables $db->dropTempTableList($sqlPermissionChecking['temp_tables']); return $nodeListArray[0]['count']; }
static function trashList( $params = false, $asCount = false ) { if ( $params === false ) { $params = array( 'Offset' => false, 'Limit' => false, 'SortBy' => false, 'AttributeFilter' => false, ); } $offset = ( isset( $params['Offset'] ) && is_numeric( $params['Offset'] ) ) ? $params['Offset'] : false; $limit = ( isset( $params['Limit'] ) && is_numeric( $params['Limit'] ) ) ? $params['Limit'] : false; $asObject = ( isset( $params['AsObject'] ) ) ? $params['AsObject'] : true; $objectNameFilter = ( isset( $params['ObjectNameFilter'] ) ) ? $params['ObjectNameFilter'] : false; $sortBy = ( isset( $params['SortBy'] ) && is_array( $params['SortBy'] ) ) ? $params['SortBy'] : array( array( 'name' ) ); if ( $asCount ) { $sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings( false ); } else { $sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings( $sortBy, 'ezcot' ); } $attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings( $params['AttributeFilter'], $sortingInfo ); if ( $attributeFilter === false ) { return null; } $useVersionName = true; $versionNameTables = eZContentObjectTreeNode::createVersionNameTablesSQLString ( $useVersionName ); $versionNameTargets = eZContentObjectTreeNode::createVersionNameTargetsSQLString( $useVersionName ); $versionNameJoins = eZContentObjectTreeNode::createVersionNameJoinsSQLString ( $useVersionName, false, false, false, 'ezcot' ); $languageFilter = ' AND ' . eZContentLanguage::languagesSQLFilter( 'ezcontentobject' ); $objectNameFilterSQL = eZContentObjectTreeNode::createObjectNameFilterConditionSQLString( $objectNameFilter ); $limitation = ( isset( $params['Limitation'] ) && is_array( $params['Limitation'] ) ) ? $params['Limitation']: false; $limitationList = eZContentObjectTreeNode::getLimitationList( $limitation ); $sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL( $limitationList, 'ezcontentobject_trash', 'ezcot' ); if ( $asCount ) { $query = "SELECT count(*) as count "; } else { $query = "SELECT ezcontentobject.*, ezcot.*, ezcontentclass.serialized_name_list as class_serialized_name_list, ezcontentclass.identifier as class_identifier $versionNameTargets $sortingInfo[attributeTargetSQL] "; } $query .= "FROM ezcontentobject_trash ezcot, ezcontentobject, ezcontentclass $versionNameTables $sortingInfo[attributeFromSQL] $attributeFilter[from] $sqlPermissionChecking[from] WHERE ezcontentclass.version=0 AND ezcot.contentobject_id = ezcontentobject.id AND ezcontentclass.id = ezcontentobject.contentclass_id AND $sortingInfo[attributeWhereSQL] $attributeFilter[where] $versionNameJoins $sqlPermissionChecking[where] $objectNameFilterSQL $languageFilter "; if ( !$asCount && $sortingInfo['sortingFields'] && strlen( $sortingInfo['sortingFields'] ) > 5 ) $query .= " ORDER BY $sortingInfo[sortingFields]"; $db = eZDB::instance(); if ( !$offset && !$limit ) $trashRowsArray = $db->arrayQuery( $query ); else $trashRowsArray = $db->arrayQuery( $query, array( 'offset' => $offset, 'limit' => $limit ) ); // cleanup temp tables $db->dropTempTableList( $sqlPermissionChecking['temp_tables'] ); if ( $asCount ) { return $trashRowsArray[0]['count']; } else if ( $asObject ) { $retTrashNodes = array(); foreach ( array_keys( $trashRowsArray ) as $key ) { $trashRow =& $trashRowsArray[ $key ]; $retTrashNodes[] = new eZContentObjectTrashNode( $trashRow ); } return $retTrashNodes; } else { return $trashRowsArray; } }