From 23f00aaab42a39905c74d06a3864719214122a1f Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 26 Jun 2011 21:55:24 -0700 Subject: [PATCH] recipient ui, friend suggestions --- mod/notifications.php | 55 +++++++++++++++++++++++++++++++++---------- view/intros.tpl | 2 +- view/suggestions.tpl | 20 ++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 view/suggestions.tpl diff --git a/mod/notifications.php b/mod/notifications.php index a3339199e..90f62fa47 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -13,11 +13,9 @@ function notifications_post(&$a) { if($request_id) { - $r = q("SELECT * FROM `intro` - WHERE `id` = %d - AND `uid` = %d LIMIT 1", - intval($request_id), - intval(local_user()) + $r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($request_id), + intval(local_user()) ); if(count($r)) { @@ -28,14 +26,22 @@ function notifications_post(&$a) { notice( t('Invalid request identifier.') . EOL); 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')) { $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($intro_id) ); - $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1", - intval($contact_id), - intval(local_user()) - ); + if(! $fid) { + $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1", + intval($contact_id), + intval(local_user()) + ); + } return; } if($_POST['submit'] == t('Ignore')) { @@ -81,18 +87,41 @@ function notifications_content(&$a) { $a->set_pager_itemspage(20); } - $r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.* - FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id` + $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 `contact`.`id` = `intro`.`contact-id` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", intval($_SESSION['uid'])); if(($r !== false) && (count($r))) { - + $sugg = get_markup_template('suggestions.tpl'); $tpl = get_markup_template("intros.tpl"); 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 '); $fan_selected = (($rr['network'] === 'stat') ? ' checked="checked" disabled ' : ''); $dfrn_tpl = get_markup_template('netfriend.tpl'); @@ -138,6 +167,7 @@ function notifications_content(&$a) { else info( t('No notifications.') . EOL); +/* if ($a->config['register_policy'] == REGISTER_APPROVE && $a->config['admin_email'] === $a->user['email']){ $o .= '

' . t('User registrations waiting for confirm') . '

' . "\r\n"; @@ -159,6 +189,7 @@ function notifications_content(&$a) { info( t('No registrations.') . EOL); } +*/ $o .= paginate($a); return $o; diff --git a/view/intros.tpl b/view/intros.tpl index 4534f2191..d52c3a7aa 100644 --- a/view/intros.tpl +++ b/view/intros.tpl @@ -3,7 +3,7 @@

$str_notifytype $notify_type

$fullname
-fullname +$fullname
$knowyou
$note
diff --git a/view/suggestions.tpl b/view/suggestions.tpl new file mode 100644 index 000000000..46c927754 --- /dev/null +++ b/view/suggestions.tpl @@ -0,0 +1,20 @@ + +
+ +

$str_notifytype $notify_type

+
$madeby
+
$fullname
+$fullname +
$note
+
+
+ + +
+
+ +
+ +
+
+