*
* This is the POST destination for most all locally posted
* text stuff. This function handles status, wall-to-wall status,
- * local comments, and remote coments - that are posted on this site
+ * local comments, and remote coments that are posted on this site
* (as opposed to being delivered in a feed).
* Also processed here are posts and comments coming through the
* statusnet/twitter API.
function item_post(&$a) {
- if((! local_user()) && (! remote_user()))
+ if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
return;
require_once('include/security.php');
$api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false);
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+ $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
/**
* Is this a reply to something?
$parid = 0;
$r = false;
- $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
-
if($parent || $parent_uri) {
if(! x($_REQUEST,'type'))
$post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
$app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : '');
- if(! can_write_wall($a,$profile_uid)) {
+ $allow_moderated = false;
+
+ // here is where we are going to check for permission to post a moderated comment.
+
+ // First check that the parent exists and it is a wall item.
+
+ if((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) {
+ notice( t('Permission denied.') . EOL) ;
+ if(x($_REQUEST,'return'))
+ goaway($a->get_baseurl() . "/" . $return_path );
+ killme();
+ }
+
+ // Now check that it is a page_type of PAGE_BLOG, and that valid personal details
+ // have been provided, and run any anti-spam plugins
+
+
+ // TODO
+
+
+
+
+ if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
$datarray['thr-parent'] = $thr_parent;
$datarray['postopts'] = '';
$datarray['origin'] = $origin;
+ $datarray['moderated'] = $allow_moderated;
/**
* These fields are for the convenience of plugins...
call_hooks('post_local',$datarray);
+ if(x($datarray,'cancel')) {
+ logger('mod_item: post cancelled by plugin.');
+ if($return_path) {
+ goaway($a->get_baseurl() . "/" . $return_path);
+ }
+
+ $json = array('cancel' => 1);
+ if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
+ $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+
+ echo json_encode($json);
+ killme();
+ }
+
if($orig_post) {
$r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
- `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin` )
- VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d )",
+ `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated` )
+ VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d )",
dbesc($datarray['guid']),
intval($datarray['uid']),
dbesc($datarray['type']),
intval($datarray['pubmail']),
dbesc($datarray['attach']),
intval($datarray['bookmark']),
- intval($datarray['origin'])
+ intval($datarray['origin']),
+ intval($datarry['moderated'])
);
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",