Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update upload-class.php #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/Options/upload-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public static function file_uploader_callback()
public static function file_batch_delete_callback()
{
$deleted = array();

if (!current_user_can('delete_posts')){
die('no permission');
}

if (isset($_POST['media-ids']) && is_array($_POST['media-ids'])) {

Expand All @@ -83,6 +87,7 @@ public static function file_batch_delete_callback()


foreach ($attachment_id_array as $attachmentid) {
self::check_current_user_access($attachmentid);
$deleted_item = wp_delete_attachment($attachmentid, true);
$deleted[] = $deleted_item->ID;
}
Expand All @@ -93,6 +98,10 @@ public static function file_batch_delete_callback()

public static function file_delete()
{
if (!current_user_can('delete_posts')){
die('no permission to delete posts');
}
self::check_current_user_access($_POST['qquuid']);

/**
* Query attachments
Expand Down Expand Up @@ -341,5 +350,15 @@ public static function parse_size($size)
return round($size);
}
}

private static function check_current_user_access($attachmentid)
{
$post_object = get_post((int)$attachmentid);
empty($post_object) && die('no access');

if ( get_current_user_id()!==(int)$post_object->post_author && !current_user_can('delete_others_posts')){
die('no permission to delete other posts');
}
}
}
}