diff options
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | doc/to_do_code.bb | 2 | ||||
-rwxr-xr-x | include/items.php | 65 | ||||
-rw-r--r-- | include/zot.php | 45 | ||||
-rw-r--r-- | install/schema_mysql.sql | 2 | ||||
-rw-r--r-- | install/schema_postgres.sql | 2 | ||||
-rw-r--r-- | install/update.php | 12 | ||||
-rw-r--r-- | mod/connedit.php | 12 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 1 | ||||
-rwxr-xr-x | view/tpl/abook_edit.tpl | 8 |
11 files changed, 128 insertions, 25 deletions
@@ -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. diff --git a/doc/to_do_code.bb b/doc/to_do_code.bb index 4e6f655e2..3a54a5357 100644 --- a/doc/to_do_code.bb +++ b/doc/to_do_code.bb @@ -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
diff --git a/include/items.php b/include/items.php index 229512ead..cef303d2e 100755 --- a/include/items.php +++ b/include/items.php @@ -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,11 +3294,71 @@ 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; + } + } + + 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; } diff --git a/include/zot.php b/include/zot.php index 02ac1301b..66156b4e0 100644 --- a/include/zot.php +++ b/include/zot.php @@ -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,10 +1699,15 @@ 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']; - 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']); + 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']); @@ -1715,18 +1726,24 @@ 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($item_result['success']) { - $item_id = $item_result['item_id']; - $parr = array('item_id' => $item_id,'item' => $arr,'sender' => $sender,'channel' => $channel); - call_hooks('activity_received',$parr); - // don't add a source route if it's a relay or later recipients will get a route mismatch - if(! $relay) - add_source_route($item_id,$sender['hash']); + + 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); + call_hooks('activity_received',$parr); + // don't add a source route if it's a relay or later recipients will get a route mismatch + if(! $relay) + add_source_route($item_id,$sender['hash']); + } + $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); } - $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) { diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 8aca3dff4..4d0da366f 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -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`), diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index a68c7d12b..a58e5a2ae 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -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"); diff --git a/install/update.php b/install/update.php index 62c976218..fb49e9a16 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1143 ); +define( 'UPDATE_VERSION' , 1144 ); /** * @@ -1656,4 +1656,14 @@ function update_r1142() { return UPDATE_FAILED; +} + +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; + }
\ No newline at end of file diff --git a/mod/connedit.php b/mod/connedit.php index cb524547c..fd7533711 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -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, diff --git a/version.inc b/version.inc index f98eedbce..b06ac504d 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-06-26.1075 +2015-06-28.1077 diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index ad203867c..e53cc7ee1 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -2277,3 +2277,4 @@ nav .badge.mail-update:hover { .channels_ckbx, .pending_ckbx, .users_ckbx { margin-top: -5px !important; } + diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl index fb02ff8ed..10692856e 100755 --- a/view/tpl/abook_edit.tpl +++ b/view/tpl/abook_edit.tpl @@ -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}} |