示例#1
0
文件: api.php 项目: resnostyle/xem
 public function savePassthru()
 {
     if (!$this->session->userdata('logged_in')) {
         $this->_fullOut('failure', array(), "not loged in");
         return false;
     }
     $orign = new Location($this->oh);
     $orign->name = $_POST['origin'];
     $orign->load();
     $destination = new Location($this->oh);
     $destination->name = $_POST['destination'];
     $destination->load();
     if ($orign->id && $destination->id) {
         $newPass = new Passthru($this->oh, (int) $_POST['id']);
         $newPass->origin_id = $orign->id;
         $newPass->destination_id = $destination->id;
         $newPass->element_id = $_POST['element_id'];
         $newPass->load();
         $newPass->type = $_POST['type'];
         if ($newPass->save()) {
             $newPass->reverse();
             unset($newPass->type);
             $newPass->load();
             $newPass->type = $_POST['type'];
             if ($newPass->save()) {
                 $this->_fullOut('success', $_POST);
                 return true;
             }
         }
     }
     $this->_fullOut('failure', $_POST);
 }