has_cap('publish_posts')) { // Add the editor_overview_widget widget, if enabled // if ($assignment_desk->get_plugin_option('editor_overview_widget_enabled')) { wp_add_dashboard_widget('ad_editor_overview', 'Assignment Desk Overview', array(&$this, 'overview_widget')); // } } wp_add_dashboard_widget('ad_assignments', 'Assignments', array(&$this, 'assignments_widget')); } /** * Return the number of objects associated with this status * $status is a term */ function count_pitches($status){ global $assignment_desk, $wpdb; $count = $wpdb->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 overview_widget() { global $assignment_desk, $current_user, $wpdb; $new_pitches_count = $this->count_pitches('New'); $approved_post_count = $this->count_pitches('Approved'); if($_REQUEST['ad-dashboard-editor-messages']){ foreach($_REQUEST['ad-dashboard-assignment-messages'] as $messages){ echo "
$message
"; } } ?>
coauthors_plus_exists()){ // @todo - Figure out how to link to the unassigned posts. $unassigned_url = "#"; echo ""; echo ""; // @todo - Figure out how to link to inprogress posts. $inprogress_url = ""; echo ""; echo ""; } $this_month_url = admin_url() . '/edit.php?post_status=publish&monthnum=' . date('M'); $q = new WP_Query( array('post_status' => 'publish', 'monthnum' => date('M'))); echo ""; echo ""; ?>
" . count(get_unassigned_posts()) . "" . _('Unassigned', 'assignment-desk') . "
" . count(get_inprogress_posts()) . "" . _('In Progress', 'assignment-desk') . "
$q->found_posts" . _('Published this month', 'assignment-desk') . "
$message"; } } // Find all of the posts this user participates in. $participant_posts = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_ad_participant_{$current_user->ID}' ORDER BY post_id"); if ( ! $participant_posts ){ $participant_posts = array(); } $roles = $assignment_desk->custom_taxonomies->get_user_roles(); foreach($participant_posts as $post ){ foreach($roles as $user_role){ // Get all of the roles this user has for this post $participant_record = get_post_meta($post->post_id, "_ad_participant_role_$user_role->term_id", true); if($participant_record) { foreach ($participant_record as $user_id => $status ){ if( $user_id == $current_user->ID && $status == 'pending' ){ $pending_posts[] = array($post->post_id, $user_role); } } } } } $count_pending = count($pending_posts); ?>

pending assignment.

{$post->post_title} | {$pending[1]->name}

"; echo "

Accept "; echo "Decline

"; ?>
» Go to Assignment Desk landing page.
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); } } } ?>