Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how coauthors fiels should work? #7

Open
Jimmi08 opened this issue May 9, 2024 · 3 comments
Open

how coauthors fiels should work? #7

Jimmi08 opened this issue May 9, 2024 · 3 comments
Labels

Comments

@Jimmi08
Copy link
Member

Jimmi08 commented May 9, 2024

No description provided.

@Jimmi08 Jimmi08 added the help wanted Extra attention is needed label May 9, 2024
@Jimmi08
Copy link
Member Author

Jimmi08 commented May 9, 2024

coauthors table was added in 3.4

		dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
  `sid` int(11) NOT NULL default '0',
  `uid` int(11) NOT NULL default '0',
  PRIMARY KEY  (`sid`,`uid`)
) ENGINE=MyISAM;");

dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET coauthors = '1' WHERE coauthors != '0'");

@Jimmi08
Copy link
Member Author

Jimmi08 commented May 9, 2024

this code looks wrong - changing it to the array

if($stories['coauthors'] == 1) {
		$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 = '".$stories['sid']."'");
		while($c = dbassoc($coauth)) {
			$coauthors[$c['uid']] = $c['penname'];
		}
		$stories['coauthors'] = $coauthors;
		unset($coauthors);
	}
	else if(empty($stories['coauthors'])) $stories['coauthors'] = array( );	

@Jimmi08
Copy link
Member Author

Jimmi08 commented May 24, 2024

Solution:

added story key coauthors_array to be sure what value should be used and when

  • story['coauthors'] - 0/1 - if story has coauthors
  • story['coauthors_array] - array with coauthors data

There is always author (UID) OR author + coauthors_array

@Jimmi08 Jimmi08 added fixed and removed help wanted Extra attention is needed labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant