public function userCanEditSection(UserInterface $user, Section $section) { if ($user->getId() == $section->user_id) { return true; } return false; }
public function getObjectForUser(\ZfcUser\Entity\UserInterface $user) { if (!$this->getSession()->offsetExists("U{$user->getId()}")) { return new \stdClass(); } return $this->getSession()->offsetGet("U{$user->getId()}"); }
/** * @param \ZfcUser\Entity\UserInterface $entity */ public function remove($entity) { $this->getEventManager()->trigger('remove.pre', $this, array('entity' => $entity)); $id = $entity->getId(); $this->delete(array('user_id' => $id)); $this->getEventManager()->trigger('remove', $this, array('entity' => $entity)); }
/** * * @param UserInterface $user * @return void|\Zend\Db\Adapter\Driver\ResultInterface */ public function deleteUser(UserInterface $user) { if (!($id = $user->getId())) { return; } return $this->delete('user_id = ' . $id); }
/** * {@inheritDoc} */ public function findByUser(UserInterface $user) { $select = $this->getSelect(); $select->where(array('user_id' => $user->getId())); $entity = $this->select($select)->current(); if ($entity instanceof UserRegistrationInterface) { $entity->setUser($user); } return $entity; }
/** * Reset the password * * @param PasswordEntity $passwordEntity * @param UserInterface $user * @param array $data * @return boolean */ public function resetPassword(PasswordEntity $passwordEntity, UserInterface $user, array $data) { $newPass = $data['newCredential']; $bcrypt = new Bcrypt(); $bcrypt->setCost($this->getZfcUserOptions()->getPasswordCost()); $pass = $bcrypt->create($newPass); $user->setPassword($pass); $this->getEventManager()->trigger(__FUNCTION__, $this, ['user' => $user]); $this->getEntityManager()->remove($passwordEntity); $this->getEntityManager()->flush(); $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, ['user' => $user]); return true; }
/** * @param UserInterface $user * @param Hybrid_User_Profile $hybridUserProfile * @param string $provider * @param array $accessToken */ public function linkUserToProvider(UserInterface $user, Hybrid_User_Profile $hybridUserProfile, $provider, array $accessToken = null) { $userProvider = $this->findUserByProviderId($hybridUserProfile->identifier, $provider); if (false != $userProvider) { if ($user->getId() == $userProvider->getUserId()) { // already linked return; } throw new Exception\RuntimeException('This ' . ucfirst($provider) . ' profile is already linked to another user.'); } $userProvider = clone $this->getEntityPrototype(); $userProvider->setUserId($user->getId())->setProviderId($hybridUserProfile->identifier)->setProvider($provider); $this->insert($userProvider); }
protected function processDate(Parameters $data, UserInterface $user, $parentId) { if (isset($data['id']) && empty($data['id'])) { unset($data['id']); } if (isset($data['submit'])) { unset($data['submit']); } if (!empty($parentId)) { $data['parent_id'] = $parentId; } $data['user_id'] = $user->getId(); return $data; }
/** * @param string $setting * @param UserInterface $user * @return SettingValue */ public function getUserSetting($setting, UserInterface $user) { return $this->entityManager->getRepository("Eye4web\\ZfcUser\\Settings\\Entity\\SettingValue")->findOneBy(['user' => $user->getId(), 'setting' => $setting]); }
protected function updateUserPasswordHash(UserEntity $user, $password, Bcrypt $bcrypt) { $hash = explode('$', $user->getPassword()); if ($hash[2] === $bcrypt->getCost()) { return; } $user = $this->getHydrator()->hydrate(compact('password'), $user); $this->getMapper()->update($user); }
/** * @param ConversationInterface $conversation * @param string $messageText * @param UserInterface $user * @return MessageInterface */ public function newMessage(ConversationInterface $conversation, $messageText, UserInterface $user) { $this->getEventManager()->trigger('newMessage.pre', $this, ['conversation' => $conversation, 'message' => $messageText, 'user' => $user]); $message = clone $this->getMessageEntity(); // Call __construct to generate a new id $message->__construct(); $message->setMessage($messageText); $message->setFrom($user->getId()); $message->setConversation($conversation); $message = $this->pmMapper->newMessage($message); $this->markUnread($conversation); // Mark it read for the sending user $this->markRead($conversation, $user); $this->getEventManager()->trigger('newMessage', $this, ['conversation' => $conversation, 'message' => $message, 'user' => $user]); return $message; }
/** * Set user * * @param UserInterface $user * @return RoleLinker */ public function setUser(UserInterface $user) { $this->setUserId($user->getId()); return $this; }
/** * @param ConversationInterface $conversation * @param UserInterface $user * @return bool */ public function isUnread(ConversationInterface $conversation, UserInterface $user) { $this->getEventManager()->trigger('isUnread.pre', $this, ['conversation' => $conversation, 'user' => $user]); $repository = $this->objectManager->getRepository($this->options->getConversationReceiverEntity()); $conversationReceiver = $repository->findOneBy(['conversation' => $conversation->getId(), 'to' => $user->getId()]); $unread = $conversationReceiver->getUnread(); $this->getEventManager()->trigger('isUnread', $this, ['conversation' => $conversation, 'unread' => $unread]); return $unread; }
/** * Gets path to image of a user(without extension(png)) * * @return string */ public function getUserImageWithoutExtension(UserInterface $user) { return $this->getUploadDirectory() . '/' . $user->getId(); }
/** * stores User data to prevent from querying to database * it only queries one time for a user * * @param User $user * @return void */ protected function setUser(UserInterface $user) { $this->retrievedUsers[$user->getId()] = $user; }
/** * @param UserInterface $user * @return array */ public function findProvidersByUser(UserInterface $user) { $er = $this->em->getRepository($this->options->getUserProviderEntityClass()); $entities = $er->findBy(array('userId' => $user->getId())); $return = array(); foreach ($entities as $entity) { $return[$entity->getProvider()] = $entity; $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); } return $return; }
/** * Finds roles by user * * @param UserInterface $user */ public function findByUser(UserInterface $user) { return $this->findByUserId($user->getId()); }
public function findByUser(UserInterface $user) { return $user->getUserRegistration(); }
/** * {@inheritDoc} */ public function createCache(UserInterface $user, $filter, ImageInterface $image) { $this->cacheManager->createCache('user/' . $user->getId(), $filter, $image, $this->storageModel->getUserImageExtension()); }
public function getUserWarnings(UserInterface $user) { $repository = $this->objectManager->getRepository("Eye4web\\ZfcUser\\Warnings\\Entity\\Warning"); return $repository->findByUser($user->getId()); }
/** * @param UserInterface $user * @param string $provider * @param \Hybrid_User_Profile $userProfile * @return mixed */ protected function update(UserInterface $user, $provider, \Hybrid_User_Profile $userProfile) { $user->setDisplayName($userProfile->displayName); $user->setEmail($userProfile->email); $options = array('user' => $user, 'provider' => $provider, 'userProfile' => $userProfile); $this->getEventManager()->trigger('scnUpdateUser.pre', $this, $options); $result = $this->getZfcUserMapper()->update($user); $this->getEventManager()->trigger('scnUpdateUser.post', $this, $options); return $result; }
public function transferChangesToExistingEntity(UserInterface $newEntity, UserInterface $existingEntity) { $existingEntity->setUsername($newEntity->getUsername()); $existingEntity->setEmail($newEntity->getEmail()); $existingEntity->setDisplayName($newEntity->getDisplayName()); $existingEntity->setState($newEntity->getState()); $passwordHash = $newEntity->getPassword(); if (!empty($passwordHash)) { $existingEntity->setPassword($passwordHash); } }