Forum OpenACS Q&A: Response to Breakthrough on bookmarks module (Final posting, for now)

Changes in most-popular-public.tcl and toggle-open-close.tcl

In most-popular-public.tcl, I had to change two queries to reflect the presence of the "dummy" entry (for folders) that I added to bm_urls. The two queries now read as follows:
# -- get the most popular hosts ----------- set selection [ns_db select $db "select host_url, count(*) as n_bookmarks from bm_urls, bm_list where bm_urls.url_id = bm_list.url_id and bm_list.private_p <> 't' and bm_urls.url_id > 0 group by host_url order by n_bookmarks desc"]
and:
set selection [ns_db select $db "select complete_url, url_title, count(*) as n_bookmarks from bm_urls, bm_list where bm_urls.url_id = bm_list.url_id and bm_list.private_p <> 't' and bm_urls.url_id > 0 group by complete_url, url_title order by n_bookmarks desc"]

And, finally, for toggle-open-close.tcl, the part I changed was after the "begin transaction". Here's the corrected version (note that the final line needs to be commented out -- it's uncommented in the original):

if { [string compare $action "open_all"] == 0 } { # we're assuming if all are open, no bookmarks are in closed folders! ns_db dml $db "update bm_list set closed_p = 'f', in_closed_p = 'f' where owner_id = $user_id" } elseif { [string compare $action "close_all"] == 0 } { # ... and if all folders are closed, all bookmarks are in closed folders! ns_db dml $db "update bm_list set closed_p = 't' where owner_id = $user_id" ns_db dml $db "update bm_list set in_closed_p = 't' where owner_id = $user_id and parent_id is not null" } else { validate_integer bookmark_id $bookmark_id # determine current state of folder (closed/open) set closed_p [database_to_tcl_string $db " select closed_p from bm_list where bookmark_id = $bookmark_id"] if { $closed_p == "t" } { ns_db dml $db " update bm_list set closed_p = 'f' where bookmark_id = $bookmark_id and owner_id = $user_id" set closed_p "f" } else { ns_db dml $db " update bm_list set closed_p = 't' where bookmark_id = $bookmark_id and owner_id = $user_id" set closed_p "t" } bm_set_one_in_closed_p $db $user_id $bookmark_id $closed_p } # bm_set_in_closed_p $db $user_id

Hopefully this covers everything. Please let me know if there are any questions or problems.


Final observations

If I've communicated everything correctly, these changes should result in a working bookmarks module. However, although the basic functionality (as detailed in the "Original question") should now be available, there are definitely certain items still missing, such as import/export. However, they should be much easier to track down and fix, now that the basic module is (or should be) working, once these fixes have been applied.