This is a quick and dirty mod to version 3.2 to add an invalidate link in the admin options when viewing a chapter that returns it to the submissions queue. It can be used by level 1 & 2 admins.
NOTE 1: It has had very limited testing. It will not work on versions older than 3.2.
NOTE 2: See this thread for patches to fix bugs in validation in 3.2 https://efiction.org/forums/index.php?topic=4742.msg25656
NOTE 3: It doesn't notify anyone that the chapter has been invalidated. However if you then validate it again it will notify people that it has been posted a second time.
1. Add to language/en.php in the view story section:
define ("_INVALIDATE", "Invalidate");
2. Add to stories.php above the delete() function:
function invalidate( ) {
global $adminloggedin,$chapid,$sid,$tableprefix,$level;
if ($adminloggedin && $chapid && $level<3) {
dbquery("UPDATE " .$tableprefix."fanfiction_chapters SET validated=0 WHERE chapid = '$chapid'");
$count = dbquery("SELECT SUM(wordcount) as totalcount FROM ".$tableprefix."fanfiction_chapters WHERE sid = '$sid' AND validated=1");
list($totalcount) = dbrow($count);
if($totalcount) {
dbquery("UPDATE ".$tableprefix."fanfiction_stories SET wordcount = '$totalcount' WHERE sid = '$sid'");
}
list($chapters, $words) = dbrow(dbquery("SELECT COUNT(chapid), SUM(wordcount) FROM ".$tableprefix."fanfiction_chapters WHERE validated=1"));
dbquery("UPDATE ".$tableprefix."fanfiction_stats set wordcount = '$words', chapters = '$chapters'");
return "<center>"._ACTIONSUCCESSFUL."</center>";
}
else {
die("Access Denied");
}
}
3. Add a case to call invalidate in the case statement at the bottom of stories.php:
case "editstory":
$output .= editstory($sid);
break;
case "invalidate":
$output .= invalidate( );
break;
case "delete":
$output .= delete( );
break;
4. Modify the links on line 309 on viewstory.php that generates the admin options. I've wrapped the
long line to make it more readable. You can leave it wrapped in your source code or put it all back on one line - both work:
$adminlinks = "<div class="adminoptions"><span class='label'>"._ADMINOPTIONS.":</span> "._EDIT.
" - <a href=""stories.php?action=editstory&sid=$sid&admin=1">"._STORY."</a>" "._OR.
" <a href=""stories.php?action=editchapter&chapid=$chapid&admin=1">"._CHAPTER."</a>" | ".
_INVALIDATE." - <a href=""stories.php?action=invalidate&chapid=$chapid&sid=$sid&admin=1">"._CHAPTER."</a>" | " .
_DELETE." - <a href=""stories.php?action=delete&sid=$sid&admin=1">"._STORY."</a>" "._OR.
" <a href=""stories.php?action=delete&chapid=$chapid&sid=$sid&admin=1">"._CHAPTER."</a></div>";"
I created a mod similar to this for the site I help out now and then, only I didn't do it by chapter, I did it for the whole story. I like the idea of invalidating chapters, though.
One additional thing I did, because my site has multiple validaters, was to modify the title so that if someone other than the revoking admin is inspecting the queue, they'll see that there's something to watch out for in this story.
Here's my "revoke" function:
function revoke() {
global $tableprefix, $tpl, $store, $storiespath, $useruid, $admin, $sid, $chapid, $logging;
// Revoke functionality
// First, reset validation of story to "0"
dbquery("UPDATE ".$tableprefix."fanfiction_stories SET validated = '0' WHERE sid = '$sid'");
// Now set each chapter's validation field to "0", resubmitting them to the validation queue
dbquery("UPDATE ".$tableprefix."fanfiction_chapters SET validated = '0' WHERE sid = '$sid'");
// Finally, modify the title so that all admins know that this story had its validation revoked and is not a new submission
$titlequery=dbquery("SELECT title FROM ".$tableprefix."fanfiction_stories WHERE sid='$sid'");
list($oldtitle)=dbrow($titlequery);
dbquery("UPDATE ".$tableprefix."fanfiction_stories SET title='[REVOKED] - ".$oldtitle."' WHERE sid='$sid'");
return "<center>"._ACTIONSUCCESSFUL."</center>";
}
// end revoke
However, invalidating individual chapters would probably save my validaters a lot of work. And if you see any glaring errors in my code, please let me know. I noticed you put in some checks for checking admin levels in your function, but that seems to be already checked when building the admin menu. This worked in version 3.0, 3.1 and 3.2.1.
