Пример #1
0
 public function setProfile()
 {
     $this->profile = $this->object->getOne('Profile');
     if (empty($this->profile)) {
         $this->profile = $this->modx->newObject('modUserProfile');
         $this->profile->set('internalKey', $this->object->get('id'));
         $this->profile->save();
         $this->object->addOne($this->profile, 'Profile');
     }
     $this->profile->fromArray($this->getProperties());
     return $this->profile;
 }
Пример #2
0
 /**
  * Setup the user data and create the user/profile objects
  *
  * @return void
  */
 public function setUserFields()
 {
     $fields = $this->dictionary->toArray();
     /* allow overriding of class key */
     if (empty($fields['class_key'])) {
         $fields['class_key'] = 'modUser';
     }
     $fields = $this->filterAllowedFields($fields);
     /* set user and profile */
     $this->user->fromArray($fields);
     $this->user->set('username', $fields[$this->controller->getProperty('usernameField', 'username')]);
     $this->user->set('active', 0);
     $version = $this->modx->getVersionData();
     /* 2.1.x+ */
     if (version_compare($version['full_version'], '2.1.0-rc1') >= 0) {
         $this->user->set('password', $fields[$this->controller->getProperty('passwordField', 'password')]);
     } else {
         /* 2.0.x */
         $this->user->set('password', md5($fields[$this->controller->getProperty('passwordField', 'password')]));
     }
     $this->profile->fromArray($fields);
     $this->profile->set('email', $this->dictionary->get($this->controller->getProperty('emailField', 'email')));
     $this->user->addOne($this->profile, 'Profile');
     /* add user groups, if set */
     $userGroupsField = $this->controller->getProperty('usergroupsField', '');
     $userGroups = !empty($userGroupsField) && array_key_exists($userGroupsField, $fields) ? $fields[$userGroupsField] : array();
     $this->setUserGroups($userGroups);
 }
Пример #3
0
 /**
  * @return modUserProfile
  */
 public function addProfile()
 {
     $this->profile = $this->modx->newObject('modUserProfile');
     $this->profile->fromArray($this->getProperties());
     $this->profile->set('blocked', $this->getProperty('blocked', false));
     $this->profile->set('photo', '');
     $this->object->addOne($this->profile, 'Profile');
     return $this->profile;
 }