From e9192b3d42660a5781101df4357d276318151e8a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:14:41 -0500 Subject: cgi-bin & lib --- lib/keywords.pm | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 lib/keywords.pm (limited to 'lib/keywords.pm') diff --git a/lib/keywords.pm b/lib/keywords.pm new file mode 100644 index 0000000..c600cd6 --- /dev/null +++ b/lib/keywords.pm @@ -0,0 +1,187 @@ +############################################### + +sub keyword_assign_mechanism + { + my ($kn, $tn, $ko) = @_; + if (!defined($kn)) + { error("no keyword specified!"); } + if (!defined($tn)) + { error("no post specified!"); } + if (!defined($ko)) + { $ko = get_keyword($kn); } + my %nk = + ( + threads => add_key($ko->{threads}, $tn) + ); + if ($DEBUG) + { + header("Assigning post to $kn"); + menu(); + foreach my $ky (keys %nk) + { print "$ky => $nk{$ky}
\n"; } + print "keyword ==> $kn
\n"; + } + update_keyword($kn, \%nk); + update_thread_keyword($tn, $kn); + } + +############################################### + +sub keyword_pulldown + { + my ($selected) = @_; + my $keywords = get_keywords(); + + if (! ($selected && $selected ne "all")) + { + if ($USER->{'username'} eq "flop4andy") + { + $selected = "dreamteamer"; + } + else + { + $selected = $BUCKY_DEFAULT_KEYWORD; + } + } + + print qq!\n!; + return; + } + +# return unless ($sees_private_keys); + + print qq!!; + foreach my $k (sort { lc($a) cmp lc($b) } keys %$keywords) + { + my $kh = $keywords->{$k}; + next if ($kh->{public} == 1); + next unless ($kh->{owner} eq $USER->{username} || check_op($kh)); + print qq!!; + } + print qq!\n!; + } + +############################################### + +sub keyword_form + { + my ($keyword, $k, $t) = @_; + my $checked = ""; + my $verb = "MODIFY"; + my $command = ($keyword eq "new") ? "create" : "update"; + $t = -1 unless (defined ($t)); + + # keyword ops(matrix) public(checkbox) agglutinate(checkbox) + + print < + +kf + print qq!\n! if ($DEBUG); + print < + +category + +kf + if ($keyword eq "new") + { + $verb = "CREATE"; + print qq!!; + } + else + { + print qq!$keyword!; + print qq!\n!; + } + print < + +kf + if ($t != -1) + { + print < +initial post +$t->{title} + +pub + } + + $checked = ($k->{public} == 1) ? " checked" : ""; + print < +color + +pub + my $rcolor = get_color(-1, $k); + color_dropdown($rcolor, 0); + print < + + +anyone can post + + +kf + + if ($k->{public} != 1 || $t != -1) + { + print < +operators + +kf + print qq!
!; + print qq!\n!; + print qq!--- if "anyone can post" is unchecked ---
users checked off below will share control of this category,
and will be able to add new posts to it,
alter privacy/color settings, etc.

\n!; + print qq!
!; + if ($t != -1) + { user_checkerboard($t->{allowed}, undef); } + elsif (exists($k->{ops})) + { user_checkerboard($k->{ops}, undef); } + else + { user_checkerboard($k->{owner}, undef); } + print qq!
!; + + print < + +kf + } + + print < +  + + + + + +kf + } + +############################################### + +1; + -- cgit v1.2.3-70-g09d2