*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '';
$interbreadcrumb[] = ['url' => 'profile.php', 'name' => get_lang('SocialNetwork')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Friends')];
//Block Social Menu
$social_menu_block = SocialManager::show_social_menu('friends');
$user_id = api_get_user_id();
$name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q'] : null;
$number_friends = 0;
if (isset($name_search) && $name_search != 'undefined') {
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND, $name_search);
} else {
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
}
$social_right_content = '
';
if (count($friends) == 0) {
$social_right_content .= Display::return_message(
Display::tag('p', get_lang('NoFriendsInYourContactList')),
'warning',
false
);
$social_right_content .= Display::toolbarButton(
get_lang('TryAndFindSomeFriends'),
'search.php',
'search',
'success'
);
} else {
$filterForm = new FormValidator('filter');
$filterForm->addText(
'id_search_image',
get_lang('Search'),
false,
[
'onkeyup' => 'search_image_social()',
'id' => 'id_search_image',
]
);
$social_right_content .= $filterForm->returnForm();
$friend_html = '
';
$friend_html .= '
';
$number_friends = count($friends);
$j = 0;
for ($k = 0; $k < $number_friends; $k++) {
while ($j < $number_friends) {
if (isset($friends[$j])) {
$friend = $friends[$j];
$toolBar = '';
$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$friend['friend_user_id'];
$friend['user_info']['complete_name'] = Display::url($friend['user_info']['complete_name'], $url);
$friend_html .= Display::getUserCard($friend['user_info'], '', $toolBar);
}
$j++;
}
}
$friend_html .= '
';
$friend_html .= '
';
$social_right_content .= $friend_html;
}
$social_right_content .= '
';
$tpl = new Template(get_lang('Social'));
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'friends');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/friends.tpl');
$tpl->display($social_layout);