\n"," ",$text);// remove the breaks added by get.php $page = getval('page', 1); $id=getval('id',0,true); $preview_width=getval('pw',''); $preview_height=getval('ph',''); $curnode=ps_value("SELECT node value FROM annotate_notes WHERE ref= ? AND note_id= ?",['i', $ref, 'i', $id],""); if (substr($text,0,strlen($username))!=$username) { $text=$username.": ".$text; } if ($curnode > 0 && get_nodes_use_count([$curnode]) == 1) { // Reuse same node $savenode = set_node($curnode,$annotate_resource_type_field,$text,null,0); } else { // Remove node from resource and create new node delete_resource_nodes($ref,[$curnode]); $savenode = set_node(null,$annotate_resource_type_field,$text,null,0); add_resource_nodes($ref,[$savenode], true, true); } if ($id > 0) { ps_query("DELETE FROM annotate_notes WHERE ref= ? AND note_id= ?", ['i', $ref, 'i', $id]); } if (substr($text,0,strlen($username))!=$username) { $text=$username.": ".$text; } ps_query("INSERT INTO annotate_notes (ref,top_pos,left_pos,width,height,preview_width,preview_height,node,user,`page`) VALUES (?,?,?,?,?,?,?,?,?,?) ", [ 'i',$ref, 'i',$top, 'i',$left, 'i',$width, 'i',$height, 'i',$preview_width, 'i',$preview_height, 'i',$savenode, 'i',$userref, 'i',$page ] ); $annotateid = sql_insert_id(); echo $annotateid; $notes=ps_query("SELECT count(note_id) FROM annotate_notes WHERE ref= ?", ['i', $ref]); ps_query("UPDATE resource SET annotation_count= ? WHERE ref= ?", ['i', count($notes), 'i', $ref]);