--- annotate.module.ORIG 2009-08-05 00:15:53.000000000 +0000 +++ annotate.module 2009-08-05 00:58:09.000000000 +0000 @@ -257,7 +257,9 @@ function annotate_private_entry_form_sub $note = trim( $form_state['values']['note']); $visibility = $form_state['values']['visibility']; - db_query("DELETE FROM {annotations} WHERE uid = %d and nid = %d", $user->uid, $nid); + ////////// + // let's NOT delete prior annotation(s) for uid+nid, so we can have multiple notes per uid+nid + // db_query("DELETE FROM {annotations} WHERE uid = %d and nid = %d", $user->uid, $nid); if (isset($note) && strlen($note)) { db_query("INSERT INTO {annotations} (uid, nid, note_format, note, visibility, timestamp) VALUES (%d, %d, %d, '%s', %d, %d)" @@ -310,22 +312,35 @@ function _annotate_list_by_sql() { function _annotate_list_by_user($account_uid) { global $user; - $sql = _annotate_list_by_sql() ." WHERE a.uid = %d"; + // BOWEN: get annotations by profile NID not user UID, so we see all annotations FOR Profile, + // not just annotations BY User + $result = db_query("SELECT nid FROM {node} WHERE type = 'profile' AND uid = %d ORDER BY created DESC LIMIT 1", $account_uid); + $profile = db_fetch_object($result); + if( $profile ) { + $sql = _annotate_list_by_sql() ." WHERE a.nid = %d"; + $sql .= " ORDER BY a.timestamp DESC"; // added so we can make sense of multiple notes per uid+nid + $result = db_query( $rewrite = db_rewrite_sql( $sql ), $profile->nid); + } else { + + $sql = _annotate_list_by_sql() ." WHERE a.uid = %d"; + + if ($user->uid==$account_uid || $user->uid==1) { + // own account : $account_uid == $user-> uid ==> show all + // user-1 ==> show all + $filter = ""; + } + else { + $filter =" a.visibility=2" // public annotations + ." OR (n.uid=%d AND a.visibility=1)"; // current node editor + + // AND-wrap + $filter = " AND (". $filter .")"; + } + $sql .= " ORDER BY a.timestamp DESC"; // added so we can make sense of multiple notes per uid+nid + $result = db_query( $rewrite = db_rewrite_sql( $sql . $filter), $account_uid, $user->uid); - if ($user->uid==$account_uid || $user->uid==1) { - // own account : $account_uid == $user-> uid ==> show all - // user-1 ==> show all - $filter = ""; - } - else { - $filter =" a.visibility=2" // public annotations - ." OR (n.uid=%d AND a.visibility=1)"; // current node editor - - // AND-wrap - $filter = " AND (". $filter .")"; - } + } - $result = db_query( $rewrite = db_rewrite_sql( $sql . $filter), $account_uid, $user->uid); return $result; } @@ -354,6 +369,7 @@ function _annotate_list_by_node($nid) { $filter = " AND (". $filter .")"; } + $sql .= " ORDER BY a.timestamp DESC"; // added so we can make sense of multiple notes per uid+nid $result = db_query( db_rewrite_sql( $sql . $filter) , $nid, $uid, $uid); return $result;