diff --git a/Code/Module/Settings/Identities.php b/Code/Module/Settings/Identities.php index e9693446f..686e729d3 100644 --- a/Code/Module/Settings/Identities.php +++ b/Code/Module/Settings/Identities.php @@ -20,19 +20,25 @@ class Identities extends Controller } if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $id = (argc() > 2) ? intval(argv(2)) : null; + $id = (isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null); } else { - $id = ($_REQUEST['id'] ? intval($_REQUEST['id']) - 1 : null); + $id = (argc() > 2) ? intval(argv(2)) : null; + } + $identities = $this->getIdentities(); $delete = ($_REQUEST['drop'] ? boolval($_REQUEST['drop']) : false); + $edit = ($_REQUEST['edit'] ? boolval($_REQUEST['edit']) : false); $description = (($_REQUEST['description']) ? escape_tags(trim($_REQUEST['description'])) : '' ); $url = (($_REQUEST['url']) ? escape_tags(trim($_REQUEST['url'])) : '' ); + if (!$edit && !$delete && $_SERVER['REQUEST_METHOD'] !== 'POST') { + return; + } if ($delete && isset($id)) { - unset($identities['id']); + unset($identities[$id]); } else { if (isset($id) && $description && $url) { @@ -42,16 +48,18 @@ class Identities extends Controller } } if ($identities) { - PConfig::Set(local_channel(), 'system', 'identities', $identities); + PConfig::Set(local_channel(), 'system', 'identities', array_values($identities)); } else { PConfig::Delete(local_channel(), 'system','identities'); } - $this->check_identities(); - - - // build_sync_packet - + if ($delete) { + goaway(z_root() . '/settings/identities'); + } + else + { + $this->check_identity($url); + } } public function get() @@ -105,44 +113,39 @@ class Identities extends Controller PConfig::Set(local_channel(),'system','identities', $identities); } - protected function check_identities() + protected function check_identity($url) { $channel = App::get_channel(); $myUrl = z_root() . '/channel/' . $channel['channel_address']; $myIdentity = $channel['channel_hash']; - $identities = $this->getIdentities(); $links = $this->loadIdentities($myIdentity); - foreach ($identities as $identity) { - $currentRecord = $this->matchRecord($identity[1], $links); - $validator = new Relme(); - $isMe = $validator->RelmeValidate($identity[1], $myUrl); + $currentRecord = $this->matchRecord($url, $links); + $validator = new Relme(); + $isMe = $validator->RelmeValidate($url, $myUrl); + if ($isMe) { if ($currentRecord) { q("update linkid set sigtype = %d where link_id = %d", - intval($isMe ? IDLINK_RELME : IDLINK_NONE), + intval(IDLINK_RELME), intval($currentRecord['link_id']) ); } else { q("insert into linkid (ident, link, ikey, lkey, isig, lsig, sigtype) values ( '%s', '%s', '', '', '', '', %d) ", dbesc($myIdentity), - dbesc($identity[1]), - intval($isMe ? IDLINK_RELME : IDLINK_NONE) + dbesc($url), + intval(IDLINK_RELME) ); } $links = $this->loadIdentities($myIdentity); } - - foreach ($links as $link) { - if (! $this->matchLinks($link['link'], $identities)) { - q("delete from linkid where link_id = %d", - intval($link['link_id']) - ); - } + else { + q("delete from linkid where ident = '%s' and link = '%s'", + dbesc($myIdentity), + dbesc($url) + ); } - q("delete from linkid where sigtype = %d", - intval(IDLINK_NONE) - ); + return $isMe; } protected function loadIdentities($myIdentity) diff --git a/include/items.php b/include/items.php index ec165fa79..d3999d488 100644 --- a/include/items.php +++ b/include/items.php @@ -2900,7 +2900,7 @@ function i_am_mentioned($channel,$item,$check_groups = false) { */ function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $group = false, $edit = false) { - btlogger('start_chain: ' . $channel['channel_id'] . ' item: ' . $item_id); + // btlogger('start_chain: ' . $channel['channel_id'] . ' item: ' . $item_id); $moderated = perm_is_allowed($channel['channel_id'], $item['author_xchan'], 'moderated'); $source = check_item_source($channel['channel_id'],$item); diff --git a/view/tpl/identity_settings.tpl b/view/tpl/identity_settings.tpl index 3b02c82e1..436db1977 100644 --- a/view/tpl/identity_settings.tpl +++ b/view/tpl/identity_settings.tpl @@ -15,7 +15,7 @@
{{$identity.0}}
-
+
{{/foreach}} @@ -25,6 +25,9 @@
{{include file="field_input.tpl" field=$description}} {{include file="field_input.tpl" field=$url}} + {{if isset($id) }} + + {{/if}}