function process_request($request)
 {
     require_once QA_INCLUDE_DIR . 'qa-app-format.php';
     require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
     require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
     require_once QA_INCLUDE_DIR . 'mp-db-users.php';
     // report that we entered this page
     qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING']));
     // create the editor and update its content
     qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext);
     $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs');
     $editor = qa_load_editor(@$incontent, @$informat, $editorname);
     // retrieve variable data
     $innotify = qa_post_text('notify') ? true : false;
     // handle creation of annoucement
     if (qa_post_text('docreate')) {
         //retrieve data
         $title = qa_post_text('title');
         $content = $incontent;
         $format = $informat;
         // validate data
         // handle create work
         // actual create process is in file mp-app-posts.php
         $postid = qa_post_create('AN', null, $title, $content, $format, mp_get_categoryid(), null, qa_get_logged_in_userid(), $innotify);
         // redirect page
         qa_redirect('mp-announcements-page');
         // our work is done here
     }
     $qa_content = qa_content_prepare();
     // if the user is not logged in, request user to login
     if (!qa_get_logged_in_userid()) {
         $qa_content['error'] = qa_insert_login_links('Please ^1log in^2 or ^3register^4 first.', $request);
         return $qa_content;
     }
     $qa_content['title'] = 'Create Announcement';
     $qa_content['form_newannouncement'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('announcements/a_title_label'), 'tags' => 'NAME="title"', 'value' => qa_html(qa_post_text('title')), 'error' => qa_html(@$errors['title'])), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('announcements/a_content_label'), 'error' => qa_html(@$errors['content']))), 'notify' => array('label' => 'Send email notification to all registered students', 'tags' => 'NAME="notify"', 'type' => 'checkbox', 'value' => qa_html($innotify))), 'buttons' => array('ok' => array('tags' => 'NAME="docreate"', 'label' => 'Create Announcement', 'value' => '1')), 'hidden' => array('hiddenfield' => '1', 'editor' => qa_html($editorname)));
     // create the sub menu for navigation
     $qa_content['navigation']['sub'] = mp_announcements_sub_navigation();
     $qa_content['navigation']['sub']['create']['selected'] = true;
     return $qa_content;
 }
Esempio n. 2
0
 function do_post($data)
 {
     if (!isset($data['action_data']) || !isset($data['action_data']['type'])) {
         return false;
     }
     $userid = qa_get_logged_in_userid();
     $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
     // create a new cookie if necessary
     $questionid = (int) @$data['action_data']['question_id'];
     $input = $data['action_data'];
     $type = $input['type'];
     $title = @$input['title'];
     $content = @$input['content'];
     $format = @$input['format'];
     $tags = @$input['tags'];
     $category = @$input['category'];
     $notify = @$input['notify'];
     $email = @$input['email'];
     $parentid = @$input['parentid'];
     $permiterror = qa_user_permit_error('permit_post_' . strtolower($type), QA_LIMIT_QUESTIONS);
     if ($permiterror) {
         // not allowed
         return false;
     }
     require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
     $postid = qa_post_create($type, $parentid, $title, $content, $format, $category, $tags, $userid, $notify, $email);
     return $postid != null;
 }
Esempio n. 3
0
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . $_FILES["file"]["size"] / 1024 . " Kb<br />";
        echo "Stored in: " . $_FILES["file"]["tmp_name"];
        $objExcel = PHPExcel_IOFactory::load($_FILES["file"]["tmp_name"]);
        $sheet = $objExcel->getSheet(0);
        $highestRow = $sheet->getHighestRow();
        echo $highestRow, "<br>";
        $answer = 'a';
        for ($row = 1; $row <= $highestRow; ++$row) {
            echo "row number:", $row, "<br>";
            $tags = $sheet->getCellByColumnAndRow(0, $row)->getValue();
            $tags = str_replace(' ', ',', $tags);
            $q_title = $sheet->getCellByColumnAndRow(1, $row)->getValue();
            $q_content = $sheet->getCellByColumnAndRow(2, $row)->getValue();
            $answer = $sheet->getCellByColumnAndRow(3, $row)->getValue();
            // echo $answer;
            $q_id = qa_post_create('Q', null, $q_title, $q_content, '', null, $tags, 2);
            echo "question id:", $q_id, "<br>";
            // sleep(2);
            echo "answer:", $answer, "<br>";
            $a_id = qa_post_create('A', $q_id, null, $answer, '', null, null, 2);
            // ++$answer;
            echo "answer id:", $a_id, "<br>";
            // sleep(2);
        }
    }
} else {
    echo "Invalid file";
}
?>
</body>
Esempio n. 4
0
function createAnswer($parentid, $content, $userid = null, $format = '', $categoryid = null, $notify = null, $email = null, $extravalue = null, $name = null)
{
    if ($userid == null) {
        $userid = qa_get_logged_in_userid();
    }
    $type = 'A';
    // question
    if (isset($tags)) {
        $tags = str_replace(",", ",", $tags);
        //如果有中文标点,改为英文标点
    }
    $postid = qa_post_create($type, $parentid, null, $content, $format, $categoryid, null, $userid);
    // $query = qa_db_query_sub("update ^posts set areaclass = $, conclass = $ where postid = $", $areaclass, $conclass, $postid);
    return $postid;
}