Skip to content

Instantly share code, notes, and snippets.

@pedro-vasconcelos
Created April 6, 2013 11:34
Show Gist options
  • Save pedro-vasconcelos/5325812 to your computer and use it in GitHub Desktop.
Save pedro-vasconcelos/5325812 to your computer and use it in GitHub Desktop.
Get data from EZ Publish content tree
$attributeFilter = array( array( 'user/sync_time', '=', '' ),
// array( 'user/guid', '=', '' ),
//array( 'user/user_settings/is_enabled', '=', 1 ),
array( 'modified', '>', $last_modified)
);
$params = array(
/*
Depth
By default set to 1, this value tells eZ how many levels it should search down.
Example: array( ‘Depth’ => 3 )
--- */
'Depth' => 1,
/*
Offset
By default set to 0, this value is usually used in conjunction with Limit to
control the offset of the results.
Example: array( ‘Offset’ => 20 )
--- */
'Offset' => $offset,
/*
Limit
By default set to 0 which pulls out all of the results, this can be set to make
your queries more resource friendly.
Example: array( ‘Limit’ => 20 )
--- */
'Limit' => $limit,
/*
SortBy
This can be used to sort in order of name, published date or any custom values.
You must use true/false to specify ASC/DESC.
Example: array( ‘Limit’ => array(“name”,true) )
--- */
'SortBy' => array('modified', true),
/*
AttributeFilter
This is the key parameter which we will look into in more detail. For user export
you may use this in a number of ways, whether to check users wish to be contacted
or users for within a specified timespan. Our example here is simple. We will look
at more complex examples but I would also recommend looking at the content list
documentation on the eZ.no site for more examples.
Example: array( ‘AttributeFilter’ => array( array( ‘name’, ‘like’, ‘David*’ ) ))
--- */
'AttributeFilter' => ($attributeFilter) ? $attributeFilter : false,
/*
ClassFilterType / ClassFilterArray
These are used in tandem so we will show their use together. ClassFilterType can
be set to include or exclude. The classes filtered relate to the content types created
in the CMS (such as User and Article) and do not relate to physical PHP file types
(like eZUser). Please note that you need to use the class identifier rather than the
class name.
Example: array(‘ClassFilterType’=>’include’,'ClassFilterArray’=>array(‘user’))
*/
'ClassFilterType' => 'include',
'ClassFilterArray' => $includeClasses,
//'Limitation' => array(), // Optimize proccess cycle
'LoadDataMap' => false,
'AsObject' => false,
'IgnoreVisibility' => true
);
// Vai buscar o objecto pelo caminho (URL) que tem os objectos que nos interessa por baixo
// Desta forma limitamos a zona de pesquisa para o EZ
// Nota importante: é necessário converter os hifens "-" em underscores "_"
$parent_node = eZContentObjectTreeNode::fetchByURLPath('users/guest_accounts');
// Retira o ID do objecto encontrado
$parent_node_id = $parent_node->NodeID;
// O método subTreeByNodeID usa as permissões do utilizador em causa para fazer o filtro
// No caso da shell o utilizador é Anónimo e pode não ter permissões para consultar os
// objectos em causa. Nas linhas mais acima definimos com que utilizador estamos a fazer o filtro.
// Se não quisermos definir o utilizador temos de acrescentar o paramentro:
// 'Limitation' => array()
//$results = eZContentObjectTreeNode::subTreeByNodeID( $params, $parent_node_id );
//echo eZContentObjectTreeNode::subTreeCountByNodeID( $params, $parent_node_id );
//print_r( $results );
$customers = eZContentObjectTreeNode::subTreeByNodeID(array(
'Depth' => false,
'Limitation' => array(), // Optimize proccess cycle
'Limit' => 1,
'LoadDataMap' => false,
'AsObject' => false,
'SortBy' => array('modified', false),
'ClassFilterType' => 'include',
'ClassFilterArray' => array('user'),
'AttributeFilter' => ($attributeFilter) ? $attributeFilter : false
),$parent_node_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment