$dbStatement = Util::getDbConnection()->prepare("UPDATE Link " . "SET IsCreated = 'Y' " . "WHERE SourceEpisodeID = :parentToUpdate " . "AND TargetEpisodeID = :episodeToUpdate"); $dbStatement->bindParam(":parentToUpdate", $parentToUpdate, PDO::PARAM_INT); $dbStatement->bindParam(":episodeToUpdate", $episodeToUpdate, PDO::PARAM_INT); $dbStatement->execute(); if ($dbStatement->rowCount() != 1) { throw new HardStoryException("Unable to update the link record."); } for ($i = 0; $i < $linkCount; $i++) { $var1 = "option" . $i; $var2 = "backlink" . $i; if (!empty(${$var1})) { if (${$var2} != 0) { Util::createLink($episodeToUpdate, ${$var2}, ${$var1}, true); } else { $newEpisode = Util::createEpisode($episodeToUpdate, $scheme); Util::createLink($episodeToUpdate, $newEpisode, ${$var1}, false); } } } if ($adminEmail != "-") { // send a notification email to the administrator Util::extensionNotification($adminEmail, $parentToUpdate, $episodeToUpdate, $authorName); // send a notification email (if applicable) to the author of the parent episode $dbStatement = Util::getDbConnection()->prepare("SELECT AuthorNotify, " . "AuthorEmail " . "FROM Episode " . "WHERE EpisodeID = :parentToUpdate"); $dbStatement->bindParam(":parentToUpdate", $parentToUpdate, PDO::PARAM_INT); $dbStatement->execute(); $row = $dbStatement->fetch(PDO::FETCH_NUM); if (!$row) { throw new HardStoryException("Problem fetching parent episode row from the database."); } $tempAuthorNotify = $row[0];
$row = $dbStatement->fetch(PDO::FETCH_NUM); if (!$row) { $message .= "The back linked episode doesn't exist.<BR>"; } else { if ($row[0] != "Y") { $message .= "The back linked episode is not linkable.<BR>"; } } } if (empty($message)) { Util::createEpisodeEditLog($episode, "New link added by " . $userName . "."); if ($linkEpisode == 0) { $newEpisode = Util::createEpisode($episode, $scheme); Util::createLink($episode, $newEpisode, $linkDescription, false); } else { Util::createLink($episode, $linkEpisode, $linkDescription, true); } $dbStatement = Util::getDbConnection()->prepare("UPDATE Episode " . "SET EditorSessionID = :sessionID, " . "Status = 2, " . "LockDate = '', " . "LockKey = 0, " . "CreationTimestamp = now() " . "WHERE EpisodeID = :episode"); $dbStatement->bindParam(":sessionID", $sessionID, PDO::PARAM_INT); $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT); $dbStatement->execute(); if ($dbStatement->rowCount() != 1) { throw new HardStoryException("Unable to unlock the episode record."); } $message = "Link Added"; $command = "Done"; } else { $message = "Problem adding link:<P>" . $message; $command = "AddLink"; } }