aboutsummaryrefslogtreecommitdiffstats
path: root/include/channel.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-06-28 13:36:48 -0700
committerredmatrix <git@macgirvin.com>2016-06-28 13:36:48 -0700
commit7d62e087c65d964282171dd736e337cba135610f (patch)
tree68db35a16ec3a91b7533ced90233d015e848293d /include/channel.php
parent7b2d54dffac5a5ee3c0ff79aee964ac0869b3142 (diff)
downloadvolse-hubzilla-7d62e087c65d964282171dd736e337cba135610f.tar.gz
volse-hubzilla-7d62e087c65d964282171dd736e337cba135610f.tar.bz2
volse-hubzilla-7d62e087c65d964282171dd736e337cba135610f.zip
identity_export_year() was a bit short-sighted. We really require arbitrary date ranges. A new function was created to tackle this - channel_export_items() which takes a channel, and a start and finish date. Finish date will default to "now" if not set. Will be working this into the interface under a module named "export_items" which will correspond closely to the existing "import_items" module you'll need to do the reverse operation. Will also make it available via the API. Once that is complete, I anticipate removing identity_export_year() as it will then be somewhat redundant, and modifying the documentation on the channel export page accordingly. Note: the function works strictly in GMT so an interface would need to convert from channel local time.
Diffstat (limited to 'include/channel.php')
-rw-r--r--include/channel.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/channel.php b/include/channel.php
index 913768017..95506ed78 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -747,6 +747,44 @@ function identity_export_year($channel_id,$year,$month = 0) {
return $ret;
}
+// export items within an arbitrary date range. Date/time is in UTC.
+
+function channel_export_items($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()];
+ }
+
+ $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($start),
+ dbesc($finish)
+ );
+
+ if($r) {
+ $ret['item'] = array();
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+ foreach($r as $rr)
+ $ret['item'][] = encode_item($rr,true);
+ }
+
+ return $ret;
+}
+
/**
* @brief Loads a profile into the App structure.