You are here

function agreement_type_load in Agreement 7.2

Load agreement types.

Parameters

string $name: (Optional) An agreement type machine name to load.

bool $use_cache: (Optional) Whether or not to load from cache or not.

Return value

array An associative array of agreement types keyed by the agreement type ID, or a single agreement type.

17 calls to agreement_type_load()
AgreementCustomUnprivilegedUserTestCase::testAgreementDestination in ./agreement.test
Tests the agreement destination functionality.
AgreementCustomUnprivilegedUserTestCase::testAgreementFrequency in ./agreement.test
Tests the agreement frequency setting.
AgreementMultipleRoleTestCase::setUp in ./agreement.test
Sets up a Drupal site for running functional and integration tests.
AgreementMultipleTestCase::testAgreement in ./agreement.test
Tests that multiple agreements can function independently.
AgreementTestCase::setUp in ./agreement.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

./agreement.module, line 230
Agreement module code - agreement.module.

Code

function agreement_type_load($name = NULL, $use_cache = TRUE) {
  $agreement_types =& drupal_static(__FUNCTION__);
  if (!$use_cache || !isset($agreement_types) || !is_array($agreement_types)) {
    $types = array();
    $query = db_select('agreement_type');
    $query
      ->fields('agreement_type')
      ->orderBy('name');
    $result = $query
      ->execute();
    if (!empty($result)) {
      $types = $result
        ->fetchAllAssoc('name', PDO::FETCH_ASSOC);

      // Unserialize the type settings.
      foreach ($types as $type_name => $type) {
        $types[$type_name]['settings'] = unserialize($types[$type_name]['settings']);
      }
    }

    // Set the type(s) into static cache.
    $agreement_types = $types;
  }
  else {
    $types = $agreement_types;
  }
  return !empty($types) && isset($name) && isset($types[$name]) ? $types[$name] : $types;
}