Ejemplo n.º 1
0
/**
* Saves a story submission
*
* @param    array   $A  Data for that submission
* @return   string      HTML redirect
*
*/
function savestory($A)
{
    global $_CONF, $_TABLES, $_USER;
    $retval = '';
    $story = new Story();
    $story->loadSubmission();
    // pseudo-formatted story text for the spam check
    $result = PLG_checkforSpam($story->GetSpamCheckFormat(), $_CONF['spamx']);
    if ($result > 0) {
        COM_updateSpeedlimit('submit');
        COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden');
    }
    COM_updateSpeedlimit('submit');
    $result = $story->saveSubmission();
    if ($result == STORY_NO_ACCESS_TOPIC) {
        // user doesn't have access to this topic - bail
        $retval = COM_refresh($_CONF['site_url'] . '/index.php');
    } elseif ($result == STORY_SAVED || $result == STORY_SAVED_SUBMISSION) {
        if (isset($_CONF['notification']) && in_array('story', $_CONF['notification'])) {
            sendNotification($_TABLES['storysubmission'], $story);
        }
        if ($result == STORY_SAVED) {
            $retval = COM_refresh(COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()));
        } else {
            $retval = COM_refresh($_CONF['site_url'] . '/index.php?msg=2');
        }
    }
    return $retval;
}