groups.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <?php
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. * @package dokeos.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. $cidReset=true;
  8. $language_file = array('userInfo');
  9. require_once '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  15. api_block_anonymous_users();
  16. $this_section = SECTION_SOCIAL;
  17. //jquery thickbox already called from main/inc/header.inc.php
  18. // prepare anchor for message group topic
  19. $anchor = '';
  20. if (isset($_GET['anchor_topic'])) {
  21. $anchor = Security::remove_XSS($_GET['anchor_topic']);
  22. } else {
  23. $match = 0;
  24. $param_names = array_keys($_GET);
  25. foreach ($param_names as $param) {
  26. if (preg_match('/^items_(\d)_page_nr$/', $param, $match)) {
  27. break;
  28. }
  29. }
  30. $anchor = 'topic_'.$match[1];
  31. }
  32. $htmlHeadXtra[] = '<script type="text/javascript">
  33. var counter_image = 1;
  34. function remove_image_form(id_elem1) {
  35. var elem1 = document.getElementById(id_elem1);
  36. elem1.parentNode.removeChild(elem1);
  37. counter_image--;
  38. var filepaths = document.getElementById("filepaths");
  39. if (filepaths.childNodes.length < 3) {
  40. var link_attach = document.getElementById("link-more-attach");
  41. if (link_attach) {
  42. link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>&nbsp;('.get_lang('MaximunFileSizeXMB').')\';
  43. }
  44. }
  45. }
  46. function add_image_form() {
  47. // Multiple filepaths for image form
  48. var filepaths = document.getElementById("filepaths");
  49. if (document.getElementById("filepath_"+counter_image)) {
  50. counter_image = counter_image + 1;
  51. } else {
  52. counter_image = counter_image;
  53. }
  54. var elem1 = document.createElement("div");
  55. elem1.setAttribute("id","filepath_"+counter_image);
  56. filepaths.appendChild(elem1);
  57. id_elem1 = "filepath_"+counter_image;
  58. id_elem1 = "\'"+id_elem1+"\'";
  59. document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
  60. if (filepaths.childNodes.length == 3) {
  61. var link_attach = document.getElementById("link-more-attach");
  62. if (link_attach) {
  63. link_attach.innerHTML="";
  64. }
  65. }
  66. }
  67. function validate_text_empty (str,msg) {
  68. var str = str.replace(/^\s*|\s*$/g,"");
  69. if (str.length == 0) {
  70. alert(msg);
  71. return true;
  72. }
  73. }
  74. jQuery(document).ready(function() {
  75. var valor = "'.$anchor.'";
  76. $(".head").click(function() {
  77. $(this).next().next().slideToggle("fast");
  78. image_clicked = $("#" + this.id + " img").attr("src");
  79. image_clicked_info = image_clicked.split("/");
  80. image_real_clicked = image_clicked_info[image_clicked_info.length-1];
  81. image_path = image_clicked.split("img");
  82. current_path = image_path[0]+"img/";
  83. if (image_real_clicked == "div_show.gif") {
  84. current_path = current_path+"div_hide.gif";
  85. $("#" + this.id + " img").attr("src", current_path);
  86. } else {
  87. current_path = current_path+"div_show.gif";
  88. $("#" + this.id + " img").attr("src", current_path)
  89. }
  90. return false;
  91. }).next().next().hide();
  92. // anchor for current topic
  93. if (valor) {
  94. $("#"+valor).show();
  95. window.location = document.URL+"#"+valor;
  96. }
  97. });
  98. function show_icon_edit(element_html) {
  99. ident="#edit_image";
  100. $(ident).show();
  101. }
  102. function hide_icon_edit(element_html) {
  103. ident="#edit_image";
  104. $(ident).hide();
  105. }
  106. </script>';
  107. $allowed_views = array('mygroups','newest','pop');
  108. $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
  109. if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
  110. if ($_GET['view'] == 'mygroups') {
  111. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  112. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups'));
  113. } else if ( $_GET['view'] == 'newest') {
  114. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  115. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest'));
  116. } else {
  117. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  118. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular'));
  119. }
  120. } else {
  121. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  122. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList'));
  123. }
  124. Display :: display_header($tool_name, 'Groups');
  125. // save message group
  126. if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) {
  127. if (isset($_POST['action'])) {
  128. $title = $_POST['title'];
  129. $content = $_POST['content'];
  130. $group_id = intval($_POST['group_id']);
  131. $parent_id = intval($_POST['parent_id']);
  132. if ($_POST['action'] == 'edit_message_group') {
  133. $edit_message_id = intval($_POST['message_id']);
  134. $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, $edit_message_id);
  135. } else {
  136. $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id);
  137. }
  138. // display error messages
  139. if (is_string($res)) {
  140. Display::display_error_message($res);
  141. }
  142. if ($res === true) {
  143. $groups_user = GroupPortalManager::get_users_by_group($group_id);
  144. $group_info = GroupPortalManager::get_group_data($group_id);
  145. $admin_user_info = api_get_user_info(1);
  146. $sender_name = api_get_person_name($admin_user_info['firstName'], $admin_user_info['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
  147. $sender_email = $admin_user_info['mail'];
  148. $subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'),$group_info['name']);
  149. $link = api_get_path(WEB_PATH).'main/social/groups.php?'.$_SERVER['QUERY_STRING'];
  150. $text_link = '<a href="'.$link.'">'.get_lang('ClickHereToSeeMessageGroup')."</a><br />\r\n<br />\r\n".get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$link;
  151. $message = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'),$group_info['name'])."<br />$text_link";
  152. foreach ($groups_user as $group_user) {
  153. if ($group_user == $current_user) continue;
  154. $group_user_info = api_get_user_info($group_user['user_id']);
  155. $recipient_name = api_get_person_name($group_user_info['firstName'], $group_user_info['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
  156. $recipient_email = $group_user_info['mail'];
  157. @api_mail_html($recipient_name, $recipient_email, stripslashes($subject), $message, $sender_name, $sender_email);
  158. }
  159. }
  160. Security::clear_token();
  161. }
  162. }
  163. // getting group information
  164. $group_id = intval($_GET['id']);
  165. $relation_group_title = '';
  166. $my_group_role = 0;
  167. if ($group_id != 0 ) {
  168. $user_leave_message = false;
  169. $user_added_group_message = false;
  170. $group_info = GroupPortalManager::get_group_data($group_id);
  171. if (isset($_GET['action']) && $_GET['action']=='leave') {
  172. $user_leaved = intval($_GET['u']);
  173. //I can "leave me myself"
  174. if (api_get_user_id() == $user_leaved) {
  175. GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
  176. $user_leave_message = true;
  177. }
  178. }
  179. // add a user to a group if its open
  180. if (isset($_GET['action']) && $_GET['action']=='join') {
  181. // we add a user only if is a open group
  182. $user_join = intval($_GET['u']);
  183. if (api_get_user_id() == $user_join && !empty($group_id)) {
  184. if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
  185. GroupPortalManager::add_user_to_group($user_join, $group_id);
  186. $user_added_group_message = true;
  187. } else {
  188. GroupPortalManager::add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER);
  189. $user_added_group_message = true;
  190. }
  191. }
  192. }
  193. }
  194. echo '<div id="social-content">';
  195. echo '<div id="social-content-left">';
  196. //this include the social menu div
  197. if ($group_id != 0 ) {
  198. SocialManager::show_social_menu('groups',$group_id);
  199. } else {
  200. $show_menu = 'groups';
  201. if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
  202. $show_menu = $_GET['view'];
  203. }
  204. SocialManager::show_social_menu($show_menu);
  205. }
  206. echo '</div>';
  207. echo '<div id="social-content-right">';
  208. if ($group_id != 0 ) {
  209. $group_info = GroupPortalManager::get_group_data($group_id);
  210. //Loading group information
  211. if (isset($_GET['status']) && $_GET['status']=='sent') {
  212. Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false);
  213. }
  214. if ($user_leave_message) {
  215. Display::display_confirmation_message(get_lang('UserIsNotSubscribedToThisGroup'), false);
  216. }
  217. if ($user_added_group_message) {
  218. Display::display_confirmation_message(get_lang('UserIsSubscribedToThisGroup'), false);
  219. }
  220. // details about the current group
  221. echo '<div class="head_group">';
  222. echo '<div id="social-group-details">';
  223. //Group's title
  224. echo '<h2><a href="groups.php?id='.$group_id.'">'.$group_info['name'].'</a></h2>';
  225. //Group's description
  226. echo '<div class="social-group-details-info">'.$group_info['description'].'</div>';
  227. echo '<div class="social-group-details-info"><a target="_blank" href="'.$group_info['url'].'">'.$group_info['url'].'</a></div>';
  228. //Privacy
  229. echo '<div class="social-group-details-info">';
  230. echo '<span>'.get_lang('Privacy').' : </span>';
  231. if ($group_info['visibility']== GROUP_PERMISSION_OPEN) {
  232. echo get_lang('ThisIsAnOpenGroup');
  233. } elseif ($group_info['visibility']== GROUP_PERMISSION_CLOSED) {
  234. echo get_lang('ThisIsACloseGroup');
  235. }
  236. echo '</div>';
  237. if (!empty($relation_group_title)) {
  238. echo '<div class="social-group-details-info">';
  239. echo '<span>'.get_lang('StatusInThisGroup').' : </span>';
  240. echo $relation_group_title;
  241. echo '</div>';
  242. }
  243. //Group's tags
  244. if (!empty($tags)) {
  245. echo '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
  246. }
  247. echo '</div>';
  248. echo '</div>';
  249. echo '<div class="clear"></div>';
  250. //-- Show message groups
  251. echo '<div class="messages">';
  252. if (GroupPortalManager::is_group_member($group_id)) {
  253. echo '<h3>'.get_lang('Topics').'</h3>';
  254. $content = MessageManager::display_messages_for_group($group_id);
  255. if (!empty($content)) {
  256. echo $content;
  257. } else {
  258. echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouShouldCreateATopic').'</span></a></li>';
  259. }
  260. } else {
  261. // if I already sent an invitation message
  262. if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
  263. echo '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('group_join.png', get_lang('YouShouldJoinTheGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouShouldJoinTheGroup').'</a></span>';
  264. } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
  265. echo '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('group_join.png', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a>';
  266. }
  267. }
  268. echo '</div>'; // end layout messages
  269. } else {
  270. // My groups -----
  271. $results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0);
  272. $grid_my_groups = array();
  273. if (is_array($results) && count($results) > 0) {
  274. foreach ($results as $result) {
  275. $id = $result['id'];
  276. $url_open = '<a href="groups.php?id='.$id.'">';
  277. $url_close = '</a>';
  278. $name = api_strtoupper(cut($result['name'],25,true));
  279. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  280. $name .= Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
  281. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  282. $name .= Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
  283. }
  284. $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
  285. if ($count_users_group == 1 ) {
  286. $count_users_group = $count_users_group.' '.get_lang('Member');
  287. } else {
  288. $count_users_group = $count_users_group.' '.get_lang('Members');
  289. }
  290. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  291. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  292. $grid_item_1 = Display::return_icon('boxmygroups.jpg',get_lang('MyGroups'));
  293. $item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg','').'</div>';
  294. $item_2 = '';
  295. $item_3 = '';
  296. if ($result['description'] != '') {
  297. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
  298. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  299. } else {
  300. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  301. $item_3 = '<div class="box_description_group_content" ></div>';
  302. }
  303. $item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  304. $grid_item_2 = $item_1.$item_2.$item_3.$item_4;
  305. $grid_my_groups[]= array($grid_item_1,$grid_item_2);
  306. }
  307. }
  308. // Newest groups --------
  309. $results = GroupPortalManager::get_groups_by_age(4,false);
  310. $grid_newest_groups = array();
  311. foreach ($results as $result) {
  312. $id = $result['id'];
  313. $url_open = '<a href="groups.php?id='.$id.'">';
  314. $url_close = '</a>';
  315. $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
  316. if ($count_users_group == 1 ) {
  317. $count_users_group = $count_users_group.' '.get_lang('Member');
  318. } else {
  319. $count_users_group = $count_users_group.' '.get_lang('Members');
  320. }
  321. $name = api_strtoupper(cut($result['name'],30,true));
  322. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  323. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  324. $grid_item_1 = Display::return_icon('boxmygroups.jpg',get_lang('Newest'));
  325. $item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg','').'</div>';
  326. if ($result['description'] != '') {
  327. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
  328. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  329. } else {
  330. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  331. $item_3 = '<div class="box_description_group_content" ></div>';
  332. }
  333. $item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  334. $grid_item_2 = $item_1.$item_2.$item_3.$item_4;
  335. $grid_newest_groups[]= array($grid_item_1,$grid_item_2);
  336. }
  337. // Pop groups -----
  338. $results = GroupPortalManager::get_groups_by_popularity(4,false);
  339. $grid_pop_groups = array();
  340. if (is_array($results) && count($results) > 0) {
  341. foreach ($results as $result) {
  342. $id = $result['id'];
  343. $url_open = '<a href="groups.php?id='.$id.'">';
  344. $url_close = '</a>';
  345. $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000));
  346. if ($count_users_group == 1 ) {
  347. $count_users_group = $count_users_group.' '.get_lang('Member');
  348. } else {
  349. $count_users_group = $count_users_group.' '.get_lang('Members');
  350. }
  351. $name = api_strtoupper(cut($result['name'],30,true));
  352. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  353. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  354. $grid_item_1 = Display::return_icon('boxmygroups.jpg',get_lang('Popular'));
  355. $item_1 = '<div>'.$url_open.$result['picture_uri'].'<p class="social-groups-text1"><strong>'.$name.'<br />('.$count_users_group.')</strong></p>'.$url_close.Display::return_icon('linegroups.jpg').'</div>';
  356. if ($result['description'] != '') {
  357. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
  358. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  359. } else {
  360. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  361. $item_3 = '<div class="box_description_group_content" ></div>';
  362. }
  363. $item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  364. $grid_item_2 = $item_1.$item_2.$item_3.$item_4;
  365. $grid_pop_groups[]= array($grid_item_1,$grid_item_2);
  366. }
  367. }
  368. // display groups (newest, mygroups, pop)
  369. echo '<div class="social-box-container2">';
  370. if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
  371. $view_group = $_GET['view'];
  372. switch ($view_group) {
  373. case 'mygroups' :
  374. if (count($grid_my_groups) > 0) {
  375. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('MyGroups')).'</div>';
  376. Display::display_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
  377. }
  378. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  379. if (empty($grid_my_groups)) {
  380. echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  381. }
  382. }
  383. break;
  384. case 'newest' :
  385. if (count($grid_newest_groups) > 0) {
  386. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';
  387. Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
  388. }
  389. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  390. if (empty($grid_newest_groups)) {
  391. echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  392. }
  393. }
  394. break;
  395. default :
  396. if (count($grid_pop_groups) > 0) {
  397. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Popular')).'</div>';
  398. Display::display_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
  399. }
  400. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  401. if (empty($grid_pop_groups)) {
  402. echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  403. }
  404. }
  405. break;
  406. }
  407. } else {
  408. if (count($grid_my_groups) > 0) {
  409. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('MyGroups')).'</div>';
  410. Display::display_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
  411. }
  412. if (count($grid_newest_groups) > 0) {
  413. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Newest')).'</div>';
  414. Display::display_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
  415. }
  416. if (count($grid_pop_groups) > 0) {
  417. echo '<div class="social-groups-text3">'.api_strtoupper(get_lang('Popular')).'</div>';
  418. Display::display_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
  419. }
  420. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  421. if (empty($grid_my_groups) && empty($grid_newest_groups) && empty($grid_pop_groups) ) {
  422. echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  423. }
  424. }
  425. }
  426. echo '</div>';
  427. }
  428. echo '</div>';
  429. echo '</div>';
  430. Display :: display_footer();