public function context_menu_edit()
 {
     if (!mpp_is_single_gallery()) {
         return;
     }
     if (mpp_is_gallery_management() || mpp_is_media_management()) {
         return;
     }
     if (!mpp_user_can_edit_gallery(mpp_get_current_gallery_id())) {
         return;
     }
     $links = '';
     if (mpp_is_single_media()) {
         $url = mpp_get_media_edit_url();
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, _x('Edit media', 'Profile context menu rel', 'mediapress'), _x('Edit', 'Profile context menu media edit label', 'mediapress'));
     } else {
         $url = mpp_get_gallery_edit_media_url(mpp_get_current_gallery());
         //bulk edit media url
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, _x('Edit Gallery', 'Profile context menu rel attribute', 'mediapress'), _x('Edit', 'Profile contextual edit gallery menu label', 'mediapress'));
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', mpp_get_gallery_add_media_url(mpp_get_current_gallery()), _x('Add Media', 'Profile context menu rel attribute', 'mediapress'), _x('Add Media', 'Profile contextual add media  menu label', 'mediapress'));
     }
     echo $links;
 }
Exemple #2
0
<?php

// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
    exit;
}
if (mpp_user_can_edit_gallery(mpp_get_current_gallery_id())) {
    ?>

<?php 
    $gallery = mpp_get_current_gallery();
    ?>

<form method="post" action="" id="mpp-gallery-edit-form" class="mpp-form mpp-form-stacked mpp-gallery-edit-form">
	

	
	<div class="mpp-g">
		
		<div class="mpp-u-1-1 mpp-clearfix">
			
				<?php 
    do_action('mpp_before_edit_gallery_form_fields', $gallery->id);
    ?>
			
		</div>
		
		<div class="mpp-u-1-2 mpp-gallery-type mpp-cover-wrapper">
			<div class="mpp-gallery-cover-edit-image mpp-cover-image"  id="mpp-cover-<?php 
    echo $gallery->id;
    ?>
Exemple #3
0
 public function context_menu_edit()
 {
     if (mpp_is_gallery_management() || mpp_is_media_management()) {
         return;
     }
     if (!mpp_is_single_gallery()) {
         return;
     }
     if (!mpp_user_can_edit_gallery(mpp_get_current_gallery_id())) {
         return;
     }
     if (mpp_is_single_media()) {
         $url = mpp_get_media_edit_url();
     } else {
         $url = mpp_get_gallery_edit_media_url(mpp_get_current_gallery());
     }
     //bulk edit media url
     printf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, __('Edit', 'mediapress'), __('Edit', 'mediapress'));
 }
Exemple #4
0
/**
 * Handles gallery details updation
 * 
 * @return type
 */
function mpp_action_edit_gallery()
{
    //allow gallery to be created from anywhere
    if (empty($_POST['mpp-action']) || $_POST['mpp-action'] != 'edit-gallery') {
        return;
    }
    $referer = wp_get_referer();
    //if we are here, It is gallery create action
    if (!wp_verify_nonce($_POST['mpp-nonce'], 'mpp-edit-gallery')) {
        //add error message and return back to the old page
        mpp_add_feedback(__('Action not authorized!', 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    $gallery_id = absint($_POST['mpp-gallery-id']);
    if (!$gallery_id) {
        return;
    }
    //check for permission
    //we may want to allow passing of component from the form in future!
    if (!mpp_user_can_edit_gallery($gallery_id)) {
        mpp_add_feedback(__("You don't have permission to edit this gallery!", 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //if we are here, validate the data and let us see if we can create
    $title = $_POST['mpp-gallery-title'];
    $description = $_POST['mpp-gallery-description'];
    $status = $_POST['mpp-gallery-status'];
    $errors = array();
    if (!mpp_is_active_status($status)) {
        $errors['status'] = __('Invalid Gallery status!', 'mediapress');
    }
    if (empty($title)) {
        $errors['title'] = __('Title can not be empty', 'mediapress');
    }
    //give opportunity to other plugins to add their own validation errors
    $validation_errors = apply_filters('mpp-edit-gallery-field-validation', $errors, $_POST);
    if (!empty($validation_errors)) {
        //let us add the validation error and return back to the earlier page
        $message = join('\\r\\n', $validation_errors);
        mpp_add_feedback($message, 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //let us create gallery
    $gallery_id = mpp_update_gallery(array('title' => $title, 'description' => $description, 'status' => $status, 'creator_id' => get_current_user_id(), 'id' => $gallery_id));
    if (!$gallery_id) {
        mpp_add_feedback(__('Unable to update gallery!', 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //if we are here, the gallery was created successfully,
    //let us redirect to the gallery_slug/manage/upload page
    $redirect_url = mpp_get_gallery_settings_url($gallery_id);
    mpp_add_feedback(__('Gallery updated successfully!', 'mediapress'));
    mpp_redirect($redirect_url);
}
Exemple #5
0
function mpp_setup_gallery_nav()
{
    //only add on single gallery
    if (!mpp_is_single_gallery()) {
        return;
    }
    $gallery = mpp_get_current_gallery();
    $url = '';
    if ($gallery) {
        $url = mpp_get_gallery_permalink($gallery);
    }
    //only add view/edit/dele links on the single mgallery view
    mpp_add_gallery_nav_item(array('label' => __('View', 'mediapress'), 'url' => $url, 'action' => 'view', 'slug' => 'view'));
    $user_id = get_current_user_id();
    if (mpp_user_can_edit_gallery($gallery->id, $user_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Edit Media', 'mediapress'), 'url' => mpp_get_gallery_edit_media_url($gallery), 'action' => 'edit', 'slug' => 'edit'));
    }
    if (mpp_user_can_upload($gallery->component, $gallery->component_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Add Media', 'mediapress'), 'url' => mpp_get_gallery_add_media_url($gallery), 'action' => 'add', 'slug' => 'add'));
    }
    if (mpp_user_can_edit_gallery($gallery->id, $user_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Reorder', 'mediapress'), 'url' => mpp_get_gallery_reorder_media_url($gallery), 'action' => 'reorder', 'slug' => 'reorder'));
        mpp_add_gallery_nav_item(array('label' => __('Edit Details', 'mediapress'), 'url' => mpp_get_gallery_settings_url($gallery), 'action' => 'settings', 'slug' => 'settings'));
    }
    if (mpp_user_can_delete_gallery($gallery->id)) {
        mpp_add_gallery_nav_item(array('label' => __('Delete', 'mediapress'), 'url' => mpp_get_gallery_delete_url($gallery), 'action' => 'delete', 'slug' => 'delete'));
    }
}
Exemple #6
0
 public function reload_bulk_edit()
 {
     //verify nonce
     if (!wp_verify_nonce($_POST['_wpnonce'], 'mpp-manage-gallery')) {
         wp_send_json(array('message' => __('Invalid action.', 'mediapress'), 'error' => 1));
         exit(0);
     }
     $gallery_id = absint($_POST['gallery_id']);
     $gallery = mpp_get_gallery($gallery_id);
     if (!$gallery_id || !$gallery) {
         wp_send_json(array('message' => __('Invalid action.', 'mediapress'), 'error' => 1));
         exit(0);
     }
     if (!mpp_user_can_edit_gallery($gallery)) {
         wp_send_json(array('message' => __("You don't have permission to update gallery.", 'mediapress'), 'error' => 1));
         exit(0);
     }
     //show the form
     mediapress()->current_gallery = $gallery;
     mediapress()->the_media_query = new MPP_Media_Query(array('gallery_id' => $gallery_id, 'per_page' => -1, 'nopaging' => true));
     global $post;
     $bkp_post = $post;
     ob_start();
     require_once $this->template_dir . 'gallery/edit-media.php';
     $contents = ob_get_clean();
     $post = $bkp_post;
     wp_send_json(array('message' => __('Updated.', 'mediapress'), 'success' => 1, 'contents' => $contents));
     exit(0);
 }