/** * Remove a principal from a group. * * @param IPrincipal $principal * @param IGroup $group * @throws EyeUMException User not found or group not found. */ public function removeFromGroup(IPrincipal $principal, IGroup $group) { if (!$principal instanceof AbstractEyeosPrincipal) { throw new EyeInvalidArgumentException($principal); } if (!$group instanceof AbstractEyeosGroup) { throw new EyeInvalidArgumentException($group); } if ($principal instanceof IUser && $group->getId() == $principal->getPrimaryGroupId()) { $userExists = true; try { $this->getUserById($principal->getId()); } catch (EyeNoSuchUserException $e) { $userExists = false; } if ($userExists) { throw new EyeUnsupportedOperationException('Cannot unassign a user from its primary group, try updating instead.'); } } $assignation = new EyeosPrincipalGroupAssignation(); $assignation->setPrincipalId($principal->getId()); $assignation->setGroupId($group->getId()); $assignation = current($this->eyeosDAO->search($assignation)); SecurityManager::getInstance()->checkPermission($assignation, new SimplePermission($group->getName(), array('removeFromGroup'))); try { $this->eyeosDAO->delete($assignation); } catch (Exception $e) { throw new EyeUMException('Unable to remove principal "' . $principal->getName() . '" from group "' . $group->getName() . '".', 0, $e); } }
public function retrieveAllGroupCalendarsFromOwner(IPrincipal $principal) { return self::convertResultsToCalendarObjects($this->retrieveGroupCalendar($principal->getId())); }
public function retrieveAllCalendarsFromOwner(IPrincipal $principal) { return self::convertResultsToCalendarObjects($this->retrieveAllCalendarsWithFilter(array(CalendarManager::CALENDAR_KEY_OWNERID => $principal->getId()))); }
public function getTag(IPrincipal $principal, ITag $tag) { try { $tag = $this->getProvider()->getTag($principal->getId(), $tag); } catch (Exception $e) { self::$Logger->error('Unable to retrieve tags from object from principal "' . $principal . '": ' . $e->getMessage()); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false)); } throw $e; } SecurityManager::getInstance()->checkPermission($tag, new SimplePermission(null, array('read'), $principal)); }
/** * Updates the information of a principal. * * @param IPrincipal $principal * @throws EyeUMException Principal not found. */ public function updatePrincipal(IPrincipal $principal) { $oldPrincipal = self::getPrincipalById($principal->getId()); self::getPrincipalsManagerInstance()->updatePrincipal($principal); $event = new UMEvent($principal, $oldPrincipal); if ($principal instanceof IUser) { $this->logger->info('User updated: ' . $principal); $this->fireEvent('userUpdated', $event); } else { if ($principal instanceof IWorkgroup) { $this->logger->info('Workgroup updated: ' . $principal); $this->fireEvent('workgroupUpdated', $event); } else { if ($principal instanceof IGroup) { $this->logger->info('Group updated: ' . $principal); $this->fireEvent('groupUpdated', $event); } } } }