function qa_admin_single_click($postid, $action) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $post = qa_post_get_full($postid); if (isset($post)) { $userid = qa_get_logged_in_userid(); $queued = substr($post['type'], 1) == '_QUEUED'; switch ($action) { case 'approve': if ($queued && !qa_user_permit_error('permit_moderate')) { qa_post_set_hidden($postid, false, $userid); return true; } break; case 'reject': if ($queued && !qa_user_permit_error('permit_moderate')) { qa_post_set_hidden($postid, true, $userid); return true; } break; case 'hide': if (!$queued && !qa_user_permit_error('permit_hide_show')) { qa_post_set_hidden($postid, true, $userid); return true; } break; case 'reshow': if ($post['hidden'] && !qa_user_permit_error('permit_hide_show')) { qa_post_set_hidden($postid, false, $userid); return true; } break; case 'delete': if ($post['hidden'] && !qa_user_permit_error('permit_delete_hidden')) { qa_post_delete($postid); return true; } break; case 'clearflags': require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; if (!qa_user_permit_error('permit_hide_show')) { qa_flags_clear_all($post, $userid, qa_get_logged_in_handle(), null); return true; } break; } } return false; }
function qa_page_q_single_click_c($comment, $question, $parent, &$error) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); $prefix = 'c' . $comment['postid'] . '_'; if (qa_clicked($prefix . 'dohide') && $comment['hideable'] || qa_clicked($prefix . 'doreject') && $comment['moderatable']) { if (qa_page_q_click_check_form_code($parent, $error)) { qa_comment_set_hidden($comment, true, $userid, $handle, $cookieid, $question, $parent); return true; } } if (qa_clicked($prefix . 'doreshow') && $comment['reshowable'] || qa_clicked($prefix . 'doapprove') && $comment['moderatable']) { if (qa_page_q_click_check_form_code($parent, $error)) { if ($comment['moderatable'] || $comment['reshowimmed']) { $status = QA_POST_STATUS_NORMAL; } else { $in = qa_page_q_prepare_post_for_filters($comment); $filtermodules = qa_load_modules_with('filter', 'filter_comment'); // run through filters but only for queued status foreach ($filtermodules as $filtermodule) { $tempin = $in; // always pass original comment in because we aren't modifying anything else $filtermodule->filter_comment($tempin, $temperrors, $question, $parent, $comment); $in['queued'] = $tempin['queued']; // only preserve queued status in loop } $status = $in['queued'] ? QA_POST_STATUS_QUEUED : QA_POST_STATUS_NORMAL; } qa_comment_set_status($comment, $status, $userid, $handle, $cookieid, $question, $parent); return true; } } if (qa_clicked($prefix . 'dodelete') && $comment['deleteable'] && qa_page_q_click_check_form_code($parent, $error)) { qa_comment_delete($comment, $question, $parent, $userid, $handle, $cookieid); return true; } if (qa_clicked($prefix . 'doclaim') && $comment['claimable'] && qa_page_q_click_check_form_code($parent, $error)) { if (qa_user_limits_remaining(QA_LIMIT_COMMENTS)) { qa_comment_set_userid($comment, $userid, $handle, $cookieid); return true; } else { $error = qa_lang_html('question/comment_limit'); } } if (qa_clicked($prefix . 'doflag') && $comment['flagbutton'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; $error = qa_flag_error_html($comment, $userid, qa_request()); if (!$error) { if (qa_flag_set_tohide($comment, $userid, $handle, $cookieid, $question)) { qa_comment_set_hidden($comment, true, null, null, null, $question, $parent); } // hiding not really by this user so pass nulls return true; } } if (qa_clicked($prefix . 'dounflag') && $comment['unflaggable'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flag_clear($comment, $userid, $handle, $cookieid); return true; } if (qa_clicked($prefix . 'doclearflags') && $comment['clearflaggable'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flags_clear_all($comment, $userid, $handle, $cookieid); return true; } return false; }
function qa_page_q_single_click_c($comment, $question, $parent, &$error) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); $prefix = 'c' . $comment['postid'] . '_'; if (qa_page_q_clicked($prefix . 'dohide') && $comment['hideable'] || qa_page_q_clicked($prefix . 'doreject') && $comment['moderatable']) { qa_comment_set_hidden($comment, true, $userid, $handle, $cookieid, $question, $parent); return true; } if (qa_page_q_clicked($prefix . 'doreshow') && $comment['reshowable'] || qa_page_q_clicked($prefix . 'doapprove') && $comment['moderatable']) { qa_comment_set_hidden($comment, false, $userid, $handle, $cookieid, $question, $parent); return true; } if (qa_page_q_clicked($prefix . 'dodelete') && $comment['deleteable']) { qa_comment_delete($comment, $question, $parent, $userid, $handle, $cookieid); return true; } if (qa_page_q_clicked($prefix . 'doclaim') && $comment['claimable']) { if (qa_limits_remaining($userid, QA_LIMIT_COMMENTS)) { qa_comment_set_userid($comment, $userid, $handle, $cookieid); return true; } else { $error = qa_lang_html('question/comment_limit'); } } if (qa_page_q_clicked($prefix . 'doflag') && $comment['flagbutton']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; $error = qa_flag_error_html($comment, $userid, qa_request()); if (!$error) { if (qa_flag_set_tohide($comment, $userid, $handle, $cookieid, $question)) { qa_comment_set_hidden($comment, true, null, null, null, $question, $parent); } // hiding not really by this user so pass nulls return true; } } if (qa_page_q_clicked($prefix . 'dounflag') && $comment['unflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flag_clear($comment, $userid, $handle, $cookieid); return true; } if (qa_page_q_clicked($prefix . 'doclearflags') && $comment['clearflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flags_clear_all($comment, $userid, $handle, $cookieid); return true; } return false; }
function qa_admin_single_click($entityid, $action) { $userid = qa_get_logged_in_userid(); if (!QA_FINAL_EXTERNAL_USERS && ($action == 'userapprove' || $action == 'userblock')) { // approve/block moderated users require_once QA_INCLUDE_DIR . 'db/selects.php'; $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($entityid, true)); if (isset($useraccount) && qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR) { switch ($action) { case 'userapprove': if ($useraccount['level'] <= QA_USER_LEVEL_APPROVED) { // don't demote higher level users require_once QA_INCLUDE_DIR . 'app/users-edit.php'; qa_set_user_level($useraccount['userid'], $useraccount['handle'], QA_USER_LEVEL_APPROVED, $useraccount['level']); return true; } break; case 'userblock': require_once QA_INCLUDE_DIR . 'app/users-edit.php'; qa_set_user_blocked($useraccount['userid'], $useraccount['handle'], true); return true; break; } } } else { // something to do with a post require_once QA_INCLUDE_DIR . 'app/posts.php'; $post = qa_post_get_full($entityid); if (isset($post)) { $queued = substr($post['type'], 1) == '_QUEUED'; switch ($action) { case 'approve': if ($queued && !qa_user_post_permit_error('permit_moderate', $post)) { qa_post_set_hidden($entityid, false, $userid); return true; } break; case 'reject': if ($queued && !qa_user_post_permit_error('permit_moderate', $post)) { qa_post_set_hidden($entityid, true, $userid); return true; } break; case 'hide': if (!$queued && !qa_user_post_permit_error('permit_hide_show', $post)) { qa_post_set_hidden($entityid, true, $userid); return true; } break; case 'reshow': if ($post['hidden'] && !qa_user_post_permit_error('permit_hide_show', $post)) { qa_post_set_hidden($entityid, false, $userid); return true; } break; case 'delete': if ($post['hidden'] && !qa_user_post_permit_error('permit_delete_hidden', $post)) { qa_post_delete($entityid); return true; } break; case 'clearflags': require_once QA_INCLUDE_DIR . 'app/votes.php'; if (!qa_user_post_permit_error('permit_hide_show', $post)) { qa_flags_clear_all($post, $userid, qa_get_logged_in_handle(), null); return true; } break; } } } return false; }
if (!$pageerror) { if (qa_flag_set_tohide($comment, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question)) { qa_comment_set_hidden($comment, true, null, null, null, $question, $commentanswer); } // hiding not really by this user so pass nulls qa_redirect($qa_request, null, null, null, qa_anchor($commentparenttype, $comment['parentid'])); } } if (qa_clicked('dounflagc_' . $commentid) && $comment['unflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flag_clear($comment, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid); qa_redirect($qa_request, null, null, null, qa_anchor($commentparenttype, $comment['parentid'])); } if (qa_clicked('doclearflagsc_' . $commentid) && $comment['clearflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flags_clear_all($comment, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid); qa_redirect($qa_request, null, null, null, qa_anchor($commentparenttype, $comment['parentid'])); } if ($comment['editbutton']) { if (qa_clicked('docancel')) { qa_redirect($qa_request); } elseif (qa_clicked('doeditc_' . $commentid)) { qa_redirect($qa_request, array('state' => 'edit-' . $commentid)); } elseif (qa_clicked('dosavec_' . $commentid) && qa_page_q_permit_edit($comment, 'permit_edit_c')) { $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); qa_get_post_content('editor', 'comment', $ineditor, $incomment, $informat, $intext); $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail); if (empty($errors)) { $setnotify = $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $innotify, $inemail) : $comment['notify']; qa_comment_set_content($comment, $incomment, $informat, $intext, $setnotify, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question, $commentanswer);