##sub THEFAKEOUT contains the actual nodelet ## the rest of the stuff is just for testing puroses ## you can see real life results after __END__ #=pod package FUDGE; sub new { return bless {}, shift }; { my $bob = 0; sub sqlSelect{ $bob++; ## IsApproved? return 1 if $bob==1; ## IsFrontpaged? return 1 if $bob==2; ## ApprovedBy? return 10277 if $bob==3; ## FrontpagedBy? return 10277 if $bob==4; ## IsConsidered? return "DELETE - OBVIOUS" if $bob==5; # I frontpage, approve, and consider everything }; } package main; use strict; use warnings; use vars qw( $NODE $DB ); $DB = new FUDGE; $NODE = { type => { title => "note" } }; sub getId{10277} sub linkNode{my($id,$alt)=@_;return"[id://$id".($alt?"|$alt]":"]");} sub getVars { return { types => "note,monkdiscuss", note_node => 1, note_linktype => 1, front_page => 1, frontpage_linktype => 1, }; }; sub getNode {} print "THEFAKEOUT
\n ", THEFAKEOUT(); #=cut sub THEFAKEOUT { # ahoy hoy # this just be the approval nodelet stripped naked (mostly) # title: Node Status # or # Mini Approval Nodelet # In the code below, you'll see a few comments like # IsApproved? # these ought to be made into htmlcodes, and eventually, make it # into their own package, like Everything::Moderation::Approval #[% my $SETTING = getVars( getNode('approval nodelet settings','setting') ); my $type = $NODE->{type}{title}; my %types; { my @types = split /,/, $SETTING->{types}; @types{@types} = (1) x @types; } return unless $types{$type} or grep( $_ eq $type, qw( modulereview bookreview note sourcecode snippet perltutorial perlnews ) ); my $nid = getId($NODE); my $ok = 0; ## IsApproved? $ok = $DB->sqlSelect( '*', 'links', "from_node = $SETTING->{$type.'_node'}" . " and to_node = $nid" . " and linktype = $SETTING->{$type.'_linktype'}", "limit 1" ) if $types{$type}; ## IsFrontpaged? my $fp = 0; $fp = $DB->sqlSelect( '*', 'links', "from_node = $SETTING->{'front_page'}" . " and to_node = $nid" . " and linktype = $SETTING->{'frontpage_linktype'}", "limit 1" ) if $types{$type}; ## Node Type ~ like %S for titles in [id://27|basichead] my $message = "Node Type: $NODE->{type}{title}
"; if( $ok || $fp ) { my $okid = 0; ## ApprovedBy? $okid = $DB->sqlSelect( 'user_id', 'approved', qq{node_id = $nid and action = "ok"}, "order by tstamp desc limit 1" ) if $ok; my $fpid = 0; ## FrontpagedBy? $fpid = $DB->sqlSelect( 'user_id', 'approved', qq{node_id = $nid and action = "fp"}, "order by tstamp desc limit 1" ) if $ok; ## The Actual Status Messages if( $ok and $okid ) { $message .= sprintf 'Approved by %s
', linkNode($okid); } else { $message .= "This node hasn't been approved yet
"; } if( $fp and $fpid ){ $message .= sprintf 'Front-paged by %s
', linkNode($fpid); } } ## IsConsidered? my $considered = $DB->sqlSelect( 'description', 'considernodes', "considernodes_id = $nid" ); if( $considered) { $considered =~ s/^[(](.+?)[)](.*)/ sprintf '(%s) %s', linkNodeTitle($1), $2/eg; $message .= linkNode(28877, 'Considered') . ': ' . $considered . '
'; } return $message . linkNode(17645, 'help'); #%] }# end of sub THEFAKEOUT __END__ #