It's a difficult issue. There's no way I know of to have PHP code in MODX pop up a dialog. All you can do is inject JS code into the page that will execute on some page event (like a click). You shouldn't have to save the resource yourself, since MODX is happy to do it for you. The question is how to inject your pop-up into the equation.
One solution is to catch the process even earlier when the user clicks on the "Save" button. Your JS code can intercept that click and (if the user says no) prevent the default action of the button, or (if the user says Yes) return without doing anything and let MODX continue saving the resource.
You'd want to have your plugin inject your JS code in OnDocFormRender or OnDocFormPrerender, because it needs to be there before "Save" is clicked. On the other hand, the logic for presenting the confirm button would have to all be in the JS code since the information you need to make that decision won't be there until the "Save" button is actually pressed.
This would be the OnDocFormRender (or Prerender) code:
if ($mode == modSystemEvent::MODE_UPD) {
$modx->regClientStartupScript('path/to/js/file.js');
}
return ''
That's all the PHP code you'd have.
I can't think of any way to do it using either of the DocFormSave events since there's no good way to interact with the user in them.
[ed. note: BobRay last edited this post 5 years, 10 months ago.]