View Single Post
  #1  
Old 2nd June 2010, 01:29
blargh blargh is offline
Member
 
Join Date: Feb 2010
P2P
Posts: 9
Cool Commenting Rights Enable/Disable
sql:

Code:
ALTER TABLE `users` ADD `commpost` ENUM( 'yes', 'no' ) DEFAULT 'yes' NOT NULL;
in userdetails.php file:
find where the mod tools start and place this bit where you want the option to appear

Code:
print("<tr><td class=\"rowhead\">".$userdetails_lang['commpost']."</td><td colspan=\"2\" align=\"left\"><input type=\"radio\" name=\"commpost\" value=\"yes\"" .($user["commpost"] == "yes" ? " checked=\"checked\"" : "")." />".$tracker_lang['yes']." <input type=\"radio\" name=\"commpost\" value=\"no\"" .($user["commpost"] == "no" ? " checked=\"checked\"" : "")." />".$tracker_lang['no']."</td></tr>\n");
in languages/english/lang_userdetails.php file:

Code:
$userdetails_lang['commpost'] = "Commenting Rights";
$userdetails_lang['commpost'] = "You are not allowed to post comments!";
in modtask.php file:

Code:
    // Comment Post Enable / Disable
    if ((isset($_POST['commpost'])) && (($commpost = $_POST['commpost']) != $user['commpost']))
    {
    if ($commpost == 'yes')
    {
    $modcomment = get_date( time(), 'DATE', 1 ) . " - Comment posting enabled by " . $CURUSER['username'] . ".\n" . $modcomment;
    $msg = sqlesc("Your Comment posting rights have been given back by ".$CURUSER['username'].". You can post comments again.");
    $added = time();
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    }
    else
    {
    $modcomment = get_date( time(), 'DATE', 1 ) . " - Comment posting disabled by " . $CURUSER['username'] . ".\n" . $modcomment;
    $msg = sqlesc("Your Comment posting rights have been removed by ".$CURUSER['username'].", Please PM ".$CURUSER['username']." for the reason why.");
    $added = time();
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    }
    $updateset[] = "commpost = " . sqlesc($commpost);
    }
In details.php

find:
(note ive changed my print to echo same code just with echo instead)

Code:
if (!$count) {
add after:
Code:
  if ($CURUSER["commpost"] != "no")
  {
find:

Code:
     textbbcode("comment","text","");
     echo "</div>";
     echo "</td></tr><tr><td  align=\"center\" colspan=\"2\">";
     echo "<input type=\"hidden\" name=\"tid\" value=\"$id\"/>";
     echo "<input type=\"submit\" class=btn value=\"".$tracker_lang['add_comment']."\" />";
     echo "</td></tr></form></table>";
        }
add after:
Code:
   else {
     echo "<table style=\"margin-top: 2px;\" cellpadding=\"5\" width=\"100%\">";
     echo "<tr><td class=colhead align=\"left\" colspan=\"2\">";
     echo "<div style=\"float: left; width: auto;\" align=\"left\"> :: ".$tracker_lang['comments']."</div>";
     echo "</td></tr><tr><td align=\"center\">";
     echo "".$tracker_lang['no_comments']."";
     echo "</td></tr></table><br>";
     echo "<table style=\"margin-top: 2px;\" cellpadding=\"5\" width=\"100%\">";
     echo "<tr><td class=colhead align=\"left\" colspan=\"2\"> <a name=comments>&nbsp;</a></td></tr>";
     echo "<tr><td align=\"center\" >";
     echo "</table>";
     }
     }
now right below that will be:

Code:
        else {
         list($pagertop, $pagerbottom, $limit) = pager($limited, $count, "details.php?id=$id&", array(lastpagedefault => 1));
         $subres = sql_query("SELECT c.id, c.ip, c.text, c.user, c.added, c.editedby, c.editedat, u.avatar, u.warned, ".
         "u.username, u.title, u.class, u.donor, u.downloaded, u.uploaded, u.gender, u.last_access, e.username AS editedbyname FROM ".TABLE_COMMENTS." AS c LEFT JOIN ".TABLE_USERS." AS u ON c.user = u.id LEFT JOIN ".TABLE_USERS." AS e ON c.editedby = e.id WHERE torrent = " .
         "$id ORDER BY c.id $limit") or sqlerr(__FILE__, __LINE__);
         $allrows = array();
BETWEEN:

Code:
else {
and
Code:
         list($pagertop, $pagerbottom, $limit) = pager($limited, $count,  "details.php?id=$id&", array(lastpagedefault => 1));
         $subres = sql_query("SELECT c.id, c.ip, c.text, c.user,  c.added, c.editedby, c.editedat, u.avatar, u.warned, ".
         "u.username, u.title, u.class, u.donor, u.downloaded,  u.uploaded, u.gender, u.last_access, e.username AS editedbyname FROM  ".TABLE_COMMENTS." AS c LEFT JOIN ".TABLE_USERS." AS u ON c.user = u.id  LEFT JOIN ".TABLE_USERS." AS e ON c.editedby = e.id WHERE torrent = " .
         "$id ORDER BY c.id $limit") or sqlerr(__FILE__, __LINE__);
         $allrows = array();
ADD:
Code:
  if ($CURUSER["commpost"] != "no")
  {
find:
Code:
         echo "</td></tr></table></center>";
         echo "</td></tr><tr><td  align=\"center\" colspan=\"2\">";
         echo "<input type=\"hidden\" name=\"tid\" value=\"$id\"/>";
         echo "<input type=\"submit\" class=btn value=\"".$tracker_lang['add_comment']."\" />";
         echo "</td></tr></form></table>";
        }
add BELOW:
Code:
        else { 
         list($pagertop, $pagerbottom, $limit) = pager($limited, $count, "details.php?id=$id&", array(lastpagedefault => 1));
         $subres = sql_query("SELECT c.id, c.ip, c.text, c.user, c.added, c.editedby, c.editedat, u.avatar, u.warned, ".
         "u.username, u.title, u.class, u.donor, u.downloaded, u.uploaded, u.gender, u.last_access, e.username AS editedbyname FROM ".TABLE_COMMENTS." AS c LEFT JOIN ".TABLE_USERS." AS u ON c.user = u.id LEFT JOIN ".TABLE_USERS." AS e ON c.editedby = e.id WHERE torrent = " .
         "$id ORDER BY c.id $limit") or sqlerr(__FILE__, __LINE__);
         $allrows = array();
         while ($subrow = mysql_fetch_array($subres))
         $allrows[] = $subrow;
         echo "<table class=main cellspacing=\"0\" cellPadding=\"5\" width=\"100%\" >";
         echo "<tr><td class=\"colhead\" align=\"center\" >";
         echo "<div style=\"float: left; width: auto;\" align=\"left\"> :: ".$tracker_lang['comments']."</div>";
         echo "</td></tr>";
         echo "<tr><td>";
         echo $pagertop;
         echo "</td></tr>";
         echo "<tr><td>";
         commenttable($allrows);
         echo "</td></tr>";
         echo "<tr><td>";
         echo $pagerbottom;
         echo "</td></tr>";
         echo "</table>";
         echo "<table style=\"margin-top: 2px;\" cellpadding=\"5\" width=\"100%\">";
         echo "<tr><td class=colhead align=\"left\" colspan=\"2\">  <a name=comments>&nbsp;</a></td></tr>";
         echo "</table>";
         }
         }
In comment.php

find:
Code:
if ($action == "add")
{
add BELOW:
Code:
if ($CURUSER["commpost"] != "no")
    {
find:
Code:
      print("<h2>Recent comments, in the reverse order of /h2>\n");
      commenttable($allrows);
    }
  stdfoot();
    die;
}
add BELOW:
Code:
else {
newerr($tracker_lang['error'], 'Your Commenting Rights Have Been Lifted. Please Contact Staff For A Reason');
}
}
find:
Code:
elseif ($action == "quote")
{
add BELOW:
Code:
if ($CURUSER["commpost"] != "no")
    {
find:
Code:
    print("<p><input type=\"submit\" value=\"Submit\" /></p></form>\n");

    stdfoot();

}
add BELOW:
Code:
else {
newerr($tracker_lang['error'], 'Your Commenting Rights Have Been Lifted. Please Contact Staff For A Reason');
}
}
find:
elseif ($action == "edit")
{
[/code]

add BELOW:
Code:
if ($CURUSER["commpost"] != "no")
    {
find:
Code:
    print("<p><input type=\"submit\" value=\"Edit!\" /></p></form>\n");

    stdfoot();
    die;
}
add BELOW:
Code:
else {
newerr($tracker_lang['error'], 'Your Commenting Rights Have Been Lifted. Please Contact Staff For A Reason');
}
}
and thats it. now you can disable users ability to post comments altogether. if you have users that constantly break your comment rules then just disable their ability to post them.

This mod was adapted from the TBDev 09 mod to disable/enable forum/download/upload rights found here: http://www.tbdev.net/index.php?showtopic=21638 and working on Yuna Scatari pre7 by BoLaMN

*EDITED*
ive updated the post to clean up the code a bit. and ive added a check for editing and replying to comments aswell. hope you enjoy

Last edited by blargh; 5th June 2010 at 01:06.
Reply With Quote
The Following User Says Thank You to blargh For This Useful Post:
look (26th March 2012)