aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-02-29 19:31:52 -0800
committerredmatrix <git@macgirvin.com>2016-02-29 19:31:52 -0800
commitbe2b7c0b5f7f9b8080affbb4bc44c5adda18e82f (patch)
tree6dde06168b0df62044a3fdeaf2b4b9b649165d7a /include
parent44b2503572700ab24e7afad4637f62c413d3d489 (diff)
downloadvolse-hubzilla-be2b7c0b5f7f9b8080affbb4bc44c5adda18e82f.tar.gz
volse-hubzilla-be2b7c0b5f7f9b8080affbb4bc44c5adda18e82f.tar.bz2
volse-hubzilla-be2b7c0b5f7f9b8080affbb4bc44c5adda18e82f.zip
abconfig
Diffstat (limited to 'include')
-rw-r--r--include/config.php66
-rw-r--r--include/identity.php8
-rw-r--r--include/zot.php19
3 files changed, 88 insertions, 5 deletions
diff --git a/include/config.php b/include/config.php
index f65e4a470..51d4e99ac 100644
--- a/include/config.php
+++ b/include/config.php
@@ -549,4 +549,68 @@ function set_aconfig($account_id, $family, $key, $value) {
function del_aconfig($account_id, $family, $key) {
return del_xconfig('a_' . $account_id, $family, $key);
-} \ No newline at end of file
+}
+
+
+function load_abconfig($chash,$xhash) {
+ $r = q("select * from abconfig where chan = '%s' and xchan = '%s'",
+ dbesc($chash),
+ dbesc($xhash)
+ );
+ return $r;
+}
+
+function get_abconfig($chash,$xhash,$family,$key) {
+ $r = q("select * from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' limit 1",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+ if($r) {
+ return ((preg_match('|^a:[0-9]+:{.*}$|s', $r[0]['v'])) ? unserialize($r[0]['v']) : $r[0]['v']);
+ }
+ return false;
+}
+
+
+function set_abconfig($chash,$xhash,$family,$key,$value) {
+
+ $dbvalue = ((is_array($value)) ? serialize($value) : $value);
+ $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
+
+ if(get_abconfig($chash,$xhash,$family,$key) === false) {
+ $r = q("insert into abconfig ( chan, xchan, cat, k, v ) values ( '%s', '%s', '%s', '%s', '%s' ) ",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key),
+ dbesc($dbvalue)
+ );
+ }
+ else {
+ $r = q("update abconfig set v = '%s' where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ",
+ dbesc($dbvalue),
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+ }
+ if($r)
+ return $value;
+ return false;
+}
+
+
+function del_abconfig($chash,$xhash,$family,$key) {
+
+ $r = q("delete from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+
+ return $r;
+}
diff --git a/include/identity.php b/include/identity.php
index caf2de710..478079d39 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -505,8 +505,12 @@ function identity_basic_export($channel_id, $items = false) {
if($r) {
$ret['abook'] = $r;
- foreach($r as $rr)
- $xchans[] = $rr['abook_xchan'];
+ for($x = 0; $x < count($ret['abook']); $x ++) {
+ $xchans[] = $ret['abook'][$x]['abook_chan'];
+ $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']);
+ if($abconfig)
+ $ret['abook'][$x]['abconfig'] = $abconfig;
+ }
stringify_array_elms($xchans);
}
diff --git a/include/zot.php b/include/zot.php
index 01dd06fda..a60a50d8f 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -522,6 +522,11 @@ function zot_refresh($them, $channel = null, $force = false) {
unset($new_connection[0]['abook_id']);
unset($new_connection[0]['abook_account']);
unset($new_connection[0]['abook_channel']);
+
+ $abconfig = load_abconfig($channel['channel_hash'],$new_connection['abook_xchan']);
+ if($abconfig)
+ $new_connection['abconfig'] = $abconfig;
+
build_sync_packet($channel['channel_id'], array('abook' => $new_connection));
}
}
@@ -3124,6 +3129,11 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($arr['abook'] as $abook) {
+ $abconfig = null;
+
+ if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig']))
+ $abconfig = $abook['abconfig'];
+
if(! array_key_exists('abook_blocked',$abook)) {
// convert from redmatrix
$abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001) ? 1 : 0);
@@ -3214,8 +3224,13 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
}
}
-
-
+ if($abconfig) {
+ // @fixme does not handle sync of del_abconfig
+ foreach($abconfig as $abc) {
+ if($abc['chan'] === $channel['channel_hash'])
+ set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
+ }
+ }
}
}