From 940d216395406744f23fe4144f2a503688624b45 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 18:38:55 -0700 Subject: [PATCH] initial dfrn update to pass perms --- boot.php | 2 +- database.sql | 1 + include/items.php | 12 +++++------- mod/dfrn_notify.php | 6 ++++++ mod/dfrn_poll.php | 5 ++++- update.php | 5 +++++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 75f031908e..669326dc63 100644 --- a/boot.php +++ b/boot.php @@ -4,7 +4,7 @@ set_time_limit(0); define ( 'FRIENDIKA_VERSION', '2.1.945' ); define ( 'DFRN_PROTOCOL_VERSION', '2.2' ); -define ( 'DB_UPDATE_VERSION', 1047 ); +define ( 'DB_UPDATE_VERSION', 1048 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index eb6eebc4a7..defab4e8f7 100644 --- a/database.sql +++ b/database.sql @@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `priority` tinyint(3) NOT NULL, `blocked` tinyint(1) NOT NULL DEFAULT '1', `readonly` tinyint(1) NOT NULL DEFAULT '0', + `writable` tinyint(1) NOT NULL DEFAULT '0', `pending` tinyint(1) NOT NULL DEFAULT '1', `rating` tinyint(1) NOT NULL DEFAULT '0', `reason` text NOT NULL, diff --git a/include/items.php b/include/items.php index 5969466813..d7644fb421 100644 --- a/include/items.php +++ b/include/items.php @@ -867,14 +867,14 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if($dissolve) $postvars['dissolve'] = '1'; - if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) { - $postvars['data'] = $atom; - } - elseif($owner['page-flags'] == PAGE_COMMUNITY) { + + if((($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { $postvars['data'] = $atom; + $postvars['perm'] = 'rw'; } else { $postvars['data'] = str_replace('1','0',$atom); + $postvars['perm'] = 'r'; } if($rino && $rino_allowed && (! $dissolve)) { @@ -916,7 +916,6 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if((! $curl_stat) || (! strlen($xml))) return(-1); // timed out - if(strpos($xml,'status; - + return $res->status; } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index cd67df1d7c..dd6866b385 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -10,6 +10,12 @@ function dfrn_notify_post(&$a) { $data = ((x($_POST,'data')) ? $_POST['data'] : ''); $key = ((x($_POST,'key')) ? $_POST['key'] : ''); $dissolve = ((x($_POST,'dissolve')) ? intval($_POST['dissolve']) : 0); + $perm = ((x($_POST,'perm')) ? notags(trim($_POST['perm'])) : 'r'); + + $writable = (-1); + if($dfrn_version >= 2.21) { + $writable = (($perm === 'rw') ? 1 : 0); + } $direction = (-1); if(strpos($dfrn_id,':') == 1) { diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 2ccfadd03e..a2fdb9ee13 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -16,6 +16,7 @@ function dfrn_poll_init(&$a) { $challenge = ((x($_GET,'challenge')) ? $_GET['challenge'] : ''); $sec = ((x($_GET,'sec')) ? $_GET['sec'] : ''); $dfrn_version = ((x($_GET,'dfrn_version')) ? (float) $_GET['dfrn_version'] : 2.0); + $perm = ((x($_GET,'perm')) ? $_GET['perm'] : 'r'); $direction = (-1); @@ -183,8 +184,9 @@ function dfrn_poll_post(&$a) { $challenge = ((x($_POST,'challenge')) ? $_POST['challenge'] : ''); $url = ((x($_POST,'url')) ? $_POST['url'] : ''); $sec = ((x($_POST,'sec')) ? $_POST['sec'] : ''); - $ptype = ((x($_POST,'type')) ? $_POST['type'] : ''); + $ptype = ((x($_POST,'type')) ? $_POST['type'] : ''); $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); + $perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r'); if($ptype === 'profile-check') { @@ -344,6 +346,7 @@ function dfrn_poll_content(&$a) { $destination_url = ((x($_GET,'destination_url')) ? $_GET['destination_url'] : ''); $sec = ((x($_GET,'sec')) ? $_GET['sec'] : ''); $dfrn_version = ((x($_GET,'dfrn_version')) ? (float) $_GET['dfrn_version'] : 2.0); + $perm = ((x($_GET,'perm')) ? $_GET['perm'] : 'r'); $direction = (-1); if(strpos($dfrn_id,':') == 1) { diff --git a/update.php b/update.php index 1c243e6ee6..1d45f5f11a 100644 --- a/update.php +++ b/update.php @@ -423,3 +423,8 @@ function update_1045() { function update_1046() { q("ALTER TABLE `item` ADD `attach` MEDIUMTEXT NOT NULL AFTER `tag` "); } + +function update_1047() { + q("ALTER TABLE `contact` ADD `writable` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `readonly` "); +} +