You are here

abstract class EntityLegalMethod in Entity Legal 7.2

Same name and namespace in other branches
  1. 7 methods/entity_legal.method.inc \EntityLegalMethod

Base class for entity_legal methods.

Provides helper functions for methods to use.

Hierarchy

Expanded class hierarchy of EntityLegalMethod

File

methods/entity_legal.method.inc, line 12
Method include file for common base class.

View source
abstract class EntityLegalMethod {

  /**
   * Get all Entity Legal Documents for a given user type and method.
   *
   * @param string $method
   *   The name of the method to find entity legal documents for.
   * @param string $user_type
   *   The type of user, existing or signup.
   *
   * @return array
   *   All published entity legal documents required for the given user type.
   */
  public function getDocumentsForMethod($method, $user_type = ENTITY_LEGAL_USER_EXISTING) {

    // Entity Legal administrators should never be forced to accept documents.
    if (user_access('administer entity legal')) {
      return array();
    }

    // Don't run method for anonymous users.
    if ($user_type == ENTITY_LEGAL_USER_EXISTING && user_is_anonymous()) {
      return array();
    }

    // Get all active documents that must be agreed to by existing users.
    $documents = entity_legal_get_all_documents(TRUE, $user_type);

    // Remove any documents from the array set that don't use the given
    // acceptance method.
    foreach ($documents as $name => $document) {
      $agreed = !$document
        ->userMustAgree($user_type == ENTITY_LEGAL_USER_ANONYMOUS) || $document
        ->userHasAgreed();
      $is_method = $document
        ->getAcceptanceDeliveryMethod($user_type == ENTITY_LEGAL_USER_ANONYMOUS) == $method;
      if ($agreed || !$is_method) {
        unset($documents[$name]);
      }
    }
    return $documents;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityLegalMethod::getDocumentsForMethod public function Get all Entity Legal Documents for a given user type and method.