Example #1
0
 public static function syncRelations($entityguid, $userid, $relations = array())
 {
     $entityname = EntityTypes::getTypeByGuid($entityguid);
     if ($entityname === null) {
         throw new Exception("Object entity type not found for relation");
     }
     $relids = EntityRelations::relateReverseEntity($entityguid, "organization", $userid, $relations);
     EntityRelations::unrelateAll($entityguid, $relids, true, EntityRelations::getRelationTypePairIDs("organization", $entityname));
     $relids = EntityRelations::relateReverseEntity($entityguid, "project", $userid, $relations);
     EntityRelations::unrelateAll($entityguid, $relids, true, EntityRelations::getRelationTypePairIDs("project", $entityname));
     $relids = EntityRelations::relateDirectEntity($entityguid, "software", $userid, $relations);
     EntityRelations::unrelateAll($entityguid, $relids, false, EntityRelations::getRelationTypePairIDs($entityname, "software"));
     if ($entityname !== 'swappliance') {
         //vappliance realtions to swappliance is done by the backend
         $relids = EntityRelations::relateDirectEntity($entityguid, "vappliance", $userid, $relations);
         EntityRelations::unrelateAll($entityguid, $relids, false, EntityRelations::getRelationTypePairIDs($entityname, "vappliance"));
     }
 }