diff options
author | Friendika <info@friendika.com> | 2011-06-26 19:30:57 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-06-26 19:30:57 -0700 |
commit | 3fe1e197254f62e5377c28a24e4d5a75014e931b (patch) | |
tree | a920b222eedb539ae114f998089af3b1ea07ead5 | |
parent | f7964efa52f7efa8159403568a59e320209cbffa (diff) | |
download | volse-hubzilla-3fe1e197254f62e5377c28a24e4d5a75014e931b.tar.gz volse-hubzilla-3fe1e197254f62e5377c28a24e4d5a75014e931b.tar.bz2 volse-hubzilla-3fe1e197254f62e5377c28a24e4d5a75014e931b.zip |
pass notify endpoint with friend suggestions
-rw-r--r-- | boot.php | 2 | ||||
-rw-r--r-- | database.sql | 4 | ||||
-rw-r--r-- | include/notifier.php | 32 | ||||
-rw-r--r-- | mod/dfrn_notify.php | 14 | ||||
-rw-r--r-- | update.php | 7 | ||||
-rw-r--r-- | view/atom_suggest.tpl | 1 |
6 files changed, 49 insertions, 11 deletions
@@ -6,7 +6,7 @@ ini_set('pcre.backtrack_limit', 250000); define ( 'FRIENDIKA_VERSION', '2.2.1023' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1069 ); +define ( 'DB_UPDATE_VERSION', 1070 ); define ( 'EOL', "<br />\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index b33c0cdcb..df99ca7f6 100644 --- a/database.sql +++ b/database.sql @@ -509,7 +509,8 @@ CREATE TABLE IF NOT EXISTS `fcontact` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `url` CHAR( 255 ) NOT NULL , `name` CHAR( 255 ) NOT NULL , -`photo` CHAR( 255 ) NOT NULL +`photo` CHAR( 255 ) NOT NULL , +`request` CHAR( 255 ) NOT NULL ) ENGINE = MYISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `ffinder` ( @@ -526,6 +527,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` ( `cid` INT NOT NULL , `name` CHAR( 255 ) NOT NULL , `url` CHAR( 255 ) NOT NULL , +`request` CHAR( 255 ) NOT NULL, `photo` CHAR( 255 ) NOT NULL , `note` TEXT NOT NULL , `created` DATETIME NOT NULL diff --git a/include/notifier.php b/include/notifier.php index 842e11080..d9f903853 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -71,6 +71,16 @@ function notifier_run($argv, $argc){ if(! count($items)) return; } + elseif($cmd === 'suggest') { + $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1", + intval($item_id) + ); + if(! count($suggest)) + return; + $uid = $suggest[0]['uid']; + $recipients[] = $suggest[0]['cid']; + $item = $suggest[0]; + } else { // find ancestors @@ -126,7 +136,7 @@ function notifier_run($argv, $argc){ // fill this in with a single salmon slap if applicable $slap = ''; - if($cmd != 'mail') { + if($cmd != 'mail' && $cmd != 'suggest') { require_once('include/group.php'); @@ -236,6 +246,26 @@ function notifier_run($argv, $argc){ '$parent_id' => xmlify($item['parent-uri']) )); } + elseif($cmd === 'suggest') { + $notify_hub = false; // suggestions are not public + + $sugg_template = get_markup_template('atom_suggest.tpl'); + + $atom .= replace_macros($sugg_template, array( + '$name' => xmlify($item['name']), + '$url' => xmlify($item['url']), + '$photo' => xmlify($item['photo']), + '$request' => xmlify($item['request']), + '$note' => xmlify($item['note']) + )); + + // We don't need this any more + + q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", + intval($item['id']) + ); + + } else { if($followup) { foreach($items as $item) { // there is only one item diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 6cb4f69a0..31314da7b 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -165,6 +165,7 @@ function dfrn_notify_post(&$a) { $fsugg['name'] = notags(unxmlify($base['name'][0]['data'])); $fsugg['photo'] = notags(unxmlify($base['photo'][0]['data'])); $fsugg['url'] = notags(unxmlify($base['url'][0]['data'])); + $fsugg['request'] = notags(unxmlify($base['request'][0]['data'])); $fsugg['body'] = escape_tags(unxmlify($base['note'][0]['data'])); // Does our member already have a friend matching this description? @@ -180,24 +181,25 @@ function dfrn_notify_post(&$a) { // Do we already have an fcontact record for this person? $fid = 0; - $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `photo` = '%s' LIMIT 1", + $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `request` = '%s' LIMIT 1", dbesc($fsugg['url']), dbesc($fsugg['name']), - dbesc($fsugg['photo']) + dbesc($fsugg['request']) ); if(count($r)) { $fid = $r[0]['id']; } if(! $fid) - $r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo` ) VALUES ( '%s', '%s', '%s' ) ", + $r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo`,`request` ) VALUES ( '%s', '%s', '%s', '%s' ) ", dbesc($fsugg['name']), dbesc($fsugg['url']), - dbesc($fsugg['photo']) + dbesc($fsugg['photo']), + dbesc($fsugg['request']) ); - $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `photo` = '%s' LIMIT 1", + $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `request` = '%s' LIMIT 1", dbesc($fsugg['url']), dbesc($fsugg['name']), - dbesc($fsugg['photo']) + dbesc($fsugg['request']) ); if(count($r)) { $fid = $r[0]['id']; diff --git a/update.php b/update.php index 2e22b9d1c..ce8c694ca 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1069 ); +define( 'UPDATE_VERSION' , 1070 ); /** * @@ -561,4 +561,7 @@ function update_1068() { } - +function update_1069() { + q("ALTER TABLE `fsuggest` ADD `request` CHAR( 255 ) NOT NULL AFTER `url` "); + q("ALTER TABLE `fcontact` ADD `request` CHAR( 255 ) NOT NULL AFTER `photo` "); +} diff --git a/view/atom_suggest.tpl b/view/atom_suggest.tpl index 8df011bfd..66c61f9b6 100644 --- a/view/atom_suggest.tpl +++ b/view/atom_suggest.tpl @@ -4,6 +4,7 @@ <dfrn:url>$url</dfrn:url> <dfrn:name>$name</dfrn:name> <dfrn:photo>$photo</dfrn:photo> + <dfrn:request>$request</dfrn:request> <dfrn:note>$note</dfrn:note> </dfrn:suggest> |