no this isn't it. well ok, it's part of it, but not the important part. it's still pretty cool.

This commit is contained in:
redmatrix 2015-06-28 21:16:56 -07:00
parent 1ee1b6a334
commit de13497333
11 changed files with 128 additions and 25 deletions

View File

@ -49,7 +49,7 @@ define ( 'PLATFORM_NAME', 'redmatrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1143 );
define ( 'DB_UPDATE_VERSION', 1144 );
/**
* @brief Constant with a HTML line break.

View File

@ -4,7 +4,7 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]Documentation - see Red Documentation Project To-Do List[/li]
[li]Include TOS link in registration/verification email[/li]
[li]forum widget with unread counts[/li]
[li]forum widget with unread counts (requires the DB schema changes from v3/hubzilla to be viable)[/li]
[li]Create bug tracker module[/li]
[li]translation plugins - moses or apertium[/li]
[li]Infinite scroll improvements (i.e. embedded page links) see http://scrollsample.appspot.com/items

View File

@ -3284,8 +3284,7 @@ function check_item_source($uid, $item) {
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain($text);
/** @BUG $items is undefined, should this be $item? */
$tags = ((count($items['term'])) ? $items['term'] : false);
$tags = ((count($item['term'])) ? $item['term'] : false);
$words = explode("\n",$r[0]['src_patt']);
if($words) {
@ -3295,7 +3294,9 @@ function check_item_source($uid, $item) {
if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
return true;
}
if(stristr($text,$word) !== false)
elseif((strpos($word,'/') === 0) && preg_match($word,$body))
return true;
elseif(stristr($text,$word) !== false)
return true;
}
}
@ -3303,6 +3304,64 @@ function check_item_source($uid, $item) {
return false;
}
function post_is_importable($item,$abook) {
if(! $abook)
return true;
if(! $item)
return false;
if((! $abook['abook_incl']) && (! $abook['abook_excl']))
return true;
require_once('include/html2plain.php');
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain($text);
$tags = ((count($item['term'])) ? $item['term'] : false);
// exclude always has priority
$exclude = (($abook['abook_excl']) ? explode("\n",$abook['abook_excl']) : null);
if($exclude) {
foreach($exclude as $word) {
$word = trim($word);
if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t)
if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
return false;
}
elseif((strpos($word,'/') === 0) && preg_match($word,$body))
return false;
elseif(stristr($text,$word) !== false)
return false;
}
}
$include = (($abook['abook_incl']) ? explode("\n",$abook['abook_incl']) : null);
if($include) {
foreach($include as $word) {
$word = trim($word);
if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t)
if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
return true;
}
elseif((strpos($word,'/') === 0) && preg_match($word,$body))
return true;
elseif(stristr($text,$word) !== false)
return true;
}
}
else {
return true;
}
return false;
}
function mail_store($arr) {

View File

@ -1654,6 +1654,12 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
}
}
$ab = q("select abook.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and (abook_flags & %d) = 0",
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
);
$abook = (($ab) ? $ab[0] : null);
if($arr['item_restrict'] & ITEM_DELETED) {
// remove_community_tag is a no-op if this isn't a community tag activity
@ -1693,11 +1699,16 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
elseif($arr['edited'] > $r[0]['edited']) {
$arr['id'] = $r[0]['id'];
$arr['uid'] = $channel['channel_id'];
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
}
else {
update_imported_item($sender,$arr,$channel['channel_id']);
$result[] = array($d['hash'],'updated',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
if(! $relay)
add_source_route($item_id,$sender['hash']);
}
}
else {
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
// We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
@ -1716,8 +1727,13 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
if(check_item_source($arr['uid'], $arr))
call_hooks('post_local', $arr);
$item_result = item_store($arr);
$item_id = 0;
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
$result[] = array($d['hash'],'post ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
}
else {
$item_result = item_store($arr);
if($item_result['success']) {
$item_id = $item_result['item_id'];
$parr = array('item_id' => $item_id,'item' => $arr,'sender' => $sender,'channel' => $channel);
@ -1728,6 +1744,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
}
$result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
}
}
if($relay && $item_id) {
logger('process_delivery: invoking relay');

View File

@ -20,6 +20,8 @@ CREATE TABLE IF NOT EXISTS `abook` (
`abook_dob` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`abook_flags` int(11) NOT NULL DEFAULT '0',
`abook_profile` char(64) NOT NULL DEFAULT '',
`abook_incl` TEXT NOT NULL DEFAULT '',
`abook_excl` TEXT NOT NULL DEFAULT '',
PRIMARY KEY (`abook_id`),
KEY `abook_account` (`abook_account`),
KEY `abook_channel` (`abook_channel`),

View File

@ -14,6 +14,8 @@ CREATE TABLE "abook" (
"abook_dob" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"abook_flags" bigint NOT NULL DEFAULT '0',
"abook_profile" char(64) NOT NULL DEFAULT '',
"abook_incl" TEXT NOT NULL DEFAULT '',
"abook_excl" TEXT NOT NULL DEFAULT '',
PRIMARY KEY ("abook_id")
);
create index "abook_account" on abook ("abook_account");

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1143 );
define( 'UPDATE_VERSION' , 1144 );
/**
*
@ -1657,3 +1657,13 @@ function update_r1142() {
}
function update_r1143() {
$r1 = q("ALTER TABLE abook ADD abook_incl TEXT NOT NULL DEFAULT ''");
$r2 = q("ALTER TABLE abook ADD abook_excl TEXT NOT NULL DEFAULT '' ");
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View File

@ -101,6 +101,9 @@ function connedit_post(&$a) {
}
}
$abook_incl = escape_tags($_POST['abook_incl']);
$abook_excl = escape_tags($_POST['abook_excl']);
$hidden = intval($_POST['hidden']);
$priority = intval($_POST['poll']);
@ -190,12 +193,15 @@ function connedit_post(&$a) {
}
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d,
abook_incl = '%s', abook_excl = '%s'
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
intval($abook_flags),
dbesc($abook_incl),
dbesc($abook_excl),
intval($contact_id),
intval(local_channel())
);
@ -662,7 +668,9 @@ function connedit_content(&$a) {
'$lbl_slider' => t('Slide to adjust your degree of friendship'),
'$lbl_rating' => t('Rating (this information is public)'),
'$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'),
'$rating_txt' => $rating_text,
'$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')),
'$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')),
'$rating_text' => array('rating_text', t('Optionally explain your rating (this information is public)'),$rating_text,''),
'$rating' => $rating,
'$rating_val' => $rating_val,
'$slide' => $slide,

View File

@ -1 +1 @@
2015-06-26.1075
2015-06-28.1077

View File

@ -2277,3 +2277,4 @@ nav .badge.mail-update:hover {
.channels_ckbx, .pending_ckbx, .users_ckbx {
margin-top: -5px !important;
}

View File

@ -50,6 +50,9 @@
{{/if}}
{{include file="field_textarea.tpl" field=$incl}}
{{include file="field_textarea.tpl" field=$excl}}
{{if $rating}}
<h3>{{$lbl_rating}}</h3>
@ -58,6 +61,8 @@
{{/if}}
{{/if}}
@ -75,8 +80,7 @@
{{if $rating}}
{{if $notself}}
<h3 class="abook-rating-text-desc">{{$lbl_rating_txt}}</h3>
<textarea name="rating_text" id="rating-text" >{{$rating_txt}}</textarea>
{{include file="field_textarea.tpl" field=$rating_text}}
{{/if}}
{{/if}}