From 3ebb4a3dc7a369e7a716ab93d02b44b20522080f Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 9 Sep 2012 21:17:06 -0700 Subject: updates --- include/Contact.php | 54 +++++++++++++++++++++++++++++++++++++++++++++ include/Scrape.php | 5 +++-- include/auth.php | 3 +-- include/contact_widgets.php | 13 ++++++++--- include/conversation.php | 21 ++++++++++++++++-- include/delivery.php | 5 +++-- include/items.php | 14 +++++++++++- include/notifier.php | 8 +++---- include/oauth.php | 1 + include/security.php | 16 +++++++++++++- 10 files changed, 123 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index c141fa188..5e0964d03 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,5 +1,59 @@ get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); else $edpost = false; - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; $drop = array( 'dropping' => $dropping, diff --git a/include/delivery.php b/include/delivery.php index 09448fcae..0d99f48a2 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -322,8 +322,9 @@ function delivery_run($argv, $argc){ dbesc($nickname) ); - if(count($x)) { - if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) { + if($x && count($x)) { + $write_flag = (($x[0]['rel'] == CONTACT_IS_FOLLOWER || $x[0]['rel'] == CONTACT_IS_FRIEND) ? true : false); + if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { q("update contact set writable = 1 where id = %d limit 1", intval($x[0]['id']) ); diff --git a/include/items.php b/include/items.php index 63e9a646d..4acf72d77 100755 --- a/include/items.php +++ b/include/items.php @@ -3557,9 +3557,21 @@ function drop_item($id,$interactive = true) { $owner = $item['uid']; + $cid = 0; + // check if logged in user is either the author or owner of this item - if((local_user() == $item['uid']) || (remote_user() == $item['contact-id']) || (! $interactive)) { + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) { + $cid = $visitor['cid']; + break; + } + } + } + + + if((local_user() == $item['uid']) || ($cid) || (! $interactive)) { // delete the item diff --git a/include/notifier.php b/include/notifier.php index 6e3cede56..15ab67b7b 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -279,7 +279,7 @@ function notifier_run($argv, $argc){ // a delivery fork. private groups (forum_mode == 2) do not uplink if((intval($parent['forum_mode']) == 1) && (! $top_level) && ($cmd !== 'uplink')) { - proc_run('php','include/notifier','uplink',$item_id); + proc_run('php','include/notifier.php','uplink',$item_id); } $conversants = array(); @@ -543,9 +543,9 @@ function notifier_run($argv, $argc){ dbesc($nickname) ); - if(count($x)) { - - if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) { + if($x && count($x)) { + $write_flag = (($x[0]['rel'] == CONTACT_IS_FOLLOWER || $x[0]['rel'] == CONTACT_IS_FRIEND) ? true : false); + if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { q("update contact set writable = 1 where id = %d limit 1", intval($x[0]['id']) ); diff --git a/include/oauth.php b/include/oauth.php index 2724dcf7c..103d4c2fa 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -145,6 +145,7 @@ class FKOAuth1 extends OAuthServer { } $_SESSION['uid'] = $record['uid']; $_SESSION['theme'] = $record['theme']; + $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme'); $_SESSION['authenticated'] = 1; $_SESSION['page_flags'] = $record['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname']; diff --git a/include/security.php b/include/security.php index 497166ec4..bc1e97059 100644 --- a/include/security.php +++ b/include/security.php @@ -181,12 +181,26 @@ function can_write_wall(&$a,$owner) { elseif($verified === 1) return false; else { + $cid = 0; + + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $owner) { + $cid = $visitor['cid']; + break; + } + } + } + + if(! $cid) + return false; + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", intval($owner), - intval(remote_user()), + intval($cid), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND), intval(PAGE_COMMUNITY) -- cgit v1.2.3