You are here

function gdpr_search_content in General Data Protection Regulation 7

Searches for gdpr related nodes. i.e.: Privacy Policy, Terms of use.

Return value

array Nodes array

1 call to gdpr_search_content()
gdpr_checklistapi_checklist_info in ./gdpr.module
Implements hook_checklistapi_checklist_info().

File

./gdpr.module, line 455
Contains hook implementations and shared functions.

Code

function gdpr_search_content() {
  if ($cached_content = cache_get('gdpr_content', 'cache')) {
    $nids = $cached_content->data;
  }
  else {

    // TODO: Localization.
    $nids = [];
    if (module_exists('node')) {
      $pattern = '(privacy( +)policy)|(terms( +)of( +)use)|(about( +)us)|(impressum)';
      $query = new EntityFieldQuery();
      $results = $query
        ->entityCondition('entity_type', 'node')
        ->propertyCondition('title', $pattern, 'RLIKE')
        ->execute();
      if (!empty($results['node'])) {
        $nids = array_keys($results['node']);
      }
    }
    cache_set('gdpr_content', $nids, 'cache', CACHE_TEMPORARY);
  }
  return node_load_multiple($nids);
}