group_portal_manager.lib.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This library provides functions for the group management.
  5. * Include/require it in your code to use its functionality.
  6. * @author Julio Montoya <gugli100@gmail.com>
  7. * @package chamilo.library
  8. */
  9. // Group permissions
  10. define('GROUP_PERMISSION_OPEN' , '1');
  11. define('GROUP_PERMISSION_CLOSED', '2');
  12. // Group user permissions
  13. define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group
  14. define('GROUP_USER_PERMISSION_READER' ,'2'); // a normal user
  15. define('GROUP_USER_PERMISSION_PENDING_INVITATION' ,'3'); // When an admin/moderator invites a user
  16. define('GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER' ,'4'); // an user joins a group
  17. define('GROUP_USER_PERMISSION_MODERATOR' ,'5'); // a moderator
  18. define('GROUP_USER_PERMISSION_ANONYMOUS' ,'6'); // an anonymous user
  19. define('GROUP_IMAGE_SIZE_ORIGINAL', 1);
  20. define('GROUP_IMAGE_SIZE_BIG', 2);
  21. define('GROUP_IMAGE_SIZE_MEDIUM', 3);
  22. define('GROUP_IMAGE_SIZE_SMALL', 4);
  23. class GroupPortalManager
  24. {
  25. /**
  26. * Creates a new group
  27. *
  28. * @author Julio Montoya <gugli100@gmail.com>,
  29. *
  30. * @param string The URL of the site
  31. * @param string The description of the site
  32. * @param int is active or not
  33. * @param int the user_id of the owner
  34. * @return boolean if success
  35. */
  36. public static function add($name, $description, $url, $visibility, $picture='')
  37. {
  38. $tms = time();
  39. $table = Database :: get_main_table(TABLE_MAIN_GROUP);
  40. $sql = "INSERT INTO $table
  41. SET name = '".Database::escape_string($name)."',
  42. description = '".Database::escape_string($description)."',
  43. picture_uri = '".Database::escape_string($picture)."',
  44. url = '".Database::escape_string($url)."',
  45. visibility = '".Database::escape_string($visibility)."',
  46. created_on = FROM_UNIXTIME(".$tms."),
  47. updated_on = FROM_UNIXTIME(".$tms.")";
  48. $result = Database::query($sql);
  49. $return = Database::insert_id();
  50. return $return;
  51. }
  52. /**
  53. * Updates a group
  54. * @author Julio Montoya <gugli100@gmail.com>,
  55. *
  56. * @param int The id
  57. * @param string The description of the site
  58. * @param int is active or not
  59. * @param int the user_id of the owner
  60. * @return boolean if success
  61. */
  62. public static function update($group_id, $name, $description, $url, $visibility, $picture_uri)
  63. {
  64. $group_id = intval($group_id);
  65. $table = Database::get_main_table(TABLE_MAIN_GROUP);
  66. $tms = time();
  67. $sql = "UPDATE $table
  68. SET name = '".Database::escape_string($name)."',
  69. description = '".Database::escape_string($description)."',
  70. picture_uri = '".Database::escape_string($picture_uri)."',
  71. url = '".Database::escape_string($url)."',
  72. visibility = '".Database::escape_string($visibility)."',
  73. updated_on = FROM_UNIXTIME(".$tms.")
  74. WHERE id = '$group_id'";
  75. $result = Database::query($sql);
  76. return $result;
  77. }
  78. /**
  79. * Deletes a group
  80. * @author Julio Montoya
  81. * @param int id
  82. * @return boolean true if success
  83. * */
  84. public static function delete($id)
  85. {
  86. $id = intval($id);
  87. $table = Database :: get_main_table(TABLE_MAIN_GROUP);
  88. $sql= "DELETE FROM $table WHERE id = ".Database::escape_string($id);
  89. $result = Database::query($sql);
  90. //deleting all relationship with users and groups
  91. self::delete_users($id);
  92. // delete group image
  93. self::delete_group_picture($id);
  94. return $result;
  95. }
  96. /**
  97. * Gets data of all groups
  98. * @author Julio Montoya
  99. * @param int visibility
  100. * @param int from which record the results will begin (use for pagination)
  101. * @param int number of items
  102. * @return array
  103. * */
  104. public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
  105. {
  106. $table = Database :: get_main_table(TABLE_MAIN_GROUP);
  107. $visibility = intval($visibility);
  108. $user_condition = '';
  109. $sql = "SELECT name, description, picture_uri FROM $table WHERE visibility = $visibility ";
  110. $res = Database::query($sql);
  111. $data = array ();
  112. while ($item = Database::fetch_array($res)) {
  113. $data[] = $item;
  114. }
  115. return $data;
  116. }
  117. /**
  118. * Gets the group data
  119. *
  120. *
  121. */
  122. public static function get_group_data($group_id)
  123. {
  124. $table = Database :: get_main_table(TABLE_MAIN_GROUP);
  125. $group_id = intval($group_id);
  126. $user_condition = '';
  127. $sql = "SELECT id, name, description, picture_uri, url, visibility FROM $table WHERE id = $group_id ";
  128. $res = Database::query($sql);
  129. $item = array();
  130. if (Database::num_rows($res)>0) {
  131. $item = Database::fetch_array($res,'ASSOC');
  132. }
  133. return $item;
  134. }
  135. /**
  136. * Gets the tags from a given group
  137. * @param int group id
  138. * @param bool show group links or not
  139. *
  140. */
  141. public static function get_group_tags($group_id, $show_tag_links = true)
  142. {
  143. $tag = Database :: get_main_table(TABLE_MAIN_TAG);
  144. $table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG);
  145. $group_id = intval($group_id);
  146. $user_condition = '';
  147. $sql = "SELECT tag FROM $tag t INNER JOIN $table_group_rel_tag gt ON (gt.tag_id= t.id) WHERE gt.group_id = $group_id ";
  148. $res = Database::query($sql);
  149. $tags = array();
  150. if (Database::num_rows($res)>0) {
  151. while ($row = Database::fetch_array($res,'ASSOC')) {
  152. $tags[] = $row;
  153. }
  154. }
  155. if ($show_tag_links == true) {
  156. if (is_array($tags) && count($tags)>0) {
  157. foreach ($tags as $tag) {
  158. $tag_tmp[] = '<a href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tag['tag'].'">'.$tag['tag'].'</a>';
  159. }
  160. if (is_array($tags) && count($tags)>0) {
  161. $tags= implode(', ',$tag_tmp);
  162. }
  163. } else {
  164. $tags = '';
  165. }
  166. }
  167. return $tags;
  168. }
  169. /** Gets the inner join from users and group table
  170. * @return int access url id
  171. * @return array Database::store_result of the result
  172. * @author Julio Montoya
  173. * */
  174. public static function get_groups_by_user($user_id='', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
  175. {
  176. $where = '';
  177. $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
  178. $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
  179. $user_id = intval($user_id);
  180. if ($relation_type == 0) {
  181. $where_relation_condition = '';
  182. } else {
  183. $relation_type = intval($relation_type);
  184. $where_relation_condition = "AND gu.relation_type = $relation_type ";
  185. }
  186. $sql = "SELECT g.picture_uri, g.name, g.description, g.id , gu.relation_type
  187. FROM $tbl_group g
  188. INNER JOIN $table_group_rel_user gu
  189. ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ORDER BY created_on desc ";
  190. $result=Database::query($sql);
  191. $array = array();
  192. if (Database::num_rows($result) > 0) {
  193. while ($row = Database::fetch_array($result, 'ASSOC')) {
  194. if ($with_image == true) {
  195. $picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
  196. $img = '<img src="'.$picture['file'].'" />';
  197. $row['picture_uri'] = $img;
  198. }
  199. $array[$row['id']] = $row;
  200. }
  201. }
  202. return $array;
  203. }
  204. /** Gets the inner join of users and group table
  205. * @return int quantity of records
  206. * @return bool show groups with image or not
  207. * @return array with group content
  208. * @author Julio Montoya
  209. * */
  210. public static function get_groups_by_popularity($num = 6, $with_image = true)
  211. {
  212. $where = '';
  213. $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
  214. $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
  215. if (empty($num)) {
  216. $num = 6;
  217. } else {
  218. $num = intval($num);
  219. }
  220. // only show admins and readers
  221. $where_relation_condition = " WHERE gu.relation_type IN ('".GROUP_USER_PERMISSION_ADMIN."' , '".GROUP_USER_PERMISSION_READER."') ";
  222. $sql = "SELECT count(user_id) as count, g.picture_uri, g.name, g.description, g.id
  223. FROM $tbl_group g
  224. INNER JOIN $table_group_rel_user gu
  225. ON gu.group_id = g.id $where_relation_condition GROUP BY g.id ORDER BY count DESC LIMIT $num";
  226. $result=Database::query($sql);
  227. $array = array();
  228. while ($row = Database::fetch_array($result, 'ASSOC')) {
  229. if ($with_image == true) {
  230. $picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
  231. $img = '<img src="'.$picture['file'].'" />';
  232. $row['picture_uri'] = $img;
  233. }
  234. $array[$row['id']] = $row;
  235. }
  236. return $array;
  237. }
  238. /** Gets the last groups created
  239. * @return int quantity of records
  240. * @return bool show groups with image or not
  241. * @return array with group content
  242. * @author Julio Montoya
  243. * */
  244. public static function get_groups_by_age($num = 6, $with_image = true)
  245. {
  246. $where = '';
  247. $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
  248. $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
  249. if (empty($num)) {
  250. $num = 6;
  251. } else {
  252. $num = intval($num);
  253. }
  254. $sql = "SELECT g.picture_uri, g.name, g.description, g.id
  255. FROM $tbl_group g
  256. ORDER BY created_on desc LIMIT $num ";
  257. $result=Database::query($sql);
  258. $array = array();
  259. while ($row = Database::fetch_array($result, 'ASSOC')) {
  260. if ($with_image == true) {
  261. $picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
  262. $img = '<img src="'.$picture['file'].'" />';
  263. $row['picture_uri'] = $img;
  264. }
  265. $array[$row['id']] = $row;
  266. }
  267. return $array;
  268. }
  269. /**
  270. * Gets the group's members
  271. */
  272. public static function get_users_by_group($group_id, $with_image = false, $relation_type = array(), $from = 0, $limit = 15, $image_conf = array('size'=>USER_IMAGE_SIZE_MEDIUM,'height'=>80))
  273. {
  274. $where = '';
  275. $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
  276. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  277. $group_id = intval($group_id);
  278. $from = intval($from);
  279. $limit = intval($limit);
  280. if (empty($group_id)){
  281. return array();
  282. }
  283. if (empty($limit)) {
  284. $limit = 15;
  285. }
  286. if (empty($from)) {
  287. $from = 0;
  288. }
  289. if (count($relation_type) == 0) {
  290. $where_relation_condition = '';
  291. } else {
  292. $new_relation_type = array();
  293. foreach($relation_type as $rel) {
  294. $rel = intval($rel);
  295. $new_relation_type[] ="'$rel'";
  296. }
  297. $relation_type = implode(',', $new_relation_type);
  298. $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
  299. }
  300. $sql="SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u
  301. INNER JOIN $table_group_rel_user gu
  302. ON (gu.user_id = u.user_id) WHERE gu.group_id= $group_id $where_relation_condition ORDER BY relation_type, firstname LIMIT $from, $limit";
  303. $result=Database::query($sql);
  304. $array = array();
  305. while ($row = Database::fetch_array($result, 'ASSOC')) {
  306. if ($with_image == true) {
  307. $image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true);
  308. $picture = UserManager::get_picture_user($row['user_id'], $image_path['file'],$image_conf['height'],$image_conf['size']);
  309. $row['image'] = '<img src="'.$picture['file'].'" '.$picture['style'].' />';
  310. }
  311. $array[$row['user_id']] = $row;
  312. }
  313. return $array;
  314. }
  315. /**
  316. * Gets all the members of a group no matter the relationship for more specifications use get_users_by_group
  317. * @param int group id
  318. * @return array
  319. */
  320. public static function get_all_users_by_group($group_id)
  321. {
  322. $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
  323. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  324. $group_id = intval($group_id);
  325. if (empty($group_id)){
  326. return array();
  327. }
  328. $sql="SELECT u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u
  329. INNER JOIN $table_group_rel_user gu
  330. ON (gu.user_id = u.user_id) WHERE gu.group_id= $group_id ORDER BY relation_type, firstname";
  331. $result=Database::query($sql);
  332. $array = array();
  333. while ($row = Database::fetch_array($result, 'ASSOC')) {
  334. $array[$row['user_id']] = $row;
  335. }
  336. return $array;
  337. }
  338. /**
  339. * Gets the relationship between a group and a User
  340. * @author Julio Montoya
  341. * @param int user id
  342. * @param int group_id
  343. * @return int 0 if there are not relationship otherwise returns the user group
  344. * */
  345. public static function get_user_group_role($user_id, $group_id)
  346. {
  347. $table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  348. $return_value = 0;
  349. if (!empty($user_id) && !empty($group_id)) {
  350. $sql = "SELECT relation_type FROM $table_group_rel_user WHERE group_id = ".intval($group_id)." AND user_id = ".intval($user_id)." ";
  351. $result = Database::query($sql);
  352. if (Database::num_rows($result)>0) {
  353. $row = Database::fetch_array($result,'ASSOC');
  354. $return_value = $row['relation_type'];
  355. }
  356. }
  357. return $return_value;
  358. }
  359. /**
  360. * Add a user into a group
  361. * @author Julio Montoya
  362. * @param user_id
  363. * @param url_id
  364. * @return boolean true if success
  365. * */
  366. public static function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
  367. {
  368. $table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  369. if (!empty($user_id) && !empty($group_id)) {
  370. $role = self::get_user_group_role($user_id,$group_id);
  371. if ($role == 0) {
  372. $sql = "INSERT INTO $table_url_rel_group
  373. SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type);
  374. $result = Database::query($sql);
  375. } elseif($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
  376. //if somebody already invited me I can be added
  377. self::update_user_role($user_id, $group_id, GROUP_USER_PERMISSION_READER);
  378. }
  379. }
  380. return $result;
  381. }
  382. /**
  383. * Add a group of users into a group of URLs
  384. * @author Julio Montoya
  385. * @param array of user_ids
  386. * @param array of url_ids
  387. * */
  388. public static function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER) {
  389. $table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  390. $result_array = array();
  391. $relation_type = intval($relation_type);
  392. if (is_array($user_list) && is_array($group_list)) {
  393. foreach ($group_list as $group_id) {
  394. foreach ($user_list as $user_id) {
  395. $role = self::get_user_group_role($user_id,$group_id);
  396. if ($role == 0) {
  397. $sql = "INSERT INTO $table_url_rel_group
  398. SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type);
  399. $result = Database::query($sql);
  400. if ($result)
  401. $result_array[$group_id][$user_id]=1;
  402. else
  403. $result_array[$group_id][$user_id]=0;
  404. }
  405. }
  406. }
  407. }
  408. return $result_array;
  409. }
  410. /**
  411. * Deletes a group and user relationship
  412. * @author Julio Montoya
  413. * @param int user id
  414. * @param int relation type (optional)
  415. * @return boolean true if success
  416. * */
  417. public static function delete_users($group_id,$relation_type='')
  418. {
  419. $table_ = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  420. $condition_relation = "";
  421. if (!empty($relation_type)) {
  422. $relation_type = intval($relation_type);
  423. $condition_relation = " AND relation_type = '$relation_type'";
  424. }
  425. $sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id).$condition_relation;
  426. $result = Database::query($sql);
  427. return $result;
  428. }
  429. /**
  430. * Deletes an url and session relationship
  431. * @author Julio Montoya
  432. * @param char course code
  433. * @param int url id
  434. * @return boolean true if success
  435. * */
  436. public static function delete_user_rel_group($user_id, $group_id)
  437. {
  438. $table = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  439. $sql= "DELETE FROM $table WHERE user_id = ".intval($user_id)." AND group_id=".intval($group_id)." ";
  440. $result = Database::query($sql);
  441. return $result;
  442. }
  443. /**
  444. * Updates the group_rel_user table with a given user and group ids
  445. * @author Julio Montoya
  446. * @param int user id
  447. * @param int group id
  448. * @param int relation type
  449. * */
  450. public static function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
  451. {
  452. $table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  453. $group_id = intval($group_id);
  454. $user_id = intval($user_id);
  455. $sql = "UPDATE $table_group_rel_user
  456. SET relation_type = ".intval($relation_type)." WHERE user_id = $user_id AND group_id = $group_id" ;
  457. $result = Database::query($sql);
  458. }
  459. public static function get_group_admin_list($user_id, $group_id)
  460. {
  461. $table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
  462. $group_id = intval($group_id);
  463. $user_id = intval($user_id);
  464. $sql = "SELECT user_id FROM $table_group_rel_user WHERE
  465. relation_type = ".GROUP_USER_PERMISSION_ADMIN." AND user_id = $user_id AND group_id = $group_id" ;
  466. $result = Database::query($sql);
  467. }
  468. public static function get_all_group_tags($tag, $from=0, $number_of_items=10) {
  469. // database table definition
  470. $group_table = Database::get_main_table(TABLE_MAIN_GROUP);
  471. $table_tag = Database::get_main_table(TABLE_MAIN_TAG);
  472. $table_group_tag_values = Database::get_main_table(TABLE_MAIN_GROUP_REL_TAG);
  473. //default field_id == 1
  474. $field_id = 5;
  475. $tag = Database::escape_string($tag);
  476. $from = intval($from);
  477. $number_of_items = intval($number_of_items);
  478. // all the information of the field
  479. $sql = "SELECT g.id, g.name, g.description, g.picture_uri FROM $table_tag t INNER JOIN $table_group_tag_values tv ON (tv.tag_id=t.id)
  480. INNER JOIN $group_table g ON(tv.group_id =g.id)
  481. WHERE tag LIKE '$tag%' AND field_id= $field_id ORDER BY tag";
  482. $sql .= " LIMIT $from,$number_of_items";
  483. $result = Database::query($sql);
  484. $return = array();
  485. if (Database::num_rows($result)> 0) {
  486. while ($row = Database::fetch_array($result,'ASSOC')) {
  487. $return[$row['id']] = $row;
  488. }
  489. }
  490. $keyword = $tag;
  491. $sql = "SELECT g.id, g.name, g.description, g.url, g.picture_uri FROM $group_table g";
  492. //@todo implement groups + multiple urls
  493. /*
  494. global $_configuration;
  495. if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
  496. $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
  497. $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
  498. }*/
  499. //@todo implement visibility
  500. if (isset ($keyword)) {
  501. $keyword = Database::escape_string($keyword);
  502. $sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%' OR g.url LIKE '%".$keyword."%' )";
  503. }
  504. $direction = 'ASC';
  505. if (!in_array($direction, array('ASC','DESC'))) {
  506. $direction = 'ASC';
  507. }
  508. $column = intval($column);
  509. $from = intval($from);
  510. $number_of_items = intval($number_of_items);
  511. //$sql .= " ORDER BY col$column $direction ";
  512. $sql .= " LIMIT $from,$number_of_items";
  513. $res = Database::query($sql);
  514. if (Database::num_rows($res)> 0) {
  515. while ($row = Database::fetch_array($res,'ASSOC')) {
  516. if (!in_array($row['id'], $return)) {
  517. $return[$row['id']] = $row;
  518. }
  519. }
  520. }
  521. return $return;
  522. }
  523. /**
  524. * Creates new group pictures in various sizes of a user, or deletes user pfotos.
  525. * Note: This method relies on configuration setting from dokeos/main/inc/conf/profile.conf.php
  526. * @param int The group id
  527. * @param string $file The common file name for the newly created pfotos. It will be checked and modified for compatibility with the file system.
  528. * If full name is provided, path component is ignored.
  529. * If an empty name is provided, then old user photos are deleted only, @see UserManager::delete_user_picture() as the prefered way for deletion.
  530. * @param string $source_file The full system name of the image from which user photos will be created.
  531. * @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
  532. * When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
  533. */
  534. public static function update_group_picture($group_id, $file = null, $source_file = null) {
  535. // Validation 1.
  536. if (empty($group_id)) {
  537. return false;
  538. }
  539. $delete = empty($file);
  540. if (empty($source_file)) {
  541. $source_file = $file;
  542. }
  543. // Configuration options about user photos.
  544. require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
  545. // User-reserved directory where photos have to be placed.
  546. $path_info = self::get_group_picture_path_by_id($group_id, 'system', true);
  547. $path = $path_info['dir'];
  548. // If this directory does not exist - we create it.
  549. if (!file_exists($path)) {
  550. @mkdir($path, api_get_permissions_for_new_directories(), true);
  551. }
  552. // The old photos (if any).
  553. $old_file = $path_info['file'];
  554. // Let us delete them.
  555. if (!empty($old_file)) {
  556. if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE) {
  557. $prefix = 'saved_'.date('Y_m_d_H_i_s').'_'.uniqid('').'_';
  558. @rename($path.'small_'.$old_file, $path.$prefix.'small_'.$old_file);
  559. @rename($path.'medium_'.$old_file, $path.$prefix.'medium_'.$old_file);
  560. @rename($path.'big_'.$old_file, $path.$prefix.'big_'.$old_file);
  561. @rename($path.$old_file, $path.$prefix.$old_file);
  562. } else {
  563. @unlink($path.'small_'.$old_file);
  564. @unlink($path.'medium_'.$old_file);
  565. @unlink($path.'big_'.$old_file);
  566. @unlink($path.$old_file);
  567. }
  568. }
  569. // Exit if only deletion has been requested. Return an empty picture name.
  570. if ($delete) {
  571. return '';
  572. }
  573. // Validation 2.
  574. $allowed_types = array('jpg', 'jpeg', 'png', 'gif');
  575. $file = str_replace('\\', '/', $file);
  576. $filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file;
  577. $extension = strtolower(substr(strrchr($filename, '.'), 1));
  578. if (!in_array($extension, $allowed_types)) {
  579. return false;
  580. }
  581. // This is the common name for the new photos.
  582. if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
  583. $old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
  584. $filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
  585. $filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
  586. } else {
  587. $filename = replace_dangerous_char($filename);
  588. if (PREFIX_IMAGE_FILENAME_WITH_UID) {
  589. $filename = uniqid('').'_'.$filename;
  590. }
  591. // We always prefix user photos with user ids, so on setting
  592. // api_get_setting('split_users_upload_directory') === 'true'
  593. // the correspondent directories to be found successfully.
  594. $filename = $group_id.'_'.$filename;
  595. }
  596. // Storing the new photos in 4 versions with various sizes.
  597. $picture_info = @getimagesize($source_file);
  598. $type = $picture_info[2];
  599. $small = self::resize_picture($source_file, 22);
  600. $medium = self::resize_picture($source_file, 85);
  601. $normal = self::resize_picture($source_file, 200);
  602. $big = new image($source_file); // This is the original picture.
  603. $ok = false;
  604. $detected = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG');
  605. if (in_array($type, array_keys($detected))) {
  606. $ok = $small->send_image($detected[$type], $path.'small_'.$filename)
  607. && $medium->send_image($detected[$type], $path.'medium_'.$filename)
  608. && $normal->send_image($detected[$type], $path.'big_'.$filename)
  609. && $big->send_image($detected[$type], $path.$filename);
  610. }
  611. return $ok ? $filename : false;
  612. }
  613. /**
  614. * Gets the group picture URL or path from group ID (returns an array).
  615. * The return format is a complete path, enabling recovery of the directory
  616. * with dirname() or the file with basename(). This also works for the
  617. * functions dealing with the user's productions, as they are located in
  618. * the same directory.
  619. * @param integer User ID
  620. * @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
  621. * @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
  622. * @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
  623. * @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
  624. */
  625. public static function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false) {
  626. switch ($type) {
  627. case 'system': // Base: absolute system path.
  628. $base = api_get_path(SYS_CODE_PATH);
  629. break;
  630. case 'rel': // Base: semi-absolute web path (no server base).
  631. $base = api_get_path(REL_CODE_PATH);
  632. break;
  633. case 'web': // Base: absolute web path.
  634. $base = api_get_path(WEB_CODE_PATH);
  635. break;
  636. case 'none':
  637. default: // Base: empty, the result path below will be relative.
  638. $base = '';
  639. }
  640. if (empty($id) || empty($type)) {
  641. return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
  642. }
  643. $id = intval($id);
  644. $group_table = Database :: get_main_table(TABLE_MAIN_GROUP);
  645. $sql = "SELECT picture_uri FROM $group_table WHERE id=".$id;
  646. $res = Database::query($sql);
  647. if (!Database::num_rows($res)) {
  648. return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
  649. }
  650. $user = Database::fetch_array($res);
  651. $picture_filename = trim($user['picture_uri']);
  652. if (api_get_setting('split_users_upload_directory') === 'true') {
  653. if (!empty($picture_filename)) {
  654. $dir = $base.'upload/users/groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
  655. } elseif ($preview) {
  656. $dir = $base.'upload/users/groups/'.substr((string)$id, 0, 1).'/'.$id.'/';
  657. } else {
  658. $dir = $base.'upload/users/groups/'.$id.'/';
  659. }
  660. } else {
  661. $dir = $base.'upload/users/groups/'.$id.'/';
  662. }
  663. if (empty($picture_filename) && $anonymous) {
  664. return array('dir' => $base.'img/', 'file' => 'unknown.jpg');
  665. }
  666. return array('dir' => $dir, 'file' => $picture_filename);
  667. }
  668. /**
  669. * Resize a picture
  670. *
  671. * @param string file picture
  672. * @param int size in pixels
  673. * @return obj image object
  674. */
  675. public static function resize_picture($file, $max_size_for_picture) {
  676. if (!class_exists('image')) {
  677. require_once api_get_path(LIBRARY_PATH).'image.lib.php';
  678. }
  679. $temp = new image($file);
  680. $picture_infos = api_getimagesize($file);
  681. if ($picture_infos[0] > $max_size_for_picture) {
  682. $thumbwidth = $max_size_for_picture;
  683. if (empty($thumbwidth) or $thumbwidth == 0) {
  684. $thumbwidth = $max_size_for_picture;
  685. }
  686. $new_height = round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]);
  687. if ($new_height > $max_size_for_picture)
  688. $new_height = $thumbwidth;
  689. $temp->resize($thumbwidth, $new_height, 0);
  690. }
  691. return $temp;
  692. }
  693. /**
  694. * Gets the current group image
  695. * @param string group id
  696. * @param string picture group name
  697. * @param string height
  698. * @param string picture size it can be small_, medium_ or big_
  699. * @param string style css
  700. * @return array with the file and the style of an image i.e $array['file'] $array['style']
  701. */
  702. public static function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') {
  703. $patch_profile = 'upload/users/groups/';
  704. $picture = array();
  705. $picture['style'] = $style;
  706. if ($picture_file == 'unknown.jpg') {
  707. $picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
  708. return $picture;
  709. }
  710. switch ($size_picture) {
  711. case GROUP_IMAGE_SIZE_ORIGINAL :
  712. $size_picture = '';
  713. break;
  714. case GROUP_IMAGE_SIZE_BIG :
  715. $size_picture = 'big_';
  716. break;
  717. case GROUP_IMAGE_SIZE_MEDIUM :
  718. $size_picture = 'medium_';
  719. break;
  720. case GROUP_IMAGE_SIZE_SMALL :
  721. $size_picture = 'small_';
  722. break;
  723. default:
  724. $size_picture = 'medium_';
  725. }
  726. $image_array_sys = self::get_group_picture_path_by_id($id, 'system', false, true);
  727. $image_array = self::get_group_picture_path_by_id($id, 'web', false, true);
  728. $file = $image_array_sys['dir'].$size_picture.$picture_file;
  729. if (file_exists($file)) {
  730. $picture['file'] = $image_array['dir'].$size_picture.$picture_file;
  731. $picture['style'] = '';
  732. if ($height > 0) {
  733. $dimension = api_getimagesize($picture['file']);
  734. $margin = (($height - $dimension[1]) / 2);
  735. //@ todo the padding-top should not be here
  736. $picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension[0].'px; height:'.$dimension[1].';" ';
  737. }
  738. } else {
  739. //$file = api_get_path(SYS_CODE_PATH).$patch_profile.$user_id.'/'.$picture_file;
  740. $file = $image_array_sys['dir'].$picture_file;
  741. if (file_exists($file) && !is_dir($file)) {
  742. $picture['file'] = $image_array['dir'].$picture_file;
  743. } else {
  744. $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_group.png';
  745. }
  746. }
  747. return $picture;
  748. }
  749. public static function delete_group_picture($group_id) {
  750. return self::update_group_picture($group_id);
  751. }
  752. public static function is_group_admin($group_id, $user_id = 0) {
  753. if (empty($user_id)) {
  754. $user_id = api_get_user_id();
  755. }
  756. $user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
  757. if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
  758. return true;
  759. } else {
  760. return false;
  761. }
  762. }
  763. public static function is_group_moderator($group_id, $user_id = 0) {
  764. if (empty($user_id)) {
  765. $user_id = api_get_user_id();
  766. }
  767. $user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
  768. if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
  769. return true;
  770. } else {
  771. return false;
  772. }
  773. }
  774. public static function is_group_member($group_id, $user_id = 0) {
  775. if (empty($user_id)) {
  776. $user_id = api_get_user_id();
  777. }
  778. $user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
  779. if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR, GROUP_USER_PERMISSION_READER))) {
  780. return true;
  781. } else {
  782. return false;
  783. }
  784. }
  785. /**
  786. * Shows the left column of the group page
  787. * @param int group id
  788. * @param int user id
  789. *
  790. */
  791. public static function show_group_column_information($group_id, $user_id, $show = '') {
  792. global $relation_group_title, $my_group_role;
  793. $group_info = GroupPortalManager::get_group_data($group_id);
  794. $picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_MEDIUM);
  795. $big_image = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_BIG);
  796. $tags = GroupPortalManager::get_group_tags($group_id, true);
  797. $members = GroupPortalManager::get_users_by_group($group_id);
  798. $groups_by_user = GroupPortalManager::get_groups_by_user($user_id, 0);
  799. //my relation with the group is set here
  800. $my_group_role = self::get_user_group_role($user_id, $group_id);
  801. //@todo this must be move to default.css for dev use only
  802. echo '<style>
  803. #group_members { width:270px; height:300px; overflow-x:none; overflow-y: auto;}
  804. .group_member_item { width:100px; height:130px; float:left; margin:5px 5px 15px 5px; }
  805. .group_member_picture { display:block;
  806. margin:0;
  807. overflow:hidden; };
  808. </style>';
  809. //Loading group permission
  810. $links = '';
  811. switch ($my_group_role) {
  812. case GROUP_USER_PERMISSION_READER:
  813. // I'm just a reader
  814. $relation_group_title = get_lang('IamAReader');
  815. $links .= '<li><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('NewTopic').'</span></a></li>';
  816. $links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
  817. $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
  818. $links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
  819. $links .= '<li><a href="groups.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
  820. break;
  821. case GROUP_USER_PERMISSION_ADMIN:
  822. $relation_group_title = get_lang('IamAnAdmin');
  823. $links .= '<li><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('NewTopic').'</span></a></li>';
  824. $links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
  825. $links .= '<li><a href="group_edit.php?id='.$group_id.'">'. Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show=='group_edit'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>';
  826. $links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
  827. //if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
  828. $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
  829. //}
  830. $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
  831. break;
  832. case GROUP_USER_PERMISSION_PENDING_INVITATION:
  833. // $links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>';
  834. break;
  835. case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
  836. $relation_group_title = get_lang('WaitingForAdminResponse');
  837. break;
  838. case GROUP_USER_PERMISSION_MODERATOR:
  839. $relation_group_title = get_lang('IamAModerator');
  840. $links .= '<li><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('NewTopic').'</span></a></li>';
  841. $links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
  842. $links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
  843. if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
  844. $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
  845. }
  846. $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
  847. break;
  848. default:
  849. //$links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
  850. break;
  851. }
  852. if (!empty($links)) {
  853. echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.cut($group_info['name'],40,true).'</span></div>';
  854. echo '<ul class="social-menu-groups">';
  855. echo $links;
  856. echo '</ul>';
  857. }
  858. //Members
  859. if (count($members) > 0) {
  860. echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.get_lang('Members').'</span></div>';
  861. echo '<div align="center">';
  862. $min_count_members = 4;
  863. $i = 1;
  864. foreach($members as $member) {
  865. if ($i > $min_count_members) break;
  866. // if is a member
  867. if (in_array($member['relation_type'] , array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) {
  868. //add icons
  869. if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  870. $icon= Display::return_icon('admin_star.png', get_lang('Admin'));
  871. }elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  872. $icon= Display::return_icon('moderator_star.png', get_lang('Moderator'));
  873. } else{
  874. $icon= '';
  875. }
  876. $image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
  877. $picture = UserManager::get_picture_user($member['user_id'], $image_path['file'], 60, USER_IMAGE_SIZE_MEDIUM);
  878. echo '<div class="social-menu-group-member">';
  879. echo '<a href="profile.php?u='.$member['user_id'].'">';
  880. echo '<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>';
  881. echo '<div>'.api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).'&nbsp;'.$icon.'</div></a>';
  882. echo '</div>';
  883. $i++;
  884. }
  885. }
  886. if (count($members) > $min_count_members) {
  887. //More link
  888. echo '<div class="group_member_more" style="margin-top:20px;"><a href="group_members.php?id='.$group_id.'">'.get_lang('SeeMore').'</a></div>';
  889. }
  890. echo '</div>';
  891. echo '<div class="clear"></div>';
  892. echo '<br />';
  893. }
  894. /*
  895. // my other groups
  896. if (count($groups_by_user) > 1) {
  897. echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.get_lang('MyOtherGroups').'</span></div>';
  898. echo '<div align="center">';
  899. $min_count_groups = 4;
  900. $i = 1;
  901. $more_link = false;
  902. foreach($groups_by_user as $group) {
  903. if ($group['id'] == $group_id) continue;
  904. if ($i > $min_count_groups) {
  905. $more_link = true;
  906. break;
  907. }
  908. $picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80);
  909. echo '<a href="groups.php?id='.$group['id'].'">';
  910. echo '<img height="44" border="2" align="middle" width="44" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>';
  911. echo '<div>'.cut($group['name'],50,true).'</div></a>';
  912. $i++;
  913. }
  914. if ($more_link) {
  915. //More link
  916. echo '<div class="mygroups_more" style="margin-top:20px;"><a href="groups.php?view=mygroups">'.get_lang('SeeMore').'</a></div>';
  917. }
  918. echo '</div>';
  919. }
  920. */
  921. }
  922. }
  923. ?>