示例#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
 /**
  * {@inheritDoc}
  * 
  * @return array|string
  */
 public function process()
 {
     $this->prepare();
     /* save profile */
     if ($this->profile->save() == false) {
         return $this->failure($this->modx->lexicon('user_profile_err_save'));
     } else {
         /* log manager action */
         $this->modx->logManagerAction('save_profile', 'modUser', $this->modx->user->get('id'));
     }
     return $this->success($this->modx->lexicon('success'), $this->profile->toArray());
 }
 /**
  * Sync the User's Profile with the ActiveDirectory data
  *
  * TODO: After Revo 2.0.1, move this to modActiveDirectoryUser. Cant now
  * because class isnt accessible from onauthenticate
  * 
  * @param modUserProfile $profile
  * @param array $data An array of userinfo data
  * @return boolean
  */
 public function syncProfile(modUserProfile &$profile, $data)
 {
     /* map of ActiveDirectory => MODx Profile fields */
     $map = array('name' => 'fullname', 'mail' => 'email', 'streetaddress' => 'address', 'l' => 'city', 'st' => 'state', 'co' => 'country', 'postalcode' => 'zip', 'mobile' => 'mobilephone', 'telephonenumber' => 'phone', 'info' => 'comment', 'wwwhomepage' => 'website');
     foreach ($data as $k => $v) {
         if (!is_array($v) || !array_key_exists($k, $map)) {
             continue;
         }
         $this->modx->log(xPDO::LOG_LEVEL_DEBUG, '[ActiveDirectory] Syncing field "' . $map[$k] . '" to: "' . $v[0] . '"');
         $profile->set($map[$k], $v[0]);
     }
     $id = $profile->get('internalKey');
     if (!empty($id)) {
         $saved = $profile->save();
     }
     //$saved = $user->syncProfile($userInfo);
     if (!$saved) {
         $this->modx->log(modX::LOG_LEVEL_INFO, '[ActiveDirectory] User Profile information was unable to be synced.');
     }
     return $saved;
 }