friend suggestions
This commit is contained in:
parent
23f00aaab4
commit
c410c9013c
|
@ -268,6 +268,10 @@ function contacts_content(&$a) {
|
||||||
if($r[0]['last-update'] !== '0000-00-00 00:00:00')
|
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"));
|
$last_update .= ' ' . (($r[0]['last-update'] == $r[0]['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
|
||||||
|
|
||||||
|
$lblsuggest = (($r[0]['network'] === NETWORK_DFRN)
|
||||||
|
? '<div id="contact-suggest-wrapper"><a href="fsuggest/' . $r[0]['id'] . '" id="contact-suggest">' . t('Suggest friends') . '</a></div>' : '');
|
||||||
|
|
||||||
|
|
||||||
$o .= replace_macros($tpl,array(
|
$o .= replace_macros($tpl,array(
|
||||||
'$header' => t('Contact Editor'),
|
'$header' => t('Contact Editor'),
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
|
@ -284,6 +288,7 @@ function contacts_content(&$a) {
|
||||||
'$altcrepair' => t('Repair contact URL settings'),
|
'$altcrepair' => t('Repair contact URL settings'),
|
||||||
'$lblcrepair' => t("Repair contact URL settings \x28WARNING: Advanced\x29"),
|
'$lblcrepair' => t("Repair contact URL settings \x28WARNING: Advanced\x29"),
|
||||||
'$lblrecent' => t('View conversations'),
|
'$lblrecent' => t('View conversations'),
|
||||||
|
'$lblsuggest' => $lblsuggest,
|
||||||
'$grps' => $grps,
|
'$grps' => $grps,
|
||||||
'$delete' => t('Delete contact'),
|
'$delete' => t('Delete contact'),
|
||||||
'$poll_interval' => contact_poll_interval($r[0]['priority']),
|
'$poll_interval' => contact_poll_interval($r[0]['priority']),
|
||||||
|
|
114
mod/fsuggest.php
Normal file
114
mod/fsuggest.php
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
function fsuggest_post(&$a) {
|
||||||
|
|
||||||
|
if(! local_user()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($a->argc != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$contact_id = intval($a->argv[1]);
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
intval($contact_id),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
if(! count($r)) {
|
||||||
|
notice( t('Contact not found.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$contact = $r[0];
|
||||||
|
|
||||||
|
$new_contact = intval($_POST['suggest']);
|
||||||
|
|
||||||
|
$hash = random_string();
|
||||||
|
|
||||||
|
$note = escape_tags(trim($_POST['note']));
|
||||||
|
|
||||||
|
if($new_contact) {
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
intval($new_contact),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
if(count($r)) {
|
||||||
|
|
||||||
|
$x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
|
||||||
|
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
|
||||||
|
intval(local_user()),
|
||||||
|
intval($contact_id),
|
||||||
|
dbesc($r[0]['name']),
|
||||||
|
dbesc($r[0]['url']),
|
||||||
|
dbesc($r[0]['request']),
|
||||||
|
dbesc($r[0]['photo']),
|
||||||
|
dbesc($hash),
|
||||||
|
dbesc(datetime_convert())
|
||||||
|
);
|
||||||
|
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
|
dbesc($hash),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
if(count($r)) {
|
||||||
|
$fsuggest_id = $r[0]['id'];
|
||||||
|
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
dbesc($note),
|
||||||
|
intval($fsuggest_id),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
proc_run('php', 'include/notifier.php', 'suggest' , $fsuggest_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
info( t('Friend suggestion sent.') . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function fsuggest_content(&$a) {
|
||||||
|
|
||||||
|
require_once('include/acl_selectors.php');
|
||||||
|
|
||||||
|
if(! local_user()) {
|
||||||
|
notice( t('Permission denied.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($a->argc != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$contact_id = intval($a->argv[1]);
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
intval($contact_id),
|
||||||
|
intval(local_user())
|
||||||
|
);
|
||||||
|
if(! count($r)) {
|
||||||
|
notice( t('Contact not found.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$contact = $r[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$o = '<h3>' . t('Suggest Friends') . '</h3>';
|
||||||
|
|
||||||
|
$o .= sprintf( t('Suggest a friend for %s'), $contact['name']);
|
||||||
|
|
||||||
|
$o .= '<form action="fsuggest/' . $contact_id . '" method="post" >';
|
||||||
|
|
||||||
|
// TODO: selector should have an option to ignore the recipient
|
||||||
|
$o .= contact_select('suggest','suggest-select', $preselect, 4, true);
|
||||||
|
|
||||||
|
|
||||||
|
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />';
|
||||||
|
$o .= '</form>';
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
|
@ -45,6 +45,7 @@ $ignored
|
||||||
$grps
|
$grps
|
||||||
|
|
||||||
<div id="view-recent-wrapper"><a href="network/?cid=$contact_id" id="contact-view-recent">$lblrecent</a></div>
|
<div id="view-recent-wrapper"><a href="network/?cid=$contact_id" id="contact-view-recent">$lblrecent</a></div>
|
||||||
|
$lblsuggest
|
||||||
|
|
||||||
<div id="contact-edit-info-wrapper">
|
<div id="contact-edit-info-wrapper">
|
||||||
<h4>$lbl_info1</h4>
|
<h4>$lbl_info1</h4>
|
||||||
|
|
Loading…
Reference in a new issue