]> git.mxchange.org Git - friendica.git/commitdiff
profile load optimisation
authorFriendika <info@friendika.com>
Sat, 11 Dec 2010 12:16:58 +0000 (04:16 -0800)
committerFriendika <info@friendika.com>
Sat, 11 Dec 2010 12:16:58 +0000 (04:16 -0800)
boot.php
mod/dfrn_request.php
mod/display.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/settings.php
mod/viewcontacts.php

index a526dd0d1495017c0c79bbf9801a11ed9a01e663..4625f64f0fd4937d9fe1d2f1cbd6a569a968ec24 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -7,7 +7,8 @@ define ( 'DFRN_PROTOCOL_VERSION',  '2.0'  );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
-
+define ( 'DOWN_ARROW',             '&#x21e9;'       );
+         
 /**
  * log levels
  */
@@ -1678,4 +1679,74 @@ function smilies($s) {
                '<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />'
        ), $s);
-}}
\ No newline at end of file
+}}
+
+
+/**
+ *
+ * Function : profile_load
+ * @parameter App    $a
+ * @parameter string $nickname
+ * @parameter int    $profile
+ *
+ * Summary: Loads a profile into the page sidebar. 
+ * The function requires a writeable copy of the main App structure, and the nickname
+ * of a registered local account.
+ *
+ * If the viewer is an authenticated remote viewer, the profile displayed is the
+ * one that has been configured for his/her viewing in the Contact manager.
+ * Passing a non-zero profile ID can also allow a preview of a selected profile
+ * by the owner.
+ *
+ * Profile information is placed in the App structure for later retrieval.
+ * Honours the owner's chosen theme for display. 
+ *
+ */
+
+if(! function_exists('profile_load')) {
+function profile_load(&$a, $nickname, $profile = 0) {
+       if(remote_user()) {
+               $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
+                       intval($_SESSION['visitor_id']));
+               if(count($r))
+                       $profile = $r[0]['profile-id'];
+       } 
+
+       $r = null;
+
+       if($profile) {
+               $profile_int = intval($profile);
+               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
+                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+                       WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
+                       dbesc($nickname),
+                       intval($profile_int)
+               );
+       }
+       if(! count($r)) {       
+               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
+                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+                       WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
+                       dbesc($nickname)
+               );
+       }
+
+       if(($r === false) || (! count($r))) {
+               notice( t('No profile') . EOL );
+               $a->error = 404;
+               return;
+       }
+
+       $a->profile = $r[0];
+
+       $a->page['template'] = 'profile';
+
+       $a->page['title'] = $a->profile['name'];
+       $_SESSION['theme'] = $a->profile['theme'];
+
+       if(! (x($a->page,'aside')))
+               $a->page['aside'] = '';
+       $a->page['aside'] .= contact_block();
+
+       return;
+}}
index 60106661cb38afd37d07f3581a731c5446716617..ce422aa9f9cbf9f5cf0a5c0c992ef60ecdd90b07 100644 (file)
@@ -6,7 +6,6 @@ function dfrn_request_init(&$a) {
        if($a->argc > 1)
                $which = $a->argv[1];
 
-       require_once('mod/profile.php');
        profile_init($a,$which);
 
        return;
index 36916161920114d2cf9aac04293bf6bf74f6f54e..1049b28a0919e3391d96f93105586c1ecf691bc5 100644 (file)
@@ -5,7 +5,6 @@ function display_content(&$a) {
 
        $o = '<div id="live-display"></div>' . "\r\n";
 
-       require_once('mod/profile.php');
        profile_init($a);
 
        $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
index a431f4bdd8aee5c7fbdf92dd91834a157eec4ece..b40617d03b1d23eda51086918b308b3d9321bfd5 100644 (file)
@@ -1,53 +1,5 @@
 <?php
 
-if(! function_exists('profile_load')) {
-function profile_load(&$a, $username, $profile = 0) {
-       if(remote_user()) {
-               $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
-                       intval($_SESSION['visitor_id']));
-               if(count($r))
-                       $profile = $r[0]['profile-id'];
-       } 
-
-       $r = null;
-
-       if($profile) {
-               $profile_int = intval($profile);
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
-                       dbesc($username),
-                       intval($profile_int)
-               );
-       }
-       if(! count($r)) {       
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
-                       dbesc($username)
-               );
-       }
-
-       if(($r === false) || (! count($r))) {
-               notice( t('No profile') . EOL );
-               $a->error = 404;
-               return;
-       }
-
-       $a->profile = $r[0];
-
-       $a->page['template'] = 'profile';
-
-       $a->page['title'] = $a->profile['name'];
-       $_SESSION['theme'] = $a->profile['theme'];
-
-       if(! (x($a->page,'aside')))
-               $a->page['aside'] = '';
-       $a->page['aside'] .= contact_block();
-
-       return;
-}}
-
 function profile_init(&$a) {
 
        if($a->argc > 1)
index 39808776b7e4fad331db8a0cc9028221b3f73a97..64093b2de0fb4c062dbd3250f003963440e97761 100644 (file)
@@ -8,7 +8,6 @@ function profile_photo_init(&$a) {
                return;
        }
 
-       require_once("mod/profile.php");
        profile_load($a,$a->user['nickname']);
 
 }
index 604eb2f62c30a54dfe47f01788a9fae36662300f..e675af2e4856405ebd7e09d1ffbfab5cad5aeafe 100644 (file)
@@ -327,7 +327,6 @@ function profiles_content(&$a) {
                        return;
                }
 
-               require_once('mod/profile.php');
                profile_load($a,$a->user['nickname'],$r[0]['id']);
 
                require_once('include/profile_selectors.php');
index 7ed7ad32e8359911047188c52b8d111c9a0f8a6f..a8e02ea4001815b2fb573c5a4e0d6152a2c84f5f 100644 (file)
@@ -3,7 +3,6 @@
 
 function settings_init(&$a) {
        if(local_user()) {
-               require_once("mod/profile.php");
                profile_load($a,$a->user['nickname']);
        }
 }
index 562b60c25cbb0de58ccd2805aa806a4af9802f1f..bd73b2ffbe837d1e657ca8aba9e6536d0c3e3057 100644 (file)
@@ -2,7 +2,6 @@
 
 function viewcontacts_init(&$a) {
 
-       require_once("mod/profile.php");
        profile_load($a,$a->argv[1]);
 
 }