Ejemplo n.º 1
0
 public function update()
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, Kohana::lang('graph.method_not_exist'));
     }
     $data = $this->get_data();
     if (empty($data)) {
         $this->send_response(400, NULL, Kohana::lang('graph.invalid_request'));
     }
     $guid = isset($data['guid']) ? $data['guid'] : '';
     if ($guid) {
         $reason = 'guid';
         $url = '';
     } else {
         $reason = isset($data['reason']) ? $data['reason'] : '';
         $url = isset($data['url']) ? $data['url'] : '';
     }
     if (empty($reason)) {
         $this->send_response(400, NULL, Kohana::lang('graph.reason_empty'));
     }
     if (empty($url) and empty($guid)) {
         $this->send_response(400, NULL, Kohana::lang('graph.url_empty'));
     }
     if ($this->model->update($this->user_id, $url, $reason, $this->appid, $this->device_id, $this->source, $guid)) {
         $this->send_response(200, NULL, '', FALSE);
     } else {
         $this->send_response(500, NULL, Kohana::lang('graph.operation_fail'));
     }
 }
Ejemplo n.º 2
0
 /**
  * 单例模式
  * @return Graph_Model
  */
 public static function &instance()
 {
     if (!isset(self::$instance)) {
         // Create a new instance
         self::$instance = new Graph_Model();
     }
     return self::$instance;
 }