Esempio n. 1
0
File: new.php Progetto: rair/yacs
    // build the form
    $context['text'] .= Skin::build_form($fields);
    // the submit button
    $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
    // end of the form
    $context['text'] .= '</div></form>';
    // the script used for form handling at the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	// letter_title is mandatory' . "\n" . '	if(!container.letter_title.value) {' . "\n" . '		alert("' . i18n::s('No title has been provided.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . "\n" . 'document.main_form.letter_title.focus();' . "\n");
    // no mail in demo mode
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // handle posted data
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    // ensure all letters will be sent even if the browser connection dies
    Safe::ignore_user_abort(TRUE);
    // always archive the letter
    $anchor = Sections::lookup('letters');
    // no section yet, create one
    if (!$anchor) {
        $context['text'] .= i18n::s('Creating a section for archived letters') . BR . "\n";
        $fields['nick_name'] = 'letters';
        $fields['title'] = i18n::c('Archived letters');
        $fields['introduction'] = i18n::c('To remember our previous messages');
        $fields['description'] = i18n::c('YACS puts automatically sent letters into this section.');
        $fields['locked'] = 'Y';
        // no direct contributions
        $fields['index_map'] = 'N';
        // listed only to associates
        $fields['rank'] = 30000;
        // at the end of the list