From 97b44056419ded07ab0bfd36a732e7be18e05019 Mon Sep 17 00:00:00 2001 From: Louis-Philippe Gauthier Date: Fri, 19 Jun 2020 08:44:21 -0400 Subject: [PATCH] Added a config flag to allow teachers or admins to view full social profile the same way that if they'd be Good friends in the social network. --- main/inc/lib/social.lib.php | 28 +++++++++++++++++++++++++++- main/social/vcard_export.php | 8 ++++++-- web.config | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index a3bb02f530..a1c735882d 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -83,7 +83,33 @@ class SocialManager extends UserManager return $row['id']; } else { - return USER_UNKNOWN; + if(api_get_configuration_value('treat_superior_statuses_as_friends')) + { + $targetUserCoursesList = CourseManager::get_courses_list_by_user_id($user_id,true,false); + $AdminList = UserManager::get_all_administrators(); + foreach($AdminList as $admin) + { + if(api_get_user_id() == $admin['user_id']) + { + return USER_RELATION_TYPE_GOODFRIEND; + } + } + foreach($targetUserCoursesList as $course) + { + $TeachersList = CourseManager::get_teacher_list_from_course_code($course['code']); + foreach($TeachersList as $teacher) + { + if(api_get_user_id() == $teacher['user_id']) + { + return USER_RELATION_TYPE_GOODFRIEND; + } + } + } + } + else { + return USER_UNKNOWN; + } + } } diff --git a/main/social/vcard_export.php b/main/social/vcard_export.php index 03055e96f0..2e7e18847f 100644 --- a/main/social/vcard_export.php +++ b/main/social/vcard_export.php @@ -13,7 +13,7 @@ use JeroenDesloovere\VCard\VCard; require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); -api_protect_admin_script(); +//api_protect_admin_script(); if (isset($_REQUEST['userId'])) { $userId = intval($_REQUEST['userId']); @@ -21,13 +21,17 @@ if (isset($_REQUEST['userId'])) { api_not_allowed(true); } + // Return User Info to vCard Export $userInfo = api_get_user_info($userId, true, false, true); if (empty($userInfo)) { api_not_allowed(true); } - +if(api_get_user_id() != $userId && !SocialManager::get_relation_between_contacts(api_get_user_id(),$userId)) +{ + api_not_allowed(true); +} // Pre-Loaded User Info $language = get_lang('Language').': '.$userInfo['language']; diff --git a/web.config b/web.config index 91eba6bd8d..6f53c717c9 100644 --- a/web.config +++ b/web.config @@ -103,4 +103,4 @@ - + \ No newline at end of file