Browse Source

Fix User can't post in a Friend's Wall (1.10.x) - Refs #7921

José Loguercio 9 years ago
parent
commit
785527ba43
3 changed files with 48 additions and 38 deletions
  1. 32 23
      main/inc/lib/social.lib.php
  2. 2 3
      main/social/profile.php
  3. 14 12
      main/template/default/social/user_block.tpl

+ 32 - 23
main/inc/lib/social.lib.php

@@ -1643,7 +1643,7 @@ class SocialManager extends UserManager
      * @param int $groupId Optional. Group ID
      * @return string The HTML code with the social block
      */
-    public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0)
+    public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0, $show_full_profile = true)
     {
         if (api_get_setting('allow_social_tool') != 'true') {
             return '';
@@ -1668,7 +1668,11 @@ class SocialManager extends UserManager
         $template->assign('social_avatar_block', $socialAvatarBlock);
         $template->assign('profile_edition_link', $profileEditionLink);
         //Added the link to export the vCard to the Template
-        $template->assign('vcard_user_link', $vCardUserLink);
+        
+        //If not friend $show_full_profile is False and the user can't see Email Address and Vcard Download Link
+        if ($show_full_profile) {
+            $template->assign('vcard_user_link', $vCardUserLink);
+        }
 
         if (api_get_setting('gamification_mode') === '1') {
             $gamificationPoints = GamificationUtils::getTotalUserPoints(
@@ -1820,30 +1824,35 @@ class SocialManager extends UserManager
     /**
      * @return string
      */
-    public static function getWallForm()
+    public static function getWallForm($show_full_profile = true)
     {
-        $form = new FormValidator(
-            'social_wall_main',
-            'post',
-            api_get_path(WEB_CODE_PATH).'social/profile.php',
-            null,
-            array('enctype' => 'multipart/form-data') ,
-            FormValidator::LAYOUT_HORIZONTAL    
-        );
+        if ($show_full_profile) {
+            $userId = isset($_GET['u']) ? '?u='.intval($_GET['u']) : '';
+            $form = new FormValidator(
+                'social_wall_main',
+                'post',
+                api_get_path(WEB_CODE_PATH).'social/profile.php'.$userId,
+                null,
+                array('enctype' => 'multipart/form-data') ,
+                FormValidator::LAYOUT_HORIZONTAL    
+            );
 
-        $form->addTextarea(
-            'social_wall_new_msg_main',
-            null,
-            [
-                'placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'),
-                'cols-size' => [1, 10, 1]
-            ]
-        );
-        $form->addHidden('url_content', '');
-        $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
-        $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
+            $socialWallPlaceholder = isset($_GET['u']) ? get_lang('SocialWallWriteNewPostToFriend') : get_lang('SocialWallWhatAreYouThinkingAbout');
 
-        return $html;
+            $form->addTextarea(
+                'social_wall_new_msg_main',
+                null,
+                [
+                    'placeholder' => $socialWallPlaceholder,
+                    'cols-size' => [1, 10, 1]
+                ]
+            );
+            $form->addHidden('url_content', '');
+            $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
+            $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
+
+            return $html;
+        }
     }
 
     /**

+ 2 - 3
main/social/profile.php

@@ -274,7 +274,7 @@ $friend_html = SocialManager::listMyFriendsBlock(
     $show_full_profile
 );
 
-$wallSocialAddPost = SocialManager::getWallForm();
+$wallSocialAddPost = SocialManager::getWallForm($show_full_profile);
 $social_wall_block = $wallSocialAddPost;
 
 // Social Post Wall
@@ -330,7 +330,6 @@ $(document).ready(function() {
 
 $socialRightInformation = null;
 $social_right_content = null;
-$show_full_profile = true;
 if ($show_full_profile) {
 
     $t_ufo = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
@@ -679,7 +678,7 @@ if ($show_full_profile) {
 
 $tpl = new Template(get_lang('Social'));
 // Block Avatar Social
-SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile');
+SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile', 0, $show_full_profile);
 
 $tpl->assign('social_friend_block', $friend_html);
 $tpl->assign('social_menu_block', $social_menu_block);

+ 14 - 12
main/template/default/social/user_block.tpl

@@ -17,18 +17,20 @@
                             <li class="item">
                                 {{ user.complete_name }}
                             </li>
-                            <li class="item">
-                                <a href="{{ _p.web }}main/messages/new_message.php">
-                                <img src="{{ "instant_message.png" | icon }}" alt="{{ "Email" | get_lang }}">
-                                {{ user.email}}
-                                </a>
-                            </li>
-                            <li class="item">
-                                <a href="{{ vcard_user_link }}">
-                                <img src="{{ "vcard.png" | icon(16) }}" alt="{{ "BusinessCard" | get_lang }}" width="16" height="16">
-                                {{ "BusinessCard" | get_lang }}
-                                </a>
-                            </li>
+                            {% if vcard_user_link  %}
+                                <li class="item">
+                                    <a href="{{ _p.web }}main/messages/new_message.php">
+                                    <img src="{{ "instant_message.png" | icon }}" alt="{{ "Email" | get_lang }}">
+                                    {{ user.email}}
+                                    </a>
+                                </li>
+                                <li class="item">
+                                    <a href="{{ vcard_user_link }}">
+                                    <img src="{{ "vcard.png" | icon(16) }}" alt="{{ "BusinessCard" | get_lang }}" width="16" height="16">
+                                    {{ "BusinessCard" | get_lang }}
+                                    </a>
+                                </li>
+                            {% endif %}
                         {% if chat_enabled == 1 %}
                             <li class="item">
                                 {% if user.id == _u.id %}