home.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php //$id: $
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. * @package dokeos.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. $language_file = array('registration','messages','userInfo','admin','forum','blog');
  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. api_block_anonymous_users();
  19. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  20. //fast upload image
  21. if (api_get_setting('profile', 'picture') == 'true') {
  22. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  23. $form = new FormValidator('profile', 'post', 'home.php', null, array());
  24. // PICTURE
  25. $form->addElement('file', 'picture', get_lang('AddImage'));
  26. $form->add_progress_bar();
  27. if (!empty($user_data['picture_uri'])) {
  28. $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
  29. }
  30. $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
  31. $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  32. $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
  33. if ($form->validate()) {
  34. $user_data = $form->getSubmitValues();
  35. var_dump($_FILES);
  36. // upload picture if a new one is provided
  37. if ($_FILES['picture']['size']) {
  38. if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
  39. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  40. $sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id = ".api_get_user_id();
  41. $result = Database::query($sql, __FILE__, __LINE__);
  42. }
  43. }
  44. }
  45. }
  46. Display :: display_header(null);
  47. echo '<div id="social_wrapper">';
  48. //this include the social menu div
  49. SocialManager::show_social_menu(array('messages'));
  50. echo '<div id="social_main">';
  51. echo '<div id="social_main_sub">';
  52. echo '<div id="social_top">';
  53. echo get_lang('User Online').'120';
  54. echo '</div>';
  55. echo '<div id="social_left">';
  56. //@todo fix this aswell as in main/auth/profile.php
  57. //User picture size is calculated from SYSTEM path
  58. $image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
  59. $image_syspath['dir'].$image_syspath['file'];
  60. $image_size = @getimagesize($image_syspath['dir'].$image_syspath['file']);
  61. //Web path
  62. $image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', false, true);
  63. $image_dir = $image_path['dir'];
  64. $image = $image_path['file'];
  65. $image_file = $image_dir.$image;
  66. $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
  67. .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
  68. .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" ';
  69. if ($image_size[0] > 300) {
  70. //limit display width to 300px
  71. $img_attributes .= 'width="300" ';
  72. }
  73. // get the path,width and height from original picture
  74. $big_image = $image_dir.'big_'.$image;
  75. $big_image_size = api_getimagesize($big_image);
  76. $big_image_width = $big_image_size[0];
  77. $big_image_height = $big_image_size[1];
  78. $url_big_image = $big_image.'?rnd='.time();
  79. // Style position:absolute has been removed for Opera-compatibility.
  80. //echo '<div id="image-message-container" style="float:right;display:inline;position:absolute;padding:3px;width:250px;" >';
  81. //echo '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:250px;" >';
  82. if ($image == 'unknown.jpg') {
  83. echo '<img '.$img_attributes.' />';
  84. if (api_get_setting('profile', 'picture') == 'true') {
  85. $form->display();
  86. }
  87. } else {
  88. echo '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
  89. }
  90. echo '<div id="social_center">';
  91. echo '</div>';
  92. echo '<div id="social_center">';
  93. echo '</div>';
  94. echo '<div id="social_center">';
  95. echo '</div>';
  96. echo '</div>';
  97. echo '<div id="social_right">';
  98. $results = GroupPortalManager::get_groups_by_age(1);
  99. $groups = array();
  100. foreach ($results as $result) {
  101. $id = $result['id'];
  102. $url_open = '<a href="groups.php?id='.$id.'">';
  103. $url_close = '</a>';
  104. $groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close, cut($result['description'],180,true));
  105. }
  106. if (count($groups) > 0) {
  107. echo '<h3>'.get_lang('Popular').'</h3>';
  108. Display::display_sortable_grid('home_group', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
  109. }
  110. $results = GroupPortalManager::get_groups_by_popularity(1);
  111. $groups = array();
  112. foreach ($results as $result) {
  113. $id = $result['id'];
  114. $url_open = '<a href="groups.php?id='.$id.'">';
  115. $url_close = '</a>';
  116. if ($result['count'] == 1 ) {
  117. $result['count'] = $result['count'].' '.get_lang('Member');
  118. } else {
  119. $result['count'] = $result['count'].' '.get_lang('Members');
  120. }
  121. $groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close,$result['count'],cut($result['description'],120,true));
  122. }
  123. if (count($groups) > 0) {
  124. echo '<h3>'.get_lang('Popular').'</h3>';
  125. Display::display_sortable_grid('home_group', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
  126. }
  127. echo '</div>';
  128. echo '</div>';
  129. echo '</div>';
  130. echo '</div>';
  131. Display :: display_footer();