* @autor Alex Aragon CSS Design and Template */ /** * Initialization */ $language_file = array('userInfo'); $cidReset = true; require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'skill.lib.php'; $user_id = api_get_user_id(); $show_full_profile = true; //social tab $this_section = SECTION_SOCIAL; unset($_SESSION['this_section']); //for hmtl editor repository api_block_anonymous_users(); if (api_get_setting('allow_social_tool') != 'true') { $url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; header('Location: ' . $url); exit; api_not_allowed(); } //fast upload image if (api_get_setting('profile', 'picture') == 'true') { $form = new FormValidator('profile', 'post', 'home.php', null, array()); // PICTURE $form->addElement('file', 'picture', get_lang('AddImage')); $form->add_progress_bar(); if (!empty($user_data['picture_uri'])) { $form->addElement( 'checkbox', 'remove_picture', null, get_lang('DelImage') ); } $allowed_picture_types = api_get_supported_image_extensions(); $form->addRule( 'picture', get_lang('OnlyImagesAllowed') . ' (' . implode( ',', $allowed_picture_types ) . ')', 'filetype', $allowed_picture_types ); $form->addElement( 'style_submit_button', 'apply_change', get_lang('SaveSettings'), 'floppy-o', 'btn btn-success' ); if ($form->validate()) { $user_data = $form->getSubmitValues(); // upload picture if a new one is provided if ($_FILES['picture']['size']) { if ($new_picture = UserManager::update_user_picture( api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'] ) ) { $table_user = Database :: get_main_table(TABLE_MAIN_USER); $sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id = " . api_get_user_id(); $result = Database::query($sql); } } } } $userInfo = UserManager :: get_user_info_by_id(api_get_user_id()); $social_avatar_block = '
'; $social_avatar_block .= SocialManager::show_social_avatar_block('home'); $social_avatar_block .= '
'.$userInfo['lastname'].'
'; $social_avatar_block .= '
'.$userInfo['firstname'].'
'; $social_avatar_block .= ''; $chat_status = $userInfo['extra']; if(!empty($chat_status['user_chat_status'])){ $social_avatar_block.= '
'.Display::return_icon('online.png').get_lang('Chat')." (".get_lang('Online').')
'; }else{ $social_avatar_block.= '
'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')
'; } $editProfileUrl = Display::getProfileEditionLink(api_get_user_id()); $social_avatar_block .= ''; $social_avatar_block .= '
'; //Block Menu $social_menu_block = SocialManager::show_social_menu('home'); //Search box $social_search_block = ''; //BLock Social Skill $social_skill_block = ''; if (api_get_setting('allow_skills_tool') == 'true') { $skill = new Skill(); $ranking = $skill->get_user_skill_ranking(api_get_user_id()); $skills = $skill->get_user_skills(api_get_user_id(), true); $social_skill_block = '
'; $social_skill_block .= '
' . get_lang('Skills'); $social_skill_block .= '
'; $lis = ''; if (!empty($skills)) { foreach ($skills as $skill) { $badgeImage = null; if (!empty($skill['icon'])) { $badgeImage = Display::img( api_get_path(WEB_DATA_PATH) . $skill['icon'], $skill['name'] ); } else { $badgeImage = Display::return_icon( 'badges-default.png', $skill['name'], array('title' => $skill['name']),ICON_SIZE_BIG ); } $lis .= Display::tag( 'li', $badgeImage . '
' . $skill['name'] . '
' ); } $social_skill_block .= '
'; $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges')); $social_skill_block .= '
'; }else{ $social_skill_block .= '
'; $social_skill_block .= '

'. get_lang("WithoutAchievedSkills") . '

'; $social_skill_block .= '

' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'

'; $social_skill_block .= '
'; } $social_skill_block.='
'; } //Group box by age $social_group_block = '
'; $social_group_block .= '
'.get_lang('Group').'
'; $social_group_block .= '
'; $results = GroupPortalManager::get_groups_by_age(1, false); $groups_newest = array(); if (!empty($results)) { foreach ($results as $result) { $id = $result['id']; $result['description'] = Security::remove_XSS( $result['description'], STUDENT, true ); $result['name'] = Security::remove_XSS($result['name'], STUDENT, true); if ($result['count'] == 1) { $result['count'] = '1 ' . get_lang('Member'); } else { $result['count'] = $result['count'] . ' ' . get_lang('Members'); } $group_url = "groups.php?id=$id"; $result['name'] = '
'.Display::url( api_ucwords(cut($result['name'], 40, true)), $group_url) .'
'.Display::return_icon('user.png','','',ICON_SIZE_TINY).$result['count'].'
'; $picture = GroupPortalManager::get_picture_group( $id, $result['picture_uri'], 80 ); $result['picture_uri'] = ''; $group_actions = ''; $group_info= '

' . cut($result['description'], 120, true) . "

"; $groups_newest[] = array( Display::url( $result['picture_uri'], $group_url ),$result['name'],$group_info.$group_actions ); } } //Top popular $results = GroupPortalManager::get_groups_by_popularity(1, false); $groups_pop = array(); foreach ($results as $result) { $result['description'] = Security::remove_XSS( $result['description'], STUDENT, true ); $result['name'] = Security::remove_XSS($result['name'], STUDENT, true); $id = $result['id']; $group_url = "groups.php?id=$id"; if ($result['count'] == 1) { $result['count'] = '1 ' . get_lang('Member'); } else { $result['count'] = $result['count'] . ' ' . get_lang('Members'); } $result['name'] = '
'.Display::url( api_ucwords(cut($result['name'], 40, true)),$group_url) .'
'.Display::return_icon('user.png','','',ICON_SIZE_TINY).$result['count'].'
'; $picture = GroupPortalManager::get_picture_group( $id, $result['picture_uri'], 80 ); $result['picture_uri'] = ''; $group_actions = ''; $group_info= '

' . cut($result['description'], 120, true) . "

"; $groups_pop[] = array( Display::url($result['picture_uri'], $group_url), $result['name'],$group_info. $group_actions ); } $list=count($groups_newest); if ($list > 0) { $social_group_block .= '
'; $social_group_block .= '
' . get_lang('Newest') . '
'; for($i = 0;$i < $list; $i++){ $social_group_block.='
'; $social_group_block.='
' . $groups_newest[$i][0] . '
'; $social_group_block.='
' . $groups_newest[$i][1]; $social_group_block.= $groups_newest[$i][2] . '
'; $social_group_block.="
"; } $social_group_block.= "
"; } $list=count($groups_pop); if ($list > 0) { $social_group_block .= '
'; $social_group_block .= '
' . get_lang('Popular') . '
'; for($i = 0;$i < $list; $i++){ $social_group_block.='
'; $social_group_block.='
' . $groups_pop[$i][0] . '
'; $social_group_block.='
' . $groups_pop[$i][1]; $social_group_block.= $groups_pop[$i][2] . '
'; $social_group_block.="
"; } /*$social_group_block .= Display::return_sortable_grid( 'home_group', array(), $groups_pop, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, true, true) );*/ } $social_group_block .= '
'; $tpl = new Template(get_lang('SocialNetwork')); $tpl->assign('social_avatar_block', $social_avatar_block); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_search_block', $social_search_block); $tpl->assign('social_skill_block', $social_skill_block); $tpl->assign('social_group_block', $social_group_block); $social_layout = $tpl->get_template('social/home.tpl'); $tpl->display($social_layout);