jmontoyaa пре 8 година
родитељ
комит
2b02a1bc7f

+ 1 - 1
main/inc/lib/CourseChatUtils.php

@@ -43,7 +43,7 @@ class CourseChatUtils
         $course = $em->find('ChamiloCoreBundle:Course', $this->courseId);
 
         if ($this->sessionId) {
-            $criteria = Criteria::create()->where(Criteria::expr()->eq("course", $course));
+            $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course));
 
             return $em
                 ->find('ChamiloCoreBundle:Session', $this->sessionId)

+ 0 - 1
main/inc/lib/CoursesAndSessionsCatalog.class.php

@@ -6,7 +6,6 @@
  */
 class CoursesAndSessionsCatalog
 {
-
     /**
      * Check the configuration for the courses and sessions catalog
      * @global array $_configuration Configuration

+ 0 - 1
main/inc/lib/GamificationUtils.php

@@ -25,7 +25,6 @@ class GamificationUtils
         );
 
         if (empty($sessions)) {
-
             return 0;
         }
 

+ 0 - 2
main/inc/lib/VideoChat.php

@@ -10,7 +10,6 @@
  */
 class VideoChat
 {
-
     /**
      * Get the video chat info by its users
      * @param int $user1 User id
@@ -89,5 +88,4 @@ class VideoChat
 
         return false;
     }
-
 }

+ 6 - 1
main/inc/lib/fileUpload.lib.php

@@ -2077,7 +2077,12 @@ function add_all_documents_in_folder_to_database(
                 if ($folderExists === true) {
                     $documentId = DocumentManager::get_document_id($courseInfo, $completePath, $sessionId);
                     if ($documentId) {
-                        $newFolderData = DocumentManager::get_document_data_by_id($documentId, $courseInfo, false, $sessionId);
+                        $newFolderData = DocumentManager::get_document_data_by_id(
+                            $documentId,
+                            $courseInfo,
+                            false,
+                            $sessionId
+                        );
                     }
                 } else {
                     $newFolderData = create_unexisting_directory(

+ 0 - 3
main/inc/lib/internationalization.lib.php

@@ -458,8 +458,6 @@ function api_get_local_time(
         $from_timezone = 'UTC';
     }
 
-
-
     try {
         $date = new DateTime($time, new DateTimezone($from_timezone));
         $date->setTimezone(new DateTimeZone($to_timezone));
@@ -664,7 +662,6 @@ function api_format_date($time, $format = null, $language = null)
 function date_to_str_ago($date, $timeZone = 'UTC')
 {
     if ($date === '0000-00-00 00:00:00') {
-
         return '';
     }
 

+ 50 - 80
main/inc/lib/social.lib.php

@@ -504,8 +504,11 @@ class SocialManager extends UserManager
                 $image = $my_course['course_info']['course_image'];
                 $imageCourse = Display::img($image, $course_title, array('class'=>'img-course'));
             } else {
-                $imageCourse = Display::return_icon('session_default_small.png', $course_title, array('class' => 'img-course'));
-
+                $imageCourse = Display::return_icon(
+                    'session_default_small.png',
+                    $course_title,
+                    array('class' => 'img-course')
+                );
             }
         } else {
             $imageCourse = Display::return_icon('course.png', get_lang('Course'), array('class' => 'img-default'));
@@ -525,7 +528,7 @@ class SocialManager extends UserManager
         ) {
            $result .= '<span class="title">' . $course_title . '<span>';
         } else {
-            $result .= $course_title." "." ".get_lang('CourseClosed')."";
+            $result .= $course_title." ".get_lang('CourseClosed');
         }
 
         $result .= '</li>';
@@ -563,7 +566,7 @@ class SocialManager extends UserManager
             $my_course['user_course_cat'],
             $result,
             $my_course['id_session'],
-            $session,
+            $session
         );
 
         return $output;
@@ -572,7 +575,7 @@ class SocialManager extends UserManager
     /**
      * Shows the avatar block in social pages
      *
-     * @param string highlight link possible values:
+     * @param string $show highlight link possible values:
      * group_add,
      * home,
      * messages,
@@ -583,8 +586,8 @@ class SocialManager extends UserManager
      * shared_profile,
      * friends,
      * groups search
-     * @param int group id
-     * @param int user id
+     * @param int $group_id
+     * @param int $user_id
      *
      */
     public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0)
@@ -644,14 +647,13 @@ class SocialManager extends UserManager
                     'normal' => UserManager::getUserPicture(
                         $user_id,
                         USER_IMAGE_SIZE_MEDIUM
-                    ),
+                    )
                 ]
             );
         }
 
         $skillBlock = $template->get_template('social/avatar_block.tpl');
 
-
         return $template->fetch($skillBlock);
     }
 
@@ -685,18 +687,8 @@ class SocialManager extends UserManager
         if (empty($user_id)) {
             $user_id = api_get_user_id();
         }
-        $usergroup = new UserGroup();
-
-        $user_info = api_get_user_info($user_id, true);
-        $current_user_id = api_get_user_id();
-        $current_user_info = api_get_user_info($current_user_id, true);
-
-        if ($current_user_id == $user_id) {
-            $user_friend_relation = null;
-        } else {
-            $user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
-        }
 
+        $usergroup = new UserGroup();
         $show_groups = array(
             'groups',
             'group_messages',
@@ -810,17 +802,16 @@ class SocialManager extends UserManager
                 $myFiles = '';
             }
             $links .= $myFiles;
-
             $links .='</ul>';
 
             $html .= Display::panelCollapse(
-                    get_lang('SocialNetwork'),
-                    $links,
-                    'social-network-menu',
-                    null,
-                    'sn-sidebar',
-                    'sn-sidebar-collapse'
-                    );
+                get_lang('SocialNetwork'),
+                $links,
+                'social-network-menu',
+                null,
+                'sn-sidebar',
+                'sn-sidebar-collapse'
+            );
         }
 
         if (in_array($show, $show_groups) && !empty($group_id)) {
@@ -971,7 +962,10 @@ class SocialManager extends UserManager
                         );
 
                         if (!empty($content)) {
-                            $url = Display::url(Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')', api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']);
+                            $url = Display::url(
+                                Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')',
+                                api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']
+                            );
                             $announcements[] = Display::tag('li', $url);
                         }
                     }
@@ -1027,11 +1021,8 @@ class SocialManager extends UserManager
         if (api_is_anonymous()) {
             $add_row = true;
         }
-
-        $extra_params = array();
         $course_url = '';
         if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
-            $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
             $course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
         }
 
@@ -1061,7 +1052,7 @@ class SocialManager extends UserManager
             $url =  null;
             // Anonymous users can't have access to the profile
             if (!api_is_anonymous()) {
-                if (api_get_setting('allow_social_tool') == 'true') {
+                if (api_get_setting('allow_social_tool') === 'true') {
                     $url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$uid.$course_url;
                 } else {
                     $url = '?id='.$uid.$course_url;
@@ -1361,22 +1352,25 @@ class SocialManager extends UserManager
         $start = Database::escape_string($start);
         $limit = intval($limit);
 
-        $sql = "
-        SELECT
-          id,
-          user_sender_id,
-          user_receiver_id,
-          send_date,
-          content,
-          parent_id,
-          (SELECT ma.path FROM $tblMessageAttachment ma
-           WHERE  ma.message_id = tm.id ) as path,
-          (SELECT ma.filename FROM $tblMessageAttachment ma
-          WHERE  ma.message_id = tm.id ) as filename
-        FROM $tblMessage tm
-        WHERE
-            user_receiver_id = $userId AND
-            send_date > '$start'
+        $sql = "SELECT
+                    id,
+                    user_sender_id,
+                    user_receiver_id,
+                    send_date,
+                    content,
+                    parent_id,
+                    (
+                        SELECT ma.path FROM $tblMessageAttachment ma
+                        WHERE  ma.message_id = tm.id 
+                    ) as path,
+                    (
+                        SELECT ma.filename FROM $tblMessageAttachment ma 
+                        WHERE ma.message_id = tm.id 
+                    ) as filename
+                    FROM $tblMessage tm
+                WHERE
+                    user_receiver_id = $userId AND 
+                    send_date > '$start'
         ";
 
         $sql .= (empty($messageStatus) || is_null($messageStatus)) ? '' : " AND msg_status = '$messageStatus' ";
@@ -1646,33 +1640,6 @@ class SocialManager extends UserManager
         }
     }
 
-
-    /**
-     * Get full image path from a path and a size
-     * @param   string  $path
-     * @return  string
-     */
-    private static function getImagePath($path, $size = '')
-    {
-        $name = '';
-        $array = preg_split('#\/#', $path);
-        if (isset($array[2]) && !empty($array[2])) {
-
-            if ($size == IMAGE_WALL_SMALL) {
-                $name = IMAGE_WALL_SMALL. '_' . $array[2];
-            }else if($size == IMAGE_WALL_MEDIUM){
-                $name = IMAGE_WALL_MEDIUM. '_' . $array[2];
-            }else if($size == IMAGE_WALL_BIG){
-                $name = IMAGE_WALL_BIG. '_' . $array[2];
-            }else {
-                $name = IMAGE_WALL_SMALL. '_' . $array[2];
-            }
-            $lessImage = str_replace($array[2], '', $path);
-            $name = $lessImage . $name;
-        }
-
-        return $name;
-    }
     /**
     * Delete messages delete logic
     * @param int $id id message to delete.
@@ -1698,8 +1665,13 @@ class SocialManager extends UserManager
      * @param int $groupId Optional. Group ID
      * @return string The HTML code with the social block
      */
-    public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0, $show_full_profile = true)
-    {
+    public static function setSocialUserBlock(
+        Template $template,
+        $userId,
+        $groupBlock = '',
+        $groupId = 0,
+        $show_full_profile = true
+    ) {
         if (api_get_setting('allow_social_tool') != 'true') {
             return '';
         }
@@ -1937,7 +1909,6 @@ class SocialManager extends UserManager
         foreach ($messages as $message) {
             $post = $message['html'];
             $comment = SocialManager::getWallMessagesHTML($userId, $friendId, $message['id']);
-
             $html .= Display::panel($post.$comment, '');
         }
 
@@ -1956,7 +1927,6 @@ class SocialManager extends UserManager
         }
 
         $skill = new Skill();
-
         $ranking = $skill->get_user_skill_ranking($userId);
         $skills = $skill->get_user_skills($userId, true);
 

+ 35 - 21
main/inc/lib/statistics.lib.php

@@ -304,7 +304,6 @@ class Statistics
             }
 
             if (!empty($row[5])) {
-
                 //course
                 if (!empty($row[3])) {
                     $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH).'admin/course_edit.php?id='.$row[3]);
@@ -314,7 +313,10 @@ class Statistics
 
                 // session
                 if (!empty($row[4])) {
-                    $row[4] = Display::url($row[4], api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$row[4]);
+                    $row[4] = Display::url(
+                        $row[4],
+                        api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$row[4]
+                    );
                 } else {
                     $row[4] = '-';
                 }
@@ -571,7 +573,10 @@ class Statistics
         if ($distinct) {
             $field = 'DISTINCT(login_user_id)';
         }
-        $sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)";
+        $sql = "SELECT count($field) AS number, date(login_date) as login_date 
+                FROM $table $table_url 
+                WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url 
+                GROUP BY date(login_date)";
 
         $res = Database::query($sql);
         while ($row = Database::fetch_array($res,'ASSOC')){
@@ -847,16 +852,18 @@ class Statistics
                 $field = 'user_receiver_id';
                 break;
         }
+
         if (api_is_multiple_url_enabled()) {
             $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message 
-                FROM ".$access_url_rel_user_table." as url, ".$message_table." m 
-                LEFT JOIN ".$user_table." u ON m.$field = u.user_id 
+                FROM $access_url_rel_user_table as url, $message_table m 
+                LEFT JOIN $user_table u ON m.$field = u.user_id 
                 WHERE  url.user_id = m.$field AND  access_url_id='".$current_url_id."' 
-                GROUP BY m.$field ORDER BY count_message DESC ";
+                GROUP BY m.$field 
+                ORDER BY count_message DESC ";
         } else {
             $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message 
-                FROM ".$message_table." m 
-                LEFT JOIN ".$user_table." u ON m.$field = u.user_id 
+                FROM $message_table m 
+                LEFT JOIN $user_table u ON m.$field = u.user_id 
                 GROUP BY m.$field ORDER BY count_message DESC ";
         }
         $res = Database::query($sql);
@@ -885,17 +892,23 @@ class Statistics
         $current_url_id = api_get_current_access_url_id();
 
         if (api_is_multiple_url_enabled()) {
-            $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend ".
-                "FROM ".$access_url_rel_user_table." as url, ".$user_friend_table." uf ".
-                "LEFT JOIN ".$user_table." u ON uf.user_id = u.user_id ".
-                "WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND uf.user_id = url.user_id AND  access_url_id='".$current_url_id."' ".
-                "GROUP BY uf.user_id ORDER BY count_friend DESC ";
+            $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend 
+                    FROM $access_url_rel_user_table as url, $user_friend_table uf 
+                    LEFT JOIN $user_table u 
+                    ON uf.user_id = u.user_id 
+                    WHERE 
+                        uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND 
+                        uf.user_id = url.user_id AND  
+                        access_url_id = '".$current_url_id."' 
+                    GROUP BY uf.user_id 
+                    ORDER BY count_friend DESC ";
         } else {
-            $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend ".
-                "FROM ".$user_friend_table." uf ".
-                "LEFT JOIN ".$user_table." u ON uf.user_id = u.user_id ".
-                "WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' ".
-                "GROUP BY uf.user_id ORDER BY count_friend DESC ";
+            $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend 
+                    FROM $user_friend_table uf 
+                    LEFT JOIN $user_table u ON uf.user_id = u.user_id 
+                    WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' 
+                    GROUP BY uf.user_id 
+                    ORDER BY count_friend DESC ";
         }
         $res = Database::query($sql);
         $list_friends = array();
@@ -903,6 +916,7 @@ class Statistics
             $users = api_get_person_name($friends['firstname'], $friends['lastname']).'<br />('.$friends['username'].')';
             $list_friends[$users] = $friends['count_friend'];
         }
+
         return $list_friends;
     }
 
@@ -924,11 +938,11 @@ class Statistics
             $where_url='';
         }
         $now = api_get_utc_datetime();
-        $sql[get_lang('ThisDay')]    =
+        $sql[get_lang('ThisDay')] =
             "SELECT count(distinct(login_user_id)) AS number ".
             " FROM $table $table_url ".
             " WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url";
-        $sql[get_lang('Last7days')]  =
+        $sql[get_lang('Last7days')] =
             "SELECT count(distinct(login_user_id)) AS number ".
             " FROM $table $table_url ".
             " WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url";
@@ -940,7 +954,7 @@ class Statistics
             "SELECT count(distinct(login_user_id)) AS number ".
             " FROM $table $table_url ".
             " WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url";
-        $sql[get_lang('NeverConnected')]      =
+        $sql[get_lang('NeverConnected')] =
             "SELECT count(distinct(login_user_id)) AS number ".
             " FROM $table $table_url WHERE 1=1 $where_url";
         foreach ($sql as $index => $query) {

+ 13 - 11
main/inc/lib/thematic.lib.php

@@ -278,9 +278,9 @@ class Thematic
         $res = Database::query($sql);
         if (Database::num_rows($res) > 0) {
             if (!empty($thematic_id)) {
-                $data = Database::fetch_array($res,'ASSOC');
+                $data = Database::fetch_array($res, 'ASSOC');
             } else {
-                while ($row = Database::fetch_array($res,'ASSOC')) {
+                while ($row = Database::fetch_array($res, 'ASSOC')) {
                     $data[$row['id']] = $row;
                 }
             }
@@ -469,7 +469,8 @@ class Thematic
         $tbl_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
         $course_id = api_get_course_int_id();
 
-        $sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic_advance
+        $sql = "SELECT COUNT(id) AS total_number_of_items 
+                FROM $tbl_thematic_advance
                 WHERE c_id = $course_id AND thematic_id = $thematic_id ";
         $res = Database::query($sql);
         $obj = Database::fetch_object($res);
@@ -821,7 +822,7 @@ class Thematic
                 $_course,
                 'thematic_advance',
                 $thematic_advance_id,
-                "ThematicAdvanceDeleted",
+                'ThematicAdvanceDeleted',
                 $user_id
             );
         }
@@ -885,7 +886,8 @@ class Thematic
             $sql = "SELECT
                         tp.id, thematic_id, tp.title, description, description_type, t.session_id
 			        FROM $tbl_thematic_plan tp
-			        INNER JOIN $tbl_thematic t ON (t.id=tp.thematic_id)
+			        INNER JOIN $tbl_thematic t 
+			        ON (t.id=tp.thematic_id)
                     WHERE
                         t.c_id = $course_id AND
                         tp.c_id = $course_id
@@ -1071,7 +1073,7 @@ class Thematic
                 $_course,
                 'thematic_plan',
                 $thematic_plan_id,
-                "ThematicPlanDeleted",
+                'ThematicPlanDeleted',
                 $user_id
             );
         }
@@ -1097,7 +1099,7 @@ class Thematic
 		        WHERE
 		            c_id = $course_id AND
 		            thematic_id = $thematic_id AND
-		            description_type >= ".ADD_THEMATIC_PLAN." ";
+		            description_type >= ".ADD_THEMATIC_PLAN;
         $rs = Database::query($sql);
         $row = Database::fetch_array($rs);
         $last_description_type = $row['max'];
@@ -1220,6 +1222,7 @@ class Thematic
                 }
             }
         }
+
         return $affected_rows;
     }
 
@@ -1292,8 +1295,8 @@ class Thematic
 
     /**
      * Get total average of thematic advances
-     * @param	string	Course code (optional)
-     * @param	int		Session id	(optional)
+     * @param	string	$course_code (optional)
+     * @param	int		$session_id	(optional)
      * @return 	float	Average of thematic advances
      */
     public function get_total_average_of_thematic_advances($course_code = null, $session_id = null)
@@ -1332,7 +1335,7 @@ class Thematic
             $score = array_sum($a_average_of_advances_by_thematic);
             $total_average = round(($score * 100) / ($count_tematics * 100));
         }
-        
+
         return $total_average;
     }
 
@@ -1362,7 +1365,6 @@ class Thematic
         }
 
         return $average;
-
     }
 
     /**

+ 9 - 7
main/inc/lib/urlmanager.lib.php

@@ -510,7 +510,7 @@ class UrlManager
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $result_array = array();
 
-        if (is_array($course_list) && is_array($url_list)){
+        if (is_array($course_list) && is_array($url_list)) {
             foreach ($url_list as $url_id) {
                 foreach ($course_list as $course_code) {
                     $courseInfo = api_get_course_info($course_code);
@@ -531,7 +531,7 @@ class UrlManager
             }
         }
 
-        return 	$result_array;
+        return $result_array;
     }
 
     /**
@@ -560,7 +560,7 @@ class UrlManager
             }
         }
 
-        return 	$resultArray;
+        return $resultArray;
     }
 
     /**
@@ -589,7 +589,7 @@ class UrlManager
             }
         }
 
-        return 	$resultArray;
+        return $resultArray;
     }
 
     /**
@@ -625,6 +625,7 @@ class UrlManager
                 usergroup_id = '".intval($userGroupId)."',
                 access_url_id = ".intval($urlId);
         Database::query($sql);
+
         return Database::insert_id();
     }
 
@@ -832,7 +833,7 @@ class UrlManager
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
         $sql= "DELETE FROM $table
                WHERE usergroup_id = '".intval($userGroupId)."' AND
-                     access_url_id=".intval($urlId)."  ";
+                     access_url_id = ".intval($urlId);
         $result = Database::query($sql);
 
         return $result;
@@ -884,7 +885,9 @@ class UrlManager
     public static function update_urls_rel_user($user_list, $access_url_id)
     {
         $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-        $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
+        $sql = "SELECT user_id 
+                FROM $table_url_rel_user 
+                WHERE access_url_id = ".intval($access_url_id);
         $result = Database::query($sql);
         $existing_users = array();
 
@@ -1008,7 +1011,6 @@ class UrlManager
         }
 
         // Adding
-
         foreach ($list as $id) {
             UrlManager::addCourseCategoryToUrl($id, $urlId);
             $categoryInfo = CourseCategory::getCategoryById($id);

+ 20 - 52
main/inc/lib/usergroup.lib.php

@@ -801,7 +801,8 @@ class UserGroup extends Model
         if ($this->useMultipleUrl) {
             $urlId = api_get_current_access_url_id();
             $sql = "SELECT * FROM $this->table u
-                    INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id = u.id)
+                    INNER JOIN {$this->access_url_rel_usergroup} a 
+                    ON (a.usergroup_id = u.id)
                     WHERE name = '".Database::escape_string($name)."' AND access_url_id = $urlId";
         } else {
             $sql = "SELECT * FROM $this->table WHERE name = '".Database::escape_string($name)."'";
@@ -954,7 +955,6 @@ class UserGroup extends Model
 
         $groupExists = $this->usergroup_exists(trim($params['name']));
         if ($groupExists == false) {
-
             $id = parent::save($params, $show_query);
             if ($id) {
                 if ($this->useMultipleUrl) {
@@ -1318,7 +1318,6 @@ class UserGroup extends Model
         $form->applyFilter('description', 'trim');
 
         if ($this->showGroupTypeSetting) {
-
             $form->addElement(
                 'checkbox',
                 'group_type',
@@ -1356,7 +1355,7 @@ class UserGroup extends Model
         $form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('AllowMemberLeaveGroup'));
 
         // Setting the form elements
-        if ($type == 'add') {
+        if ($type === 'add') {
             $form->addButtonCreate($header);
         } else {
             $form->addButtonUpdate($header);
@@ -1376,7 +1375,7 @@ class UserGroup extends Model
     {
         $picture = array();
         //$picture['style'] = $style;
-        if ($picture_file == 'unknown.jpg') {
+        if ($picture_file === 'unknown.jpg') {
             $picture['file'] = Display::returnIconPath($picture_file);
             return $picture;
         }
@@ -1485,7 +1484,7 @@ class UserGroup extends Model
      */
     public function getAllowedPictureExtensions()
     {
-        return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
+        return ['jpg', 'jpeg', 'png', 'gif'];
     }
 
     /**
@@ -1828,8 +1827,8 @@ class UserGroup extends Model
     }
 
     /** Gets the last groups created
-     * @param int  quantity of records
-     * @param bool show groups with image or not
+     * @param int  $num quantity of records
+     * @param bool $with_image show groups with image or not
      * @return array  with group content
      * @author Julio Montoya
      * */
@@ -1992,7 +1991,6 @@ class UserGroup extends Model
         $my_group_role = self::get_user_group_role($user_id, $group_id);
 
         // Loading group permission
-
         $links = '';
         switch ($my_group_role) {
             case GROUP_USER_PERMISSION_READER:
@@ -2088,16 +2086,19 @@ class UserGroup extends Model
      * @param bool $with_image
      * @return int
      */
-    public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
-    {
-        $table_group_rel_user	= $this->usergroup_rel_user_table;
-        $tbl_group				= $this->table;
-        $user_id 				= intval($user_id);
+    public function get_groups_by_user_count(
+        $user_id = '',
+        $relation_type = GROUP_USER_PERMISSION_READER,
+        $with_image = false
+    ) {
+        $table_group_rel_user = $this->usergroup_rel_user_table;
+        $tbl_group = $this->table;
+        $user_id = intval($user_id);
 
         if ($relation_type == 0) {
             $where_relation_condition = '';
         } else {
-            $relation_type 			= intval($relation_type);
+            $relation_type = intval($relation_type);
             $where_relation_condition = "AND gu.relation_type = $relation_type ";
         }
 
@@ -2125,39 +2126,11 @@ class UserGroup extends Model
     public function get_all_group_tags($tag, $from = 0, $number_of_items = 10, $getCount = false)
     {
         $group_table = $this->table;
-        $table_tag = Database::get_main_table(TABLE_MAIN_TAG);
-        //$table_group_tag_values	= Database::get_main_table(TABLE_USERGROUP_REL_TAG);
-
-        $field_id = 5;
         $tag = Database::escape_string($tag);
         $from = intval($from);
         $number_of_items = intval($number_of_items);
         $return = array();
 
-        // all the information of the field
-        /*$select = "SELECT g.id, g.name, g.description, g.picture";
-
-        $sql = "$select
-                FROM $table_tag t
-                INNER JOIN $table_group_tag_values tv
-                ON (tv.tag_id=t.id)
-                INNER JOIN $group_table g
-                ON (tv.usergroup_id =g.id)
-				WHERE
-				    tag LIKE '$tag%' AND
-				    field_id= $field_id
-                ORDER BY tag";
-
-        $sql .= " LIMIT $from, $number_of_items";
-
-        $result = Database::query($sql);
-
-        if (Database::num_rows($result)> 0) {
-            while ($row = Database::fetch_array($result,'ASSOC')) {
-                $return[$row['id']] = $row;
-            }
-        }*/
-
         $keyword = $tag;
         $sql = "SELECT  g.id, g.name, g.description, g.url, g.picture
                 FROM $group_table g";
@@ -2243,9 +2216,7 @@ class UserGroup extends Model
         $includeSubgroupsUsers = true
     ) {
         $userId = intval($userId);
-
         $groups = $this->get_groups_by_user($userId, $relationType);
-
         $groupsId = array_keys($groups);
         $subgroupsId = [];
         $userIdList = [];
@@ -2304,9 +2275,7 @@ class UserGroup extends Model
         for ($i = 1; $i <= $levels; $i++) {
             $tableIndexNumber = $i;
             $tableIndexJoinNumber = $i - 1;
-
             $select .= "g$i.id as id_$i ";
-
             $select .= ($i != $levels ? ", " : null);
 
             if ($i == 1) {
@@ -2322,9 +2291,9 @@ class UserGroup extends Model
         $result = Database::query("$select $from");
 
         while ($item = Database::fetch_assoc($result)) {
-            foreach ($item as $groupId) {
-                if (!empty($groupId)) {
-                    $groups[] = $groupId;
+            foreach ($item as $myGroupId) {
+                if (!empty($myGroupId)) {
+                    $groups[] = $myGroupId;
                 }
             }
         }
@@ -2362,6 +2331,7 @@ class UserGroup extends Model
             }
         }
         $res = Database::query($sql);
+
         return $res;
     }
 
@@ -2411,6 +2381,4 @@ class UserGroup extends Model
     {
         return $groupInfo['allow_members_leave_group'] == 1 ? true : false;
     }
-
 }
-