]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
Better handling of the network field in the item table.
[friendica.git] / mod / profile.php
index 9e9af19834c0b6c89429cdfeb8b73ae9bd60e964..28e93b294797c44400ddf9535efd83f3d01c2625 100644 (file)
@@ -33,7 +33,6 @@ function profile_init(&$a) {
                auto_redir($a, $which);
        }
 
-       set_template_engine($a); // reset the template engine to the default in case the user's theme doesn't specify one
        profile_load($a,$which,$profile);
 
        $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
@@ -199,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);
@@ -217,7 +217,8 @@ function profile_content(&$a, $update = 0) {
 
        if($update) {
 
-               $r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid`
+               $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,
+                       `contact`.`uid` AS `contact-uid`
                        FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
                        (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
@@ -258,8 +259,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,10 @@ 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` FORCE INDEX (created, uid) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+
+               $r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
+                       `contact`.`uid` AS `contact-uid`
                        FROM `item` 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
@@ -288,7 +301,7 @@ function profile_content(&$a, $update = 0) {
                        $parents_arr[] = $rr['item_id'];
                $parents_str = implode(', ', $parents_arr);
  
-               $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+               $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, 
                        `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
                        `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`