Exemplo n.º 1
0
 /**
  * saves user info to Rave
  * @param confirm indicator, if you want to send the confirmation text message
  */
 public function save($confirm = false)
 {
     // TODO: we should validate the object before sending off to Rave
     $phone_ok = $this->validatePhone('1') && $this->validatePhone('2') && $this->validatePhone('3');
     if (!$phone_ok) {
         return false;
     }
     // end if
     if (!$this->validateEmail()) {
         return false;
     }
     // end validateEmail
     if ($this->inRave) {
         $user = REST::updateUser($this->getXML());
     } else {
         $user = REST::registerUser($this->getXML());
         $this->inRave = true;
     }
     // end else
     $this->refresh($user);
     if ($confirm) {
         try {
             REST::sendConfCode($this->email);
         } catch (\Rave\PhoneAlreadyConfirmed $e) {
             return true;
         }
         // end catch
     }
     // end if confirm
     return true;
     // success!
 }