function emptyCache() {
global $modx;
include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
}if($mode=="new"){
$wuid = $username;
$table_name = $modx->getFullTableName( 'site_content' );
$fields = array(
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => $wuid,
'alias' => $wuid,
'published' => '1', //is the page published?
'parent' => '16', //what is the parent of this new page?
'isfolder' => '0', // lets make this a folder
'template' => '15', //type template id here
'cacheable' => '0',
'createdby' => $wuid,
'createdon' => time(),
'editedon' => time(),
'publishedon' => time(),
'hidemenu' => '1'
);
$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
//Create placeholder and put the id in a session to use for mail or whatever.
$_SESSION['eigenpaginaid'] = $modx->db->getInsertId();
$modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
return;
}
function emptyCache() {
global $modx;
include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
return;
}
public function forward($postId) {
if (empty($postId)) {
$postId = $this->existing? $this->existing : $this->resource->get('id');
}
/* clear cache on new resource */
if (! $this->existing) {
$cacheManager = $this->modx->getCacheManager();
$cacheManager->clearCache(array (
"{$this->resource->context_key}/",
),
array(
'objects' => array('modResource', 'modContext', 'modTemplateVarResource'),
'publishing' => true
)
);
}
$_SESSION['np_resource_id'] = $this->resource->get('id');
$goToUrl = $this->modx->makeUrl($postId);
/* redirect to post id */
/* ToDo: The next two lines can probably be removed once makeUrl() and sendRedirect() are updated */
$controller = $this->modx->getOption('request_controller',null,'index.php');
$goToUrl = $controller . '?id=' . $postId;
$this->modx->sendRedirect($goToUrl);
}if($mode=="new"){
$wuid = $username;
$table_name = $modx->getFullTableName( 'site_content' );
$fields = array(
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => $wuid,
'alias' => $wuid,
'published' => '1', //is the page published?
'parent' => '16', //what is the parent of this new page?
'isfolder' => '0', // lets make this a folder
'template' => '15', //type template id here
'cacheable' => '0',
'createdby' => $wuid,
'createdon' => time(),
'editedon' => time(),
'publishedon' => time(),
'hidemenu' => '1'
);
$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
//Create placeholder and put the id in a session to use for mail or whatever.
$_SESSION['eigenpaginaid'] = $modx->db->getInsertId();
$modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
return;
}$modx->sendRedirect('index.php?id='. $forwardId);if($mode=="new"){
$wuid = $username;
$table_name = $modx->getFullTableName( 'site_content' );
$fields = array(
'type' => 'document',
'contentType' => 'text/html',
'pagetitle' => $wuid,
'alias' => $wuid,
'published' => '1', //is the page published?
'parent' => '16', //what is the parent of this new page?
'isfolder' => '0', // lets make this a folder
'template' => '15', //type template id here
'cacheable' => '0',
'createdby' => $wuid,
'createdon' => time(),
'editedon' => time(),
'publishedon' => time(),
'hidemenu' => '1'
);
$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
//Create placeholder and put the id in a session to use for mail or whatever.
$_SESSION['eigenpaginaid'] = $modx->db->getInsertId();
$modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
emptyCache();
return;
}
function emptyCache() {
global $modx;
include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
return;
} // $fields holds the resource fields as in your code + this one:
$fields['syncsite'] = true;
$response = $modx->runProcessor('resource/create', $fields);
if ($response->isError()) {
if ($response->hasFieldErrors()) {
$fieldErrors = $response->getAllErrors();
$errorMessage = implode("\n", $fieldErrors);
} else {
$errorMessage = 'An error occurred: ' . $response->getMessage();
}
$this->setError($errorMessage);
return '';
} else {
$object = $response->getObject();
$postId = $object['id'];
}
$controller =$modx->getOption('request_controller',null,'index.php');
$goToUrl = $controller . '?id=' . $postId;
$modx->sendRedirect($goToUrl);