a couple of bugfixes from earlier checkins and implementation of source tags

This commit is contained in:
redmatrix 2016-05-01 22:45:38 -07:00
parent bd2f11ed8b
commit a10fe5f13e
5 changed files with 50 additions and 7 deletions

View file

@ -7,7 +7,7 @@ class Sources extends \Zotlabs\Web\Controller {
function post() { function post() {
if(! local_channel()) if(! local_channel())
return; return;
if(! feature_enabled(local_channel(),'channel_sources')) if(! feature_enabled(local_channel(),'channel_sources'))
return ''; return '';
@ -17,6 +17,7 @@ class Sources extends \Zotlabs\Web\Controller {
$words = $_REQUEST['words']; $words = $_REQUEST['words'];
$frequency = $_REQUEST['frequency']; $frequency = $_REQUEST['frequency'];
$name = $_REQUEST['name']; $name = $_REQUEST['name'];
$tags = $_REQUEST['tags'];
$channel = \App::get_channel(); $channel = \App::get_channel();
@ -36,14 +37,15 @@ class Sources extends \Zotlabs\Web\Controller {
notice ( t('Failed to create source. No channel selected.') . EOL); notice ( t('Failed to create source. No channel selected.') . EOL);
return; return;
} }
if(! $source) { if(! $source) {
$r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt ) $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt, src_tag )
values ( %d, '%s', '%s', '%s' ) ", values ( %d, '%s', '%s', '%s', '%s' ) ",
intval(local_channel()), intval(local_channel()),
dbesc($channel['channel_hash']), dbesc($channel['channel_hash']),
dbesc($xchan), dbesc($xchan),
dbesc($words) dbesc($words),
dbesc($tags)
); );
if($r) { if($r) {
info( t('Source created.') . EOL); info( t('Source created.') . EOL);
@ -51,9 +53,10 @@ class Sources extends \Zotlabs\Web\Controller {
goaway(z_root() . '/sources'); goaway(z_root() . '/sources');
} }
else { else {
$r = q("update source set src_xchan = '%s', src_patt = '%s' where src_channel_id = %d and src_id = %d", $r = q("update source set src_xchan = '%s', src_patt = '%s', src_tag = '%s' where src_channel_id = %d and src_id = %d",
dbesc($xchan), dbesc($xchan),
dbesc($words), dbesc($words),
dbesc($tags),
intval(local_channel()), intval(local_channel()),
intval($source) intval($source)
); );
@ -62,6 +65,7 @@ class Sources extends \Zotlabs\Web\Controller {
} }
} }
} }
@ -105,6 +109,8 @@ class Sources extends \Zotlabs\Web\Controller {
'$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'), '$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'),
'$words' => array( 'words', t('Only import content with these words (one per line)'),'',t('Leave blank to import all public content')), '$words' => array( 'words', t('Only import content with these words (one per line)'),'',t('Leave blank to import all public content')),
'$name' => array( 'name', t('Channel Name'), '', ''), '$name' => array( 'name', t('Channel Name'), '', ''),
'$tags' => array('tags', t('Add the following tags to posts imported from this source (comma separated)','','')),
'$submit' => t('Submit') '$submit' => t('Submit')
)); ));
return $o; return $o;
@ -138,6 +144,7 @@ class Sources extends \Zotlabs\Web\Controller {
'$words' => array( 'words', t('Only import content with these words (one per line)'),$r[0]['src_patt'],t('Leave blank to import all public content')), '$words' => array( 'words', t('Only import content with these words (one per line)'),$r[0]['src_patt'],t('Leave blank to import all public content')),
'$xchan' => $r[0]['src_xchan'], '$xchan' => $r[0]['src_xchan'],
'$abook' => $x[0]['abook_id'], '$abook' => $x[0]['abook_id'],
'$tags' => array('tags', t('Add the following tags to posts imported from this source (comma separated)'),$r[0]['src_tag'],''),
'$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''), '$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''),
'$submit' => t('Submit') '$submit' => t('Submit')
)); ));

View file

@ -3400,6 +3400,37 @@ function tgroup_check($uid,$item) {
*/ */
function start_delivery_chain($channel, $item, $item_id, $parent) { function start_delivery_chain($channel, $item, $item_id, $parent) {
$sourced = check_item_source($channel['channel_id'],$item);
if($sourced) {
$r = q("select * from source where src_channel_id = %d and ( src_xchan = '%s' or src_xchan = '*' ) limit 1",
intval($channel['channel_id']),
dbesc(($item['source_xchan']) ? $item['source_xchan'] : $item['owner_xchan'])
);
if($r) {
$t = trim($r[0]['src_tag']);
if($t) {
$tags = explode(',',$t);
if($tags) {
foreach($tags as $tt) {
$tt = trim($tt);
if($tt) {
q("insert into term (uid,oid,otype,type,term,url)
values(%d,%d,%d,%d,'%s','%s') ",
intval($channel['channel_id']),
intval($item_id),
intval(TERM_OBJ_POST),
intval(TERM_UNKNOWN),
dbesc($tt),
dbesc(z_root() . '/search?f=&tag=' . urlencode($tt))
);
}
}
}
}
}
}
// Change this copy of the post to a forum head message and deliver to all the tgroup members // Change this copy of the post to a forum head message and deliver to all the tgroup members
// also reset all the privacy bits to the forum default permissions // also reset all the privacy bits to the forum default permissions
@ -3459,6 +3490,9 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
intval($item_id) intval($item_id)
); );
if($r) if($r)
proc_run('php','include/notifier.php','tgroup',$item_id); proc_run('php','include/notifier.php','tgroup',$item_id);
else { else {

View file

@ -122,7 +122,7 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
function purify_html($s, $allow_position) { function purify_html($s, $allow_position = false) {
require_once('library/HTMLPurifier.auto.php'); require_once('library/HTMLPurifier.auto.php');
require_once('include/html2bbcode.php'); require_once('include/html2bbcode.php');

View file

@ -7,6 +7,7 @@
<input type="hidden" name="source" value="{{$id}}" /> <input type="hidden" name="source" value="{{$id}}" />
<input type="hidden" id="id_abook" name="abook" value="{{$abook}}" /> <input type="hidden" id="id_abook" name="abook" value="{{$abook}}" />
{{include file="field_input.tpl" field=$name}} {{include file="field_input.tpl" field=$name}}
{{include file="field_input.tpl" field=$tags}}
{{include file="field_textarea.tpl" field=$words}} {{include file="field_textarea.tpl" field=$words}}
<div class="sources-submit-wrapper" > <div class="sources-submit-wrapper" >

View file

@ -6,6 +6,7 @@
<form action="sources" method="post"> <form action="sources" method="post">
<input type="hidden" id="id_abook" name="abook" value="{{$abook}}" /> <input type="hidden" id="id_abook" name="abook" value="{{$abook}}" />
{{include file="field_input.tpl" field=$name}} {{include file="field_input.tpl" field=$name}}
{{include file="field_input.tpl" field=$tags}}
{{include file="field_textarea.tpl" field=$words}} {{include file="field_textarea.tpl" field=$words}}
<div class="sources-submit-wrapper" > <div class="sources-submit-wrapper" >