Example #1
0
File: Auth.php Project: zfury/cmf
 /**
  * @param \User\Entity\User $user
  * @param $password
  * @return \User\Entity\Auth
  */
 public function generateEquals(\User\Entity\User $user, $password)
 {
     //delete row
     $auth = $this->getObjectManager()->getRepository('User\\Entity\\Auth')->findOneBy(['userId' => $user->getId(), 'provider' => Auth::PROVIDER_EQUALS]);
     //            ->findOneByUserId($user->getId());
     if ($auth) {
         $this->getObjectManager()->remove($auth);
         $this->getObjectManager()->flush();
     }
     // new auth row
     $row = new \User\Entity\Auth();
     $row->setUserId($user->getId());
     $row->setForeignKey($user->getEmail());
     $row->setProvider(self::PROVIDER_EQUALS);
     $row->setTokenType(self::TYPE_ACCESS);
     // generate secret
     $alpha = range('a', 'z');
     shuffle($alpha);
     $secret = array_slice($alpha, 0, rand(5, 15));
     $secret = md5($user->getId() . join('', $secret));
     $row->setTokenSecret($secret);
     // encrypt password and save as token
     $row->setToken(self::encrypt($row, $password));
     $user->getAuths()->add($row);
     $row->setUser($user);
     $this->getObjectManager()->persist($row);
     $this->getObjectManager()->flush();
     return $row;
 }
Example #2
0
 public function __invoke(User $user)
 {
     $escaper = $this->getView()->plugin('escapehtml');
     $url = $this->getView()->plugin('url');
     $href = $url('user/view', array('id' => $user->getId()));
     $name = $escaper($user->getFullName());
     return sprintf('<a class="user-view" href="%s">%s</a>', $href, $name);
 }
Example #3
0
 /**
  * @param User $user
  */
 public function save(User $user)
 {
     if (!$user->getId()) {
         $user->setId(null);
         $this->_em->persist($user);
     }
     $this->_em->flush($user);
 }
 public function __invoke(User $user, $options, $attributes, $link = false)
 {
     /** @var Gravatar $gravatar */
     $gravatar = $this->getView()->plugin('gravatar');
     $picture = $gravatar($user->getEmail(), $options, $attributes)->getImgTag();
     if (!$link) {
         return $picture;
     }
     $url = $this->getView()->plugin('url');
     $href = $url('user/view', array('id' => $user->getId()));
     return sprintf('<a class="user-view" href="%s">%s</a>', $href, $picture);
 }
Example #5
0
 /**
  * @param $commentText
  * @return \Comment\Entity\Comment
  * @throws \Doctrine\DBAL\ConnectionException
  * @throws \Exception
  */
 protected function createComment($commentText)
 {
     /**
      * @var \Doctrine\ORM\EntityManager $objectManager
      */
     $commentData = array('comment' => $commentText, 'entityType' => $this->entityType, 'entityId' => $this->user->getId(), 'user' => $this->getApplicationServiceLocator()->get('Zend\\Authentication\\AuthenticationService')->getIdentity()->getUser());
     $objectManager = $this->getApplicationServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $comment = new Comment();
     $objectManager->getConnection()->beginTransaction();
     try {
         $hydrator = new DoctrineHydrator($objectManager);
         $hydrator->hydrate($commentData, $comment);
         $objectManager->persist($comment);
         $objectManager->flush();
         $objectManager->getConnection()->commit();
         $objectManager->clear();
     } catch (\Exception $e) {
         $objectManager->getConnection()->rollback();
         throw $e;
     }
     return $comment;
 }
 /**
  * Send confirmation email
  * 
  * @author Stoyan Rangelov
  * @param \User\Entity\User $user
  */
 public function sendConfirmationEmail(\User\Entity\User $user)
 {
     $from = $this->getSenderEmail();
     $to = $user->getLogin();
     $subject = "Bitte aktivieren Sie lhren incoverage-Account";
     //$htmlBody = "Hello <br /> Please activate your account via the following link: <br /> <b> {$this->getActivationURL()}/{$user->getId()}/{$user->getActivationCode()} </b>";
     $activationUrl = "{$this->getActivationURL()}/{$user->getId()}/{$user->getActivationCode()}";
     $htmlBody = $this->getConfirmationTemplate($to, $activationUrl);
     $textBody = "";
     $htmlPart = new MimePart($htmlBody);
     $htmlPart->type = "text/html; charset=UTF-8";
     $textPart = new MimePart($textBody);
     $textPart->type = "text/plain; charset=UTF-8";
     $body = new MimeMessage();
     $body->setParts(array($textPart, $htmlPart));
     $message = new Mail\Message();
     $message->setFrom($from, 'Incoverage')->addTo($to)->setSubject($subject);
     $message->setEncoding("UTF-8");
     $message->setBody($body);
     $transport = new SmtpTransport();
     if ($this->getDefaultConfig()['user_module']['using_gmail']) {
         $transport->setOptions($this->getSMTPOptions());
     }
     $transport->send($message);
 }
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
     return parent::getId();
 }
Example #8
0
 public function getData()
 {
     $client = $this->client ? $this->client->getEmployer() ? $this->client->getEmployer()->getData() : null : null;
     if ($client) {
         $client['types'] = $this->client->getTypes();
     }
     return ['client' => $client, 'user' => $this->client ? $this->client->getData() : null, 'userid' => $this->client->getId(), 'dueDate' => $this->dueDate, 'quote_no' => $this->quote_no, 'project_no' => $this->project_no, 'tax' => $this->tax, 'discount' => $this->discount, 'duration' => $this->duration, 'field' => $this->field ? $this->field->getData() : null, 'id' => $this->id, 'interpretingInfo' => $this->interpretingInfo, 'serviceLevel' => $this->serviceLevel, 'pm' => $this->pm ? $this->pm->getData() : null, 'priority' => $this->priority, 'reference' => $this->reference, 'sale' => $this->sale ? $this->sale->getData() : null, 'sourceLanguage' => $this->sourceLanguage->getData(), 'startDate' => $this->startDate, 'status' => $this->status, 'targetLanguages' => $this->getArrayData($this->targetLanguages), 'po' => $this->po, 'sourcetext' => $this->sourcetext, 'currency' => $this->currency, 'total_tmp' => $this->total_tmp, 'total' => $this->total, 'types' => $this->types, 'transGraph' => $this->transGraph, 'payStatus' => $this->payStatus, 'description' => $this->description];
 }
 public function getInDepthClientsAndSums(User $user)
 {
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('id', 'id');
     $rsm->addScalarResult('unpaid', 'unpaid');
     $sql = "SELECT c.id, COALESCE(SUM(d.amount_tax),0) - COALESCE(SUM(bt.sum),0) as unpaid FROM document d LEFT JOIN customer c on (c.id = d.customer_id)\n                LEFT JOIN bank_transaction bt on (bt.document_id = d.id) WHERE DATE(d.payment_date) < CURDATE() AND d.disc = 'invoice'\n                AND d.user_id =" . $user->getId() . " GROUP BY c.id ORDER BY unpaid DESC LIMIT 5";
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $result = $query->getScalarResult();
     return $result;
 }
Example #10
0
 /**
  * Authorizes user.
  *
  * @param \User\Entity\User $user
  */
 protected function loginUser(Entity\User $user)
 {
     /** @var \User\Entity\Auth $userAuth */
     $userAuth = new Entity\Auth();
     $userAuth->setUserId($user->getId());
     $userAuth->setProvider(Auth::PROVIDER_EQUALS);
     $userAuth->setUser($user);
     $userAuth->login($this->getApplicationServiceLocator());
 }