groups.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.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. api_block_anonymous_users();
  11. if (api_get_setting('allow_social_tool') !='true') {
  12. api_not_allowed();
  13. }
  14. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  15. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  16. $this_section = SECTION_SOCIAL;
  17. // prepare anchor for message group topic
  18. $anchor = '';
  19. if (isset($_GET['anchor_topic'])) {
  20. $anchor = Security::remove_XSS($_GET['anchor_topic']);
  21. } else {
  22. $match = 0;
  23. $param_names = array_keys($_GET);
  24. foreach ($param_names as $param) {
  25. if (preg_match('/^items_(\d)_page_nr$/', $param, $match)) {
  26. break;
  27. }
  28. }
  29. $anchor = 'topic_'.$match[1];
  30. }
  31. $htmlHeadXtra[] = api_get_jquery_ui_js();
  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>\';
  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. /* Binds a tab id in the url */
  76. $("#tab_browse").bind("tabsselect", function(event, ui) {
  77. window.location.href=ui.tab;
  78. });
  79. $("#tabs").tabs();
  80. $("#tab_browse").tabs();
  81. var valor = "'.$anchor.'";
  82. $(".head").click(function() {
  83. $(this).next().next().slideToggle("fast");
  84. image_clicked = $("#" + this.id + " img").attr("src");
  85. image_clicked_info = image_clicked.split("/");
  86. image_real_clicked = image_clicked_info[image_clicked_info.length-1];
  87. image_path = image_clicked.split("img");
  88. current_path = image_path[0]+"img/";
  89. if (image_real_clicked == "div_show.gif") {
  90. current_path = current_path+"div_hide.gif";
  91. $("#" + this.id + " img").attr("src", current_path);
  92. } else {
  93. current_path = current_path+"div_show.gif";
  94. $("#" + this.id + " img").attr("src", current_path)
  95. }
  96. return false;
  97. }).next().next().hide();
  98. // anchor for current topic
  99. if (valor) {
  100. $("#"+valor).show();
  101. window.location = document.URL+"#"+valor;
  102. }
  103. });
  104. </script>';
  105. $allowed_views = array('mygroups','newest','pop');
  106. $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
  107. if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
  108. if ($_GET['view'] == 'mygroups') {
  109. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  110. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups'));
  111. } else if ( $_GET['view'] == 'newest') {
  112. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  113. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest'));
  114. } else {
  115. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  116. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular'));
  117. }
  118. } else {
  119. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  120. if (!isset($_GET['id'])) {
  121. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList'));
  122. } else {
  123. //$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group'));
  124. }
  125. }
  126. Display :: display_header($tool_name, 'Groups');
  127. // getting group information
  128. $group_id = isset($_GET['id']) ? intval($_GET['id']) : null;
  129. $relation_group_title = '';
  130. $my_group_role = 0;
  131. if ($group_id != 0 ) {
  132. $user_leave_message = false;
  133. $user_added_group_message = false;
  134. $user_invitation_sent = false;
  135. $group_info = GroupPortalManager::get_group_data($group_id);
  136. if (isset($_GET['action']) && $_GET['action']=='leave') {
  137. $user_leaved = intval($_GET['u']);
  138. //I can "leave me myself"
  139. if (api_get_user_id() == $user_leaved) {
  140. GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
  141. $user_leave_message = true;
  142. }
  143. }
  144. // add a user to a group if its open
  145. if (isset($_GET['action']) && $_GET['action']=='join') {
  146. // we add a user only if is a open group
  147. $user_join = intval($_GET['u']);
  148. if (api_get_user_id() == $user_join && !empty($group_id)) {
  149. if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
  150. GroupPortalManager::add_user_to_group($user_join, $group_id);
  151. $user_added_group_message = true;
  152. } else {
  153. GroupPortalManager::add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER);
  154. $user_invitation_sent = true;
  155. }
  156. }
  157. }
  158. }
  159. $create_thread_link = '';
  160. echo '<div id="social-content">';
  161. echo '<div id="social-content-left">';
  162. //this include the social menu div
  163. if ($group_id != 0 ) {
  164. SocialManager::show_social_menu('groups',$group_id);
  165. } else {
  166. $show_menu = 'browse_groups';
  167. if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
  168. $show_menu = $_GET['view'];
  169. }
  170. SocialManager::show_social_menu($show_menu);
  171. }
  172. echo '</div>';
  173. echo '<div id="social-content-right">';
  174. if ($group_id != 0 ) {
  175. $group_info = GroupPortalManager::get_group_data($group_id);
  176. //Loading group information
  177. if (isset($_GET['status']) && $_GET['status']=='sent') {
  178. Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false);
  179. }
  180. if ($user_leave_message) {
  181. Display::display_confirmation_message(get_lang('UserIsNotSubscribedToThisGroup'), false);
  182. }
  183. if ($user_added_group_message) {
  184. Display::display_confirmation_message(get_lang('UserIsSubscribedToThisGroup'), false);
  185. }
  186. if ($user_invitation_sent) {
  187. Display::display_confirmation_message(get_lang('InvitationSent'), false);
  188. }
  189. $is_group_member = GroupPortalManager::is_group_member($group_id);
  190. // details about the current group
  191. echo '<div class="head_group">';
  192. echo '<div id="social-group-details">';
  193. //Group's title
  194. echo Display::tag('h2', Security::remove_XSS($group_info['name'], STUDENT, true));
  195. //echo '<div class="social-group-details-info"><a target="_blank" href="'.$group_info['url'].'">'.$group_info['url'].'</a></div>';
  196. //Privacy
  197. if (!$is_group_member) {
  198. echo '<div class="social-group-details-info">';
  199. echo '<span>'.get_lang('Privacy').' : </span>';
  200. if ($group_info['visibility']== GROUP_PERMISSION_OPEN) {
  201. echo get_lang('ThisIsAnOpenGroup');
  202. } elseif ($group_info['visibility']== GROUP_PERMISSION_CLOSED) {
  203. echo get_lang('ThisIsACloseGroup');
  204. }
  205. echo '</div>';
  206. }
  207. if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
  208. $role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
  209. if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
  210. echo Display::display_normal_message(get_lang('YouAlreadySentAnInvitation'));
  211. }
  212. }
  213. if (!empty($relation_group_title)) {
  214. /*
  215. echo '<div class="social-group-details-info">';
  216. echo '<span>'.get_lang('StatusInThisGroup').' : </span>';
  217. echo $relation_group_title;
  218. echo '</div>';*/
  219. }
  220. //Group's tags
  221. if (!empty($tags)) {
  222. echo '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
  223. }
  224. echo '</div>';
  225. echo '</div>';
  226. echo '<div class="clear"></div>';
  227. //-- Show message groups
  228. echo '<div class="messages" style="width:700px">';
  229. if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
  230. if (!$is_group_member) {
  231. if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
  232. echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
  233. } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
  234. echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
  235. }
  236. echo '<br /><br />';
  237. }
  238. $content = MessageManager::display_messages_for_group($group_id);
  239. if ($is_group_member) {
  240. if (empty($content)) {
  241. $create_thread_link = '<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="a_button orange medium thickbox" title="'.get_lang('ComposeMessage').'">'.get_lang('YouShouldCreateATopic').'</a></li>';
  242. } else {
  243. $create_thread_link = '<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="a_button orange medium thickbox" title="'.get_lang('ComposeMessage').'">'.get_lang('NewTopic').'</a>';
  244. }
  245. }
  246. $members = GroupPortalManager::get_users_by_group($group_id);
  247. $member_content = '';
  248. //Members
  249. if (count($members) > 0) {
  250. if ($my_group_role == GROUP_USER_PERMISSION_ADMIN) {
  251. $member_content .= Display::url(Display::return_icon('edit.gif', get_lang('EditMembersList')).' '.get_lang('EditMembersList'), 'group_members.php?id='.$group_id);
  252. }
  253. foreach($members as $member) {
  254. // if is a member
  255. if (in_array($member['relation_type'] , array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) {
  256. //add icons
  257. if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  258. $icon= Display::return_icon('social_group_admin.png', get_lang('Admin'));
  259. } elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  260. $icon= Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
  261. } else{
  262. $icon= '';
  263. }
  264. $image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
  265. $picture = UserManager::get_picture_user($member['user_id'], $image_path['file'], 60, USER_IMAGE_SIZE_MEDIUM);
  266. $member_content .= '<div class="">';
  267. $member_name = Display::url(api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).'&nbsp;'.$icon, 'profile.php?u='.$member['user_id']);
  268. $member_content .= Display::div('<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>&nbsp'.$member_name);
  269. $member_content .= '</div>';
  270. }
  271. }
  272. }
  273. if (!empty($create_thread_link)) {
  274. $create_thread_link = Display::div($create_thread_link, array('style'=>'padding-top:2px;height:40px'));
  275. }
  276. //api_get_item_property_by_tool('group', $course_info, $group_id);
  277. //$updates =
  278. //get_lang('Updates'),
  279. $headers = array(get_lang('Discussions'), get_lang('Members'));
  280. echo Display::tabs($headers, array($create_thread_link.$content, $member_content),'tabs');
  281. } else {
  282. // if I already sent an invitation message
  283. if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
  284. echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
  285. } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
  286. echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
  287. }
  288. }
  289. echo '</div>'; // end layout messages
  290. } else {
  291. // My groups -----
  292. $results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0);
  293. $grid_my_groups = array();
  294. $my_group_list = array();
  295. if (is_array($results) && count($results) > 0) {
  296. foreach ($results as $result) {
  297. $id = $result['id'];
  298. $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
  299. $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
  300. $my_group_list[] = $id;
  301. $url_open = '<a href="groups.php?id='.$id.'">';
  302. $url_close = '</a>';
  303. $name = cut($result['name'], GROUP_TITLE_LENGTH, true);
  304. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  305. $name .= ' '.Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
  306. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  307. $name .= ' '.Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
  308. }
  309. $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));
  310. if ($count_users_group == 1 ) {
  311. $count_users_group = $count_users_group.' '.get_lang('Member');
  312. } else {
  313. $count_users_group = $count_users_group.' '.get_lang('Members');
  314. }
  315. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  316. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  317. $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
  318. $members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
  319. $item_1 = Display::div(Display::tag('h2', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
  320. $item_2 = '';
  321. $item_3 = '';
  322. if ($result['description'] != '') {
  323. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  324. } else {
  325. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  326. $item_3 = '<div class="box_description_group_content" ></div>';
  327. }
  328. /*$join_url = '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('group_join.png', get_lang('JoinGroup'), array('hspace'=>'6')).''.get_lang('JoinGroup').'</a> ';
  329. $item_4 = '<div class="box_description_group_actions" >'.$join_url. $url_open.get_lang('SeeMore').$url_close.'</div>';*/
  330. $grid_item_2 = $item_0.$item_1.$item_2.$item_3;
  331. $grid_my_groups[]= array($grid_item_2);
  332. }
  333. }
  334. // Newest groups
  335. $results = GroupPortalManager::get_groups_by_age(4,false);
  336. $grid_newest_groups = array();
  337. foreach ($results as $result) {
  338. $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
  339. $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
  340. $id = $result['id'];
  341. $url_open = '<a href="groups.php?id='.$id.'">';
  342. $url_close = '</a>';
  343. $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));
  344. if ($count_users_group == 1 ) {
  345. $count_users_group = $count_users_group.' '.get_lang('Member');
  346. } else {
  347. $count_users_group = $count_users_group.' '.get_lang('Members');
  348. }
  349. $name = cut($result['name'],GROUP_TITLE_LENGTH,true);
  350. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  351. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  352. $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
  353. $members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
  354. $item_1 = Display::div(Display::tag('h2', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
  355. if ($result['description'] != '') {
  356. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  357. } else {
  358. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  359. $item_3 = '<div class="box_description_group_content" ></div>';
  360. }
  361. //Avoiding my groups
  362. $join_url = '';
  363. if (!in_array($id,$my_group_list)) {
  364. $join_url = '<a class="a_button white medium" href="groups.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> ';
  365. }
  366. $item_4 = '<div class="box_description_group_actions" >'.$join_url.'</div>';
  367. $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4;
  368. $grid_newest_groups[]= array($grid_item_2);
  369. }
  370. // Pop groups
  371. $results = GroupPortalManager::get_groups_by_popularity(4,false);
  372. $grid_pop_groups = array();
  373. if (is_array($results) && count($results) > 0) {
  374. foreach ($results as $result) {
  375. $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
  376. $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
  377. $id = $result['id'];
  378. $url_open = '<a href="groups.php?id='.$id.'">';
  379. $url_close = '</a>';
  380. $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));
  381. if ($count_users_group == 1 ) {
  382. $count_users_group = $count_users_group.' '.get_lang('Member');
  383. } else {
  384. $count_users_group = $count_users_group.' '.get_lang('Members');
  385. }
  386. $name = cut($result['name'],GROUP_TITLE_LENGTH,true);
  387. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  388. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  389. $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
  390. $members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
  391. $item_1 = Display::div(Display::tag('h2', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
  392. if ($result['description'] != '') {
  393. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  394. } else {
  395. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  396. $item_3 = '<div class="box_description_group_content" ></div>';
  397. }
  398. $join_url = '';
  399. if (!in_array($id,$my_group_list)) {
  400. $join_url = '<a class="a_button white medium" href="groups.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> ';
  401. }
  402. $item_4 = '<div class="box_description_group_actions" >'.$join_url.'</div>';
  403. $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4;
  404. $grid_pop_groups[]= array($grid_item_2);
  405. }
  406. }
  407. // Display groups (newest, mygroups, pop)
  408. $query_vars = array();
  409. if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
  410. $view_group = $_GET['view'];
  411. switch ($view_group) {
  412. case 'mygroups' :
  413. if (count($grid_my_groups) > 0) {
  414. $my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
  415. }
  416. if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  417. $create_group_item = '<a class="a_button orange medium" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
  418. //$my_group_content = $create_group_item. $my_group_content;
  419. } else {
  420. if (api_is_allowed_to_edit(null,true)) {
  421. $create_group_item = '<a class="a_button orange medium" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
  422. //$my_group_content = $create_group_item. $my_group_content;
  423. }
  424. }
  425. break;
  426. case 'newest' :
  427. if (count($grid_newest_groups) > 0) {
  428. $newest_content = Display::return_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
  429. }
  430. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  431. if (empty($grid_newest_groups)) {
  432. //echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  433. }
  434. }
  435. break;
  436. default :
  437. if (count($grid_pop_groups) > 0) {
  438. $popular_content = Display::return_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
  439. }
  440. if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  441. if (empty($grid_pop_groups)) {
  442. //echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
  443. }
  444. }
  445. break;
  446. }
  447. } else {
  448. $my_group_content = null;
  449. if (count($grid_my_groups) > 0) {
  450. $my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
  451. }
  452. if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  453. $create_group_item = '<a class="a_button orange medium" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
  454. //$my_group_content = $create_group_item. $my_group_content;
  455. } else {
  456. if (api_is_allowed_to_edit(null,true)) {
  457. $create_group_item = '<a class="a_button orange medium" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
  458. //$my_group_content = $create_group_item. $my_group_content;
  459. }
  460. }
  461. if (count($grid_newest_groups) > 0) {
  462. $newest_content = Display::return_sortable_grid('mygroups', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
  463. }
  464. if (count($grid_pop_groups) > 0) {
  465. $popular_content = Display::return_sortable_grid('mygroups', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
  466. }
  467. }
  468. if (!empty($create_group_item)) {
  469. echo Display::div($create_group_item, array('style'=>'padding-top:12px;height:30px'));
  470. }
  471. $headers = array(get_lang('MyGroups'), get_lang('Newest'), get_lang('Popular'));
  472. echo Display::tabs($headers, array($my_group_content, $newest_content, $popular_content),'tab_browse');
  473. }
  474. echo '</div>';
  475. echo '</div>';
  476. Display :: display_footer();