Beispiel #1
0
 /**
  * Synchronize a person and user 
  * 
  * @param ComPeopleDomainEntityPerson $person
  * @param JUser	                      $user
  * 
  * @return void
  */
 public function synchronizeWithUser($person, $user)
 {
     if ($person->userId != $user->id) {
         return;
     }
     $params = new JParameter($user->params);
     $person->setData(array('component' => 'com_people', 'name' => $user->name, 'username' => $user->username, 'email' => $user->email, 'userType' => $user->usertype, 'registrationDate' => AnDomainAttribute::getInstance('date')->setDate($user->registerDate), 'lastVisitDate' => AnDomainAttribute::getInstance('date')->setDate($user->lastvisitDate), 'language' => $params->get('language'), 'timezone' => $params->get('timezone'), 'enabled' => !$user->block), AnDomain::ACCESS_PROTECTED);
 }
Beispiel #2
0
 /**
  * Validates a person object
  * 
  * @param ComPeopleDomainEntityPerson $person
  * 
  * @return boolean
  */
 public function validateEntity($person)
 {
     //if a password is set then validate the password
     if ($password = $person->getPassword()) {
         if (!$this->getFilter('password')->validate($password)) {
             $person->addError(array('message' => 'Invalid password format', 'code' => AnError::INVALID_FORMAT, 'key' => 'password'));
         }
     }
     return parent::validateEntity($person);
 }
Beispiel #3
0
 /**
  * store user method.
  *
  * Method is called after user data is stored in the database
  *
  * @param 	array		holds the new user data
  * @param 	bool		true if a new user is stored
  * @param	bool		true if user was succesfully stored in the database
  * @param	string		message
  */
 public function onAfterStoreUser($user, $isnew, $succes, $msg)
 {
     $this->_createToken($user['username']);
     $userId = $user['id'];
     if ($this->_person) {
         //unblock the user
         $user = KService::get('repos://site/users')->find($userId);
         $user->block = false;
         $user->save();
         $user = $this->_api->getUser();
         if (KRequest::get('post.import_avatar', 'cmd') && $user->large_avatar) {
             $this->_person->setPortraitImage(array('url' => $user->large_avatar));
         }
         $this->_person->enabled = true;
         $this->_person->save();
     }
 }
Beispiel #4
0
 /**
  * Retunr if an order can be processed
  * 
  * @return boolean
  */
 public function canProcess()
 {
     if ($this->persisted()) {
         return false;
     }
     if (!$this->_subscriber) {
         return false;
     }
     if (!$this->validateEntity()) {
         return false;
     }
     if (!$this->_subscriber->persisted() && !$this->_subscriber->validateEntity()) {
         return false;
     }
     if (!isset($this->_package)) {
         return false;
     }
     if (!isset($this->_payment_method)) {
         return false;
     }
     return true;
 }
Beispiel #5
0
 /**
  * Checks with a setting delegate of the notification whether to notify a person or not
  *
  * @param ComPeopleDomainEntityPerson         $person
  * @param ComNotificationsDomainEntitySetting $setting
  * 
  * @return int
  */
 public function shouldNotify($person, $setting)
 {
     //if a person is not notifiable then return false
     if (!$person->isNotifiable()) {
         return false;
     }
     //check if the target allows access to the person
     if (!$this->target->allows($person, 'access')) {
         return false;
     }
     if (isset($this->object) && $this->object->isPrivatable() && !$this->object->allows($person, 'access')) {
         return false;
     }
     if ($this->type) {
         $delegate = $this->getService('com://site/notifications.domain.delegate.setting.' . $this->type);
         return $delegate->shouldNotify($person, $this, $setting);
     } else {
         return ComNotificationsDomainDelegateSettingInterface::NOTIFY_WITH_EMAIL;
     }
 }
Beispiel #6
0
 /**
  * Lead a person command.
  *
  * @param ComActorsDomainEntityActor  $actor  that is going to be followed
  * @param ComPeopleDomainEntityPerson $person person that is going to be added as a follower to the $actor
  *
  * @return LibBaseTemplateObject
  */
 public function getLeadCommand($actor, $person)
 {
     if (!$actor->isFollowable() || !$person->isLeadable()) {
         return;
     }
     if ($actor->eql($person)) {
         return;
     }
     if ($actor->blocking($person)) {
         return;
     }
     if ($person->following($actor) && $actor->authorize('administration')) {
         $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'unlead'));
         $command->name = 'unlead';
     } elseif (!$person->following($actor) && $actor->authorize('lead')) {
         $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'lead'));
         $command->name = 'lead';
     } else {
         return;
     }
     return $command;
 }
Beispiel #7
0
 /**
  * Return true if viewer is a guest.
  *
  * @return bool
  */
 public function canResetPassword()
 {
     return $this->_viewer->guest();
 }