group_portal_manager.lib.php 41 KB

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