Browse code

Revert coauthors array changes as it occasionally brings up an undefined variable warning with no real way to fix it

Clarissa Walker authored on 2026/09/01 23:37:00
Showing 2 changed files
... ...
@@ -278,20 +278,15 @@ function title_link($stories) {
278 278
 
279 279
 // Same with the author list
280 280
 function author_link($stories) {
281
-	
282
-	$authlink[] = "<a href=\"" . _BASEDIR . "viewuser.php?uid=" . $stories['uid'] . "\">" . $stories['penname'] . "</a>";
283
-
284
-	if($stories['coauthors'] && $stories['coauthors_array'])  {	
281
+	if(is_array($stories['coauthors'])) {
282
+		$authlink[] = "<a href=\""._BASEDIR."viewuser.php?uid=".$stories['uid']."\">".$stories['penname']."</a>";
285 283
 		//not needed, why is it there?
286
-		//$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co 
287
-		//LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$stories['sid']."'");
288
-
289
-		foreach($stories['coauthors_array'] AS $k => $v) {
284
+		//$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']."'");
285
+		foreach($stories['coauthors'] AS $k => $v) {
290 286
 			$authlink[] = "<a href=\""._BASEDIR."viewuser.php?uid=".$k."\">".$v."</a>";
291 287
 		}
292 288
 	}
293
- 
294
-	return  implode(", ", $authlink) ;
289
+	return isset($authlink) ? implode(", ", $authlink) : "<a href=\""._BASEDIR."viewuser.php?uid=".$stories['uid']."\">".$stories['penname']."</a>";
295 290
 }
296 291
 
297 292
 // Used to truncate text (summaries in blocks for example) to a set length.  An improvement on the old version as this keeps words intact
... ...
@@ -26,15 +26,15 @@ if(!defined("_CHARSET")) exit( );
26 26
 	$tpl->assign("sid", $stories['sid']);
27 27
 	unset($challengelinks, $challengeadmin, $serieslinks, $categorylinks, $adminlinks, $authlink);
28 28
 	if($stories['coauthors'] == 1) {
29
-		$array_coauthors = array();
29
+		$coauthors = array();
30 30
 		$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']."'");
31 31
 		while($c = dbassoc($coauth)) {
32
-			$array_coauthors[$c['uid']] = $c['penname'];
32
+			$coauthors[$c['uid']] = $c['penname'];
33 33
 		}
34
-		$stories['coauthors_array'] = $array_coauthors;
35
-		unset($array_coauthors);
34
+		$stories['coauthors'] = $coauthors;
35
+		unset($coauthors);
36 36
 	}
37
-	else  $stories['coauthors_array'] = array( );	 
37
+	else if(empty($stories['coauthors'])) $stories['coauthors'] = array( );
38 38
 	$tpl->assign("title"   , stripslashes(title_link($stories)) );
39 39
 	$tpl->assign("author"   , author_link($stories));
40 40
 	$tpl->assign("summary", stripslashes($stories['summary']) );
... ...
@@ -108,7 +108,7 @@ if(!defined("_CHARSET")) exit( );
108 108
 	}
109 109
 	$tpl->assign("wordcount"   , $stories['wordcount'] ? $stories['wordcount'] : "0" );
110 110
 	$tpl->assign("numreviews"   , ($reviewsallowed == "1" ? "<a href=\""._BASEDIR."reviews.php?type=ST&amp;item=".$stories['sid']."\">".$stories['reviews']."</a>" : "") );
111
-	if((isADMIN && uLEVEL < 4) || USERUID == $stories['uid'] || (is_array($stories['coauthors']) && array_key_exists(USERUID, $stories['coauthors_array'])))
111
+	if((isADMIN && uLEVEL < 4) || USERUID == $stories['uid'] || (is_array($stories['coauthors']) && array_key_exists(USERUID, $stories['coauthors'])))
112 112
 		$adminlinks .= "[<a href=\""._BASEDIR."stories.php?action=editstory&amp;sid=".$stories['sid'].(isADMIN ? "&amp;admin=1" : "")."\">"._EDIT."</a>] [<a href=\""._BASEDIR."stories.php?action=delete&amp;sid=".$stories['sid'].(isADMIN ? "&amp;admin=1" : "")."\">"._DELETE."</a>]";
113 113
 	global $featured;
114 114
 	if($stories['featured'] == 1) {
... ...
@@ -126,6 +126,6 @@ if(!defined("_CHARSET")) exit( );
126 126
 	$tpl->assign("oddeven", ($count % 2 ? "odd" : "even"));
127 127
 	$tpl->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&amp;url=viewstory.php?sid=".$stories['sid']."\">"._REPORTTHIS."</a>]");
128 128
 	if(isADMIN && uLEVEL < 4) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> ".$adminlinks."</div>");
129
-	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>");
129
+	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>");
130 130
 	$count++;
131 131
 ?>