Example #1
0
 public function testGetPhones()
 {
     try {
         include_once "../config.php";
         $phones = new Phones($arrConfig);
         $result = $phones->getPhones();
         foreach ($result as $value) {
             $this->assertEquals("+", $value[0]);
         }
     } catch (Exception $ex) {
         $this->fail($ex->getMessage());
     }
 }
Example #2
0
 public function addAction()
 {
     $phones = new Phones();
     $producer = PhonesProducers::findFirst("name = '" . $this->request->getPost('producer') . "'");
     $producerId = $producer->id;
     $phones->producer_id = $producerId;
     $OS = OperatingSystems::findFirst("name = '" . $this->request->getPost('OS') . "'");
     $OSId = $OS->id;
     $phones->operating_system_id = $OSId;
     $phones->model = $this->request->getPost('model');
     $phones->save();
     $this->flash->success("Phone was successfully added.");
     $this->dispatcher->forward(['action' => 'index']);
 }
Example #3
0
 public function cancelReservationAction($phoneId)
 {
     $phone = Phones::findFirst('id ="' . $phoneId . '"');
     $phone->user_id = 0;
     $phone->status = 'Available';
     $phone->save();
     $this->dispatcher->forward(['action' => 'index']);
 }
Example #4
0
File: index.php Project: sm87/test
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Задание 1</title>
    <style type="text/css">
        body { font-family:courier }
    </style>
</head>
<body>
<table>
    <?php 
require "../config.php";
require "Phones.php";
try {
    $phones = new Phones($arrConfig);
    $result = $phones->getPhones();
    foreach ($result as $value) {
        echo "<tr><td>" . $value . "</td></tr>";
    }
} catch (Exception $ex) {
    die($ex->getMessage());
}
?>
</table>
</body>
</html>
Example #5
0
 /**
  * inactivates other phonees owned by this user with the same 
  * phone type
  */
 private function _inactivate_all_actives()
 {
     $phones = new Phones($this->pidm);
     $phones->load();
     $active = $phones->active_by_type($this->tele_code);
     foreach ($active as $phone) {
         $phone->set_inactive();
         $phone->save();
     }
     //end foreach
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMrPhones()
 {
     return $this->hasMany(Phones::className(), ['place_id' => 'id']);
 }
Example #7
0
 /**
  * save the Rave phone
  *
  * @param $option \b Rave save option (false, opted_out, deferred, resend, no_confirm)
  */
 public function save($option = false)
 {
     if (!$this->wp_id) {
         throw new UnexpectedValueException('A user id (wp_id) is required before saving. No user id was provided.');
     }
     //end if
     $args = $this->sanitize();
     // we need to get the current phone for the user.
     // load the phones
     $phones = new Phones($this->wp_id);
     $phones->load();
     // grab the most recent, active number whose type matches this phone's type
     $current = $phones->current($phones->type($args['phone_type']));
     if ($current || $option == 'deferred' || $option == 'opted_out') {
         /* it will enter the following if (not the ifesles) when:
          *   1) they have a current phone that doesn't match the phone they are saving, OR
          *   2) they are deferring, OR
          *   3) they are opting out, OR
          *   4) they have a current phone that matches the phone they are saving AND they 
          *        are either continuing/not confirming AND the current phone is set to optout or deferred
          */
         if ($current && $current->phone != $args['phone'] || $option == 'deferred' || $option == 'opted_out' || $current && $current->phone == $args['phone'] && ($option == 'continue' || $option == 'no_confirm') && ($current->opt_nocell || $current->opt_notnow)) {
             \PSU::db('emergency_notificationt')->StartTrans();
             if ($current && !($current->phone == $args['phone'] && $option == 'continue')) {
                 $current->unconfirm($current->phone);
             }
             //end if
             // if we get here, we're going to be adding a new phone number.  Expire
             //   all of the active ones that match this number's type
             self::expire_all_active($args['wp_id'], $args['phone_type']);
             $do_final_commit = true;
         } elseif ($option === 'resend') {
             $rave_user = \PSU\Rave\User::get($this->wp_id);
             return $rave_user->save(true);
         } else {
             // phone has not changed, do nothing
             return true;
         }
         // end else
     }
     //end if
     // assume we want to actually commit...we'll cancel
     // the commit later if there was an error
     $commit = true;
     if ($ok = $this->_insert($args, $option)) {
         // if we get in here, the insert worked swimmingly
         if (!($ok = $this->_rave_save($args['phone'], $option))) {
             // if we get in here, Rave had an error
             // explicitly fail the transaction
             $commit = false;
         }
         // end rollback
         \PSU::db('emergency_notificationt')->CompleteTrans($commit);
         if ($do_final_commit) {
             \PSU::db('emergency_notificationt')->CompleteTrans($commit);
         }
         return $ok;
     }
     // end if
     return false;
 }
Example #8
0
 public function actionParse($from = null, $to = null, $id = null, $nocache = null)
 {
     if ($id) {
         $from = $id;
         $to = $id + 1;
     }
     if (!$from) {
         $this->stop("((");
     }
     $flag_working = true;
     $ank_id = intval($from);
     $tries = 0;
     while ($flag_working) {
         if ($ank_id == $to) {
             $this->stop("All done");
         }
         //sleep(2);
         $this->writeln("Parsing {$ank_id}");
         $html = $this->getHtml($ank_id, $nocache == 1 ? false : true);
         if (preg_match('/' . $this->stopWord . '/uism', $html)) {
             $tries++;
             $ank_id++;
             $this->writeln($this->stopWord);
             if ($tries == 5) {
                 return $this->stop("I'm stopping");
             }
             continue;
         } else {
             $tries = 0;
         }
         // parse
         preg_match('/Жизненное\\s+кредо<\\/td>(.+?)<\\/td>/xuism', $html, $matches);
         $ro = preg_replace('/\\s\\s+/', ' ', $matches[0]);
         //var_dump($matches);
         $phone = $this->capturePhone($matches[0]);
         if (!$phone) {
             preg_match('/(Дополнительная\\s+информация\\s+\\(несколько\\s+слов\\s+о\\s+себе\\s+и\\s+своих\\s+увлечениях\\)<\\/td>(.+?)<\\/td>)/xuism', $html, $matches);
             if (isset($matches[0])) {
                 $ro = preg_replace('/\\s\\s+/', ' ', $matches[0]);
                 $phone = $this->capturePhone($matches[0]);
             }
             if (!$phone) {
                 $this->no_phone[] = $this->anketUrl . $ank_id;
                 $this->writeln("no phone");
                 $ank_id++;
                 continue;
             }
         }
         $this->writeln($phone);
         // save
         $phone_model = Phones::model()->findByAttributes(array('phone' => $phone));
         if (!$phone_model) {
             $phone_model = new Phones();
             $phone_model->phone = $phone;
             if (!$phone_model->save()) {
                 $this->stop('failed to save $phone_model');
             }
         }
         $anket_model = Ankets::model()->findByAttributes(array('id' => $ank_id));
         if (!$anket_model) {
             $anket_model = new Ankets();
             $anket_model->id = $ank_id;
             $anket_model->phone_id = $phone_model->id;
             if (!$anket_model->save()) {
                 $this->stop('failed to save $anket_model');
             }
         }
         $ank_id++;
     }
 }
Example #9
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Phones::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }