Ejemplo n.º 1
0
 /**
  * Loads all the granted group G2 permissions for a specific
  * album and returns an array with G3 groups ids and G3 permission ids.
  */
 private static function _map_permissions($g2_album_id)
 {
     $g2_permissions = g2(GalleryCoreApi::fetchAllPermissionsForItem($g2_album_id));
     $permissions = array();
     foreach ($g2_permissions as $entry) {
         // @todo Do something about user permissions? E.g. map G2's user albums
         //       to a user-specific group in G3?
         if (!isset($entry["groupId"])) {
             continue;
         }
         $g2_permission_id = $entry["permission"];
         if (!isset(self::$_permission_map[$g2_permission_id])) {
             continue;
         }
         $group_id = self::map($entry["groupId"]);
         if ($group_id == null) {
             // E.g. the G2 admin group isn't mapped.
             continue;
         }
         $permission_id = self::$_permission_map[$g2_permission_id];
         if (!isset($permissions[$group_id])) {
             $permissions[$group_id] = array();
         }
         $permissions[$group_id][$permission_id] = 1;
     }
     return $permissions;
 }