Get all usernames as an array that dosent exist in either enviroment
@param  $missingAccountsLocally Set to "true" to get accounts that exists in ad but not in WordPress. False value reverses the check.
@return array
772559
public function diffUserAccounts($getMissingAccountsLocally = true)
    {
        $ad = $this->getAdAccounts();
        $local = $this->getLocalAccounts();

        if ($getMissingAccountsLocally === true) {
            return array_diff((array)$ad, (array)$local);
        } else {
            return array_diff((array)$local, (array)$ad);
        }
    }
315551
public function getCustomerAccount()
    {
        if ($account = $this->entity->getCustomerAccount()) {
            return array(
                'id' => $account->getId(),
                'name' => $account->getName()
            );
        }

        return null;
    }
540153
public function checkUsername() {
    if (!Tilmeld::$config['email_usernames']) {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify a username.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Usernames must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }
      if (array_diff(
          str_split($this->username),
          str_split(Tilmeld::$config['valid_chars'])
      )) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_chars_notice']
        ];
      }
      if (!preg_match(Tilmeld::$config['valid_regex'], $this->username)) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_regex_notice']
        ];
      }
      $selector = ['&',
        'ilike' => [
          'username',
          str_replace(
              ['\\', '%', '_'],
              ['\\\\\\\\', '\%', '\_'],
              $this->username
          )
        ]
      ];
      if (isset($this->guid)) {
        $selector['!guid'] = $this->guid;
      }
      $test = Nymph::getEntity(
          ['class' => '\Tilmeld\Entities\User', 'skip_ac' => true],
          $selector
      );
      if (isset($test->guid)) {
        return ['result' => false, 'message' => 'That username is taken.'];
      }

      return [
        'result' => true,
        'message' => (
          isset($this->guid) ? 'Username is valid.' : 'Username is available!'
        )
      ];
    } else {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify an email.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Emails must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }

      return $this->checkEmail();
    }
  }
705092
public function getUsersList() {
        $response=CodeBank_ClientAPI::responseBase();
        
        $members=Permission::get_members_by_permission(array('ADMIN', 'CODE_BANK_ACCESS'));
        foreach($members as $member) {
            $response['data'][]=array(
                                    'id'=>$member->ID,
                                    'username'=>$member->Email,
                                    'lastLogin'=>$member->LastVisited
                                );
        }
        
        
        return $response;
    }
1192119
protected function _getAvailableRoles() {
		if ($this->_roles !== null) {
			return $this->_roles;
		}

		$roles = Configure::read($this->getConfig('rolesTable'));
		if (is_array($roles)) {
			if ($this->getConfig('superAdminRole')) {
				$key = $this->getConfig('superAdmin') ?: 'superadmin';
				$roles[$key] = $this->getConfig('superAdminRole');
			}
			return $roles;
		}

		$rolesTable = TableRegistry::get($this->getConfig('rolesTable'));
		$result = $rolesTable->find()->formatResults(function (ResultSetInterface $results) {
			return $results->combine($this->getConfig('aliasColumn'), 'id');
		});
		$roles = $result->toArray();

		if ($this->getConfig('superAdminRole')) {
			$key = $this->getConfig('superAdmin') ?: 'superadmin';
			$roles[$key] = $this->getConfig('superAdminRole');
		}

		if (count($roles) < 1) {
			throw new Exception('Invalid TinyAuth role setup (roles table `' . $this->getConfig('rolesTable') . '` has no roles)');
		}

		$this->_roles = $roles;

		return $roles;
	}
1340336
private function collectValues(array $missing)
    {
        $values = [];

        foreach ($missing as $missingKey) {
            $values[$missingKey] = $this->ask(
                "<fg=yellow>{$missingKey}</> translation", $this->getDefaultValue($missingKey)
            );
        }

        return $values;
    }
678488
public function getAdAccounts()
    {
        //Authentication
        $data = array(
            'username' => AD_BULK_IMPORT_USER,
            'password' => AD_BULK_IMPORT_PASSWORD
        );

        //Fetch index
        $index = $this->curl->request('POST', rtrim(AD_INTEGRATION_URL, "/") . '/user/index', $data, 'json',
            array('Content-Type: application/json'));

        //Validate json response
        if ($this->response::isJsonError($index) || !json_decode($index)) {
            return false;
        }

        //Check that no errors occured
        if (json_last_error() != JSON_ERROR_NONE) {
            error_log("Ad integration: Could not read index due to the fact that the response wasen't a valid json string.");
            exit;
        }

        //Return
        return array_map('strtolower', json_decode($index));
    }
703019
public static function getAllSuperUserAccessEmailAddresses()
    {
        $emails = array();

        try {
            $superUsers = APIUsersManager::getInstance()->getUsersHavingSuperUserAccess();
        } catch (\Exception $e) {
            return $emails;
        }

        foreach ($superUsers as $superUser) {
            $emails[$superUser['login']] = $superUser['email'];
        }

        return $emails;
    }
907989
public function getRolesForUserCreation(): array
    {
        $roles = [];

        if (auth()->check()) {
            /** @var HCUser $user */
            $user = auth()->user();

            if ($user->isSuperAdmin()) {
                $roles = HCAclRole::select('id', 'name as label')->orderBy('name')->get()->toArray();
            } else {
                foreach ($user->roles as $role) {
                    $roles[] = [
                        'id' => $role->id,
                        'label' => $role->name,
                    ];
                }
            }
        }

        return $roles;
    }
1373395
public function getLinksArray($includeOnlyVisited = false){
        $links = $this->getLinks();
        
        if($includeOnlyVisited === true){
            $links = array_filter($links, function (Link $linkObj) {
                /*@var $linkObj Link */
                return $linkObj->isVisited() === true;
            });
        }
        
        return array_map(function(Link $link){
            return [
              'fullUrl' => $link->getAbsoluteUrl(),
              'uri' => $link->getPath(),
              'metaInfo' => $link->getMetaInfoArray(),
              'parentLink' => $link->getParentUrl(),
              'statusCode' => $link->getStatusCode(), 
              'status' => $link->getStatus(), 
              'contentType' => $link->getContentType(), 
              'errorInfo' => $link->getErrorInfo(),
              'crawlDepth' => $link->getCrawlDepth(),              
            ];
        },$links);
    }
1089900
protected function parseTransactionAccountName()
    {
        $results = [];
        // SEPA MT940 Structured
        if (preg_match('#/NAME/(.+?)\n?/(REMI|ADDR|ISDT|CSID)/#ms', $this->getCurrentTransactionData(), $results)) {
            $accountName = trim($results[1]);
            if (!empty($accountName)) {
                return $this->sanitizeAccountName($accountName);
            }
        }

        if (preg_match('/^:61:.*? (.+)/m', $this->getCurrentTransactionData(), $results)) {
            $accountName = trim($results[1]);
            if (!empty($accountName)) {
                return $this->sanitizeAccountName($accountName);
            }
        }

        if (preg_match('/(.*) Betaalautomaat/', $this->parseTransactionDescription(), $results)) {
            $accountName = trim($results[1]);
            if (!empty($accountName)) {
                return $this->sanitizeAccountName($accountName);
            }
        }
        return '';
    }
366977
public function getAdminRecoveryData()
    {
        $oSession             = Factory::service('Session', 'nails/module-auth');
        $existingRecoveryData = $oSession->getUserData($this->sAdminRecoveryField);

        if (empty($existingRecoveryData)) {
            return [];
        } else {
            return end($existingRecoveryData);
        }
    }
304711
protected function _getDelAddressData()
    {
        // if user company name, user name and additional info has special chars
        $blShowShipAddressParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('blshowshipaddress');
        $blShowShipAddressVariable = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('blshowshipaddress');
        $sDeliveryAddressParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('deladr', true);
        $aDeladr = ($blShowShipAddressParameter || $blShowShipAddressVariable) ? $sDeliveryAddressParameter : [];
        $aDelAdress = $aDeladr;

        if (is_array($aDeladr)) {
            // checking if data is filled
            if (isset($aDeladr['oxaddress__oxsal'])) {
                unset($aDeladr['oxaddress__oxsal']);
            }
            if (!count($aDeladr) || implode('', $aDeladr) == '') {
                // resetting to avoid empty records
                $aDelAdress = [];
            }
        }

        return $aDelAdress;
    }
1054753
public function getMissingAttribs()
    {
        return array_combine(
            array_keys($this->missingAttribs),
            array_map(function ($ref) {
                return $ref['attrib'];
            }, array_values($this->missingAttribs))
        );
    }
174952
public function getAccountAddresses()
    {
        $accountAddresses = [];
        if ($this->entity->getAccountAddresses()) {
            foreach ($this->entity->getAccountAddresses() as $adr) {
                $accountAddress[] = new AccountAddress($adr);
            }
        }

        return $accountAddresses;
    }
901796
public function getUsersPairsWithGroupNamesForSelects()
    {
        // Check and init cache
        if (!self::$cached_users_pairs_with_groups) {
            $user_collection = new AdminUserRepository;
            $user_collection->addOrderByField('name');
            foreach ($user_collection->getAsArrayOfObjects() as $v) {
                /** @var AdminUser $v */

                $group = new AdminUserGroup($v->getGroupId());
                self::$cached_users_pairs_with_groups[$group->getTitle()][$v->getId()] = $v->getName() . ' ' . $v->getSurname() . ' [' . $v->getLogin() . ']';
            }
        }

        return self::$cached_users_pairs_with_groups;
    }
722389
public function createAccount($userNames)
    {
        if (!is_array($userNames)) {
            $userNames = array($userNames);
        }

        foreach ($userNames as $userName) {
            if (empty($userName)) {
                continue;
            }

            if (!in_array($userName, $this->getLocalAccounts())) {

                //Do a sanity check
                if ($this->userNameExists($userName) === false) {

                    try {
                        $userId = wp_insert_user(
                            array(
                                'user_login' => $userName,
                                'user_pass' => wp_generate_password(),
                                'user_nicename' => $userName,
                                'user_email' => $this->createFakeEmail($userName),
                                'user_registered' => date('Y-m-d H:i:s'),
                                'role' =>  $this->defaultRole
                            )
                        );
                    } catch (\Exception $e) {
                        error_log("Error: Could not create a new user using bulk data (ad-api-integration).");
                    }

                } else {
                    $userId = null;
                }

                if (is_numeric($userId)) {
                    $this->setUserRole($userId);
                }
            }
        }
    }