aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-06-07 03:46:43 +0100
committerThomas Willingham <founder@kakste.com>2013-06-07 03:46:43 +0100
commit466a6d5227fbaf0a36cd76b5603cb42bb1b7462b (patch)
tree395936a63e27fa105e0dc69d13c1b951dc9e9439 /mod
parentdc6472e046ee6ac0afc934e8ad1edc1e281a3cb0 (diff)
parentc21f8c68e39e22a0348e5717109f0005d4d35809 (diff)
downloadvolse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.tar.gz
volse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.tar.bz2
volse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r--mod/directory.php6
-rw-r--r--mod/import.php7
-rw-r--r--mod/photos.php6
-rw-r--r--mod/settings.php4
-rw-r--r--mod/tagger.php186
5 files changed, 78 insertions, 131 deletions
diff --git a/mod/directory.php b/mod/directory.php
index 21fb14bfc..46fc34e16 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -4,7 +4,7 @@ require_once('include/dir_fns.php');
function directory_init(&$a) {
- $a->set_pager_itemspage(60);
+ $a->set_pager_itemspage(80);
}
@@ -66,7 +66,7 @@ function directory_content(&$a) {
logger('mod_directory: query: ' . $query);
$x = z_fetch_url($query);
- logger('directory: return from upstream: ' . print_r($x,true));
+ logger('directory: return from upstream: ' . print_r($x,true), LOGGER_DATA);
if($x['success']) {
$t = 0;
@@ -166,7 +166,7 @@ function directory_content(&$a) {
));
- $o .= alt_pager($a,$j['records'], t('more'), t('back'));
+ $o .= alt_pager($a,$j['records'], t('next page'), t('previous page'));
}
else {
diff --git a/mod/import.php b/mod/import.php
index 9443f5c60..d1b3216d0 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -4,7 +4,7 @@
// connection to original server.
require_once('include/Contact.php');
-
+require_once('include/zot.php');
function import_post(&$a) {
@@ -39,7 +39,7 @@ function import_post(&$a) {
$servername = substr($old_address,strpos($old_address,'@')+1);
$scheme = 'https://';
- $api_path = '/api/export/basic?f=&channel=' . $channelname;
+ $api_path = '/api/red/channel/export/basic?f=&channel=' . $channelname;
$binary = false;
$redirects = 0;
$opts = array('http_auth' => $email . ':' . $password);
@@ -60,6 +60,7 @@ function import_post(&$a) {
return;
}
+ $data = json_decode($data,true);
// logger('import: data: ' . print_r($data,true));
@@ -113,6 +114,8 @@ function import_post(&$a) {
// reset
$channel = $r[0];
+ set_default_login_identity($a->get_account(),$channel['channel_id'],false);
+
if($data['photo']) {
require_once('include/photo/photo_driver.php');
import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id,$channel['channel_id']);
diff --git a/mod/photos.php b/mod/photos.php
index 5b81e18a7..65bf866f1 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -650,10 +650,10 @@ function photos_content(&$a) {
$albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
if(count($a->data['albums'])) {
foreach($a->data['albums'] as $album) {
- if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
+ if($album['text'] === '')
continue;
- $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
- $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
+ $selected = (($selname === $album['text']) ? ' selected="selected" ' : '');
+ $albumselect .= '<option value="' . $album['text'] . '"' . $selected . '>' . $album['text'] . '</option>';
}
}
diff --git a/mod/settings.php b/mod/settings.php
index 5ee6b5d15..f417586af 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -456,6 +456,7 @@ function settings_post(&$a) {
set_pconfig(local_user(),'system','post_newfriend', $post_newfriend);
set_pconfig(local_user(),'system','post_joingroup', $post_joingroup);
set_pconfig(local_user(),'system','post_profilechange', $post_profilechange);
+ set_pconfig(local_user(),'system','blocktags',$blocktags);
/*
if($page_flags == PAGE_PRVGROUP) {
@@ -907,7 +908,6 @@ function settings_content(&$a) {
$expire = $channel['channel_expire_days'];
$blockwall = $a->user['blockwall'];
- $blocktags = $a->user['blocktags'];
$unkmail = $a->user['unkmail'];
$cntunkmail = $a->user['cntunkmail'];
@@ -939,6 +939,8 @@ function settings_content(&$a) {
$post_profilechange = get_pconfig(local_user(), 'system','post_profilechange');
$post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0
+ $blocktags = get_pconfig(local_user(),'system','blocktags');
+ $blocktags = (($blocktags===false) ? '0' : $blocktags);
$timezone = date_default_timezone_get();
diff --git a/mod/tagger.php b/mod/tagger.php
index b8e90e2fd..28e10d131 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -23,11 +23,12 @@ function tagger_content(&$a) {
logger('tagger: tag ' . $term . ' item ' . $item_id);
- $r = q("SELECT * FROM `item` WHERE `id` = '%s' LIMIT 1",
- dbesc($item_id)
+ $r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = '%s' and uid = %d LIMIT 1",
+ dbesc($item_id),
+ intval(local_user())
);
- if(! $item_id || (! count($r))) {
+ if((! $item_id) || (! $r)) {
logger('tagger: no item ' . $item_id);
return;
}
@@ -36,89 +37,82 @@ function tagger_content(&$a) {
$owner_uid = $item['uid'];
- $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
- intval($owner_uid)
- );
- if(count($r)) {
- $owner_nick = $r[0]['nickname'];
- $blocktags = $r[0]['blocktags'];
+ switch($item['resource_type']) {
+ case 'photo':
+ $targettype = ACTIVITY_OBJ_PHOTO;
+ $post_type = t('photo');
+ break;
+ case 'event':
+ $targgettype = ACTIVITY_OBJ_EVENT;
+ $post_type = t('event');
+ break;
+ default:
+ $targettype = ACTIVITY_OBJ_NOTE;
+ $post_type = t('status');
+ if($item['mid'] != $item['parent_mid'])
+ $post_type = t('comment');
+ break;
}
- if(local_user() != $owner_uid)
- return;
- $r = q("select * from contact where self = 1 and uid = %d limit 1",
- intval(local_user())
- );
- if(count($r))
- $contact = $r[0];
- else {
- logger('tagger: no contact_id');
- return;
- }
+ $links = array(array('rel' => 'alternate','type' => 'text/html',
+ 'href' => z_root() . '/display/' . $item['mid']));
- $mid = item_message_id();
- $xterm = xmlify($term);
- $post_type = (($item['resource_id']) ? t('photo') : t('status'));
- $targettype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
+ $target = json_encode(array(
+ 'type' => $targettype,
+ 'id' => $item['mid'],
+ 'link' => $links,
+ 'title' => $item['title'],
+ 'content' => $item['body'],
+ 'created' => $item['created'],
+ 'edited' => $item['edited'],
+ 'author' => array(
+ 'name' => $item['xchan_name'],
+ 'address' => $item['xchan_addr'],
+ 'guid' => $item['xchan_guid'],
+ 'guid_sig' => $item['xchan_guid_sig'],
+ 'link' => array(
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item['xchan_url']),
+ array('rel' => 'photo', 'type' => $item['xchan_photo_mimetype'], 'href' => $item['xchan_photo_m'])),
+ ),
+ ));
- $link = xmlify('<link rel="alternate" type="text/html" href="'
- . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
- $body = xmlify($item['body']);
- $target = <<< EOT
- <target>
- <type>$targettype</type>
- <local>1</local>
- <id>{$item['mid']}</id>
- <link>$link</link>
- <title></title>
- <content>$body</content>
- </target>
-EOT;
+ $link = xmlify('<link rel="alternate" type="text/html" href="'
+ . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$tagid = $a->get_baseurl() . '/search?tag=' . $term;
$objtype = ACTIVITY_OBJ_TAGTERM;
- $obj = <<< EOT
- <object>
- <type>$objtype</type>
- <local>1</local>
- <id>$tagid</id>
- <link>$tagid</link>
- <title>$xterm</title>
- <content>$xterm</content>
- </object>
-EOT;
+ $obj = json_encode(array(
+ 'type' => $objtype,
+ 'id' => $tagid,
+ 'link' => array(array('rel' => 'alternate','type' => 'text/html', 'href' => $tagid)),
+ 'title' => $term,
+ 'content' => $term
+ ));
$bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
- if(! isset($bodyverb))
- return;
-
$termlink = html_entity_decode('&#x2317;') . '[zrl=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/zrl]';
+ $channel = $a->get_channel();
+
$arr = array();
- $arr['mid'] = $mid;
- $arr['uid'] = $owner_uid;
- $arr['contact-id'] = $contact['id'];
- $arr['type'] = 'activity';
- $arr['wall'] = $item['wall'];
- $arr['gravity'] = GRAVITY_COMMENT;
- $arr['parent'] = $item['id'];
- $arr['parent_mid'] = $item['mid'];
- $arr['owner-name'] = $item['author-name'];
- $arr['owner-link'] = $item['author-link'];
- $arr['owner-avatar'] = $item['author-avatar'];
- $arr['author-name'] = $contact['name'];
- $arr['author-link'] = $contact['url'];
- $arr['author-avatar'] = $contact['thumb'];
+ $arr['owner_xchan'] = $item['owner_xchan'];
+ $arr['author_xchan'] = $channel['channel_hash'];
+
+
+ $arr['item_flags'] = ITEM_ORIGIN;
+ if($item['item_flags'] & ITEM_WALL)
+ $arr['item_flags'] |= ITEM_WALL;
- $ulink = '[zrl=' . $contact['url'] . ']' . $contact['name'] . '[/zrl]';
- $alink = '[zrl=' . $item['author-link'] . ']' . $item['author-name'] . '[/zrl]';
+ $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
+ $alink = '[zrl=' . $item['xchan_url'] . ']' . $item['xchan_name'] . '[/zrl]';
$plink = '[zrl=' . $item['plink'] . ']' . $post_type . '[/zrl]';
+
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink );
$arr['verb'] = ACTIVITY_TAG;
@@ -126,65 +120,13 @@ EOT;
$arr['target'] = $target;
$arr['obj_type'] = $objtype;
$arr['object'] = $obj;
- $arr['private'] = $item['private'];
- $arr['allow_cid'] = $item['allow_cid'];
- $arr['allow_gid'] = $item['allow_gid'];
- $arr['deny_cid'] = $item['deny_cid'];
- $arr['deny_gid'] = $item['deny_gid'];
- $arr['visible'] = 1;
- $arr['unseen'] = 1;
- $arr['origin'] = 1;
-
- $post_id = item_store($arr);
-
- q("UPDATE `item` set plink = '%s' where id = %d limit 1",
- dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
- intval($post_id)
- );
-
-
- if(! $item['visible']) {
- $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($item['id']),
- intval($owner_uid)
- );
- }
-
- if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) {
- q("update item set tag = '%s' where id = %d limit 1",
- dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[zrl=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/zrl]'),
- intval($item['id'])
- );
- }
-
- // if the original post is on this site, update it.
-
- $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `mid` = '%s' LIMIT 1",
- dbesc($item['mid'])
- );
- if(count($r)) {
- $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
- intval($r[0]['uid'])
- );
- if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
- q("update item set tag = '%s' where id = %d limit 1",
- dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[zrl=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/zrl]'),
- intval($r[0]['id'])
- );
- }
-
- }
-
-
- $arr['id'] = $post_id;
+ $arr['parent_mid'] = $item['mid'];
- call_hooks('post_local_end', $arr);
+ $ret = post_activity_item($arr);
- proc_run('php',"include/notifier.php","tag","$post_id");
+ if($ret['success'])
+ proc_run('php','include/notifier.php','tag',$ret['activity']['id']);
killme();
- return; // NOTREACHED
-
-
} \ No newline at end of file