Beispiel #1
0
 public static function getUserLibraries($userID)
 {
     return array_merge(array(Zotero_Users::getLibraryIDFromUserID($userID)), Zotero_Groups::getUserGroupLibraries($userID));
 }
Beispiel #2
0
 /**
  * Calculate the difference between two sets of permissions,
  * taking all-group access into account
  */
 private function permissionsDiff($permissions1, $permissions2, $userID)
 {
     $diff = [];
     $userGroupLibraries = Zotero_Groups::getUserGroupLibraries($userID);
     foreach ($permissions2 as $libraryID => $libraryPermissions) {
         if (!$libraryPermissions['library']) {
             continue;
         }
         if (empty($permissions1[$libraryID]['library'])) {
             // If second set has a 0 (all-group access), diff is user's groups not
             // explicitly listed in first set
             if ($libraryID === 0) {
                 $diff = array_merge($diff, array_filter($userGroupLibraries, function ($libraryID) use($permissions1) {
                     return empty($permissions1[$libraryID]['library']);
                 }));
             } else {
                 $libraryType = Zotero_Libraries::getType($libraryID);
                 if ($libraryType == 'user' || $libraryType == 'group' && empty($permissions1[0]['library'])) {
                     $diff[] = $libraryID;
                 }
             }
         }
     }
     return $diff;
 }