Esempio n. 1
0
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid)
{
    /* 
     * Proceeds to create an announcement
     *
     */
    require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'mp-app-users.php';
    // persist data to database
    $postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid);
    qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null);
    // update new post with category path hierarchy
    qa_db_posts_calc_category_path($postid);
    // send notifications
    if ($notify && isset($postid)) {
        $category = mp_get_categoryinfo($categoryid);
        $recipients = mp_get_category_userids($categoryid);
        foreach ($recipients as $recipient) {
            // retrieve the user flags
            $userflags = mp_get_user_flags($recipient['userid']);
            // check user flags to determine whether user should be notified or not
            // of the new answer post
            if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) {
                qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null)));
            }
        }
    }
    // report announcement create event
    qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify));
    return $postid;
}
Esempio n. 2
0
 function logged_in()
 {
     qa_html_theme_base::logged_in();
     $qa_login_userid = qa_get_logged_in_userid();
     if (isset($qa_login_userid)) {
         $currentcourse = mp_get_categoryinfo(mp_get_categoryid());
         //$this->output('Course: '.$currentcourse['title'] );
         //$this->output('<A HREF="'.qa_path_html('mp-change-course-page').'" class="qa-user-link">Change Course</a>');
         $this->output('course: <A HREF="' . qa_path_html('mp-change-course-page') . '" class="qa-user-link">' . $currentcourse['title'] . '</a>');
     }
 }
function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question)
{
    $postid = qa_db_post_create('A', $question['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $content, $format, null, qa_combine_notify_email($userid, $notify, $email), $question['categoryid']);
    qa_db_posts_calc_category_path($postid);
    if (!$question['hidden']) {
        // don't index answer if parent question is hidden
        qa_post_index($postid, 'A', $question['postid'], null, $text, null);
    }
    qa_db_post_acount_update($question['postid']);
    qa_db_hotness_update($question['postid']);
    qa_db_points_update_ifuser($userid, 'aposts');
    qa_db_acount_update();
    qa_db_unaqcount_update();
    if (isset($question['notify']) && !qa_post_is_by_user($question, $userid, $cookieid)) {
        require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
        require_once QA_INCLUDE_DIR . 'qa-app-options.php';
        require_once QA_INCLUDE_DIR . 'qa-util-string.php';
        $blockwordspreg = qa_get_block_words_preg();
        $sendtitle = qa_block_words_replace($question['title'], $blockwordspreg);
        $sendtext = qa_block_words_replace($text, $blockwordspreg);
        qa_send_notification($question['userid'], $question['notify'], @$question['handle'], qa_lang('emails/q_answered_subject'), qa_lang('emails/q_answered_body'), array('^a_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendtext, '^url' => qa_path(qa_q_request($question['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $postid))));
    }
    // notify all members of the category about the new post
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'mp-db-users.php';
    require_once QA_INCLUDE_DIR . 'mp-app-users.php';
    // find list of members of the category
    $recipients = mp_get_category_userids(mp_get_categoryid());
    // remove the current user from the list of recipients
    unset($recipients[$userid]);
    // get details for current category
    $currentcategory = mp_get_categoryinfo(mp_get_categoryid());
    foreach ($recipients as $recipient) {
        // retrieve the user flags
        $userflags = mp_get_user_flags($recipient['userid']);
        // check user flags to determine whether user should be notified or not
        // of the new answer post
        if (!($userflags & QA_USER_FLAGS_NOTIFY_ANSWERS)) {
            // for each member, send notification
            qa_send_notification($recipient['userid'], null, null, qa_lang('emails/q_answered_with_category_subject'), qa_lang('emails/q_answered_with_category_body'), array('^a_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $question['title'], '^a_content' => $text, '^url' => qa_path(qa_q_request($question['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $postid)), '^category_title' => $currentcategory['title'] . $userflags));
        }
    }
    qa_report_event('a_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $question['categoryid'], 'notify' => $notify, 'email' => $email));
    return $postid;
}
Esempio n. 4
0
            $qa_cookieid = qa_cookie_get_create();
        }
        // create a new cookie if necessary
        $questionid = qa_question_create($followanswer, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail, $incategoryid);
        qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_post', $questionid, null, null);
        qa_redirect(qa_q_request($questionid, $intitle));
        // our work is done here
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$incategoryid)));
$qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title');
$editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs');
$editor = qa_load_editor(@$incontent, @$informat, $editorname);
// MP: find category title
$categoryinfo = mp_get_categoryinfo(mp_get_categoryid());
$qa_content['form'] = array('tags' => 'NAME="ask" METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('follows' => array(), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="title" ID="title" AUTOCOMPLETE="off"', 'value' => qa_html(@$intitle), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<SPAN ID="similar"></SPAN>'), 'categorylabel' => array('type' => 'static', 'label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['category']), 'value' => $categoryinfo['title']), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$errors['content']))), 'tags' => array('error' => qa_html(@$errors['tags']))), 'buttons' => array('ask' => array('label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'doask' => '1', 'category' => mp_get_categoryid()));
if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) {
    $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
    $qa_content['form']['fields']['title']['tags'] .= ' onChange="qa_title_change(this.value);"';
    if (strlen(@$intitle)) {
        $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($intitle) . ');';
    }
}
//if (qa_using_categories() && count($categories)) {
//	qa_set_up_category_field($qa_content, $qa_content['form']['fields']['category'], 'category',
//		$categories, $incategoryid, true, qa_opt('allow_no_sub_category'));
//
//	if (!qa_opt('allow_no_category')) // don't auto-select a category even though one is required
//		$qa_content['form']['fields']['category']['options']['']='';
//
$debug = qa_get('debug');
$body = "";
// build the list of subjects for the emails
$subjects = array('Your Biweekly Microprobe activity for course ', 'Hello, this is your biweekly Microprobe activity for course ', 'A new edition of your biweekly Microprobe activity report for course ');
$subjectindex = rand(0, count($subjects) > 0 ? count($subjects) - 1 : 0);
// set the debug mode.  if debug flag not set, set it to false by default
if ($debug == "true") {
    $debug = TRUE;
} else {
    $debug = FALSE;
}
// check to ensure we provide a category
if (!$category) {
    echo 'ERROR: You must provide a category as a http argment: category=categoryid';
} else {
    $categoryinfo = mp_get_categoryinfo($category);
    // retrieve the list of users
    $users = mp_get_category_userids($category);
    foreach ($users as $user) {
        $u = mp_db_user_find_by_userid($user['userid']);
        $body = sprintf("It has been %s days since your last login to Microprobe %s\n\n", mp_db_user_find_dayssincelastlogin_by_userid($user['userid']), $u[0]['email']);
        $questioncount = mp_get_count_posts_by_userid_category_posttype($user['userid'], $category, 'Q');
        $body .= sprintf("ACTIVITY INFORMATION\n");
        if ($questioncount > 0) {
            $body .= sprintf("You have posted %s questions so far. ", $questioncount);
            $body .= sprintf("It has been %s days since you last posted a question.\n", mp_get_days_since_last_post($user['userid'], $category, 'Q'));
        } else {
            $body .= sprintf("You have not posted a question before.  Posting a question will help increase your activity points while motivating the knowledge sharing process.\n\n");
        }
        $answercount = mp_get_count_posts_by_userid_category_posttype($user['userid'], $category, 'A');
        if ($answercount > 0) {