|
|
@@ -212,6 +212,101 @@ class SyncUsers {
|
|
|
return $groupsTodo;
|
|
|
}
|
|
|
|
|
|
+ public function getSyncGroupTodoList($groupID, $syncNestedGroups = false) {
|
|
|
+ $syncTodoList = array();
|
|
|
+ $groupFrom = $this->_fromStorage->getGroup($groupID);
|
|
|
+ $groupTo = $this->_toStorage->getGroup($groupID);
|
|
|
+
|
|
|
+ if (!$groupFrom) {
|
|
|
+ $syncTodoList[] = "Group {$groupID} not exists in fromStorage";
|
|
|
+ return $syncTodoList;
|
|
|
+ }
|
|
|
+ else if (!$groupTo) {
|
|
|
+ $syncTodoList[] = "Create group {$groupID} in toStorage";
|
|
|
+ return $syncTodoList;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $updateData = array();
|
|
|
+ if (empty($groupTo->realName) && $groupFrom->realName != $groupTo->realName) {
|
|
|
+ $updateData['realName'] = $groupFrom->realName;
|
|
|
+ }
|
|
|
+ foreach ($updateData as $key => $val) {
|
|
|
+ $syncTodoList[] = "Update {$key}: {$val}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($syncNestedGroups) {
|
|
|
+ if (!empty($groupTo->nestedGroups) || !empty($groupFrom->nestedGroups)) {
|
|
|
+ $groupsTodo = array();
|
|
|
+ if (!empty($groupTo->nestedGroups)) {
|
|
|
+ foreach ($groupTo->nestedGroups as $kUid => $vGroup) {
|
|
|
+ $groupsTodo[$kUid] = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($groupFrom->nestedGroups)) {
|
|
|
+ foreach ($groupFrom->nestedGroups as $kUid => $vGroup) {
|
|
|
+ if (isset($groupsTodo[$kUid])) {
|
|
|
+ unset($groupsTodo[$kUid]);
|
|
|
+ } else {
|
|
|
+ $groupsTodo[$kUid] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($groupsTodo)) {
|
|
|
+ foreach ($groupsTodo as $kGroupID => $vBool) {
|
|
|
+ if ($vBool) {
|
|
|
+ $syncTodoList[] = "Add group '{$kGroupID}' to group '{$groupID}' in toStorage";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $syncTodoList[] = "Remove group '{$kGroupID}' from group '{$groupID}' in toStorage";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $fromParentGroups = $groupFrom->getParentGroups();
|
|
|
+ $toParentGroups = $groupTo->getParentGroups();
|
|
|
+
|
|
|
+ {
|
|
|
+ $groupsTodo = array();
|
|
|
+ if (!empty($toParentGroups)) {
|
|
|
+ foreach ($toParentGroups as $kUid => $vGroup) {
|
|
|
+ $groupsTodo[$kUid] = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($fromParentGroups)) {
|
|
|
+ foreach ($fromParentGroups as $kUid => $vGroup) {
|
|
|
+ if (isset($groupsTodo[$kUid])) {
|
|
|
+ unset($groupsTodo[$kUid]);
|
|
|
+ } else {
|
|
|
+ $groupsTodo[$kUid] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($groupsTodo)) {
|
|
|
+ foreach ($groupsTodo as $kGroupID => $vBool) {
|
|
|
+ if ($vBool) {
|
|
|
+ $syncTodoList[] = "Add parent group '{$kGroupID}' to group '{$groupID}' in toStorage";// == add $groupID to $kGroupID
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $groupTest = $this->_fromStorage->getGroup($kGroupID);
|
|
|
+ if ($groupTest) {
|
|
|
+ $syncTodoList[] = "Remove parent group '{$kGroupID}' from group '{$groupID}' in toStorage";// == remove $groupID from $kGroupID
|
|
|
+ } else {
|
|
|
+ //$syncTodoList[] = "Keep parent group '{$kGroupID}' in group '{$groupID}' in toStorage, because that group dont exists in fromStorage";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $syncTodoList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Sync user.
|
|
|
*
|