Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
 public static function store_extended_properties($id = false, &$prefs)
 {
     if ($id == false) {
         $id = self::my_id();
     }
     $dict = array();
     $defaults = self::$extended_properties;
     foreach ($prefs as $k => $v) {
         if ($v !== '' && isset($defaults[$k]) && $defaults[$k] != $v) {
             switch ($k) {
                 case 'rules':
                 case 'message':
                     $dict[$k] = clean_text_with_tags($v, 0, false, 300);
                     break;
                 default:
                     $dict[$k] = mb_substr(clean_input_string($v), 0, 100);
             }
         }
     }
     $key = self::PREFERENCES_KEY . $id;
     $a = new Annotation($key);
     if (!empty($dict)) {
         $json = json_encode($dict);
         $a->text = $json;
         return $a->store();
     }
     return $a->delete();
 }
Exemplo n.º 3
0
 public static function store_extended_properties($id = false, &$prefs)
 {
     if ($id == false) {
         $id = self::my_id();
     }
     $dict = array();
     $defaults = array_merge(self::$extended_properties, self::$extra_extended_properties);
     foreach ($prefs as $k => $v) {
         if ($v !== '' && isset($defaults[$k]) && $defaults[$k] != $v) {
             switch ($k) {
                 case 'rules':
                 case 'message':
                     $dict[$k] = clean_text_with_tags($v, 0, false, 3000);
                     break;
                 case 'post_html':
                     // TODO: validate the HTML
                     $dict[$k] = $v;
                     break;
                 default:
                     if (isset($defaults[$k]) && is_int($defaults[$k])) {
                         $dict[$k] = intval($v);
                     } else {
                         $dict[$k] = mb_substr(clean_input_string($v), 0, 140);
                     }
             }
         }
     }
     $key = self::PREFERENCES_KEY . $id;
     $a = new Annotation($key);
     if (!empty($dict)) {
         $json = json_encode($dict);
         $a->text = $json;
         return $a->store();
     }
     return $a->delete();
 }