| Total Complexity | 113 |
| Total Lines | 655 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like AbstractProfile often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractProfile, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 40 | abstract class AbstractProfile extends EntityWithDBProperties { |
||
| 41 | |||
| 42 | const HIDDEN = -1; |
||
| 43 | const AVAILABLE = 0; |
||
| 44 | const UNAVAILABLE = 1; |
||
| 45 | const INCOMPLETE = 2; |
||
| 46 | const NOTCONFIGURED = 3; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * DB identifier of the parent institution of this profile |
||
| 50 | * @var int |
||
| 51 | */ |
||
| 52 | public $institution; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * name of the parent institution of this profile in the current language |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | public $instName; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * realm of this profile (empty string if unset) |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | public $realm; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * This array holds the supported EAP types (in object representation). |
||
| 68 | * |
||
| 69 | * They are not synced against the DB after instantiation. |
||
| 70 | * |
||
| 71 | * @var array |
||
| 72 | */ |
||
| 73 | protected $privEaptypes; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * number of profiles of the IdP this profile is attached to |
||
| 77 | */ |
||
| 78 | protected $idpNumberOfProfiles; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * IdP-wide attributes of the IdP this profile is attached to |
||
| 82 | */ |
||
| 83 | protected $idpAttributes; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Federation level attributes that this profile is attached to via its IdP |
||
| 87 | */ |
||
| 88 | protected $fedAttributes; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * This class also needs to handle frontend operations, so needs its own |
||
| 92 | * access to the FRONTEND datbase. This member stores the corresponding |
||
| 93 | * handle. |
||
| 94 | * |
||
| 95 | * @var DBConnection |
||
| 96 | */ |
||
| 97 | protected $frontendHandle; |
||
| 98 | |||
| 99 | protected function saveDownloadDetails($idpIdentifier, $profileId, $deviceId, $area, $lang, $eapType) { |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * each profile has supported EAP methods, so get this from DB, Silver Bullet has one |
||
| 112 | * static EAP method. |
||
| 113 | */ |
||
| 114 | protected function fetchEAPMethods() { |
||
| 115 | $eapMethod = $this->databaseHandle->exec("SELECT eap_method_id |
||
| 116 | FROM supported_eap supp |
||
| 117 | WHERE supp.profile_id = $this->identifier |
||
| 118 | ORDER by preference"); |
||
| 119 | $eapTypeArray = []; |
||
| 120 | // SELECTs never return a boolean, it's always a resource |
||
| 121 | while ($eapQuery = (mysqli_fetch_object(/** @scrutinizer ignore-type */ $eapMethod))) { |
||
| 122 | $eaptype = new common\EAP($eapQuery->eap_method_id); |
||
| 123 | $eapTypeArray[] = $eaptype; |
||
| 124 | } |
||
| 125 | $this->loggerInstance->debug(4, "This profile supports the following EAP types:\n" . print_r($eapTypeArray, true)); |
||
| 126 | return $eapTypeArray; |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Class constructor for existing profiles (use IdP::newProfile() to actually create one). Retrieves all attributes and |
||
| 131 | * supported EAP types from the DB and stores them in the priv_ arrays. |
||
| 132 | * |
||
| 133 | * sub-classes need to set the property $realm, $name themselves! |
||
| 134 | * |
||
| 135 | * @param int $profileIdRaw identifier of the profile in the DB |
||
| 136 | * @param IdP $idpObject optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
||
| 137 | */ |
||
| 138 | public function __construct($profileIdRaw, $idpObject = NULL) { |
||
| 139 | $this->databaseType = "INST"; |
||
| 140 | parent::__construct(); // we now have access to our INST database handle and logging |
||
| 141 | $this->frontendHandle = DBConnection::handle("FRONTEND"); |
||
| 142 | // first make sure that we are operating on numeric identifiers |
||
| 143 | if (!is_numeric($profileIdRaw)) { |
||
| 144 | throw new Exception("Non-numeric Profile identifier was passed to AbstractProfile constructor!"); |
||
| 145 | } |
||
| 146 | $profileId = (int) $profileIdRaw; // no, it can not possibly be a double. Try to convince Scrutinizer... |
||
| 147 | $profile = $this->databaseHandle->exec("SELECT inst_id FROM profile WHERE profile_id = $profileId"); |
||
| 148 | // SELECT always yields a resource, never a boolean |
||
| 149 | if ($profile->num_rows == 0) { |
||
| 150 | $this->loggerInstance->debug(2, "Profile $profileId not found in database!\n"); |
||
| 151 | throw new Exception("Profile $profileId not found in database!"); |
||
| 152 | } |
||
| 153 | $this->identifier = $profileId; |
||
| 154 | $profileQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $profile); |
||
| 155 | if (!($idpObject instanceof IdP)) { |
||
| 156 | $this->institution = $profileQuery->inst_id; |
||
| 157 | $idp = new IdP($this->institution); |
||
| 158 | } else { |
||
| 159 | $idp = $idpObject; |
||
| 160 | $this->institution = (int) $idp->identifier; |
||
| 161 | } |
||
| 162 | |||
| 163 | $this->instName = $idp->name; |
||
| 164 | $this->idpNumberOfProfiles = $idp->profileCount(); |
||
| 165 | $this->idpAttributes = $idp->getAttributes(); |
||
| 166 | $fedObject = new Federation($idp->federation); |
||
| 167 | $this->fedAttributes = $fedObject->getAttributes(); |
||
| 168 | $this->loggerInstance->debug(3, "--- END Constructing new AbstractProfile object ... ---\n"); |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * join new attributes to existing ones, but only if not already defined on |
||
| 173 | * a different level in the existing set |
||
| 174 | * @param array $existing the already existing attributes |
||
| 175 | * @param array $new the new set of attributes |
||
| 176 | * @param string $newlevel the level of the new attributes |
||
| 177 | * @return array the new set of attributes |
||
| 178 | */ |
||
| 179 | protected function levelPrecedenceAttributeJoin($existing, $new, $newlevel) { |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * find a profile, given its realm |
||
| 196 | */ |
||
| 197 | public static function profileFromRealm($realm) { |
||
| 198 | // static, need to create our own handle |
||
| 199 | $handle = DBConnection::handle("INST"); |
||
| 200 | $execQuery = $handle->exec("SELECT profile_id FROM profile WHERE realm LIKE '%@$realm'"); |
||
| 201 | // a SELECT query always yields a resource, not a boolean |
||
| 202 | if ($profileIdQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $execQuery)) { |
||
| 203 | return $profileIdQuery->profile_id; |
||
| 204 | } |
||
| 205 | return FALSE; |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * Constructs the outer ID which should be used during realm tests. Obviously |
||
| 210 | * can only do something useful if the realm is known to the system. |
||
| 211 | * |
||
| 212 | * @return string the outer ID to use for realm check operations |
||
| 213 | * @thorws Exception |
||
| 214 | */ |
||
| 215 | public function getRealmCheckOuterUsername() { |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * update the last_changed timestamp for this profile |
||
| 237 | */ |
||
| 238 | public function updateFreshness() { |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * gets the last-modified timestamp (useful for caching "dirty" check) |
||
| 244 | */ |
||
| 245 | public function getFreshness() { |
||
| 250 | } |
||
| 251 | } |
||
| 252 | |||
| 253 | /** |
||
| 254 | * tests if the configurator needs to be regenerated |
||
| 255 | * returns the configurator path or NULL if regeneration is required |
||
| 256 | */ |
||
| 257 | /** |
||
| 258 | * This function tests if the configurator needs to be regenerated |
||
| 259 | * (properties of the Profile may have changed since the last configurator |
||
| 260 | * generation). |
||
| 261 | * SilverBullet will always return NULL here because all installers are new! |
||
| 262 | * |
||
| 263 | * @param string $device device ID to check |
||
| 264 | * @return mixed a string with the path to the configurator download, or NULL if it needs to be regenerated |
||
| 265 | */ |
||
| 266 | |||
| 267 | /** |
||
| 268 | * This function tests if the configurator needs to be regenerated (properties of the Profile may have changed since the last configurator generation). |
||
| 269 | * |
||
| 270 | * @param string $device device ID to check |
||
| 271 | * @return mixed a string with the path to the configurator download, or NULL if it needs to be regenerated |
||
| 272 | */ |
||
| 273 | public function testCache($device) { |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Updates database with new installer location. Actually does stuff when |
||
| 293 | * caching is possible; is a noop if not |
||
| 294 | * |
||
| 295 | * @param string $device the device identifier string |
||
| 296 | * @param string $path the path where the new installer can be found |
||
| 297 | * @param string $mime the mime type of the new installer |
||
| 298 | * @param int $integerEapType the inter-representation of the EAP type that is configured in this installer |
||
| 299 | */ |
||
| 300 | abstract public function updateCache($device, $path, $mime, $integerEapType); |
||
| 301 | |||
| 302 | /** |
||
| 303 | * Log a new download for our stats |
||
| 304 | * |
||
| 305 | * @param string $device the device id string |
||
| 306 | * @param string $area either admin or user |
||
| 307 | * @return boolean TRUE if incrementing worked, FALSE if not |
||
| 308 | */ |
||
| 309 | public function incrementDownloadStats($device, $area) { |
||
| 310 | if ($area == "admin" || $area == "user" || $area == "silverbullet") { |
||
| 311 | $lang = $this->languageInstance->getLang(); |
||
| 312 | $this->frontendHandle->exec("INSERT INTO downloads (profile_id, device_id, lang, downloads_$area) VALUES (? ,?, ?, 1) ON DUPLICATE KEY UPDATE downloads_$area = downloads_$area + 1", "iss", $this->identifier, $device, $lang); |
||
| 313 | // get eap_type from the downloads table |
||
| 314 | $eapTypeQuery = $this->frontendHandle->exec("SELECT eap_type FROM downloads WHERE profile_id = ? AND device_id = ? AND lang = ?", "iss", $this->identifier, $device, $lang); |
||
| 315 | // SELECT queries always return a resource, not a boolean |
||
| 316 | if (!$eapTypeQuery || !$eapO = mysqli_fetch_object(/** @scrutinizer ignore-type */ $eapTypeQuery)) { |
||
| 317 | $this->loggerInstance->debug(2, "Error getting EAP_type from the database\n"); |
||
| 318 | } else { |
||
| 319 | if ($eapO->eap_type == NULL) { |
||
| 320 | $this->loggerInstance->debug(2, "EAP_type not set in the database\n"); |
||
| 321 | } else { |
||
| 322 | $this->saveDownloadDetails($this->institution, $this->identifier, $device, $area, $this->languageInstance->getLang(), $eapO->eap_type); |
||
| 323 | } |
||
| 324 | } |
||
| 325 | return TRUE; |
||
| 326 | } |
||
| 327 | return FALSE; |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Retrieve current download stats from database, either for one specific device or for all devices |
||
| 332 | * @param string $device the device id string |
||
| 333 | * @return mixed user downloads of this profile; if device is given, returns the counter as int, otherwise an array with devicename => counter |
||
| 334 | */ |
||
| 335 | public function getUserDownloadStats($device = NULL) { |
||
| 336 | $columnName = "downloads_user"; |
||
| 337 | if ($this instanceof \core\ProfileSilverbullet) { |
||
| 338 | $columnName = "downloads_silverbullet"; |
||
| 339 | } |
||
| 340 | $returnarray = []; |
||
| 341 | $numbers = $this->frontendHandle->exec("SELECT device_id, SUM($columnName) AS downloads_user FROM downloads WHERE profile_id = ? GROUP BY device_id", "i", $this->identifier); |
||
| 342 | // SELECT queries always return a resource, not a boolean |
||
| 343 | while ($statsQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $numbers)) { |
||
| 344 | $returnarray[$statsQuery->device_id] = $statsQuery->downloads_user; |
||
| 345 | } |
||
| 346 | if ($device !== NULL) { |
||
| 347 | if (isset($returnarray[$device])) { |
||
| 348 | return $returnarray[$device]; |
||
| 349 | } |
||
| 350 | return 0; |
||
| 351 | } |
||
| 352 | // we should pretty-print the device names |
||
| 353 | $finalarray = []; |
||
| 354 | $devlist = \devices\Devices::listDevices(); |
||
| 355 | foreach ($returnarray as $devId => $count) { |
||
| 356 | if (isset($devlist[$devId])) { |
||
| 357 | $finalarray[$devlist[$devId]['display']] = $count; |
||
| 358 | } |
||
| 359 | } |
||
| 360 | return $finalarray; |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Deletes the profile from database and uninstantiates itself. |
||
| 365 | * Works fine also for Silver Bullet; the first query will simply do nothing |
||
| 366 | * because there are no stored options |
||
| 367 | * |
||
| 368 | */ |
||
| 369 | public function destroy() { |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Specifies the realm of this profile. |
||
| 377 | * |
||
| 378 | * Forcefully type-hinting $realm parameter to string - Scrutinizer seems to |
||
| 379 | * think that it can alternatively be an array<integer,?> which looks like a |
||
| 380 | * false positive. If there really is an issue, let PHP complain about it at |
||
| 381 | * runtime. |
||
| 382 | * |
||
| 383 | * @param string $realm the realm (potentially with the local@ part that should be used for anonymous identities) |
||
| 384 | */ |
||
| 385 | public function setRealm(string $realm) { |
||
| 386 | $this->databaseHandle->exec("UPDATE profile SET realm = ? WHERE profile_id = ?", "si", $realm, $this->identifier); |
||
| 387 | $this->realm = $realm; |
||
| 388 | } |
||
| 389 | |||
| 390 | /** |
||
| 391 | * register new supported EAP method for this profile |
||
| 392 | * |
||
| 393 | * @param \core\common\EAP $type The EAP Type, as defined in class EAP |
||
| 394 | * @param int $preference preference of this EAP Type. If a preference value is re-used, the order of EAP types of the same preference level is undefined. |
||
| 395 | * |
||
| 396 | */ |
||
| 397 | public function addSupportedEapMethod(\core\common\EAP $type, $preference) { |
||
| 398 | $this->databaseHandle->exec("INSERT INTO supported_eap (profile_id, eap_method_id, preference) VALUES (" |
||
| 399 | . $this->identifier . ", " |
||
| 400 | . $type->getIntegerRep() . ", " |
||
| 401 | . $preference . ")"); |
||
| 402 | $this->updateFreshness(); |
||
| 403 | } |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Produces an array of EAP methods supported by this profile, ordered by preference |
||
| 407 | * |
||
| 408 | * @param int $completeOnly if set and non-zero limits the output to methods with complete information |
||
| 409 | * @return array list of EAP methods, (in object representation) |
||
| 410 | */ |
||
| 411 | public function getEapMethodsinOrderOfPreference($completeOnly = 0) { |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Performs a sanity check for a given EAP type - did the admin submit enough information to create installers for him? |
||
| 427 | * |
||
| 428 | * @param common\EAP $eaptype the EAP type |
||
| 429 | * @return mixed TRUE if the EAP type is complete; an array of missing attribues if it's incomplete; FALSE if it's incomplete for other reasons |
||
| 430 | */ |
||
| 431 | public function isEapTypeDefinitionComplete($eaptype) { |
||
| 463 | } |
||
| 464 | |||
| 465 | /** |
||
| 466 | * list all devices marking their availabiblity and possible redirects |
||
| 467 | * |
||
| 468 | * @return array of device ids display names and their status |
||
| 469 | */ |
||
| 470 | public function listDevices() { |
||
| 544 | } |
||
| 545 | |||
| 546 | /** |
||
| 547 | * prepare profile attributes for device modules |
||
| 548 | * Gets profile attributes taking into account the most specific level on which they may be defined |
||
| 549 | * as wel as the chosen language. |
||
| 550 | * can be called with an optional $eap argument |
||
| 551 | * |
||
| 552 | * @param array $eap if specified, retrieves all attributes except those not pertaining to the given EAP type |
||
| 553 | * @return array list of attributes in collapsed style (index is the attrib name, value is an array of different values) |
||
| 554 | */ |
||
| 555 | public function getCollapsedAttributes($eap = []) { |
||
| 556 | $collapsedList = []; |
||
| 557 | foreach ($this->getAttributes() as $attribute) { |
||
| 558 | // filter out eap-level attributes not pertaining to EAP type $eap |
||
| 559 | if (count($eap) > 0 && isset($attrib['eapmethod']) && $attrib['eapmethod'] != 0 && $attrib['eapmethod'] != $eap) { |
||
| 560 | continue; |
||
| 561 | } |
||
| 562 | // create new array indexed by attribute name |
||
| 563 | $collapsedList[$attribute['name']][] = $attribute['value']; |
||
| 564 | // and keep all language-variant names in a separate sub-array |
||
| 565 | if ($attribute['flag'] == "ML") { |
||
| 566 | $collapsedList[$attribute['name']]['langs'][$attribute['lang']] = $attribute['value']; |
||
| 567 | } |
||
| 568 | } |
||
| 569 | // once we have the final list, populate the respective "best-match" |
||
| 570 | // language to choose for the ML attributes |
||
| 571 | foreach ($collapsedList as $attribName => $valueArray) { |
||
| 572 | if (isset($valueArray['langs'])) { // we have at least one language-dependent name in this attribute |
||
| 573 | // for printed names on screen: |
||
| 574 | // assign to exact match language, fallback to "default" language, fallback to English, fallback to whatever comes first in the list |
||
| 575 | $collapsedList[$attribName][0] = $valueArray['langs'][$this->languageInstance->getLang()] ?? $valueArray['langs']['C'] ?? $valueArray['langs']['en'] ?? array_shift($valueArray['langs']); |
||
| 576 | // for names usable in filesystems (closer to good old ASCII...) |
||
| 577 | // prefer English, otherwise the "default" language, otherwise the same that we got above |
||
| 578 | $collapsedList[$attribName][1] = $valueArray['langs']['en'] ?? $valueArray['langs']['C'] ?? $collapsedList[$attribName][0]; |
||
| 579 | } |
||
| 580 | } |
||
| 581 | |||
| 582 | return $collapsedList; |
||
| 583 | } |
||
| 584 | |||
| 585 | const READINESS_LEVEL_NOTREADY = 0; |
||
| 586 | const READINESS_LEVEL_SUFFICIENTCONFIG = 1; |
||
| 587 | const READINESS_LEVEL_SHOWTIME = 2; |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Does the profile contain enough information to generate installers with |
||
| 591 | * it? Silverbullet will always return TRUE; RADIUS profiles need to do some |
||
| 592 | * heavy lifting here. |
||
| 593 | * |
||
| 594 | * * @return int one of the constants above which tell if enough info is set to enable installers |
||
| 595 | */ |
||
| 596 | public function readinessLevel() { |
||
| 597 | $result = $this->databaseHandle->exec("SELECT sufficient_config, showtime FROM profile WHERE profile_id = ?", "i", $this->identifier); |
||
| 598 | // SELECT queries always return a resource, not a boolean |
||
| 599 | $configQuery = mysqli_fetch_row(/** @scrutinizer ignore-type */ $result); |
||
| 600 | if ($configQuery[0] == "0") { |
||
| 601 | return self::READINESS_LEVEL_NOTREADY; |
||
| 602 | } |
||
| 603 | // at least fully configured, if not showtime! |
||
| 604 | if ($configQuery[1] == "0") { |
||
| 605 | return self::READINESS_LEVEL_SUFFICIENTCONFIG; |
||
| 606 | } |
||
| 607 | return self::READINESS_LEVEL_SHOWTIME; |
||
| 608 | } |
||
| 609 | |||
| 610 | /** |
||
| 611 | * Checks if the profile has enough information to have something to show to end users. This does not necessarily mean |
||
| 612 | * that there's a fully configured EAP type - it is sufficient if a redirect has been set for at least one device. |
||
| 613 | * |
||
| 614 | * @return boolean TRUE if enough information for showtime is set; FALSE if not |
||
| 615 | */ |
||
| 616 | private function readyForShowtime() { |
||
| 617 | $properConfig = FALSE; |
||
| 618 | $attribs = $this->getCollapsedAttributes(); |
||
| 619 | // do we have enough to go live? Check if any of the configured EAP methods is completely configured ... |
||
| 620 | if (sizeof($this->getEapMethodsinOrderOfPreference(1)) > 0) { |
||
| 621 | $properConfig = TRUE; |
||
| 622 | } |
||
| 623 | // if not, it could still be that general redirect has been set |
||
| 624 | if (!$properConfig) { |
||
| 625 | if (isset($attribs['device-specific:redirect'])) { |
||
| 626 | $properConfig = TRUE; |
||
| 627 | } |
||
| 628 | // just a per-device redirect? would be good enough... but this is not actually possible: |
||
| 629 | // per-device redirects can only be set on the "fine-tuning" page, which is only accessible |
||
| 630 | // if at least one EAP type is fully configured - which is caught above and makes readyForShowtime TRUE already |
||
| 631 | } |
||
| 632 | // do we know at least one SSID to configure, or work with wired? If not, it's not ready... |
||
| 633 | if (!isset($attribs['media:SSID']) && |
||
| 634 | !isset($attribs['media:SSID_with_legacy']) && |
||
| 635 | (!isset(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) || count(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid']) == 0) && |
||
| 636 | !isset($attribs['media:wired'])) { |
||
| 637 | $properConfig = FALSE; |
||
| 638 | } |
||
| 639 | return $properConfig; |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * set the showtime property if prepShowTime says that there is enough info *and* the admin flagged the profile for showing |
||
| 644 | */ |
||
| 645 | public function prepShowtime() { |
||
| 646 | $properConfig = $this->readyForShowtime(); |
||
| 647 | $this->databaseHandle->exec("UPDATE profile SET sufficient_config = " . ($properConfig ? "TRUE" : "FALSE") . " WHERE profile_id = " . $this->identifier); |
||
| 648 | |||
| 649 | $attribs = $this->getCollapsedAttributes(); |
||
| 650 | // if not enough info to go live, set FALSE |
||
| 651 | // even if enough info is there, admin has the ultimate say: |
||
| 652 | // if he doesn't want to go live, no further checks are needed, set FALSE as well |
||
| 653 | if (!$properConfig || !isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) { |
||
| 654 | $this->databaseHandle->exec("UPDATE profile SET showtime = FALSE WHERE profile_id = ?", "i", $this->identifier); |
||
| 655 | return; |
||
| 656 | } |
||
| 657 | $this->databaseHandle->exec("UPDATE profile SET showtime = TRUE WHERE profile_id = ?", "i", $this->identifier); |
||
| 658 | } |
||
| 659 | |||
| 660 | /** |
||
| 661 | * internal helper - some attributes are added by the constructor "ex officio" |
||
| 662 | * without actual input from the admin. We can streamline their addition in |
||
| 663 | * this function to avoid duplication. |
||
| 664 | * |
||
| 665 | * @param array $internalAttributes - only names and value |
||
| 666 | * @return array full attributes with all properties set |
||
| 667 | */ |
||
| 668 | protected function addInternalAttributes($internalAttributes) { |
||
| 669 | // internal attributes share many attribute properties, so condense the generation |
||
| 670 | $retArray = []; |
||
| 671 | foreach ($internalAttributes as $attName => $attValue) { |
||
| 672 | $retArray[] = ["name" => $attName, |
||
| 673 | "lang" => NULL, |
||
| 674 | "value" => $attValue, |
||
| 675 | "level" => "Profile", |
||
| 676 | "row" => 0, |
||
| 677 | "flag" => NULL, |
||
| 678 | ]; |
||
| 679 | } |
||
| 680 | return $retArray; |
||
| 681 | } |
||
| 682 | |||
| 683 | /** |
||
| 684 | * Retrieves profile attributes stored in the database |
||
| 685 | * |
||
| 686 | * @return array The attributes in one array |
||
| 687 | */ |
||
| 688 | protected function addDatabaseAttributes() { |
||
| 695 | } |
||
| 696 | |||
| 697 | } |
||
| 698 |