Jump to content

Enabling ability to access trash for a Role


evanmcd
 Share

Recommended Posts

Hi all,

Does anyone know of a way to create a Role that can be given access to the Trash?

In normal circumstances, I agree with Ryan's decision to allow it only to Superusers, however I'm using PW as a the admin for a contest app on Facebook, and I need the company we have handling moderation of the submissions to be able to access the Trash.

Any ideas welcome!

Thanks.

Link to comment
Share on other sites

We don't want people to have access to the trash so they can't irresponsibility delete some important thing, right? What about giving them access only to recover things?

Link to comment
Share on other sites

It's not possible at present to give other roles access to the trash. That is an area where access inheritance doesn't exist (since it's an anything-goes bucket 'o trash). It becomes a can of worms when considered in light of access control. Do you really want someone digging in your trash? :)

A couple of alternatives:

1. Consider that /trash/ is just a page with children (albeit a smelly one). But you can just as easily make your own trash page. Rather than deleting pages, ask them to change the parent to your trash page (or drag their page into it). So long as they have access, they should be able to drag stuff in and out of it. If they pages they are dragging into it use templates that inherit access, and you make your trash page not viewable to guest, then any pages dragged into it are essentially removed from the site.

2. It sounds like you might be using trash as an unpublished area. If that's the case, I recommend just using PW's Unpublished status rather than the trash.

3. If you still want to use PW's system trash, you can create a template or module that lets them undelete stuff they've deleted. This isn't complete, but gives the basic idea:

$deletedPages = $pages->get('/trash/')->find("modified_users_id=$user, include=all"); 

if(count($input->post->restore)) {
 $parent = $pages->get('/some/parent/'); 
 foreach($deletedPages as $p) {
   if(in_array($p->id, $input->post->restore)) {
     $p->parent = $parent; 
     $p->save();
     echo "<li>Restored: {$p->url}</li>";
   }
 }
} 

// display list of their deleted pages and give them a 'restore' checkbox
foreach($deletedPages as $p) {
 echo "<li><label><input type='checkbox' name='restore[]' value='{$p->id}' /> {$p->title}</label></li>";
}

  • Like 1
Link to comment
Share on other sites

Thanks Ryan, I think I will go for option 1. I hadn't thought of that, and it seems like a fine solution for this.

We are also using the published status, so it can't do double duty in this case. This is an odd situation in which we have an agency administering the contest that uses subcontractors to actually review the submissions. We want the agency to be able to see and remove from trash (to keep tabs on their contractors), but of course we don't want the agency doing much else in the admin.

Anyway, thanks again. I'll post back here with any tips in case someone else with a similar need stumbles across this post later on.

Cheers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...