]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
- Improved speed due to forced indexes when showing items.
[friendica.git] / mod / profile.php
index 827166f92731135c093061981eec72176c43393b..c5f787a4f0792fd33a636a18dffd1be13d1153f9 100644 (file)
@@ -198,7 +198,8 @@ function profile_content(&$a, $update = 0) {
                'acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
                    'bang' => '',
                'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),
-                   'profile_uid' => $a->profile['profile_uid']
+                   'profile_uid' => $a->profile['profile_uid'],
+                               'acl_data' => ( $is_owner ? construct_acl_data($a, $a->user) : '' ), // For non-Javascript ACL selector
                );
 
                $o .= status_editor($a,$x);
@@ -242,7 +243,7 @@ function profile_content(&$a, $update = 0) {
                        $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
                }
 
-               if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) {
+               if( (! get_config('alt_pager', 'global')) && (! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) ) {
                    $r = q("SELECT COUNT(*) AS `total`
                            FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                            WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
@@ -257,8 +258,17 @@ function profile_content(&$a, $update = 0) {
                        }
                }
 
-               $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
-               $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
+               //  check if we serve a mobile device and get the user settings 
+               //  accordingly
+               if ($a->is_mobile) { 
+                   $itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
+                   $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
+               } else { 
+                   $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
+                   $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
+               }
+               //  now that we have the user settings, see if the theme forces 
+               //  a maximum item number which is lower then the user choice
                if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
                        $itemspage_network = $a->force_max_items;
 
@@ -267,7 +277,7 @@ function profile_content(&$a, $update = 0) {
                $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
 
                $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
-                       FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                       FROM `item` FORCE INDEX (created) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
                        and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
@@ -323,12 +333,12 @@ function profile_content(&$a, $update = 0) {
        $o .= conversation($a,$items,'profile',$update);
 
        if(! $update) {
-         if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) {
-                       $o .= paginate($a);
-               }
-               else {
-                       $o .= alt_pager($a,count($items));
-               }
+               if( get_config('alt_pager', 'global') || get_pconfig($a->profile['profile_uid'],'system','alt_pager') ) {
+                       $o .= alt_pager($a,count($items));
+               }
+               else {
+                       $o .= paginate($a);
+               }
        }
 
        return $o;