/** * Set header parameters */ private function set_header_parameters() { global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section; $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as & $thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('online.png')); $this->assign('offline_button',Display::return_icon('offline.png')); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('Institution'); $title_list[] = api_get_setting('siteName'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $this->set_css_files(); $this->set_js_files(); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-'.$this_section); $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep.'favicon.ico')) { $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->set_help(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang( 'ReportABug' ).'"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); //Preparing values for the menu //Logout link if (isset($_configuration['hide_logout_button']) && $_configuration['hide_logout_button'] == 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id()); } //Profile link if (api_get_setting('allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH).'messages/inbox.php'; $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('Institution'); $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); //Setting notifications $count_unread_message = 0; if (api_get_setting('allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( api_get_user_id() ); $group_pending_invitations = GroupPortalManager::get_groups_by_user( api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false ); $group_pending_invitations = 0; if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval( $count_unread_message ); } $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null); $this->assign('user_notifications', $total_invitations); //Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); //if ($this->show_header == 1) { header('Content-Type: text/html; charset='.api_get_system_encoding()); header( 'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1) ); //} }
function return_profile_block() { global $_configuration; $user_id = api_get_user_id(); if (empty($user_id)) { return; } $profile_content = '<ul class="nav nav-list">'; // @todo Add a platform setting to add the user image. if (api_get_setting('allow_message_tool') == 'true') { require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; // New messages. $number_of_new_messages = MessageManager::get_new_messages(); // New contact invitations. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); // New group invitations sent by a moderator. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false); $group_pending_invitations = count($group_pending_invitations); $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; $cant_msg = Display::badge($number_of_new_messages); $link = ''; if (api_get_setting('allow_social_tool') == 'true') { $link = '?f=social'; } $profile_content .= '<li class="inbox-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.get_lang('Inbox').$cant_msg.' </a></li>'; $profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.get_lang('Compose').' </a></li>'; if (api_get_setting('allow_social_tool') == 'true') { $total_invitations = Display::badge($total_invitations); $profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('PendingInvitations').$total_invitations.'</a></li>'; } if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) { $profile_content .= '<li class="myfiles-social"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.get_lang('MyFiles').'</a></li>'; } } $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; if (api_get_setting('sso_authentication') === 'true') { $subSSOClass = api_get_setting('sso_authentication_subclass'); $objSSO = null; if (!empty($subSSOClass)) { require_once api_get_path(SYS_CODE_PATH) . 'auth/sso/sso.' . $subSSOClass . '.class.php'; $subSSOClass = 'sso' . $subSSOClass; $objSSO = new $subSSOClass(); } else { $objSSO = new sso(); } $editProfileUrl = $objSSO->generateProfileEditingURL(); } $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.get_lang('EditProfile').'</a></li>'; $profile_content .= '</ul>'; $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block'); return $html; }
GROUP_USER_PERMISSION_PENDING_INVITATION ) ) ) { $social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id( ) . '">' . get_lang('JoinGroup') . '</a>'; } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) { $social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id( ) . '">' . get_lang('YouHaveBeenInvitedJoinNow') . '</a>'; } } $social_right_content .= '</div>'; // end layout messages } else { // My groups ----- $results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0); $grid_my_groups = array(); $my_group_list = array(); if (is_array($results) && count($results) > 0) { foreach ($results as $result) { $id = $result['id']; $result['name'] = Security::remove_XSS( $result['name'], STUDENT, true ); $result['description'] = Security::remove_XSS( $result['description'], STUDENT, true );
} } } // if there are information to show if (!empty($extra_information_value)) { $extra_information .= $extra_information_value; } $extra_information .= '</div>'; //social-profile-info } // if there are information to show if (!empty($extra_information_value)) { $socialRightInformation .= SocialManager::social_wrapper_div($extra_information, 4); } // MY GROUPS $results = GroupPortalManager::get_groups_by_user($my_user_id, 0); $grid_my_groups = array(); $max_numbers_of_group = 4; if (is_array($results) && count($results) > 0) { $i = 1; foreach ($results as $result) { if ($i > $max_numbers_of_group) break; $id = $result['id']; $url_open = '<a href="groups.php?id='.$id.'">'; $url_close = '</a>'; $icon = ''; $name = cut($result['name'],CUT_GROUP_NAME,true); if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $icon = Display::return_icon( 'social_group_admin.png', get_lang('Admin'),
/** * @param $visible * @param $id * @param int $start * @param string $user_id * @return string */ public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='') { $user_selected_language = api_get_interface_language(); $start = intval($start); $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); $temp_user_groups = GroupPortalManager::get_groups_by_user(api_get_user_id(),0); $groups =array(); foreach ($temp_user_groups as $user_group) { $groups = array_merge($groups, array($user_group['id'])); $groups = array_merge($groups, GroupPortalManager::get_parent_groups($user_group['id'])); } //checks if tables exists to not break platform not updated $ann_group_db_ok =false; if( Database::num_rows(Database::query("SHOW TABLES LIKE 'announcement_rel_group'")) > 0) $ann_group_db_ok =true; $groups_string = '('.implode($groups,',').')'; $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); $now = api_get_utc_datetime(); $sql = "SELECT * FROM ".$db_table." WHERE ( lang = '$user_selected_language' OR lang IS NULL) AND ( '$now' >= date_start AND '$now' <= date_end) "; switch ($visible) { case self::VISIBLE_GUEST : $sql .= " AND visible_guest = 1 "; break; case self::VISIBLE_STUDENT : $sql .= " AND visible_student = 1 "; break; case self::VISIBLE_TEACHER : $sql .= " AND visible_teacher = 1 "; break; } if (count($groups) > 0 and $ann_group_db_ok ) { $sql .= " OR id IN (SELECT announcement_id FROM $tbl_announcement_group WHERE group_id in $groups_string) "; } if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); $sql .= " AND access_url_id IN ('1', '$current_access_url_id')"; } if(!isset($_GET['start']) || $_GET['start'] == 0) { $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; } else { $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; } $announcements = Database::query($sql); $content = ''; if (Database::num_rows($announcements) > 0) { $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); $query_string = ereg_replace('&$', '', $query_string); $url = api_get_self(); $content .= '<div class="system_announcements">'; $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>'; $content .= '<table align="center">'; $content .= '<tr>'; $content .= '<td>'; $content .= SystemAnnouncementManager :: display_arrow($user_id); $content .= '</td>'; $content .= '</tr>'; $content .= '</table>'; $content .= '<table align="center" border="0" width="900px">'; while ($announcement = Database::fetch_object($announcements)) { $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); $content .= '<tr><td>'; $content .= '<a name="'.$announcement->id.'"></a> <div class="system_announcement"> <h2>'.$announcement->title.'</h2><div class="system_announcement_date">'.$display_date.'</div> <br /> <div class="system_announcement_content">' .$announcement->content.' </div> </div><br />'; $content .= '</tr></td>'; } $content .= '</table>'; $content .= '<table align="center">'; $content .= '<tr>'; $content .= '<td>'; $content .= SystemAnnouncementManager :: display_arrow($user_id); $content .= '</td>'; $content .= '</tr>'; $content .= '</table>'; $content .= '</div>'; } return $content; }
/** * Get the group member list by a user and his group role * @param int $userId The user ID * @param int $relationType Optional. The relation type. GROUP_USER_PERMISSION_ADMIN by default * @param boolean $includeSubgroupsUsers Optional. Whether include the users from subgroups * @return array */ public static function getGroupUsersByUser($userId, $relationType = GROUP_USER_PERMISSION_ADMIN, $includeSubgroupsUsers = true) { $userId = intval($userId); $groups = GroupPortalManager::get_groups_by_user($userId, $relationType); $groupsId = array_keys($groups); $subgroupsId = []; $userIdList = []; if ($includeSubgroupsUsers) { foreach ($groupsId as $groupId) { $subgroupsId = array_merge($subgroupsId, GroupPortalManager::getGroupsByDepthLevel($groupId)); } $groupsId = array_merge($groupsId, $subgroupsId); } $groupsId = array_unique($groupsId); if (empty($groupsId)) { return []; } foreach ($groupsId as $groupId) { $groupUsers = GroupPortalManager::get_users_by_group($groupId); if (empty($groupUsers)) { continue; } foreach ($groupUsers as $member) { if ($member['user_id'] == $userId) { continue; } $userIdList[] = intval($member['user_id']); } } return array_unique($userIdList); }
/** * Shows the right menu of the Social Network tool * * @param string $show highlight link possible values: * group_add, * home, * messages, * messages_inbox, * messages_compose , * messages_outbox, * invitations, * shared_profile, * friends, * groups search * @param int $group_id group id * @param int $user_id user id * @param bool $show_full_profile show profile or not (show or hide the user image/information) * @param bool $show_delete_account_button * */ public static function show_social_menu( $show = '', $group_id = 0, $user_id = 0, $show_full_profile = false, $show_delete_account_button = false ) { if (empty($user_id)) { $user_id = api_get_user_id(); } $user_info = api_get_user_info($user_id, true); $current_user_id = api_get_user_id(); $current_user_info = api_get_user_info($current_user_id, true); if ($current_user_id == $user_id) { $user_friend_relation = null; } else { $user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id); } $show_groups = array( 'groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups' ); // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); $count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null; $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $group_pending_invitations = GroupPortalManager::get_groups_by_user( api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false ); $group_pending_invitations = count($group_pending_invitations); $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : ''); $html = ''; $active = null; if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'))) { $html .= '<div class="well sidebar-nav"><ul class="nav nav-list">'; $active = $show == 'home' ? 'active' : null; $html .= '<li class="home-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Home').'</a></li>'; $active = $show == 'messages' ? 'active' : null; $html .= '<li class="messages-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php?f=social">'.get_lang('Messages').$count_unread_message.'</a></li>'; //Invitations $active = $show == 'invitations' ? 'active' : null; $html .= '<li class="invitations-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">'.get_lang('Invitations').$total_invitations.'</a></li>'; //Shared profile and groups $active = $show == 'shared_profile' ? 'active' : null; $html .= '<li class="shared-profile-icon'.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">'.get_lang('ViewMySharedProfile').'</a></li>'; $active = $show == 'friends' ? 'active' : null; $html .= '<li class="friends-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">'.get_lang('Friends').'</a></li>'; $active = $show == 'browse_groups' ? 'active' : null; $html .= '<li class="browse-groups-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php">'.get_lang('SocialGroups').'</a></li>'; //Search users $active = $show == 'search' ? 'active' : null; $html .= '<li class="search-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">'.get_lang('Search').'</a></li>'; //My files $active = $show == 'myfiles' ? 'active' : null; $html .= '<li class="myfiles-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">'.get_lang('MyFiles').'</span></a></li>'; $html .='</ul> </div>'; } if (in_array($show, $show_groups) && !empty($group_id)) { $html .= GroupPortalManager::show_group_column_information( $group_id, api_get_user_id(), $show ); } if ($show == 'shared_profile') { $html .= '<div class="well sidebar-nav"> <ul class="nav nav-list">'; // My own profile if ($show_full_profile && $user_id == intval(api_get_user_id())) { $html .= '<li class="home-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Home').'</a></li> <li class="messages-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php?f=social">'.get_lang('Messages').$count_unread_message.'</a></li>'; $active = $show == 'invitations' ? 'active' : null; $html .= '<li class="invitations-icon'.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">'.get_lang('Invitations').$total_invitations.'</a></li>'; $html .= '<li class="shared-profile-icon active"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">'.get_lang('ViewMySharedProfile').'</a></li> <li class="friends-icon"><a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">'.get_lang('Friends').'</a></li> <li class="browse-groups-icon"><a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php">'.get_lang('SocialGroups').'</a></li>'; $active = $show == 'search' ? 'active' : null; $html .= '<li class="search-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">'.get_lang('Search').'</a></li>'; $active = $show == 'myfiles' ? 'active' : null; $html .= '<li class="myfiles-icon '.$active.'"><a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">'.get_lang('MyFiles').'</a></li>'; } // My friend profile. if ($user_id != api_get_user_id()) { $html .= '<li><a href="javascript:void(0);" onclick="javascript:send_message_to_user(\''.$user_id.'\');" title="'.get_lang('SendMessage').'">'; $html .= Display::return_icon('compose_message.png', get_lang('SendMessage')).' '.get_lang('SendMessage').'</a></li>'; } // Check if I already sent an invitation message $invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id()); if (isset($invitation_sent_list[$user_id]) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) > 0) { $html .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">'.Display::return_icon('invitation.png', get_lang('YouAlreadySentAnInvitation')).' '.get_lang('YouAlreadySentAnInvitation').'</a></li>'; } else { if (!$show_full_profile) { $html .= '<li><a href="javascript:void(0);" onclick="javascript:send_invitation_to_user(\''.$user_id.'\');" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).' '.get_lang('SendInvitation').'</a></li>'; } } // Chat //@todo check if user is online and if it's a friend to show the chat link if (api_is_global_chat_enabled()) { $user_name = $user_info['complete_name']; if ($user_friend_relation == USER_RELATION_TYPE_FRIEND) { if ($user_id != api_get_user_id()) { //Only show chat if I'm available to talk if ($current_user_info['user_is_online_in_chat'] == 1) { $options = array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."', '".$user_info['user_is_online_in_chat']."')"); $chat_icon = $user_info['user_is_online_in_chat'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline')); $html .= Display::tag('li', Display::url( $chat_icon.' '.get_lang('Chat'), 'javascript:void(0);', $options ) ); } } } else { if ($user_id != api_get_user_id()) { if ($current_user_info['user_is_online_in_chat'] == 1) { $message = Security::remove_XSS(sprintf(get_lang("YouHaveToAddXAsAFriendFirst"), $user_name)); $options = array('onclick' => "javascript:chatNotYetWith('".$message."')"); $chat_icon = $user_info['user_is_online_in_chat'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline')); $html .= Display::tag('li', Display::url( $chat_icon.' '.get_lang('Chat'), 'javascript:void(0);', $options ) ); } } } } $html .= '</ul></div>'; if ($show_full_profile && $user_id == intval(api_get_user_id())) { $personal_course_list = UserManager::get_personal_session_course_list($user_id); $course_list_code = array(); $i = 1; if (is_array($personal_course_list)) { foreach ($personal_course_list as $my_course) { if ($i <= 10) { $course_list_code[] = array('code' => $my_course['code']); } else { break; } $i++; } //to avoid repeted courses $course_list_code = array_unique_dimensional($course_list_code); } //-----Announcements $my_announcement_by_user_id = intval($user_id); $announcements = array(); foreach ($course_list_code as $course) { $course_info = api_get_course_info($course['code']); if (!empty($course_info)) { $content = AnnouncementManager::get_all_annoucement_by_user_course($course_info['code'], $my_announcement_by_user_id); if (!empty($content)) { $url = Display::url(Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')', api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']); $announcements[] = Display::tag('li', $url); } } } if (!empty($announcements)) { $html .= '<div class="social_menu_items">'; $html .= '<ul>'; foreach ($announcements as $announcement) { $html .= $announcement; } $html .= '</ul>'; $html .= '</div>'; } } } if ($show_delete_account_button) { $html .= '<div class="sidebar-nav"><ul><li>'; $url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php'; $html .= Display::url(Display::return_icon('delete.png', get_lang('Unsubscribe'), array(), ICON_SIZE_TINY).get_lang('Unsubscribe'), $url); $html .= '</li></ul></div>'; } $html .= ''; return $html; }
$show_message = Display::return_message(get_lang('GroupInvitationWasDeny')); break 2; } } } $social_avatar_block = SocialManager::show_social_avatar_block('invitations'); $social_menu_block = SocialManager::show_social_menu('invitations'); $social_right_content = '<div class="span9"> <div id="id_response" align="center"></div> </div></div>'; $user_id = api_get_user_id(); $list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id); $list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id); $pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION); $number_loop = count($list_get_invitation); $total_invitations = $number_loop + count($list_get_invitation_sent) + count($pending_invitations); if ($total_invitations == 0 && count($_GET) <= 0) { $social_right_content .= '<div class="row"><div class="span9"><a class="btn" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a></div></div>'; } if ($number_loop != 0) { $social_right_content .= '<div class="row"><div class="span9">'.Display::page_subheader(get_lang('InvitationReceived')).'</div></div>'; foreach ($list_get_invitation as $invitation) { $sender_user_id = $invitation['user_sender_id']; $social_right_content .= '<div id="id_'.$sender_user_id.'" class="row invitation-clear">';
} $result = Database::query($sql); $Users = Database::store_result($result); foreach ($Users as $user) { $sessionUsersList[$user['user_id']] = $user; } } else { $friends = SocialManager::get_friends(api_get_user_id()); $suggest_friends = false; if (!$friends) { $suggest_friends = true; } else { foreach ($friends as $friend) { $group_friend_list = GroupPortalManager::get_groups_by_user( $friend['friend_user_id'], 0 ); $friend_group_id = ''; if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) { $friend_group_id = $group_id; } if (!isset($group_friend_list[$group_id]) || isset($group_friend_list[$group_id]) && empty($group_friend_list[$group_id]['relation_type'])) { $Users[$friend['friend_user_id']] = array( 'user_id' => $friend['friend_user_id'], 'firstname' => $friend['firstName'], 'lastname' => $friend['lastName'], 'username' => $friend['username'], 'group_id' => $friend_group_id ); } }
/** * Delete a user from the platform, and all its belongings. This is a * very dangerous function that should only be accessible by * super-admins. Other roles should only be able to disable a user, * which removes access to the platform but doesn't delete anything. * @param int The ID of th user to be deleted * @return boolean true if user is successfully deleted, false otherwise * @assert (null) === false * @assert ('abc') === false */ public static function delete_user($user_id) { if ($user_id != strval(intval($user_id))) { return false; } if ($user_id === false) { return false; } if (!self::can_delete_user($user_id)) { return false; } $table_user = Database :: get_main_table(TABLE_MAIN_USER); $usergroup_rel_user = Database :: get_main_table(TABLE_USERGROUP_REL_USER); $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); $table_session = Database :: get_main_table(TABLE_MAIN_SESSION); $table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN); $table_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER); $table_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $table_group = Database :: get_course_table(TABLE_GROUP_USER); $table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); // Unsubscribe the user from all groups in all his courses $sql = "SELECT c.id FROM $table_course c, $table_course_user cu WHERE cu.user_id = '".$user_id."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND c.code = cu.course_code"; $res = Database::query($sql); while ($course = Database::fetch_object($res)) { $sql = "DELETE FROM $table_group WHERE c_id = {$course->id} AND user_id = $user_id"; Database::query($sql); } // Unsubscribe user from all classes //Classes are not longer supported /* $sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'"; Database::query($sql); */ // Unsubscribe user from usergroup_rel_user $sql = "DELETE FROM $usergroup_rel_user WHERE user_id = '".$user_id."'"; Database::query($sql); // Unsubscribe user from all courses $sql = "DELETE FROM $table_course_user WHERE user_id = '".$user_id."'"; Database::query($sql); // Unsubscribe user from all courses in sessions $sql = "DELETE FROM $table_session_course_user WHERE id_user = '******'"; Database::query($sql); // If the user was added as a id_coach then set the current admin as coach see BT# $currentUserId = api_get_user_id(); $sql = "UPDATE $table_session SET id_coach = $currentUserId WHERE id_coach = '".$user_id."'"; Database::query($sql); $sql = "UPDATE $table_session SET id_coach = $currentUserId WHERE session_admin_id = '".$user_id."'"; Database::query($sql); // Unsubscribe user from all sessions $sql = "DELETE FROM $table_session_user WHERE id_user = '******'"; Database::query($sql); // Delete user picture /* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true' a user has 4 differnt sized photos to be deleted. */ $user_info = api_get_user_info($user_id); if (strlen($user_info['picture_uri']) > 0) { $img_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri']; if (file_exists($img_path)) unlink($img_path); } // Delete the personal course categories $course_cat_table = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY); $sql = "DELETE FROM $course_cat_table WHERE user_id = '".$user_id."'"; Database::query($sql); // Delete user from database $sql = "DELETE FROM $table_user WHERE user_id = '".$user_id."'"; Database::query($sql); // Delete user from the admin table $sql = "DELETE FROM $table_admin WHERE user_id = '".$user_id."'"; Database::query($sql); // Delete the personal agenda-items from this user $agenda_table = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); $sql = "DELETE FROM $agenda_table WHERE user = '******'"; Database::query($sql); $gradebook_results_table = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); $sql = 'DELETE FROM '.$gradebook_results_table.' WHERE user_id = '.$user_id; Database::query($sql); $t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); $sqlv = "DELETE FROM $t_ufv WHERE user_id = $user_id"; Database::query($sqlv); require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; if (api_get_multiple_access_url()) { $url_id = api_get_current_access_url_id(); UrlManager::delete_url_rel_user($user_id, $url_id); } else { //we delete the user from the url_id =1 UrlManager::delete_url_rel_user($user_id, 1); } if (api_get_setting('allow_social_tool') == 'true') { require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; //Delete user from portal groups $group_list = GroupPortalManager::get_groups_by_user($user_id); if (!empty($group_list)) { foreach ($group_list as $group_id => $data) { GroupPortalManager::delete_user_rel_group($user_id, $group_id); } } // Delete user from friend lists SocialManager::remove_user_rel_user($user_id, true); } // Removing survey invitation survey_manager::delete_all_survey_invitations_by_user($user_id); // Delete students works $sql = "DELETE FROM $table_work WHERE user_id = $user_id AND c_id <> 0"; Database::query($sql); // Add event to system log $user_id_manager = api_get_user_id(); event_system(LOG_USER_DELETE, LOG_USER_ID, $user_id, api_get_utc_datetime(), $user_id_manager, null, $user_info); event_system(LOG_USER_DELETE, LOG_USER_OBJECT, $user_info, api_get_utc_datetime(), $user_id_manager, null, $user_info); return true; }