From 732c6134ddfc6bb1df191c7967069e008d85acfb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 14 Oct 2015 13:11:24 -0700 Subject: support for mail sync --- include/identity.php | 25 +++++++++++++++++++++++++ include/items.php | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index d84c22693..edf91f5bf 100644 --- a/include/identity.php +++ b/include/identity.php @@ -622,6 +622,31 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['likes'] = $r; + + $r = q("select * from conv where uid = %d", + intval($channel_id) + ); + if($r) + $ret['conv'] = $r; + + + $r = q("select mail.*, conv.guid as conv_guid from mail left join conv on mail.convid = conv.id where mail.uid = %d", + intval($channel_id) + ); + if($r) { + $m = array(); + foreach($r as $rr) { + + + + + } + $ret['mail'] = $m; + } + + + + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", intval($channel_id) ); diff --git a/include/items.php b/include/items.php index eed9dabb2..54dcf2b51 100755 --- a/include/items.php +++ b/include/items.php @@ -1561,7 +1561,7 @@ function encode_item_flags($item) { return $ret; } -function encode_mail($item) { +function encode_mail($item,$extended = false) { $x = array(); $x['type'] = 'mail'; $x['encoding'] = 'zot'; @@ -1595,6 +1595,18 @@ function encode_mail($item) { $x['body'] = ''; } + if($extended) { + $x['conv_guid'] = $item['conv_guid']; + if($item['mail_flags'] & MAIL_DELETED) + $x['flags'][] = 'deleted'; + if($item['mail_flags'] & MAIL_REPLIED) + $x['flags'][] = 'replied'; + if($item['mail_flags'] & MAIL_ISREPLY) + $x['flags'][] = 'isreply'; + if($item['mail_flags'] & MAIL_SEEN) + $x['flags'][] = 'seen'; + } + return $x; } @@ -1619,6 +1631,18 @@ function get_mail_elements($x) { if(in_array('recalled',$x['flags'])) { $arr['mail_flags'] |= MAIL_RECALLED; } + if(in_array('replied',$x['flags'])) { + $arr['mail_flags'] |= MAIL_REPLIED; + } + if(in_array('isreply',$x['flags'])) { + $arr['mail_flags'] |= MAIL_ISREPLY; + } + if(in_array('seen',$x['flags'])) { + $arr['mail_flags'] |= MAIL_SEEN; + } + if(in_array('deleted',$x['flags'])) { + $arr['mail_flags'] |= MAIL_DELETED; + } } $key = get_config('system','pubkey'); -- cgit v1.2.3 From f4e708a02f70e0ca2dbe43419d6f1c92ff2000e9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 14 Oct 2015 13:19:28 -0700 Subject: port of mail encoding --- include/items.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index e69e83b83..5569cd1e4 100755 --- a/include/items.php +++ b/include/items.php @@ -1594,13 +1594,13 @@ function encode_mail($item,$extended = false) { if($extended) { $x['conv_guid'] = $item['conv_guid']; - if($item['mail_flags'] & MAIL_DELETED) + if(intval($item['mail_deleted'])) $x['flags'][] = 'deleted'; - if($item['mail_flags'] & MAIL_REPLIED) + if(intval($item['mail_replied'])) $x['flags'][] = 'replied'; - if($item['mail_flags'] & MAIL_ISREPLY) + if(intval($item['mail_isreply'])) $x['flags'][] = 'isreply'; - if($item['mail_flags'] & MAIL_SEEN) + if(intval($item['mail_seen'])) $x['flags'][] = 'seen'; } @@ -1629,16 +1629,16 @@ function get_mail_elements($x) { $arr['mail_recalled'] = 1; } if(in_array('replied',$x['flags'])) { - $arr['mail_flags'] |= MAIL_REPLIED; + $arr['mail_replied'] = 1; } if(in_array('isreply',$x['flags'])) { - $arr['mail_flags'] |= MAIL_ISREPLY; + $arr['mail_isreply'] = 1; } if(in_array('seen',$x['flags'])) { - $arr['mail_flags'] |= MAIL_SEEN; + $arr['mail_seen'] = 1; } if(in_array('deleted',$x['flags'])) { - $arr['mail_flags'] |= MAIL_DELETED; + $arr['mail_deleted'] = 1; } } -- cgit v1.2.3 From b2d949ce9a499653bba833913084b0c1406cca7f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 14 Oct 2015 13:25:58 -0700 Subject: issue #82 - args not defined (should be arr) --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 0ed1690ec..fc95e3a75 100644 --- a/include/attach.php +++ b/include/attach.php @@ -595,7 +595,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } } else { - $folder_hash = ((array_key_exists('folder',$args)) ? $args['folder'] : ''); + $folder_hash = ((($arr) && array_key_exists('folder',$arr)) ? $arr['folder'] : ''); } if((! $options) || ($options === 'import')) { -- cgit v1.2.3