coauthors fix
--- a/includes/corefunctions.php
+++ b/includes/corefunctions.php
@@ -266,14 +266,21 @@
// Same with the author list
function author_link($stories) {
- if(is_array($stories['coauthors'])) {
- $authlink[] = "<a href=\""._BASEDIR."viewuser.php?uid=".$stories['uid']."\">".$stories['penname']."</a>";
- $coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$stories['sid']."'");
- foreach($stories['coauthors'] AS $k => $v) {
+
+ $authlink[] = "<a href=\"" . _BASEDIR . "viewuser.php?uid=" . $stories['uid'] . "\">" . $stories['penname'] . "</a>";
+
+ if($stories['coauthors']) {
+
+ //not needed, why is it there?
+ //$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co
+ //LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$stories['sid']."'");
+
+ foreach($stories['coauthors_array'] AS $k => $v) {
$authlink[] = "<a href=\""._BASEDIR."viewuser.php?uid=".$k."\">".$v."</a>";
}
}
- return isset($authlink) ? implode(", ", $authlink) : "<a href=\""._BASEDIR."viewuser.php?uid=".$stories['uid']."\">".$stories['penname']."</a>";
+
+ return implode(", ", $authlink) ;
}
// Used to truncate text (summaries in blocks for example) to a set length. An improvement on the old version as this keeps words intact
@@ -569,3 +576,4 @@
return $numrows;
}
?>
+
--- a/includes/storyblock.php
+++ b/includes/storyblock.php
@@ -31,10 +31,10 @@
while($c = dbassoc($coauth)) {
$array_coauthors[$c['uid']] = $c['penname'];
}
- $stories['coauthors'] = $array_coauthors;
+ $stories['coauthors_array'] = $array_coauthors;
unset($array_coauthors);
}
- else $stories['coauthors'] = array( );
+ else $stories['coauthors_array'] = array( );
$tpl->assign("title" , stripslashes(title_link($stories)) );
$tpl->assign("author" , author_link($stories));
@@ -95,7 +95,7 @@
$tpl->assign("ratingpics" , ratingpics($stories['rating']) );
$tpl->assign("reviews" , ($reviewsallowed ? "<a href=\""._BASEDIR."reviews.php?type=ST&item=".$stories['sid']."\">"._REVIEWS."</a>" : "") );
if(isMEMBER && !empty($favorites))
- $tpl->assign("addtofaves", "[<a href=\""._BASEDIR."user.php?action=favst&add=1&sid=".$stories['sid']."\">"._ADDSTORY2FAVES."</a>] [<a href=\""._BASEDIR."user.php?action=favau&add=".$stories['uid'].(count($stories['coauthors']) ? ",".implode(",", array_keys($stories['coauthors'])) : "")."\">"._ADDAUTHOR2FAVES."</a>]");
+ $tpl->assign("addtofaves", "[<a href=\""._BASEDIR."user.php?action=favst&add=1&sid=".$stories['sid']."\">"._ADDSTORY2FAVES."</a>] [<a href=\""._BASEDIR."user.php?action=favau&add=".$stories['uid'].(count($stories['coauthors_array']) ? ",".implode(",", array_keys($stories['coauthors_array'])) : "")."\">"._ADDAUTHOR2FAVES."</a>]");
$numchapsquery = dbquery("SELECT count(sid) FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".$stories['sid']."' AND validated > 0");
list($chapters) = dbrow($numchapsquery);
@@ -109,7 +109,7 @@
}
$tpl->assign("wordcount" , $stories['wordcount'] ? $stories['wordcount'] : "0" );
$tpl->assign("numreviews" , ($reviewsallowed == "1" ? "<a href=\""._BASEDIR."reviews.php?type=ST&item=".$stories['sid']."\">".$stories['reviews']."</a>" : "") );
- if((isADMIN && uLEVEL < 4) || USERUID == $stories['uid'] || (is_array($stories['coauthors']) && array_key_exists(USERUID, $stories['coauthors'])))
+ if((isADMIN && uLEVEL < 4) || USERUID == $stories['uid'] || (is_array($stories['coauthors']) && array_key_exists(USERUID, $stories['coauthors_array'])))
$adminlinks .= "[<a href=\""._BASEDIR."stories.php?action=editstory&sid=".$stories['sid'].(isADMIN ? "&admin=1" : "")."\">"._EDIT."</a>] [<a href=\""._BASEDIR."stories.php?action=delete&sid=".$stories['sid'].(isADMIN ? "&admin=1" : "")."\">"._DELETE."</a>]";
global $featured;
if($stories['featured'] == 1) {
@@ -127,7 +127,7 @@
$tpl->assign("oddeven", ($count % 2 ? "odd" : "even"));
$tpl->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&url=viewstory.php?sid=".$stories['sid']."\">"._REPORTTHIS."</a>]");
if(isADMIN && uLEVEL < 4) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> ".$adminlinks."</div>");
- else if(isMEMBER && (USERUID == $stories['uid'] || array_key_exists(USERUID, $stories['coauthors']))) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._OPTIONS.":</span> ".$adminlinks."</div>");
+ else if(isMEMBER && (USERUID == $stories['uid'] || array_key_exists(USERUID, $stories['coauthors_array']))) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._OPTIONS.":</span> ".$adminlinks."</div>");
$count++;
?>
--- a/viewstory.php
+++ b/viewstory.php
@@ -48,21 +48,23 @@
dbclose();
exit();
}
-
+
if($storyinfo['coauthors'] > 0) {
$array_coauthors = array();
$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$sid."'");
while($c = dbassoc($coauth)) {
$array_coauthors[$c['uid']] = $c['penname'];
}
- $storyinfo['coauthors'] = $array_coauthors;
+ $storyinfo['coauthors_array'] = $array_coauthors;
unset($array_coauthors);
}
- else $storyinfo['coauthors'] = array();
+ else $storyinfo['coauthors_array'] = array();
+
+
// Check that the story is valid and that the visitor has permissions to read this story
$warning = "";
if(!$storyinfo) $warning = _INVALIDSTORY;
- if(!$storyinfo['valid'] && !isADMIN && ($storyinfo['uid'] != USERUID || !in_array(USERUID, $storyinfo['coauthors']))) $warning = _ACCESSDENIED;
+ if(!$storyinfo['valid'] && !isADMIN && ($storyinfo['uid'] != USERUID || !in_array(USERUID, $storyinfo['coauthors_array']))) $warning = _ACCESSDENIED;
if ($storyinfo['rid'] != 0 ) {
$ratingquery = dbquery("SELECT ratingwarning, warningtext FROM " . TABLEPREFIX . "fanfiction_ratings WHERE rid = '" . $storyinfo['rid'] . "' LIMIT 1");
$rating = dbassoc($ratingquery);
@@ -158,7 +160,7 @@
$chapterinfo = dbquery("SELECT *, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as c, "._AUTHORTABLE.") WHERE sid = '$sid' AND inorder = '$chapter' AND c.uid = "._UIDFIELD." LIMIT 1");
$c = dbassoc($chapterinfo);
// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.
- if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors'])) {
+ if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors_array'])) {
$warning = write_error(_ACCESSDENIED);
$tpl->assign("archivedat", $warning);
$tpl->printToScreen( );
@@ -344,7 +346,7 @@
$printicon = "<a href=\"viewstory.php?action=printable&sid=$sid&textsize=$textsize&chapter=1\" target=\"_blank\"><img src='".(isset($printer) ? $priner : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>";
}
// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.
- if(!$valid && !isADMIN && USERUID != $chapterauthor && !in_array($chapterauthor, $storyinfo['coauthors'])) {
+ if(!$valid && !isADMIN && USERUID != $chapterauthor && !in_array($chapterauthor, $storyinfo['coauthors_array'])) {
$warning = accessDenied( );
}
$stories = $storyinfo;
@@ -355,7 +357,7 @@
if(isADMIN && uLEVEL < 3)
$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> | "._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>";
if(isMEMBER && $favorites) {
- $jumpmenu2 .= "<option value=\"user.php?action=favst&add=1&sid=$sid\">"._ADDSTORY2FAVES."</option><option value=\"user.php?action=favau&add=1&author=".$stories['uid'].(count($storyinfo['coauthors']) ? ",".implode(",", array_keys($storyinfo['coauthors'])) : "")."\">"._ADDAUTHOR2FAVES."</option>";
+ $jumpmenu2 .= "<option value=\"user.php?action=favst&add=1&sid=$sid\">"._ADDSTORY2FAVES."</option><option value=\"user.php?action=favau&add=1&author=".$stories['uid'].(count($storyinfo['coauthors_array']) ? ",".implode(",", array_keys($storyinfo['coauthors_array'])) : "")."\">"._ADDAUTHOR2FAVES."</option>";
}
if($reviewsallowed ) {
if(isMEMBER || $anonreviews) {