<?php
$id = $_POST["id"];
$title = $_POST["title"];
$copy = $_POST["copy"];
$resource = $modx->getObject("modResource", $id);
if(is_null($resource)) return "Failed to get resource $id.";
$resource->setContent($copy);
$resource->set("pagetitle", $title);
$resource->save();
$cm = $modx->getCacheManager();
$cm->refresh();
return 1;
?>
I mostly do it that way
Dave,
As far I can see, $resource->setContent($copy); is the same as $resource->set('content', $copy);
So it will not check your permissions.
However; modResource is extending from the cores' modAccessibleSimpleObject and as far my knowledge will go, is this a default interface that checks the permissions. So basically it should be checked I think.
Near to that;
Why do you not use FormIt and a hook to process the save of your resource? You can easily add validations to your form etc. because FormIt provides you that.I mostly do it that way
As Bert says, setContent just sets the content field and ia a common way to set an objects' content.. even for things like chunks where the content field is named "snippet" for legacy reasons, setContent sets the snippet field in that case.
The permissions of the user will be checked in retrieving the object (getObject) and calling the save method.