]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
initial dfrn update to pass perms
[friendica.git] / mod / profile.php
index 88fc16ebb1f8707ba4e3b01217e600a317729fc1..88e23a8a46c945488267459ea81337ccfe08d3c6 100644 (file)
@@ -98,21 +98,17 @@ function profile_content(&$a, $update = 0) {
 
                $o .= replace_macros($tpl,array(
                        '$url' => $a->get_baseurl() . '/' . $a->cmd,
-                       '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname']
+                       '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'],
+                       '$status' => t('Status'),
+                       '$profile' => t('Profile'),
+                       '$photos' => t('Photos')
                ));
 
 
                if($tab === 'profile') {
-                       $profile_lang = get_config('system','language');
-                       if(! $profile_lang)
-                               $profile_lang = 'en';
-                       if(file_exists("view/$profile_lang/profile_advanced.php"))
-                               require_once("view/$profile_lang/profile_advanced.php");
-                       else
-                               require_once('view/profile_advanced.php');
-
+                       require_once('include/profile_advanced.php');
+                       $o .= advanced_profile($a);
                        call_hooks('profile_advanced',$o);
-
                        return $o;
                }
 
@@ -130,7 +126,13 @@ function profile_content(&$a, $update = 0) {
                        $a->page['htmlhead'] .= replace_macros($tpl, array(
                                '$baseurl' => $a->get_baseurl(),
                                '$geotag'  => $geotag,
-                               '$nickname' => $a->profile['nickname']
+                               '$nickname' => $a->profile['nickname'],
+                               '$linkurl' => t('Please enter a link URL:'),
+                               '$utubeurl' => t('Please enter a YouTube link:'),
+                               '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"),
+                               '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"),
+                               '$whereareu' => t('Where are you right now?'),
+                               '$title' => t('Enter a title for this item') 
                        ));
 
                        require_once('include/acl_selectors.php');
@@ -157,8 +159,11 @@ function profile_content(&$a, $update = 0) {
                                '$upload' => t('Upload photo'),
                                '$weblink' => t('Insert web link'),
                                '$youtube' => t('Insert YouTube video'),
+                               '$video' => t('Insert Vorbis [.ogg] video'),
+                               '$audio' => t('Insert Vorbis [.ogg] audio'),
                                '$setloc' => t('Set your location'),
                                '$noloc' => t('Clear browser location'),
+                               '$title' => t('Set title'),
                                '$wait' => t('Please wait'),
                                '$permset' => t('Permission settings'),
                                '$content' => '',
@@ -233,31 +238,52 @@ function profile_content(&$a, $update = 0) {
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
-               AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+               AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
                $sql_extra ",
                intval($a->profile['profile_uid'])
 
        );
 
-       if(count($r))
+       if(count($r)) {
                $a->set_pager_total($r[0]['total']);
+               $a->set_pager_itemspage(40);
+       }
 
-       $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
-               `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, 
-               `contact`.`thumb`, `contact`.`self`, 
-               `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+       $r = q("SELECT `item`.`id` AS `item_id`, `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 `contact`.`blocked` = 0 AND `contact`.`pending` = 0
-               AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+               AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
                $sql_extra
-               ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ",
+               ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
                intval($a->profile['profile_uid']),
                intval($a->pager['start']),
                intval($a->pager['itemspage'])
 
        );
 
+       $parents_arr = array();
+       $parents_str = '';
+
+       if(count($r)) {
+               foreach($r as $rr)
+                       $parents_arr[] = $rr['item_id'];
+               $parents_str = implode(', ', $parents_arr);
+               $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+                       `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, 
+                       `contact`.`thumb`, `contact`.`self`, 
+                       `contact`.`id` AS `cid`, `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 `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+                       AND `item`.`parent` IN ( %s )
+                       $sql_extra
+                       ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
+                       intval($a->profile['profile_uid']),
+                       dbesc($parents_str)
+               );
+       }
 
        if($is_owner && ! $update)
                $o .= get_birthdays();
@@ -265,6 +291,7 @@ function profile_content(&$a, $update = 0) {
        $cmnt_tpl = load_view_file('view/comment_item.tpl');
 
        $like_tpl = load_view_file('view/like.tpl');
+       $noshare_tpl = load_view_file('view/like_noshare.tpl');
 
        $tpl = load_view_file('view/wall_item.tpl');
 
@@ -281,11 +308,23 @@ function profile_content(&$a, $update = 0) {
 
        if($r !== false && count($r)) {
 
+               $comments = array();
+               foreach($r as $rr) {
+                       if(intval($rr['gravity']) == 6) {
+                               if(! x($comments,$rr['parent']))
+                                       $comments[$rr['parent']] = 1;
+                               else
+                                       $comments[$rr['parent']] += 1;
+                       }
+               }
+
                foreach($r as $item) {
                        like_puller($a,$item,$alike,'like');
                        like_puller($a,$item,$dlike,'dislike');
                }
 
+               $comments_collapsed = false;
+
                foreach($r as $item) {
 
                        $sparkle = '';          
@@ -300,6 +339,25 @@ function profile_content(&$a, $update = 0) {
                                && ($item['id'] != $item['parent']))
                                continue;
 
+                       if($item['id'] == $item['parent']) {
+                               $comments_seen = 0;
+                               $comments_collapsed = false;
+                       }
+                       else
+                               $comments_seen ++;
+
+
+                       if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+                               if(! $comments_collapsed) {
+                                       $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>';
+                                       $o .= '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
+                                       $comments_collapsed = true;
+                               }
+                       }
+                       if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
+                               $o .= '</div></div>';
+                       }
+
                        $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
                                || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
                                ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
@@ -307,10 +365,11 @@ function profile_content(&$a, $update = 0) {
 
                        if(can_write_wall($a,$a->profile['profile_uid'])) {
                                if($item['id'] == $item['parent']) {
-                                       $likebuttons = replace_macros($like_tpl,array(
+                                       $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array(
                                                '$id' => $item['id'],
                                                '$likethis' => t("I like this \x28toggle\x29"),
                                                '$nolike' => t("I don't like this \x28toggle\x29"),
+                                               '$share' => t('Share'),
                                                '$wait' => t('Please wait') 
                                        ));
                                }
@@ -325,6 +384,8 @@ function profile_content(&$a, $update = 0) {
                                                '$mylink' => $contact['url'],
                                                '$mytitle' => t('This is you'),
                                                '$myphoto' => $contact['thumb'],
+                                               '$comment' => t('Comment'),
+                                               '$submit' => t('Submit'),
                                                '$ww' => ''
                                        ));
                                }
@@ -336,7 +397,7 @@ function profile_content(&$a, $update = 0) {
                        // This is my profile page but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend,
                        // I can go directly to their profile as an authenticated guest.
 
-                       if(local_user() && ($item['contact-uid'] == $_SESSION['uid']
+                       if(local_user() && ($item['contact-uid'] == local_user()
                                && ($item['network'] === 'dfrn') && (! $item['self'] )) {
                                $profile_url = $redirect_url;
                                $sparkle = ' sparkle';
@@ -344,6 +405,12 @@ function profile_content(&$a, $update = 0) {
                        else
                                $sparkle = '';
 
+
+                       $edpost = '';
+                       if((local_user()) && ($a->profile['profile_uid'] == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) 
+                               $edpost = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>';
+
+
                        // We would prefer to use our own avatar link for this item because the one in the author-avatar might reference a 
                        // remote site (which could be down). We will use author-avatar if we haven't got something stored locally.
                        // We use this same logic block in mod/network.php to determine it this is a third party post and we don't have any 
@@ -382,10 +449,12 @@ function profile_content(&$a, $update = 0) {
                        if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
                                $indent .= ' shiny'; 
 
+
                        $tmp_item = replace_macros($template,array(
                                '$id' => $item['item_id'],
                                '$linktitle' => t('View $name\'s profile'),
                                '$profile_url' => $profile_link,
+                               '$item_photo_menu' => item_photo_menu($item),                           
                                '$name' => $profile_name,
                                '$thumb' => $profile_avatar,
                                '$sparkle' => $sparkle,
@@ -396,6 +465,7 @@ function profile_content(&$a, $update = 0) {
                                '$location' => $location, 
                                '$indent' => $indent, 
                                '$plink' => get_plink($item),
+                               '$edpost' => $edpost,
                                '$drop' => $drop,
                                '$like' => $like,
                                '$vote' => $likebuttons,
@@ -418,6 +488,5 @@ function profile_content(&$a, $update = 0) {
        $o .= paginate($a);
        $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
 
-
        return $o;
 }