Esempio n. 1
0
 function mycred_subtract($ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = 'mycred_default')
 {
     if ($ref == '' || $user_id == '' || $amount == '') {
         return false;
     }
     if ($amount > 0) {
         $amount = 0 - $amount;
     }
     return mycred_add($ref, $user_id, $amount, $entry, $ref_id, $data, $type);
 }
function wppa_add_credit_points($amount, $reason = '', $id = '', $value = '')
{
    global $user_ID;
    // Initialize
    if (!$user_ID) {
        get_currentuserinfo();
    }
    $bret = false;
    // Must be logged in
    if (!is_user_logged_in()) {
        return $bret;
    }
    // Cube points
    if (function_exists('cp_alterPoints')) {
        cp_alterPoints(cp_currentUser(), $amount);
        $bret = true;
    }
    // myCred
    if (function_exists('mycred_add')) {
        $entry = $reason . ($id ? ', ' . __('Photo id =', 'wppa') . ' ' . $id : '') . ($value ? ', ' . __('Value =', 'wppa') . ' ' . $value : '');
        $bret = mycred_add(str_replace(' ', '_', $reason), $user_ID, $amount, $entry, '', '', '');
        // $ref_id, $data, $type );
    }
    return $bret;
}
function wppa_add_credit_points($amount, $reason = '', $id = '', $value = '', $user = '')
{
    // Anything to do?
    if (!$amount) {
        return;
    }
    // Initialize
    $bret = false;
    if ($user) {
        $usr = get_user_by('login', $user);
    } else {
        $usr = wp_get_current_user();
    }
    if (!$usr) {
        wppa_log('err', 'Could not add points to user ' . $user);
        return false;
    }
    // Cube points
    if (function_exists('cp_alterPoints')) {
        cp_alterPoints($usr->ID, $amount);
        $bret = true;
    }
    // myCred
    if (function_exists('mycred_add')) {
        $entry = $reason . ($id ? ', ' . __('Photo id =', 'wp-photo-album-plus') . ' ' . $id : '') . ($value ? ', ' . __('Value =', 'wp-photo-album-plus') . ' ' . $value : '');
        $bret = mycred_add(str_replace(' ', '_', $reason), $usr->ID, $amount, $entry, '', '', '');
    }
    return $bret;
}
function nex_record_comment_activity($comment_id)
{
    $comment = get_comment($comment_id);
    $user_id = get_current_user_id();
    $post_id = $comment->comment_post_ID;
    $content = $comment->comment_content;
    if (get_post_type($post_id) == 'dwqa-question') {
        $post = get_post($post_id);
        $post_permalink = get_permalink($post_id);
        $activity_action = sprintf(__('%s commented on the question: %s', 'nex'), bp_core_get_userlink($user_id), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>');
        $hide_sitewide = $post->post_status == 'private' ? true : false;
    } else {
        $post = get_post($post_id);
        $question_id = get_post_meta($post_id, '_question', true);
        $question = get_post($question_id);
        $post_permalink = get_permalink($question_id);
        $activity_action = sprintf(__('%s commented on the answer at: %s', 'nex'), bp_core_get_userlink($user_id), '<a href="' . $post_permalink . '">' . $question->post_title . '</a>');
        $hide_sitewide = $question->post_status == 'private' ? true : false;
    }
    if (function_exists('bp_blogs_record_activity')) {
        bp_blogs_record_activity(array('user_id' => $user_id, 'action' => $activity_action, 'content' => $content, 'primary_link' => $post_permalink, 'type' => 'new_blog_comment', 'item_id' => 0, 'secondary_item_id' => $comment_id, 'recorded_time' => $comment->comment_date_gmt, 'hide_sitewide' => $hide_sitewide));
    }
    if (function_exists('mycred_add')) {
        mycred_add('new_comment', $user_id, '10', '%plural% for a Comment', $post_id, array('ref_type' => 'comment'));
    }
}
Esempio n. 5
0
 function mycred_subtract($ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = 'mycred_default')
 {
     if (empty($ref) || empty($user_id) || empty($amount)) {
         return false;
     }
     if ((int) $amount > 0) {
         $amount = 0 - $amount;
     }
     return mycred_add($ref, $user_id, $amount, $entry, $ref_id, $data, $type);
 }