aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-11-06 18:13:47 -0800
committerfriendica <info@friendica.com>2012-11-06 18:13:47 -0800
commit295b865d065b12c6686592bd34739ac9d9b87978 (patch)
tree1f00cafdc2e4867bd53af98985eb410b17d98d0b
parent55df0452b60d6faf00b782a03c8cc590f08d8f94 (diff)
downloadvolse-hubzilla-295b865d065b12c6686592bd34739ac9d9b87978.tar.gz
volse-hubzilla-295b865d065b12c6686592bd34739ac9d9b87978.tar.bz2
volse-hubzilla-295b865d065b12c6686592bd34739ac9d9b87978.zip
"follow" now creates an address book entry, which means we can start tying that into the "connections" module - still have to turn the "contact edit" page from a mockup to real code, but it's all starting to flow.
-rw-r--r--include/Contact.php32
-rw-r--r--include/follow.php16
-rw-r--r--include/zot.php1
-rw-r--r--mod/connections.php62
-rw-r--r--view/tpl/abook_edit.tpl2
5 files changed, 69 insertions, 44 deletions
diff --git a/include/Contact.php b/include/Contact.php
index a7da29b35..ff798ed74 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -3,8 +3,8 @@
function vcard_from_xchan($xchan) {
return replace_macros(get_markup_template('xchan_vcard.tpl'),array(
- $name => $abook['xchan_name'],
- $photo => $abook['xchan_photo_l']
+ '$name' => $xchan['xchan_name'],
+ '$photo' => $xchan['xchan_photo_l']
));
}
@@ -206,26 +206,23 @@ function contact_photo_menu($contact) {
$poke_link="";
$sparkle = false;
- if($contact['network'] === NETWORK_DFRN) {
+ if($contact['xchan_network'] === NETWORK_ZOT) {
$sparkle = true;
- $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+ $profile_link = $a->get_baseurl() . '/magic?f=&id=' . $contact['abook_id'];
}
else
- $profile_link = $contact['url'];
-
- if($profile_link === 'mailbox')
- $profile_link = '';
+ $profile_link = $contact['xchan_url'];
if($sparkle) {
- $status_link = $profile_link . "?url=status";
- $photos_link = $profile_link . "?url=photos";
- $profile_link = $profile_link . "?url=profile";
- $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+ $status_link = $profile_link . "&url=status";
+ $photos_link = $profile_link . "&url=photos";
+ $profile_link = $profile_link . "&url=profile";
+ $pm_url = $a->get_baseurl() . '/message/new/' . $contact['xchan_hash'];
}
- $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
- $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
- $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
+ $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['abook_id'];
+ $contact_url = $a->get_baseurl() . '/connections/' . $contact['abook_id'];
+ $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['abook_id'];
$menu = Array(
t("Poke") => $poke_link,
@@ -245,10 +242,7 @@ function contact_photo_menu($contact) {
$o = "";
foreach($menu as $k=>$v){
if ($v!="") {
- if(($k !== t("Network Posts")) && ($k !== t("Send PM")) && ($k !== t('Edit Contact')))
- $o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
- else
- $o .= "<li><a href=\"$v\">$k</a></li>\n";
+ $o .= "<li><a href=\"$v\">$k</a></li>\n";
}
}
return $o;
diff --git a/include/follow.php b/include/follow.php
index b3591b8ba..686282624 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -73,6 +73,8 @@ function new_contact($uid,$url,$channel,$interactive = false) {
if(! $x['success'])
return $x;
+ $xchan_hash = $x['hash'];
+
// Do we already have an abook entry?
// go directly to the abook edit page.
@@ -100,10 +102,20 @@ function new_contact($uid,$url,$channel,$interactive = false) {
}
+ $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_created, abook_updated )
+ values( %d, %d, '%s', %d, '%s', '%s' ) ",
+ intval(get_account_id()),
+ intval(local_user()),
+ dbesc($xchan_hash),
+ intval($their_perms),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert())
+ );
+ if(! $r)
+ logger('mod_follow: abook creation failed');
+
- // Else create an entry
-
// Then send a ping/message to the other side
diff --git a/include/zot.php b/include/zot.php
index 46400f597..3d1669c0f 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -294,6 +294,7 @@ function import_xchan_from_json($j) {
if(! x($ret,'message')) {
$ret['success'] = true;
+ $ret['hash'] = $xchan_hash;
}
return $ret;
} \ No newline at end of file
diff --git a/mod/connections.php b/mod/connections.php
index 152395679..6c63d1b14 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -144,18 +144,36 @@ function connections_content(&$a) {
return;
}
+ $xchan = null;
+
if(argc() == 3) {
+ $cmd = argv(2);
- $cmd = argv(1);
- if($cmd === 'profile') {
+ if(argv(1) === 'profile') {
$xchan_hash = argv(2);
if($xchan_hash) {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($xchan_hash)
);
- if($r && count($r)) {
+ if($r) {
+ $xchan = $r[0];
+ }
+ }
+ }
+ elseif(intval(argv(1)) && argv(2) === 'profile')
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_user()),
+ intval(argv(1))
+ );
+ if($r)
+ $xchan = $r[0];
+
+ if($xchan) {
+
$o .= <<< EOT
<script language="JavaScript">
<!--
@@ -188,7 +206,7 @@ window.onresize=resize_iframe;
</script>
-<iframe id="glu" width="100%" src="{$r[0]['xchan_url']}" onload="resize_iframe()">
+<iframe id="glu" width="100%" src="{$xchan['xchan_url']}" onload="resize_iframe()">
</iframe>
EOT;
@@ -196,10 +214,10 @@ EOT;
// $o .= '<div id="profile-frame-wrapper" style="width: 100%; height: 100%;"><iframe id="profile-frame" src="' . $r[0]['xchan_url'] . '" style="width: 100%; height: 100%;"></iframe></div>';
return $o;
- }
- }
+
}
+
$contact_id = intval(argv(1));
if(! $contact_id)
return;
@@ -207,7 +225,7 @@ EOT;
$cmd = argv(2);
$orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_id = %d AND abook_channel = %d AND NOT abook_flags & %d LIMIT 1",
+ WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d ) LIMIT 1",
intval($contact_id),
intval(local_user()),
intval(ABOOK_FLAG_SELF)
@@ -305,7 +323,7 @@ EOT;
$slider_tpl = get_markup_template('contact_slider.tpl');
$slide = replace_macros($slider_tpl,array(
'$me' => t('Me'),
- '$val' => $contact['closeness'],
+ '$val' => $contact['abook_closeness'],
'$intimate' => t('Best Friends'),
'$friends' => t('Friends'),
'$coworkers' => t('Co-workers'),
@@ -316,7 +334,8 @@ EOT;
$o .= replace_macros($tpl,array(
- '$header' => t('Contact Settings') . ' for ' . $contact['name'],
+ '$header' => t('Contact Settings') . ' for ' . $contact['xchan_name'],
+ '$viewprof' => t('View Profile'),
'$slide' => $slide,
'$tab_str' => $tab_str,
'$submit' => t('Submit'),
@@ -324,7 +343,7 @@ EOT;
'$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
'$lbl_info1' => t('Contact Information / Notes'),
'$infedit' => t('Edit contact notes'),
- '$close' => $contact['closeness'],
+ '$close' => $contact['abook_closeness'],
'$them' => t('Their Settings'),
'$me' => t('My Settings'),
@@ -344,7 +363,7 @@ EOT;
'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
'$all_friends' => $all_friends,
'$relation_text' => $relation_text,
- '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
+ '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['xchan_name'],$contact['xchan_url']),
'$blockunblock' => t('Block/Unblock contact'),
'$ignorecont' => t('Ignore contact'),
'$lblcrepair' => t("Repair URL settings"),
@@ -360,7 +379,7 @@ EOT;
'$last_update' => $last_update,
'$udnow' => t('Update now'),
'$profile_select' => contact_profile_assign($contact['profile_id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
- '$contact_id' => $contact['id'],
+ '$contact_id' => $contact['abook_id'],
'$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
@@ -423,7 +442,7 @@ EOT;
}
}
- $sql_extra = "and ( abook_flags & " . $search_flags . " ) ";
+ $sql_extra = (($search_flags) ? "and ( abook_flags & " . $search_flags . " ) " : "");
$search = ((x($_REQUEST,'search')) ? notags(trim($_REQUEST['search'])) : '');
@@ -508,7 +527,6 @@ EOT;
$total = $r[0]['total'];
}
-
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
WHERE abook_channel = %d and not (abook_flags & %d) $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d , %d ",
intval(local_user()),
@@ -540,27 +558,27 @@ EOT;
break;
}
if(($rr['network'] === 'dfrn') && ($rr['rel'])) {
- $url = "redir/{$rr['id']}";
+ $url = "redir/{$rr['abook_id']}";
$sparkle = ' class="sparkle" ';
}
else {
- $url = $rr['url'];
+ $url = $rr['xchan_url'];
$sparkle = '';
}
$contacts[] = array(
- 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
+ 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['xchan_name'],$rr['xchan_url']),
'edit_hover' => t('Edit contact'),
'photo_menu' => contact_photo_menu($rr),
- 'id' => $rr['id'],
+ 'id' => $rr['abook_id'],
'alt_text' => $alt_text,
'dir_icon' => $dir_icon,
- 'thumb' => $rr['thumb'],
- 'name' => $rr['name'],
- 'username' => $rr['name'],
+ 'thumb' => $rr['xchan_photo_m'],
+ 'name' => $rr['xchan_name'],
+ 'username' => $rr['xchan_name'],
'sparkle' => $sparkle,
- 'itemurl' => $rr['url'],
+ 'itemurl' => $rr['xchan_url'],
'url' => $url,
'network' => network_to_name($rr['network']),
);
diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index 487a113bf..82372a297 100644
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -2,7 +2,7 @@
<h2>$header</h2>
<br />
-<a href="" style="background-color: #CCC; padding: 10px; border-radius: 5px;">View Profile</a><a href="" style="background-color: #CCC; padding: 10px; border-radius: 5px; margin-left: 20px;">Archive</a>
+<a href="connections/$contact_id/profile">$viewprof</a>
<div id="contact-edit-wrapper">
<br />