]> git.mxchange.org Git - friendica.git/commitdiff
The "display" page now shows the current author profile with a "connect" link (if...
authorMichael Vogel <icarus@dabo.de>
Mon, 25 Aug 2014 12:09:56 +0000 (14:09 +0200)
committerMichael Vogel <icarus@dabo.de>
Mon, 25 Aug 2014 12:09:56 +0000 (14:09 +0200)
boot.php
include/contact_widgets.php
mod/contacts.php
mod/display.php
mod/item.php
object/Item.php
view/templates/follow.tpl
view/templates/profile_vcard.tpl
view/theme/vier/style.css
view/theme/vier/templates/profile_vcard.tpl

index ca7829ff5188364a134874e913558d917679127d..ca193693b2bfba9b9961374ee1a5422c16fc732d 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -768,8 +768,8 @@ if(! class_exists('App')) {
                                if(! count($r)){
                                        $this->cached_profile_image[$avatar_image] = $avatar_image;
                                } else {
-                                       $this->cached_profile_picdate[$common_filename] = "?rev=" . urlencode($r[0]['picdate']);
-                                       $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
+                                       $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
+                                       $this->cached_profile_image[$avatar_image] = $avatar_image.$this->cached_profile_picdate[$common_filename];
                                }
                        }
                        return $this->cached_profile_image[$avatar_image];
@@ -1345,7 +1345,7 @@ if(! function_exists('get_max_import_size')) {
  */
 
 if(! function_exists('profile_load')) {
-       function profile_load(&$a, $nickname, $profile = 0) {
+       function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) {
 
                $user = q("select uid from user where nickname = '%s' limit 1",
                        dbesc($nickname)
@@ -1410,9 +1410,10 @@ if(! function_exists('profile_load')) {
                $a->profile = $r[0];
 
                $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
-
+               $a->profile['network'] = NETWORK_DFRN;
 
                $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
+
                $_SESSION['theme'] = $a->profile['theme'];
                $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
 
@@ -1430,7 +1431,7 @@ if(! function_exists('profile_load')) {
                if(! (x($a->page,'aside')))
                        $a->page['aside'] = '';
 
-               if(local_user() && local_user() == $a->profile['uid']) {
+               if(local_user() && local_user() == $a->profile['uid'] && $profiledata) {
                        $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
                                '$editprofile' => t('Edit profile'),
                                '$profid' => $a->profile['id']
@@ -1439,7 +1440,14 @@ if(! function_exists('profile_load')) {
 
                $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
 
-               $a->page['aside'] .= profile_sidebar($a->profile, $block);
+               // To-Do:
+               // By now, the contact block isn't shown, when a different profile is given
+               // But: When this profile was on the same server, then we could display the contacts
+               if ($profiledata)
+                       $a->page['aside'] .= profile_sidebar($profiledata, true);
+               else
+                       $a->page['aside'] .= profile_sidebar($a->profile, $block);
+
 
                /*if(! $block)
                 $a->page['aside'] .= contact_block();*/
@@ -1467,7 +1475,6 @@ if(! function_exists('profile_load')) {
 
 if(! function_exists('profile_sidebar')) {
        function profile_sidebar($profile, $block = 0) {
-
                $a = get_app();
 
                $o = '';
@@ -1498,7 +1505,10 @@ if(! function_exists('profile_sidebar')) {
 
                // Is the local user already connected to that user?
                if ($connect AND local_user()) {
-                       $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
+                       if (isset($profile["url"]))
+                               $profile_url = normalise_link($profile["url"]);
+                       else
+                               $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
 
                        $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
                                local_user(), $profile_url);
@@ -1506,6 +1516,12 @@ if(! function_exists('profile_sidebar')) {
                                $connect = false;
                }
 
+               if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect']))
+                               $connect = false;
+
+               if (isset($profile['remoteconnect']))
+                       $remoteconnect = $profile['remoteconnect'];
+
                if( get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()) )
                        $wallmessage = t('Message');
                else
@@ -1514,7 +1530,6 @@ if(! function_exists('profile_sidebar')) {
                // show edit profile to yourself
                if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
                        $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
-
                        $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                                        local_user());
 
@@ -1604,6 +1619,7 @@ if(! function_exists('profile_sidebar')) {
                $o .= replace_macros($tpl, array(
                        '$profile' => $p,
                        '$connect'  => $connect,
+                       '$remoteconnect'  => $remoteconnect,
                        '$wallmessage' => $wallmessage,
                        '$location' => $location,
                        '$gender'   => $gender,
index 6d9b097d693e81e7656dcdd90369d7d84fadf6c1..810671a91cceee3e4ce78a646b56b7ef443a79d3 100644 (file)
@@ -1,11 +1,12 @@
 <?php
 
-function follow_widget() {
+function follow_widget($value = "") {
 
        return replace_macros(get_markup_template('follow.tpl'),array(
                '$connect' => t('Add New Contact'),
                '$desc' => t('Enter address or web location'),
                '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
+               '$value' => $value,
                '$follow' => t('Connect')
        ));
 
index 3d79eb583e679751f22abe8642dc8737fc378d80..0c53736220d974986470ea4a7cd08ab10b3d3dd0 100644 (file)
@@ -37,7 +37,10 @@ function contacts_init(&$a) {
        }
        else {
                $vcard_widget = '';
-               $follow_widget = follow_widget();
+               if (isset($_GET['add']))
+                       $follow_widget = follow_widget($_GET['add']);
+               else
+                       $follow_widget = follow_widget();
        }
 
        $groups_widget .= group_side('contacts','group',false,0,$contact_id);
index e0a7912a28d4d25dd365b4930613c952f05cc9e0..e3c8f85cf7e2b3e2117c394eaf6b3d8ce48ab4c8 100644 (file)
@@ -7,34 +7,106 @@ function display_init(&$a) {
        }
 
        $nick = (($a->argc > 1) ? $a->argv[1] : '');
+       $profiledata = array();
 
        // If there is only one parameter, then check if this parameter could be a guid
        if ($a->argc == 2) {
                $nick = "";
+               $itemuid = 0;
 
                // Does the local user have this item?
                if (local_user()) {
-                       $r = q("SELECT `id` FROM `item`
+                       $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network` FROM `item`
                                WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                        AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user());
-                       if (count($r))
+                       if (count($r)) {
                                $nick = $a->user["nickname"];
+                               $itemuid = local_user();
+                       }
                }
 
                // Or is it anywhere on the server?
                if ($nick == "") {
-                       $r = q("SELECT `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
+                       $r = q("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`,
+                               `item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`
+                               FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
                                WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                        AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
                                        AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
-                                       AND `item`.`private` = 0 AND `item`.`wall` = 1
+                                       AND `item`.`private` = 0
                                        AND `item`.`guid` = '%s'", $a->argv[1]);
-                       if (count($r))
+                               //      AND `item`.`private` = 0 AND `item`.`wall` = 1
+                       if (count($r)) {
                                $nick = $r[0]["nickname"];
+                               $itemuid = $r[0]["uid"];
+                       }
+               }
+               if (count($r)) {
+                       if ($r[0]["id"] != $r[0]["parent"])
+                               $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network` FROM `item`
+                                       WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+                                               AND `id` = %d", $r[0]["parent"]);
+
+                       if (!strstr(normalise_link($r[0]["author-link"]), normalise_link($a->get_baseurl()))) {
+                               require_once("mod/proxy.php");
+                               require_once("include/bbcode.php");
+                               $profiledata["uid"] = -1;
+                               $profiledata["nickname"] = $r[0]["author-name"];
+                               $profiledata["name"] = $r[0]["author-name"];
+                               $profiledata["picdate"] = "";
+                               $profiledata["photo"] = proxy_url($r[0]["author-avatar"]);
+                               $profiledata["url"] = $r[0]["author-link"];
+                               $profiledata["network"] = $r[0]["network"];
+
+                               // Fetching profile data from unique contacts
+                               // To-do: Extend "unique contacts" table for further contact data like location, ...
+                               $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
+                               if (count($r)) {
+                                       $profiledata["photo"] = proxy_url($r[0]["avatar"]);
+                                       if ($r[0]["nick"] != "")
+                                               $profiledata["nickname"] = $r[0]["nick"];
+                               } else {
+                                       // Is this case possible?
+                                       // Fetching further contact data from the contact table, when it isn't available in the "unique contacts"
+                                       $r = q("SELECT `photo`, `nick` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
+                                               normalise_link($profiledata["url"]), $itemuid);
+                                       if (count($r)) {
+                                               $profiledata["photo"] = proxy_url($r[0]["photo"]);
+                                               if ($r[0]["nick"] != "")
+                                                       $profiledata["nickname"] = $r[0]["nick"];
+                                       }
+                               }
+
+                               if (local_user()) {
+                                       if ($profiledata["network"] == NETWORK_DFRN) {
+                                               $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"])."&addr=".bin2hex($a->get_baseurl()."/profile/".$a->user["nickname"]);
+                                               $profiledata["remoteconnect"] = $connect;
+                                       } elseif ($profiledata["network"] == NETWORK_DIASPORA)
+                                               $profiledata["remoteconnect"] = $a->get_baseurl()."/contacts?add=".GetProfileUsername($profiledata["url"], "", true);
+                               } elseif ($profiledata["network"] == NETWORK_DFRN) {
+                                       $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
+                                       $profiledata["remoteconnect"] = $connect;
+                               }
+                       } else {
+                               $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($r[0]["author-link"]));
+
+                               if (($nickname != $a->user["nickname"])) {
+                                       $profiledata["url"] = $r[0]["author-link"];
+
+                                       $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
+                                               INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
+                                               WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
+                                               dbesc($nickname)
+                                       );
+                                       if (count($r))
+                                               $profiledata = $r[0];
+                                       $profiledata["network"] = NETWORK_DFRN;
+                               }
+                       }
                }
        }
 
-       profile_load($a,$nick);
+       profile_load($a, $nick, 0, $profiledata);
 
 }
 
@@ -89,8 +161,9 @@ function display_content(&$a, $update = 0) {
                                        WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                                AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
                                                AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
-                                               AND `item`.`private` = 0 AND `item`.`wall` = 1
+                                               AND `item`.`private` = 0
                                                AND `item`.`guid` = '%s'", $a->argv[1]);
+                                       //      AND `item`.`private` = 0 AND `item`.`wall` = 1
                                if (count($r)) {
                                        $item_id = $r[0]["id"];
                                        $nick = $r[0]["nickname"];
index 9be9de6688e65dfaa3c506d7266209160d2d2970..a08d0e02b3b6733f027a09bc10875b533bdbde29 100644 (file)
@@ -573,7 +573,7 @@ function item_post(&$a) {
                        if($fullnametagged)
                                continue;
 
-                       $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); 
+                       $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
                        if($success['replaced'])
                                $tagged[] = $tag;
                        if(is_array($success['contact']) && intval($success['contact']['prv'])) {
@@ -1040,12 +1040,12 @@ function item_content(&$a) {
  *
  * @return boolean true if replaced, false if not replaced
  */
-function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
+function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") {
 
        $replaced = false;
        $r = null;
 
-       //is it a hash tag? 
+       //is it a hash tag?
        if(strpos($tag,'#') === 0) {
                //if the tag is replaced...
                if(strpos($tag,'[url='))
@@ -1068,15 +1068,15 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                }
                return $replaced;
        }
-       //is it a person tag? 
+       //is it a person tag?
        if(strpos($tag,'@') === 0) {
-               //is it already replaced? 
+               //is it already replaced?
                if(strpos($tag,'[url='))
                        return $replaced;
                $stat = false;
                //get the person's name
                $name = substr($tag,1);
-               //is it a link or a full dfrn address? 
+               //is it a link or a full dfrn address?
                if((strpos($name,'@')) || (strpos($name,'http://'))) {
                        $newname = $name;
                        //get the profile links
@@ -1093,7 +1093,9 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                                        }
                                }
                        }
-               } else { //if it is a name rather than an address
+               } elseif (($network != NETWORK_OSTATUS) AND ($network != NETWORK_TWITTER) AND
+                       ($network != NETWORK_STATUSNET) AND ($network != NETWORK_APPNET)) {
+                       //if it is a name rather than an address
                        $newname = $name;
                        $alias = '';
                        $tagcid = 0;
@@ -1116,11 +1118,33 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                        else {
                                $newname = str_replace('_',' ',$name);
 
-                               //select someone from this user's contacts by name
-                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
-                                               dbesc($newname),
-                                               intval($profile_uid)
-                               );
+                               // At first try to fetch a contact according to the given network
+                               if ($network != "") {
+                                       //select someone from this user's contacts by name
+                                       $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($newname),
+                                                       dbesc($network),
+                                                       intval($profile_uid)
+                                       );
+                                       if(! $r) {
+                                               //select someone by attag or nick and the name passed in
+                                               $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
+                                                               dbesc($name),
+                                                               dbesc($name),
+                                                               dbesc($network),
+                                                               intval($profile_uid)
+                                               );
+                                       }
+                               } else
+                                       $r = false;
+
+                               if(! $r) {
+                                       //select someone from this user's contacts by name
+                                       $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($newname),
+                                                       intval($profile_uid)
+                                       );
+                               }
 
                                if(! $r) {
                                        //select someone by attag or nick and the name passed in
@@ -1179,10 +1203,10 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                                        $str_tags .= ',';
                                $str_tags .= $newtag;
                        }
-       
+
                        // Status.Net seems to require the numeric ID URL in a mention if the person isn't
                        // subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
-       
+
                        if(strlen($alias)) {
                                $newtag = '@[url=' . $alias . ']' . $newname    . '[/url]';
                                if(! stristr($str_tags,$newtag)) {
@@ -1194,7 +1218,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                }
        }
 
-       return array('replaced' => $replaced, 'contact' => $r[0]);      
+       return array('replaced' => $replaced, 'contact' => $r[0]);
 }
 
 
index 246fecc189a15a260375105c8e992281cb9878cc..283381ef51a3fb42cd7b6091de9e75ac3f23cb84 100644 (file)
@@ -691,9 +691,8 @@ class Item extends BaseObject {
                $this->wall_to_wall = false;
 
                if($this->is_toplevel()) {
-                       if( (! $this->get_data_value('self')) && ($conv->get_mode() !== 'profile')) {
-                               if($this->get_data_value('wall')) {
-
+                       if($conv->get_mode() !== 'profile') {
+                               if($this->get_data_value('wall') AND !$this->get_data_value('self')) {
                                        // On the network page, I am the owner. On the display page it will be the profile owner.
                                        // This will have been stored in $a->page_contact by our calling page.
                                        // Put this person as the wall owner of the wall-to-wall notice.
@@ -708,6 +707,7 @@ class Item extends BaseObject {
                                        $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
                                        $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
                                        $owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name'));
+
                                        if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
 
                                                // The author url doesn't match the owner (typically the contact)
@@ -718,7 +718,7 @@ class Item extends BaseObject {
                                                // well that it's the same Bob Smith. 
 
                                                // But it could be somebody else with the same name. It just isn't highly likely. 
-                                               
+
 
                                                $this->owner_photo = $this->get_data_value('owner-avatar');
                                                $this->owner_name = $this->get_data_value('owner-name');
index 7cd7c5c5376a90e867c21d2e857636faa38da5b3..1df5cd86b0976be1044640ca6469b513c4670347 100644 (file)
@@ -7,7 +7,7 @@
        <h3>{{$connect}}</h3>
        <div id="connect-desc">{{$desc}}</div>
        <form action="follow" method="post" >
-               <input id="side-follow-url" type="text" name="url" size="24" placeholder="{{$hint}}" title="{{$hint}}" /><input id="side-follow-submit" type="submit" name="submit" value="{{$follow}}" />
+               <input id="side-follow-url" type="text" name="url" value="{{$value}}" size="24" placeholder="{{$hint}}" title="{{$hint}}" /><input id="side-follow-submit" type="submit" name="submit" value="{{$follow}}" />
        </form>
 </div>
 
index 4734f5525593871fedeb360bda571bca5afdfe44..5c022b6a588b6886d63eebe99a78d510927c0527 100644 (file)
                                
        
        {{if $pdesc}}<div class="title">{{$profile.pdesc}}</div>{{/if}}
-       <div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></div>
-
 
+       {{if $profile.picdate}}
+               <div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></div>
+        {{else}}
+               <div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></div>
+        {{/if}}
 
        {{if $location}}
                <dl class="location"><dt class="location-label">{{$location}}</dt> 
index 88f310b26a96b535d46a1fdc89af6c98d0e910ed..44f3b0ee0559bfb3f9aa6989eb023acf47140a58 100644 (file)
@@ -898,6 +898,10 @@ aside .vcard dd {
   margin-left: 4px;
   /* width: 60%; */
 }
+aside #profile-photo-wrapper img {
+  width: 175px;
+}
+
 aside #profile-extra-links ul {
   padding: 0px;
   margin: 0px;
index 49d031e07cb16a35fb6aa6e46d1000ce859620ff..1d898eeed96086a9f13b480b935d42fa90a987db 100644 (file)
                        </ul>
                        </div>
                {{else}}
-                       <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="{{$editprofile}}" href="profiles" ></a></div>
+                       {{if $profile.menu}}
+                               <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="{{$editprofile}}" href="profiles" ></a></div>
+                       {{/if}}
                {{/if}}
        </div>
 
-
-       <div id="profile-photo-wrapper"><img class="photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}" /></div>
+       {{if $profile.picdate}}
+               <div id="profile-photo-wrapper"><img class="photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}" /></div>
+       {{else}}
+               <div id="profile-photo-wrapper"><img class="photo" src="{{$profile.photo}}" alt="{{$profile.name}}" /></div>
+       {{/if}}
        {{if $pdesc}}<div class="title">{{$profile.pdesc}}</div>{{/if}}
 
 
        <div id="profile-extra-links">
                <ul>
                        {{if $connect}}
-                               <li><a id="dfrn-request-link" href="dfrn_request/{{$profile.nickname}}">{{$connect}}</a></li>
+                               {{if $remoteconnect}}
+                                       <li><a id="dfrn-request-link" href="{{$remoteconnect}}">{{$connect}}</a></li>
+                               {{else}}
+                                       <li><a id="dfrn-request-link" href="dfrn_request/{{$profile.nickname}}">{{$connect}}</a></li>
+                               {{/if}}
                        {{/if}}
                </ul>
        </div>