mirror of
https://github.com/friendica/friendica
synced 2024-12-23 06:40:15 +00:00
contact edit updates
This commit is contained in:
parent
722e8e3d49
commit
15f2ce5459
5 changed files with 104 additions and 47 deletions
|
@ -150,7 +150,8 @@ function common_friends($uid,$cid) {
|
|||
$r = q("SELECT `gcontact`.*
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
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($uid),
|
||||
intval($uid),
|
||||
|
@ -181,7 +182,8 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) {
|
|||
|
||||
$r = q("SELECT `gcontact`.*
|
||||
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($uid),
|
||||
intval($start),
|
||||
|
|
|
@ -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]);
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
|
||||
intval(local_user()),
|
||||
intval($contact_id)
|
||||
);
|
||||
if(! count($r)) {
|
||||
notice( t('Contact not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
$contact_id = $a->data['contact']['id'];
|
||||
$contact = $a->data['contact'];
|
||||
|
||||
$tpl = get_markup_template('contact_head.tpl');
|
||||
$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");
|
||||
|
||||
switch($r[0]['rel']) {
|
||||
switch($contact['rel']) {
|
||||
case CONTACT_IS_FRIEND:
|
||||
$dir_icon = 'images/lrarrow.gif';
|
||||
$relation_text = t('You are mutual friends with %s');
|
||||
|
@ -249,52 +242,75 @@ function contacts_content(&$a) {
|
|||
break;
|
||||
}
|
||||
|
||||
$relation_text = sprintf($relation_text,$r[0]['name']);
|
||||
$relation_text = sprintf($relation_text,$contact['name']);
|
||||
|
||||
if(($r[0]['network'] === 'dfrn') && ($r[0]['rel'])) {
|
||||
$url = "redir/{$r[0]['id']}";
|
||||
if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
|
||||
$url = "redir/{$contact['id']}";
|
||||
$sparkle = ' class="sparkle" ';
|
||||
}
|
||||
else {
|
||||
$url = $r[0]['url'];
|
||||
$url = $contact['url'];
|
||||
$sparkle = '';
|
||||
}
|
||||
|
||||
$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')
|
||||
: 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')
|
||||
$last_update .= ' ' . (($r[0]['last-update'] == $r[0]['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
|
||||
if($contact['last-update'] !== '0000-00-00 00:00:00')
|
||||
$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) : '');
|
||||
|
||||
$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') : '');
|
||||
|
||||
// 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(
|
||||
'$header' => t('Contact Editor'),
|
||||
'$tab_str' => $tab_str,
|
||||
'$submit' => t('Submit'),
|
||||
'$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'),
|
||||
'$infedit' => t('Edit contact notes'),
|
||||
'$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,
|
||||
'$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'),
|
||||
'$ignorecont' => t('Ignore contact'),
|
||||
'$lblcrepair' => t("Repair URL settings"),
|
||||
|
@ -302,22 +318,22 @@ function contacts_content(&$a) {
|
|||
'$lblsuggest' => $lblsuggest,
|
||||
'$delete' => t('Delete contact'),
|
||||
'$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,
|
||||
'$lastupdtext' => t('Last update:'),
|
||||
'$updpub' => t('Update public posts'),
|
||||
'$last_update' => $last_update,
|
||||
'$udnow' => t('Update now'),
|
||||
'$profile_select' => contact_profile_assign($r[0]['profile-id'],(($r[0]['network'] !== NETWORK_DFRN) ? true : false)),
|
||||
'$contact_id' => $r[0]['id'],
|
||||
'$block_text' => (($r[0]['blocked']) ? t('Unblock') : t('Block') ),
|
||||
'$ignore_text' => (($r[0]['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 : ''),
|
||||
'$info' => $r[0]['info'],
|
||||
'$blocked' => (($r[0]['blocked']) ? t('Currently blocked') : ''),
|
||||
'$ignored' => (($r[0]['readonly']) ? t('Currently ignored') : ''),
|
||||
'$photo' => $r[0]['photo'],
|
||||
'$name' => $r[0]['name'],
|
||||
'$profile_select' => contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
|
||||
'$contact_id' => $contact['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 : ''),
|
||||
'$info' => $contact['info'],
|
||||
'$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
|
||||
'$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
|
||||
'$photo' => $contact['photo'],
|
||||
'$name' => $contact['name'],
|
||||
'$dir_icon' => $dir_icon,
|
||||
'$alt_text' => $alt_text,
|
||||
'$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);
|
||||
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
<?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) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
@ -100,7 +132,7 @@ function crepair_content(&$a) {
|
|||
|
||||
$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.');
|
||||
|
||||
$o .= '<h2>' . $msg1 . '</h2>';
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
<div id="contact-edit-wrapper" >
|
||||
|
||||
$tab_str
|
||||
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div id="contact-edit-drop-link-end"></div>
|
||||
|
||||
|
||||
<div id="contact-edit-nav-wrapper" >
|
||||
<div id="contact-edit-links">
|
||||
<ul>
|
||||
|
@ -23,6 +26,9 @@
|
|||
{{ if $ignored }}
|
||||
<li><div id="ignore-message">$ignored</div></li>
|
||||
{{ endif }}
|
||||
|
||||
<li> </li>
|
||||
|
||||
{{ if $common_text }}
|
||||
<li><div id="contact-edit-common"><a href="common/$contact_id">$common_text</a></div></li>
|
||||
{{ endif }}
|
||||
|
@ -30,15 +36,12 @@
|
|||
<li><div id="contact-edit-allfriends"><a href="allfriends/$contact_id">$all_friends</a></div></li>
|
||||
{{ endif }}
|
||||
|
||||
<li> </li>
|
||||
|
||||
<li><a href="network/?cid=$contact_id" id="contact-edit-view-recent">$lblrecent</a></li>
|
||||
{{ if $lblsuggest }}
|
||||
<li><a href="fsuggest/$contact_id" id="contact-edit-suggest">$lblsuggest</a></li>
|
||||
{{ 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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1419,7 +1419,11 @@ input#dfrn-url {
|
|||
|
||||
#contact-edit-links ul {
|
||||
list-style: none;
|
||||
list-style-type: none;
|
||||
margin-left: 0px;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#contact-edit-links li {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue