You are here

function photos_access_node_load in Album Photos 7.3

Same name and namespace in other branches
  1. 8.5 photos_access/photos_access.module \photos_access_node_load()
  2. 8.4 photos_access/photos_access.module \photos_access_node_load()
  3. 6.0.x photos_access/photos_access.module \photos_access_node_load()

Implements hook_node_load().

File

photos_access/photos_access.module, line 334

Code

function photos_access_node_load($nodes, $types) {
  foreach ($nodes as $nid => $node) {
    $result = db_query('SELECT * FROM {photos_access_album} WHERE nid = :nid', array(
      ':nid' => $nid,
    ))
      ->fetchObject();
    $info = array();
    if ($result) {

      // Node privacy settings.
      $info['privacy'] = array();

      // @todo replace vid and eid with access_id.
      $info['privacy']['access_id'] = $result->id;
      $info['privacy']['vid'] = $result->id;
      $info['privacy']['eid'] = $result->id;
      $info['privacy']['viewid'] = $result->viewid;
      if ($result->viewid == 3) {
        $info['privacy']['pass'] = $result->pass;
      }

      // Users who can collaborate.
      $info['privacy']['updateuser'] = _photos_access_userlist($result->id, TRUE);

      // Users who can view.
      $info['privacy']['viewuser'] = _photos_access_userlist($result->id, FALSE);
      $nodes[$nid]->privacy = $info['privacy'];
    }
  }
}