aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Sources.php19
-rwxr-xr-xinclude/items.php34
-rw-r--r--include/text.php2
-rw-r--r--view/tpl/sources_edit.tpl1
-rw-r--r--view/tpl/sources_new.tpl1
5 files changed, 50 insertions, 7 deletions
diff --git a/Zotlabs/Module/Sources.php b/Zotlabs/Module/Sources.php
index cca9e5ebf..ef32991ee 100644
--- a/Zotlabs/Module/Sources.php
+++ b/Zotlabs/Module/Sources.php
@@ -7,7 +7,7 @@ class Sources extends \Zotlabs\Web\Controller {
function post() {
if(! local_channel())
return;
-
+
if(! feature_enabled(local_channel(),'channel_sources'))
return '';
@@ -17,6 +17,7 @@ class Sources extends \Zotlabs\Web\Controller {
$words = $_REQUEST['words'];
$frequency = $_REQUEST['frequency'];
$name = $_REQUEST['name'];
+ $tags = $_REQUEST['tags'];
$channel = \App::get_channel();
@@ -36,14 +37,15 @@ class Sources extends \Zotlabs\Web\Controller {
notice ( t('Failed to create source. No channel selected.') . EOL);
return;
}
-
+
if(! $source) {
- $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt )
- values ( %d, '%s', '%s', '%s' ) ",
+ $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt, src_tag )
+ values ( %d, '%s', '%s', '%s', '%s' ) ",
intval(local_channel()),
dbesc($channel['channel_hash']),
dbesc($xchan),
- dbesc($words)
+ dbesc($words),
+ dbesc($tags)
);
if($r) {
info( t('Source created.') . EOL);
@@ -51,9 +53,10 @@ class Sources extends \Zotlabs\Web\Controller {
goaway(z_root() . '/sources');
}
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($words),
+ dbesc($tags),
intval(local_channel()),
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.'),
'$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'), '', ''),
+ '$tags' => array('tags', t('Add the following tags to posts imported from this source (comma separated)','','')),
+
'$submit' => t('Submit')
));
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')),
'$xchan' => $r[0]['src_xchan'],
'$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'], ''),
'$submit' => t('Submit')
));
diff --git a/include/items.php b/include/items.php
index 2720dd841..3649ef8c9 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3400,6 +3400,37 @@ function tgroup_check($uid,$item) {
*/
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
// 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)
);
+
+
+
if($r)
proc_run('php','include/notifier.php','tgroup',$item_id);
else {
diff --git a/include/text.php b/include/text.php
index cf2f777aa..66a49d4b5 100644
--- a/include/text.php
+++ b/include/text.php
@@ -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('include/html2bbcode.php');
diff --git a/view/tpl/sources_edit.tpl b/view/tpl/sources_edit.tpl
index a5b384ca3..61f6e8cb0 100644
--- a/view/tpl/sources_edit.tpl
+++ b/view/tpl/sources_edit.tpl
@@ -7,6 +7,7 @@
<input type="hidden" name="source" value="{{$id}}" />
<input type="hidden" id="id_abook" name="abook" value="{{$abook}}" />
{{include file="field_input.tpl" field=$name}}
+{{include file="field_input.tpl" field=$tags}}
{{include file="field_textarea.tpl" field=$words}}
<div class="sources-submit-wrapper" >
diff --git a/view/tpl/sources_new.tpl b/view/tpl/sources_new.tpl
index 3c8a54373..bbc22df84 100644
--- a/view/tpl/sources_new.tpl
+++ b/view/tpl/sources_new.tpl
@@ -6,6 +6,7 @@
<form action="sources" method="post">
<input type="hidden" id="id_abook" name="abook" value="{{$abook}}" />
{{include file="field_input.tpl" field=$name}}
+{{include file="field_input.tpl" field=$tags}}
{{include file="field_textarea.tpl" field=$words}}
<div class="sources-submit-wrapper" >