From 2a7ff3018b8f82013c739eb70cd02c51737211bb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 3 Sep 2015 17:21:20 -0700 Subject: channel export - don't include linked resource items (photos, events). These items will need to be provided with those objects so that they can be re-linked. --- include/identity.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index e236b5a90..ca4c009c8 100644 --- a/include/identity.php +++ b/include/identity.php @@ -598,7 +598,9 @@ function identity_basic_export($channel_id, $items = false) { /** @warning this may run into memory limits on smaller systems */ - $r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d order by created", + /** Don't export linked resource items. we'll have to pull those out separately. */ + + $r = q("select * from item where (item_flags & %d) > 0 and not (item_restrict & %d) > 0 and uid = %d and resource_type = '' order by created", intval(ITEM_WALL), intval(ITEM_DELETED), intval($channel_id) @@ -635,7 +637,7 @@ function identity_export_year($channel_id,$year,$month = 0) { else $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00'); - $r = q("select * from item where (item_flags & %d) > 0 and (item_restrict & %d) = 0 and uid = %d and created >= '%s' and created < '%s' order by created ", + $r = q("select * from item where (item_flags & %d) > 0 and (item_restrict & %d) = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created ", intval(ITEM_WALL), intval(ITEM_DELETED), intval($channel_id), -- cgit v1.2.3 From f7d9523c7da3c193dd0216fa00e62a940d0d174d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 3 Sep 2015 18:43:44 -0700 Subject: export chatrooms --- include/identity.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index ca4c009c8..1a2a9c177 100644 --- a/include/identity.php +++ b/include/identity.php @@ -577,6 +577,12 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['app'] = $r; + $r = q("select * from chatroom where cr_uid = %d", + intval($channel_id) + ); + if($r) + $ret['chatroom'] = $r; + if(! $items) return $ret; -- cgit v1.2.3 From d79e81a0697617b5552917c2fe169b30433c54f6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 3 Sep 2015 18:44:40 -0700 Subject: import and sync chatrooms --- include/chat.php | 2 ++ include/identity.php | 7 +++- include/import.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++-- include/zot.php | 3 ++ 4 files changed, 108 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/chat.php b/include/chat.php index 05bb02bb9..a0646265a 100644 --- a/include/chat.php +++ b/include/chat.php @@ -91,6 +91,8 @@ function chatroom_destroy($channel,$arr) { return $ret; } + create_sync_packet($channel['channel_id'],array('chatroom' => $r)); + q("delete from chatroom where cr_id = %d", intval($r[0]['cr_id']) ); diff --git a/include/identity.php b/include/identity.php index c3f59b371..393378cc4 100644 --- a/include/identity.php +++ b/include/identity.php @@ -566,13 +566,18 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['obj'] = $r; - $r = q("select * from app where app_channel = %d", intval($channel_id) ); if($r) $ret['app'] = $r; + $r = q("select * from chatroom where cr_uid = %d", + intval($channel_id) + ); + if($r) + $ret['chatroom'] = $r; + if(! $items) return $ret; diff --git a/include/import.php b/include/import.php index 6ce572ea2..261219ce0 100644 --- a/include/import.php +++ b/include/import.php @@ -349,7 +349,7 @@ function sync_apps($channel,$apps) { intval($channel['channel_id']) ); if($x) { - if($x[0]['app_edited'] >= $obj['app_edited']) + if($x[0]['app_edited'] >= $app['app_edited']) continue; $exists = true; } @@ -377,4 +377,99 @@ function sync_apps($channel,$apps) { } } } -} \ No newline at end of file +} + + + +function import_chatrooms($channel,$chatrooms) { + + if($channel && $chatrooms) { + foreach($chatrooms as $chatroom) { + + if(! $chatroom['cr_name']) + continue; + + unset($chatroom['cr_id']); + unset($chatroom['cr_aid']); + unset($chatroom['cr_uid']); + + $chatroom['cr_aid'] = $channel['channel_account_id']; + $chatroom['cr_uid'] = $channel['channel_id']; + + dbesc_array($chatroom); + $r = dbq("INSERT INTO chatroom (`" + . implode("`, `", array_keys($chatroom)) + . "`) VALUES ('" + . implode("', '", array_values($chatroom)) + . "')" + ); + } + } +} + + + +function sync_chatrooms($channel,$chatrooms) { + + if($channel && $chatrooms) { + foreach($chatrooms as $chatroom) { + + if(! $chatroom['cr_name']) + continue; + + if(array_key_exists('cr_deleted',$chatroom) && $chatroom['cr_deleted']) { + q("delete from chatroom where cr_name = '%s' and cr_uid = %d limit 1", + dbesc($chatroom['cr_name']), + intval($channel['channel_id']) + ); + continue; + } + + + unset($chatroom['cr_id']); + unset($chatroom['cr_aid']); + unset($chatroom['cr_uid']); + + if(! $chatroom['cr_created'] || $chatroom['cr_created'] === NULL_DATE) + $chatroom['cr_created'] = datetime_convert(); + if(! $chatroom['cr_edited'] || $chatroom['cr_edited'] === NULL_DATE) + $chatroom['cr_edited'] = datetime_convert(); + + $chatroom['cr_aid'] = $channel['channel_account_id']; + $chatroom['cr_uid'] = $channel['channel_id']; + + $exists = false; + + $x = q("select * from chatroom where cr_name = '%s' and cr_uid = %d limit 1", + dbesc($chatroom['cr_name']), + intval($channel['channel_id']) + ); + if($x) { + if($x[0]['cr_edited'] >= $chatroom['cr_edited']) + continue; + $exists = true; + } + $name = $chatroom['cr_name']; + + if($exists) { + foreach($chatroom as $k => $v) { + $r = q("UPDATE chatroom SET `%s` = '%s' WHERE cr_name = '%s' AND cr_uid = %d", + dbesc($k), + dbesc($v), + dbesc($name), + intval($channel['channel_id']) + ); + } + } + else { + dbesc_array($chatroom); + $r = dbq("INSERT INTO chatroom (`" + . implode("`, `", array_keys($chatroom)) + . "`) VALUES ('" + . implode("', '", array_values($chatroom)) + . "')" + ); + } + } + } +} diff --git a/include/zot.php b/include/zot.php index fecaa7ad2..9610df894 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2881,6 +2881,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('app',$arr) && $arr['app']) sync_apps($channel,$arr['app']); + if(array_key_exists('chatroom',$arr) && $arr['chatroom']) + sync_apps($channel,$arr['chatroom']); + if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { if(array_key_exists('channel_page_flags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) { $arr['channel']['channel_removed'] = (($arr['channel']['channel_pageflags'] & 0x8000) ? 1 : 0); -- cgit v1.2.3 From fc804751a2967db0d46385bb89248228b2b5d8bf Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Fri, 4 Sep 2015 12:39:47 +0200 Subject: Fix for PHP Fatal error: Function name must be a string in /var/www/hubzilla/include/items.php on line 3325 Please review if this is correct? --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9807831e3..91afad0e6 100755 --- a/include/items.php +++ b/include/items.php @@ -3322,7 +3322,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { dbesc($title), dbesc($body), intval($item_wall), - $intval($item_origin), + intval($item_origin), intval($item_id) ); -- cgit v1.2.3 From 55ab968edf93c4c903e2a88e0eed94741cc80fb6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 5 Sep 2015 17:35:00 -0700 Subject: make js_upload work with hubzilla. It still needs a rewrite. --- include/attach.php | 44 ++++++++++++++++++++++++++++++++++---------- include/photos.php | 4 ++-- 2 files changed, 36 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 620c7620c..513486bfc 100644 --- a/include/attach.php +++ b/include/attach.php @@ -405,6 +405,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { require_once('include/photos.php'); + + call_hooks('photo_upload_begin',$arr); + $ret = array('success' => false); $channel_id = $channel['channel_id']; $sql_options = ''; @@ -451,15 +454,28 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $hash = $arr['resource_id']; } elseif($options !== 'update') { - if(! x($_FILES,'userfile')) { - $ret['message'] = t('No source file.'); - return $ret; - } + $f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); - $src = $_FILES['userfile']['tmp_name']; - $filename = basename($_FILES['userfile']['name']); - $filesize = intval($_FILES['userfile']['size']); + call_hooks('photo_upload_file',$f); + call_hooks('attach_upload_file',$f); + if (x($f,'src') && x($f,'filesize')) { + $src = $f['src']; + $filename = $f['filename']; + $filesize = $f['filesize']; + $type = $f['type']; + + } else { + + if(! x($_FILES,'userfile')) { + $ret['message'] = t('No source file.'); + return $ret; + } + + $src = $_FILES['userfile']['tmp_name']; + $filename = basename($_FILES['userfile']['name']); + $filesize = intval($_FILES['userfile']['size']); + } } $existing_size = 0; @@ -615,6 +631,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { if(($maxfilesize) && ($filesize > $maxfilesize)) { $ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize); @unlink($src); + call_hooks('photo_upload_end',$ret); return $ret; } @@ -627,10 +644,11 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { $ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000); @unlink($src); + call_hooks('photo_upload_end',$ret); return $ret; } } - $mimetype = z_mime_content_type($filename); + $mimetype = ((isset($type) && $type) ? $type : z_mime_content_type($filename)); } $os_basepath = 'store/' . $channel['channel_address'] . '/' ; @@ -658,7 +676,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { else $edited = $created; - if($options === 'replace') { $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, data = '%s', edited = '%s' where id = %d and uid = %d", dbesc($filename), @@ -714,6 +731,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } else { + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), @@ -738,6 +756,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if($is_photo) { + $args = array( 'source' => $source, 'visible' => 0, 'resource_id' => $hash, 'album' => basename($pathname), 'os_path' => $os_basepath . $os_relpath, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct); if($arr['contact_allow']) $args['contact_allow'] = $arr['contact_allow']; @@ -772,6 +791,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { if(! $r) { $ret['message'] = t('File upload failed. Possible system limit or action terminated.'); + call_hooks('photo_upload_end',$ret); return $ret; } @@ -784,13 +804,17 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { if(! $r) { $ret['message'] = t('Stored file could not be verified. Upload failed.'); + call_hooks('photo_upload_end',$ret); return $ret; } $ret['success'] = true; $ret['data'] = $r[0]; - + if(! $is_photo) { + // This would've been called already with a success result in photos_upload() if it was a photo. + call_hooks('photo_upload_end',$ret); + } return $ret; } diff --git a/include/photos.php b/include/photos.php index b4129fbf1..25818124a 100644 --- a/include/photos.php +++ b/include/photos.php @@ -27,7 +27,7 @@ function photo_upload($channel, $observer, $args) { return $ret; } - call_hooks('photo_upload_begin', $args); +// call_hooks('photo_upload_begin', $args); /* * Determine the album to use @@ -84,7 +84,7 @@ function photo_upload($channel, $observer, $args) { } else { $f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); - call_hooks('photo_upload_file',$f); +// call_hooks('photo_upload_file',$f); if (x($f,'src') && x($f,'filesize')) { $src = $f['src']; -- cgit v1.2.3 From 1b09c6485638339aede6dc2fd69956716b80fb00 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 7 Sep 2015 03:59:38 -0700 Subject: PRIVACY: item_private seems to have been removed from permissions_sql checking with an observer. --- include/security.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index bad39d805..0c3dc29d6 100644 --- a/include/security.php +++ b/include/security.php @@ -260,7 +260,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) { $regexop = db_getfunc('REGEXP'); $sql = sprintf( " AND ( NOT (deny_cid like '%s' OR deny_gid $regexop '%s') - AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '') ) + AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '' AND item_private = 0 ) ) ) ", dbesc(protect_sprintf( '%<' . $observer . '>%')), @@ -295,7 +295,7 @@ function public_permissions_sql($observer_hash) { $regexop = db_getfunc('REGEXP'); $sql = sprintf( " OR (( NOT (deny_cid like '%s' OR deny_gid $regexop '%s') - AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '') ) + AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '' AND item_private = 0 ) ) )) ", dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), -- cgit v1.2.3 From 6711ceb662a997d4f44743266a792ec762790d05 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Mon, 7 Sep 2015 16:28:42 -0700 Subject: fix postgres zotfeed --- include/items.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 01b4a3460..981f52d7a 100755 --- a/include/items.php +++ b/include/items.php @@ -4588,10 +4588,12 @@ function zot_feed($uid,$observer_hash,$arr) { $items = array(); - /** @FIXME fix this part for PostgreSQL */ + /** @FIXME re-unite these SQL statements. There is no need for them to be separate. The mySQL is convoluted with misuse of group by. As it stands, there is a slight difference where the postgres version doesn't remove the duplicate parents up to 100. In practice this doesn't matter. It could be made to match behavior by adding "distinct on (parent) " to the front of the selection list, at a not-worth-it performance penalty (page temp results to disk). duplicates are still ignored in the in() clause, you just get less than 100 parents if there are many children. */ if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - return array(); + $groupby = ''; + } else { + $groupby = 'GROUP BY parent'; } if(is_sys_channel($uid)) { @@ -4599,7 +4601,7 @@ function zot_feed($uid,$observer_hash,$arr) { WHERE uid != %d AND item_private = 0 AND item_restrict = 0 AND uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") AND (item_flags & %d) > 0 - $sql_extra GROUP BY parent ORDER BY created ASC $limit", + $sql_extra $groupby ORDER BY created ASC $limit", intval($uid), intval(ITEM_WALL) ); @@ -4608,7 +4610,7 @@ function zot_feed($uid,$observer_hash,$arr) { $r = q("SELECT parent, created, postopts from item WHERE uid = %d AND item_restrict = 0 AND (item_flags & %d) > 0 - $sql_extra GROUP BY parent ORDER BY created ASC $limit", + $sql_extra $groupby ORDER BY created ASC $limit", intval($uid), intval(ITEM_WALL) ); -- cgit v1.2.3 From 6d1b64065aa1f44e2b9d864ddba97891ca85d1e5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 7 Sep 2015 18:14:30 -0700 Subject: consolidate import_items/sync_items --- include/import.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/photos.php | 3 --- include/zot.php | 6 +++++ 3 files changed, 83 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 261219ce0..a81ade791 100644 --- a/include/import.php +++ b/include/import.php @@ -473,3 +473,80 @@ function sync_chatrooms($channel,$chatrooms) { } } } + + + +function import_items($channel,$items) { + + if($channel && $items) { + foreach($items as $i) { + $item = get_item_elements($i); + if(! $item) + continue; + + $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", + dbesc($item['mid']), + intval($channel['channel_id']) + ); + if($r) { + if($item['edited'] > $r[0]['edited']) { + $item['id'] = $r[0]['id']; + $item['uid'] = $channel['channel_id']; + item_store_update($item); + continue; + } + } + else { + $item['aid'] = $channel['channel_account_id']; + $item['uid'] = $channel['channel_id']; + $item_result = item_store($item); + } + + } + } +} + + +function sync_items($channel,$items) { + import_items($channel,$items); +} + + + +function import_item_ids($channel,$itemids) { + if($channel && $itemids) { + foreach($itemids as $i) { + $r = q("select id from item where mid = '%s' and uid = %d limit 1", + dbesc($i['mid']), + intval($channel['channel_id']) + ); + if(! $r) + continue; + $z = q("select * from item_id where service = '%s' and sid = '%s' and iid = %d and uid = %d limit 1", + dbesc($i['service']), + dbesc($i['sid']), + intval($r[0]['id']), + intval($channel['channel_id']) + ); + if(! $z) { + q("insert into item_id (iid,uid,sid,service) values(%d,%d,'%s','%s')", + intval($r[0]['id']), + intval($channel['channel_id']), + dbesc($i['sid']), + dbesc($i['service']) + ); + } + } + } +} + + + + + + + + + + + diff --git a/include/photos.php b/include/photos.php index 25818124a..49aab6865 100644 --- a/include/photos.php +++ b/include/photos.php @@ -226,11 +226,8 @@ function photo_upload($channel, $observer, $args) { $width_x_height = $ph->getWidth() . 'x' . $ph->getHeight(); - $mid = item_message_id(); - // Create item container - $item_hidden = (($visible) ? 0 : 1 ); $lat = $lon = null; diff --git a/include/zot.php b/include/zot.php index 9610df894..6f159b4f8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2884,6 +2884,12 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_apps($channel,$arr['chatroom']); + if(array_key_exists('item',$arr) && $arr['item']) + sync_items($channel,$arr['item']); + + if(array_key_exists('item_id',$arr) && $arr['item_id']) + sync_items($channel,$arr['item_id']); + if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { if(array_key_exists('channel_page_flags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) { $arr['channel']['channel_removed'] = (($arr['channel']['channel_pageflags'] & 0x8000) ? 1 : 0); -- cgit v1.2.3 From c39e3613a8facf0ef626fbd671f21f822ff25096 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 7 Sep 2015 20:28:02 -0700 Subject: create event sync packets --- include/event.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/event.php b/include/event.php index 134c23aa2..3b48837f1 100644 --- a/include/event.php +++ b/include/event.php @@ -376,6 +376,20 @@ function event_addtocal($item_id, $uid) { intval($channel['channel_id']) ); + $item['resource_id'] = $event['event_hash']; + $item['resource_type'] = 'event'; + + $i = array($item); + xchan_query($i); + $sync_item = fetch_post_tags($i); + $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + if($z) { + build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); + } + return true; } } -- cgit v1.2.3 From 650e98b2a9aff2f54be84782ac48cc57badbf76f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 7 Sep 2015 21:01:49 -0700 Subject: work on event sync --- include/import.php | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/zot.php | 8 +++++- 2 files changed, 82 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index a81ade791..616ee4987 100644 --- a/include/import.php +++ b/include/import.php @@ -540,6 +540,81 @@ function import_item_ids($channel,$itemids) { } } +function import_events($channel,$events) { + + if($channel && $events) { + foreach($events as $event) { + unset($event['id']); + $event['aid'] = $channel['channel_account_id']; + $event['uid'] = $channel['channel_id']; + + dbesc_array($event); + $r = dbq("INSERT INTO event (`" + . implode("`, `", array_keys($event)) + . "`) VALUES ('" + . implode("', '", array_values($event)) + . "')" + ); + } + } +} + + +function sync_events($channel,$events) { + + if($channel && $events) { + foreach($events as $event) { + + if((! $event['event_hash']) || (! $event['start'])) + continue; + + if($event['event_deleted']) { + $r = q("delete from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + continue; + } + + unset($event['id']); + $event['aid'] = $channel['channel_account_id']; + $event['uid'] = $channel['channel_id']; + + $exists = false; + + $x = q("select * from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + if($x) { + if($x[0]['edited'] >= $event['edited']) + continue; + $exists = true; + } + + if($exists) { + foreach($event as $k => $v) { + $r = q("UPDATE event SET `%s` = '%s' WHERE event_hash = '%s' AND uid = %d", + dbesc($k), + dbesc($v), + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + } + } + else { + dbesc_array($event); + $r = dbq("INSERT INTO event (`" + . implode("`, `", array_keys($event)) + . "`) VALUES ('" + . implode("', '", array_values($event)) + . "')" + ); + } + } + } +} + diff --git a/include/zot.php b/include/zot.php index 6f159b4f8..285668209 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2882,7 +2882,13 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { sync_apps($channel,$arr['app']); if(array_key_exists('chatroom',$arr) && $arr['chatroom']) - sync_apps($channel,$arr['chatroom']); + sync_chatrooms($channel,$arr['chatroom']); + + if(array_key_exists('event',$arr) && $arr['event']) + sync_events($channel,$arr['event']); + + if(array_key_exists('event_item',$arr) && $arr['event_item']) + sync_items($channel,$arr['event_item']); if(array_key_exists('item',$arr) && $arr['item']) sync_items($channel,$arr['item']); -- cgit v1.2.3 From 11e19a06b74014cd62a26f127162ff1984159dce Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 7 Sep 2015 22:54:43 -0700 Subject: export events --- include/identity.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 1a2a9c177..76079e93a 100644 --- a/include/identity.php +++ b/include/identity.php @@ -583,6 +583,25 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['chatroom'] = $r; + + $r = q("select * from event where uid = %d", + intval($channel_id) + ); + if($r) + $ret['event'] = $r; + + $r = q("select * from item where resource_type = 'event' and uid = %d", + intval($channel_id) + ); + if($r) { + $ret['event_item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['event_item'][] = encode_item($rr,true); + } + + if(! $items) return $ret; -- cgit v1.2.3 From 1ebaacfd5e7e481cbc025842e78161f79f5d7cce Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 17:50:24 -0700 Subject: menu export --- include/identity.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 76079e93a..4d2f8b961 100644 --- a/include/identity.php +++ b/include/identity.php @@ -5,7 +5,7 @@ require_once('include/zot.php'); require_once('include/crypto.php'); - +require_once('include/menu.php'); /** * @brief Called when creating a new channel. @@ -601,6 +601,16 @@ function identity_basic_export($channel_id, $items = false) { $ret['event_item'][] = encode_item($rr,true); } + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } + if(! $items) return $ret; -- cgit v1.2.3 From 75d521d42affbafa34e87752deeb1961367de1d5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 17:51:48 -0700 Subject: menu import and sync --- include/Import/import_diaspora.php | 5 +- include/identity.php | 11 ++++ include/import.php | 124 +++++++++++++++++++++++++++++++++++++ include/menu.php | 13 +++- include/zot.php | 3 + 5 files changed, 154 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php index fca9fa4f2..a0f473b50 100644 --- a/include/Import/import_diaspora.php +++ b/include/Import/import_diaspora.php @@ -57,6 +57,10 @@ function import_diaspora($data) { $channel_id = $c['channel']['channel_id']; + // Hubzilla only: Turn on the Diaspora protocol so that follow requests will be sent. + + set_pconfig($channel_id,'system','diaspora_allowed','1'); + // todo - add auto follow settings, (and strip exif in hubzilla) $location = escape_tags($data['user']['profile']['location']); @@ -70,7 +74,6 @@ function import_diaspora($data) { ); if($data['user']['profile']['nsfw']) { - // fixme for hubzilla which doesn't use pageflags any more q("update channel set channel_pageflags = (channel_pageflags | %d) where channel_id = %d", intval(PAGE_ADULT), intval($channel_id) diff --git a/include/identity.php b/include/identity.php index 211832d51..f68b1fe4a 100644 --- a/include/identity.php +++ b/include/identity.php @@ -5,6 +5,7 @@ require_once('include/zot.php'); require_once('include/crypto.php'); +require_once('include/menu.php'); /** @@ -595,6 +596,16 @@ function identity_basic_export($channel_id, $items = false) { foreach($r as $rr) $ret['event_item'][] = encode_item($rr,true); } + + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } if(! $items) diff --git a/include/import.php b/include/import.php index 616ee4987..7b2f574d9 100644 --- a/include/import.php +++ b/include/import.php @@ -1,5 +1,6 @@ = $m['menu_edited']) + continue; + if($menu['menu_deleted']) { + menu_delete_id($r[0]['menu_id'],$channel['channel_id']); + continue; + } + $menu_id = $r[0]['menu_id']; + $x = menu_edit($m); + if(! $x) + continue; + $editing = true; + } + if(! $editing) { + $menu_id = menu_create($m); + } + if($menu_id) { + if($editing) { + // don't try syncing - just delete all the entries and start over + q("delete from menu_item where mitem_menu_id = %d", + intval($menu_id) + ); + } + + if(is_array($menu['items'])) { + foreach($menu['items'] as $it) { + $mitem = array(); + + $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']); + $mitem['mitem_desc'] = escape_tags($it['desc']); + $mitem['mitem_order'] = intval($it['order']); + if(is_array($it['flags'])) { + $mitem['mitem_flags'] = 0; + if(in_array('zid',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_ZID; + if(in_array('new-window',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN; + if(in_array('chatroom',$it['flags'])) + $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM; + } + menu_add_item($menu_id,$channel['channel_id'],$mitem); + } + } + } + } + } +} diff --git a/include/menu.php b/include/menu.php index 7ed931a59..32d8630a6 100644 --- a/include/menu.php +++ b/include/menu.php @@ -6,7 +6,7 @@ require_once('include/bbcode.php'); function menu_fetch($name,$uid,$observer_xchan) { - $sql_options = permissions_sql($uid); + $sql_options = permissions_sql($uid,$observer_xchan); $r = q("select * from menu where menu_channel_id = %d and menu_name = '%s' limit 1", intval($uid), @@ -388,3 +388,14 @@ function menu_del_item($menu_id,$uid,$item_id) { return $r; } +function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { + $r = menu_fetch_id($menu_id,$uid); + if($r) { + $m = menu_fetch($r[0]['menu_name'],$uid,$observer_hash); + if($m) { + if($delete) + $m['menu_delete'] = 1; + build_sync_packet($uid,array('menu' => array(menu_element($m)))); + } + } +} diff --git a/include/zot.php b/include/zot.php index 285668209..9fac4d40e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2896,6 +2896,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('item_id',$arr) && $arr['item_id']) sync_items($channel,$arr['item_id']); + if(array_key_exists('menu',$arr) && $arr['menu']) + sync_menus($channel,$arr['menu']); + if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { if(array_key_exists('channel_page_flags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) { $arr['channel']['channel_removed'] = (($arr['channel']['channel_pageflags'] & 0x8000) ? 1 : 0); -- cgit v1.2.3 From 50d7554ccd36d483a7fc205215e0d980232ce368 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 18:40:19 -0700 Subject: add sync packets for menus --- include/menu.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/menu.php b/include/menu.php index d20df1d6e..fc8aa1386 100644 --- a/include/menu.php +++ b/include/menu.php @@ -388,3 +388,14 @@ function menu_del_item($menu_id,$uid,$item_id) { return $r; } +function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { + $r = menu_fetch_id($menu_id,$uid); + if($r) { + $m = menu_fetch($r['menu_name'],$uid,$observer_hash); + if($m) { + if($delete) + $m['menu_delete'] = 1; + build_sync_packet($uid,array('menu' => array(menu_element($m)))); + } + } +} -- cgit v1.2.3 From f0847e6f32ceb5a91109f968225b3492dcfe6c9c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 18:40:56 -0700 Subject: debugging menu sync --- include/import.php | 2 ++ include/menu.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 7b2f574d9..e468889b4 100644 --- a/include/import.php +++ b/include/import.php @@ -690,6 +690,7 @@ function sync_menus($channel,$menus) { } $editing = false; + $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1", dbesc($m['menu_name']), intval($channel['channel_id']) @@ -702,6 +703,7 @@ function sync_menus($channel,$menus) { continue; } $menu_id = $r[0]['menu_id']; + $m['menu_id'] = $r[0]['menu_id']; $x = menu_edit($m); if(! $x) continue; diff --git a/include/menu.php b/include/menu.php index 32d8630a6..075372515 100644 --- a/include/menu.php +++ b/include/menu.php @@ -238,7 +238,6 @@ function menu_edit($arr) { return false; } - $r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1", intval($menu_id), intval($menu_channel_id) @@ -391,7 +390,7 @@ function menu_del_item($menu_id,$uid,$item_id) { function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) { $r = menu_fetch_id($menu_id,$uid); if($r) { - $m = menu_fetch($r[0]['menu_name'],$uid,$observer_hash); + $m = menu_fetch($r['menu_name'],$uid,$observer_hash); if($m) { if($delete) $m['menu_delete'] = 1; -- cgit v1.2.3 From e6690c818df5f64f26a92bdbbeb867056bab6a1a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:13:43 -0700 Subject: export TERM_FILE when mirroring --- include/identity.php | 1 + include/items.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 4d2f8b961..d84c22693 100644 --- a/include/identity.php +++ b/include/identity.php @@ -666,6 +666,7 @@ function identity_export_year($channel_id,$year,$month = 0) { $target_month = '01'; $ret = array(); + $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00'); if($month && $month < 12) $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00'); diff --git a/include/items.php b/include/items.php index 981f52d7a..3669628b4 100755 --- a/include/items.php +++ b/include/items.php @@ -1260,7 +1260,7 @@ function encode_item($item,$mirror = false) { $x['comment_scope'] = $c_scope; if($item['term']) - $x['tags'] = encode_item_terms($item['term']); + $x['tags'] = encode_item_terms($item['term'],$mirror); if($item['diaspora_meta']) $x['diaspora_signature'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key); @@ -1349,6 +1349,11 @@ function encode_item_terms($terms) { $allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK ); + if($mirror) { + $allowed_export_terms[] = TERM_PCATEGORY; + $allowed_export_terms[] = TERM_FILE; + } + if($terms) { foreach($terms as $term) { if(in_array($term['type'],$allowed_export_terms)) -- cgit v1.2.3 From f13a8f725c393961b4e3cfa79f1eff348f3893f3 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 19:14:29 -0700 Subject: export TERM_FILE when mirroring --- include/items.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 5d38b0982..4c21d55a1 100755 --- a/include/items.php +++ b/include/items.php @@ -1309,7 +1309,7 @@ function encode_item($item,$mirror = false) { $x['comment_scope'] = $c_scope; if($item['term']) - $x['tags'] = encode_item_terms($item['term']); + $x['tags'] = encode_item_terms($item['term'],$mirror); if($item['diaspora_meta']) { $z = json_decode($item['diaspora_meta'],true); @@ -1401,11 +1401,16 @@ function encode_item_xchan($xchan) { return $ret; } -function encode_item_terms($terms) { +function encode_item_terms($terms,$mirror = false) { $ret = array(); $allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK ); + if($mirror) { + $allowed_export_terms[] = TERM_PCATEGORY; + $allowed_export_terms[] = TERM_FILE; + } + if($terms) { foreach($terms as $term) { if(in_array($term['type'],$allowed_export_terms)) -- cgit v1.2.3 From d702133ded36f23a79f7aed22c7d20ad263cff7b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 20:48:35 -0700 Subject: move mod_admin to Comanche finally --- include/widgets.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 42d9db19a..8c5e92140 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1074,4 +1074,63 @@ function widget_helpindex($arr) { $o .= ''; return $o; +} + + + +function widget_admin($arr) { + + /* + * Side bar links + */ + + if(! is_site_admin()) { + return login(false); + } + + + $a = get_app(); + $o = ''; + + // array( url, name, extra css classes ) + + $aside = array( + 'site' => array(z_root() . '/admin/site/', t('Site'), 'site'), + 'users' => array(z_root() . '/admin/users/', t('Accounts'), 'users'), + 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), + 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), + 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), + 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), + 'dbsync' => array(z_root() . '/admin/dbsync/', t('DB updates'), 'dbsync') + + ); + + /* get plugins admin page */ + + $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); + + $aside['plugins_admin'] = array(); + if($r) { + foreach ($r as $h){ + $plugin = $h['name']; + $aside['plugins_admin'][] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); + // temp plugins with admin + $a->plugins_admin[] = $plugin; + } + } + + $aside['logs'] = array(z_root() . '/admin/logs/', t('Logs'), 'logs'); + + $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( + '$admin' => $aside, + '$admtxt' => t('Admin'), + '$plugadmtxt' => t('Plugin Features'), + '$logtxt' => t('Logs'), + '$h_pending' => t('User registrations waiting for confirmation'), + '$admurl'=> z_root() . '/admin/' + )); + + return $o; + } \ No newline at end of file -- cgit v1.2.3 From 0a051ff2cd13eb33ecffc3c4e34a1a56a3fcf29a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 8 Sep 2015 22:46:34 -0700 Subject: preserve code blocks on item import if channel has code rights. When importing the channel itself, turn code access off unless this is the admin. --- include/api.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ include/import.php | 18 +++++++++++++++++- include/items.php | 17 +++++++++++++++-- 3 files changed, 81 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 6d71cfc33..a77bf15f7 100644 --- a/include/api.php +++ b/include/api.php @@ -896,6 +896,55 @@ require_once('include/items.php'); api_register_func('api/red/item/new','red_item_new', true); + function red_item(&$a, $type) { + + if (api_user() === false) { + logger('api_red_item_new: no user'); + return false; + } + + if($_REQUEST['mid']) { + $arr = array('mid' => $_REQUEST['mid']); + } + elseif($_REQUEST['item_id']) { + $arr = array('item_id' => $_REQUEST['item_id']); + } + else + json_return_and_die(array()); + + $arr['start'] = 0; + $arr['records'] = 999999; + $arr['item_type'] = '*'; + + $i = items_fetch($arr,$a->get_channel(),get_observer_hash()); + + if(! $i) + json_return_and_die(array()); + + $ret = array(); + $tmp = array(); + $str = ''; + foreach($i as $ii) { + $tmp[] = encode_item($ii,true); + if($str) + $str .= ','; + $str .= $ii['id']; + } + $ret['item'] = $tmp; + if($str) { + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item.id in ( $str ) "); + + if($r) + $ret['item_id'] = $r; + } + + json_return_and_die($ret); + } + + api_register_func('api/red/item/full','red_item', true); + + + function api_get_status($xchan_hash) { require_once('include/security.php'); diff --git a/include/import.php b/include/import.php index e468889b4..168446be9 100644 --- a/include/import.php +++ b/include/import.php @@ -50,6 +50,11 @@ function import_channel($channel) { unset($channel['channel_id']); $channel['channel_account_id'] = get_account_id(); $channel['channel_primary'] = (($seize) ? 1 : 0); + + if($channel['channel_pageflags'] & PAGE_ALLOWCODE) { + if(! is_site_admin()) + $channel['channel_pageflags'] = $channel['channel_pageflags'] ^ PAGE_ALLOWCODE; + } dbesc_array($channel); @@ -480,8 +485,19 @@ function sync_chatrooms($channel,$chatrooms) { function import_items($channel,$items) { if($channel && $items) { + $allow_code = false; + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id + where channel_id = %d limit 1", + intval($channel['channel_id']) + ); + if($r) { + if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { + $allow_code = true; + } + } + foreach($items as $i) { - $item = get_item_elements($i); + $item = get_item_elements($i,$allow_code); if(! $item) continue; diff --git a/include/items.php b/include/items.php index 4c21d55a1..28fd8502b 100755 --- a/include/items.php +++ b/include/items.php @@ -833,10 +833,13 @@ function title_is_body($title, $body) { } -function get_item_elements($x) { +function get_item_elements($x,$allow_code = false) { $arr = array(); - $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); + if($allow_code) + $arr['body'] = $x['body']; + else + $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : ''); $key = get_config('system','pubkey'); @@ -4731,6 +4734,12 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C if($arr['wall']) $sql_options .= " and item_wall = 1 "; + + if($arr['item_id']) + $sql_options .= " and parent = " . intval($arr['item_id']) . " "; + + if($arr['mid']) + $sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' "; $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) "; @@ -4857,11 +4866,15 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash); + if($arr['pages']) $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " "; else $item_restrict = " AND item_type = 0 "; + if($arr['item_type'] === '*') + $item_restrict = ''; + if ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD) && $channel) { // "New Item View" - show all items unthreaded in reverse created date order -- cgit v1.2.3 From 4af339da636e70b2695c12881f5dbc086e55a656 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 9 Sep 2015 18:18:27 -0700 Subject: slight hack to improve public forum detection in the forum widget --- include/message.php | 1 + include/widgets.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/message.php b/include/message.php index 396e3162c..efe1a7710 100644 --- a/include/message.php +++ b/include/message.php @@ -49,6 +49,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' // look for any existing conversation structure + if(strlen($replyto)) { $r = q("select convid from mail where channel_id = %d and ( mid = '%s' or parent_mid = '%s' ) limit 1", intval(local_channel()), diff --git a/include/widgets.php b/include/widgets.php index 8c5e92140..9f7380c87 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1007,7 +1007,9 @@ function widget_forums($arr) { $perms_sql = item_permissions_sql(local_channel()) . item_normal(); - $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where xchan_pubforum = 1 and abook_channel = %d order by xchan_name $limit ", + $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and abook_channel = %d order by xchan_name $limit ", + intval(PERMS_W_TAGWALL), + intval(PERMS_W_STREAM), intval(local_channel()) ); if(! $r1) -- cgit v1.2.3 From 43e064749cfb5cd9d4a0e64991bf297f28a3a6d4 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 9 Sep 2015 18:50:15 -0700 Subject: major changes to "forum mode" on the network/matrix page --- include/widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 9f7380c87..5e40bf54a 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1036,7 +1036,7 @@ function widget_forums($arr) { foreach($r1 as $rr) { if($unseen && (! intval($rr['unseen']))) continue; - $o .= '
  • ' . ((intval($rr['unseen'])) ? intval($rr['unseen']) : '') . ' ' . $rr['xchan_name'] . '
  • '; + $o .= '
  • ' . ((intval($rr['unseen'])) ? intval($rr['unseen']) : '') . ' ' . $rr['xchan_name'] . '
  • '; } $o .= ''; } -- cgit v1.2.3 From db58b6223503a63f92cccddd87179ae8e3ae1e46 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 9 Sep 2015 19:54:16 -0700 Subject: don't auto-open the editor in forum mode. Save the forum selection text until we open it. --- include/conversation.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a3fdf39df..fb8ef8585 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1137,6 +1137,7 @@ function status_editor($a, $x, $popup = false) { '$newpost' => 'true', '$baseurl' => $a->get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$pretext' => ((x($x,'pretext')) ? $x['pretext'] : ''), '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => t('Visible to everybody'), -- cgit v1.2.3 From 2d94a038a5055e7df76799f8fe110991cedbee88 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 10 Sep 2015 01:21:18 -0700 Subject: ensure connections have a name --- include/network.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/network.php b/include/network.php index 75729d6e4..d3320f3ee 100644 --- a/include/network.php +++ b/include/network.php @@ -1137,6 +1137,8 @@ function discover_by_webbie($webbie) { if($hcard) { $vcard = scrape_vcard($hcard); $vcard['nick'] = substr($webbie,0,strpos($webbie,'@')); + if(! $vcard['fn']) + $vcard['fn'] = $webbie; } $r = q("select * from xchan where xchan_hash = '%s' limit 1", -- cgit v1.2.3 From 50e32c3d8a9eb9d7b4c449224e0ad3da5d44f9e0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 10 Sep 2015 16:48:08 -0700 Subject: zot_refresh: always try the hubloc pointed to by xchan_addr first --- include/zot.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 0376dc7f5..a81c13707 100644 --- a/include/zot.php +++ b/include/zot.php @@ -296,9 +296,18 @@ function zot_refresh($them, $channel = null, $force = false) { if ($them['hubloc_url']) { $url = $them['hubloc_url']; } else { - $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'", - dbesc($them['xchan_hash']) - ); + $r = null; + + if(array_key_exists('xchan_addr',$them) && $them['xchan_addr']) { + $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_addr = '%s'", + dbesc($them['xchan_addr']) + ); + } + if(! $r) { + $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'", + dbesc($them['xchan_hash']) + ); + } if ($r) { foreach ($r as $rr) { if ($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) { -- cgit v1.2.3 From 00b480527a13d64299401292f2b6b1bb416f11c1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 10 Sep 2015 17:53:06 -0700 Subject: provide remote delivery report at logger_debug level --- include/zot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index a5ddd661c..6b5ea4be3 100644 --- a/include/zot.php +++ b/include/zot.php @@ -972,7 +972,7 @@ function zot_process_response($hub, $arr, $outq) { ); } - logger('zot_process_response: ' . print_r($x,true), LOGGER_DATA); + logger('zot_process_response: ' . print_r($x,true), LOGGER_DEBUG); } /** @@ -2236,7 +2236,7 @@ function sync_locations($sender, $arr, $absolute = false) { // Absolute sync - make sure the current primary is correctly reflected in the xchan $pr = hubloc_change_primary($r[0]); if($pr) { - $what .= 'xchan_primary'; + $what .= 'xchan_primary '; $changed = true; } } -- cgit v1.2.3 From 4abfd4053a955a70c461290b7220145d2ce1a861 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 10 Sep 2015 19:18:12 -0700 Subject: sync likes --- include/import.php | 37 +++++++++++++++++++++++++++++++++++++ include/zot.php | 3 +++ 2 files changed, 40 insertions(+) (limited to 'include') diff --git a/include/import.php b/include/import.php index 168446be9..ad8bcd84e 100644 --- a/include/import.php +++ b/include/import.php @@ -762,6 +762,43 @@ function sync_menus($channel,$menus) { +function import_likes($channel,$likes) { + if($channel && $likes) { + foreach($likes as $like) { + if($like['deleted']) { + q("delete from likes where liker = '%s' and likee = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s'", + dbesc($like['liker']), + dbesc($like['likee']), + dbesc($like['verb']), + dbesc($like['target_type']), + dbesc($like['target_id']) + ); + continue; + } + + unset($like['id']); + unset($like['iid']); + $like['channel_id'] = $channel['channel_id']; + $r = q("select * from likes where liker = '%s' and likee = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' and i_mid = '%s'", + dbesc($like['liker']), + dbesc($like['likee']), + dbesc($like['verb']), + dbesc($like['target_type']), + dbesc($like['target_id']), + dbesc($like['i_mid']) + ); + if($r) + continue; + + dbesc_array($config); + $r = dbq("INSERT INTO likes (`" + . implode("`, `", array_keys($like)) + . "`) VALUES ('" + . implode("', '", array_values($like)) + . "')" ); + } + } +} diff --git a/include/zot.php b/include/zot.php index 6b5ea4be3..0e00f39b4 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2888,6 +2888,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('obj',$arr) && $arr['obj']) sync_objs($channel,$arr['obj']); + if(array_key_exists('likes',$arr) && $arr['likes']) + import_likes($channel,$arr['likes']); + if(array_key_exists('app',$arr) && $arr['app']) sync_apps($channel,$arr['app']); -- cgit v1.2.3