Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active June 4, 2017 13:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save matdave/ce7535a41b546c694e06 to your computer and use it in GitHub Desktop.
Save matdave/ce7535a41b546c694e06 to your computer and use it in GitHub Desktop.
HideDeleted
<?php
/* Set plugin to run on "OnManagerPageBeforeRender"
*/
$user = $modx->getUser();
$restricted = true;
if($user) {
$restricted = (!$user->isMember(array('Administrator')));
}
if($restricted){
$modx->regClientStartupHTMLBlock('<style type="text/css">.deleted{display:none;}</style>');
}
<?php
/* First create a resource named "Trash Can" or whatever and set it to list access only
* Note the ID of that resource for the following plugin
* Set plugin to run on "OnDocFormDelete" and "OnResourceDelete"
*/
$trashcan = 33; //RESOURCE ID OF TRASHCAN
if(!empty($resource)){
if($resource->get('parent') != $trashcan && $id != $trashcan){
$resource->set('parent',$trashcan);
$resource->set('deleted',0);
$resource->set('published',0);
$resource->save();
}
if($id == $trashcan){
$resource->set('deleted',0);
$resource->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment