function ap_get_parti($post_id, $count = false)
{
    global $wpdb;
    if ($count) {
        return ap_meta_total_count('parti', $post_id, false, 'apmeta_userid');
    } else {
        return ap_get_all_meta(array('where' => array('apmeta_type' => array('value' => 'parti', 'compare' => '=', 'relation' => 'AND'), 'apmeta_actionid' => array('value' => $post_id, 'compare' => '=', 'relation' => 'AND')), 'group' => array('apmeta_userid' => array('relation' => 'AND'))), 5);
    }
}
Beispiel #2
0
function ap_get_parti($post_id = false, $count = false, $param = false)
{
    global $wpdb;
    if ($count) {
        return ap_meta_total_count('parti', $post_id, false, 'apmeta_userid');
    } else {
        $where = array('apmeta_type' => array('value' => 'parti', 'compare' => '=', 'relation' => 'AND'));
        if ($post_id !== false) {
            $where['apmeta_actionid'] = array('value' => $post_id, 'compare' => '=', 'relation' => 'AND');
        }
        if ($param !== false) {
            $where['apmeta_param'] = array('value' => $param, 'compare' => '=', 'relation' => 'AND');
        }
        return ap_get_all_meta(array('where' => $where, 'group' => array('apmeta_userid' => array('relation' => 'AND'))));
    }
}
Beispiel #3
0
function ap_get_post_history($post_id)
{
    global $wpdb;
    $post_ids = array();
    $comments_id = array();
    $ids = ap_get_child_answers_comm($post_id);
    $post_ids[] = $post_id;
    if (isset($ids['posts'])) {
        $post_ids = $ids['posts'];
    }
    $post_ids = "('" . implode("', '", $post_ids) . "')";
    if (isset($ids['comments'])) {
        $comments_id = $ids['comments'];
    }
    $comments_id = "('" . implode("', '", $comments_id) . "')";
    return ap_get_all_meta(false, 20, "SELECT *, UNIX_TIMESTAMP(apmeta_date) as unix_date FROM " . $wpdb->prefix . "ap_meta where apmeta_type = 'history' AND (apmeta_actionid IN {$post_ids} OR (apmeta_actionid IN {$comments_id} AND apmeta_value IN ('commented', 'edited_comment', 'deleted_comment', 'updated_comment'))) ");
}
Beispiel #4
0
    public function flag_meta_box_content($post)
    {
        // get all flag message
        $flag_note = ap_opt('flag_note');
        $results = ap_get_all_meta(array('apmeta_type' => 'flag', 'apmeta_actionid' => $post->ID), 10);
        if (!empty($results)) {
            foreach ($results as $r) {
                ?>
			<div class="flag-item clearfix">
				<div class="flagger">
					<?php 
                echo get_avatar($r->apmeta_userid, 30);
                ?>
					<strong><?php 
                echo ap_user_display_name($r->apmeta_userid);
                ?>
</strong>
				</div>
				<div class="flag-message">
					<div class="submitted-on">
						<?php 
                printf(__('<span class="when">Flagged about %s ago</span>', 'ap'), ap_human_time($r->unix_date));
                ?>
					</div>
					<strong><?php 
                echo $r->apmeta_value !== NULL ? $flag_note[$r->apmeta_value]['title'] : __('Flagged with custom message', 'ap');
                ?>
</strong>
					<span><?php 
                echo $r->apmeta_value !== NULL ? $flag_note[$r->apmeta_value]['description'] : $r->apmeta_param;
                ?>
</span>
				</div>
			</div>
		<?php 
            }
        } else {
            _e('No flag yet', 'ap');
        }
    }
/**
 * Return all subscribers of a question
 * @param  integer $question_id
 * @return array
 * @since 2.1
 */
function ap_get_subscribers($action_id, $type = false)
{
    global $wpdb;
    if ($type === 'category') {
        $subscribe_type = 'category';
    } elseif ($type === 'tag') {
        $subscribe_type = 'tag';
    } else {
        $subscribe_type = false;
    }
    $where = array('apmeta_type' => array('value' => 'subscriber', 'compare' => '=', 'relation' => 'AND'));
    if ($subscribe_type !== false) {
        $where['apmeta_param'] = array('value' => $subscribe_type, 'compare' => '=', 'relation' => 'AND');
    }
    $where['apmeta_actionid'] = array('value' => $action_id, 'compare' => '=', 'relation' => 'AND');
    return ap_get_all_meta(array('where' => $where, 'group' => array('apmeta_userid' => array('relation' => 'AND'))));
}
Beispiel #6
0
 *
 * @link http://anspress.io
 * @since 2.0.0-alpha2
 * @author Rahul Aryan <*****@*****.**>
 * @package AnsPress
 */
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}
$post_id = (int) $_GET['post_id'];
global $post;
// Assign your post details to $post (& not any other variable name!!!!)
$post = get_post($post_id);
setup_postdata($post);
$flags = ap_get_all_meta(array('where' => array('apmeta_type' => array('value' => 'flag', 'compare' => '=', 'relation' => 'AND'), 'apmeta_actionid' => array('value' => $post->ID, 'compare' => '=', 'relation' => 'AND'))));
?>
<div id="ap-admin-dashboard" class="wrap">
	<?php 
do_action('ap_before_admin_page_title');
?>
	<h2><?php 
_e('Post flag', 'ap');
?>
</h2>

	<div class="ap-admin-container">
		<div class="ap-flag-post-content">
			<h1><?php 
the_title();
?>
Beispiel #7
0
function ap_get_post_history($post_id)
{
    if (!$post_id) {
        return;
    }
    global $wpdb;
    $query = $wpdb->prepare('SELECT *, UNIX_TIMESTAMP(apmeta_date) as unix_date FROM ' . $wpdb->prefix . 'ap_meta where apmeta_type = "history" AND apmeta_actionid = %d', $post_id);
    return ap_get_all_meta(false, 20, $query);
}