예제 #1
0
파일: SmsQueue.php 프로젝트: rj28/test
 public function send()
 {
     /** @var \Rj\SmsGate\Herald $mailer */
     $gate = $this->getDI()->getShared('SmsGate');
     try {
         if ($num = Helper::sanitizePhone($this->phone)) {
             $result = $gate->send($num, $this->text, ['uid' => $this->sms_queue_id]);
         } else {
             trigger_error('Invalid phone number ' . $this->phone);
             $result = false;
         }
         if ($result) {
             $this->sent_at = date('Y-m-d H:i:s');
             $this->err = null;
             $this->status = static::STATUS_OK;
         } else {
             if ($error = error_get_last()) {
                 $this->err = $error['message'];
                 $this->status = static::STATUS_ERR;
             } else {
                 $this->status = static::STATUS_ERR;
             }
         }
     } catch (Exception $e) {
         $this->err = $e->getMessage();
         $this->status = static::STATUS_ERR;
     }
     $this->save();
     Assert::noMessages($this);
 }
예제 #2
0
 public function confirm(UserInterface $user, $code)
 {
     if ($user->getId() == $this->user_id && $user->getPhoneNumber() == $this->phone) {
         if ($code && $code != $this->code) {
             return false;
         }
         $this->getWriteConnection()->begin();
         try {
             $user->setPhoneNumberConfirmed(true);
             Assert::noMessages($user);
             $this->save(['active' => null, 'result' => 1]);
             Assert::noMessages($this);
             $this->expireAnother();
             $this->getWriteConnection()->commit();
         } catch (Exception $e) {
             $this->getWriteConnection()->rollback();
             throw $e;
         }
         return true;
     } else {
         $this->save(['active' => null, 'result' => 0]);
         Assert::noMessages($this);
     }
     return false;
 }
예제 #3
0
파일: Settings.php 프로젝트: rj28/test
 public static function set($key, $value)
 {
     $entry = static::findFirst(['key = ?0', 'bind' => [$key]]);
     if (!$entry) {
         $entry = new static();
         $entry->key = $key;
     }
     $entry->save(['value' => $value]);
     Assert::noMessages($entry);
 }
예제 #4
0
파일: EmailConfirm.php 프로젝트: rj28/test
 public function confirm()
 {
     if ($user = $this->_getUserModel()) {
         $this->getWriteConnection()->begin();
         try {
             $this->save(['expires_at' => new Phalcon_RawValue('NULL'), 'confirm_success' => 'y']);
             Assert::noMessages($this);
             $this->expireOlder();
             $this->_confirm();
             $this->getWriteConnection()->commit();
         } catch (Exception $e) {
             $this->getWriteConnection()->rollback();
             throw $e;
         }
     } else {
         throw new Exception('Bad confirmation record: no such user');
     }
 }