/**
  * called from stream wrapper code in
  * @see ExampleModules::setupExampleModuleFiles()
  *
  * @throws \Exception
  */
 static function addCall()
 {
     if (!isset(self::$callLog)) {
         throw new \Exception("StaticCallLog not initialized yet.");
     }
     $trace = version_compare(PHP_VERSION, '5.4.0', '>=') ? debug_backtrace(0, 2) : debug_backtrace(0);
     $call = $trace[1];
     $callFiltered = array();
     foreach (array('function', 'class', 'type') as $key) {
         if (isset($call[$key])) {
             $callFiltered[$key] = $call[$key];
         }
     }
     $callFiltered['args'] = array();
     foreach ($call['args'] as $arg) {
         if (is_array($arg)) {
             $arg = '(array)';
         } elseif (is_object($arg)) {
             $arg = '(' . get_class($arg) . ')';
         }
         $callFiltered['args'][] = $arg;
     }
     self::$callLog->addCall($callFiltered);
 }
Exemple #2
0
 public function index($offset = 0)
 {
     $columns = array('weather_id' => 'int');
     $configs = array('admin', 'call_logs', '%s');
     $conditions = conditions($columns, $configs, 'CallLog', $this->input_gets());
     $conditions = array(implode(' AND ', $conditions));
     $limit = 25;
     $total = CallLog::count(array('conditions' => $conditions));
     $offset = $offset < $total ? $offset : 0;
     $this->load->library('pagination');
     $configs = array_merge(array('total_rows' => $total, 'num_links' => 5, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>'), $configs);
     $this->pagination->initialize($configs);
     $pagination = $this->pagination->create_links();
     $call_logs = CallLog::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'include' => array('weather'), 'conditions' => $conditions));
     $message = identity()->get_session('_flash_message', true);
     $this->add_js(base_url('resource', 'javascript', 'jquery-timeago_v1.3.1', 'jquery.timeago.js'))->add_js(base_url('resource', 'javascript', 'jquery-timeago_v1.3.1', 'locales', 'jquery.timeago.zh-TW.js'))->load_view(array('message' => $message, 'pagination' => $pagination, 'call_logs' => $call_logs, 'columns' => $columns));
 }
Exemple #3
0
 public function icon($weather)
 {
     CallLog::create(array('weather_id' => $weather->id));
     if (($data = download_web_file('http://api.openweathermap.org/data/2.5/weather?lat=' . $weather->latitude . '&lon=' . $weather->longitude . '')) && ($data = json_decode($data))) {
         if (isset($data->weather[0]) && $data->weather[0]->icon && isset($data->main->temp)) {
             $weather->temperature = $data->main->temp;
             $weather->save();
             $file_path = array('resource', 'image', 'map', $data->weather[0]->icon . '.png');
             if (file_exists(implode(DIRECTORY_SEPARATOR, $file_path))) {
                 return array('temperature' => round($weather->temperature - 273.15), 'icon' => base_url($file_path));
             } else {
                 return '';
             }
         }
     }
     return '';
 }
 /**
  * Tests a request where modules are enabled, but xautoload is already
  * enabled.
  *
  * @dataProvider providerModuleEnable
  *
  * @param mixed[] $initialModules
  *   Initial modules being installed / enabled.
  * @param array $expectedCalls
  *
  * @throws \Exception
  */
 function testModuleEnable(array $initialModules, array $expectedCalls)
 {
     $this->prepare();
     $this->prepareInitialModules($initialModules);
     foreach ($this->exampleModules->getExampleClasses() as $classes) {
         foreach ((array) $classes as $class) {
             $this->assertClassIsUndefined($class);
         }
     }
     $this->exampleDrupal->boot();
     $new_modules = array_keys($this->exampleModules->getExampleClasses());
     $this->exampleDrupal->moduleEnable($new_modules);
     # HackyLog::log($this->callLog->getCalls());
     $this->callLog->assertCalls($this, $expectedCalls);
     // Now we want all classes to be available.
     foreach ($this->exampleModules->getExampleClasses() as $classes) {
         foreach ((array) $classes as $class) {
             $this->assertClassExists($class);
         }
     }
     $this->unprepare();
 }
 public function getCalls()
 {
     return array('numbers' => CallLog::all());
 }
Exemple #6
0
            $inbound->save();
            break;
        case 'dn':
            $outbound_chunk = OutboundChunk::where('message_id', '=', Input::get('messageId'))->first();
            if (!$outbound_chunk) {
                break;
            }
            $outbound_chunk->dn_status = Input::get('status');
            $outbound_chunk->dn_error_code = Input::get('err-code');
            $outbound_chunk->save();
            break;
        case 'voice':
            if (!Input::has('call-id')) {
                break;
            }
            $call = new CallLog();
            $call->call_id = Input::get('call-id');
            $call->to = Input::get('to');
            $call->status = Input::get('status');
            $call->price = Input::get('call-price');
            $call->rate = Input::get('call-rate');
            $call->duration = Input::get('call-duration');
            $call->start_time = Input::get('call-start');
            $call->end_time = Input::get('call-end');
            $call->direction = Input::get('call-direction');
            $call->save();
    }
    return Response::make('OK');
});
/* API */
Route::api(['version' => 'v1', 'protected' => true], function () {