Exemplo n.º 1
0
 private function _find_recommend_annotation(Annotation $annotation)
 {
     $scope_coll = $annotation->get_scopes();
     $user = $annotation->get_user();
     $recommend_scope = $annotation->get_recommend_by_scopes();
     if (is_null($recommend_scope)) {
         $recommend_scope = $scope_coll;
     }
     $target_over_score = $this->_get_recommend_by_threshold();
     $this->_CI_load('library', 'search/Search_order_score', 'search_order_score');
     $order_type_id = $this->CI->search_order_score->get_type_id();
     $this->_CI_load('library', 'search/Search_annotation_collection', 'search_annotation_collection');
     $search = new Search_annotation_collection();
     $search->set_limit(1);
     $search->add_order($order_type_id, TRUE);
     $search->set_overlap_scope($recommend_scope);
     $search->set_exclude_scope($scope_coll);
     $search->set_exclude_user($user);
     $search->set_target_over_score($target_over_score);
     if ($search->length() == 1) {
         return $search->get_item(0);
     } else {
         return NULL;
     }
 }
Exemplo n.º 2
0
 public function check_auth()
 {
     create_context(TRUE);
     $url = 'http://www.plurk.com/p/6dhwp7';
     $email = '*****@*****.**';
     $group_name = 'check_auth';
     $user = $this->user->create_user($url, $email);
     $group = $this->group->create_group($url, $group_name);
     $group->add_actor($user);
     $annotation = new Annotation(784);
     $this->authorize_manager->set_resource($annotation);
     $this->authorize_manager->policy_add_actor(5, $group);
     clear_context_user();
     $search = new Search_annotation_collection();
     $count = $search->length();
     $this->unit->run($count, 'is_int', '先找看看有沒有,應該是有的');
     set_context_user($user);
     $search = new Search_annotation_collection();
     $this->unit->run($search->length(), $count + 1, '設定權限之後,應該能找到被設定的那一個項目');
     unit_test_report($this);
 }
Exemplo n.º 3
0
 /**
  * 取得tooltip指定的標註
  * @param int $annotation_index 標註的位置
  * @param string $callback
  */
 public function tooltip($annotation_index, $callback)
 {
     // -------------
     // 搜尋
     //$annotation_index = 100000;
     $search = new Search_annotation_collection();
     // 限定範圍
     $search->set_overlap_scope_index($annotation_index, $annotation_index);
     // 依照分數排序,由高到低
     $search->add_order(1, TRUE);
     // 只輸出一份
     //$search->set_limit(1);
     // 限定該網頁
     $search->set_target_referer_webpage();
     //--------------
     // 轉換資料
     //$annotation = new Annotation();
     //$annotation = null;
     $annotation = null;
     $output_data = array();
     $result = null;
     foreach ($search as $search_annotation) {
         $annotation = $search_annotation;
         $result = $annotation->get_id();
         $output_data["annotation"] = $annotation->export_data();
         break;
     }
     $output_data["count"] = $search->length();
     //--------------
     // 記錄
     $action = 35;
     $log_note = array('index' => $annotation_index, 'result' => $result);
     kals_log($this->db, $action, $log_note);
     context_complete();
     // -------------
     // 輸出
     return $this->_display_jsonp($output_data, $callback);
 }