3 function notifications_post(&$a) {
9 $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
11 if($request_id === "all")
16 $r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
22 $intro_id = $r[0]['id'];
23 $contact_id = $r[0]['contact-id'];
26 notice( t('Invalid request identifier.') . EOL);
30 // If it is a friend suggestion, the contact is not a new friend but an existing friend
31 // that should not be deleted.
35 if($_POST['submit'] == t('Discard')) {
36 $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1",
40 $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1",
47 if($_POST['submit'] == t('Ignore')) {
48 $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d LIMIT 1",
59 function notifications_content(&$a) {
62 notice( t('Permission denied.') . EOL);
67 $o .= '<script> $(document).ready(function() { $(\'#nav-notify-link\').addClass(\'nav-selected\'); });</script>';
69 if(($a->argc > 1) && ($a->argv[1] == 'all'))
72 $sql_extra = " AND `ignore` = 0 ";
74 $o .= '<h1>' . t('Pending Friend/Connect Notifications') . '</h1>' . "\r\n";
76 $o .= '<div id="notification-show-hide-wrapper" >';
77 $o .= '<a href="' . ((strlen($sql_extra)) ? 'notifications/all' : 'notifications' ) . '" id="notifications-show-hide-link" >'
78 . ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '</a></div>' . "\r\n";
81 $r = q("SELECT COUNT(*) AS `total` FROM `intro`
82 WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
83 intval($_SESSION['uid'])
86 $a->set_pager_total($r[0]['total']);
87 $a->set_pager_itemspage(20);
90 $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`
91 FROM `intro` LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
92 WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
93 intval($_SESSION['uid']));
95 if(($r !== false) && (count($r))) {
97 $sugg = get_markup_template('suggestions.tpl');
98 $tpl = get_markup_template("intros.tpl");
103 $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
104 $o .= replace_macros($sugg,array(
105 '$str_notifytype' => t('Notification type: '),
106 '$notify_type' => t('Friend Suggestion'),
107 '$intro_id' => $rr['intro_id'],
108 '$madeby' => sprintf( t('suggested by %s'),$rr['name']),
109 '$contact_id' => $rr['contact-id'],
110 '$photo' => ((x($rr,'fphoto')) ? $rr['fphoto'] : "images/default-profile.jpg"),
111 '$fullname' => $rr['fname'],
112 '$url' => $rr['furl'],
113 '$knowyou' => $knowyou,
114 '$approve' => t('Approve'),
115 '$note' => $rr['note'],
116 '$request' => $rr['frequest'] . '?addr=' . $return_addr,
117 '$ignore' => t('Ignore'),
118 '$discard' => t('Discard')
125 $friend_selected = (($rr['network'] !== NETWORK_OSTATUS) ? ' checked="checked" ' : ' disabled ');
126 $fan_selected = (($rr['network'] === NETWORK_OSTATUS) ? ' checked="checked" disabled ' : '');
127 $dfrn_tpl = get_markup_template('netfriend.tpl');
132 if($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) {
133 if($rr['network'] === NETWORK_DFRN)
134 $knowyou = t('Claims to be known to you: ') . (($rr['knowyou']) ? t('yes') : t('no'));
137 $dfrn_text = replace_macros($dfrn_tpl,array(
138 '$intro_id' => $rr['intro_id'],
139 '$friend_selected' => $friend_selected,
140 '$fan_selected' => $fan_selected,
141 '$approve_as' => t('Approve as: '),
142 '$as_friend' => t('Friend'),
143 '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer'))
149 $o .= replace_macros($tpl,array(
150 '$str_notifytype' => t('Notification type: '),
151 '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
152 '$dfrn_text' => $dfrn_text,
153 '$dfrn_id' => $rr['issued-id'],
154 '$uid' => $_SESSION['uid'],
155 '$intro_id' => $rr['intro_id'],
156 '$contact_id' => $rr['contact-id'],
157 '$photo' => ((x($rr,'photo')) ? $rr['photo'] : "images/default-profile.jpg"),
158 '$fullname' => $rr['name'],
159 '$url' => $rr['url'],
160 '$knowyou' => $knowyou,
161 '$approve' => t('Approve'),
162 '$note' => $rr['note'],
163 '$ignore' => t('Ignore'),
164 '$discard' => t('Discard')
170 info( t('No notifications.') . EOL);