e107-eFiction / efiction-3.5.x

eFiction CMS version 3.5.7
https://www.hpfanfiction.cz/
GNU General Public License v3.0
1 stars 0 forks source link

how coauthors fiels should work? #7

Open Jimmi08 opened 2 months ago

Jimmi08 commented 2 months ago

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 commented 2 months ago

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 commented 1 month ago

Solution:

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

There is always author (UID) OR author + coauthors_array