コード例 #1
0
/**
 * Loads a form to edit a file or a folder
 *
 * @uses buddydrive_get_buddyfile() to get the item to edit
 * @uses buddydrive_get_folder_post_type() to get the BuddyFolder post type
 * @uses buddydrive_get_file_post_type() to get the BuddyFile post type
 * @uses wp_kses() to sanitize data
 * @uses buddydrive_select_sharing_options() to display the privacy choices
 * @uses buddydrive_select_user_group() to display the groups available
 * @uses buddydrive_select_folder_options() to display the available folders
 * @return string the edit form
 */
function buddydrive_edit_form()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    $item_id = !empty($_POST['buddydrive_item']) ? intval($_POST['buddydrive_item']) : false;
    if (!empty($item_id)) {
        $item = buddydrive_get_buddyfile($item_id, array(buddydrive_get_folder_post_type(), buddydrive_get_file_post_type()));
        ?>
		<form class="standard-form" id="buddydrive-item-edit-form">

			<div id="buddyitem-description">
				<input type="hidden" id="buddydrive-item-id" value="<?php 
        echo $item->ID;
        ?>
">
				<label for="buddydrive-item-title"><?php 
        esc_html_e('Name', 'buddydrive');
        ?>
</label>
				<input type="text" name="buddydrive-edit[item-title]" id="buddydrive-item-title" value="<?php 
        echo esc_attr(stripslashes($item->title));
        ?>
" />

				<?php 
        if ($item->post_type == buddydrive_get_file_post_type()) {
            ?>
					<label for="buddydrive-item-content"><?php 
            esc_html_e('Description', 'buddydrive');
            ?>
</label>
					<textarea name="buddydrive-edit[item-content]" id="buddydrive-item-content" maxlength="140"><?php 
            echo wp_kses(stripslashes($item->content), array());
            ?>
</textarea>
					<?php 
            if (has_action('buddydrive_uploader_custom_fields')) {
                ?>
						<div id="buddydrive-custom-step-edit" class="buddydrive-step hide">
							<?php 
                do_action('buddydrive_uploader_custom_fields', $item->ID);
                ?>
						</div>
					<?php 
            }
            ?>
				<?php 
        }
        ?>

			</div>

			<?php 
        if (empty($item->post_parent)) {
            ?>

				<div id="buddydrive-privacy-section-options">
					<label for="buddydrive-sharing-option"><?php 
            esc_html_e('Item Sharing options', 'buddydrive');
            ?>
</label>
					<?php 
            buddydrive_select_sharing_options('buddyitem-sharing-options', $item->check_for, 'buddydrive-edit[sharing]');
            ?>

					<div id="buddydrive-admin-privacy-detail">
						<?php 
            if ($item->check_for == 'password') {
                ?>
							<label for="buddydrive-password"><?php 
                esc_html_e('Password', 'buddydrive');
                ?>
</label>
							<input type="text" value="<?php 
                echo esc_attr(stripslashes($item->password));
                ?>
" name="buddydrive-edit[password]" id="buddypass"/>
						<?php 
            } elseif ($item->check_for == 'groups') {
                ?>
							<label for="buddygroup"><?php 
                esc_html_e('Choose the group', 'buddydrive');
                ?>
</label>
							<?php 
                buddydrive_select_user_group($item->user_id, $item->group, 'buddydrive-edit[buddygroup]');
                ?>
						<?php 
            }
            ?>
					</div>
				</div>

			<?php 
        } else {
            ?>

				<div id="buddyitem-sharing-option">
					<label for="buddydrive-sharing-option"><?php 
            esc_html_e('Edit your sharing options', 'buddydrive');
            ?>
</label>
					<p><?php 
            esc_html_e('Privacy of this item rely on its parent folder', 'buddydrive');
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<?php 
        if ($item->post_type == buddydrive_get_file_post_type()) {
            ?>

				<div class="buddyitem-folder-section" id="buddyitem-folder-section-options">
					<label for="buddyitem-folder-option"><?php 
            esc_html_e('Folder', 'buddydrive');
            ?>
</label>
					<?php 
            buddydrive_select_folder_options($item->user_id, $item->post_parent, 'buddydrive-edit[folder]');
            ?>
				</div>

			<?php 
        }
        ?>

			<p class="buddydrive-action folder"><input type="submit" value="<?php 
        esc_html_e('Edit Item', 'buddydrive');
        ?>
" name="buddydrive_edit[submit]">&nbsp;<a href="#" class="cancel-item button"><?php 
        esc_html_e('Cancel', 'buddydrive');
        ?>
</a></p>

		</form>
		<?php 
    }
    die;
}
コード例 #2
0
/**
 * Privacy Metabox settings
 *
 * @param  object $item The BuddyDrive Item object
 * @uses get_post_meta() to get the privacy settings
 * @uses buddydrive_get_show_owner_avatar() to get owner's avatar
 * @uses buddydrive_user_used_quota() to get user's space left
 * @uses buddydrive_select_sharing_options() to display the select box of available privacy options
 * @uses buddydrive_select_user_group() to display the group select box
 * @uses buddydrive_get_file_post_type() to get the BuddyFile post type
 * @uses buddydrive_select_folder_options() to display the parent folder select box
 */
function buddydrive_admin_edit_metabox_privacy($item)
{
    $privacy_status = get_post_meta($item->ID, '_buddydrive_sharing_option', true);
    $owner = $item->user_id;
    $avatar = buddydrive_get_show_owner_avatar($owner);
    ?>
	<div class="buddydrive-owner-section" id="buddydrive-owner-section-info">
		<div>
			<label><?php 
    _e('Owner', 'buddydrive');
    ?>
</label>
			<table>
				<tr>
					<td><?php 
    echo $avatar;
    ?>
</td>
					<td><?php 
    _e('BuddyDrive Usage', 'buddydrive');
    ?>
 : <?php 
    buddydrive_user_used_quota(false, $owner);
    ?>
 %</td>
				</tr>
			</table>
		</div>
		<input type="hidden" value="<?php 
    echo $owner;
    ?>
" id="buddydrive-owner-id" disabled>
	</div>

	<?php 
    if (empty($item->post_parent)) {
        ?>

		<div class="buddydrive-privacy-section" id="buddydrive-privacy-section-options">
			<label for="buddydrive-sharing-option"><?php 
        _e('Item Sharing options', 'buddydrive');
        ?>
</label>
			<?php 
        buddydrive_select_sharing_options('buddydrive-admin-sharing-options', $privacy_status, 'buddydrive-edit[sharing]');
        ?>

			<div id="buddydrive-admin-privacy-detail">
				<?php 
        if ($privacy_status == 'password') {
            ?>
					<label for="buddydrive-password"><?php 
            _e('Password', 'buddydrive');
            ?>
</label>
					<input type="text" value="<?php 
            echo esc_attr(stripslashes($item->password));
            ?>
" name="buddydrive-edit[password]" id="buddydrive-password"/>
				<?php 
        } elseif ($privacy_status == 'groups') {
            ?>
					<label for="buddygroup"><?php 
            _e('Choose the group', 'buddydrive');
            ?>
</label>
					<?php 
            buddydrive_select_user_group($owner, $item->group, 'buddydrive-edit[buddygroup]');
            ?>
				<?php 
        }
        ?>
			</div>
		</div>

		<?php 
        if (empty($privacy_status)) {
            ?>
			<p><strong><?php 
            _e('The privacy of this item is not defined, please correct this!', 'buddydrive');
            ?>
</strong></p>
		<?php 
        }
        ?>

	<?php 
    } else {
        ?>

		<div class="buddydrive-privacy-section" id="buddydrive-privacy-section-options">
			<label for="buddydrive-sharing-option"><?php 
        _e('Item Sharing options', 'buddydrive');
        ?>
</label>
			<p><?php 
        printf(__("Privacy of this item rely on its parent <a href=\"%s\">folder</a>", "buddydrive"), esc_url(add_query_arg(array('page' => 'buddydrive-files', 'bid' => $item->post_parent, 'action' => 'edit'), bp_get_admin_url('admin.php'))));
        ?>
</p>
		</div>

	<?php 
    }
    ?>

	<?php 
    if ($item->post_type == buddydrive_get_file_post_type()) {
        ?>

		<div class="buddydrive-folder-section" id="buddydrive-folder-section-options">
			<label for="buddydrive-folder-option"><?php 
        _e('Folder', 'buddydrive');
        ?>
</label>
			<?php 
        buddydrive_select_folder_options($owner, $item->post_parent, 'buddydrive-edit[folder]');
        ?>
		</div>

	<?php 
    }
    ?>

<?php 
}
コード例 #3
0
/**
 * Displays the form to create a new folder
 *
 * @uses buddydrive_select_sharing_options() to display the privacy select box
 */
function buddydrive_folder_form()
{
    ?>
	<form class="standard-form" action="" method="post" id="buddydrive-folder-editor-form">

		<div id="buddyfolder-first-step">
			<label for="buddyfolder-sharing-options"><?php 
    _e('Define your sharing options', 'buddydrive');
    ?>
</label>
			<?php 
    buddydrive_select_sharing_options('buddyfolder-sharing-options');
    ?>
			<div id="buddyfolder-sharing-details"></div>
			<input type="hidden" id="buddyfolder-sharing-settings" value="private">
			<p class="buddydrive-action"><a href="#" class="next-step button"><?php 
    _e('Next Step', 'buddydrive');
    ?>
</a></p>
		</div>
		<div id="buddyfolder-second-step" class="hide">
			<label for="buddydrive-folder-title"><?php 
    _e('Create your folder', 'buddydrive');
    ?>
</label>
			<input type="text" placeholder="<?php 
    _e('Name of your folder', 'buddydrive');
    ?>
" id="buddydrive-folder-title" name="buddydrive_folder[title]">
			<p class="buddydrive-action folder"><input type="submit" value="<?php 
    _e('Add folder', 'buddydrive');
    ?>
" name="buddydrive_folder[submit]">&nbsp;<a href="#" class="cancel-folder button"><?php 
    _e('Cancel', 'buddydrive');
    ?>
</a></p>
		</div>
	</form>
	<?php 
}
コード例 #4
0
    /**
     * Finally output the uploader
     *
     * @global $type, $tab, $pagenow, $is_IE, $is_opera
     * @return string the output
     */
    public function display()
    {
        global $type, $tab, $pagenow, $is_IE, $is_opera;
        ?>
		<form enctype="multipart/form-data" method="post" action="" class="media-upload-form type-form validate standard-form" id="file-form">

			<?php 
        if (!_device_can_upload()) {
            echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.', 'buddydrive') . '</p>';
            return;
        }
        $upload_size_unit = $max_upload_size = buddydrive_max_upload_size(true);
        $sizes = array('KB', 'MB', 'GB');
        for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
            $upload_size_unit /= 1024;
        }
        if ($u < 0) {
            $upload_size_unit = 0;
            $u = 0;
        } else {
            $upload_size_unit = (int) $upload_size_unit;
        }
        ?>

			<div id="media-upload-notice"><?php 
        if (isset($errors['upload_notice'])) {
            echo $errors['upload_notice'];
        }
        ?>
			</div>
			<div id="media-upload-error"><?php 
        if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) {
            echo $errors['upload_error']->get_error_message();
        }
        ?>
			</div>

			<div id="buddydrive-first-step" class="buddydrive-step">
				<label for="buddyfile-desc"><?php 
        _e('Describe your file', 'buddydrive');
        ?>
</label>
				<textarea placeholder="<?php 
        _e('140 characters to do so', 'buddydrive');
        ?>
" maxlength="140" id="buddyfile-desc"></textarea>
				<p class="buddydrive-action"><a href="#" class="next-step button"><?php 
        _e('Next Step', 'buddydrive');
        ?>
</a></p>
			</div>

			<?php 
        if (has_action('buddydrive_uploader_custom_fields')) {
            ?>

				<div id="buddydrive-custom-step-new" class="buddydrive-step hide">

					<?php 
            do_action('buddydrive_uploader_custom_fields');
            ?>
					<p class="buddydrive-action"><a href="#" class="next-step button"><?php 
            _e('Next Step', 'buddydrive');
            ?>
</a></p>

				</div>

			<?php 
        }
        ?>

			<div id="buddydrive-second-step" class="buddydrive-step hide">
				<label for="buddydrive-sharing-options"><?php 
        _e('Define your sharing options', 'buddydrive');
        ?>
</label>

				<?php 
        buddydrive_select_sharing_options();
        ?>

				<div id="buddydrive-sharing-details"></div>
				<input type="hidden" id="buddydrive-sharing-settings" value="private">
				<p class="buddydrive-action"><a href="#" class="next-step button"><?php 
        _e('Next Step', 'buddydrive');
        ?>
</a></p>
			</div>

			<?php 
        if (is_multisite() && !is_upload_space_available()) {
            do_action('upload_ui_over_quota');
            return;
        }
        $buddydrive_params = array('action' => 'buddydrive_upload', '_wpnonce' => wp_create_nonce('buddydrive-form'));
        $buddydrive_params = apply_filters('buddydrive_upload_post_params', $buddydrive_params);
        // hook change! old name: 'swfupload_post_params'
        $plupload_init = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'drag-drop-area', 'file_data_name' => 'buddyfile-upload', 'multi_selection' => false, 'url' => admin_url('admin-ajax.php', 'relative'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*', 'max_file_size' => $max_upload_size . 'b')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $buddydrive_params);
        $plupload_init = apply_filters('buddydrive_plupload_init', $plupload_init);
        ?>

			<script type="text/javascript">
			var wpUploaderInit = <?php 
        echo json_encode($plupload_init);
        ?>
;
			</script>

			<div id="buddydrive-third-step" class="buddydrive-step hide">
				<label for="plupload-browse-buttons"><?php 
        _e('Upload your file!', 'buddydrive');
        ?>
</label>

				<div id="plupload-upload-ui" class="hide-if-no-js">

					<div id="drag-drop-area">
						<div class="drag-drop-inside">
							<p class="drag-drop-info"><?php 
        _e('Drop your file here', 'buddydrive');
        ?>
</p>
							<p><?php 
        _ex('or', 'Uploader: Drop your file here - or - Select your File', 'buddydrive');
        ?>
</p>
							<p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php 
        esc_attr_e('Select your File', 'buddydrive');
        ?>
" class="button" /></p>
						</div>
					</div>

				</div>

				<p><span class="max-upload-size"><?php 
        printf(__('Maximum upload file size: %d%s.', 'buddydrive'), esc_html($upload_size_unit), esc_html($sizes[$u]));
        ?>
</span></p>
				<p class="buddydrive-action"><a href="#" class="cancel-step button"><?php 
        _e('Cancel', 'buddydrive');
        ?>
</a></p>

			</div>

		</form>
		<?php 
    }