/** * Loads a list of MessageChannels * * @param int $start The number of the first channel which should be returned (SQL LIMIT) * @param int $count The number of channels which should be returned (SQL LIMIT) * * @return MessageChannel[] A list of MessageChannels. */ public function getChannels($start = 0, $count = 15) { $crit = new GenericCriterionObject(); $crit->addCountIndicator((int) $start, (int) $count); return $this->loadRelatedObjects('PostboxFolder2MessageChannel', $crit); }
/** * Checks the user's credentials. * * @param User $user The user to authenticate. * * @return boolean True in case, the user is allowed to login, false otherwise. * * @author Christian Achatz * @version * Version 0.1, 17.05.2009<br /> */ public function validateCredentials(User $user) { $authCrit = new GenericCriterionObject(); $authCrit->addPropertyIndicator('Username', $user->getUsername()); $authCrit->addPropertyIndicator('Password', md5($user->getPassword())); $gbUser = $this->orm->loadObjectByCriterion('User', $authCrit); return $gbUser !== null; }
/** * Removes the given user from the channel, if he is a reader. * If he is the last reader, the channel will be completely deleted. * * @param GenericORMapperDataObject $User The user which should be removed from the list of readers. * * @return AbstractMessageChannel Returns itself (fluent-interface) * @throws \BadFunctionCallException */ public function removeReader(GenericORMapperDataObject &$User) { if ($this->getDataComponent() === null) { throw new \BadFunctionCallException('[MessageChannel::removeReader()] DataComponent is not set, if the object was not loaded by ORM, you need to set it manually!'); } if ($this->getDataComponent()->isAssociated('User2MessageChannel', $User, $this)) { // If this user is the last reader, we delete the channel completely if (count($this->getReaders()) === 1) { $this->delete(); } else { // remove unread-relations $this->setReadForUser($User); // check if channel is in a folder from the given user and remove it from there if necessary $crit = new GenericCriterionObject(); $crit->addRelationIndicator('User2PostboxFolder', $User); /* @var $folder AbstractPostboxFolder */ $folder = $this->loadRelatedObject('PostboxFolder2MessageChannel', $crit); if ($folder !== null) { $folder->removeChannel($this); } // finally remove the relation between user and channel $this->getDataComponent()->deleteAssociation('User2MessageChannel', $User, $this); } } return $this; }
/** * Loads the user by the generated ForgotPasswordHash * * @param string $hash The hash to reset the password * * @return UmgtUser|null The corresponding user or null if the user cannot be found. * * @author dave * @version * Version 0.1, 29.10.15<br /> */ public function loadUserByForgotPasswordHash($hash) { $crit = new GenericCriterionObject(); $crit->addPropertyIndicator('ForgotPasswordHash', $hash); return $this->getORMapper()->loadObjectByCriterion('User', $crit); }
/** * Counts the News which exist for the given application key. * * @param string $appKey Optional. Default: Current context. The application identifier, which is used to differentiate different news instances. * * @return int The number of existing news. */ public function getNewsCount($appKey = null) { if ($appKey === null) { $appKey = $this->getContext(); } $crit = new GenericCriterionObject(); $crit->addPropertyIndicator('AppKey', $appKey); return $this->ORM->loadObjectCount('News', $crit); }
/** * Loads the RecipientList with the given name, which belongs to the user. * * @param string $Name The name of the list which should be loaded * * @return RecipientList */ public function getRecipientListByName($Name) { $crit = new GenericCriterionObject(); $crit->addPropertyIndicator('Name', $Name); return $this->User->loadRelatedObject('User2RecipientList', $crit); }