Módulo VPSManager para WHMCS con configuración externa, acceso seguro al panel y métricas Graphite para LX.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

38 lines
1.5 KiB

  1. <?php
  2. namespace VPSManager;
  3. final class BackupOption
  4. {
  5. public const NAMES = ['Backup diario', 'Backup diario VPS'];
  6. // Resolve only groups linked to the product of the authorized service.
  7. // Definitions describe applicable options; they never prove subscription.
  8. public static function applicable($productId): array
  9. {
  10. $groups = \WHMCS\Database\Capsule::table('tblproductconfiglinks')->where('pid', $productId)->get();
  11. $seenGroups = []; $keys = [];
  12. foreach ($groups as $link) {
  13. if (isset($seenGroups[$link->gid])) continue;
  14. $seenGroups[$link->gid] = true;
  15. $options = \WHMCS\Database\Capsule::table('tblproductconfigoptions')->where('gid', $link->gid)->get();
  16. foreach ($options as $option) {
  17. if (!in_array($option->optionname, self::NAMES, true)) continue;
  18. // Only the confirmed Yes/No definition type is supported. This is NOT activation.
  19. if (!in_array($option->optiontype, [3, '3'], true) || in_array($option->optionname, $keys, true)) {
  20. throw new \RuntimeException('OPTION_DEFINITION');
  21. }
  22. $keys[] = $option->optionname;
  23. }
  24. }
  25. sort($keys, SORT_STRING);
  26. return $keys;
  27. }
  28. public static function conflict(array $options): bool
  29. {
  30. return array_key_exists(self::NAMES[0], $options) && array_key_exists(self::NAMES[1], $options)
  31. && $options[self::NAMES[0]] !== $options[self::NAMES[1]];
  32. }
  33. }