Advertisement
the0938

gptek-groups-analyze

Jul 12th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. $lkaExists = [];
  2. $lkkExists = [];
  3.  
  4. // LkkInfo
  5. foreach (bx_hl_select(91) as $item)
  6. {
  7.     $code = $item['UF_USER_CODE'];
  8.  
  9.     if (!$code)
  10.     {
  11.         continue;
  12.     }
  13.  
  14.     $lkkExists[$code] = true;
  15. }
  16.  
  17. // LkaAbonentInfo
  18. foreach (bx_hl_select(36) as $item)
  19. {
  20.     $code = $item['UF_USER_CODE'];
  21.  
  22.     if (!$code)
  23.     {
  24.         continue;
  25.     }
  26.  
  27.     $lkaExists[$code] = true;
  28. }
  29.  
  30. $lkkUsers = [];
  31. $lkaUsers = [];
  32. $lkgUsers = [];
  33.  
  34. $otherUsers = [];
  35.  
  36. foreach (Bx\User\UserModel::getList() as $user)
  37. {
  38.     // Exclude admins.
  39.     if ($user->isGroup(1))
  40.     {
  41.         continue;
  42.     }
  43.  
  44.     $userCode = $user['UF_CODE_LKA'];
  45.  
  46.     $isLkk = $userCode && ($lkkExists[$userCode] ?: false);
  47.     $isLka = $userCode && ($lkaExists[$userCode] ?: false);
  48.     $isLkg = $user->isGroup('lkg');
  49.  
  50.     $isLkkOnly = $isLkk && !$isLka && !$isLkg;
  51.     $isLkaOnly = $isLka && !$isLkk && !$isLkg;
  52.     $isLkgOnly = $isLkg && !$isLka && !$isLkk;
  53.  
  54.     if ($isLkkOnly)
  55.     {
  56.         $lkkUsers[] = $user;
  57.         continue;
  58.     }
  59.  
  60.     if ($isLkaOnly)
  61.     {
  62.         $lkaUsers[] = $user;
  63.         continue;
  64.     }
  65.  
  66.     if ($isLkgOnly)
  67.     {
  68.         $lkgUsers[] = $user;
  69.         continue;
  70.     }
  71.  
  72.     $otherUsers[] = $user;
  73. }
  74.  
  75. echo 'lkk: '.count($lkkUsers).PHP_EOL;
  76. echo 'lka: '.count($lkaUsers).PHP_EOL;
  77. echo 'lkg: '.count($lkgUsers).PHP_EOL;
  78. echo 'others: '.count($otherUsers).PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement