Dokeos PHP Cross Reference Learning Management Systems

Source: /main/inc/lib/group_portal_manager.lib.php - 1039 lines - 41354 bytes - Summary - Text - Print

Description: This library provides functions for the group management. Include/require it in your code to use its functionality.

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

title

Description

title

Description

title

Description

title

title

Body