Beispiel #1
0
 /**
  * Creates a visibility definition relating an application proxy object to the users and
  * groups, that should have access to the object.
  *
  * @param UmgtVisibilityDefinitionType $type The visibility type (object type of application's the target object).
  * @param UmgtVisibilityDefinition $definition The visibility definition (object id of application's the target object).
  * @param UmgtUser[] $users The list of users, that should have visibility permissions on the given application object.
  * @param UmgtGroup[] $groups The list of groups, that should have visibility permissions on the given application object.
  *
  * @return int The id of the desired visibility definition.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 26.05.2010<br />
  */
 public function createVisibilityDefinition(UmgtVisibilityDefinitionType $type, UmgtVisibilityDefinition $definition, array $users = [], array $groups = [])
 {
     $orm = $this->getORMapper();
     // try to reuse existing visibility definitions having the same
     // combination of proxy + type!
     $criterion = new GenericCriterionObject();
     $criterion->addPropertyIndicator('AppObjectId', $definition->getAppObjectId());
     $criterion->addRelationIndicator('AppProxy2AppProxyType', $type);
     // Allow best balance between creating new visibility definitions for proxy id, proxy type, and permission setup.
     // For details on the discussion, please refer to http://forum.adventure-php-framework.org/viewtopic.php?f=1&t=5387.
     $criterion->addPropertyIndicator('ReadPermission', $definition->getReadPermission());
     $criterion->addPropertyIndicator('WritePermission', $definition->getWritePermission());
     $criterion->addPropertyIndicator('LinkPermission', $definition->getLinkPermission());
     $criterion->addPropertyIndicator('DeletePermission', $definition->getDeletePermission());
     $storedVisibilityDefinition = $orm->loadObjectByCriterion('AppProxy', $criterion);
     if ($storedVisibilityDefinition !== null) {
         $definition = $storedVisibilityDefinition;
     }
     // append proxy to current application
     $app = $this->getCurrentApplication();
     $definition->addRelatedObject('Application2AppProxy', $app);
     // create domain structure
     $definition->addRelatedObject('AppProxy2AppProxyType', $type);
     foreach ($users as $id => $DUMMY) {
         $definition->addRelatedObject('AppProxy2User', $users[$id]);
     }
     foreach ($groups as $id => $group) {
         $definition->addRelatedObject('AppProxy2Group', $groups[$id]);
     }
     // save domain structure
     return $orm->saveObject($definition);
 }