* @version 1.7
 * @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE
 *
 ***/
if (array_key_exists("save", $_POST['action']) || array_key_exists("done", $_POST['action'])) {
    $fields = array();
    ##IMPORTANT. MUST Initialize this incase register globals is on
    include_once TOOLKIT . "/class.entrymanager.php";
    $entryManager = new EntryManager($Admin);
    $data = $_POST['fields'];
    $section_id = intval($_REQUEST['_sid']);
    $entry_id = intval($_REQUEST['id']);
    if ($Admin->getConfigVar('strict_section_field_validation', 'symphony') == '1') {
        $errors = $entryManager->validateFieldsXSLT($section_id, $data['custom'], $entry_id);
    } else {
        $errors = $entryManager->validateFields($section_id, $data['custom']);
    }
    if (is_array($errors) && !empty($errors)) {
        define("__SYM_ENTRY_MISSINGFIELDS__", true);
    } elseif (!defined('__SYM_ENTRY_VALIDATION_ERROR__') && !defined('__SYM_ENTRY_FIELD_XSLT_ERROR__')) {
        $newPublishTimestamp = NULL;
        if (isset($data['time']) && isset($data['publish_date'])) {
            ##Do some processing to ensure all the text is in the correct format
            $date = $Admin->getDateObj();
            $date->setFormat("Y-m-d H:i:s");
            ##User has specified the time, grab it as GMT
            if ($data['time'] == "Automatic" || $data['time'] == "") {
                $data['time'] = date("h:i:sa", $date->get(true, false));
            }
            ##User has specified the time, grab it as GMT
            $date->set(strtotime($data['time'] . " " . $data['publish_date']));