home.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php //$id: $
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. * @package chamilo.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. $language_file = array('userInfo');
  8. $cidReset = true;
  9. require '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'array.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  14. $user_id = api_get_user_id();
  15. $show_full_profile = true;
  16. //social tab
  17. $this_section = SECTION_SOCIAL;
  18. unset($_SESSION['this_section']);//for hmtl editor repository
  19. api_block_anonymous_users();
  20. if (api_get_setting('allow_social_tool') !='true' ){
  21. api_not_allowed();
  22. }
  23. $htmlHeadXtra[] = '<script type="text/javascript">
  24. function show_icon_edit(element_html) {
  25. ident="#edit_image";
  26. $(ident).show();
  27. }
  28. function hide_icon_edit(element_html) {
  29. ident="#edit_image";
  30. $(ident).hide();
  31. }
  32. </script>';
  33. //fast upload image
  34. if (api_get_setting('profile', 'picture') == 'true') {
  35. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  36. $form = new FormValidator('profile', 'post', 'home.php', null, array());
  37. // PICTURE
  38. $form->addElement('file', 'picture', get_lang('AddImage'));
  39. $form->add_progress_bar();
  40. if (!empty($user_data['picture_uri'])) {
  41. $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
  42. }
  43. $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
  44. $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  45. $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
  46. if ($form->validate()) {
  47. $user_data = $form->getSubmitValues();
  48. // upload picture if a new one is provided
  49. if ($_FILES['picture']['size']) {
  50. if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
  51. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  52. $sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id = ".api_get_user_id();
  53. $result = Database::query($sql);
  54. }
  55. }
  56. }
  57. }
  58. Display :: display_header(get_lang('Social'));
  59. $user_info = UserManager :: get_user_info_by_id(api_get_user_id());
  60. $user_online_list = who_is_online(api_get_setting('time_limit_whosonline'),true);
  61. $user_online_count = count($user_online_list);
  62. echo '<div id="social-content">';
  63. echo '<div id="social-content-left">';
  64. //this include the social menu div
  65. SocialManager::show_social_menu('home');
  66. echo '</div>';
  67. echo '<div id="social-content-right">';
  68. echo '<div class="social-box-main1">';
  69. echo '<div class="rounded_div" style="width:280px">';
  70. // information current user
  71. echo '<div><p><strong>'.get_lang('Name').'</strong><br /><span class="social-groups-text4">'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</span></p></div>
  72. <div><p><strong>'.get_lang('Email').'</strong><br /><span class="social-groups-text4">'.($user_info['email']?$user_info['email']:'').'</span></p></div>
  73. <div class="box_description_group_actions" ><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.Display::return_icon('profile_edit.png', get_lang('EditProfile'), array('hspace'=>'6')).get_lang('EditProfile').'</a></div>';
  74. echo '</div>';
  75. /*
  76. echo '<div class="rounded_div" style="width:280px">';
  77. if (count($user_online_list) > 0) {
  78. echo' <div class="clear"></div>
  79. <h3>'.get_lang('UsersOnline').'</strong> </p></h3>';
  80. echo '<center>'.SocialManager::display_user_list($user_online_list).'</center>';
  81. }
  82. echo '</div>';*/
  83. //Search box
  84. echo '<div class="social-box-right">';
  85. echo '<br />';
  86. echo UserManager::get_search_form('');
  87. echo '<br />';
  88. //Group box by age
  89. $results = GroupPortalManager::get_groups_by_age(1,false);
  90. $groups_newest = array();
  91. if (!empty($results)) {
  92. foreach ($results as $result) {
  93. $id = $result['id'];
  94. if ($result['count'] == 1 ) {
  95. $result['count'] = '1 '.get_lang('Member');
  96. } else {
  97. $result['count'] = $result['count'].' '.get_lang('Members');
  98. }
  99. $group_url = "groups.php?id=$id";
  100. $result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
  101. $picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
  102. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
  103. $actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
  104. $groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], cut($result['description'],120,true).$actions);
  105. }
  106. }
  107. $results = GroupPortalManager::get_groups_by_popularity(1,false);
  108. $groups_pop = array();
  109. foreach ($results as $result) {
  110. $id = $result['id'];
  111. $group_url = "groups.php?id=$id";
  112. if ($result['count'] == 1 ) {
  113. $result['count'] = '1 '.get_lang('Member');
  114. } else {
  115. $result['count'] = $result['count'].' '.get_lang('Members');
  116. }
  117. $result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
  118. $picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
  119. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
  120. $actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
  121. $groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], cut($result['description'],120,true).$actions);
  122. }
  123. if (count($groups_newest) > 0) {
  124. echo '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
  125. Display::display_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));
  126. }
  127. if (count($groups_pop) > 0) {
  128. echo '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
  129. Display::display_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
  130. }
  131. echo '</div>';
  132. echo '</div>';
  133. echo '</div>';
  134. echo '</div>';
  135. Display :: display_footer();