%PDF- %PDF-
Direktori : /var/www/html/bbw/farmaci/kritik-portale/module/Basis/src/Basis/Model/User/ |
Current File : /var/www/html/bbw/farmaci/kritik-portale/module/Basis/src/Basis/Model/User/User.php |
<?php /** * Created by PhpStorm. * User: juliangilles * Date: 29.07.14 * Time: 14:27 */ namespace Basis\Model\User; use Basis\Event\User\UserChangedActive; use Basis\Event\User\UserChangedCreatedAt; use Basis\Event\User\UserChangedEmail; use Basis\Event\User\UserChangedExternalCustomerID; use Basis\Event\User\UserChangedForgotten; use Basis\Event\User\UserChangedHash; use Basis\Event\User\UserChangedHome; use Basis\Event\User\UserChangedName; use Basis\Event\User\UserChangedNewsletter; use Basis\Event\User\UserChangedPassword; use Basis\Event\User\UserChangedPhone; use Basis\Event\User\UserChangedRemind; use Basis\Event\User\UserChangedRole; use Basis\Event\User\UserChangedSalutation; use Basis\Event\User\UserChangedSurname; use Basis\Event\User\UserChangedTitle; use Basis\Event\User\UserChangedUsername; use Basis\Event\User\UserChangedVerifyMail; use Basis\Event\User\UserDeleted; use Basis\Event\User\UserSendMailClaimActivation; use Basis\Event\User\UserSendMailClaimCollision; use Basis\Event\User\UserSendMailClaimInformation; use Basis\Event\User\UserSendMailClaimPharmacy; use Basis\Event\User\UserSendMailClaimSuccessful; use Basis\Model\EventBasis; use ReviewBase\Model\CleverReachManager; use Zend\Json\Json; class User extends EventBasis { /** * @var string */ protected $_id; /** * @var string */ protected $_name = null; protected $_surname = null; // protected $_username = null; protected $_email = null; protected $_role = null; protected $_password = null; protected $_hash = null; protected $_created_at = null; protected $_remind = null; protected $_active = null; protected $_forgotten = null; protected $_phone = null; protected $_salutation = null; protected $_title = null; protected $_newsletter = null; /** * @var string */ protected $_entityId = null; protected $_cleverReachManager = null; protected $_home = null; protected $_external_customer_id = null; protected $_verify_mail = null; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function generateId() { $this->_id = uniqid(); } public function __construct(CleverReachManager $cleverReachManager) { $this->_cleverReachManager = $cleverReachManager; } /** * @param array $events * @param \Basis\EventBus\EventBus $eventBus * @param \Zend\Db\Adapter\Adapter $databaseAdapter */ public function setFromEvents($events, \Basis\EventBus\EventBus $eventBus, \Zend\Db\Adapter\Adapter $databaseAdapter) { foreach ($events as $event) { /* @var $event \Basis\Event\Event */ $data = Json::decode($event->__get("domaindata")); switch ($event->__get("eventtype")) { case 'Basis\Event\User\UserSendMailClaimCollision': break; case 'Basis\Event\User\UserSendMailClaimInformation': break; case 'Basis\Event\User\UserSendMailClaimSuccessful': break; default: foreach ($data as $key => $value) { $this->set($key, $value); } } } } /** * @param $property * @param $value */ protected function set($property, $value) { $property = "_" . $property; $this->$property = $value; } /** * @param string $name */ public function setName($name) { if ($this->_name !== $name) { $this->_name = $name; $event = new UserChangedName(); $event->setParams(array( "name" => $name )); $this->addEvent($event); } } /** * @return string */ public function getName() { return $this->_name; } public function setExternalCustomerID($external_customer_id) { if ($this->_external_customer_id !== $external_customer_id) { $this->_external_customer_id = $external_customer_id; $event = new UserChangedExternalCustomerID(); $event->setParams(array( "external_customer_id" => $external_customer_id )); $this->addEvent($event); } } public function getExternalCustomerID() { return $this->_external_customer_id; } /** * @param string $name */ public function setSurname($surname) { if ($this->_surname !== $surname) { $this->_surname = $surname; $event = new UserChangedSurname(); $event->setParams(array( "surname" => $surname )); $this->addEvent($event); } } /** * @return string */ public function getSurname() { return $this->_surname; } // public function setUsername($username) // { // if ($this->_username !== $username) { // $this->_username = $username; // $event = new UserChangedUsername(); // $event->setParams(array( // "username" => $username // )); // $this->addEvent($event); // } // } // // public function getUsername() // { // return $this->_username; // } /** * @param string $email */ public function setEmail($email) { if ($this->_email !== $email) { $this->_email = $email; $event = new UserChangedEmail(); $event->setParams(array( "email" => $email )); $this->addEvent($event); } } /** * @return string */ public function getEmail() { return $this->_email; } /** * @param string $verify_email */ public function setVerifyMail($verify_email) { if ($this->_verify_mail !== $verify_email) { $this->_verify_mail = $verify_email; $event = new UserChangedVerifyMail(); $event->setParams(array( "verify_mail" => $verify_email )); $this->addEvent($event); } } /** * @return string */ public function getVerifyMail() { return $this->_verify_mail; } /** * @param string $password */ public function setPassword($password) { if ($this->_password !== $password) { $this->_password = $password; $event = new UserChangedPassword(); $event->setParams(array( "password" => $password )); $this->addEvent($event); } } /** * @return string */ public function getPassword() { return $this->_password; } /** * @param string $role */ public function setRole($role) { if ($this->_role !== $role) { $this->_role = $role; $event = new UserChangedRole(); $event->setParams(array( "role" => $role )); $this->addEvent($event); } } /** * @return string */ public function getRole() { return $this->_role; } /** * @param string $hash */ public function setHash($hash) { if ($this->_hash !== $hash) { $this->_hash = $hash; $event = new UserChangedHash(); $event->setParams(array( "hash" => $hash )); $this->addEvent($event); } } /** * @return string */ public function getHash() { return $this->_hash; } public function generateHash() { return md5($this->_entityId . $this->_email . time()); } public function delete() { $event = new UserDeleted(); $event->setParams(array( "entityid" => $this->getId() )); $this->addEvent($event); } /** * @param string $active */ public function setActive($active) { if ($this->_active !== $active) { $this->_active = $active; $event = new UserChangedActive(); $event->setParams(array( "active" => $active )); $this->addEvent($event); } } /** * @return string */ public function getActive() { return $this->_active; } /** * @param string $createdAt */ public function setCreatedAt($createdAt) { if ($this->_created_at !== $createdAt) { $this->_created_at = $createdAt; $event = new UserChangedCreatedAt(); $event->setParams(array( "created_at" => $createdAt )); $this->addEvent($event); } } /** * @return string */ public function getCreatedAt() { return $this->_created_at; } /** * @param string $remind */ public function setRemind($remind) { if ($this->_remind !== $remind) { $this->_remind = $remind; $event = new UserChangedRemind(); $event->setParams(array( "remind" => $remind )); $this->addEvent($event); } } /** * @return string */ public function getRemind() { return $this->_remind; } /** * @param string $forgotten */ public function setForgotten($forgotten) { if ($this->_forgotten !== $forgotten) { $this->_forgotten = $forgotten; $event = new UserChangedForgotten(); $event->setParams(array( "forgotten" => $forgotten )); $this->addEvent($event); } } /** * @return string */ public function getForgotten() { return $this->_forgotten; } /** * @param string $phone */ public function setPhone($phone) { try { $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance(); $phoneNumber = $phoneUtil->parse($phone, 'DE'); $phone = $phoneUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::E164); } catch (\Exception $e){ $e->getMessage(); } if ($this->_phone !== $phone) { $this->_phone = $phone; $event = new UserChangedPhone(); $event->setParams(array( "phone" => $phone )); $this->addEvent($event); } } /** * @return string */ public function getPhone() { return $this->_phone; } public function setSalutation($salutation) { if ($this->_salutation !== $salutation) { $this->_salutation = $salutation; $event = new UserChangedSalutation(); $event->setParams(array( "salutation" => $salutation )); $this->addEvent($event); } } public function getSalutation() { return $this->_salutation; } /** * @param string $title */ public function setTitle($title) { if ($this->_title !== $title) { $this->_title = $title; $event = new UserChangedTitle(); $event->setParams(array( "title" => $title )); $this->addEvent($event); } } /** * @return string */ public function getTitle() { return $this->_title; } /** * @param string $newsletter */ public function setNewsletter($newsletter) { if ($this->_newsletter !== $newsletter) { $this->_newsletter = $newsletter; $event = new UserChangedNewsletter(); $event->setParams(array( "newsletter" => $newsletter )); $this->addEvent($event); } $boolNewsletter = (bool)$this->_newsletter; $this->_cleverReachManager->updateUser($this, $boolNewsletter); } /** * @return string */ public function getNewsletter() { $userStatusCleverReach = $this->_cleverReachManager->getStatus($this); if ($userStatusCleverReach !== "ERROR") { $stringStatusCleverReach = $userStatusCleverReach === true ? '1' : '0'; if ($this->_newsletter !== $stringStatusCleverReach) { $this->setNewsletter($stringStatusCleverReach); } } return $this->_newsletter; } public function setHomeID($id) { if ($this->_home !== $id) { $this->_home = $id; $event = new UserChangedHome(); $event->setParams(array( "home" => $id )); $this->addEvent($event); } } public function getHomeID() { return $this->_home; } public function setClaimingInformationMail($pharmacy) { $event = new UserSendMailClaimInformation(); $event->setParams([ 'entityid' => $pharmacy->entityid, 'aponame' => $pharmacy->name ]); $this->addEvent($event); } public function setClaimingCollisionMail($pharmacy) { $event = new UserSendMailClaimCollision(); $event->setParams([ 'entityid' => $pharmacy->entityid, 'aponame' => $pharmacy->name, ]); $this->addEvent($event); } public function setClaimingSuccessfulMail($pharmacy) { $event = new UserSendMailClaimSuccessful(); $event->setParams([ 'entityid' => $pharmacy->entityid, 'aponame' => $pharmacy->name, ]); $this->addEvent($event); } }