ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTermsOfServiceUserHasCountryCriterion.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
11  protected $countryCodes = [];
12 
17  public function __construct(array $countryCodes)
18  {
19  $this->countryCodes = $countryCodes;
20  }
21 
25  public function getTypeIdent() : string
26  {
27  return 'usr_country';
28  }
29 
33  public function hasUniqueNature() : bool
34  {
35  return true;
36  }
37 
42  {
43  $country = $config['country'] ?? '';
44 
45  if (!is_string($country) || 2 !== strlen($country) || !is_string($user->getSelectedCountry())) {
46  return false;
47  }
48 
49  $result = strtolower($country) === strtolower($user->getSelectedCountry());
50 
51  return $result;
52  }
53 
58  {
59  return new ilTermsOfServiceUserHasCountryCriterionGUI($this, $lng, $this->countryCodes);
60  }
61 }
Interface ilTermsOfServiceCriterionTypeGUI.
$result
Interface ilTermsOfServiceCriterionType.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
ui(ilLanguage $lng)
ilTermsOfServiceCriterionTypeGUI
Class ilTermsOfServiceCriterionConfig.
getTypeIdent()
Returns a unique id of the criterion type.string
hasUniqueNature()
Returns whether or not a criterion is unique by it&#39;s nature.Example: "User Language". A user account can only have one profile language . bool
$lng
__construct(array $countryCodes)
ilTermsOfServiceUserHasCountryCriterion constructor.
getSelectedCountry()
Get selected country (selection drop down)
evaluate(ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
bool