############################################################################### # MemberGroups.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 2.4 # # Packaged: April 12, 2009 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2009 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # # Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com # # Your source for web hosting, web design, and domains. # ############################################################################### $membergroupsplver = 'YaBB 2.4 $Revision$'; if ($GLOBAL::ACTION eq 'detailedversion') { return 1; } sub EditMemberGroups { &is_admin_or_gmod; my ($MemStatAdmin, $MemStarNumAdmin, $MemStarPicAdmin, $MemTypeColAdmin, $noshowAdmin, $viewpermsAdmin, $topicpermsAdmin, $replypermsAdmin, $pollpermsAdmin, $attachpermsAdmin, undef) = split(/\|/, $Group{'Administrator'}); my ($MemStatGMod, $MemStarNumGMod, $MemStarPicGMod, $MemTypeColGMod, $noshowGMod, $viewpermsGMod, $topicpermsGMod, $replypermsGMod, $pollpermsGMod, $attachpermsGMod, undef) = split(/\|/, $Group{'Global Moderator'}); my ($MemStatMod, $MemStarNumMod, $MemStarPicMod, $MemTypeColMod, $noshowMod, $viewpermsMod, $topicpermsMod, $replypermsMod, $pollpermsMod, $attachpermsMod, undef) = split(/\|/, $Group{'Moderator'}); my $noshowAdmin = ($noshowAdmin == 1) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; my $noshowGMod = ($noshowGMod == 1) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; my $noshowMod = ($noshowMod == 1) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; my $adminpi = &permImage($viewpermsAdmin, $topicpermsAdmin, $replypermsAdmin, $pollpermsAdmin, $attachpermsAdmin); my $gmodpi = &permImage($viewpermsGMod, $topicpermsGMod, $replypermsGMod, $pollpermsGMod, $attachpermsGMod); my $modpi = &permImage($viewpermsMod, $topicpermsMod, $replypermsMod, $pollpermsMod, $attachpermsMod); $yymain .= qq~
 $admin_txt{'8'}

$admin_txt{'11'}


~; if ($MemTypeColAdmin) { $thecolname = &hextoname($MemTypeColAdmin); $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~ ~; if ($MemTypeColGMod) { $thecolname = &hextoname($MemTypeColGMod); $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~ ~; if ($MemTypeColMod) { $thecolname = &hextoname($MemTypeColMod); $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~
 $admin_txt{'12'}
$amgtxt{'03'} $amgtxt{'19'} $amgtxt{'08'} $amgtxt{'01'} $admin_txt{'53'}  
$MemStatAdmin x $MemStarNumAdmin$thecolname $noshowAdmin $admin_txt{'53'}  
$MemStatGMod x $MemStarNumGMod$thecolname $noshowGMod $admin_txt{'53'}  
$MemStatMod x $MemStarNumMod$thecolname $noshowMod $admin_txt{'53'}  

~; my $colspan = 6; my $width1 = '25%'; my $width2 = '10%'; my $width3 = '15%'; if ($addmemgroup_enabled > 0) { $additional_tablehead = qq~$amgtxt{'83'}~; $colspan = 7; $width1 = '20%'; $width2 = '5%'; $width3 = '10%'; } my $reorderlink = ""; if ($#nopostorder) { $reorderlink = qq~ | $admintxt{'reordergroups'}~; } $yymain .= qq~
$additional_tablehead ~; $count = 0; foreach (@nopostorder) { ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms, $additional) = split(/\|/, $NoPost{$_}); $permimage = ""; $permimage = &permImage($viewperms, $topicperms, $replyperms, $pollperms, $attachperms); $noshow = ($noshow == 1) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; $additional = ($additional == 0) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; if (!$stars) { $stars = "0"; } $yymain .= qq~ ~; if ($color) { $thecolname = &hextoname($color); $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~ ~; if ($addmemgroup_enabled > 0) { $yymain .= qq~ ~; } $yymain .= qq~ ~; $count++; } if ($count == 0) { $yymain .= qq~ ~; } $yymain .= qq~
 $amgtxt{'37'} ($admintxt{'18c'}$reorderlink)
$amgtxt{'03'} $amgtxt{'19'} $amgtxt{'08'} $amgtxt{'01'}$admin_txt{'53'} $admin_txt{'54'}
$title x $stars$thecolname $noshow$additional$admin_txt{'53'} $admin_txt{'54'}
$amgtxt{'35'}

~; my $count = 0; foreach (sort { $b <=> $a } keys %Post) { my ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms, undef) = split(/\|/, $Post{$_}); $permimage = ""; $permimage = &permImage($viewperms, $topicperms, $replyperms, $pollperms, $attachperms); $noshow = ($noshow == 1) ? "$admin_txt{'164'}" : "$admin_txt{'163'}"; if (!$stars) { $stars = "0"; } if ($starpic !~ /\//) { $starpic = "$imagesdir/$starpic"; } $yymain .= qq~ ~; if ($color) { $thecolname = &hextoname($color); $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~ ~; $count++; } if ($count == 0) { $yymain .= qq~ ~; } $yymain .= qq~
 $amgtxt{'40'} ($admintxt{'18c'})
$amgtxt{'03'} $amgtxt{'19'} $amgtxt{'08'} $admin_txt{'21'} $admin_txt{'53'} $admin_txt{'54'}
$title x $stars$thecolname $_ $admin_txt{'53'} $admin_txt{'54'}
$amgtxt{'36'}
~; $yytitle = $admin_txt{'8'}; $action_area = 'modmemgr'; &AdminTemplate; } sub hextoname { $colorname = $_[0]; $colorname =~ s~aqua|#00FFFF~$amgtxt{'56'}~i; $colorname =~ s~black|#000000~$amgtxt{'57'}~i; $colorname =~ s~blue|#0000FF~$amgtxt{'58'}~i; $colorname =~ s~fuchsia|#FF00FF~$amgtxt{'59'}~i; $colorname =~ s~gray|#808080~$amgtxt{'60'}~i; $colorname =~ s~green|#008000~$amgtxt{'61'}~i; $colorname =~ s~lime|#00FF00~$amgtxt{'62'}~i; $colorname =~ s~maroon|#800000~$amgtxt{'63'}~i; $colorname =~ s~navy|#000080~$amgtxt{'64'}~i; $colorname =~ s~olive|#808000~$amgtxt{'65'}~i; $colorname =~ s~purple|#800080~$amgtxt{'66'}~i; $colorname =~ s~red|#FF0000~$amgtxt{'67'}~i; $colorname =~ s~silver|#C0C0C0~$amgtxt{'68'}~i; $colorname =~ s~teal|#008080~$amgtxt{'69'}~i; $colorname =~ s~white|#FFFFFF~$amgtxt{'70'}~i; $colorname =~ s~yellow|#FFFF00~$amgtxt{'71'}~i; $colorname =~ s~#DEB887~$amgtxt{'75'}~i; $colorname =~ s~#FFD700~$amgtxt{'76'}~i; $colorname =~ s~#FFA500~$amgtxt{'77'}~i; $colorname =~ s~#A0522D~$amgtxt{'78'}~i; $colorname =~ s~#87CEEB~$amgtxt{'79'}~i; $colorname =~ s~#6A5ACD~$amgtxt{'80'}~i; $colorname =~ s~#4682B4~$amgtxt{'81'}~i; $colorname =~ s~#9ACD32~$amgtxt{'82'}~i; return $colorname; } sub editAddGroup { &is_admin_or_gmod; if ($INFO{'group'}) { $viewtitle = $admintxt{'18a'}; ($type, $element) = split(/\|/, $INFO{'group'}); if ($element ne '') { if ($type eq 'P') { $posts = $element; ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms, $additional) = split(/\|/, $Post{$element}); } else { $noposts = $element; $choosable = 1; ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms, $additional) = split(/\|/, $NoPost{$element}); } } else { ($title, $stars, $starpic, $color, $noshow, $viewperms, $topicperms, $replyperms, $pollperms, $attachperms, $additional) = split(/\|/, $Group{$INFO{'group'}}); } } else { $viewtitle = $admintxt{'18b'}; $title = ''; $stars = ''; $starpic = ''; $color = ''; $posts = ''; $noposts = 1; foreach (sort { $a <=> $b } keys %NoPost) { $noposts = $_ + 1; } } if ($stars !~ /\A[0-9]+\Z/) { $stars = 0; } $otherdisable = qq~ disabled="disabled"~; # Get star selected if needed. if ($starpic eq "staradmin.gif") { $stars1 = "selected=\"selected\"" } elsif ($starpic eq "stargmod.gif") { $stars2 = "selected=\"selected\"" } elsif ($starpic eq "starmod.gif") { $stars3 = "selected=\"selected\"" } elsif ($starpic eq "starblue.gif") { $stars4 = "selected=\"selected\"" } elsif ($starpic eq "starsilver.gif") { $stars5 = "selected=\"selected\"" } elsif ($starpic eq "stargold.gif") { $stars6 = "selected=\"selected\"" } elsif ($starpic eq "") { $stars1 = "selected=\"selected\"" } else { $stars7 = "selected=\"selected\""; $pick = $starpic; $otherdisable = ""; } my $starurl = ($starpic !~ m~http://~ ? "$imagesdir/" : "") . ($starpic ? $starpic : "blank.gif"); $color =~ s/\#//g; $pc = qq~ checked="checked"~; $pd = ""; $pt = ""; if ($noshow) { $pc = ''; } if ($additional) { $admg = qq~ checked="checked"~; } if ($posts eq "" && $GLOBAL::ACTION ne "editgroup1") { $post2 = qq~ checked="checked"~; $pt = qq~ disabled="disabled"~; } else { $post1 = qq~ checked="checked"~; $pd = qq~ disabled="disabled"~; } if ($viewperms == 1) { $vc = qq~ checked="checked"~; } if ($topicperms == 1) { $tc = qq~ checked="checked"~; } if ($replyperms == 1) { $rc = qq~ checked="checked"~; } if ($pollperms == 1) { $poc = qq~ checked="checked"~; } if ($attachperms == 1) { $ac = qq~ checked="checked"~; } $yymain .= qq~
~; # Get color selected $yymain =~ s/(~; } else { $yymain .= qq~ ~; } if ($addmemgroup_enabled > 0) { if ($choosable || (!$choosable && $GLOBAL::ACTION ne 'editgroup1' && !$INFO{'group'})) { $yymain .= qq~ ~; } } unless ($INFO{'group'} eq "Administrator") { $yymain .= qq~
$viewtitle
   
  #  




~; } $yymain .= qq~
$amgtxt{'44'}
~; $yytitle = $admin_txt{'8'}; $action_area = "modmemgr"; &AdminTemplate; } sub editAddGroup2 { &is_admin_or_gmod; # Additional checks are: # If post independent -> post dependent, then need to kill off post independent # If post dependent -> post independent, then need to kill off post dependent. # If post dependent -> NEW post dependent, then need to kill off OLD post dependent. $newpostdep = 0; if (!$FORM{'title'}) { &fatal_error("no_group_name"); } $name = $FORM{'title'}; $name =~ s~&~&~g; $name =~ s~'~'~g; $name =~ s~,~,~g; $name =~ s~\|~|~g; $lcname = lc($name); $star = ($FORM{'starsadmin'} eq "other") ? $FORM{'otherstar'} : $FORM{'starsadmin'}; $color = $FORM{'color2'} ne '' ? "#$FORM{'color2'}" : ''; $postdepend = $FORM{'postdepend'}; if ($FORM{'posts'} !~ /\d+/ && $postdepend eq "Yes") { &fatal_error("no_post_number"); } else { $posts = $FORM{'posts'} } if ($postdepend eq "No") { $noposts = $FORM{'noposts'}; } if ($FORM{'viewpublic'}) { $viewpublic = 0 } else { $viewpublic = 1 } $view = $FORM{'view'} || 0; $topics = $FORM{'topics'} || 0; $reply = $FORM{'reply'} || 0; $polls = $FORM{'polls'} || 0; $attach = $FORM{'attach'} || 0; $additional = $FORM{'additional'} || 0; $original = $FORM{'original'}; # all the checks. if ($original ne '') { ($type, $element) = split(/\|/, $original); # Ignoring Administrative groups. if ($element ne "") { if ($type eq "P") { if ($element != $posts || $postdepend eq "No") { if ($iamgmod) { &fatal_error("newpostdep_gmod"); } delete $Post{$element}; $newpostdep = 1; $noposts = 1; foreach (sort { $a <=> $b } keys %NoPost) { $noposts = $_ + 1; } } } elsif ($type eq "NP") { if ($element != $noposts || $postdepend eq "Yes") { delete $NoPost{$element}; for ($i = 0; $i < @nopostorder; $i++) { if ($nopostorder[$i] == $element) { splice(@nopostorder,$i,1); last; } } } } } } if ((split(/\|/, $Group{$original}, 2))[0] ne $name) { if ($lcname eq lc((split(/\|/, $Group{'Administrator'}, 2))[0])) { &fatal_error("double_group", $lcname); } if ($lcname eq lc((split(/\|/, $Group{'Global Moderator'}, 2))[0])) { &fatal_error("double_group", $lcname); } if ($lcname eq lc((split(/\|/, $Group{'Moderator'}, 2))[0])) { &fatal_error("double_group", $lcname); } } # Check Post Independent foreach my $key (keys %NoPost) { if ($type eq "NP" && $key eq $element) { next; } ($value, undef) = split(/\|/, $NoPost{$key}, 2); $lcvalue = lc($value); if ($lcname eq $lcvalue) { &fatal_error("double_group", $lcname); } } # Check Post Dependent foreach my $key (keys %Post) { if ($type eq "P" && $key eq $element) { next; } ($value, undef) = split(/\|/, $Post{$key}, 2); $lcvalue = lc($value); if ($lcname eq $lcvalue) { &fatal_error("double_group", $lcname); } } if ($FORM{'numstars'} !~ /\A[0-9]+\Z/) { $FORM{'numstars'} = 0; } # Now, we must deliberate on what type of thing this group is, and add/readd(when editing) it. # First, using original variable, we check to see it's not a perma-group. ($type, $element) = split(/\|/, $original); if ($element eq "" && $original ne "") { # We have a perma-group! $type is now equal to the perma group or key for the hash. # add in code to actually set the line. $Group{"$type"} = "$name|$FORM{'numstars'}|$star|$color|$viewpublic|$view|$topics|$reply|$polls|$attach|$additional"; } else { # post dependent group. if ($postdepend eq "Yes") { foreach my $key (keys %Post) { if ($posts == $key && ($FORM{'origin'} eq "editgroup1" || $original ne "P|$posts")) { &fatal_error("double_count","($posts)"); } } if ($iamgmod) { &fatal_error("newpostdep_gmod"); } $Post{$posts} = "$name|$FORM{'numstars'}|$star|$color|0|$view|$topics|$reply|$polls|$attach|$additional"; $newpostdep = 1; # no post group } else { $NoPost{$noposts} = "$name|$FORM{'numstars'}|$star|$color|$viewpublic|$view|$topics|$reply|$polls|$attach|$additional"; my $isinorder; for ($i = 0; $i < @nopostorder; $i++) { if ($NoPost{$nopostorder[$i]} && $nopostorder[$i] == $noposts) { $isinorder = 1; last; } } if (!$isinorder) { push(@nopostorder, $noposts); } } } require "$admindir/NewSettings.pl"; &SaveSettingsTo('Settings.pl'); # save @nopostorder, %Group, %NoPost and %Post if ($newpostdep) { $yySetLocation = qq~$adminurl?action=rebuildmemlist;actiononfinish=modmemgr~; } else { $yySetLocation = qq~$adminurl?action=modmemgr~; } &redirectexit; } sub permImage { my $viewperms, $topicperms, $replyperms, $pollperms, $attachperms; $viewperms = ($_[0] != 1) ? "" : ""; $topicperms = ($_[1] != 1) ? "" : ""; $replyperms = ($_[2] != 1) ? "" : ""; $pollperms = ($_[3] != 1) ? "" : ""; $attachperms = ($_[4] != 1) ? "" : ""; return "$viewperms $topicperms $replyperms $pollperms $attachperms"; } sub deleteGroup { if ($INFO{'group'}) { ($type, $element) = split(/\|/, $INFO{'group'}); if ($element ne "") { if ($type eq "P") { delete $Post{$element}; } elsif ($type eq "NP") { delete $NoPost{$element}; &KillModeratorGroup($element); } } } else { &fatal_error("no_info"); } my @new_nopostorder; foreach (@nopostorder) { if ($NoPost{$_}) { push(@new_nopostorder, $_); } } @nopostorder = @new_nopostorder; require "$admindir/NewSettings.pl"; &SaveSettingsTo('Settings.pl'); # save @nopostorder, %Group, %NoPost and %Post $yySetLocation = qq~$adminurl?action=rebuildmemlist;actiononfinish=modmemgr~; &redirectexit; } sub reorderGroups { $selsize = 0; foreach (@nopostorder) { if ($NoPost{$_}) { ($title, undef) = split(/\|/, $NoPost{$_}, 2); if ($_ eq $INFO{"thegroup"}) { $orderopt .= qq~~; } else { $orderopt .= qq~~; } $selsize++; } } $rowspan = $#nopostorder + 2; $yymain .= qq~
~; foreach (@nopostorder) { ($title, $stars, $starpic, $color, undef) = split(/\|/, $NoPost{$_}, 5); if (!$stars) { $stars = "0"; } $yymain .= qq~ ~; } $yymain .= qq~
 $admintxt{'reordergroups2'}
$amgtxt{'03'} $amgtxt{'19'}

~; if ($color) { $yymain .= qq~$title~; } else { $yymain .= qq~$title~; } $yymain .= qq~ ~; for (1..$stars) { $yymain .= qq~~; } $yymain .= qq~
~; $yytitle = $admintxt{'reordergroups'}; $action_area = 'modmemgr'; &AdminTemplate; } sub reorderGroups2 { my $moveitem = $FORM{'ordergroups'}; if ($moveitem) { for ($i = 0; $i < @nopostorder; $i++) { if ($nopostorder[$i] == $moveitem && (($FORM{'moveup'} && $i > 0 && $i <= $#nopostorder) || ($FORM{'movedown'} && $i < $#nopostorder && $i >= 0))) { my $j = $FORM{'moveup'} ? $i - 1 : $i + 1; $nopostorder[$i] = $nopostorder[$j]; $nopostorder[$j] = $moveitem; last; } } } require "$admindir/NewSettings.pl"; &SaveSettingsTo('Settings.pl'); # save @nopostorder $yySetLocation = qq~$adminurl?action=reordergroup;thegroup=$moveitem~; &redirectexit; } 1;