]> git.mxchange.org Git - friendica.git/commitdiff
celebrity/group/community pages about 75% implemented
authorMike Macgirvin <mike@macgirvin.com>
Mon, 18 Oct 2010 03:04:17 +0000 (20:04 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Mon, 18 Oct 2010 03:04:17 +0000 (20:04 -0700)
15 files changed:
boot.php
include/auth.php
include/nav.php
include/security.php
index.php
mod/dfrn_confirm.php
mod/dfrn_request.php
mod/lostpass.php
mod/register.php
mod/settings.php
mod/xrd.php
view/intro_complete_eml.tpl
view/login.tpl
view/lostpass.tpl
view/xrd_person.tpl

index 3a9173ef8057e7ece1948c0f56f8f4bb9fa45488..eb3d1b06e3d898a9e424b27c324937b786153ecc 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -22,11 +22,16 @@ define ( 'REL_BUD',        3);
 
 
 // page/profile types
+// PAGE_NORMAL is a typical personal profile account
+// PAGE_SOAPBOX automatically approves all friend requests as REL_FAN, (readonly)
+// PAGE_COMMUNITY automatically approves all friend requests as REL_FAN, but with 
+// write access to wall and comments (no email and not included in page owner's ACL lists)
+// PAGE_FREELOVE automatically approves all friend requests as full friends (REL_BUD). 
 
 define ( 'PAGE_NORMAL',            0 );
-define ( 'PAGE_AUTO_FAN',          1 );
-define ( 'PAGE_AUTO_FAN_RW',       2 );
-define ( 'PAGE_AUTO_BUD',          3 );
+define ( 'PAGE_SOAPBOX',           1 );
+define ( 'PAGE_COMMUNITY',         2 );
+define ( 'PAGE_FREELOVE',          3 );
 
 // Maximum number of "people who like (or don't like) this" 
 // that we will list by name
@@ -102,6 +107,7 @@ class App {
        public  $pager;
        public  $strings;   
        public  $path;
+       public  $interactive = true;
 
        private $scheme;
        private $hostname;
@@ -579,9 +585,9 @@ function remote_user() {
 
 if(! function_exists('notice')) {
 function notice($s) {
-
-       $_SESSION['sysmsg'] .= $s;
-
+       $a = get_app();
+       if($a->interactive)
+               $_SESSION['sysmsg'] .= $s;
 }}
 
 // wrapper around config to limit the text length of an incoming message
index f4f75c607bcbcb0e4faa692ad3f5296c9251ddd7..7e04cb2e70a1280ceae7330cbaee512ba9950af0 100644 (file)
@@ -14,6 +14,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] === 'login'))) {
                unset($_SESSION['administrator']);
                unset($_SESSION['cid']);
                unset($_SESSION['theme']);
+               unset($_SESSION['page_flags']);
                notice( t('Logged out.') . EOL);
                goaway($a->get_baseurl());
        }
@@ -34,6 +35,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] === 'login'))) {
 
                $a->user = $r[0];
                $_SESSION['theme'] = $a->user['theme'];
+               $_SESSION['page_flags'] = $a->user['page-flags'];
                if(strlen($a->user['timezone']))
                        date_default_timezone_set($a->user['timezone']);
 
@@ -58,6 +60,7 @@ else {
        unset($_SESSION['cid']);
        unset($_SESSION['theme']);
        unset($_SESSION['my_url']);
+       unset($_SESSION['page_flags']);
 
        $encrypted = hash('whirlpool',trim($_POST['password']));
 
@@ -77,6 +80,7 @@ else {
                $_SESSION['uid'] = $r[0]['uid'];
                $_SESSION['theme'] = $r[0]['theme'];
                $_SESSION['authenticated'] = 1;
+               $_SESSION['page_flags'] = $r[0]['page-flags'];
                $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];
 
                notice( t("Welcome back ") . $r[0]['username'] . EOL);
index cb08822802cedd686859d968edfa56ccc8c946fe..2c9d76bb35f9f2de647fe8ab74f294bacd54ac15 100644 (file)
@@ -27,8 +27,12 @@ else {
                $a->page['nav'] .= '<a id="nav-home-link" class="nav-commlink" href="profile/' . $a->user['nickname'] . '">' 
                        . t('Home') . '</a><span id="home-update" class="nav-ajax-left"></span>' . "\r\n";
 
-               $a->page['nav'] .= '<a id="nav-notify-link" class="nav-commlink" href="notifications">' . t('Notifications') 
-                       . '</a><span id="notify-update" class="nav-ajax-left"></span>' . "\r\n";
+               // only show friend requests for normal pages. Other page types have automatic friendship.
+
+               if($_SESSION['page_flags'] == PAGE_NORMAL) {
+                       $a->page['nav'] .= '<a id="nav-notify-link" class="nav-commlink" href="notifications">' . t('Notifications') 
+                               . '</a><span id="notify-update" class="nav-ajax-left"></span>' . "\r\n";
+               }
 
                $a->page['nav'] .= '<a id="nav-messages-link" class="nav-commlink" href="message">' . t('Messages') 
                        . '</a><span id="mail-update" class="nav-ajax-left"></span>' . "\r\n";
index 630690f9e6e5e9e24d197edc37e6be07917a8f98..cb10770490be82e8c86637e4765435a0b75a8426 100644 (file)
@@ -3,15 +3,18 @@
 function can_write_wall(&$a,$owner) {
         if((! (local_user())) && (! (remote_user())))
                 return false;
-        if((local_user()) && ($_SESSION['uid'] == $owner))
+               $uid = get_uid();
+        if(($uid) && ($uid === $owner))
                 return true;
 
-        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `id` = %d AND `blocked` = 0 AND `pending` = 0 
-               AND `readonly` = 0  AND `rel` IN ( %d , %d ) LIMIT 1",
-                intval($owner),
-                intval($_SESSION['visitor_id']),
-               intval(REL_VIP),
-               intval(REL_BUD)
+        $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 `readonly` = 0  AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page_flags` = %d ) LIMIT 1",
+                       intval($owner),
+                       intval($_SESSION['visitor_id']),
+                       intval(REL_VIP),
+                       intval(REL_BUD),
+                       intval(PAGE_COMMUNITY)
         );
         if(count($r))
                 return true;
index ce2d32316a8d867e6e9e29ff86eb432ea818e368..0a089106b91fd5304d557f4fe3b8a47ff93710e8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -88,6 +88,7 @@ if(x($_SESSION,'sysmsg')) {
        unset($_SESSION['sysmsg']);
 }
 
+
 // Feel free to comment out this line on production sites.
 $a->page['content'] .= $debug_text;
 
index 3df36182e18ad34cd065b56eea62752b47b0d168..82e1b7624a2ebb66f901f5aaa7387d99d8d1c0f7 100644 (file)
@@ -1,32 +1,60 @@
 <?php
 
-// There are two possible entry points. Both are called via POST.
+// There are two possible entry points. 
 
-function dfrn_confirm_post(&$a) {
+function dfrn_confirm_post(&$a,$handsfree = null) {
 
-       if($a->argc > 1)
-               $node = $a->argv[1];
+       if(is_array($handsfree)) {
+
+               // called directly from dfrn_request due to automatic friend acceptance
+               // any $_POST parameters we might need are supplied in the $handsfree array
+
+               $node = $handsfree['node'];
+               $a->interactive = false; // notice() becomes a no-op since nobody is there to see it
+
+       }
+       else {
+               if($a->argc > 1)
+                       $node = $a->argv[1];
+       }
 
                // Main entry point. Our user received a friend request notification (perhaps 
                // from another site) and clicked 'Accept'. $POST['source_url'] is not set.
-               // They will perform the following:
+               // OR we have been called directly from dfrn_request ($handsfree != null) due to 
+               // this being a page type which supports automatic friend acceptance.
 
        if(! x($_POST,'source_url')) {
-
-               $uid = get_uid();
+               
+               $uid = ((is_array($handsfree)) ? $handsfree['uid'] : get_uid());
 
                if(! $uid) {
                        notice( t('Permission denied.') . EOL );
                        return;
                }       
 
-               // These come from the friend request notification form.
-       
-               $dfrn_id  = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : "");
-               $intro_id = intval($_POST['intro_id']);
-               $duplex   = intval($_POST['duplex']);
+               $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+                       intval($uid)
+               );
+
+               if(! $user) {
+                       notice( t('Profile not found.') . EOL );
+                       return;
+               }       
 
 
+               // These come from the friend request notification form or $handsfree reply.
+
+               if(is_array($handsfree)) {
+                       $dfrn_id = $handsfree['dfrn_id'];
+                       $intro_id = $handsfree['intro_id'];
+                       $duplex = $handsfre['duplex'];
+               }
+               else {
+                       $dfrn_id  = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : "");
+                       $intro_id = intval($_POST['intro_id']);
+                       $duplex   = intval($_POST['duplex']);
+               }
+
                // The other person will have been issued an ID when they first requested friendship.
                // Locate their record. At this time, their record will have both pending and blocked set to 1. 
 
@@ -75,7 +103,6 @@ function dfrn_confirm_post(&$a) {
                        intval($uid) 
                );
 
-
                $params = array();
 
                // Per the protocol document, we will verify both ends by encrypting the dfrn_id with our 
@@ -92,13 +119,13 @@ function dfrn_confirm_post(&$a) {
                $src_aes_key = random_string();
 
                $result = '';
-               openssl_private_encrypt($dfrn_id,$result,$a->user['prvkey']);
+               openssl_private_encrypt($dfrn_id,$result,$user[0]['prvkey']);
 
                $params['dfrn_id'] = bin2hex($result);
                $params['public_key'] = $public_key;
 
 
-               $my_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
+               $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
 
                openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
                $params['source_url'] = bin2hex($params['source_url']);
@@ -266,7 +293,8 @@ function dfrn_confirm_post(&$a) {
                // Let's send our user to the contact editor in case they want to
                // do anything special with this new friend.
  
-               goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
+               if($handsfree === null)
+                       goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
                return;  //NOTREACHED
        }
 
index 3c16e2560a14851aeb1637f44429e2473650c167..6821e1fd604b6ddd8be293939780b706d94968d1 100644 (file)
@@ -208,11 +208,16 @@ function dfrn_request_post(&$a) {
                                        notice( t('You have already introduced yourself here.') . EOL );
                                        return;
                                }
+                               elseif($ret[0]['rel'] == REL_BUD) {
+                                       notice( t('Apparently you are already friends with .') . $a->profile['name'] . EOL);
+                                       return;
+                               }
                                else {
                                        $contact_record = $ret[0];
                                        $parms = array('dfrn-request' => $ret[0]['request']);
                                }
                        }
+
                        $issued_id = random_string();
 
                        if(is_array($contact_record)) {
@@ -314,8 +319,7 @@ function dfrn_request_post(&$a) {
                                );
                        }
        
-
-                       // This notice will only be seen by the requestor if  the requestor and requestee are on the same server.
+                       // This notice will only be seen by the requestor if the requestor and requestee are on the same server.
 
                        if(! $failed) 
                                notice( t('Your introduction has been sent.') . EOL );
@@ -417,9 +421,13 @@ function dfrn_request_content(&$a) {
                                WHERE `contact`.`id` = %d LIMIT 1",
                                intval($intro[0]['contact-id'])
                        );
-                       if(count($r)) {
 
-                               if($r[0]['notify-flags'] & NOTIFY_INTRO) {
+                       $auto_confirm = false;
+
+                       if(count($r)) {
+                               if($r[0]['page-flags'] != PAGE_NORMAL)
+                                       $auto_confirm = true;                           
+                               if(($r[0]['notify-flags'] & NOTIFY_INTRO) && (! $auto_confirm)) {
                                        $email_tpl = load_view_file('view/request_notify_eml.tpl');
                                        $email = replace_macros($email_tpl, array(
                                                '$requestor' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
@@ -434,12 +442,29 @@ function dfrn_request_content(&$a) {
                                                'From: ' . t('Administrator') . '@' . $_SERVER[SERVER_NAME] );
                                        // This is a redundant notification - no point throwing errors if it fails.
                                }
+                               if($auto_confirm) {
+                                       require_once('mod/dfrn_confirm.php');
+                                       $handsfree = array(
+                                               'uid' => $r[0]['uid'],
+                                               'node' => $r[0]['nickname'],
+                                               'dfrn_id' => $r[0]['issued-id'],
+                                               'intro_id' => $intro[0]['id'],
+                                               'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0)
+                                       );
+                                       dfrn_confirm_post($a,$handsfree);
+                               }
+
                        }
 
-                       $r = q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s' LIMIT 1",
-                               dbesc($_GET['confirm_key'])
-                       );
+                       if(! $auto_confirm) {
 
+                               // If we are auto_confirming, this record will have already been nuked
+                               // in dfrn_confirm_post()
+
+                               $r = q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s' LIMIT 1",
+                                       dbesc($_GET['confirm_key'])
+                               );
+                       }
                }
                killme();
                return; // NOTREACHED
index 20d35133a47db0b6b5e31f3b02f83c9c1699b481..0b5dc1376bb7ca17dba16ecde71243c2926d1455 100644 (file)
@@ -7,7 +7,8 @@ function lostpass_post(&$a) {
        if(! $email)
                goaway($a->get_baseurl());
 
-       $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
+       $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) LIMIT 1",
+               dbesc($email),
                dbesc($email)
        );
        if(! count($r))
index 890bc69b7d15ea6fae8c68b7595b8747bb3e8b0f..6f0469db8e498f58b1bbec5d1e53d5bbda0692e3 100644 (file)
@@ -250,7 +250,13 @@ function register_post(&$a) {
 if(! function_exists('register_content')) {
 function register_content(&$a) {
 
-       if($a->config['register_policy'] == REGISTER_CLOSED) {
+       // logged in users can register others (people/pages/groups)
+       // even with closed registrations, unless specifically prohibited by site policy.
+       // 'block_extended_register' blocks all registrations, period.
+
+       $block = get_config('system','block_extended_register');
+
+       if((($a->config['register_policy'] == REGISTER_CLOSED) && (! getuid())) || ($block)) {
                notice("Permission denied." . EOL);
                return;
        }
index b76d9ffb9e9e96729553e848836439af875054df..5caf08b04b2865d06bd8329a4171b0485df31586 100644 (file)
@@ -198,7 +198,7 @@ function settings_content(&$a) {
                ? true : false);
 
        if($invisible)
-               notice( t('Profile is not published.') . EOL );
+               notice( t('Profile is <strong>not published</strong>.') . EOL );
 
        $nickname_block = load_view_file("view/settings_nick_set.tpl");
        
index fd87803e9d96b417809b0ef80800100d86305990..47516e8dd50e4af3bbb059bcd6bb1425e75b8cbc 100644 (file)
@@ -28,7 +28,7 @@ function xrd_content(&$a) {
                '$accturi'     => $uri,
                '$profile_url' => $a->get_baseurl() . '/profile/'       . $r[0]['nickname'],
                '$atom'        => $a->get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
-               '$photo'       => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'],
+               '$photo'       => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
                '$salmon'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'],
                '$salmen'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
                '$modexp'      => 'data:application/magic-public-key,'  . $salmon_key
index 1ac27a855dd846d565426cf2aafbaefe3508a985..a60745ec5549783104cf7141f2f0b00b0f5debfc 100644 (file)
@@ -1,27 +1,19 @@
 
 Dear $username,
 
-       I've got good news and bad news... first the good news. 
-'$fn' at '$dfrn_url' has accepted your connection request at
-'$sitename'. 
-
-The bad news is that '$fn' did not make you a "full friend", 
-but rather accepted you as a "fan". [Maybe you were expecting this, 
-maybe not.]
-
-What this means is that '$fn' can communicate with you at any 
-time and comment on your activities, but your communications to 
-'$fn' may be restricted. In particular, you do NOT have the 
-ability to exchange private mail. You are only able to communicate 
-with '$fn' via your own status updates.
-
-In the future, '$fn' MAY decide to seek a full connection and make 
-a reciprocal request. If you approve such a request, you will then be 
-considered mutual friends with full communication ability.  
-
-The network at $sitename allows many types of relationships - 
-as opposed to older social networks where friendship is either 
-"yes" or "no" - with nothing in between. 
+       '$fn' at '$dfrn_url' has accepted 
+your connection request at '$sitename'.
+
+       '$fn' has chosen to accept you a "fan", which restricts 
+some forms of communication - such as private messaging and some profile
+interactions. If this is a celebrity or community page, these settings were
+applied automatically.
+
+       '$fn' may choose to extend this into a two-way or more permissive 
+relationship in the future. 
+
+       You will start receiving public status updates from '$fn', 
+which will appear on your 'Network' page at  
 
 $siteurl
 
index 39fadb1236c03204e2f97e18b6e146b602aa4189..8fe09e7d3789af14bb3a307355485393e093c168 100644 (file)
@@ -2,7 +2,7 @@
 <form action="" method="post" >
 <input type="hidden" name="auth-params" value="login" />
 <div id="login-name-wrapper">
-        <label for="login-name" id="label-login-name">Username or Email: </label>
+        <label for="login-name" id="label-login-name">Nickname or Email: </label>
         <input type="text" maxlength="60" name="login-name" id="login-name" value="" />
 </div>
 <div id="login-name-end" ></div>
index 9de0a2acfcfe85f3b05cb71f0fe4c206a10e5ad9..a7040c1493d20424255789f0313aa6825916b177 100644 (file)
@@ -6,7 +6,7 @@ Enter your email address and submit to have your password reset. Then check your
 
 <form action="lostpass" method="post" >
 <div id="login-name-wrapper">
-        <label for="login-name" id="label-login-name">Email address: </label>
+        <label for="login-name" id="label-login-name">Nickname or Email: </label>
         <input type="text" maxlength="60" name="login-name" id="login-name" value="" />
 </div>
 <div id="login-extra-end"></div>
index 24bf9449a0712f2ec3704f69ecb6e61015860625..b99f7c1fce1afe430b1b1f26a52218762b985cb9 100644 (file)
@@ -17,6 +17,7 @@
           type="text/html"
           href="$profile_url" />
     <Link rel="http://webfinger.net/rel/avatar"
+          type="image/jpeg"
           href="$photo" />
     <Link rel="salmon" 
           href="$salmon" />