/**
 * 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);
}
Exemplo n.º 2
0
 function get_row_actions($row_actions)
 {
     global $buddydrive_template;
     $buddyfile_id = buddydrive_get_item_id();
     $privacy = buddydrive_get_item_privacy();
     if ($privacy['privacy'] == 'course') {
         if (buddydrive_current_user_can_link($privacy)) {
             $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'vibe') . '</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('course')) {
             $inside_top[] = '<a class="buddydrive-course-activity" href="#">' . __('Share', 'vibe') . '</a>';
         }
         if (buddydrive_current_user_can_remove($privacy['course']) && bp_is_active('course')) {
             $inside_top[] = '<a class="buddydrive-remove-course" href="#" data-course="' . esc_attr($privacy['course']) . '">' . esc_html__('Remove', 'vibe') . '</a>';
         }
     }
     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 $row_actions;
 }