You are here

function merci_restrictions_override_validate in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

1 string reference to 'merci_restrictions_override_validate'
merci_restrictions_field_widget_form_alter in merci_restrictions/merci_restrictions.module

File

merci_restrictions/merci_restrictions.module, line 37

Code

function merci_restrictions_override_validate($element, &$form_state, $form) {
  if (!empty($element['target_id']['#value'])) {
    $line_item = $element['target_id']['#entity'];
    if ($line_item->is_new) {
      if (preg_match("/.+\\((\\d+)\\)/", $element['target_id']['#value'], $matches)) {
        $value = $matches[1];
        $account = user_load($value);
        $name = $account->name;
      }
      else {
        $name = $element['target_id']['#value'];
      }
      $password = $element['override_password']['#value'];
      if (!user_authenticate($name, $password)) {
        form_error($element, t('Password for override operator incorrect.'));
      }
    }
  }
}