public function transformContent()
 {
     $form = $this->getForm('Groups');
     $uM = $this->getManager();
     $user = $uM->loadUserByID($this->getRequest()->getParameter('userid'));
     $groups = $uM->loadGroupsNotWithUser($user);
     if (count($groups) === 0) {
         $tmpl = $this->getTemplate('NoMoreGroups');
         $tmpl->getLabel('message-1')->setPlaceHolder('display-name', $user->getDisplayName());
         $tmpl->getLabel('message-2')->setPlaceHolder('user-view-link', $this->generateLink(['mainview' => 'user', 'groupview' => null, 'userid' => null]));
         $tmpl->transformOnPlace();
         return;
     }
     $groupsControl = $form->getFormElementByName('Groups');
     /* @var $groupsControl MultiSelectBoxTag */
     foreach ($groups as $group) {
         $groupsControl->addOption($group->getDisplayName(), $group->getObjectId());
     }
     if ($form->isSent() && $form->isValid()) {
         $options = $groupsControl->getSelectedOptions();
         $additionalGroups = [];
         foreach ($options as $option) {
             /* @var $option SelectBoxOptionTag */
             $additionalGroup = new UmgtGroup();
             $additionalGroup->setObjectId($option->getValue());
             $additionalGroups[] = $additionalGroup;
             unset($additionalGroup);
         }
         $uM->attachUser2Groups($user, $additionalGroups);
         // back to user main view
         $this->getResponse()->forward($this->generateLink(['mainview' => 'user', 'groupview' => null, 'userid' => null]));
     } else {
         $form->transformOnPlace();
     }
 }
 public function transformContent()
 {
     $form = $this->getForm('GroupAdd');
     if ($form->isSent() && $form->isValid()) {
         $uM = $this->getManager();
         $group = new UmgtGroup();
         $displayName = $form->getFormElementByName('DisplayName');
         $group->setDisplayName($displayName->getValue());
         $description = $form->getFormElementByName('Description');
         $group->setDescription($description->getValue());
         $uM->saveGroup($group);
         // redirect to the desired view
         $this->getResponse()->forward($this->generateLink(['mainview' => 'group', 'groupview' => '']));
     }
     $form->transformOnPlace();
 }
 public function transformContent()
 {
     // initialize the form
     $form = $this->getForm('User');
     $userControl = $form->getFormElementByName('User');
     /* @var $userControl MultiSelectBoxTag */
     $groupId = $this->getRequest()->getParameter('groupid');
     $uM = $this->getManager();
     $group = $uM->loadGroupByID($groupId);
     $users = $uM->loadUsersWithGroup($group);
     $count = count($users);
     // display hint, if no user is assigned to this group
     if ($count == 0) {
         $template = $this->getTemplate('NoMoreUser');
         $template->getLabel('message-1')->setPlaceHolder('display-name', $group->getDisplayName());
         $template->getLabel('message-2')->setPlaceHolder('group-view-link', $this->generateLink(['mainview' => 'group', 'groupview' => null, 'groupid' => null]));
         $template->transformOnPlace();
         return;
     }
     // fill the multiselect field
     for ($i = 0; $i < $count; $i++) {
         $userControl->addOption($users[$i]->getLastName() . ', ' . $users[$i]->getFirstName(), $users[$i]->getObjectId());
     }
     // remove the desired users
     if ($form->isSent() && $form->isValid()) {
         $options = $userControl->getSelectedOptions();
         $users = [];
         for ($i = 0; $i < count($options); $i++) {
             $user = new UmgtUser();
             $user->setObjectId($options[$i]->getAttribute('value'));
             $users[] = $user;
             unset($user);
         }
         $group = new UmgtGroup();
         $group->setObjectId($groupId);
         $uM->detachUsersFromGroup($users, $group);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'group', 'groupview' => null, 'groupid' => null]));
     } else {
         $form->transformOnPlace();
     }
 }
 public function transformContent()
 {
     // get the group id from the request
     $groupId = $this->getRequest()->getParameter('groupid');
     // load the current group and print the display name
     $uM = $this->getManager();
     $group = $uM->loadGroupByID($groupId);
     $this->getLabel('display-name')->setPlaceHolder('display-name', $group->getDisplayName());
     // prepare the forms and execute action
     $formNo = $this->getForm('GroupDelNo');
     $formYes = $this->getForm('GroupDelYes');
     $response = $this->getResponse();
     if ($formYes->isSent()) {
         $group = new UmgtGroup();
         $group->setObjectId($groupId);
         $uM->deleteGroup($group);
         $response->forward($this->generateLink(['mainview' => 'group', 'groupview' => '', 'groupid' => '']));
     } elseif ($formNo->isSent()) {
         $response->forward($this->generateLink(['mainview' => 'group', 'groupview' => '', 'groupid' => '']));
     } else {
         $formNo->transformOnPlace();
         $formYes->transformOnPlace();
     }
 }
Beispiel #5
0
 /**
  * Saves a group object within the current application.
  *
  * @param UmgtGroup $group current group.
  *
  * @return int The id of the group.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 15.06.2008<br />
  */
 public function saveGroup(UmgtGroup &$group)
 {
     $app = $this->getCurrentApplication();
     $group->addRelatedObject('Application2Group', $app);
     return $this->getORMapper()->saveObject($group);
 }
 public function transformContent()
 {
     $uM = $this->getManager();
     $form = $this->getForm('visibilitydef');
     // pre-fill mode if "proxytypeid" and "appobjectid" are given
     $request = $this->getRequest();
     $proxyTypeId = $request->getParameter('proxytypeid');
     $appObjectId = $request->getParameter('appobjectid');
     $proxyId = $request->getParameter('proxyid');
     $selectedUsers = [];
     $selectedGroups = [];
     if ($proxyTypeId != null && $appObjectId != null) {
         $proxy = new UmgtVisibilityDefinition();
         $proxy->setObjectId($proxyId);
         $selectedUsers = $uM->loadUsersWithVisibilityDefinition($proxy);
         $selectedGroups = $uM->loadGroupsWithVisibilityDefinition($proxy);
     }
     // load the defined visibility types
     $proxyTypes = $uM->loadVisibilityDefinitionTypes();
     /* @var $typeElement SelectBoxTag */
     $typeElement = $form->getFormElementByName('proxytypeid');
     foreach ($proxyTypes as $proxyType) {
         $typeElement->addOption($proxyType->getAppObjectName(), $proxyType->getObjectId());
     }
     // load users
     $userList = $uM->getPagedUserList();
     /* @var $usersElement MultiSelectBoxTag */
     $usersElement = $form->getFormElementByName('users');
     foreach ($userList as $user) {
         $usersElement->addOption($user->getDisplayName(), $user->getObjectId());
     }
     foreach ($selectedUsers as $selectedUser) {
         $usersElement->setOption2Selected($selectedUser->getObjectId());
     }
     // load groups
     $groups = $uM->getPagedGroupList();
     /* @var $groupsElement MultiSelectBoxTag */
     $groupsElement = $form->getFormElementByName('groups');
     foreach ($groups as $group) {
         $groupsElement->addOption($group->getDisplayName(), $group->getObjectId());
     }
     foreach ($selectedGroups as $selectedGroup) {
         $groupsElement->setOption2Selected($selectedGroup->getObjectId());
     }
     // store visibility definition
     if ($form->isSent() && $form->isValid()) {
         // setup type
         $type = new UmgtVisibilityDefinitionType();
         $type->setObjectId($typeElement->getSelectedOption()->getAttribute('value'));
         // setup proxy
         $definition = new UmgtVisibilityDefinition();
         $definition->setAppObjectId($form->getFormElementByName('appobjectid')->getAttribute('value'));
         // setup users
         $users = [];
         foreach ($usersElement->getSelectedOptions() as $option) {
             $user = new UmgtUser();
             $user->setObjectId($option->getAttribute('value'));
             $users[] = $user;
             unset($user);
         }
         // setup groups
         $groups = [];
         foreach ($groupsElement->getSelectedOptions() as $option) {
             $group = new UmgtGroup();
             $group->setObjectId($option->getAttribute('value'));
             $groups[] = $group;
             unset($group);
         }
         // setup access permissions
         $definition->setReadPermission($form->getFormElementByID('read-perm')->isChecked() ? 1 : 0);
         $definition->setWritePermission($form->getFormElementByID('write-perm')->isChecked() ? 1 : 0);
         $definition->setLinkPermission($form->getFormElementByID('link-perm')->isChecked() ? 1 : 0);
         $definition->setDeletePermission($form->getFormElementByID('delete-perm')->isChecked() ? 1 : 0);
         $uM->createVisibilityDefinition($type, $definition, $users, $groups);
         $this->getResponse()->forward($this->generateLink(['mainview' => 'proxy', 'proxyview' => null, 'proxytypeid' => null]));
     } else {
         $form->transformOnPlace();
     }
 }