I do end up using the PO_Insert_ID thing in my code, but because the AddStory module has a redirect at the end of the adding, I think it would hijack my process. In addition to it not returning the story ID. :)
For those curious, I'll include my function that I ended up creating. Maybe it'll help someone else, until .8 :)
<?php// add a new travel item to a project in the databasefunction projects_travelapi_create
($args){ // Get arguments from argument array extract($args);
// Argument check if ((!
isset($projid)) ||
(!
isset($dates)) ||
(!
isset($locations)) ||
(!
isset($people)) ||
(!
isset($itin))) { pnSessionSetVar
('errormsg', _MODARGSERROR
);
return false;
} // Security check if (!pnSecAuthAction
(0,
'projects:projects:',
"$projid::", ACCESS_EDIT
)) { pnSessionSetVar
('errormsg', _MODULENOAUTH
);
return false;
} // Get datbase setup $dbconn =& pnDBGetConn
(true);
$pntable =& pnDBGetTables
();
$traveltable =
$pntable['project_travel'];
$travelcolumn = &
$pntable['project_travel_column'];
$projecttable =
$pntable['project_projects'];
$projectcolumn = &
$pntable['project_projects_column'];
$storytable=
$pntable['stories'];
$storycolumn=&
$pntable['stories_column'];
$projectinfo=pnModAPIFunc
('projects',
'projects',
'get',
array('projid'=>
$projid));
// Get next ID in table $nextId =
$dbconn->
GenId($traveltable);
$username=pnUserGetVar
('uname');
$userid=pnUserGetVar
('uid');
$projecturl=pnModURL
('projects',
'projects',
'display',
array ('projid' =>
$projid));
$bodytext=
"<b>Travel dates</b><br>".
$dates.
" <br>
<b>Locations</b><br>".
$locations.
" <br>
<b>People</b><br>".
$people.
" <br>
<b>Itinerary</b><br>".
$itin.
"<br>
<a href=\"".
$projecturl.
"\">Project page</a>";
$title=
'Travel for '.
$projectinfo['title'];
//PostNuke-ify the variables. list($userid,
$title,
$bodytext) = pnVarPrepForStore
($userid,
$title,
$bodytext);
// Add item to the DB // change the cid to the travel category id when you upload to the live site. // change the cid to the travel topic id when you upload to the live site. (or the other way around. I forget now.) $sql =
"INSERT INTO $storytable (
$storycolumn[sid],
$storycolumn[catid],
$storycolumn[aid],
$storycolumn[title],
$storycolumn[time],
$storycolumn[hometext],
$storycolumn[bodytext],
$storycolumn[comments],
$storycolumn[counter],
$storycolumn[topic],
$storycolumn[informant],
$storycolumn[notes],
$storycolumn[ihome],
$storycolumn[themeoverride],
$storycolumn[language],
$storycolumn[withcomm],
$storycolumn[format_type])
VALUES (
'".
(int
)$nextId.
"',
'0',
'".
$userid.
"',
'".
$title.
"',
NOW(),
' ',
'".
$bodytext.
"',
'0',
'0',
'8',
'".
$username.
"',
'Please use the project page to update this entry.',
'0',
' ',
' ',
'0',
'0')";
$dbconn->
Execute($sql);
// Check for an error with the database code if ($dbconn->
ErrorNo() !=
0) { pnSessionSetVar
('errormsg', _STORYCREATEFAILED
);
return false;
} // Get the ID of the item that we inserted. $storyid =
$dbconn->
PO_Insert_ID($storytable,
$storycolumn['sid']);
$nextId =
$dbconn->
GenId($traveltable);
//PostNuke-ify the variables. list($projid,
$storyid) = pnVarPrepForStore
($projid,
$storyid);
// Add item to the DB $sql =
"INSERT INTO $traveltable (
$travelcolumn[travid],
$travelcolumn[projid],
$travelcolumn[storyid])
VALUES (
'".
(int
)$nextId.
"',
'".
$projid.
"',
'".
$storyid.
"')";
$dbconn->
Execute($sql);
// Check for an error with the database code if ($dbconn->
ErrorNo() !=
0) { pnSessionSetVar
('errormsg', _TRAVELCREATEFAILED
);
return false;
} // Get the ID of the item that we inserted. $travid =
$dbconn->
PO_Insert_ID($traveltable,
$travelcolumn['travid']);
// Update the project's last-updated date. $updated = pnModAPIFunc
('projects',
'projects',
'update_lastupdate',
array('projid' =>
$projid));
if (!
$updated) { pnSessionSetVar
('errormsg', _PROJECTUPDATEFAILED
);
return false;
} // Return the id of the newly created item to the calling process return $travid;
}?>