示例#1
0
文件: log.php 项目: 119155012/kals
 /**
  * 實際建立log的方法
  * @param String $json
  * @return type
  */
 private function _create_log($json)
 {
     if ($json === FALSE) {
         return FALSE;
     }
     //$this->output->enable_profiler(TRUE);
     //print_r($_POST);
     /*
             if (!isset($_POST["json"])) {
        $data = false;
        //$this->_display_jsonp($data, $callback);
        echo "aaaaaaaaaaaaaaaaaaaaa";
        return;
             }
             
             $json = $_POST["json"];
     */
     $data = json_to_object($json);
     //取得參考網址資料跟位於session的user
     //$url = $this->url;
     $user = $this->user;
     //取得來自$json的範圍資料
     $action = $data->action;
     $note = $data->note;
     //$t = "\u6578\u4f4d\u5716\u66f8\u9928\u6982\u8aaa";
     //test_msg(kals_json_encode($note));
     kals_log($this->db, $action, $note);
     context_complete();
     set_ignore_authorize(false);
     $data = true;
     //$this->_display_jsonp($data, $callback);
     return $data;
 }
示例#2
0
 private function _do_response($topic_annotation, $data)
 {
     set_ignore_authorize(true);
     // 開始新增標註回應
     //取得參考網址(全文網址)資料($url)跟現在登入(session)的user
     //$user_now = $this->session->userdata('user_id');
     $user_now = get_context_user();
     //建立範圍(使用topic_id取得)
     $scope_coll = $topic_annotation->get_scopes();
     //開始建立回應標註
     $new_res_annotation = $topic_annotation->create_annotation($user_now, $scope_coll);
     $type_id = $_POST["annotation_type"];
     $type_id = intval($type_id);
     //設定標註細節
     //echo 'set annotation detail ->';
     //type
     if (isset($type_id)) {
         $new_res_annotation->set_type($type_id);
     } else {
         //test_msg('no type_id');
         $data["error_message"] = $this->lang->line("mobile_apps.annotation_thread.error");
     }
     //note
     $note_message = $_POST["note"];
     if (isset($note_message) && $note_message !== '') {
         $new_res_annotation->set_note($note_message);
     } else {
         //test_msg('no note_msg');
         $data["error_message"] = $this->lang->line("mobile_apps.annotation_thread.error");
     }
     //標註錨點範圍的特徵(feature location)
     $feature_location = $topic_annotation->get_feature_location();
     if (isset($feature_location)) {
         $new_res_annotation->set_feature_location($feature_location);
     }
     //設定respond_topic_id
     $topic_id = $topic_annotation->get_id();
     $new_res_annotation->set_respond_to_topic($topic_id);
     //設定policy
     //echo 'start set policy';
     //$policy_type = 1;
     /*$this->load->library('policy/Authorize_manager');
               $ACTION_ANNOTATION_READ = 5;
               $auth->set_resource($annotation);
     
               if (is_array($share_user_coll)){
                  foreach ($share_user_coll AS $share_user)
                  {
                    //在這邊為該$annotation設定policy readable
                      $auth->policy_add_actor($ACTION_ANNOTATION_READ, $share_user);
                  }
                }
               else{
                  //清除該$annotation的policy
                  $auth->policy_remove_actor($ACTION_ANNOTATION_READ);
               }*/
     //test_msg("準備儲存?", $data["error_message"]);
     if (isset($data["error_message"]) === FALSE) {
         // 如果沒有錯誤
         //test_msg("準備儲存?");
         //先將權限設成管理者
         set_ignore_authorize(true);
         //回傳標註
         $new_res_annotation->update();
         set_ignore_authorize(false);
         // 寫入DB(若note不為空才寫入)
         context_complete();
     }
     return $data;
 }
示例#3
0
文件: mobile.php 项目: 119155012/kals
 /**
  * annotation_thread
  * @param type  $annotation_id
  */
 public function annotation_thread($annotation_id)
 {
     //載入libary
     $this->load->library('kals_resource/Webpage');
     $this->load->library('kals_resource/Annotation');
     $this->load->library('scope/Scope_anchor_text');
     $this->load->library('search/Search_annotation_collection');
     // 語系
     $this->lang->load('kals_web_apps');
     // 接收-送回應值
     // 用post接收textarea的值:array
     $data = array();
     if (isset($_POST["note_text"])) {
         $note_massage = $_POST["note_text"];
         $data["note_massage"] = $note_massage;
     }
     // radio-type
     if (isset($_POST["annotation_type"])) {
         $anno_type = $_POST["annotation_type"];
         $data['pop_type'] = $anno_type;
     }
     $annotation_self_id = $annotation_id;
     // check topic id
     $is_topic_id = NULL;
     if (isset($annotation_id)) {
         $topic_array = $this->db->query("SELECT topic_id\n                                   FROM annotation\n                                   WHERE annotation_id ='" . $annotation_id . "'");
         foreach ($topic_array->result_array() as $row) {
             $is_topic_id = $row['topic_id'];
         }
     }
     if ($is_topic_id !== NULL) {
         //is respond id
         $annotation_id = $is_topic_id;
     }
     //echo 'annotation_id ='.$annotation_id.'/';
     //echo 'topic_id = '.$is_topic_id.'/';
     // $login_test = $this->session->userdata('logged_in');
     //echo 'loggin = '.$login_test.'/';
     // $annotation_id
     $annotation = new Annotation($annotation_id);
     $annotation_id = $annotation->get_id();
     $log_topic_id = $annotation_id;
     $anchor_text = $annotation->get_anchor_text();
     $user = $annotation->get_user()->get_name();
     $user_id = $annotation->get_user()->get_id();
     $type = $annotation->get_type()->get_name();
     $css_type = $annotation->get_type()->get_type_id();
     $note = $annotation->get_note();
     $timestamp = $annotation->get_update_timestamp();
     //$log_user_id = $this->session->userdata('user_id');
     //echo $this->session->userdata('user_id').'??';
     //echo $this->session->userdata('logged_in').'??';
     $login_user = get_context_user();
     $log_user_id = NULL;
     $logged_id = FALSE;
     if (isset($login_user)) {
         $log_user_id = $login_user->get_id();
         $logged_id = TRUE;
     }
     // 如果有回應值才要做新增的動作
     if (isset($note_massage) && isset($anno_type)) {
         // 開始新增標註回應
         //先將權限設成管理者
         set_ignore_authorize(true);
         //取得參考網址(全文網址)資料($url)跟現在登入(session)的user
         //$user_now = $this->session->userdata('user_id');
         $user_now = get_context_user();
         //建立範圍(使用topic_id取得)
         $scope_coll = $annotation->get_scopes();
         //開始建立回應標註
         $new_res_annotation = $annotation->create_annotation($user_now, $scope_coll);
         $type_id = $anno_type;
         //設定標註細節
         //echo 'set annotation detail ->';
         //type
         if (isset($type_id)) {
             $new_res_annotation->set_type($type_id);
         } else {
             echo 'no type_id';
         }
         set_ignore_authorize(true);
         //note
         if (isset($note_massage) && $note_massage !== '') {
             $new_res_annotation->set_note($note_massage);
         } else {
             echo 'no note_msg';
         }
         //標註錨點範圍的特徵(feature location)
         $feature_location = $annotation->get_feature_location();
         if (isset($feature_location)) {
             $new_res_annotation->set_feature_location($feature_location);
         } else {
             echo 'no feature_location';
         }
         //設定respond_topic_id
         $topic_id = $annotation_id;
         if (isset($topic_id)) {
             $new_res_annotation->set_respond_to_topic($topic_id);
         } else {
             echo 'no topic id';
         }
         //設定policy
         //echo 'start set policy';
         $policy_type = 1;
         /*$this->load->library('policy/Authorize_manager');
                      $ACTION_ANNOTATION_READ = 5;
                      $auth->set_resource($annotation);
         
                      if (is_array($share_user_coll)){
                         foreach ($share_user_coll AS $share_user)
                         {
                           //在這邊為該$annotation設定policy readable
                             $auth->policy_add_actor($ACTION_ANNOTATION_READ, $share_user);
                         }
                       }
                      else{
                         //清除該$annotation的policy
                         $auth->policy_remove_actor($ACTION_ANNOTATION_READ);
                      }*/
         //回傳標註
         $new_res_annotation->update();
         set_ignore_authorize(false);
         // 寫入DB(若note不為空才寫入)
         if (isset($note_massage) && $note_massage !== '') {
             context_complete();
         }
     }
     //log區-mobile瀏覽討論-action = 41
     $action = 41;
     // data: topic_id
     $log_webpage = $annotation->get_append_to_webpages();
     $log_webpage_id = $log_webpage[0]->get_id();
     $array_data = array('target_topic' => FALSE, 'topic_id' => $log_topic_id, 'order_by' => 'create', 'show_total_count' => TRUE);
     kals_mobile_log($this->db, $log_webpage_id, $action, array('memo' => $array_data, 'user_id' => $log_user_id));
     context_complete();
     //寫入db
     $data['log_webpage_id'] = $log_webpage_id;
     // type
     if ($type != 'annotation.type.custom') {
         $type_show = $this->lang->line("web_apps." . $type);
         $type_name = $type_show;
     }
     // css-type
     switch ($css_type) {
         case 1:
             $css_type = 'importance';
             break;
         case 2:
             $css_type = 'concept';
             break;
         case 3:
             $css_type = 'confusion';
             break;
         case 4:
             $css_type = 'question';
             break;
         case 5:
             $css_type = 'example';
             break;
         case 6:
             $css_type = 'summary';
             break;
         case 7:
             $css_type = 'other';
             break;
         case 8:
             $css_type = 'custom';
             break;
         default:
             $css_type = 'importance';
             break;
     }
     // annotation_respones
     $respond_collection = $annotation->get_topic_respond_coll();
     $respond_json = array();
     foreach ($respond_collection as $respond_annotation) {
         $json = array();
         $json["annotation_id"] = $respond_annotation->get_id();
         $json["user"] = $respond_annotation->get_user()->get_name();
         $css_res_type = $respond_annotation->get_type()->get_type_id();
         $res_type = $respond_annotation->get_type()->get_name();
         if ($res_type != 'annotation.type.custom') {
             $res_type_show = $this->lang->line("web_apps." . $res_type);
             $res_type = $res_type_show;
         } else {
             $res_type_show = $this->lang->line("web_apps." . 'annotation.type.other');
             $res_type = $res_type_show;
         }
         switch ($css_res_type) {
             case 1:
                 $css_res_type = 'importance';
                 break;
             case 2:
                 $css_res_type = 'concept';
                 break;
             case 3:
                 $css_res_type = 'confusion';
                 break;
             case 4:
                 $css_res_type = 'question';
                 break;
             case 5:
                 $css_res_type = 'example';
                 break;
             case 6:
                 $css_res_type = 'summary';
                 break;
             case 7:
                 $css_res_type = 'other';
                 break;
             case 8:
                 $css_res_type = 'custom';
                 break;
             default:
                 $css_res_type = 'importance';
                 break;
         }
         $json["css_type"] = $css_res_type;
         $json["type"] = $res_type;
         $json["note"] = $respond_annotation->get_note();
         $sub_res_timestamp = $respond_annotation->get_update_timestamp();
         $json["timestamp"] = substr($sub_res_timestamp, 0, 10);
         $respond_json[] = $json;
     }
     //$respond_json[0]['user'];
     // 詳見全文url:Webpage -> get_url()
     $webpage = $annotation->get_append_to_webpages();
     $webpage_id = $webpage[0]->get_id();
     //$webpage_id = 1573;
     $mobile_webpage = new Webpage($webpage_id);
     $url = $mobile_webpage->get_url();
     $data['webpage_url'] = $url;
     $data['webpage_id'] = $webpage_id;
     $data['webpage'] = $webpage;
     // send data -annotation topic
     $data["annotataion_id"] = $annotation_id;
     $data["annotation_self_id"] = $annotation_self_id;
     $data["anchor_text"] = $anchor_text;
     $data["user"] = $user;
     $data["type"] = $type;
     $data["type_name"] = $type_name;
     $data["css_type"] = $css_type;
     $data["note"] = $note;
     $sub_timestamp = substr($timestamp, 0, 10);
     $data["timestamp"] = $sub_timestamp;
     $data["respond_json"] = $respond_json;
     $this->load->view('mobile/mobile_views_header');
     $this->load->view('mobile/annotation_thread_view', $data);
     $this->load->view('mobile/mobile_views_footer');
 }
示例#4
0
 /**
  * 
  * @param Annotation $annotation
  * @return Boolean
  */
 private function _delete_annotation($annotation)
 {
     $annotation_id = $annotation->get_id();
     $annotation_user = $annotation->get_user();
     //test_msg('delete', $annotation_user->get_id());
     if (is_null($annotation_user->get_id())) {
         $data = show_error('No annotation.');
         return $this->_display_jsonp($data, $callback);
     }
     $user = $this->user;
     if ($user->equals($annotation_user) === FALSE) {
         $data = show_error('Permission deny.');
         return $this->_display_jsonp($data, $callback);
     }
     $action = "image_spot.delete";
     kals_log($this->db, $action, $annotation_id);
     set_ignore_authorize(true);
     $annotation->delete();
     context_complete();
     set_ignore_authorize(false);
 }
示例#5
0
 public function recommend_reject($json, $callback)
 {
     $annotation_id = $json;
     $annotation = new Annotation($annotation_id);
     $annotation_user = $annotation->get_user();
     $user = $this->user;
     if ($annotation_user->equals($user) == false) {
         $data = create_json_excpetion('Set Annnotation Recommend Error', 'You cannot set annotation recommend whick is not yours.');
         return $this->_display_jsonp($data, $callback);
     }
     $recommend = $annotation->get_recommend();
     //log區
     $array_data = $recommend->get_id();
     $action = 26;
     $user_id = NULL;
     if (isset($user)) {
         $user_id = $user->get_id();
     }
     kals_log($this->db, $action, array('memo' => $array_data, 'user_id' => $user_id));
     set_ignore_authorize(true);
     $recommend->set_accept(FALSE);
     set_ignore_authorize(false);
     context_complete();
     $data = TRUE;
     return $this->_display_jsonp($data, $callback);
 }