function entity_legal_get_all_documents in Entity Legal 7
Same name and namespace in other branches
- 7.2 entity_legal.module \entity_legal_get_all_documents()
Get all active legal documents on the site.
Parameters
bool $published: Whether or not the document has a published version.
string $user_type: The type of user process the document is required on, signup or existing.
Return value
array An array of legal documents index by entity id.
2 calls to entity_legal_get_all_documents()
- EntityLegalMethod::getDocumentsForMethod in methods/
entity_legal.method.inc - Get all Entity Legal Documents for a given user type and method.
- entity_legal_permission in ./
entity_legal.module - Implements hook_permission().
File
- ./
entity_legal.module, line 326 - Entity Legal module.
Code
function entity_legal_get_all_documents($published = TRUE, $user_type = NULL) {
$legal_document_query = new EntityFieldQuery();
$legal_document_query
->entityCondition('entity_type', ENTITY_LEGAL_DOCUMENT_ENTITY_NAME);
if ($published) {
$legal_document_query
->propertyCondition('published_version', 'NULL', '!=');
}
switch ($user_type) {
case ENTITY_LEGAL_USER_ANONYMOUS:
$legal_document_query
->propertyCondition('require_signup', 1);
break;
case ENTITY_LEGAL_USER_EXISTING:
$legal_document_query
->propertyCondition('require_existing', 1);
break;
}
$results = $legal_document_query
->execute();
return empty($results[ENTITY_LEGAL_DOCUMENT_ENTITY_NAME]) ? array() : entity_load(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, array_keys($results[ENTITY_LEGAL_DOCUMENT_ENTITY_NAME]));
}