recipient ui, friend suggestions

This commit is contained in:
Friendika 2011-06-26 21:55:24 -07:00
parent 3fe1e19725
commit 23f00aaab4
3 changed files with 64 additions and 13 deletions

View File

@ -13,9 +13,7 @@ function notifications_post(&$a) {
if($request_id) { if($request_id) {
$r = q("SELECT * FROM `intro` $r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
WHERE `id` = %d
AND `uid` = %d LIMIT 1",
intval($request_id), intval($request_id),
intval(local_user()) intval(local_user())
); );
@ -28,14 +26,22 @@ function notifications_post(&$a) {
notice( t('Invalid request identifier.') . EOL); notice( t('Invalid request identifier.') . EOL);
return; return;
} }
// If it is a friend suggestion, the contact is not a new friend but an existing friend
// that should not be deleted.
$fid = $r[0]['fid'];
if($_POST['submit'] == t('Discard')) { if($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1",
intval($intro_id) intval($intro_id)
); );
if(! $fid) {
$r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1", $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1",
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
}
return; return;
} }
if($_POST['submit'] == t('Ignore')) { if($_POST['submit'] == t('Ignore')) {
@ -81,18 +87,41 @@ function notifications_content(&$a) {
$a->set_pager_itemspage(20); $a->set_pager_itemspage(20);
} }
$r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.* $r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`
FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id` FROM `intro` LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if(($r !== false) && (count($r))) { if(($r !== false) && (count($r))) {
$sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl"); $tpl = get_markup_template("intros.tpl");
foreach($r as $rr) { foreach($r as $rr) {
if($rr['fid']) {
$return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
$o .= replace_macros($sugg,array(
'$str_notifytype' => t('Notification type: '),
'$notify_type' => t('Friend Suggestion'),
'$intro_id' => $rr['intro_id'],
'$madeby' => sprintf( t('suggested by %s'),$rr['name']),
'$contact_id' => $rr['contact-id'],
'$photo' => ((x($rr,'fphoto')) ? $rr['fphoto'] : "images/default-profile.jpg"),
'$fullname' => $rr['fname'],
'$url' => $rr['furl'],
'$knowyou' => $knowyou,
'$approve' => t('Approve'),
'$note' => $rr['note'],
'$request' => $rr['frequest'] . '?addr=' . $return_addr,
'$ignore' => t('Ignore'),
'$discard' => t('Discard')
));
continue;
}
$friend_selected = (($rr['network'] !== 'stat') ? ' checked="checked" ' : ' disabled '); $friend_selected = (($rr['network'] !== 'stat') ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($rr['network'] === 'stat') ? ' checked="checked" disabled ' : ''); $fan_selected = (($rr['network'] === 'stat') ? ' checked="checked" disabled ' : '');
$dfrn_tpl = get_markup_template('netfriend.tpl'); $dfrn_tpl = get_markup_template('netfriend.tpl');
@ -138,6 +167,7 @@ function notifications_content(&$a) {
else else
info( t('No notifications.') . EOL); info( t('No notifications.') . EOL);
/*
if ($a->config['register_policy'] == REGISTER_APPROVE && if ($a->config['register_policy'] == REGISTER_APPROVE &&
$a->config['admin_email'] === $a->user['email']){ $a->config['admin_email'] === $a->user['email']){
$o .= '<h1>' . t('User registrations waiting for confirm') . '</h1>' . "\r\n"; $o .= '<h1>' . t('User registrations waiting for confirm') . '</h1>' . "\r\n";
@ -159,6 +189,7 @@ function notifications_content(&$a) {
info( t('No registrations.') . EOL); info( t('No registrations.') . EOL);
} }
*/
$o .= paginate($a); $o .= paginate($a);
return $o; return $o;

View File

@ -3,7 +3,7 @@
<p class="intro-desc">$str_notifytype $notify_type</p> <p class="intro-desc">$str_notifytype $notify_type</p>
<div class="intro-fullname" id="intro-fullname-$contact_id" >$fullname</div> <div class="intro-fullname" id="intro-fullname-$contact_id" >$fullname</div>
<a class="intro-url-link" id="intro-url-link-$contact_id" href="$url" ><img id="photo-$contact_id" class="intro-photo" src="$photo" width="175" height=175" name="$fullname" alt="fullname" /></a> <a class="intro-url-link" id="intro-url-link-$contact_id" href="$url" ><img id="photo-$contact_id" class="intro-photo" src="$photo" width="175" height=175" title="$fullname" alt="$fullname" /></a>
<div class="intro-knowyou">$knowyou</div> <div class="intro-knowyou">$knowyou</div>
<div class="intro-note" id="intro-note-$contact_id">$note</div> <div class="intro-note" id="intro-note-$contact_id">$note</div>
<div class="intro-wrapper-end" id="intro-wrapper-end-$contact_id"></div> <div class="intro-wrapper-end" id="intro-wrapper-end-$contact_id"></div>

20
view/suggestions.tpl Normal file
View File

@ -0,0 +1,20 @@
<div class="intro-wrapper" >
<p class="intro-desc">$str_notifytype $notify_type</p>
<div class="intro-madeby">$madeby</div>
<div class="intro-fullname" >$fullname</div>
<a class="intro-url-link" href="$url" ><img class="intro-photo" src="$photo" width="175" height=175" title="$fullname" alt="$fullname" /></a>
<div class="intro-note" >$note</div>
<div class="intro-wrapper-end"></div>
<form class="intro-form" action="notifications/$intro_id" method="post">
<input class="intro-submit-ignore" type="submit" name="submit" value="$ignore" />
<input class="intro-submit-discard" type="submit" name="submit" value="$discard" />
</form>
<div class="intro-form-end"></div>
<form class="intro-approve-form" action="$request" method="get">
<input class="intro-submit-approve" type="submit" name="submit" value="$approve" />
</form>
</div>
<div class="intro-end"></div>