Ejemplo n.º 1
0
/**
 * Builds the row actions
 *
 * @global object $buddydrive_template
 * @uses buddydrive_get_item_id() to get item id
 * @uses buddydrive_is_buddyfile() to check for a file
 * @uses buddydrive_get_item_description() to get item's description
 * @uses buddydrive_get_item_privacy() to get item's privacy options
 * @uses buddydrive_current_user_can_link()
 * @uses buddydrive_get_action_link()
 * @uses buddydrive_current_user_can_share()
 * @uses bp_is_active() to check for the messages, activity and group components.
 * @uses bp_loggedin_user_domain() to get user's home url
 * @uses bp_get_messages_slug() to get the messages component slug
 * @uses buddydrive_current_user_can_share()
 * @return [type] [description]
 */
function buddydrive_get_row_actions()
{
    global $buddydrive_template;
    $row_actions = $inside_top = $inside_bottom = false;
    $buddyfile_id = buddydrive_get_item_id();
    if (buddydrive_is_buddyfile()) {
        $description = buddydrive_get_item_description();
        if (!empty($description)) {
            $inside_top[] = '<a class="buddydrive-show-desc" href="#">' . __('Description', 'buddydrive') . '</a>';
            $inside_bottom .= '<div class="buddydrive-ra-desc hide ba">' . $description . '</div>';
        }
    }
    $privacy = buddydrive_get_item_privacy();
    switch ($privacy['privacy']) {
        case 'public':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('activity')) {
                $inside_top[] = '<a class="buddydrive-profile-activity" href="#">' . __('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'password':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('messages')) {
                $inside_top[] = '<a class="buddydrive-private-message" href="' . esc_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?buddyitem=' . $buddyfile_id) . '">' . esc_html__('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'friends':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_attr(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('messages')) {
                $inside_top[] = '<a class="buddydrive-private-message" href="' . esc_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?buddyitem=' . $buddyfile_id) . '&friends=1">' . esc_html__('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'groups':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('activity') && bp_is_active('groups')) {
                $inside_top[] = '<a class="buddydrive-group-activity" href="#">' . __('Share', 'buddydrive') . '</a>';
            }
            if (buddydrive_current_user_can_remove($privacy['group']) && bp_is_active('groups')) {
                $inside_top[] = '<a class="buddydrive-remove-group" href="#" data-group="' . esc_attr($privacy['group']) . '">' . esc_html__('Remove', 'buddydrive') . '</a>';
            }
            break;
    }
    if (!empty($inside_top)) {
        $inside_top = '<div class="buddydrive-action-btn">' . implode(' | ', $inside_top) . '</div>';
    }
    if (!empty($inside_top)) {
        $row_actions .= '<div class="buddydrive-row-actions">' . $inside_top . $inside_bottom . '</div>';
    }
    return apply_filters('buddydrive_get_row_actions', $row_actions);
}
Ejemplo n.º 2
0
 function course_privacy()
 {
     $status = buddydrive_get_item_privacy();
     if ($status['privacy'] == 'course') {
         if (!empty($status['course'])) {
             $course_id = get_post_meta(buddydrive_get_item_id(), 'course', true);
             if (has_post_thumbnail($course_id)) {
                 $thumbnail = get_the_post_thumbnail($course_id, array('32', '32'));
             } else {
                 $thumbnail = '<img src="' . vibe_get_option('default_course_avatar') . '" width="32" height="32" />';
             }
             echo '<a href="' . get_permalink($course_id) . '" >' . $thumbnail . '</a>';
         } else {
             _e('Course', 'vibe');
         }
     }
 }