get_var($wpdb->prepare("SELECT count FROM $wpdb->term_taxonomy WHERE taxonomy = '%s' AND term_id = %d", $assignment_desk->custom_taxonomies->assignment_status_label, $status->term_id)); $count = $count ? $count : 0; return $count; } function count_user_posts_by_assignment_status($status){ global $current_user, $wpdb, $assignment_desk; get_currentuserinfo(); $counts = array(); if ( ! $assignment_desk->coauthors_plus_exists() ){ return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id) WHERE $wpdb->posts.post_author = '$current_user->ID' AND $wpdb->posts.post_status != 'publish' AND $wpdb->posts.post_status != 'inherit' AND $wpdb->posts.post_status != 'trash' AND $wpdb->posts.post_status != 'auto-draft' AND $wpdb->term_taxonomy.taxonomy = 'assignment_status' AND $wpdb->term_taxonomy.term_id = $status->term_id "); } else { return 0; } } function widget() { global $assignment_desk, $current_user, $wpdb; get_currentuserinfo(); $assignment_statuses = $assignment_desk->custom_taxonomies->get_assignment_statuses(); if($_REQUEST['ad-dashboard-editor-messages']){ foreach($_REQUEST['ad-dashboard-assignment-messages'] as $messages){ echo "
"; } } ?>By assignment status
| " . $count . " | "; echo "$assignment_status->name |
| $q->found_posts | "; echo "" . _('Published this month', 'assignment-desk') . " |
| " . $count . " | "; echo "$assignment_status->name |
$count_pending pending assignment"; echo ($count_pending != 1)? 's': ''; echo "
"; echo ""; } } function respond_to_story_invite(){ global $current_user, $assignment_desk, $coauthors_plus, $user_ID; $response = $_GET['participant_response']; $post_id = (int)$_GET['post_id']; $role_id = (int)$_GET['role_id']; get_currentuserinfo(); if (!$current_user->ID || $user_ID != $post_id) { $_REQUEST['ad-dashboard-assignment-messages'][] = _('Unauthorized assignment response. This is fishy.'); } $_REQUEST['ad-dashboard-assignment-messages'] = array(); if ($response && $post_id && $role_id){ $participant_record = get_post_meta($post_id, "_ad_participant_role_$role_id", true); // This will not evaluate to true unless the user is currently pending for this role on this post. if($participant_record && $participant_record[$current_user->ID] == 'pending'){ $participant_record[$current_user->ID] = $response; if($response == 'accepted'){ $_REQUEST['ad-dashboard-assignment-messages'][] = _('Thank you.'); // Add as a co-author if($assignment_desk->coauthors_plus_exists()){ $coauthors_plus->add_coauthors($post_id, array($current_user->user_login), true); } $user_participant = get_post_meta($post_id, "_ad_participant_$current_user->ID", true); if(!$user_participant){ $user_participant = array(); } $user_participant[] = $role_id; update_post_meta($post_id, "_ad_participant_$current_user->ID", $user_participant); } else if($response == 'declined'){ $_REQUEST['ad-dashboard-assignment-messages'][] = _('Sorry!'); } } update_post_meta($post_id, "_ad_participant_role_$role_id", $participant_record); } } } ?>