示例#1
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');
         }
     }
 }
/**
 * 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);
}
示例#3
0
/**
 * Builds an admin BuddyDrive Items loop
 * @param  integer $folder_id the folder id
 * @param  integer $paged     the page to load
 * @uses add_query_args() to add some args to the url
 * @uses bp_get_admin_url() to build the admin url
 * @uses The BuddyDrive loop with some template tags
 * @uses wp_nonce_url() for security reasons
 */
function buddydrive_admin_edit_files_loop($folder_id = 0, $paged = 1)
{
    $form_url = add_query_arg(array('page' => 'buddydrive-files'), bp_get_admin_url('admin.php'));
    if (buddydrive_has_items(array('buddydrive_parent' => $folder_id, 'paged' => $paged))) {
        ?>

		<?php 
        while (buddydrive_has_items()) {
            buddydrive_the_item();
            ?>

			<tr id="item-<?php 
            buddydrive_item_id();
            ?>
">
				<td>
					<input type="checkbox" name="bid[]" class="buddydrive-item-cb" value="<?php 
            esc_attr(buddydrive_item_id());
            ?>
">
				</td>
				<td>
					<?php 
            buddydrive_item_icon();
            ?>
&nbsp;<a href="<?php 
            buddydrive_action_link();
            ?>
" class="<?php 
            buddydrive_action_link_class();
            ?>
" title="<?php 
            esc_attr(buddydrive_item_title());
            ?>
"<?php 
            buddydrive_item_attribute();
            ?>
><?php 
            esc_html(buddydrive_item_title());
            ?>
</a>
					<div class="row-actions">
						<?php 
            $base_url = add_query_arg(array('bid' => buddydrive_get_item_id()), $form_url);
            $edit_url = add_query_arg(array('action' => 'edit'), $base_url);
            $delete_url = wp_nonce_url($base_url . "&amp;action=delete", 'buddydrive-delete');
            ?>
						<span class="edit">
							<a href="<?php 
            echo esc_url($edit_url);
            ?>
"><?php 
            esc_html_e('Edit', 'buddydrive');
            ?>
</a> |
						</span>
						<span class="delete">
							<a href="<?php 
            echo esc_url($delete_url);
            ?>
"><?php 
            esc_html_e('Delete', 'buddydrive');
            ?>
</a>
						</span>
					</div>
				</td>
				<td>
					<?php 
            buddydrive_item_mime_type();
            ?>
				</td>
				<td>
					<?php 
            buddydrive_item_date();
            ?>
				</td>
			</tr>

		<?php 
        }
        ?>

		<?php 
        if (buddydrive_has_more_items()) {
            ?>
			<tr>
				<td class="buddydrive-load-more" colspan="4">
					<a href="#more-buddydrive"><?php 
            _e('Load More', 'buddydrive');
            ?>
</a>
				</td>
			</tr>
		<?php 
        }
        ?>

	<?php 
    } else {
        ?>
		<tr><td colspan="4"><?php 
        _e('No files attached to this folder', 'buddydrive');
        ?>
</td></tr>
	<?php 
    }
}