当前位置: 首页>>代码示例>>PHP>>正文


PHP ap_add_meta函数代码示例

本文整理汇总了PHP中ap_add_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP ap_add_meta函数的具体用法?PHP ap_add_meta怎么用?PHP ap_add_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ap_add_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ap_insert_views

/**
 * Insert view data in ap_meta table and update post meta ANSPRESS_VIEW_META
 * @param  integer $data_id
 * @param  string $type
 * @return boolean
 */
function ap_insert_views($data_id, $type)
{
    if ($type == 'question') {
        $userid = get_current_user_id();
        // log in DB only if not viewed before and not anonymous
        if (!ap_is_already_viewed(get_current_user_id(), $data_id) && $userid != 0) {
            /**
             * FILTER: ap_log_ip_view
             * Toggle ip logging for view count
             * @var boolean
             */
            $log_ip = apply_filters('ap_log_ip_view', true);
            $ip = $log_ip ? $_SERVER['REMOTE_ADDR'] : '';
            ap_add_meta($userid, 'post_view', $data_id, $ip);
        }
        $view = ap_get_qa_views($data_id);
        $view = $view + 1;
        update_post_meta($data_id, ANSPRESS_VIEW_META, apply_filters('ap_insert_views', $view));
        do_action('after_insert_views', $data_id, $view);
        return true;
    } elseif ($type == 'profile') {
        $userid = get_current_user_id();
        // log in DB only if not viewed before and not anonymous
        if (!ap_is_already_viewed(get_current_user_id(), $data_id, 'profile_view') && $userid != 0) {
            ap_add_meta($userid, 'profile_view', $data_id, $_SERVER['REMOTE_ADDR']);
        }
        $view = ap_get_profile_views($data_id);
        $view = $view + 1;
        update_user_meta($data_id, '__profile_views', apply_filters('ap_insert_views', $view));
        do_action('after_insert_views', $data_id, $view);
        return true;
    }
    return false;
}
开发者ID:kennyma603,项目名称:anspress,代码行数:40,代码来源:view.php

示例2: ap_add_follower

/**
 * Add a follower
 * @param  integer  		$current_user_id   	Current user_id
 * @param  integer  		$user_to_follow 	user to follow
 * @return bollean|integer
 */
function ap_add_follower($current_user_id, $user_to_follow)
{
    $row = ap_add_meta($current_user_id, 'follower', $user_to_follow);
    if ($row !== false) {
        do_action('ap_added_follower', $user_to_follow, $current_user_id);
    }
    return $row;
}
开发者ID:CasteyDaSilva,项目名称:anspress,代码行数:14,代码来源:follow.php

示例3: ap_add_vote

/**
 * Add vote meta.
 *
 * @param int    $current_userid    User ID of user casting the vote
 * @param string $type              Type of vote, "vote_up" or "vote_down"
 * @param int    $actionid          Post ID
 * @param int    $receiveing_userid User ID of user receiving the vote. @since 2.3
 *
 * @return int|bool
 */
function ap_add_vote($current_userid, $type, $actionid, $receiving_userid)
{
    $row = ap_add_meta($current_userid, $type, $actionid, $receiving_userid);
    if ($row !== false) {
        do_action('ap_vote_casted', $current_userid, $type, $actionid, $receiving_userid);
    }
    return $row;
}
开发者ID:kennyma603,项目名称:anspress,代码行数:18,代码来源:vote.php

示例4: ap_add_parti

function ap_add_parti($post_id, $user_id, $action, $param = false)
{
    $rows = ap_add_meta($user_id, 'parti', $post_id, $action, $param);
    /* Update the meta only if successfully created */
    if ($rows !== false) {
        $current_parti = ap_get_parti($post_id, true);
        update_post_meta($post_id, ANSPRESS_PARTI_META, $current_parti);
    }
}
开发者ID:coollog,项目名称:theboola,代码行数:9,代码来源:anspress-participants.php

示例5: ap_insert_views

function ap_insert_views($data_id, $type)
{
    if ($type == 'question') {
        $userid = get_current_user_id();
        $row = ap_add_meta($userid, 'post_view', $data_id, $_SERVER['REMOTE_ADDR']);
        $view = ap_get_views_db($data_id);
        $view = $view + 1;
        update_post_meta($data_id, ANSPRESS_VIEW_META, apply_filters('ap_insert_views', $view));
        do_action('after_insert_views', $data_id, $view);
    }
}
开发者ID:coollog,项目名称:theboola,代码行数:11,代码来源:anspress-view.php

示例6: ap_add_subscriber

/**
 * Insert subscriber for question or term
 * @param  integer  		$user_id   	WP user ID
 * @param  integer  		$action_id 	Question ID or Term ID
 * @param  boolean|integer 	$sub_id    	Any sub ID
 * @param  boolean|integer 	$type      	Type of subscriber, empty string for question
 * @return bollean|integer
 */
function ap_add_subscriber($user_id, $action_id, $type = false, $sub_id = false)
{
    if ($type === 'category') {
        $subscribe_type = 'category';
    } elseif ($type === 'tag') {
        $subscribe_type = 'tag';
    } else {
        $subscribe_type = $type;
    }
    $row = ap_add_meta($user_id, 'subscriber', $action_id, $sub_id, $subscribe_type);
    if ($row !== false) {
        do_action('ap_added_subscriber', $action_id, $subscribe_type, $sub_id);
    }
    return $row;
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:23,代码来源:subscriber.php

示例7: ap_add_history

function ap_add_history($userid = false, $actionid, $parent_id, $param = NULL)
{
    if (!$userid) {
        $userid = get_current_user_id();
    }
    $opts = array('userid' => $userid, 'actionid' => $actionid, 'parent_id' => $parent_id, 'param' => $param);
    $opts = apply_filters('ap_add_history_parms', $opts);
    extract($opts);
    $last_history = ap_get_latest_history($parent_id);
    if ($last_history && $last_history['user_id'] == $userid && $last_history['type'] == $param && $last_history['parent_id'] == $parent_id && $last_history['action_id'] == $actionid) {
        $row = ap_update_meta(array('apmeta_userid' => $userid, 'apmeta_actionid' => $actionid, 'apmeta_value' => $parent_id, 'apmeta_param' => $param), array('apmeta_userid' => $last_history['user_id'], 'apmeta_actionid' => $last_history['action_id'], 'apmeta_value' => $last_history['parent_id'], 'apmeta_param' => $last_history['type']));
    } else {
        $row = ap_add_meta($userid, 'history', $actionid, $parent_id, $param);
    }
    do_action('ap_after_history_' . $parent_id, $userid, $actionid, $param);
    do_action('ap_after_inserting_history', $userid, $actionid, $parent_id, $param);
    return $row;
}
开发者ID:jessor,项目名称:anspress,代码行数:18,代码来源:anspress-history.php

示例8: ap_insert_notification

/**
 * Insert notification in ap_meta table
 *
 * @param  integer  		$current_user_id   	User id of user triggering this hook
 * @param  integer  		$affected_user_id  	User id of user who is being affected
 * @param  string 			$notification_type 	Type of notification
 * @param  boolean|array 	$args              	arguments for the notification
 * @return integer|boolean
 */
function ap_insert_notification($current_user_id, $affected_user_id, $notification_type, $args = false)
{
    //if effected user id and current user id are same or is anonymous then return
    if ($affected_user_id <= 0 || $affected_user_id == $current_user_id) {
        return;
    }
    //Convert array to query string
    if ($args === false) {
        $args = array();
    }
    switch ($notification_type) {
        case 'new_answer':
        case 'question_update':
        case 'answer_update':
            $post = get_post($args['post_id']);
            $args['permalink'] = get_permalink($post->ID);
            $args['post_title'] = ap_truncate_chars($post->post_title, 50);
            break;
        case 'comment_on_question':
        case 'comment_on_answer':
            $post = get_post($args['post_id']);
            $args['permalink'] = get_comment_link($args['comment_id']);
            $args['post_title'] = ap_truncate_chars($post->post_title, 50);
            break;
        case 'vote_up':
            $post = get_post($args['post_id']);
            $args['user_id'] = $current_user_id;
            $args['permalink'] = get_permalink($post->ID);
            $args['post_title'] = ap_truncate_chars($post->post_title, 50);
            break;
        case 'new_follower':
            $args['permalink'] = ap_user_link($current_user_id);
            $args['user_id'] = $current_user_id;
            break;
        case 'answer_selected':
            $post = get_post($args['post_id']);
            $args['permalink'] = get_permalink($post->ID);
            $args['post_title'] = ap_truncate_chars($post->post_title, 50);
            break;
        case 'received_reputation':
            $args['reputation'] = $args['reputation'];
            $args['permalink'] = ap_user_link($affected_user_id, 'reputation');
            break;
        default:
            $args = apply_filters('ap_notification_args', $args, func_get_args());
            break;
    }
    $args = urlencode(strip_tags(build_query($args)));
    $row = ap_add_meta($current_user_id, 'unread_notification', $affected_user_id, $args, $notification_type);
    if ($row !== false) {
        do_action('ap_insert_notification', $current_user_id, $affected_user_id, $notification_type, $args);
    }
    return $row;
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:63,代码来源:notification.php

示例9: ap_add_meta

                    if ($old_vote->vote == -1) {
                        ap_add_meta($userids[$a->contact_id], 'reputation', $answer_id, -3, 'vote_down', $old_vote->datetime);
                        ap_add_meta($userids[$old_vote->contact_id], 'reputation', $answer_id, -1, 'voted_down', $old_vote->datetime);
                    }
                }
            }
            // Anspress will fill it with current datetime otherwise.
            update_post_meta($answer_id, '_ap_updated', $a->datetime);
            update_post_meta($answer_id, '__ap_activity', array('type' => 'new_answer', 'user_id' => $userids[$a->contact_id], 'date' => $a->datetime));
            ap_add_meta($userids[$a->contact_id], 'reputation', $answer_id, 1, 'answer', $a->datetime);
            if ($a->solution) {
                // Select answer for question too.
                update_post_meta($question_id, '_ap_selected', $answer_id);
                // Add reputation log for best answer.
                ap_add_meta($userids[$a->contact_id], 'reputation', $answer_id, 100, 'best_answer', $a->datetime);
                ap_add_meta($userids[$q->contact_id], 'reputation', $answer_id, 15, 'selecting_answer', $a->datetime);
            }
        }
    }
    // Anspress will fill it with current datetime otherwise.
    update_post_meta($question_id, '_ap_updated', $q->create_datetime);
    update_post_meta($question_id, '__ap_activity', array('type' => 'new_question', 'user_id' => $userids[$q->contact_id], 'date' => $q->create_datetime));
    $questions_counter++;
    p('Added question ' . $questions_counter . '/' . count($questions) . ' with ' . count($answers[$q->id]) . ' answers');
}
// Fill users counters.
$users = get_users();
$users_counter = 0;
foreach ($users as $user) {
    $total_questions = $wpdb->get_var("SELECT COUNT(*) FROM wp_posts WHERE post_author={$user->ID} AND post_type='question'");
    update_user_meta($user->ID, '__total_questions', $total_questions);
开发者ID:dima-stefantsov,项目名称:__heap,代码行数:31,代码来源:_dev.php

示例10: ap_reputation_log

/**
 * @param string $type
 */
function ap_reputation_log($type, $uid, $reputation, $action_id, $current_user_id)
{
    $userinfo = get_userdata($uid);
    if ($userinfo->user_login == '') {
        return false;
    }
    if ($reputation == 0) {
        return false;
    }
    $row = ap_add_meta($uid, 'reputation', $action_id, $reputation, $type);
    if ($row !== false) {
        do_action('ap_added_reputation', $uid, $action_id, $reputation, $type, $current_user_id);
    }
    return $row;
}
开发者ID:Byrlyne,项目名称:anspress,代码行数:18,代码来源:reputation.php

示例11: ap_insert_comment_flag

/**
 * Insert flag vote for comment.
 *
 * @param int   $user_id
 * @param int   $action_id
 * @param mixed $value
 * @param mixed $param
 *
 * @return integer
 */
function ap_insert_comment_flag($user_id, $action_id, $value = null, $param = null)
{
    return ap_add_meta($user_id, 'comment_flag', $action_id, $value, $param);
}
开发者ID:Byrlyne,项目名称:anspress,代码行数:14,代码来源:flag.php

示例12: ap_add_recipients

function ap_add_recipients($recipient, $sender, $conversation_id)
{
    $recipient = sanitize_comma_delimited($recipient);
    $sender = filter_var($sender, FILTER_SANITIZE_NUMBER_INT);
    $users = array_unique(explode(',', str_replace(' ', '', $recipient . ',' . $sender)));
    if (!empty($users)) {
        foreach ($users as $user) {
            ap_add_meta($user, 'recipient', $conversation_id);
        }
    }
}
开发者ID:jessor,项目名称:anspress,代码行数:11,代码来源:anspress-messages.php

示例13: ap_add_flag

/**
 * @param integer $actionid
 */
function ap_add_flag($userid, $actionid, $value = NULL, $param = NULL)
{
    return ap_add_meta($userid, 'flag', $actionid, $value, $param);
}
开发者ID:haythameyd,项目名称:powrly,代码行数:7,代码来源:vote.php

示例14: ap_point_log

function ap_point_log($type, $uid, $points, $data)
{
    $userinfo = get_userdata($uid);
    if ($userinfo->user_login == '') {
        return false;
    }
    if ($points == 0 && $type != 'reset') {
        return false;
    }
    return ap_add_meta($uid, 'point', $data, $points, $type);
}
开发者ID:jessor,项目名称:anspress,代码行数:11,代码来源:anspress-points.php

示例15: ap_set_badge

function ap_set_badge($user_id, $badge_id, $badge_type, $action_id = 0)
{
    return ap_add_meta($user_id, 'badge', $action_id, $badge_id, $badge_type);
}
开发者ID:coollog,项目名称:theboola,代码行数:4,代码来源:anspress-badges.php


注:本文中的ap_add_meta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。