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;
}
Beispiel #2
0
 public function process_event($event, $userid, $handle, $cookieid, $params)
 {
     // Don't increment limits or report user actions for events that were delayed. For example, a 'q_post'
     // event sent when a post is approved by the admin, for which a 'q_queue' event was already sent.
     if (isset($params['delayed'])) {
         return;
     }
     require_once QA_INCLUDE_DIR . 'app/limits.php';
     switch ($event) {
         case 'q_queue':
         case 'q_post':
         case 'q_claim':
             qa_limits_increment($userid, QA_LIMIT_QUESTIONS);
             break;
         case 'a_queue':
         case 'a_post':
         case 'a_claim':
             qa_limits_increment($userid, QA_LIMIT_ANSWERS);
             break;
         case 'c_queue':
         case 'c_post':
         case 'c_claim':
         case 'a_to_c':
             qa_limits_increment($userid, QA_LIMIT_COMMENTS);
             break;
         case 'q_vote_up':
         case 'q_vote_down':
         case 'q_vote_nil':
         case 'a_vote_up':
         case 'a_vote_down':
         case 'a_vote_nil':
             qa_limits_increment($userid, QA_LIMIT_VOTES);
             break;
         case 'q_flag':
         case 'a_flag':
         case 'c_flag':
             qa_limits_increment($userid, QA_LIMIT_FLAGS);
             break;
         case 'u_message':
             qa_limits_increment($userid, QA_LIMIT_MESSAGES);
             break;
         case 'u_wall_post':
             qa_limits_increment($userid, QA_LIMIT_WALL_POSTS);
             break;
     }
     $writeactions = array('_approve', '_claim', '_clearflags', '_delete', '_edit', '_favorite', '_flag', '_hide', '_post', '_queue', '_reject', '_reshow', '_unfavorite', '_unflag', '_vote_down', '_vote_nil', '_vote_up', 'a_select', 'a_to_c', 'a_unselect', 'q_close', 'q_move', 'q_reopen', 'u_block', 'u_edit', 'u_level', 'u_message', 'u_password', 'u_save', 'u_unblock');
     if (is_numeric(array_search(strstr($event, '_'), $writeactions)) || is_numeric(array_search($event, $writeactions))) {
         if (isset($userid)) {
             require_once QA_INCLUDE_DIR . 'app/users.php';
             qa_user_report_action($userid, $event);
         } elseif (isset($cookieid)) {
             require_once QA_INCLUDE_DIR . 'app/cookies.php';
             qa_cookie_report_action($cookieid, $event);
         }
     }
 }
 function process_event($event, $userid, $handle, $cookieid, $params)
 {
     require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
     switch ($event) {
         case 'q_post':
         case 'q_claim':
             qa_limits_increment($userid, QA_LIMIT_QUESTIONS);
             break;
         case 'a_post':
         case 'a_claim':
             qa_limits_increment($userid, QA_LIMIT_ANSWERS);
             break;
         case 'c_post':
         case 'c_claim':
         case 'a_to_c':
             qa_limits_increment($userid, QA_LIMIT_COMMENTS);
             break;
         case 'q_vote_up':
         case 'q_vote_down':
         case 'q_vote_nil':
         case 'a_vote_up':
         case 'a_vote_down':
         case 'a_vote_nil':
             qa_limits_increment($userid, QA_LIMIT_VOTES);
             break;
         case 'q_flag':
         case 'a_flag':
         case 'c_flag':
             qa_limits_increment($userid, QA_LIMIT_FLAGS);
             break;
         case 'u_message':
             qa_limits_increment($userid, QA_LIMIT_MESSAGES);
             break;
         case 'u_wall_post':
             qa_limits_increment($userid, QA_LIMIT_WALL_POSTS);
             break;
     }
     $writeactions = array('_approve', '_claim', '_clearflags', '_delete', '_edit', '_favorite', '_flag', '_hide', '_post', '_queue', '_reject', '_reshow', '_unfavorite', '_unflag', '_vote_down', '_vote_nil', '_vote_up', 'a_select', 'a_to_c', 'a_unselect', 'q_close', 'q_move', 'q_reopen', 'u_block', 'u_edit', 'u_level', 'u_message', 'u_password', 'u_save', 'u_unblock');
     if (!isset($params['delayed']) && (is_numeric(array_search(strstr($event, '_'), $writeactions)) || is_numeric(array_search($event, $writeactions)))) {
         if (isset($userid)) {
             require_once QA_INCLUDE_DIR . 'qa-app-users.php';
             qa_user_report_action($userid, $event);
         } elseif (isset($cookieid)) {
             require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
             qa_cookie_report_action($cookieid, $event);
         }
     }
 }
function qa_report_write_action($userid, $cookieid, $action, $questionid, $answerid, $commentid)
{
    switch ($action) {
        case 'q_post':
        case 'q_claim':
            qa_limits_increment($userid, 'Q');
            break;
        case 'a_post':
        case 'a_claim':
            qa_limits_increment($userid, 'A');
            break;
        case 'c_post':
        case 'c_claim':
        case 'a_to_c':
            qa_limits_increment($userid, 'C');
            break;
        case 'q_vote_up':
        case 'q_vote_down':
        case 'q_vote_nil':
        case 'a_vote_up':
        case 'a_vote_down':
        case 'a_vote_nil':
            qa_limits_increment($userid, 'V');
            break;
        case 'q_flag':
        case 'a_flag':
        case 'c_flag':
            qa_limits_increment($userid, 'F');
            break;
    }
    if (isset($userid)) {
        require_once QA_INCLUDE_DIR . 'qa-app-users.php';
        qa_user_report_action($userid, $action, $questionid, $answerid, $commentid);
    }
    if (isset($cookieid)) {
        require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
        qa_cookie_report_action($cookieid, $action, $questionid, $answerid, $commentid);
    }
}