Esempio n. 1
0
 /**
  * 確認是否是topic_annotation
  * @param Annotation $annotation
  */
 private function _check_is_topic($annotation)
 {
     if ($annotation->is_respond()) {
         $topic_id = $annotation->get_topic()->get_id();
         $respond_id = $annotation->get_id();
         $annotation_thread_uri = site_url("mobile_apps/annotation_thread/topic_id/" . $topic_id . "#respond_" . $respond_id);
         // 轉走
         redirect($annotation_thread_uri);
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 2
0
 private function _edit_process($json)
 {
     $data = json_to_object($json);
     //先將權限設成管理者
     set_ignore_authorize(true);
     //取得參考網址資料跟位於session的user
     $user = $this->user;
     $annotation = NULL;
     if (isset($data->annotation_id)) {
         $annotation = new Annotation($data->annotation_id);
         $annotation_user = $annotation->get_user();
         if ($user->get_id() == $annotation_user->get_id()) {
             $data = $this->_setup_annotation($annotation, $data);
             //edit之後重算分數
             set_ignore_authorize(true);
             $annotation = new Annotation($annotation->get_id());
             if ($annotation->is_respond() === FALSE) {
                 $annotation = $this->_setup_scores($annotation);
                 //$annotation->update();
             }
             context_complete();
             set_ignore_authorize(false);
         } else {
             $data = create_json_excpetion('Edit Annnotation Error', 'You cannot edit annotation whick is not yours.');
         }
     } else {
         $data = create_json_excpetion('Edit Annnotation Error', 'Annotation ID is NULL');
     }
     //log區
     $array_data = NULL;
     if (isset($annotation)) {
         $array_data = $annotation->export_webpage_data($this->url);
     }
     $action = 15;
     if ($annotation->is_respond()) {
         $action = 21;
     }
     $user_id = NULL;
     if (isset($user)) {
         $user_id = $user->get_id();
     }
     kals_log($this->db, $action, array('memo' => $array_data, 'user_id' => $user_id));
     return $data;
 }