All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.


Author Topic: Rights to Downloads Management  (Read 7887 times)

0 Members and 1 Guest are viewing this topic.

Offline LordGryn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Rights to Downloads Management
« on: 27 February 2008, 21:16 »
Hi, first off - thanks for the great plugin :)

I just wanted to ask, is it possible to give access to the Download Management to my Editors without making them Admins? As they cannot see the Downloads tab.

Thanks!

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #1 on: 28 February 2008, 01:30 »
You need to download Ryan's Role Manager and assign your editors the manage_downloads cap.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline LordGryn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Rights to Downloads Management
« Reply #2 on: 28 February 2008, 14:38 »
awesome, thanks mate :)

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,294
    • View Profile
Re: Rights to Downloads Management
« Reply #3 on: 29 February 2008, 00:02 »
:)
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline CrazySerb

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Rights to Downloads Management
« Reply #4 on: 10 March 2008, 21:50 »
Speaking of rights to download, how would I add the option in the Add File page (as a dropdown) to grant access to members of user level X (and higher), just like the wordpress roles work too...

Just because dividing the file accessibility between everyone and registered/logged in users won't do much on my site where I have custom user groups and different levels of membership/user levels that should have access to downloads and members area... and downloads would be part of that members area too.

So, in order to secure them from just any registered user, how would I code that into an option? Or if it's not possible just yet, how can I hard code it so that only users of X level (and higher) are able to access the files?

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #5 on: 11 March 2008, 01:33 »
It is not possible. It is meant to be a simple download manager. BUT i may add this in one day as I think it is a good idea.

To hard code the min level:

Find in downloadmanager.php:
Code: [Select]
add_action('template_redirect', 'download_file');
function download_file() {
global $wpdb, $user_ID;
$id = intval(get_query_var('dl_id'));
if($id > 0) {

Add below it:
Code: [Select]
$current_user = wp_get_current_user();
$user_level = intval($current_user->user_level);
if($user_level < 5) die();

Replace 5 with the level

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline CrazySerb

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Rights to Downloads Management
« Reply #6 on: 30 May 2008, 21:13 »
It is not possible. It is meant to be a simple download manager. BUT i may add this in one day as I think it is a good idea.

To hard code the min level:

Find in downloadmanager.php:
Code: [Select]
add_action('template_redirect', 'download_file');
function download_file() {
global $wpdb, $user_ID;
$id = intval(get_query_var('dl_id'));
if($id > 0) {

Add below it:
Code: [Select]
$current_user = wp_get_current_user();
$user_level = intval($current_user->user_level);
if($user_level < 5) die();

Replace 5 with the level


could you add this option on ADD FILE page?

so we can designate a permission level for each file?

I'll even pay you some $$ to get this done if that's what it takes to...

I'd prefer to see it on category creation itself, because that way you can just assign certain permissions to category itself and then upload files to it without bothering setting the permissions for each file (or have the option to do so while having the category permission level selected by default in the drop-down).

Please let me know...

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #7 on: 31 May 2008, 07:08 »
In download-add.php, you will see this line at the top:
Code: [Select]
if(!current_user_can('manage_downloads')) {
die('Access Denied');
}

Create your own role to replace "manage_downloads" and assign that newly created role to someone. I think you have to search for a plugin to do that.

The category feature is still very very simple. I have plans to make it more complicated but that is next time if I have the time to do it.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline CrazySerb

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Rights to Downloads Management
« Reply #8 on: 02 June 2008, 20:56 »
I just did this in line 148 in wp-downloadmanager.php:

Code: [Select]
$file = $wpdb->get_row("SELECT file, file_permission FROM $wpdb->downloads WHERE file_id = $id AND file_permission != -1 AND  $user_ID >= file_permission ");
and then updated a few lines in download-manager.php (where $file->file_permission appears with the drop down listing of all roles and permissions) to add my own hard coded user roles and permission levels.

It would be nice if this could be created automatically by simply dropping wp_dropdown_roles() function in there, but you'd have to change a few lines here and there to accomodate for the actual "textual" role instead of an integer.

something to think about for the next version.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #9 on: 03 June 2008, 09:29 »
The reason I do not want to add the rights as I am aiming for a simple download manager. Maybe set a base permission for a file so that if the user level must be equal or higher than the base permission to download it. Sounds good?

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline CrazySerb

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Rights to Downloads Management
« Reply #10 on: 03 June 2008, 13:03 »
well, that's exactly what I was going for...

I mean, you can't call it a simple download manager and have those 3 levels of access built in (Hidden/Everyone/Registered only).

If you bothered putting those 3 levels in, might as well put the levels defined in User Roles anyway... especially if you can do it dynamically by using wp_dropdown_roles() because not everyone has the default Author/Editor/Contributor/etc roles defined either.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #11 on: 03 June 2008, 14:23 »
I think I will stick to the user level permission. Added to my ToDo

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline kylematthews

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Rights to Downloads Management
« Reply #12 on: 14 April 2009, 19:52 »
Try as I might, I can't find a single reference of "Ryan's Role Manager" other than right in this post.

Is there something I'm missing?

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #13 on: 15 April 2009, 00:40 »
The user level will be more refined in the upcoming version of WP-DownloadManager.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline kylematthews

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Rights to Downloads Management
« Reply #14 on: 15 April 2009, 02:17 »
So is there no way at the moment to apply this? I have added the downloads cap in wp-downloadsmanager.php, deactivated and activated the plugin - but my authors still can't access the downloads area in wp-admin.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #15 on: 15 April 2009, 02:46 »
You mean rights to access the downloadmanager in wp-admin or rights to download the file? What is the code you used?

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline kylematthews

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Rights to Downloads Management
« Reply #16 on: 17 April 2009, 02:39 »
Rights to access the downloadmanager in wp-admin.

I just used the code you mentioned here - http://forums.lesterchan.net/index.php/topic,1628.msg14736.html#msg14736 (although on the wp-downloadmanager.php file).

But after deactivating and reactivating the plugin, authors still have no access to downloadmanager in wp-admin.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Rights to Downloads Management
« Reply #17 on: 17 April 2009, 07:16 »
That code is rights to download the file not access WP-Admin of WP-DownloadManager.

In wp-downloadmanager.php

Find:
Code: [Select]
// Set 'manage_downloads' Capabilities To Administrator
$role = get_role('administrator');
if(!$role->has_cap('manage_downloads')) {
$role->add_cap('manage_downloads');
}

Add below it:
Code: [Select]
// Set 'manage_downloads' Capabilities To Author
$role = get_role('author');
if(!$role->has_cap('manage_downloads')) {
$role->add_cap('manage_downloads');
}

Deactivate and activate the plugin again.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline kylematthews

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Rights to Downloads Management
« Reply #18 on: 17 April 2009, 14:44 »
Thank you!

Offline wangkai

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Rights to Downloads Management
« Reply #19 on: 16 September 2009, 01:49 »
That code is rights to download the file not access WP-Admin of WP-DownloadManager.

In wp-downloadmanager.php

Find:
Code: [Select]
// Set 'manage_downloads' Capabilities To Administrator
$role = get_role('administrator');
if(!$role->has_cap('manage_downloads')) {
$role->add_cap('manage_downloads');
}

Add below it:
Code: [Select]
// Set 'manage_downloads' Capabilities To Author
$role = get_role('author');
if(!$role->has_cap('manage_downloads')) {
$role->add_cap('manage_downloads');
}

Deactivate and activate the plugin again.


I'd like to add a role of Beta Tester Only which is set apart from registered user (so its not an 'at least' role). Would this code be it?