public function saveData($aGroupData) { if ($this->iGroupId === null) { $oGroup = new Group(); } else { $oGroup = GroupQuery::create()->findPk($this->iGroupId); } $oGroup->setName($aGroupData['name']); if ($oGroup->isNew() && count(self::$ROLES) > 0) { foreach (self::$ROLES as $sRoleKey) { $oGroupRole = new GroupRole(); $oGroupRole->setRoleKey($sRoleKey); $oGroup->addGroupRole($oGroupRole); } } else { foreach ($oGroup->getGroupRoles() as $oGroupRole) { $oGroupRole->delete(); } foreach ($aGroupData['roles'] as $sRoleKey) { $oGroupRole = new GroupRole(); $oGroupRole->setRoleKey($sRoleKey); $oGroup->addGroupRole($oGroupRole); } } return $oGroup->save(); }
/** * Return all groups, converted it names to role names. * * @return string[] * @throws \Propel\Runtime\Exception\PropelException */ public function getGroupRoles() { $names = GroupQuery::create()->select('Name')->filterByUser($this)->find(); $result = []; foreach ($names as $name) { $result[] = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($name)); } return $result; }
public function getGroupName() { if ($this->oDelegateProxy->getGroupId() !== CriteriaListWidgetDelegate::SELECT_ALL) { $oGroup = GroupQuery::create()->findPk($this->oDelegateProxy->getGroupId()); if ($oGroup) { return $oGroup->getName(); } } return $this->oDelegateProxy->getGroupId(); }
public function getGroupName() { $oGroup = GroupQuery::create()->findPk($this->oDelegateProxy->getGroupId()); if ($oGroup) { return $oGroup->getName(); } if ($this->oDelegateProxy->getGroupId() === CriteriaListWidgetDelegate::SELECT_WITHOUT) { return TranslationPeer::getString('wns.users.without_category'); } return $this->oDelegateProxy->getGroupId(); }
/** * Get the associated Group object * * @param PropelPDO Optional Connection object. * @return Group The associated Group object. * @throws PropelException */ public function getGroup(PropelPDO $con = null) { if ($this->aGroup === null && $this->group_id !== null) { $this->aGroup = GroupQuery::create()->findPk($this->group_id); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aGroup->addDirectoryPermissions($this); */ } return $this->aGroup; }
public function allGroups() { return WidgetJsonFileModule::jsonBaseObjects(GroupQuery::create()->orderByName()->find(), array('id', 'name')); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = GroupQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(GroupPeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "users"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Returns the number of related Group objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Group objects. * @throws PropelException */ public function countGroupsRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collGroupsRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collGroupsRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupsRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getGroupsRelatedByUpdatedBy()); } $query = GroupQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collGroupsRelatedByUpdatedBy); }
public function addGroup($mGroup) { if (!$mGroup instanceof Group) { $mGroup = GroupQuery::create()->createOrFindByName($mGroup); } if (!$this->hasGroup($mGroup)) { $oUserGroup = new UserGroup(); $oUserGroup->setUserRelatedByUserId($this); $oUserGroup->setGroup($mGroup); } return $mGroup; }