aboutsummaryrefslogtreecommitdiffstats
path: root/include/channel.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/channel.php')
-rw-r--r--include/channel.php116
1 files changed, 93 insertions, 23 deletions
diff --git a/include/channel.php b/include/channel.php
index 95a3f96cf..e4b6df47b 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -873,6 +873,13 @@ function identity_basic_export($channel_id, $sections = null) {
$ret['abook'][$x]['abconfig'] = $abconfig;
translate_abook_perms_outbound($ret['abook'][$x]);
}
+
+ // pick up the zot6 xchan and hublocs also
+
+ if($ret['channel']['channel_portable_id']) {
+ $xchans[] = $ret['channel']['channel_portable_id'];
+ }
+
stringify_array_elms($xchans);
}
@@ -948,6 +955,18 @@ function identity_basic_export($channel_id, $sections = null) {
}
$ret['app'] = $r;
}
+ $r = q("select * from app where app_channel = %d and app_system = 1",
+ intval($channel_id)
+ );
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['term'] = q("select * from term where otype = %d and oid = %d",
+ intval(TERM_OBJ_APP),
+ intval($r[$x]['id'])
+ );
+ }
+ $ret['sysapp'] = $r;
+ }
}
if(in_array('chatrooms',$sections)) {
@@ -1080,6 +1099,7 @@ function identity_basic_export($channel_id, $sections = null) {
return $ret;
}
+
/**
* @brief Export items for a year, or a month of a year.
*
@@ -1102,23 +1122,50 @@ function identity_export_year($channel_id, $year, $month = 0) {
else
$target_month = '01';
+ $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');
+ else
+ $maxdate = datetime_convert('UTC', 'UTC', $year+1 . '-01-01 00:00:00');
+
+ return channel_export_items_date($channel_id,$mindate,$maxdate);
+
+}
+
+/**
+ * @brief Export items within an arbitrary date range.
+ *
+ * Date/time is in UTC.
+ *
+ * @param int $channel_id The channel ID
+ * @param string $start
+ * @param string $finish
+ * @return array
+ */
+
+function channel_export_items_date($channel_id, $start, $finish) {
+
+ if(! $start)
+ return array();
+ else
+ $start = datetime_convert('UTC', 'UTC', $start);
+
+ $finish = datetime_convert('UTC', 'UTC', (($finish) ? $finish : 'now'));
+ if($finish < $start)
+ return array();
+
$ret = array();
$ch = channelx_by_n($channel_id);
if($ch) {
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
}
- $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');
- else
- $maxdate = datetime_convert('UTC', 'UTC', $year+1 . '-01-01 00:00:00');
- $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created",
+ $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created",
intval(ITEM_TYPE_POST),
intval($channel_id),
- dbesc($mindate),
- dbesc($maxdate)
+ dbesc($start),
+ dbesc($finish)
);
if($r) {
@@ -1132,39 +1179,57 @@ function identity_export_year($channel_id, $year, $month = 0) {
return $ret;
}
+
+
/**
- * @brief Export items within an arbitrary date range.
+ * @brief Export items with pagination
*
- * Date/time is in UTC.
*
* @param int $channel_id The channel ID
- * @param string $start
- * @param string $finish
+ * @param int $page
+ * @param int $limit (default 50)
* @return array
*/
-function channel_export_items($channel_id, $start, $finish) {
+
+function channel_export_items_page($channel_id, $start, $finish, $page = 0, $limit = 50) {
+
+ if(intval($page) < 1) {
+ $page = 0;
+ }
+
+ if(intval($limit) < 1) {
+ $limit = 1;
+ }
+
+ if(intval($limit) > 5000) {
+ $limit = 5000;
+ }
if(! $start)
- return array();
+ $start = NULL_DATE;
else
$start = datetime_convert('UTC', 'UTC', $start);
$finish = datetime_convert('UTC', 'UTC', (($finish) ? $finish : 'now'));
if($finish < $start)
- return array();
+ return [];
- $ret = array();
+ $offset = intval($limit) * intval($page);
+
+ $ret = [];
$ch = channelx_by_n($channel_id);
if($ch) {
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
}
- $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created",
+ $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type = '' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
intval(ITEM_TYPE_POST),
intval($channel_id),
dbesc($start),
- dbesc($finish)
+ dbesc($finish),
+ intval($limit),
+ intval($offset)
);
if($r) {
@@ -1179,6 +1244,7 @@ function channel_export_items($channel_id, $start, $finish) {
}
+
/**
* @brief Loads a profile into the App structure.
*
@@ -1392,7 +1458,7 @@ function profile_edit_menu($uid) {
* @param boolean $show_connect (optional) default true
* @param mixed $zcard (optional) default false
*
- * @return HTML string suitable for sidebar inclusion
+ * @return string (HTML) suitable for sidebar inclusion
* Exceptions: Returns empty string if passed $profile is wrong type or not populated
*/
function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) {
@@ -1753,13 +1819,16 @@ function zid_init() {
call_hooks('zid_init', $arr);
if(! local_channel()) {
- $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1",
+ $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc",
dbesc($tmp_str)
);
if(! $r) {
Master::Summon(array('Gprobe',bin2hex($tmp_str)));
}
- if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash'])
+ if($r) {
+ $r = zot_record_preferred($r);
+ }
+ if($r && remote_channel() && remote_channel() === $r['hubloc_hash'])
return;
logger('Not authenticated. Invoking reverse magic-auth for ' . $tmp_str);
@@ -1767,8 +1836,8 @@ function zid_init() {
$query = App::$query_string;
$query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query);
$dest = '/' . $query;
- if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) {
- goaway($r[0]['hubloc_url'] . '/magic' . '?f=&rev=1&owa=1&bdest=' . bin2hex(z_root() . $dest));
+ if($r && ($r['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) {
+ goaway($r['hubloc_url'] . '/magic' . '?f=&rev=1&owa=1&bdest=' . bin2hex(z_root() . $dest));
}
else
logger('No hubloc found.');
@@ -1789,6 +1858,7 @@ function zat_init() {
);
if($r) {
$xchan = atoken_xchan($r[0]);
+ atoken_create_xchan($xchan);
atoken_login($xchan);
}
}