Use the newspublisher snippet.
Use a different chunk for the form. They are all the same fields but you don’t need a content or introtext area.
Then set the fields in the array to reference, unpublished. -- or even a certain folder so you can check it for all submissions in the document tree in the manager. Then you can can check them before they are published. Ah heck, here’s the snippet I modified...
I didn’t use a chunk, but just changed the form in the snippet. I also added a dropdownbox for the folders I use for link topics. You will certainly have to take that out I’d think, or change it to reflect your own.
Right now I’m using this on a privateweb page on the frontend. I have no idea how safe it is for anonymous use, but I don’t think I changed anything significant...?
Around line 162 is where the fields are to insert into the database.
/* NewsPublisher for MODx Created by Raymond Irving, August 2005 Patch for 's and redirect to new post by Mark Kaplan, October 2005
Publish news articles directly from the web
Parameters:
&folder - folder id where comments are stored
&makefolder - set to 1 to automatically convert the parent document to a folder. Defaults to 0
&postid - document id to load after posting news item. Defaults to the page created
&canpost - comma delimitted web groups that can post comments. leave blank for public posting
&badwords - comma delimited list of words not allowed in post
&template - name of template to use for news post
&headertpl - header template (chunk name) to be inserted at the begining of the news content
&footertpl - footer template (chunk name) to be inserted at the end of the news content
&formtpl - form template (chunk name)
&rtcontent - name of a richtext content form field
&rtsummary - name of a richtext summary form field
&showinmenu - sets the flag to true or false (1|0) as to whether or not it shows in the menu. defaults to false (0)
&aliastitle - set to 1 to use page title as alias suffix. Defaults to 0 - date created.
&clearcache - when set to 1 the system will automatically clear the site cache after publishing an article.
Version 1.2 Beta */
// get user groups that can post articles
$postgrp = isset($canpost) ? explode(",",$canpost):array();
$allowAnyPost = count($postgrp)==0 ? true : false;
// get clear cache
$clearcache = isset($clearcache) ? 1:0;
// get alias title
$aliastitle = isset($aliastitle) ? 1:0;
// get folder id where we should store articles
// else store in current document
// e.s. - hardcode dropdown list instead for selected folders
//$folder = isset($folder) ? intval($folder):$modx->documentIdentifier;
$tbl = $modx->getFullTableName("site_content");
$atables = "id, pagetitle";
$awhereclaws = "parent = 16 AND isfolder = 1 AND deleted = 0 AND hidemenu = 0";
$aorderby = "pagetitle DESC";
$alimit = "";
$sqlgetfolders = $modx->db->select($atables, $tbl, $awhereclaws, $aorderby, $alimit);
if ($sqlgetfolders){
$topics .= "<select name='folder'>";
while ($row = $etomite->fetchRow($sqlgetfolders)) {
$topics .= "<option value ='".$row['id']."'>".$row['pagetitle']."</option>";
}
$topics .= "</select>";
}
// set rich text content field
$rtcontent = isset($rtcontent) ? $rtcontent:'content';
// set rich text summary field
$rtsummary = isset($rtsummary) ? $rtsummary:'introtext';
// get header
$header = isset($headertpl) ? "{{".$headertpl."}}":'';
// get footer
$footer = isset($footertpl) ? "{{".$footertpl."}}":'';
// get postback status
$isPostBack = isset($_POST['NewsPublisherForm']) ? true:false;
// get badwords
if(isset($badwords)) {
$badwords = str_replace(' ','', $badwords);
$badwords = "/".str_replace(',','|', $badwords)."/i";
}
// get menu status
$hidemenu = isset($showinmenu) && $showinmenu==1 ? 0 : 1;
// get template
$template = isset($template) ? $modx->db->getValue('SELECT id FROM '.$modx->getFullTableName('site_templates').' WHERE templatename=\''.mysql_escape_string($template).'\''):$modx->config['default_template'];
// get form template
if(isset($formtpl)) $formTpl = $modx->getChunk($formtpl);
if(empty($formTpl)) $formTpl = <<<FOR
<form name="NewsPublisher" method="post">
<input name="NewsPublisherForm" type="hidden" value="on" />
<table class="form" border="0" width="100%">
<tr>
<td width="29%" class="formtags">
Page title: </td>
<td width="71%"> <input name="pagetitle" type="text" size="40" value="[+pagetitle+]" /></td>
</tr>
<tr>
<td width="29%" class="formtags">
Long title: </td>
<td width="71%"> <input name="longtitle" type="text" size="40" value="[+longtitle+]" /></td>
</tr>
<tr>
<td width="29%" class="formtags">
Description: </td>
<td width="71%"> <input name="description" type="text" size="40" value="[+description+]" />
</td>
</tr>
<tr>
<td width="29%" class="formtags">
Weblink: </td>
<td width="71%"><input name="content" type="text" size="40" value="[+content+]" /> </td>
</tr>
<tr>
<td width="29%" class="formtags">
Link category: </td>
<td width="71%">$topics</td>
</tr>
</table>
<input name="send" type="submit" value="Create Web Link" />
</form>
FOR;
// switch block
switch ($isPostBack) {
case true: // process post back
// remove magic quotes from POST
if(get_magic_quotes_gpc()){
$_POST = array_map("stripslashes", $_POST);
}
if(trim($_POST['pagetitle'])=='') $modx->webAlert('Missing page title.');
elseif($_POST[$rtcontent]=='') $modx->webAlert('Missing news content.');
else {
// get created date
$createdon = time();
$user = $modx->getLoginUserName();
$userid = $modx->getLoginUserID();
if(!$user && $allowAnyPost) $user = 'anonymous';
// check if user has rights
if(!$allowAnyPost && !$modx->isMemberOfWebGroup($postgrp)) {
return 'You are not allowed to publish articles';
}
$allowedTags = '<p><br><a><i><em><b><blockquote><strong><pre><table><th><td><tr><img><span><div><h1><h2><h3><h4><h5><font><ul><ol><li><dl><dt><dd>';
// format content
$content = $modx->stripTags($_POST[$rtcontent],$allowedTags);
$content = str_replace('[+user+]',$user,$content);
$content = str_replace('[+createdon+]',strftime('%d-%b-%Y %H:%M',$createdon),$content);
foreach($_POST as $n=>$v) {
if(!empty($badwords)) $v = preg_replace($badwords,'[Filtered]',$v); // remove badwords
$v = $modx->stripTags(htmlspecialchars($v));
$v = str_replace("\n",'<br />',$v);
$content = str_replace('[+'.$n.'+]',$v,$content);
}
$title = mysql_escape_string($modx->stripTags($_POST['pagetitle']));
$longtitle = mysql_escape_string($modx->stripTags($_POST['longtitle']));
$description = mysql_escape_string($modx->stripTags($_POST['description']));
$introtext = mysql_escape_string($modx->stripTags($_POST[$rtsummary],$allowedTags));
$folder = mysql_escape_string($modx->stripTags($_POST['folder'])); //added for dropdown
// set menu index
$mnuidx = $modx->db->getValue('SELECT MAX(menuindex)+1 as \'mnuidx\' FROM '.$modx->getFullTableName('site_content').' WHERE parent=\''.$folder.'\'');
if($mnuidx<1) $mnuidx = 0;
// post news content
$flds = array(
'type' => 'reference',
'pagetitle' => $title,
'longtitle' => $longtitle,
'description'=> $description,
'introtext' => $introtext,
'alias' => $alias,
'parent' => $folder,
'createdon' => $createdon,
'createdby' => ($userid>0 ? $userid * -1:0),
'editedon' => '0',
'editedby' => '0',
'published' => '1',
'pub_date' => $pub_date,
'unpub_date' => $unpub_date,
'deleted' => '0',
'hidemenu' => '0',
'menuindex' => $mnuidx,
'template' => '0',
'content' => mysql_escape_string($header.$content.$footer)
);
$redirectid = $modx->db->insert($flds,$modx->getFullTableName('site_content'));
if(!empty($makefolder)) {
// convert parent into folder
$modx->db->update(array('isfolder'=>'1'),$modx->getFullTableName('site_content'),'id=\''.$folder.'\'');
}
// empty cache
if($clearcache==1){
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(); // first empty the cache
}
// get redirect/post id
$redirectid = $modx->db->getValue('SELECT id as \'redirectid\' FROM '.$modx->getFullTableName('site_content').' WHERE createdon=\''.$createdon.'\'');
$postid = isset($postid) ? $postid:$redirectid;
// redirect to post id
$modx->sendRedirect($modx->makeUrl($postid));
}
default: // display news form
// check if user has rights to post comments
if(!$allowAnyPost && !$modx->isMemberOfWebGroup($postgrp)) {
$formTpl = '';
}
else {
foreach($_POST as $n=>$v) {
$formTpl = str_replace('[+'.$n.'+]',$v,$formTpl);
}
}
// return form
return $message.$formTpl;
break;
}
You should set ’published’ => ’1’ on line 175 to 0 if you want it to be unpublished until you approve it.