Ejemplo n.º 1
0
 public function userCanEditSection(UserInterface $user, Section $section)
 {
     if ($user->getId() == $section->user_id) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 public function getObjectForUser(\ZfcUser\Entity\UserInterface $user)
 {
     if (!$this->getSession()->offsetExists("U{$user->getId()}")) {
         return new \stdClass();
     }
     return $this->getSession()->offsetGet("U{$user->getId()}");
 }
Ejemplo n.º 3
0
 /**
  * @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));
 }
Ejemplo n.º 4
0
 /**
  * 
  * @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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * @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);
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 /**
  * @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]);
 }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
 /**
  * @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;
 }
Ejemplo n.º 12
0
 /**
  * Set user
  *
  * @param  UserInterface $user
  * @return RoleLinker
  */
 public function setUser(UserInterface $user)
 {
     $this->setUserId($user->getId());
     return $this;
 }
Ejemplo n.º 13
0
 /**
  * @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;
 }
Ejemplo n.º 14
0
 /**
  * Gets path to image of a user(without extension(png))
  *
  * @return string
  */
 public function getUserImageWithoutExtension(UserInterface $user)
 {
     return $this->getUploadDirectory() . '/' . $user->getId();
 }
Ejemplo n.º 15
0
 /**
  * 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;
 }
Ejemplo n.º 16
0
 /**
  * @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;
 }
Ejemplo n.º 17
0
 /**
  * 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();
 }
Ejemplo n.º 19
0
 /**
  * {@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());
 }
Ejemplo n.º 21
0
 /**
  * @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;
 }
Ejemplo n.º 22
0
 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);
     }
 }