Skip to content

Commit

Permalink
Fix User can't post in a Friend's Wall (1.10.x) - Refs #7921
Browse files Browse the repository at this point in the history
  • Loading branch information
jloguercio committed Oct 30, 2015
1 parent 78f1f11 commit 785527b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
55 changes: 32 additions & 23 deletions main/inc/lib/social.lib.php
Expand Up @@ -1643,7 +1643,7 @@ public static function deleteMessage($id)
* @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 '';
Expand All @@ -1668,7 +1668,11 @@ public static function setSocialUserBlock(Template $template, $userId, $groupBlo
$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(
Expand Down Expand Up @@ -1820,30 +1824,35 @@ public static function listMyFriendsBlock($user_id, $link_shared, $show_full_pro
/**
* @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;
}
}

/**
Expand Down
5 changes: 2 additions & 3 deletions main/social/profile.php
Expand Up @@ -274,7 +274,7 @@ function register_friend(element_input) {
$show_full_profile
);

$wallSocialAddPost = SocialManager::getWallForm();
$wallSocialAddPost = SocialManager::getWallForm($show_full_profile);
$social_wall_block = $wallSocialAddPost;

// Social Post Wall
Expand Down Expand Up @@ -330,7 +330,6 @@ function register_friend(element_input) {

$socialRightInformation = null;
$social_right_content = null;
$show_full_profile = true;
if ($show_full_profile) {

$t_ufo = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
Expand Down Expand Up @@ -679,7 +678,7 @@ function register_friend(element_input) {

$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);
Expand Down
26 changes: 14 additions & 12 deletions main/template/default/social/user_block.tpl
Expand Up @@ -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 %}
Expand Down

0 comments on commit 785527b

Please sign in to comment.