From 02c308043b636f9cbfc49dc70e482dd3fb0ca3ea Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 31 Jan 2011 00:30:00 +0100 Subject: [PATCH] Adding group list in social tool see BT#1910 (need more love - partial) --- main/inc/lib/social.lib.php | 2 ++ main/inc/lib/usergroup.lib.php | 16 +++++++++ main/social/usergroups.php | 60 ++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100755 main/social/usergroups.php diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 22d0d1b7bb..910ba05477 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -638,6 +638,8 @@ class SocialManager extends UserManager { //Search users and groups echo '
  • '.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).''.get_lang('Search').'
  • '; + + echo Display::tag('li', Display::return_icon('group.png',get_lang('Groups'),array('hspace'=>'6')).Display::url(get_lang('MyClasses'),api_get_path(WEB_PATH).'main/social/usergroups.php')); //My files echo '
  • '.Display::return_icon('briefcase_small.png',get_lang('MyFiles'),array('hspace'=>'6')).''.get_lang('MyFiles').'
  • '; diff --git a/main/inc/lib/usergroup.lib.php b/main/inc/lib/usergroup.lib.php index 6c78e537f8..ac0f526ac9 100644 --- a/main/inc/lib/usergroup.lib.php +++ b/main/inc/lib/usergroup.lib.php @@ -66,6 +66,22 @@ class UserGroup extends Model { return $array; } + /** + * Gets the usergroup id list by user id + * @param int user id + */ + public function get_usergroup_by_user($id) { + $results = Database::select('*',$this->usergroup_rel_user_table, array('where'=>array('user_id = ?'=>$id))); + $array = array(); + if (!empty($results)) { + foreach($results as $row) { + $array[]= $row['usergroup_id']; + } + } + return $array; + } + + /** * Subscribes sessions to a group (also adding the members of the group in the session and course) diff --git a/main/social/usergroups.php b/main/social/usergroups.php new file mode 100755 index 0000000000..1c5a99b8e2 --- /dev/null +++ b/main/social/usergroups.php @@ -0,0 +1,60 @@ + + */ + +$language_file = array('userInfo'); +$cidReset=true; +require '../inc/global.inc.php'; + +require_once api_get_path(LIBRARY_PATH).'social.lib.php'; +require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; + +api_block_anonymous_users(); + +$this_section = SECTION_SOCIAL; + +//jquery thickbox already called from main/inc/header.inc.php +$htmlHeadXtra[] = ''; + +$interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social')); +$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Groups')); + +Display :: display_header($tool_name, 'Groups'); + +echo '
    '; + + echo '
    '; + //this include the social menu div + SocialManager::show_social_menu('friends'); + echo '
    '; + echo '
    '; + +$language_variable = api_xml_http_response_encode(get_lang('Groups')); +$user_id = api_get_user_id(); + +$list_path_friends = array(); +$user_id = api_get_user_id(); +$name_search= Security::remove_XSS($_POST['search_name_q']); +$number_friends = 0; + +if (isset($name_search) && $name_search!='undefined') { + $friends = SocialManager::get_friends($user_id,null,$name_search); +} else { + $friends = SocialManager::get_friends($user_id); +} + +$usergroup = new Usergroup(); +$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id()); +if (!empty($usergroup_list)) { + echo Display::tag('h2',get_lang('MyGroup')); + foreach($usergroup_list as $group_id) { + $data = $usergroup->get($group_id); + echo Display::tag('div',$data['name']); + } +} +Display :: display_footer(); \ No newline at end of file