diff options
author | Michael Meer <michael@meer.name> | 2014-01-24 11:59:15 +0100 |
---|---|---|
committer | Michael Meer <michael@meer.name> | 2014-01-24 11:59:15 +0100 |
commit | 844df110586e6726581c620754fef5419f6bea5e (patch) | |
tree | c0d8cb4bd3ad946ca91fed3d5d90227d796c0bfe /mod | |
parent | a2b07ed2814972507bf971a5ac6ed09c399e29e7 (diff) | |
parent | 21f6549204f60670af55c7ba22a00f7d7eae9c2b (diff) | |
download | volse-hubzilla-844df110586e6726581c620754fef5419f6bea5e.tar.gz volse-hubzilla-844df110586e6726581c620754fef5419f6bea5e.tar.bz2 volse-hubzilla-844df110586e6726581c620754fef5419f6bea5e.zip |
Merge branch 'master' of https://github.com/friendica/red
to be in sync with master repro
Diffstat (limited to 'mod')
-rw-r--r-- | mod/profiles.php | 40 | ||||
-rw-r--r-- | mod/profperm.php | 63 |
2 files changed, 46 insertions, 57 deletions
diff --git a/mod/profiles.php b/mod/profiles.php index b94e4bf03..c71ad9733 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -256,35 +256,23 @@ function profiles_post(&$a) { if(strpos($lookup,'@') === 0) $lookup = substr($lookup,1); $lookup = str_replace('_',' ', $lookup); - if(strpos($lookup,'@') || (strpos($lookup,'http://'))) { - $newname = $lookup; - $links = @lrdd($lookup); - if(count($links)) { - foreach($links as $link) { - if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { - $prf = $link['@attributes']['href']; - } - } - } - } - else { - $newname = $lookup; - - $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", - dbesc($newname), + $newname = $lookup; + + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1", + dbesc($newname), + intval(local_user()) + ); + if(! $r) { + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE xchan_addr = '%s' AND abook_channel = %d LIMIT 1", + dbesc($lookup . '@%'), intval(local_user()) ); - if(! $r) { - $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", - dbesc($lookup), - intval(local_user()) - ); - } - if(count($r)) { - $prf = $r[0]['url']; - $newname = $r[0]['name']; - } } + if($r) { + $prf = $r[0]['xchan_url']; + $newname = $r[0]['xchan_name']; + } + if($prf) { $with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with); diff --git a/mod/profperm.php b/mod/profperm.php index b31dfc128..08838831b 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -1,11 +1,15 @@ <?php +require_once('include/Contact.php'); + function profperm_init(&$a) { if(! local_user()) return; - $which = $a->user['nickname']; + $channel = $a->get_channel(); + $which = $channel['channel_address']; + $profile = $a->argv[1]; profile_load($a,$which,$profile); @@ -21,7 +25,7 @@ function profperm_content(&$a) { } - if($a->argc < 2) { + if(argc() < 2) { notice( t('Invalid profile identifier.') . EOL ); return; } @@ -35,59 +39,59 @@ function profperm_content(&$a) { $switchtotext = 400; - if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { - $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0 - AND `network` = 'dfrn' AND `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[2]), + if((argc() > 2) && intval(argv(1)) && intval(argv(2))) { + $r = q("SELECT abook_id FROM abook WHERE abook_id = %d and abook_channel = %d limit 1", + intval(argv(2)), intval(local_user()) ); - if(count($r)) - $change = intval($a->argv[2]); + if($r) + $change = intval(argv(2)); } - if(($a->argc > 1) && (intval($a->argv[1]))) { + if((argc() > 1) && (intval(argv(1)))) { $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1", - intval($a->argv[1]), + intval(argv(1)), intval(local_user()) ); - if(! count($r)) { + if(! $r) { notice( t('Invalid profile identifier.') . EOL ); return; } + $profile = $r[0]; - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile_id` = %d", + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = %d", intval(local_user()), - intval($a->argv[1]) + intval(argv(1)) ); $ingroup = array(); - if(count($r)) + if($r) foreach($r as $member) - $ingroup[] = $member['id']; + $ingroup[] = $member['abook_id']; $members = $r; if($change) { if(in_array($change,$ingroup)) { - q("UPDATE `contact` SET `profile_id` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", + q("UPDATE abook SET abook_profile = 0 WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($change), intval(local_user()) ); } else { - q("UPDATE `contact` SET `profile_id` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[1]), + q("UPDATE abook SET abook_profile = %d WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + intval(argv(1)), intval($change), intval(local_user()) ); } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile_id` = %d", + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = %d", intval(local_user()), - intval($a->argv[1]) + intval(argv(1)) ); $members = $r; @@ -95,7 +99,7 @@ function profperm_content(&$a) { $ingroup = array(); if(count($r)) foreach($r as $member) - $ingroup[] = $member['id']; + $ingroup[] = $member['abook_id']; } $o .= '<h2>' . t('Profile Visibility Editor') . '</h2>'; @@ -118,8 +122,8 @@ function profperm_content(&$a) { $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { - if($member['url']) { - $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;'; + if($member['xchan_url']) { + $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['abook_id'] . '); return false;'; $o .= micropro($member,true,'mpprof', $textmode); } } @@ -127,20 +131,17 @@ function profperm_content(&$a) { $o .= '<hr id="prof-separator" />'; $o .= '<div id="prof-all-contcts-title">'; - $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>'; + $o .= '<h3>' . t("All Connections") . '</h3>'; $o .= '</div>'; $o .= '<div id="prof-all-contacts">'; - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 - AND `network` = 'dfrn' ORDER BY `name` ASC", - intval(local_user()) - ); + $r = abook_connections(local_user()); - if(count($r)) { + if($r) { $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); foreach($r as $member) { - if(! in_array($member['id'],$ingroup)) { - $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;'; + if(! in_array($member['abook_id'],$ingroup)) { + $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['abook_id'] . '); return false;'; $o .= micropro($member,true,'mpprof',$textmode); } } |