[Refdb-cvs] CVS: refdb/src backend-html.c,1.27.2.5,1.27.2.6 backend-scrn.c,1.17.2.4,1.17.2.5 backend
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-09-22 21:40:16
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8744 Modified Files: Tag: Release_0_9_5_stable backend-html.c backend-scrn.c backend.c backend.h Log Message: added handling of public and private notes Index: backend-html.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-html.c,v retrieving revision 1.27.2.5 retrieving revision 1.27.2.6 diff -u -U2 -r1.27.2.5 -r1.27.2.6 --- backend-html.c 18 Sep 2005 22:51:24 -0000 1.27.2.5 +++ backend-html.c 22 Sep 2005 21:40:08 -0000 1.27.2.6 @@ -1477,5 +1477,5 @@ /* look for additional notes linked with the record, keywords, authors, or periodicals */ - if ((dbires = request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires), atoll(id), REFERENCE|KEYWORD|AUTHOR|PERIODICAL, ptr_rendinfo->username)) == NULL) { + if ((dbires = request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires), atoll(id), REFERENCE|KEYWORD|AUTHOR|PERIODICAL, ptr_rendinfo->username, ptr_rendinfo->ptr_clrequest->share_default)) == NULL) { /* printf("request_notes_by_ref() failed\n"); */ free_request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires)); Index: backend-scrn.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-scrn.c,v retrieving revision 1.17.2.4 retrieving revision 1.17.2.5 diff -u -U2 -r1.17.2.4 -r1.17.2.5 --- backend-scrn.c 18 Sep 2005 22:51:25 -0000 1.17.2.4 +++ backend-scrn.c 22 Sep 2005 21:40:08 -0000 1.17.2.5 @@ -25,4 +25,6 @@ #include "refdb.h" +#include "linklist.h" +#include "refdbd.h" #include "backend.h" #include "backend-scrn.h" @@ -30,4 +32,5 @@ #include "strfncs.h" #include "dbfncs.h" +#include "connect.h" #ifndef HAVE_ATOLL @@ -859,5 +862,5 @@ if (strstr((ptr_rendinfo->ptr_biblio_info)->format_string, "NX") != NULL || strstr((ptr_rendinfo->ptr_biblio_info)->format_string, "ALL") != NULL) { - if ((dbires = request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires), atoll(id), REFERENCE|KEYWORD|AUTHOR|PERIODICAL, ptr_rendinfo->username)) == NULL) { + if ((dbires = request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires), atoll(id), REFERENCE|KEYWORD|AUTHOR|PERIODICAL, ptr_rendinfo->username, (ptr_rendinfo->ptr_clrequest)->share_default)) == NULL) { /* printf("request_notes_by_ref() failed\n"); */ free_request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires)); Index: backend.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.c,v retrieving revision 1.27.2.9 retrieving revision 1.27.2.10 diff -u -U2 -r1.27.2.9 -r1.27.2.10 --- backend.c 21 Sep 2005 23:27:36 -0000 1.27.2.9 +++ backend.c 22 Sep 2005 21:40:08 -0000 1.27.2.10 @@ -321,5 +321,5 @@ result = dbi_result_get_short(dbires, "note_share"); if (dbi_conn_error_flag(dbi_result_get_conn(dbires))) { - return NULL; + return 0; /* be paranoid in case of an error */ } else { @@ -342,10 +342,13 @@ const char* user name of current user + int share 1=share by default, 0=hide by default + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -dbi_result request_notes_by_ref(dbi_conn conn, unsigned long long n_id, int mode, const char* user) { +dbi_result request_notes_by_ref(dbi_conn conn, unsigned long long n_id, int mode, const char* user, int share) { int nis_first = 1; char* sql_command; char* sql_chunk; const char* drivername; + char userspec[512]; dbi_result dbires; dbi_driver driver; @@ -369,9 +372,17 @@ *sql_command = '\0'; + /* assemble substring which selects the notes based on the share settings */ + if (share) { + snprintf(userspec, 512, "(t_user.user_name=\'%s\' OR (t_user.user_name!=\'%s\' AND t_note.note_share!=0))", user, user); + } + else { + snprintf(userspec, 512, "(t_user.user_name=\'%s\' OR (t_user.user_name!=\'%s\' AND t_note.note_share=1))", user, user); + } + if (!strcmp(my_dbi_driver_get_cap(driver, "union"), "t")) { if (mode & REFERENCE) { sprintf(sql_chunk, - "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", - user, + "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", + userspec, (unsigned long long)n_id); @@ -382,6 +393,6 @@ if (mode & KEYWORD) { sprintf(sql_chunk, - "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", - user, + "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", + userspec, (unsigned long long)n_id); @@ -395,6 +406,6 @@ if (mode & AUTHOR) { sprintf(sql_chunk, - "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", - user, + "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", + userspec, (unsigned long long)n_id); @@ -408,6 +419,6 @@ if (mode & PERIODICAL) { sprintf(sql_chunk, - "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", - user, + "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", + userspec, (unsigned long long)n_id); @@ -485,6 +496,6 @@ if (mode & REFERENCE) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", - user, + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", + userspec, (unsigned long long)n_id); @@ -502,6 +513,6 @@ if (mode & KEYWORD) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", - user, + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", + userspec, (unsigned long long)n_id); @@ -519,6 +530,6 @@ if (mode & AUTHOR) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", - user, + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", + userspec, (unsigned long long)n_id); @@ -536,6 +547,6 @@ if (mode & PERIODICAL) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", - user, + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND %s AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", + userspec, (unsigned long long)n_id); Index: backend.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.h,v retrieving revision 1.23.2.5 retrieving revision 1.23.2.6 diff -u -U2 -r1.23.2.5 -r1.23.2.6 --- backend.h 21 Sep 2005 23:27:36 -0000 1.23.2.5 +++ backend.h 22 Sep 2005 21:40:08 -0000 1.23.2.6 @@ -101,5 +101,5 @@ const char* get_refdb_note_content_type(dbi_result dbires); const char* get_refdb_note_content_xmllang(dbi_result dbires); -dbi_result request_notes_by_ref(dbi_conn conn, unsigned long long n_id, int mode, const char* user); +dbi_result request_notes_by_ref(dbi_conn conn, unsigned long long n_id, int mode, const char* user, int share); int free_request_notes_by_ref(dbi_conn conn); dbi_result request_links(dbi_conn conn, unsigned long long n_id, int mode); |