Example #1
0
 /**
  * Stores the accounts credentials. Throws exception if something failes
  * during the store operation.
  *
  * @throws Opus_Security_Exception If storing failes.
  * @return void
  */
 public function store()
 {
     // Check for a proper credentials
     if ($this->isValid() === false) {
         throw new Opus_Security_Exception('Credentials are invalid.');
     }
     // Check if there is a account with the same
     // loginname before creating a new record.
     if (is_null($this->getId()) === true) {
         $row = Opus_Account::fetchAccountRowByLogin($this->getLogin());
         if (is_null($row) === false) {
             throw new Opus_Security_Exception('Account with login name ' . $this->getLogin() . ' already exists.');
         }
     }
     // Now really store.
     try {
         return parent::store();
     } catch (Exception $ex) {
         $logger = Zend_Registry::get('Zend_Log');
         if (null !== $logger) {
             $message = "Unknown exception while storing account: ";
             $message .= $ex->getMessage();
             $logger->err(__METHOD__ . ': ' . $message);
         }
         $message = "Caught exception.  Please consult the server logfile.";
         throw new Opus_Security_Exception($message);
     }
 }