Ejemplo n.º 1
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.º 2
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.º 3
0
 public function userCanEditSection(UserInterface $user, Section $section)
 {
     if ($user->getId() == $section->user_id) {
         return true;
     }
     return false;
 }
Ejemplo n.º 4
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.º 5
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
 /**
  * Set user
  *
  * @param  UserInterface $user
  * @return RoleLinker
  */
 public function setUser(UserInterface $user)
 {
     $this->setUserId($user->getId());
     return $this;
 }
Ejemplo n.º 13
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.º 14
0
 /**
  * Finds roles by user
  *
  * @param UserInterface $user
  */
 public function findByUser(UserInterface $user)
 {
     return $this->findByUserId($user->getId());
 }
Ejemplo n.º 15
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.º 16
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());
 }