You are here

function _photos_access_user_validate in Album Photos 7.3

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

Validate user access to node.

1 call to _photos_access_user_validate()
photos_access_node_validate in photos_access/photos_access.module
Implements hook_node_validate().

File

photos_access/photos_access.module, line 164

Code

function _photos_access_user_validate($privacy, $oldprivacy) {
  global $user;
  $t = preg_split('/,|,/', $privacy);
  $name = array();
  if (is_array($oldprivacy)) {
    foreach ($oldprivacy as $list) {
      $name[] = $list->name;
    }
  }
  $output = '';
  foreach ($t as $a) {
    $a = trim($a);
    if ($a != $user->name) {
      if (in_array($a, $name)) {
        $output = t('Users already on the list: %name.', array(
          '%name' => $a,
        ));
      }
      elseif (!($u = _photos_access_user(array(
        'name' => $a,
      )))) {
        $output = t('The user does not exist: %name.', array(
          '%name' => $a,
        ));
      }
    }
    else {
      $output = t("You do not need to add your self to this list.");
    }
  }
  return $output;
}