More coauthors fixes
--- a/includes/storyform.php
+++ b/includes/storyform.php
@@ -63,16 +63,15 @@
<div id='coauthorsDiv' name='coauthorsDiv' style='visibility: hidden;'></div>
<iframe id='coauthorsshim' scr='' scrolling='no' frameborder='0' class='shim'></iframe>
<div><label for='coauthorsSelected'>"._COAUTHORS.": <br /><select name='coauthorsSelected' id='coauthorsSelected' size='8' multiple='multiple' class='multiSelect' onclick='javascript: removeMember(\"coauthors\");'>";
- $array_couids = array() ;
- $couids = "";
+ $couids = array() ;
if(is_array($stories['coauthors']) && count($stories['coauthors'])) {
$coauths = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." WHERE FIND_IN_SET("._UIDFIELD.", '".implode(",", $stories['coauthors'])."') > 0");
while($c = dbassoc($coauths)) {
if($c['uid'] == $stories['uid']) continue;
$output .= "<option label='".$c['penname']."' value='".$c['uid']."'>".$c['penname']."</option>";
- $array_couids[] = $c['uid'];
+ $couids[] = $c['uid'];
}
- $couids = implode(",", $array_couids);
+ $couids = implode(",", $couids);
}
$output .= "</select></label>
<input type='hidden' name='coauthors' id='coauthors' value='$couids'></div>";
@@ -175,3 +174,4 @@
}
// end chapterform
?>
+
--- a/stories.php
+++ b/stories.php
@@ -48,16 +48,16 @@
if($result) list($sid, $author) = dbrow($result);
}
if(isset($sid)) {
- $array_coauthors = array( );
+ $coauthors = array( );
$authorquery = dbquery("SELECT uid, rr, coauthors FROM ".TABLEPREFIX."fanfiction_stories WHERE sid='$sid' LIMIT 1");
$story = dbassoc($authorquery);
if($story['coauthors']) {
$cQuery = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '$sid'");
while($c = dbassoc($cQuery)) {
- $array_coauthors[] = $c['uid'];
- }
- }
- if($story['uid'] != USERUID && (is_array($array_coauthors) && !in_array(USERUID, $array_coauthors)) && !$story['rr']) accessDenied( );
+ $coauthors[] = $c['uid'];
+ }
+ }
+ if($story['uid'] != USERUID && (is_array($coauthors) && !in_array(USERUID, $coauthors)) && !$story['rr']) accessDenied( );
}
}
else if(isADMIN && uLEVEL < 4 && isset($_GET['admin'])) {
@@ -139,7 +139,7 @@
$storynotes = isset($_POST['storynotes']) ? descript(strip_tags($_POST['storynotes'], $allowed_tags)) : "";
$catid = isset($_POST['catid']) ? array_filter(explode(",", $_POST['catid']), "isNumber") : array( );
$charid = isset($_POST['charid']) ? array_filter($_POST['charid'], "isNumber") : array( );
- $array_coauthors = isset($_POST['coauthors']) ? array_filter(explode(",", $_POST['coauthors']), "isNumber") : array( );
+ $coauthors = isset($_POST['coauthors']) ? array_filter(explode(",", $_POST['coauthors']), "isNumber") : array( );
$classes = array( );
$classquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_classtypes");
while($type = dbassoc($classquery)) {
@@ -178,8 +178,8 @@
$words_to_count = trim($words_to_count);
$wordcount = count(explode(" ",$words_to_count));
$au[] = $uid;
- if(count($array_coauthors)) {
- $au = array_merge($au, $array_coauthors);
+ if(count($coauthors)) {
+ $au = array_merge($au, $coauthors);
$coauthors = 1;
}
else $coauthors = 0;
@@ -273,7 +273,7 @@
else $output .= write_error(_FATALERROR." "._TRYAGAIN);
}
if(!$newchapter) {
- if(count($array_coauthors)) {
+ if(!is_array($coauthors)) {
foreach($au AS $c) {
if($c == $uid) continue;
dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_coauthors(`sid`, `uid`) VALUES('$sid', '$c')");
@@ -635,7 +635,7 @@
$rid = isset($_POST['rid']) && isNumber($_POST['rid']) ? $_POST['rid'] : 0;
$catid = isset($_POST['catid']) ? array_filter(explode(",", $_POST['catid']), "isNumber") : array( );
$charid = isset($_POST['charid']) ? array_filter($_POST['charid'], "isNumber") : array( );
- $array_coauthors = isset($_POST['coauthors']) ? array_filter(explode(",", $_POST['coauthors']), "isNumber") : array( );
+ $coauthors = isset($_POST['coauthors']) ? array_filter(explode(",", $_POST['coauthors']), "isNumber") : array( );
if(isset($_POST['uid']) && isNumber($_POST['uid'])) $uid = $_POST['uid'];
else $uid = USERUID;
$classes = array( );
@@ -648,8 +648,8 @@
}
if(!$admin && $authorvalid && !$validated) $validated = 2;
$au[] = $uid;
- if(count($array_coauthors)) {
- $au = array_merge($au, $array_coauthors);
+ if(count($coauthors)) {
+ $au = array_merge($au, $coauthors);
$coauthors = 1;
}
else $coauthors = 0;
--- a/viewstory.php
+++ b/viewstory.php
@@ -50,21 +50,21 @@
}
if($storyinfo['coauthors'] > 0) {
- $array_coauthors = 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'] = $array_coauthors;
- unset($array_coauthors);
- }
- else $storyinfo['coauthors_array'] = array();
+ $coauthors[$c['uid']] = $c['penname'];
+ }
+ $storyinfo['coauthors'] = $coauthors;
+ unset($coauthors);
+ }
+ else $storyinfo['coauthors'] = 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_array']))) $warning = _ACCESSDENIED;
+ if(!$storyinfo['valid'] && !isADMIN && ($storyinfo['uid'] != USERUID || !in_array(USERUID, $storyinfo['coauthors']))) $warning = _ACCESSDENIED;
if ($storyinfo['rid'] != 0 ) {
$ratingquery = dbquery("SELECT ratingwarning, warningtext FROM " . TABLEPREFIX . "fanfiction_ratings WHERE rid = '" . $storyinfo['rid'] . "' LIMIT 1");
$rating = dbassoc($ratingquery);
@@ -160,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_array'])) {
+ if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors'])) {
$warning = write_error(_ACCESSDENIED);
$tpl->assign("archivedat", $warning);
$tpl->printToScreen( );
@@ -346,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_array'])) {
+ if(!$valid && !isADMIN && USERUID != $chapterauthor && !in_array($chapterauthor, $storyinfo['coauthors'])) {
$warning = accessDenied( );
}
$stories = $storyinfo;
@@ -357,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_array']) ? ",".implode(",", array_keys($storyinfo['coauthors_array'])) : "")."\">"._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']) ? ",".implode(",", array_keys($storyinfo['coauthors'])) : "")."\">"._ADDAUTHOR2FAVES."</option>";
}
if($reviewsallowed ) {
if(isMEMBER || $anonreviews) {