/** * Add the "My Account" menu and all submenus. * * @since BuddyPress (r4151) */ function bp_members_admin_bar_my_account_menu() { global $bp, $wp_admin_bar; // Bail if this is an ajax request if (defined('DOING_AJAX')) { return; } // Logged in user if (is_user_logged_in()) { // User avatar $avatar = bp_core_fetch_avatar(array('item_id' => $bp->loggedin_user->id, 'email' => $bp->loggedin_user->userdata->user_email, 'width' => 16, 'height' => 16)); // Unique ID for the 'My Account' menu $bp->my_account_menu_id = !empty($avatar) ? 'my-account-with-avatar' : 'my-account'; // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => $bp->my_account_menu_id, 'title' => $avatar . bp_get_loggedin_user_fullname(), 'href' => $bp->loggedin_user->domain)); // Show login and sign-up links } elseif (!empty($wp_admin_bar)) { add_filter('show_admin_bar', '__return_true'); // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => 'bp-login', 'title' => __('Log in', 'buddypress'), 'href' => wp_login_url())); // Sign up if (bp_get_signup_allowed()) { $wp_admin_bar->add_menu(array('id' => 'bp-register', 'title' => __('Register', 'buddypress'), 'href' => bp_get_signup_page())); } } }
/** * Render user avatar menu item * * @param string $item_output * @param array $item * @param integer $depth * @param object $args * @return string */ function kleo_menu_user_avatar($item_output, $item, $depth, $args) { $output = ''; if (is_user_logged_in()) { $url = bp_loggedin_user_domain(); $attr_title = strip_tags($item->attr_title); $output .= '<a title="' . bp_get_loggedin_user_fullname() . '" class="kleo-bp-user-avatar' . ($args->has_children && in_array($depth, array(0, 1)) ? ' js-activated' : '') . '" href="' . $url . '" title="' . $attr_title . '">' . '<img src="' . bp_get_loggedin_user_avatar(array('width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">' . ($item->attr_title != '' ? ' ' . $item->attr_title : ''); $output .= $args->has_children && in_array($depth, array(0, 1)) ? ' <span class="caret"></span></a>' : '</a>'; return $output; } elseif ($args->has_children && in_array($depth, array(0, 1))) { return $item_output; } else { return ''; } }
/** * Add the "My Account" menu and all submenus. * * @since BuddyPress (r4151) * @todo Deprecate WP 3.2 admin bar compatibility when we drop 3.2 support */ function bp_members_admin_bar_my_account_menu() { global $bp, $wp_admin_bar, $wp_version; // Bail if this is an ajax request if (defined('DOING_AJAX')) { return; } // Logged in user if (is_user_logged_in()) { // User avatar $avatar = bp_core_fetch_avatar(array('item_id' => bp_loggedin_user_id(), 'email' => $bp->loggedin_user->userdata->user_email, 'width' => 16, 'height' => 16)); // Some admin bar setup in WP 3.2 differs from WP 3.3+. // Backward-compatibility will be deprecated at some point. if (version_compare((double) $wp_version, '3.3', '>=')) { // Stored in the global so we can add menus easily later on $bp->my_account_menu_id = 'my-account-buddypress'; $title = bp_get_loggedin_user_fullname() . $avatar; $class = 'opposite'; if (!empty($avatar)) { $class .= ' with-avatar'; } $meta = array('class' => $class); } else { $bp->my_account_menu_id = !empty($avatar) ? 'my-account-with-avatar' : 'my-account'; $title = $avatar . bp_get_loggedin_user_fullname(); $meta = array(); } // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => $bp->my_account_menu_id, 'title' => $title, 'href' => $bp->loggedin_user->domain, 'meta' => $meta)); // Show login and sign-up links } elseif (!empty($wp_admin_bar)) { add_filter('show_admin_bar', '__return_true'); // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => 'bp-login', 'title' => __('Log in', 'buddypress'), 'href' => wp_login_url())); // Sign up if (bp_get_signup_allowed()) { $wp_admin_bar->add_menu(array('id' => 'bp-register', 'title' => __('Register', 'buddypress'), 'href' => bp_get_signup_page())); } } }
do_action('bp_user_deposits_options_nav'); ?> </ul> </div> </div><!-- #item-nav --> <div id="item-body" role="main"> <?php do_action('bp_before_user_deposits_body'); ?> <?php $displayed_user_fullname = bp_get_displayed_user_fullname(); if (!empty($displayed_user_fullname) && $displayed_user_fullname == bp_get_loggedin_user_fullname() && is_user_logged_in()) { echo '<a href="/deposits/item/new/" class="bp-deposits-deposit button" title="Deposit an Item">Deposit an Item</a><p />'; } ?> <div class="item-list-tabs" id="subnav"> <ul> <li class="current selected" id="deposits-personal"><a href="#"></a></li> <li id="deposits-order-select" class="last filter"> <label for="deposits-order-by"><?php _e('Order By:', 'humcore_domain'); ?> </label> <select id="deposits-order-by">
?> <div id="mpp-whats-new-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?> "> <?php bp_loggedin_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height()); ?> </a> </div> <p class="activity-greeting"> <?php printf(__("Want to say Something, %s?", 'mediapress'), bp_get_user_firstname(bp_get_loggedin_user_fullname())); ?> </p> <div id="mpp-whats-new-content"> <div id="mpp-whats-new-textarea"> <textarea name="mpp-whats-new" id="mpp-whats-new" cols="50" rows="3"><?php if (isset($_GET['r'])) { ?> @<?php echo esc_textarea($_GET['r']); ?> <?php } ?>
<div id="whats-new-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?> "> <?php bp_loggedin_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height()); ?> </a> </div> <p class="activity-greeting"><?php if (bp_is_group()) { printf(__("What's new in %s, %s?", 'wonderflux'), bp_get_group_name(), bp_get_user_firstname(bp_get_loggedin_user_fullname())); } else { printf(__("What's new, %s?", 'wonderflux'), bp_get_user_firstname(bp_get_loggedin_user_fullname())); } ?> </p> <div id="whats-new-content"> <div id="whats-new-textarea"> <label for="whats-new" class="bp-screen-reader-text"><?php _e('Post what\'s new', 'wonderflux'); ?> </label> <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if (bp_is_group()) { ?> data-suggestions-group-id="<?php
public function save_messages() { $new_message = new BP_Chat_Message(); $new_message->message = esc_html($_POST['message']); $new_message->channel_id = absint($_POST['channel_id']); $new_message->sender_id = get_current_user_id(); $new_message->save(); // open this channel, we don't care anymore who are subscribed to this channel bpchat_update_all_channel_user($new_message->channel_id, 'open'); //status of the channel //update senders last activity time bpchat_update_last_active($new_message->sender_id); //update last active time for sender echo json_encode(array('name' => bp_get_loggedin_user_fullname(), 'id' => $new_message->id)); exit(0); }
/** * Returns a follow / unfollow button for a given user depending on the follower status. * * Checks to see if the follower is already following the leader. If is following, returns * "Stop following" button; if not following, returns "Follow" button. * * @param array $args { * Array of arguments. * @type int $leader_id The user ID of the person we want to follow. * @type int $follower_id The user ID initiating the follow request. * @type string $link_text The anchor text for the link. * @type string $link_title The title attribute for the link. * @type string $wrapper_class CSS class for the wrapper container. * @type string $link_class CSS class for the link. * @type string $wrapper The element for the wrapper container. Defaults to 'div'. * } * @return mixed String of the button on success. Boolean false on failure. * @uses bp_get_button() Renders a button using the BP Button API * @author r-a-y * @since 1.1 */ function bp_follow_get_add_follow_button($args = '') { global $bp, $members_template; $r = wp_parse_args($args, array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => '', 'wrapper' => 'div')); if (!$r['leader_id'] || !$r['follower_id']) { return false; } // if we're checking during a members loop, then follow status is already // queried via bp_follow_inject_member_follow_status() if (!empty($members_template->in_the_loop) && $r['follower_id'] == bp_loggedin_user_id() && $r['leader_id'] == bp_get_member_user_id()) { $is_following = $members_template->member->is_following; // else we manually query the follow status } else { $is_following = bp_follow_is_following(array('leader_id' => $r['leader_id'], 'follower_id' => $r['follower_id'])); } // if the logged-in user is the leader, use already-queried variables if (bp_loggedin_user_id() && $r['leader_id'] == bp_loggedin_user_id()) { $leader_domain = bp_loggedin_user_domain(); $leader_fullname = bp_get_loggedin_user_fullname(); // else we do a lookup for the user domain and display name of the leader } else { $leader_domain = bp_core_get_user_domain($r['leader_id']); $leader_fullname = bp_core_get_user_displayname($r['leader_id']); } // setup some variables if ($is_following) { $id = 'following'; $action = 'stop'; $class = 'unfollow'; $link_text = sprintf(_x('Unfollow', 'Button', 'bp-follow'), apply_filters('bp_follow_leader_name', bp_get_user_firstname($leader_fullname), $r['leader_id'])); if (empty($r['link_text'])) { $r['link_text'] = $link_text; } } else { $id = 'not-following'; $action = 'start'; $class = 'follow'; $link_text = sprintf(_x('Follow', 'Button', 'bp-follow'), apply_filters('bp_follow_leader_name', bp_get_user_firstname($leader_fullname), $r['leader_id'])); if (empty($r['link_text'])) { $r['link_text'] = $link_text; } } $wrapper_class = 'follow-button ' . $id; if (!empty($r['wrapper_class'])) { $wrapper_class .= ' ' . esc_attr($r['wrapper_class']); } $link_class = $class; if (!empty($r['link_class'])) { $link_class .= ' ' . esc_attr($r['link_class']); } // make sure we can view the button if a user is on their own page $block_self = empty($members_template->member) ? true : false; // if we're using AJAX and a user is on their own profile, we need to set // block_self to false so the button shows up if (bp_follow_is_doing_ajax() && bp_is_my_profile()) { $block_self = false; } // setup the button arguments $button = array('id' => $id, 'component' => 'follow', 'must_be_logged_in' => true, 'block_self' => $block_self, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'follow-button-' . (int) $r['leader_id'], 'link_href' => wp_nonce_url($leader_domain . $bp->follow->followers->slug . '/' . $action . '/', $action . '_following'), 'link_text' => esc_attr($r['link_text']), 'link_title' => esc_attr($r['link_title']), 'link_id' => $class . '-' . (int) $r['leader_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false); // Filter and return the HTML button return bp_get_button(apply_filters('bp_follow_get_add_follow_button', $button, $r['leader_id'], $r['follower_id'])); }
<div id="user-left" name="user-left" class="sidebar sidebar-left"> <div id="user-info" class="row section hidden-xs hidden-sm"> <div class="col-xs-12 col-sm-12 col-lg-12"> <a href="<?php echo bp_loggedin_user_domain(); ?> "> <?php bp_loggedin_user_avatar('width=150&height=150'); ?> </a> </div> <div class="col-xs-12 col-sm-12 col-lg-12" style="text-align: center"> <h4 style="font-size: 1.4em"><?php echo bp_get_loggedin_user_fullname(); ?> </h4> <span class="username">@<?php echo bp_get_loggedin_user_username(); ?> </span> </div> </div> <div class="row"> <div class="col-lg-12"> <nav class="nav" role="navigation"> <div class="row"> <div class="navbar-header panel hidden-md hidden-lg" style="background-color: #fff; text-align: center"> <h4 class="no-margin">
function kleo_bp_replace_placeholders($output) { $initial_output = $output; if (strpos($output, '##profile_link##') !== false) { if (!is_user_logged_in()) { return ''; } if (function_exists('bp_is_active')) { $logged_in_link = bp_loggedin_user_domain('/'); $output = str_replace('##profile_link##', $logged_in_link, $output); } elseif (class_exists('bbPress')) { //$logged_in_link = bb_get_profile_link(); $logged_in_link = bbp_get_user_profile_url(bbp_get_current_user_id()); $output = str_replace('##profile_link##', $logged_in_link, $output); } } if (strpos($output, '##member_name##') !== false) { if (!is_user_logged_in()) { return ''; } if (function_exists('bp_is_active')) { $logged_in_username = bp_get_loggedin_user_fullname(); $output = str_replace('##member_name##', $logged_in_username, $output); } elseif (class_exists('bbPress')) { $logged_in_username = bbp_get_user_nicename(bbp_get_current_user_id()); $output = str_replace('##member_name##', $logged_in_username, $output); } } $output = apply_filters('kleo_bp_replace_placeholders', $output, $initial_output); return $output; }
function bp_loggedin_user_fullname() { echo bp_get_loggedin_user_fullname(); }
/** * Returns a compliment button for a given user. * * @since 0.0.1 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. * @global object $members_template Members template object. * @param array|string $args { * Attributes of the $args. * * @type int $receiver_id Compliment receiver ID. * @type int $sender_id Compliment sender ID. * @type string $link_text Link text. * @type string $link_title Link title. * @type string $wrapper_class Link wrapper class. * @type string $link_class Link class. Default "compliments-popup". * @type string $wrapper Link wrapper. Default "div". * * } * @return string Button HTML. */ function bp_compliments_get_add_compliment_button($args = '') { global $bp, $members_template; $r = wp_parse_args($args, array('receiver_id' => bp_displayed_user_id(), 'sender_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => 'compliments-popup', 'wrapper' => 'div')); if (!$r['receiver_id'] || !$r['sender_id']) { return false; } // if the logged-in user is the receiver, use already-queried variables if (bp_loggedin_user_id() && $r['receiver_id'] == bp_loggedin_user_id()) { $receiver_domain = bp_loggedin_user_domain(); $receiver_fullname = bp_get_loggedin_user_fullname(); // else we do a lookup for the user domain and display name of the receiver } else { $receiver_domain = bp_core_get_user_domain($r['receiver_id']); $receiver_fullname = bp_core_get_user_displayname($r['receiver_id']); } // setup some variables $id = 'compliments'; $action = 'start'; $class = 'compliments'; /** * Filters the compliment receiver name. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param string $receiver_fullname Receiver full name. * @param int $r['receiver_id'] Receiver ID. */ $link_text = sprintf(sprintf(__('Send %s', 'bp-compliments'), BP_COMP_SINGULAR_NAME), apply_filters('bp_compliments_receiver_name', bp_get_user_firstname($receiver_fullname), $r['receiver_id'])); if (empty($r['link_text'])) { $r['link_text'] = $link_text; } $wrapper_class = 'compliments-button ' . $id; if (!empty($r['wrapper_class'])) { $wrapper_class .= ' ' . esc_attr($r['wrapper_class']); } $link_class = $class; if (!empty($r['link_class'])) { $link_class .= ' ' . esc_attr($r['link_class']); } // make sure we can view the button if a user is on their own page $block_self = empty($members_template->member) ? true : false; // if we're using AJAX and a user is on their own profile, we need to set // block_self to false so the button shows up if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && bp_is_my_profile()) { $block_self = false; } // setup the button arguments $button = array('id' => $id, 'component' => 'compliments', 'must_be_logged_in' => true, 'block_self' => $block_self, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'compliments-button-' . (int) $r['receiver_id'], 'link_href' => wp_nonce_url($receiver_domain . $bp->compliments->compliments->slug . '/' . $action . '/', $action . '_compliments'), 'link_text' => esc_attr($r['link_text']), 'link_title' => esc_attr($r['link_title']), 'link_id' => $class . '-' . (int) $r['receiver_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false); // Filter and return the HTML button /** * Filters the compliment button. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param string $button Button HTML. * @param int $r['receiver_id'] Receiver ID. * @param int $r['sender_id'] Sender ID. */ return bp_get_button(apply_filters('bp_compliments_get_add_compliment_button', $button, $r['receiver_id'], $r['sender_id'])); }
<div id="whats-new-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?> "> <?php bp_loggedin_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height()); ?> </a> </div> <p class="activity-greeting"><?php if (bp_is_group()) { printf(__("What's new in %s, %s?", 'buddypress'), bp_get_group_name(), bp_get_user_firstname(bp_get_loggedin_user_fullname())); } else { printf(__("What's new, %s?", 'buddypress'), bp_get_user_firstname(bp_get_loggedin_user_fullname())); } ?> </p> <div id="whats-new-content"> <div id="whats-new-textarea"> <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if (bp_is_group()) { ?> data-suggestions-group-id="<?php echo esc_attr((int) bp_get_current_group_id()); ?> " <?php }
?> <div id="whats-new-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?> "> <?php bp_loggedin_user_avatar('type=full&width=' . bp_core_avatar_full_width() . '&height=' . bp_core_avatar_full_height()); ?> </a> </div> <p class="activity-greeting"> <?php printf(__("Welcome back, %s", 'buddypress'), bp_get_user_firstname(bp_get_loggedin_user_fullname())); ?> </p> <?php wp_nonce_field('post_update', '_wpnonce_post_update'); ?> <?php /** * Fires after the activity post form. * * @since 1.2.0 */ do_action('bp_after_activity_post_form'); ?>
/** * Gets the id of the taxonomy term associated with the item * * @since 1.0-beta * * @return str $view The current item type */ function setup_terms() { global $bp; $this->term_id = bp_docs_get_item_term_id($this->item_id, $this->item_type, $this->item_name); if (bp_is_user()) { // If this is a User Doc, then the user_term_id is the same as the term_id $this->user_term_id = $this->term_id; } else { $this->user_term_id = bp_docs_get_item_term_id($this->item_id, 'user', bp_get_loggedin_user_fullname()); } }
<div id="message-thread"> <?php do_action( 'bp_before_message_thread_content' ) ?> <?php if ( bp_thread_has_messages() ) : ?> <h3 id="message-subject"><?php bp_the_thread_subject() ?></h3> <p id="message-recipients"> <span class="highlight"> <?php printf( __('Sent between %s and %s', 'buddypress'), bp_get_the_thread_recipients(), '<a href="' . bp_get_loggedin_user_link() . '" title="' . bp_get_loggedin_user_fullname() . '">' . bp_get_loggedin_user_fullname() . '</a>' ) ?> </span> </p> <?php do_action( 'bp_before_message_thread_list' ) ?> <?php while ( bp_thread_messages() ) : bp_thread_the_message(); ?> <div class="message-box"> <div class="message-metadata"> <?php do_action( 'bp_before_message_meta' ) ?> <?php bp_the_thread_message_sender_avatar( 'type=thumb&width=30&height=30' ) ?> <strong><a href="<?php bp_the_thread_message_sender_link() ?>" title="<?php bp_the_thread_message_sender_name() ?>"><?php bp_the_thread_message_sender_name() ?></a> <span class="activity"><?php bp_the_thread_message_time_since() ?></span></strong> <?php do_action( 'bp_after_message_meta' ) ?> </div><!-- .message-metadata -->
function bp_record_vote_activity($site_id, $blog_id, $post_id, $vote) { if (!bp_loggedin_user_id()) { return false; } $username = bp_get_loggedin_user_fullname(); $username = $username ? $username : bp_get_loggedin_user_username(); if (!$username) { return false; } $user_link = bp_get_loggedin_user_link(); $link = get_blog_permalink($blog_id, $post_id); $post = get_blog_post($blog_id, $post_id); $title = $post->post_title; $args = array('action' => sprintf(__('<a href="%s">%s</a> voted on <a href="%s">%s</a>', 'wdpv'), $user_link, $username, $link, $title), 'component' => 'wdpv_post_vote', 'type' => 'wdpv_post_vote', 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'hide_sitewide' => $this->data->get_option('bp_publish_activity_local')); $res = bp_activity_add($args); return $res; }
function rendez_vous_single_get_the_dates($view = 'single') { // First add organizer $all_attendees = (array) rendez_vous()->item->attendees; if (!in_array(rendez_vous()->item->organizer, $all_attendees)) { $all_attendees = array_merge(array(rendez_vous()->item->organizer), $all_attendees); } // Then remove current_user as we want him to be in last position if ('edit' != $view) { if (!rendez_vous_single_date_set() && bp_loggedin_user_id()) { $attendees = array_diff($all_attendees, array(bp_loggedin_user_id())); } else { $attendees = $all_attendees; } } else { $attendees = $all_attendees; } $days = rendez_vous()->item->days; if (empty($days)) { return false; } ksort($days); $header = array_keys($days); $output = '<table id="rendez-vous-attendees-prefs">'; $output .= '<thead>'; $output .= '<tr><th> </th>'; foreach ($header as $date) { $output .= '<th class="rendez-vous-date">'; if (is_long($date)) { $output .= '<div class="date">' . date_i18n(get_option('date_format'), $date) . '</div>'; $output .= '<div class="time">' . date_i18n(get_option('time_format'), $date) . '</div>'; } else { $output .= '<div class="none">' . esc_html__('None', 'rendez-vous') . '</div>'; } $output .= '</th>'; } $output .= '</tr></thead>'; $output .= '<tbody>'; //rows foreach ($attendees as $attendee) { $user_link = trailingslashit(bp_core_get_user_domain($attendee)); $user_name = bp_core_get_user_displayname($attendee); $tr_class = $attendee == bp_loggedin_user_id() ? 'edited' : false; $output .= '<tr class="' . $tr_class . '"><td>'; if ('edit' == $view) { // Make sure the organizer is not removed from attendees if ($attendee == rendez_vous()->item->organizer) { $output .= '<input type="hidden" name="_rendez_vous_edit[attendees][]" value="' . $attendee . '"/>'; } else { $output .= '<input type="checkbox" name="_rendez_vous_edit[attendees][]" value="' . $attendee . '" checked="true"/> '; } } $output .= '<a href="' . esc_url($user_link) . '" title="' . esc_attr($user_name) . '">' . bp_core_fetch_avatar(array('object' => 'user', 'item_id' => $attendee, 'type' => 'thumb', 'class' => 'mini', 'width' => 20, 'height' => 20)) . ' ' . $user_name . '</a></td>'; foreach ($header as $date) { $class = in_array($attendee, $days[$date]) ? 'active' : 'inactive'; if ('none' == $date) { $class .= ' impossible'; } $output .= '<td class="' . $class . '"> </td>'; } $output .= '</tr>'; } $ending_rows = array('total' => '<td>' . esc_html__('Total', 'rendez-vous') . '</td>'); if ('edit' != $view) { $ending_rows['editable_row'] = '<td><a href="' . esc_url(bp_loggedin_user_domain()) . '" title="' . esc_attr(bp_get_loggedin_user_username()) . '">' . bp_core_fetch_avatar(array('object' => 'user', 'item_id' => bp_loggedin_user_id(), 'type' => 'thumb', 'class' => 'mini', 'width' => 20, 'height' => 20)) . ' ' . esc_html(bp_get_loggedin_user_fullname()) . '</a></td>'; // Set definitive date } else { $ending_rows['editable_row'] = '<td id="rendez-vous-set">' . esc_html__('Set date', 'rendez-vous') . '</td>'; } foreach ($header as $date) { $checked = checked(true, in_array(bp_loggedin_user_id(), $days[$date]), false); $ending_rows['total'] .= '<td><strong>' . count($days[$date]) . '</strong></td>'; // Let the user set his prefs if ('edit' != $view) { $class = false; if ('none' == $date) { $class = ' class="none-resets-cb"'; } $ending_rows['editable_row'] .= '<td><input type="checkbox" name="_rendez_vous_prefs[days][' . bp_loggedin_user_id() . '][]" value="' . $date . '" ' . $checked . $class . '/></td>'; // Let the organizer choose the definitive date } else { $def_date = !empty(rendez_vous()->item->def_date) ? rendez_vous()->item->def_date : false; if ('none' != $date) { $ending_rows['editable_row'] .= '<td><input type="radio" name="_rendez_vous_edit[def_date]" value="' . $date . '" ' . checked($date, $def_date, false) . '/></td>'; } else { $ending_rows['editable_row'] .= '<td></td>'; } } } if ('edit' != $view) { // Date is set, changes cannot be done anymore if (!rendez_vous_single_date_set()) { if ('private' == rendez_vous()->item->privacy) { // If private, display the row only if current user is an attendee or the author if (bp_loggedin_user_id() == rendez_vous()->item->organizer || in_array(bp_loggedin_user_id(), $all_attendees)) { $output .= '<tr class="edited">' . $ending_rows['editable_row'] . '</tr>'; } } else { if (current_user_can('subscribe_rendez_vous')) { $output .= '<tr class="edited">' . $ending_rows['editable_row'] . '</tr>'; } } // Display totals $output .= '<tr>' . $ending_rows['total'] . '</tr>'; } } else { // Display totals $output .= '<tr>' . $ending_rows['total'] . '</tr>'; // Display the radio to set the date if ('draft' != rendez_vous()->item->status) { $output .= '<tr>' . $ending_rows['editable_row'] . '</tr>'; } } $output .= '</tbody>'; $output .= '</table>'; if (!is_user_logged_in() && 'publish' == rendez_vous()->item->status && !rendez_vous_single_date_set()) { $output .= '<div id="message" class="info"><p>' . __('If you want to set your preferences about this rendez-vous, please log in.', 'rendez-vous') . '</p></div>'; } return apply_filters('rendez_vous_single_get_the_dates', $output, $view); }
/** * Prepare the metadata sent to Fedora and Solr from $_POST input. * * @param array $nextPids Array of fedora pids. * @return array metadata content */ function prepare_metadata($nextPids) { global $fedora_api; /** * Prepare the metadata to be sent to Fedora and Solr. */ $metadata = array(); $metadata['id'] = $nextPids[0]; $metadata['pid'] = $nextPids[0]; $metadata['creator'] = 'HumCORE'; $metadata['title'] = wp_strip_all_tags(stripslashes($_POST['deposit-title-unchanged'])); $metadata['title_unchanged'] = wp_kses(stripslashes($_POST['deposit-title-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); $metadata['abstract'] = wp_strip_all_tags(stripslashes($_POST['deposit-abstract-unchanged'])); $metadata['abstract_unchanged'] = wp_kses(stripslashes($_POST['deposit-abstract-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); $metadata['genre'] = sanitize_text_field($_POST['deposit-genre']); $metadata['committee_deposit'] = sanitize_text_field($_POST['deposit-on-behalf-flag']); $metadata['committee_id'] = sanitize_text_field($_POST['deposit-committee']); $metadata['submitter'] = bp_loggedin_user_id(); /** * Get committee or author metadata. */ if ('yes' === $metadata['committee_deposit']) { $committee = groups_get_group(array('group_id' => $metadata['committee_id'])); $metadata['organization'] = 'MLA'; $metadata['authors'][] = array('fullname' => $committee->name, 'given' => '', 'family' => '', 'uni' => $committee->slug, 'role' => 'creator', 'affiliation' => 'MLA'); } else { $user_id = bp_loggedin_user_id(); $user_firstname = get_the_author_meta('first_name', $user_id); $user_lastname = get_the_author_meta('last_name', $user_id); $user_affiliation = bp_get_profile_field_data(array('field' => 2, 'user_id' => $user_id)); $metadata['organization'] = $user_affiliation; $metadata['authors'][] = array('fullname' => bp_get_loggedin_user_fullname(), 'given' => $user_firstname, 'family' => $user_lastname, 'uni' => bp_get_loggedin_user_username(), 'role' => 'author', 'affiliation' => $user_affiliation); } if ((empty($metadata['committee_deposit']) || 'yes' !== $metadata['committee_deposit']) && (!empty($_POST['deposit-other-authors-first-name']) && !empty($_POST['deposit-other-authors-last-name']))) { $other_authors = array_map(function ($first_name, $last_name) { return array('first_name' => sanitize_text_field($first_name), 'last_name' => sanitize_text_field($last_name)); }, $_POST['deposit-other-authors-first-name'], $_POST['deposit-other-authors-last-name']); foreach ($other_authors as $author_array) { if (!empty($author_array['first_name']) && !empty($author_array['last_name'])) { $mla_user = bp_activity_find_mentions($author_array['first_name'] . $author_array['last_name']); if (!empty($mla_user)) { foreach ($mla_user as $mla_userid => $mla_username) { break; } // Only one, right? $author_name = bp_core_get_user_displayname($mla_userid); $author_firstname = get_the_author_meta('first_name', $mla_userid); $author_lastname = get_the_author_meta('last_name', $mla_userid); $author_affiliation = bp_get_profile_field_data(array('field' => 2, 'user_id' => $mla_userid)); $author_uni = $mla_username; } else { $author_firstname = $author_array['first_name']; $author_lastname = $author_array['last_name']; $author_name = trim($author_firstname . ' ' . $author_lastname); $author_uni = ''; $author_affiliation = ''; } $metadata['authors'][] = array('fullname' => $author_name, 'given' => $author_firstname, 'family' => $author_lastname, 'uni' => $author_uni, 'role' => 'author', 'affiliation' => $author_affiliation); } } } usort($metadata['authors'], function ($a, $b) { return strcasecmp($a['family'], $b['family']); }); /** * Format author info for solr. */ $metadata['author_info'] = humcore_deposits_format_author_info($metadata['authors']); if (!empty($metadata['genre']) && in_array($metadata['genre'], array('Dissertation', 'Technical Report', 'Thesis')) && !empty($_POST['deposit-institution'])) { $metadata['institution'] = sanitize_text_field($_POST['deposit-institution']); } else { if (!empty($metadata['genre']) && in_array($metadata['genre'], array('Dissertation', 'Technical Report', 'Thesis')) && empty($_POST['deposit-institution'])) { $metadata['institution'] = $metadata['organization']; } } if (!empty($metadata['genre']) && ('Conference proceeding' == $metadata['genre'] || 'Conference paper' == $metadata['genre']) && !empty($_POST['deposit-conference-title'])) { $metadata['conference_title'] = sanitize_text_field($_POST['deposit-conference-title']); $metadata['conference_organization'] = sanitize_text_field($_POST['deposit-organization']); } $metadata['group'] = array(); if (!empty($_POST['deposit-group'])) { foreach ($_POST['deposit-group'] as $group_id) { $group = groups_get_group(array('group_id' => sanitize_text_field($group_id))); $metadata['group'][] = $group->name; $metadata['group_ids'][] = $group_id; } } $metadata['subject'] = array(); if (!empty($_POST['deposit-subject'])) { foreach ($_POST['deposit-subject'] as $subject) { $metadata['subject'][] = sanitize_text_field(stripslashes($subject)); // Subject ids will be set later. } } $metadata['keyword'] = array(); if (!empty($_POST['deposit-keyword'])) { foreach ($_POST['deposit-keyword'] as $keyword) { $metadata['keyword'][] = sanitize_text_field(stripslashes($keyword)); // Keyword ids will be set later. } } $metadata['type_of_resource'] = sanitize_text_field($_POST['deposit-resource-type']); $metadata['language'] = 'English'; $metadata['notes'] = sanitize_text_field(stripslashes($_POST['deposit-notes-unchanged'])); // Where do they go in MODS? $metadata['notes_unchanged'] = wp_kses(stripslashes($_POST['deposit-notes-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); $metadata['type_of_license'] = sanitize_text_field($_POST['deposit-license-type']); $metadata['record_content_source'] = 'HumCORE'; $metadata['record_creation_date'] = gmdate('Y-m-d\\TH:i:s\\Z'); $metadata['member_of'] = $fedora_api->collectionPid; if (!empty($_POST['deposit-publication-type'])) { $metadata['publication-type'] = sanitize_text_field($_POST['deposit-publication-type']); // Not stored in solr. } else { $metadata['publication-type'] = 'none'; } if ('journal-article' == $metadata['publication-type']) { $metadata['publisher'] = sanitize_text_field($_POST['deposit-journal-publisher']); $metadata['date'] = sanitize_text_field($_POST['deposit-journal-publish-date']); if (!empty($metadata['date'])) { $temp_date = preg_replace('~^(winter(?:/|)|spring(?:/|)|summer(?:/|)|fall(?:/|)|autumn(?:/|))+\\s(\\d{4})$~i', 'Jan $2', $metadata['date']); $metadata['date_issued'] = date('Y', strtotime(preg_replace('/^(\\d{4})$/', 'Jan $1', $temp_date))); } else { $metadata['date_issued'] = date('Y', strtotime('today')); } $metadata['book_journal_title'] = sanitize_text_field($_POST['deposit-journal-title']); $metadata['volume'] = sanitize_text_field($_POST['deposit-journal-volume']); $metadata['issue'] = sanitize_text_field($_POST['deposit-journal-issue']); $metadata['start_page'] = sanitize_text_field($_POST['deposit-journal-start-page']); $metadata['end_page'] = sanitize_text_field($_POST['deposit-journal-end-page']); $metadata['issn'] = sanitize_text_field($_POST['deposit-journal-issn']); $metadata['doi'] = sanitize_text_field($_POST['deposit-journal-doi']); } elseif ('book' == $metadata['publication-type']) { $metadata['publisher'] = sanitize_text_field($_POST['deposit-book-publisher']); $metadata['date'] = sanitize_text_field($_POST['deposit-book-publish-date']); if (!empty($metadata['date'])) { $temp_date = preg_replace('~^(winter(?:/|)|spring(?:/|)|summer(?:/|)|fall(?:/|)|autumn(?:/|))+\\s(\\d{4})$~i', 'Jan $2', $metadata['date']); $metadata['date_issued'] = date('Y', strtotime(preg_replace('/^(\\d{4})$/', 'Jan $1', $temp_date))); } else { $metadata['date_issued'] = date('Y', strtotime('today')); } $metadata['book_journal_title'] = sanitize_text_field($_POST['deposit-book-title']); $metadata['book_author'] = sanitize_text_field($_POST['deposit-book-author']); $metadata['chapter'] = sanitize_text_field($_POST['deposit-book-chapter']); $metadata['start_page'] = sanitize_text_field($_POST['deposit-book-start-page']); $metadata['end_page'] = sanitize_text_field($_POST['deposit-book-end-page']); $metadata['isbn'] = sanitize_text_field($_POST['deposit-book-isbn']); $metadata['doi'] = sanitize_text_field($_POST['deposit-book-doi']); } elseif ('conference-proceeding' == $metadata['publication-type']) { $metadata['publisher'] = sanitize_text_field($_POST['deposit-proceeding-publisher']); $metadata['date'] = sanitize_text_field($_POST['deposit-proceeding-publish-date']); if (!empty($metadata['date'])) { $temp_date = preg_replace('~^(winter(?:/|)|spring(?:/|)|summer(?:/|)|fall(?:/|)|autumn(?:/|))+\\s(\\d{4})$~i', 'Jan $2', $metadata['date']); $metadata['date_issued'] = date('Y', strtotime(preg_replace('/^(\\d{4})$/', 'Jan $1', $temp_date))); } else { $metadata['date_issued'] = date('Y', strtotime('today')); } $metadata['book_journal_title'] = sanitize_text_field($_POST['deposit-proceeding-title']); $metadata['start_page'] = sanitize_text_field($_POST['deposit-proceeding-start-page']); $metadata['end_page'] = sanitize_text_field($_POST['deposit-proceeding-end-page']); $metadata['doi'] = sanitize_text_field($_POST['deposit-proceeding-doi']); } elseif ('none' == $metadata['publication-type']) { $metadata['date'] = sanitize_text_field($_POST['deposit-non-published-date']); if (!empty($metadata['date'])) { $temp_date = preg_replace('~^(winter(?:/|)|spring(?:/|)|summer(?:/|)|fall(?:/|)|autumn(?:/|))+\\s(\\d{4})$~i', 'Jan $2', $metadata['date']); $metadata['date_issued'] = date('Y', strtotime(preg_replace('/^(\\d{4})$/', 'Jan $1', $temp_date))); } else { $metadata['date_issued'] = date('Y', strtotime('today')); } } /** * Mint and reserve a DOI. */ $creators = array(); foreach ($metadata['authors'] as $author) { if ('author' === $author['role'] && !empty($author['fullname'])) { $creators[] = $author['fullname']; } } $creator_list = implode(',', $creators); $deposit_doi = humcore_create_handle($metadata['title'], $nextPids[0], $creator_list, $metadata['genre'], $metadata['date_issued'], $metadata['publisher']); if (!$deposit_doi) { $metadata['handle'] = sprintf(bp_get_root_domain() . '/deposits/item/%s/', $nextPids[0]); $metadata['deposit_doi'] = ''; // Not stored in solr. } else { $metadata['handle'] = 'http://dx.doi.org/' . str_replace('doi:', '', $deposit_doi); $metadata['deposit_doi'] = $deposit_doi; // Not stored in solr. } return $metadata; }