public static function drupalchatController::drupalchat_verify_access in DrupalChat 8
2 calls to drupalchatController::drupalchat_verify_access()
File
- src/
Controller/ drupalchatController.php, line 31 - Contains Drupal\drupalchat\Controller\drupalchatController
Class
Namespace
Drupal\drupalchat\ControllerCode
public static function drupalchat_verify_access() {
$user = \Drupal::currentUser();
// Match path if necessary.
$page_match = FALSE;
if (\Drupal::config('drupalchat.settings')
->get('drupalchat_path_pages')) {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = Unicode::strtolower(\Drupal::config('drupalchat.settings')
->get('drupalchat_path_pages'));
$drupalchat_path_visibility = \Drupal::config('drupalchat.settings')
->get('drupalchat_path_visibility') ?: 0;
if ($drupalchat_path_visibility == 2 || $drupalchat_path_visibility == 3) {
// Convert the Drupal path to lowercase
$path = Unicode::strtolower(\Drupal::service('path.current')
->getPath());
// Compare the lowercase internal and lowercase path alias (if any).
$path = ltrim($path, '/');
$page_match = \Drupal::service('path.matcher')
->matchPath($path, $pages);
// When $block->visibility has a value of 2 (BLOCK_VISIBILITY_NOTLISTED),
// the block is displayed on all pages except those listed in $block->pages.
// When set to 3 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
// pages listed in $block->pages.
if ($drupalchat_path_visibility == 2) {
$page_match = !$page_match;
}
if ($drupalchat_path_visibility == 3) {
$page_match = $page_match;
}
//$page_match = !(\Drupal::config('drupalchat.settings')->get('drupalchat_path_visibility') xor $page_match);
}
elseif (\Drupal::moduleHandler()
->moduleExists('php')) {
$page_match = php_eval(\Drupal::config('drupalchat.settings')
->get('drupalchat_path_pages') ?: NULL);
}
else {
$page_match = FALSE;
}
}
else {
$page_match = TRUE;
}
$final = FALSE;
$final = (\Drupal::config('drupalchat.settings')
->get('drupalchat_rel') == DRUPALCHAT_REL_AUTH && $user
->id() == 0 || $user
->id() > 0) && $page_match && \Drupal::currentUser()
->hasPermission('access drupalchat');
if (\Drupal::config('drupalchat.settings')
->get('drupalchat_polling_method') != DRUPALCHAT_COMMERCIAL) {
$final = $final && drupalchatController::_drupalchat_get_sid() != -1;
}
return $final;
}