contact edit updates

This commit is contained in:
Friendika 2011-11-09 19:30:14 -08:00
parent 722e8e3d49
commit 15f2ce5459
5 changed files with 104 additions and 47 deletions

View file

@ -150,7 +150,8 @@ function common_friends($uid,$cid) {
$r = q("SELECT `gcontact`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d where `glink`.`cid` = %d and `glink`.`uid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and id != %d ) ", and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and id != %d )
order by `gcontact`.`name` asc ",
intval($cid), intval($cid),
intval($uid), intval($uid),
intval($uid), intval($uid),
@ -181,7 +182,8 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) {
$r = q("SELECT `gcontact`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d LIMIT %d, %d ", where `glink`.`cid` = %d and `glink`.`uid` = %d
order by `gcontact`.`name` asc LIMIT %d, %d ",
intval($cid), intval($cid),
intval($uid), intval($uid),
intval($start), intval($start),

View file

@ -212,17 +212,10 @@ function contacts_content(&$a) {
} }
} }
if(($a->argc == 2) && intval($a->argv[1])) { if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
$contact_id = intval($a->argv[1]); $contact_id = $a->data['contact']['id'];
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", $contact = $a->data['contact'];
intval(local_user()),
intval($contact_id)
);
if(! count($r)) {
notice( t('Contact not found.') . EOL);
return;
}
$tpl = get_markup_template('contact_head.tpl'); $tpl = get_markup_template('contact_head.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl())); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
@ -231,7 +224,7 @@ function contacts_content(&$a) {
$tpl = get_markup_template("contact_edit.tpl"); $tpl = get_markup_template("contact_edit.tpl");
switch($r[0]['rel']) { switch($contact['rel']) {
case CONTACT_IS_FRIEND: case CONTACT_IS_FRIEND:
$dir_icon = 'images/lrarrow.gif'; $dir_icon = 'images/lrarrow.gif';
$relation_text = t('You are mutual friends with %s'); $relation_text = t('You are mutual friends with %s');
@ -249,52 +242,75 @@ function contacts_content(&$a) {
break; break;
} }
$relation_text = sprintf($relation_text,$r[0]['name']); $relation_text = sprintf($relation_text,$contact['name']);
if(($r[0]['network'] === 'dfrn') && ($r[0]['rel'])) { if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
$url = "redir/{$r[0]['id']}"; $url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }
else { else {
$url = $r[0]['url']; $url = $contact['url'];
$sparkle = ''; $sparkle = '';
} }
$insecure = t('Private communications are not available for this contact.'); $insecure = t('Private communications are not available for this contact.');
$last_update = (($r[0]['last-update'] == '0000-00-00 00:00:00') $last_update = (($contact['last-update'] == '0000-00-00 00:00:00')
? t('Never') ? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')); : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
if($r[0]['last-update'] !== '0000-00-00 00:00:00') if($contact['last-update'] !== '0000-00-00 00:00:00')
$last_update .= ' ' . (($r[0]['last-update'] == $r[0]['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); $last_update .= ' ' . (($contact['last-update'] == $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
$lblsuggest = (($r[0]['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
$poll_enabled = (($r[0]['network'] !== NETWORK_DIASPORA) ? true : false); $poll_enabled = (($contact['network'] !== NETWORK_DIASPORA) ? true : false);
$nettype = sprintf( t('Network type: %s'),network_to_name($r[0]['network'])); $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network']));
$common = count_common_friends(local_user(),$r[0]['id']); $common = count_common_friends(local_user(),$contact['id']);
$common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : ''); $common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : '');
$polling = (($r[0]['network'] === NETWORK_MAIL | $r[0]['network'] === NETWORK_FEED) ? 'polling' : ''); $polling = (($contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED) ? 'polling' : '');
$x = count_all_friends(local_user(), $r[0]['id']); $x = count_all_friends(local_user(), $contact['id']);
$all_friends = (($x) ? t('View all contacts') : ''); $all_friends = (($x) ? t('View all contacts') : '');
// tabs
$tabs = array(
array(
'label' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'url' => $a->get_baseurl() . '/contacts/' . $contact_id . '/block',
'sel' => '',
),
array(
'label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'url' => $a->get_baseurl() . '/contacts/' . $contact_id . '/ignore',
'sel' => '',
),
array(
'label' => t('Repair'),
'url' => $a->get_baseurl() . '/crepair/' . $contact_id,
'sel' => '',
)
);
$tab_tpl = get_markup_template('common_tabs.tpl');
$tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$header' => t('Contact Editor'), '$header' => t('Contact Editor'),
'$tab_str' => $tab_str,
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$lbl_vis1' => t('Profile Visibility'), '$lbl_vis1' => t('Profile Visibility'),
'$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $r[0]['name']), '$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'), '$lbl_info1' => t('Contact Information / Notes'),
'$infedit' => t('Edit contact notes'), '$infedit' => t('Edit contact notes'),
'$common_text' => $common_text, '$common_text' => $common_text,
'$common_link' => $a->get_baseurl() . '/common/' . $r[0]['id'], '$common_link' => $a->get_baseurl() . '/common/' . $contact['id'],
'$all_friends' => $all_friends, '$all_friends' => $all_friends,
'$relation_text' => $relation_text, '$relation_text' => $relation_text,
'$visit' => sprintf( t('Visit %s\'s profile [%s]'),$r[0]['name'],$r[0]['url']), '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
'$blockunblock' => t('Block/Unblock contact'), '$blockunblock' => t('Block/Unblock contact'),
'$ignorecont' => t('Ignore contact'), '$ignorecont' => t('Ignore contact'),
'$lblcrepair' => t("Repair URL settings"), '$lblcrepair' => t("Repair URL settings"),
@ -302,22 +318,22 @@ function contacts_content(&$a) {
'$lblsuggest' => $lblsuggest, '$lblsuggest' => $lblsuggest,
'$delete' => t('Delete contact'), '$delete' => t('Delete contact'),
'$nettype' => $nettype, '$nettype' => $nettype,
'$poll_interval' => contact_poll_interval($r[0]['priority'],(! $poll_enabled)), '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
'$poll_enabled' => $poll_enabled, '$poll_enabled' => $poll_enabled,
'$lastupdtext' => t('Last update:'), '$lastupdtext' => t('Last update:'),
'$updpub' => t('Update public posts'), '$updpub' => t('Update public posts'),
'$last_update' => $last_update, '$last_update' => $last_update,
'$udnow' => t('Update now'), '$udnow' => t('Update now'),
'$profile_select' => contact_profile_assign($r[0]['profile-id'],(($r[0]['network'] !== NETWORK_DFRN) ? true : false)), '$profile_select' => contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
'$contact_id' => $r[0]['id'], '$contact_id' => $contact['id'],
'$block_text' => (($r[0]['blocked']) ? t('Unblock') : t('Block') ), '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'$ignore_text' => (($r[0]['readonly']) ? t('Unignore') : t('Ignore') ), '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'$insecure' => (($r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['network'] !== NETWORK_DIASPORA) ? $insecure : ''), '$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
'$info' => $r[0]['info'], '$info' => $contact['info'],
'$blocked' => (($r[0]['blocked']) ? t('Currently blocked') : ''), '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
'$ignored' => (($r[0]['readonly']) ? t('Currently ignored') : ''), '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
'$photo' => $r[0]['photo'], '$photo' => $contact['photo'],
'$name' => $r[0]['name'], '$name' => $contact['name'],
'$dir_icon' => $dir_icon, '$dir_icon' => $dir_icon,
'$alt_text' => $alt_text, '$alt_text' => $alt_text,
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
@ -325,7 +341,7 @@ function contacts_content(&$a) {
)); ));
$arr = array('contact' => $r[0],'output' => $o); $arr = array('contact' => $contact,'output' => $o);
call_hooks('contact_edit', $arr); call_hooks('contact_edit', $arr);

View file

@ -1,5 +1,37 @@
<?php <?php
function crepair_init(&$a) {
if(! local_user())
return;
$contact_id = 0;
if(($a->argc == 2) && intval($a->argv[1])) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
intval($contact_id)
);
if(! count($r)) {
$contact_id = 0;
}
}
if(! x($a->page,'aside'))
$a->page['aside'] = '';
if($contact_id) {
$a->data['contact'] = $r[0];
$o .= '<div class="vcard">';
$o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
$o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
$o .= '</div>';
$a->page['aside'] .= $o;
}
}
function crepair_post(&$a) { function crepair_post(&$a) {
if(! local_user()) if(! local_user())
return; return;
@ -100,7 +132,7 @@ function crepair_content(&$a) {
$msg1 = t('Repair Contact Settings'); $msg1 = t('Repair Contact Settings');
$msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact will stop working.'); $msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
$msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.'); $msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
$o .= '<h2>' . $msg1 . '</h2>'; $o .= '<h2>' . $msg1 . '</h2>';

View file

@ -3,12 +3,15 @@
<div id="contact-edit-wrapper" > <div id="contact-edit-wrapper" >
$tab_str
<div id="contact-edit-drop-link" > <div id="contact-edit-drop-link" >
<a href="contacts/$contact_id/drop" class="icon drophide" id="contact-edit-drop-link" onclick="return confirmDelete();" title="$delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);"></a> <a href="contacts/$contact_id/drop" class="icon drophide" id="contact-edit-drop-link" onclick="return confirmDelete();" title="$delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);"></a>
</div> </div>
<div id="contact-edit-drop-link-end"></div> <div id="contact-edit-drop-link-end"></div>
<div id="contact-edit-nav-wrapper" > <div id="contact-edit-nav-wrapper" >
<div id="contact-edit-links"> <div id="contact-edit-links">
<ul> <ul>
@ -23,6 +26,9 @@
{{ if $ignored }} {{ if $ignored }}
<li><div id="ignore-message">$ignored</div></li> <li><div id="ignore-message">$ignored</div></li>
{{ endif }} {{ endif }}
<li>&nbsp;</li>
{{ if $common_text }} {{ if $common_text }}
<li><div id="contact-edit-common"><a href="common/$contact_id">$common_text</a></div></li> <li><div id="contact-edit-common"><a href="common/$contact_id">$common_text</a></div></li>
{{ endif }} {{ endif }}
@ -30,15 +36,12 @@
<li><div id="contact-edit-allfriends"><a href="allfriends/$contact_id">$all_friends</a></div></li> <li><div id="contact-edit-allfriends"><a href="allfriends/$contact_id">$all_friends</a></div></li>
{{ endif }} {{ endif }}
<li>&nbsp;</li>
<li><a href="network/?cid=$contact_id" id="contact-edit-view-recent">$lblrecent</a></li> <li><a href="network/?cid=$contact_id" id="contact-edit-view-recent">$lblrecent</a></li>
{{ if $lblsuggest }} {{ if $lblsuggest }}
<li><a href="fsuggest/$contact_id" id="contact-edit-suggest">$lblsuggest</a></li> <li><a href="fsuggest/$contact_id" id="contact-edit-suggest">$lblsuggest</a></li>
{{ endif }} {{ endif }}
<li><a href="contacts/$contact_id/block" id="contact-edit-block-link" title="$block_text">$block_text</a></li>
<li><a href="contacts/$contact_id/ignore" id="contact-edit-ignore-link" title="$ignore_text">$ignore_text</a></li>
<li><a href="crepair/$contact_id" id="contact-edit-repair" title="$lblcrepair">$lblcrepair</a></li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -1419,7 +1419,11 @@ input#dfrn-url {
#contact-edit-links ul { #contact-edit-links ul {
list-style: none; list-style: none;
list-style-type: none;
margin-left: 0px;
padding-left: 0px;
} }
#contact-edit-links li { #contact-edit-links li {
margin-top: 5px; margin-top: 5px;
} }