1 user_compare_layout_access.inc public UserCompareLayoutAccess::summary()

Provides a human-readable summary of this access check's behavior.

Parameters

$contexts: An array containing available contexts.

Return value

string: The sanitized HTML summary string for this access check.

Overrides LayoutAccess::summary

File

core/modules/layout/plugins/access/user_compare_layout_access.inc, line 24
Contains UserCompareLayoutAccess class.

Class

UserCompareLayoutAccess
Plugin to provide access if two user account contexts are the same.

Code

public function summary() {
  $contexts = $this->settings['contexts'];
  if (empty($contexts) || count($contexts) != 2 || empty($contexts['user1']) || empty($contexts['user2'])) {
    return t('Compares two user accounts');
  }

  $labels = array();
  foreach ($this->settings['contexts'] as $key => $source) {
    if ($source == 'current_user') {
      $labels[$key] = t('The logged-in user account');
    }
    elseif (is_numeric($source)) {
      $substitutions = array('@position' => $source + 1);
      $labels[$key] = t('The user account from the path (in position @position)', $substitutions);
    }
    else {
      $labels[$key] = t('A user account from the layout contexts');
    }
  }

  $substitutions = array('@user' => $labels['user2']);
  if (!empty($this->settings['equality'])) {
    return t('@user is the same as the Logged-in user account.', $substitutions);
  }
  else {
    return t('@user is different from the Logged-in user account.', $substitutions);
  }
}