Dokeos PHP Cross Reference Learning Management Systems

Source: /main/social/group_members.php - 191 lines - 8673 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  /**
   4   * @package dokeos.social
   5   * @author Julio Montoya <gugli100@gmail.com>
   6   */
   7   
   8  $language_file = array('userInfo');
   9  $cidReset = true;
  10  require  '../inc/global.inc.php';
  11  require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  12  require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  13  require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  14  
  15  //$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
  16  $htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/thickbox.js"></script>';
  17  $htmlHeadXtra[] = '<link rel="stylesheet" href="/main/inc/lib/javascript/thickbox.css" type="text/css" media="projection, screen">';
  18  $htmlHeadXtra[] = '<script type="text/javascript">
  19          
  20  function show_icon_edit(element_html) {    
  21      ident="#edit_image";
  22      $(ident).show();
  23  }        
  24  
  25  function hide_icon_edit(element_html)  {
  26      ident="#edit_image";
  27      $(ident).hide();
  28  }        
  29          
  30  </script>';
  31  
  32  $this_section = SECTION_SOCIAL;
  33  $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
  34  $interbreadcrumb[] = array('url' => 'groups.php','name' => get_lang('Groups'));
  35  $interbreadcrumb[] = array('url' => '#','name' => get_lang('MemberList'));
  36  api_block_anonymous_users();
  37  
  38  $group_id    = intval($_GET['id']);
  39  
  40  //todo @this validation could be in a function in group_portal_manager
  41  if (empty($group_id)) {
  42      api_not_allowed();
  43  } else {
  44      $group_info = GroupPortalManager::get_group_data($group_id);
  45      if (empty($group_info)) {
  46          api_not_allowed();
  47      }
  48      $user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
  49      if (!in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR, GROUP_USER_PERMISSION_READER))) {
  50          api_not_allowed();        
  51      }
  52  }
  53  
  54  
  55  Display :: display_header($tool_name, 'Groups');
  56  
  57  // Display actions
  58  echo '<div class="actions">';
  59  echo '<a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('pixel.gif',get_lang('Home'),array('class' => 'toolactionplaceholdericon toolactionshome')).get_lang('Home').'</a>';
  60  // Only admins and teachers can create groups
  61  if (api_is_allowed_to_edit(null,true)) {
  62      echo '<a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('pixel.gif',get_lang('CreateAgroup'),array('class' => 'toolactionplaceholdericon toolactionsgroup')).get_lang('CreateAgroup').'</a>';
  63  }
  64  echo '<a href="'.api_get_path(WEB_PATH).'main/social/groups.php?view=mygroups">'.Display::return_icon('pixel.gif',get_lang('MyGroups'),array('class' => 'toolactionplaceholdericon toolactiongroupimage')).get_lang('MyGroups').'</a>';
  65  if (isset($_GET['id']) && $_GET['id'] >= 0) {
  66    $group_id = Security::remove_XSS($_GET['id']);
  67    $relation_group_title = get_lang('IamAnAdmin');
  68    $links .=  '<a href="groups.php?id='.$group_id.'">'.                Display::return_icon('pixel.gif',get_lang('MessageList'),array('class' => 'toolactionplaceholdericon toolsocialmessagelist')).get_lang('MessageList').'</a>';
  69  
  70    //my relation with the group is set here
  71    $my_group_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
  72    if ($my_group_role == GROUP_USER_PERMISSION_READER) {
  73        $links .=  '<a href="groups.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.    Display::return_icon('pixel.gif', get_lang('LeaveGroup'), array('class'=>'toolactionplaceholdericon tooldeletegroup')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a>';
  74    }
  75  
  76    echo $links;
  77  }
  78  echo '</div>';
  79  // Start content
  80  echo '<div id="content">';
  81  
  82  $user_online_list = who_is_online(api_get_setting('time_limit_whosonline'), true);
  83  $user_online_count = count($user_online_list); 
  84  
  85  $show_message    = ''; 
  86  //if i'm a moderator
  87  if (isset($_GET['action']) && $_GET['action']=='add') {
  88      // we add a user only if is a open group
  89      $user_join = intval($_GET['u']);
  90      //if i'm a moderator        
  91      if (GroupPortalManager::is_group_moderator($group_id)) {
  92          GroupPortalManager::update_user_role($user_join, $group_id);
  93          $show_message = get_lang('UserAdded');
  94      }    
  95  }
  96  
  97  if (isset($_GET['action']) && $_GET['action']=='delete') {    
  98      // we add a user only if is a open group
  99      $user_join = intval($_GET['u']);
 100      //if i'm a moderator        
 101      if (GroupPortalManager::is_group_moderator($group_id)) {
 102          GroupPortalManager::delete_user_rel_group($user_join, $group_id); 
 103          $show_message = get_lang('UserDeleted');
 104      }
 105  }
 106  
 107  if (isset($_GET['action']) && $_GET['action']=='set_moderator') {    
 108      // we add a user only if is a open group
 109      $user_moderator= intval($_GET['u']);
 110      //if i'm the admin        
 111      if (GroupPortalManager::is_group_admin($group_id)) {
 112          GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR); 
 113          $show_message = get_lang('UserChangeToModerator');
 114      }
 115  }
 116  
 117  if (isset($_GET['action']) && $_GET['action']=='delete_moderator') {    
 118      // we add a user only if is a open group
 119      $user_moderator= intval($_GET['u']);
 120      //only group admins can do that    
 121      if (GroupPortalManager::is_group_admin($group_id)) {    
 122          GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_READER); 
 123          $show_message = get_lang('UserChangeToReader');
 124      }
 125  }
 126  
 127  
 128  
 129  $users    = GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000);
 130  $new_member_list = array();
 131  
 132  echo '<div id="social-content">';
 133      echo '<div id="social-content-left">';    
 134      //this include the social menu div
 135      SocialManager::show_social_menu('member_list',$group_id);
 136      echo '</div>';
 137      echo '<div id="social-content-right">';
 138          if (! empty($show_message)){
 139              Display :: display_normal_message($show_message);
 140          }    
 141          foreach($users as $user) {        
 142                  switch ($user['relation_type']) {
 143                      case  GROUP_USER_PERMISSION_ADMIN:
 144                          $user['link'] = Display::return_icon('admin_star.png', get_lang('Admin'));
 145                      break;
 146                      case  GROUP_USER_PERMISSION_READER:
 147                          if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
 148                          $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete">'.Display::return_icon('del_user_big.gif', get_lang('DeleteFromGroup')).'</a>'.
 149                                          '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('admins.gif', get_lang('AddModerator')).'</a>';
 150                          }
 151                      break;        
 152                      case  GROUP_USER_PERMISSION_PENDING_INVITATION:
 153                          $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=add">'.Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')).'</a>';                    
 154                      break;
 155                      case  GROUP_USER_PERMISSION_MODERATOR:
 156                          $user['link'] = Display::return_icon('moderator_star.png', get_lang('Moderator'));
 157                          //only group admin can manage moderators 
 158                          if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
 159                              $user['link'] .='<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete_moderator">'.Display::return_icon('del_user_big.gif', get_lang('DeleteModerator')).'</a>';
 160                          }
 161                      break;                
 162                  }
 163                  
 164                  $image_path = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);                                                
 165                  $picture = UserManager::get_picture_user($user['user_id'], $image_path['file'],80);                                        
 166                  $user['image'] = '<img src="'.$picture['file'].'"  width="50px" height="50px"  />';
 167                  
 168              $new_member_list[] = $user;
 169          }        
 170          if (count($new_member_list) > 0) {            
 171              Display::display_sortable_grid('list_members', array(), $new_member_list, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true,false,true,true));        
 172          }    
 173      echo '</div>';
 174  echo '</div>';
 175  
 176  // End content
 177  echo '</div>';
 178  
 179  // Actions
 180  echo '<div class="actions">';
 181  if (isset($_GET['id']) && $_GET['id'] >= 0) {
 182    $group_id = Security::remove_XSS($_GET['id']);
 183    $links =  '<a href="group_members.php?id='.$group_id.'">'.        Display::return_icon('pixel.gif', get_lang('MemberList'), array('class' => 'actionplaceholdericon actiongroupstudentview')).get_lang('MemberList').'</a>';
 184    $links .=  '<a href="group_waiting_list.php?id='.$group_id.'">'.    Display::return_icon('pixel.gif', get_lang('WaitingList'), array('class' => 'actionplaceholdericon actionlatestchanges')).get_lang('WaitingList').'</a>';
 185    $links .=  '<a href="group_invitation.php?id='.$group_id.'">'.    Display::return_icon('pixel.gif', get_lang('InviteFriends'), array('class' => 'actionplaceholdericon actionadduser')).get_lang('InviteFriends').'</a>';
 186    echo $links;
 187  }
 188  echo '</div>';
 189  
 190  Display :: display_footer();
 191  ?>

title

Description

title

Description

title

Description

title

title

Body