[dw-free] Allow S2 to access whether the viewer is allowed to manage tags on the journal they are vi
[commit: http://hg.dwscoalition.org/dw-free/rev/f125de3aa6c8]
http://bugs.dwscoalition.org/show_bug.cgi?id=663
Print out the link to the manage tags page after your list of tags in the
tags module, if you have the ability to edit tags on this journal (instead
of guessing when you might have the ability to). This means the link now
shows up in community journals as well. Adds a new function
viewer_can_manage_tags to make this possible.
Patch by
foxfirefey.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=663
Print out the link to the manage tags page after your list of tags in the
tags module, if you have the ability to edit tags on this journal (instead
of guessing when you might have the ability to). This means the link now
shows up in community journals as well. Adds a new function
viewer_can_manage_tags to make this possible.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/s2layers/core2.s2
- cgi-bin/LJ/S2.pm
- cgi-bin/LJ/User.pm
-------------------------------------------------------------------------------- diff -r dee8e6dde855 -r f125de3aa6c8 bin/upgrading/s2layers/core2.s2 --- a/bin/upgrading/s2layers/core2.s2 Fri Jun 11 13:12:39 2010 +0800 +++ b/bin/upgrading/s2layers/core2.s2 Fri Jun 11 13:26:55 2010 +0800 @@ -925,6 +925,9 @@ function builtin viewer_can_search() : b function builtin viewer_can_search() : bool "Returns true if the user viewing the page is logged in and can search that journal."; +function builtin viewer_can_manage_tags() : bool +"Returns true if the user viewing the page can add, edit, and delete tags on the journal being viewed."; + function builtin viewer_sees_control_strip [fixed] : bool "Returns true if reader will see the built in control strip."; @@ -3389,10 +3392,10 @@ function server_sig() """<span id="site-branding">$*text_powered_by <a href="$*SITEROOT/">$*SITENAME</a></span>"""; } -function print_tag_manage_link() "Prints out a link to the tag management page, if the viewer is the owner of the journal in question. Does not work on community pages." -{ - var Page p = get_page(); - print viewer_is_owner() ? "<div class=\"manage-tags-link\"><a href=\"" + $p.journal->tag_manage_url() + "\">$*text_tags_manage</a></div>" : ""; +function print_tag_manage_link() "Prints out a link to the tag management page, if the viewer can manage tags." +{ + var Page p = get_page(); + print viewer_can_manage_tags() ? "<div class=\"manage-tags-link\"><a href=\"" + $p.journal->tag_manage_url() + "\">$*text_tags_manage</a></div>" : ""; } function print_list_tags(TagDetail[] tagslist, string{} opts) "Prints out a list of tags. Takes as arguments the taglist and a hash with optional arguments 'list-class' and 'item-class'. 'print_uses' option can be 'number', 'text' or 'title' to determine whether to display the uses as a number, as full text, or in the link title. It defaults to full text" diff -r dee8e6dde855 -r f125de3aa6c8 cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Fri Jun 11 13:12:39 2010 +0800 +++ b/cgi-bin/LJ/S2.pm Fri Jun 11 13:26:55 2010 +0800 @@ -2638,6 +2638,17 @@ sub viewer_is_moderator { return LJ::check_rel( $ju, $remote, 'M' ); } +sub viewer_can_manage_tags +{ + my $remote = LJ::get_remote(); + return 0 unless $remote; + return 0 unless defined $LJ::S2::CURR_PAGE; + + my $ju = $LJ::S2::CURR_PAGE->{_u}; + return 1; + return $remote->can_control_tags( $ju ); +} + sub viewer_sees_control_strip { return 0 unless $LJ::USE_CONTROL_STRIP; diff -r dee8e6dde855 -r f125de3aa6c8 cgi-bin/LJ/User.pm --- a/cgi-bin/LJ/User.pm Fri Jun 11 13:12:39 2010 +0800 +++ b/cgi-bin/LJ/User.pm Fri Jun 11 13:26:55 2010 +0800 @@ -5446,6 +5446,12 @@ sub can_add_tags_to { return LJ::Tags::can_add_tags($targetu, $u); } +# can $u control (add, delete, edit) the tags of $targetu? +sub can_control_tags { + my ($u, $targetu) = @_; + + return LJ::Tags::can_control_tags($targetu, $u); +} # <LJFUNC> # name: LJ::User::get_keyword_id --------------------------------------------------------------------------------
no subject
+ return $remote->can_control_tags( $ju );
Erk?
no subject