ObjectGroup.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * $group->primaryKey
  4. * $group->realName realName eg. "[123] Grupa 123"
  5. * $group->nestedGroups
  6. * $group->type 'STANOWISKO','PODMIOT','DZIAL','local','network'
  7. * (optional) $group->zasobID
  8. * (optional) $group->zasobDESC
  9. */
  10. class ObjectGroup {
  11. public $primaryKey;
  12. public $realName;
  13. public $type;// 'STANOWISKO','PODMIOT','DZIAL','local','network'
  14. // 'local' - access groups like com.apple.access_mail
  15. // 'network' - network group: workgroup
  16. public $nestedGroups;
  17. public $parentGroups = null;
  18. public $zasobID;// (optional)
  19. public $zasobDESC;// (optional)
  20. protected $_storageName;
  21. public function __construct($storageName) {
  22. // TODO: only storage name (clientType) 'DB', 'MacOSX'
  23. // $usrStorageDB = UserStorageFactory::getStorage('DB');
  24. // $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
  25. $this->_storageName = $storageName;
  26. }
  27. public function getParentGroups() {
  28. if (null === $this->parentGroups) {
  29. $this->parentGroups = $this->getStorage()->getParentGroups($this);
  30. }
  31. return $this->parentGroups;
  32. }
  33. public function getStorage() {
  34. $storage = UserStorageFactory::getStorage($this->_storageName);
  35. if (!$storage) {
  36. throw new Exception("Storage '{$this->_storageName}' not exists!");
  37. }
  38. return $storage;
  39. }
  40. public function exportData() {
  41. $data = new stdClass();
  42. $data->primaryKey = $this->primaryKey;
  43. $data->realName = $this->realName;
  44. $data->type = $this->type;
  45. $data->nestedGroups = $this->nestedGroups;
  46. $data->parentGroups = $this->parentGroups;
  47. $data->zasobID = $this->zasobID;
  48. $data->zasobDESC = $this->zasobDESC;
  49. return $data;
  50. }
  51. }