new feature: 'suppress_duplicates' issue #146 triggered with less than two minutes between posts having identical content.
This commit is contained in:
parent
4f81d64517
commit
8f94c721bf
@ -60,6 +60,7 @@ function get_features() {
|
||||
array('content_encrypt', t('Even More Encryption'), t('Allow optional encryption of content end-to-end with a shared secret key'),false),
|
||||
array('consensus_tools', t('Enable Voting Tools'), t('Provide a class of post which others can vote on'),false),
|
||||
array('delayed_posting', t('Delayed Posting'), t('Allow posts to be published at a later date'),false),
|
||||
array('suppress_duplicates', t('Suppress Duplicate Posts/Comments'), t('Prevent posts with identical content to be published with less than two minutes in between submissions.'),true),
|
||||
|
||||
),
|
||||
|
||||
|
@ -395,9 +395,10 @@ function admin_page_site(&$a) {
|
||||
}
|
||||
|
||||
/* Banner */
|
||||
|
||||
$banner = get_config('system', 'banner');
|
||||
if($banner == false)
|
||||
$banner = 'red';
|
||||
if($banner === false)
|
||||
$banner = get_config('system','sitename');
|
||||
|
||||
$banner = htmlspecialchars($banner);
|
||||
|
||||
|
20
mod/item.php
20
mod/item.php
@ -703,6 +703,10 @@ function item_post(&$a) {
|
||||
$plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$datarray['aid'] = $channel['channel_account_id'];
|
||||
$datarray['uid'] = $profile_uid;
|
||||
|
||||
@ -781,6 +785,22 @@ function item_post(&$a) {
|
||||
if($orig_post)
|
||||
$datarray['edit'] = true;
|
||||
|
||||
|
||||
|
||||
if(feature_enabled($profile_uid,'suppress_duplicates')) {
|
||||
|
||||
$z = q("select created from item where uid = %d and body = '%s'",
|
||||
intval($profile_uid),
|
||||
dbesc($body)
|
||||
);
|
||||
|
||||
if($z && $z[0]['created'] > datetime_convert('UTC','UTC', 'now - 2 minutes')) {
|
||||
$datarray['cancel'] = 1;
|
||||
notice( t('Duplicate post suppressed.') . EOL);
|
||||
logger('Duplicate post. Faking plugin cancel.');
|
||||
}
|
||||
}
|
||||
|
||||
call_hooks('post_local',$datarray);
|
||||
|
||||
if(x($datarray,'cancel')) {
|
||||
|
Reference in New Issue
Block a user