Пример #1
0
 public function beforeSet()
 {
     if ($this->object->get('sudo')) {
         return 'You can`t update this user.';
     }
     return parent::beforeSet();
 }
Пример #2
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSet()
 {
     $fields = $this->getProperty('requiredFields', '');
     if (!empty($fields) && is_array($fields)) {
         foreach ($fields as $field) {
             if (preg_match('/(.*?)\\[(.*?)\\]/', $field, $matches)) {
                 $tmp = $this->getProperty($matches[1], null);
                 $tmp = is_array($tmp) && isset($tmp[$matches[2]]) ? $tmp[$matches[2]] : null;
             } else {
                 $tmp = $this->getProperty($field, null);
             }
             if ($field == 'email' && !preg_match('/^[^@а-яА-Я]+@[^@а-яА-Я]+(?<!\\.)\\.[^\\.а-яА-Я]{2,}$/m', $tmp)) {
                 $this->addFieldError('email', $this->modx->lexicon('user_err_not_specified_email'));
             } elseif ($field == 'email' && $this->modx->getCount('modUserProfile', array('email' => $tmp, 'internalKey:!=' => $this->object->id))) {
                 $this->addFieldError('email', $this->modx->lexicon('user_err_already_exists_email'));
             } elseif (empty($tmp)) {
                 $this->addFieldError($field, $this->modx->lexicon('field_required'));
             }
         }
     }
     if (!$this->getProperty('username')) {
         $this->setProperty('username', $this->object->get('username'));
     }
     // Allow only uploaded images
     if ($photo = $this->getProperty('photo')) {
         if (strpos($photo, '://') !== false) {
             $this->unsetProperty('photo');
         }
     }
     $this->current_email = $this->object->Profile->get('email');
     $this->new_email = $this->getProperty('email');
     return parent::beforeSet();
 }
Пример #3
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $properties = $this->getProperties();
     $properties['passwordnotifymethod'] = 's';
     if (empty($properties['username'])) {
         $properties['username'] = $this->object->get('username');
     }
     if (empty($properties['email'])) {
         $properties['email'] = $this->object->Profile->get('email');
     }
     $this->setProperties($properties);
     return parent::beforeSet();
 }
Пример #4
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSet()
 {
     $this->_current_email = $this->object->Profile->get('email');
     $this->_current_photo = $this->object->Profile->get('photo');
     $fields = $this->getProperty('requiredFields', '');
     if (!empty($fields) && is_array($fields)) {
         foreach ($fields as $field) {
             // Extended fields
             if (preg_match('/(.*?)\\[(.*?)\\]/', $field, $matches)) {
                 $tmp = $this->getProperty($matches[1], null);
                 $tmp = is_array($tmp) && isset($tmp[$matches[2]]) ? $tmp[$matches[2]] : null;
             } else {
                 $tmp = $this->getProperty($field, null);
             }
             if ($field == 'email' && !preg_match('/^[^@а-яА-Я]+@[^@а-яА-Я]+(?<!\\.)\\.[^\\.а-яА-Я]{2,}$/m', $tmp)) {
                 $this->addFieldError('email', $this->modx->lexicon('user_err_not_specified_email'));
             } elseif ($field == 'email' && $this->modx->getCount('modUserProfile', array('email' => $tmp, 'internalKey:!=' => $this->object->id))) {
                 $this->addFieldError('email', $this->modx->lexicon('user_err_already_exists_email'));
             } elseif (empty($tmp)) {
                 $this->addFieldError($field, $this->modx->lexicon('field_required'));
             }
         }
     }
     // Fields required by parent processor
     if (!$this->getProperty('username')) {
         $this->setProperty('username', $this->object->get('username'));
     }
     if (!($this->_new_email = $this->getProperty('email'))) {
         $this->setProperty('email', $this->_current_email);
     }
     // Add existing extended fields
     if ($extended = $this->getProperty('extended')) {
         if ($existing = $this->object->Profile->get('extended')) {
             $extended = array_merge($existing, $extended);
         }
         $this->setProperty('extended', $extended);
     }
     // Handle new password
     if ($this->getProperty('specifiedpassword') || $this->getProperty('confirmpassword')) {
         $this->setProperty('passwordnotifymethod', 's');
         $this->setProperty('passwordgenmethod', 'spec');
         $this->setProperty('newpassword', '');
     }
     // Allow only uploaded images
     if ($photo = $this->getProperty('photo')) {
         if (strpos($photo, '://') !== false) {
             $this->unsetProperty('photo');
         }
     }
     return parent::beforeSet();
 }
Пример #5
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSet()
 {
     $fields = $this->getProperty('requiredFields', '');
     if (!empty($fields) && is_array($fields)) {
         foreach ($fields as $field) {
             $tmp = trim($this->getProperty($field, null));
             if ($field == 'email' && !preg_match('/^[^@а-яА-Я]+@[^@а-яА-Я]+(?<!\\.)\\.[^\\.а-яА-Я]{2,}$/m', $tmp)) {
                 $this->addFieldError('email', $this->modx->lexicon('user_err_not_specified_email'));
             } else {
                 if (empty($tmp)) {
                     $this->addFieldError($field, $this->modx->lexicon('field_required'));
                 }
             }
         }
     }
     return parent::beforeSet();
 }