aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Willingham <beardyunixer@beardyunixer.com>2014-07-01 18:11:18 +0100
committerThomas Willingham <beardyunixer@beardyunixer.com>2014-07-01 18:11:18 +0100
commit67af6252c63bc508c4904632bf9e99dcb1b89cb9 (patch)
tree456ba79252049e9d7609f67a2c88518bdcc7f6ae /include
parent03e4240a223e87b86d8c5747492acdc79ef98931 (diff)
parent502b30e7689f28e72bebc35114f126db017bd456 (diff)
downloadvolse-hubzilla-67af6252c63bc508c4904632bf9e99dcb1b89cb9.tar.gz
volse-hubzilla-67af6252c63bc508c4904632bf9e99dcb1b89cb9.tar.bz2
volse-hubzilla-67af6252c63bc508c4904632bf9e99dcb1b89cb9.zip
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'include')
-rw-r--r--include/dir_fns.php2
-rwxr-xr-xinclude/text.php25
-rw-r--r--include/zot.php39
3 files changed, 42 insertions, 24 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 2f4830d05..1bc97cfec 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -157,7 +157,7 @@ function update_directory_entry($ud) {
$j = json_decode($x['body'],true);
if($j)
$success = true;
- $y = import_xchan($j,0);
+ $y = import_xchan($j,0,$ud);
}
if(! $success) {
$r = q("update updates set ud_last = '%s' where ud_addr = '%s'",
diff --git a/include/text.php b/include/text.php
index b5b8ec41a..6d6284ab2 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1237,6 +1237,27 @@ function format_hashtags(&$item) {
+function format_mentions(&$item) {
+
+ $s = '';
+ $terms = get_terms_oftype($item['term'],TERM_MENTION);
+ if($terms) {
+ $categories = array();
+ foreach($terms as $t) {
+ $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8',false) ;
+ if(! trim($term))
+ continue;
+ if(strpos($item['body'], $t['url']))
+ continue;
+
+ if($s)
+ $s .= '&nbsp';
+
+ $s .= '@<a href="' . zid($t['url']) . '" >' . $term . '</a>';
+ }
+ }
+ return $s;
+}
function format_filer(&$item) {
@@ -1293,6 +1314,10 @@ function prepare_body(&$item,$attach = false) {
$s .= format_hashtags($item);
+ if($item['resource_type'])
+ $s .= format_mentions($item);
+
+
$s .= format_categories($item,$writeable);
if(local_user() == $item['uid'])
diff --git a/include/zot.php b/include/zot.php
index 8401ac186..798ebc0af 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -582,16 +582,19 @@ function zot_register_hub($arr) {
*
* @param array $arr => json_decoded discovery packet
* @param int $ud_flags
- * Determines whether to create a directory update record if any changes occur, default is UPDATE_FLAGS_UPDATED (true)
+ * Determines whether to create a directory update record if any changes occur, default is UPDATE_FLAGS_UPDATED
* $ud_flags = UPDATE_FLAGS_FORCED indicates a forced refresh where we unconditionally create a directory update record
* this typically occurs once a month for each channel as part of a scheduled ping to notify the directory
* that the channel still exists
+ * @param array $ud_arr
+ * If set [typically by update_directory_entry()] indicates a specific update table row and more particularly
+ * contains a particular address (ud_addr) which needs to be updated in that table.
*
* @returns array => 'success' (boolean true or false)
* 'message' (optional error string only if success is false)
*/
-function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
+function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
call_hooks('import_xchan', $arr);
@@ -601,7 +604,6 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
$changed = false;
$what = '';
- $addresses = array();
if(! (is_array($arr) && array_key_exists('success',$arr) && $arr['success'])) {
logger('import_xchan: invalid data packet: ' . print_r($arr,true));
@@ -838,8 +840,6 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
if(strpos($location['address'],'/') !== false)
$location['address'] = substr($location['address'],0,strpos($location['address'],'/'));
- $addresses[] = $location['address'];
-
// match as many fields as possible in case anything at all changed.
$r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_host = '%s' and hubloc_addr = '%s' and hubloc_callback = '%s' and hubloc_sitekey = '%s' ",
@@ -964,15 +964,16 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
}
+ // Which entries in the update table are we interested in updating?
-
+ $address = (($ud_arr && $ud_arr['ud_addr']) ? $ud_arr['ud_addr'] : $arr['address']);
// Are we a directory server of some kind?
if($dirmode != DIRECTORY_MODE_NORMAL) {
if(array_key_exists('profile',$arr) && is_array($arr['profile'])) {
- $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags, 1);
+ $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$address,$ud_flags, 1);
if($profile_changed) {
$what .= 'profile ';
$changed = true;
@@ -998,27 +999,19 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
}
}
+
if(($changed) || ($ud_flags == UPDATE_FLAGS_FORCED)) {
- if($addresses) {
- foreach($addresses as $address) {
- $guid = random_string() . '@' . get_app()->get_hostname();
- update_modtime($xchan_hash,$guid,$address,$ud_flags);
- }
- }
+ $guid = random_string() . '@' . get_app()->get_hostname();
+ update_modtime($xchan_hash,$guid,$address,$ud_flags);
logger('import_xchan: changed: ' . $what,LOGGER_DEBUG);
}
elseif(! $ud_flags) {
// nothing changed but we still need to update the updates record
- if($addresses) {
- foreach($addresses as $address) {
-
- q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ",
- intval(UPDATE_FLAGS_UPDATED),
- dbesc($address),
- intval(UPDATE_FLAGS_UPDATED)
- );
- }
- }
+ q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ",
+ intval(UPDATE_FLAGS_UPDATED),
+ dbesc($address),
+ intval(UPDATE_FLAGS_UPDATED)
+ );
}
if(! x($ret,'message')) {