aboutsummaryrefslogtreecommitdiffstats
path: root/mod/fsuggest.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-06-26 22:57:08 -0700
committerFriendika <info@friendika.com>2011-06-26 22:57:08 -0700
commitc410c9013c062a9a4fce1f887572a1b1c951afbe (patch)
tree0d3977e71098ea7a0f9a19c7a5796ea67ccde6c9 /mod/fsuggest.php
parent23f00aaab42a39905c74d06a3864719214122a1f (diff)
downloadvolse-hubzilla-c410c9013c062a9a4fce1f887572a1b1c951afbe.tar.gz
volse-hubzilla-c410c9013c062a9a4fce1f887572a1b1c951afbe.tar.bz2
volse-hubzilla-c410c9013c062a9a4fce1f887572a1b1c951afbe.zip
friend suggestions
Diffstat (limited to 'mod/fsuggest.php')
-rw-r--r--mod/fsuggest.php114
1 files changed, 114 insertions, 0 deletions
diff --git a/mod/fsuggest.php b/mod/fsuggest.php
new file mode 100644
index 000000000..29fb79cfb
--- /dev/null
+++ b/mod/fsuggest.php
@@ -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;
+} \ No newline at end of file