* @author Isaac Flores Paz * @package dokeos.social */ /** * Init */ $language_file = array('registration','messages','userInfo','admin','forum','blog'); $cidReset = true; require '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'array.lib.php'; $user_id = api_get_user_id(); $show_full_profile = true; //I'm your friend? I can see your profile? if (isset($_GET['u'])) { $user_id = (int) Database::escape_string($_GET['u']); // It's me! if (api_get_user_id() != $user_id) { $user_info = UserManager::get_user_info_by_id($user_id); $show_full_profile = false; if ($user_info==false) { // user does no exist !! api_not_allowed(); } else { //checking the relationship between me and my friend $my_status= UserFriend::get_relation_between_contacts(api_get_user_id(), $user_id); if (in_array($my_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) { $show_full_profile = true; } //checking the relationship between my friend and me $my_friend_status = UserFriend::get_relation_between_contacts($user_id, api_get_user_id()); if (in_array($my_friend_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) { $show_full_profile = true; } else { // im probably not a good friend $show_full_profile = false; } } } else { $user_info = UserManager::get_user_info_by_id($user_id); } } else { $user_info = UserManager::get_user_info_by_id($user_id); } $libpath = api_get_path(LIBRARY_PATH); require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php'; require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php'; require_once $libpath.'course.lib.php'; require_once $libpath.'formvalidator/FormValidator.class.php'; require_once $libpath.'magpierss/rss_fetch.inc'; api_block_anonymous_users(); $htmlHeadXtra[] = ''; //jQuery $htmlHeadXtra[] = ''; //jQuery corner $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ' '; $htmlHeadXtra[] = ''; if (isset($_GET['shared'])) { $my_link='../social/index.php'; $link_shared='shared='.Security::remove_XSS($_GET['shared']); } else { $my_link='../auth/profile.php'; $link_shared=''; } $interbreadcrumb[]= array ('url' =>$my_link,'name' => get_lang('ModifyProfile') ); $interbreadcrumb[]= array ( 'url' => '../social/profile.php?'.$link_shared.'#remote-tab-1', 'name' => get_lang('ViewMySharedProfile') ); if (isset($_GET['u']) && is_numeric($_GET['u'])) { $info_user=api_get_user_info($_GET['u']); $interbreadcrumb[]= array ( 'url' => 'javascript: void(0);', 'name' => api_get_person_name($info_user['firstName'], $info_user['lastName']) ); } if (isset($_GET['u'])) { $param_user='u='.Security::remove_XSS($_GET['u']); }else { $info_user=api_get_user_info(api_get_user_id()); $param_user=''; } $_SESSION['social_user_id'] = $user_id; /** * Helper functions definition */ function get_logged_user_course_html($my_course, $count) { global $nosession; if (api_get_setting('use_session_mode')=='true' && !$nosession) { global $now, $date_start, $date_end; } //initialise $result = ''; // Table definitions $main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $course_database = $my_course['db']; $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database); $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database); $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database); $user_id = api_get_user_id(); $course_system_code = $my_course['k']; $course_visual_code = $my_course['c']; $course_title = $my_course['i']; $course_directory = $my_course['d']; $course_teacher = $my_course['t']; $course_teacher_email = isset($my_course['email'])?$my_course['email']:''; $course_info = Database :: get_course_info($course_system_code); //error_log(print_r($course_info,true)); $course_access_settings = CourseManager :: get_access_settings($course_system_code); $course_visibility = $course_access_settings['visibility']; $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code); //function logic - act on the data $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']); if ($is_virtual_course) { // If the current user is also subscribed in the real course to which this // virtual course is linked, we don't need to display the virtual course entry in // the course list - it is combined with the real course entry. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code); $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code); if ($is_subscribed_in_target_course) { return; //do not display this course entry } } $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id()); if ($has_virtual_courses) { $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info); $course_display_title = $return_result['title']; $course_display_code = $return_result['code']; } else { $course_display_title = $course_title; $course_display_code = $course_visual_code; } $s_course_status=$my_course['s']; $s_htlm_status_icon=""; if ($s_course_status==1) { $s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher')); } if ($s_course_status==2) { $s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach')); } if ($s_course_status==5) { $s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student')); } //display course entry $result .= '
'; //$result .= ''; $result .= '

'; $result .= $s_htlm_status_icon; //show a hyperlink to the course, unless the course is closed and user is not course admin if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { $result .= ' '.$course_title.'

'; /* if(api_get_setting('use_session_mode')=='true' && !$nosession) { if(empty($my_course['id_session'])) { $my_course['id_session'] = 0; } if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') { //$result .= ''.$course_display_title.''; $result .= ''.$course_display_title.''; } } else { //$result .= ''.$course_display_title.''; $result .= ''.$course_display_title.''; }*/ } else { $result .= $course_display_title." "." ".get_lang('CourseClosed').""; } // show the course_code and teacher if chosen to display this // we dont need this! /* if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') { $result .= '
'; } if (api_get_setting('display_coursecode_in_courselist') == 'true') { $result .= $course_display_code; } if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') { $result .= ' – '; } if (api_get_setting('display_teacher_in_courselist') == 'true') { $result .= $course_teacher; if(!empty($course_teacher_email)) { $result .= ' ('.$course_teacher_email.')'; } } */ $current_course_settings = CourseManager :: get_access_settings($my_course['k']); // display the what's new icons // $result .= show_notification($my_course); if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) { reset($digest); $result .= ''; } $result .= ''; $result .= '
'; if (api_get_setting('use_session_mode')=='true' && !$nosession) { $session = ''; $active = false; if (!empty($my_course['session_name'])) { // Request for the name of the general coach $sql = 'SELECT lastname, firstname FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table .' tu ON ts.id_coach = tu.user_id WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1'; $rs = Database::query($sql, __FILE__, __LINE__); $sessioncoach = Database::store_result($rs); $sessioncoach = $sessioncoach[0]; $session = array(); $session['title'] = $my_course['session_name']; if ( $my_course['date_start']=='0000-00-00' ) { $session['dates'] = get_lang('WithoutTimeLimits'); if ( api_get_setting('show_session_coach') === 'true' ) { $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']); } $active = true; } else { $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end']; if ( api_get_setting('show_session_coach') === 'true' ) { $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']); } $active = ($date_start <= $now && $date_end >= $now)?true:false; } } $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active); } else { $output = array ($my_course['user_course_cat'], $result); } //$my_course['creation_date']; return $output; } /** * Get user's feeds * @param int User ID * @param int Limit of posts per feed * @return string HTML section with all feeds included * @author Yannick Warnier * @since Dokeos 1.8.6.1 */ function get_user_feeds($user,$limit=5) { if (!function_exists('fetch_rss')) { return '';} $fields = UserManager::get_extra_fields(); $feed_fields = array(); $feeds = array(); $res = '
'.get_lang('RSSFeeds').'
'; $res .= '
'; $feed = UserManager::get_extra_user_data_by_field($user,'rssfeeds'); if(empty($feed)) { return ''; } $feeds = split(';',$feed['rssfeeds']); if (count($feeds)==0) { return ''; } foreach ($feeds as $url) { if (empty($url)) { continue; } $rss = fetch_rss($url); $res .= '

'.$rss->channel['title'].'

'; $res .= ''; } $res .= '
'; $res .= '

'; return $res; } /** * Display */ Display :: display_header(null); // @todo here we must show the user information as read only //User picture size is calculated from SYSTEM path $img_array= UserManager::get_user_picture_path_by_id($user_id,'web',true,true); //print_r($user_info); // Added by Ivan Tcholakov, 03-APR-2009. if (USE_JQUERY_CORNERS_SCRIPT) { // echo $s=""; // } // //echo '
'; //echo ''.Display::return_icon('edit.gif').' '.api_convert_encoding(get_lang('EditInformation'),'UTF-8',$charset).''; //echo '
'; //Setting some course info $my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id(); $personal_course_list = UserManager::get_personal_session_course_list($my_user_id); $course_list_code = array(); $i=1; //print_r($personal_course_list); if (is_array($personal_course_list)) { foreach ($personal_course_list as $my_course) { if ($i<=10) { $list[] = get_logged_user_course_html($my_course,$i); //$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']); cause double $course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']); } else { break; } $i++; } //to avoid repeted courses $course_list_code = array_unique_dimensional($course_list_code); } echo '
'; if ($user_id == api_get_user_id()) echo get_lang('ViewMySharedProfile'); else echo get_lang('ViewSharedProfile').' - '.api_get_person_name($user_info['firstname'], $user_info['lastname']); echo '
'; echo '
'; // RIGHT COLUMN echo '
'; //---- FRIENDS if ($show_full_profile) { $list_path_friends= $list_path_normal_friends = $list_path_parents = array(); $list_path_good_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND); $list_path_normal_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALFRIEND); $list_path_parents = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALPARENT); $list_path_friends = array_merge_recursive($list_path_good_friends, $list_path_normal_friends, $list_path_parents); $friend_html=''; $number_of_images=3; $number_friends=0; $list_friends_id=array(); $list_friends_dir=array(); $list_friends_file=array(); if (count($list_path_friends)!=0) { $friends_count = count($list_path_friends['id_friend']); for ($z=0;$z< $friends_count ;$z++) { $list_friends_id[] = $list_path_friends['id_friend'][$z]['friend_user_id']; $list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir']; $list_friends_file[]= $list_path_friends['path_friend'][$z]['file']; } $number_friends= count($list_friends_dir); $number_loop = ($number_friends/$number_of_images); $loop_friends = ceil($number_loop); $j=0; $friend_html .= '
'.get_lang('SocialFriend').'
'; $friend_html.= ''; // end of content section echo '
'; // LEFT COLUMN echo '
'; //--- User image echo ''; echo '
'; echo '
'; if (api_get_user_id() == $user_id) { // if i'm me echo '
'; echo Display::return_icon('email.gif'); echo ' '.get_lang('MyInbox').' '; echo '
'; echo '
'; echo Display::return_icon('edit.gif'); echo ' '.get_lang('EditInformation').' '; echo '
'; } else { echo ' '.Display::return_icon('message_new.png').'  '.get_lang('SendMessage').'
'; //echo '  '.get_lang('SendMessage').''; } echo '
'; echo '
'; // Send message or Add to friend links /*if (!$show_full_profile) { echo '  '.Display::return_icon('message_new.png').'  '.get_lang('SendMessage').'
'; }*/ // Extra information if ($show_full_profile) { //-- Extra Data $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD); $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS); $extra_user_data = UserManager::get_extra_user_data($user_id); $extra_information = ''; if (is_array($extra_user_data) && count($extra_user_data)>0 ) { $extra_information = '
'; $extra_information .= get_lang('ExtraInformation'); $extra_information .= '

'; $extra_information .=''; $extra_information .= '

'; } // if there are information to show if (!empty($extra_information_value)) echo $extra_information; // ---- My Agenda Items $my_agenda_items = show_simple_personal_agenda($user_id); if (!empty($my_agenda_items)) { echo '
'; echo get_lang('MyAgenda'); echo '
'; $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); echo ''; } //-----Announcements $announcement_content = ''; $my_announcement_by_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id(); foreach ($course_list_code as $course) { $content = get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id); $course_info=api_get_course_info($course['code']); if (!empty($content)) { $announcement_content.= ''; $announcement_content.= '
'; } } if(!empty($announcement_content)) { echo '
'; echo get_lang('Announcements'); echo '

'; echo ''; } } echo '
'; // CENTER COLUMN echo '
'; //--- Basic Information echo '
'; echo get_lang('Information'); //class="social-profile-info" echo '
'; echo ''; // COURSES LIST if ($show_full_profile) { //print_r($personal_course_list); //echo '
';
				if ( is_array($list) ) {
					echo '
'; echo api_ucfirst(get_lang('MyCourses')); echo '
'; echo ''; } echo '
'; echo '
'; echo '
'; echo '
'; //from the main echo '
 
'; Display :: display_footer();