Ejemplo n.º 1
0
 function render()
 {
     # Check users' permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_blacklist_spotter, '');
     # Make sure the editresult is set to 'not comitted' per default
     $result = new Dto_FormResult('notsubmitted');
     # Create the default blacklist information
     $blackList = array('spotterid' => '', 'origin' => '');
     # set the page title
     $this->_pageTitle = "report: blacklist spotter";
     /* 
      * bring the forms' action into the local scope for 
      * easier access
      */
     if (isset($this->_blForm['action'])) {
         $formAction = $this->_blForm['action'];
     } else {
         $formAction = '';
     }
     # else
     # Instantiate the user system which does the actually heavy lifting
     $svcUserRecord = new Services_User_Record($this->_daoFactory, $this->_settings);
     if (!empty($formAction) && !$result->isError()) {
         $result->setResult('success');
         # Make sure we have a complete blacklist information
         $blackList = array_merge($blackList, $this->_blForm);
         switch ($formAction) {
             case 'addspotterid':
                 $result->mergeResult($svcUserRecord->addSpotterToList($this->_currentSession['user'], $blackList['spotterid'], $blackList['origin'], $blackList['idtype']));
                 break;
                 # case addspotterid
             # case addspotterid
             case 'removespotterid':
                 $result->mergeResult($svcUserRecord->removeSpotterFromList($this->_currentSession['user'], $blackList['spotterid']));
                 break;
                 # case removespotterid
         }
         # switch
     }
     # if
     #- display stuff -#
     $this->template('jsonresult', array('result' => $result));
 }
Ejemplo n.º 2
0
 function validateUserRecord($user, $isEdit)
 {
     $result = new Dto_FormResult();
     # Make sure the username is valid
     if (!$isEdit) {
         if (!$this->validUsername($user['username'])) {
             $result->addError(_('Invalid username chosen'));
         }
         # if
     }
     # if
     # Check a firstname is entered
     if (strlen($user['firstname']) < 2) {
         $result->addError(_('Not a valid firstname'));
     }
     # if
     # Check a lastname is entered
     if (strlen($user['lastname']) < 2) {
         $result->addError(_('Not a valid lastname'));
     }
     # if
     # Make sure a valid password is entered for existing users
     if (strlen($user['newpassword1'] > 0) && $isEdit) {
         if (strlen($user['newpassword1']) < 5) {
             $result->addError(_('Entered password is too short'));
         }
         # if
     }
     # if
     # Make sure a valid password is entered for new users
     if (strlen($user['newpassword1']) < 5 && !$isEdit) {
         $result->addError(_('Entered password is too short'));
     }
     # if
     # and make sure the passwords match
     if ($user['newpassword1'] != $user['newpassword2']) {
         $result->addError(_('Passwords do not match'));
     }
     # if
     # check the mailaddress
     if (!filter_var($user['mail'], FILTER_VALIDATE_EMAIL)) {
         $result->addError(_('Not a valid email address'));
     }
     # if
     # and make sure the mailaddress is unique among all users
     $result->mergeResult($this->validateUserEmailExists($user));
     return $result;
 }