#-------------------------------------------------------------------# # Mods.Like.pm # #-------------------------------------------------------------------# # Like 4 YaBB2612 # # Version 0.5 # # by Carsten Dalgaard # #-------------------------------------------------------------------# # Copyright: 2013 'Carsten Dalgaard' - All Rights Reserved # # e-mail: post@carsten-dalgaard.dk # #-------------------------------------------------------------------# # Any redistribution of this script without the expressed written # # consent of 'Carsten Dalgaard' is strictly prohibited. Copying any # # of the code contained within this script and claiming it as # # your own is also prohibited. # #-------------------------------------------------------------------# # By using this script you agree to indemnify 'Carsten Dalgaard' # # from any liability that might arise from its use. # #-------------------------------------------------------------------# # You may not remove any of these header notices. # #-------------------------------------------------------------------# $likepmver = 'YaBBForum 3.1'; if ( $action eq 'detailedversion' ) { return 1; } LoadLanguage('Mods/Like'); sub LikeList { $to_scrl = $INFO{'toscrl'}; $to_tp = $INFO{'tobd'}; if ( $INFO{'toboard'} ) { $return_to = qq~board=$INFO{'toboard'};scrlto=$to_scrl~; } else { $return_to = qq~num=$to_tp;scrlto=$to_scrl~; } fopen( TOPIC, "$datadir/$to_tp.txt" ) || fatal_error( 'cannot_open', "$datadir/$to_tp.txt", 1 ); @thread = ; fclose(TOPIC); ( $tpname, undef ) = split /[|]/xsm, $thread[0]; ToChars($tpname); MessageTotals( 'load', $to_tp ); @likes = split /,/xsm, ${$to_tp}{'like'}; $likes = @likes; $txtlike = NumberFormat($likes); $altlike = $txtlike; $altlike .= $likes > 1 ? qq~ $like_txt{'likemembers'}~ : qq~ $like_txt{'likemember'}~; $altlike .= $likes > 1 ? qq~ $like_txt{'liketopic'}~ : qq~ $like_txt{'liketopics'}~; $likeopt = q{}; foreach (@likes) { LoadUser($_); $likename{ ${ $uid . $_ }{'realname'} } = "${$uid.$_}{'realname'}|$_"; } for my $tmpmembername ( sort { lc $likename{$a} cmp lc $likename{$b} } keys %likename ) { ( $membername, $memberid ) = split /[|]/xsm, $likename{$tmpmembername}; if ( $iamguest ) { $mlmb = qq~$format_unbold{$memberid}~; } else { if ($do_scramble_id) { $user = cloak($memberid); } else { $user = $memberid; } $mlmb = qq~$format_unbold{$memberid}~; } $likeopt .= $likeopt ? qq~, $mlmb~ : qq~$mlmb~; } $yymain = qq~
$altlike:
$tpname
$likeopt
~; $yytitle = $altlike; LikeListtemplate(); return; } sub LikeListtemplate { print_output_header(); $output = qq~ $yytitle $yymain ~; print_HTML_output_and_finish(); return; } sub LikeInc { if ($iamguest) { fatal_error('no_access'); } $liketopic = $INFO{'thread'}; MessageTotals( 'inclike', $liketopic ); $yySetLocation = qq~$scripturl?num=$liketopic~; redirectexit(); return; } sub LikeDec { if ($iamguest) { fatal_error('no_access'); } $liketopic = $INFO{'thread'}; MessageTotals( 'declike', $liketopic ); $yySetLocation = qq~$scripturl?num=$liketopic~; redirectexit(); return; } 1;