You are here

public function DashboardForm::checkLimitPermissions in Opigno statistics 3.x

Same name and namespace in other branches
  1. 8 src/Form/DashboardForm.php \Drupal\opigno_statistics\Form\DashboardForm::checkLimitPermissions()

Get array of learning paths ID's where user have role 'student manager'.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user account.

Return value

array The list of Learning path IDs.

1 call to DashboardForm::checkLimitPermissions()
DashboardForm::buildForm in src/Form/DashboardForm.php
Form constructor.

File

src/Form/DashboardForm.php, line 631

Class

DashboardForm
Implements the statistics dashboard.

Namespace

Drupal\opigno_statistics\Form

Code

public function checkLimitPermissions(AccountInterface $account) : array {
  $query = $this->database
    ->select('group_content_field_data', 'g_c_f_d')
    ->fields('g_c_f_d', [
    'gid',
  ]);
  $query
    ->leftJoin('group_content__group_roles', 'g_c_g_r', 'g_c_f_d.id = g_c_g_r.entity_id');
  $query
    ->condition('g_c_g_r.group_roles_target_id', 'learning_path-user_manager');
  $query
    ->condition('g_c_f_d.entity_id', $account
    ->id());
  $query
    ->condition('g_c_f_d.type', 'learning_path-group_membership');
  $result = $query
    ->execute()
    ->fetchAllAssoc('gid');
  $lp_ids = [];
  foreach ($result as $row) {
    $lp_ids[] = $row->gid;
  }
  return $lp_ids;
}