Code Duplication    Length = 7-10 lines in 4 locations

main/inc/lib/login.lib.php 1 location

@@ 796-802 (lines=7) @@
793
                $group_table = Database::get_course_table(TABLE_GROUP);
794
                $sql = "SELECT * FROM $group_table WHERE c_id = " . $_course['real_id'] . " AND id = '$group_id'";
795
                $result = Database::query($sql);
796
                if (Database::num_rows($result) > 0) { // This group has recorded status related to this course
797
                    $gpData = Database::fetch_array($result);
798
                    $_gid = $gpData ['id'];
799
                    Session::write('_gid', $_gid);
800
                } else {
801
                    Session::erase('_gid');
802
                }
803
            } elseif (isset($_SESSION['_gid']) or isset($_gid)) { // Keys missing => not anymore in the group - course relation
804
                Session::erase('_gid');
805
            }

main/inc/lib/blog.lib.php 1 location

@@ 2356-2362 (lines=7) @@
2353
		$result = Database::query($sql);
2354
2355
		// We will create an array of days on which there are posts.
2356
		if( Database::num_rows($result) > 0) {
2357
			while($blog_post = Database::fetch_array($result)) {
2358
				// If the day of this post is not yet in the array, add it.
2359
				if (!in_array($blog_post['post_day'], $posts))
2360
					$posts[] = $blog_post['post_day'];
2361
			}
2362
		}
2363
2364
		// Get tasks for this month
2365
		if ($_user['user_id']) {

index.php 1 location

@@ 102-108 (lines=7) @@
99
                                WHERE login_user_id = '".$_user['user_id']."'
100
                                ORDER BY login_date DESC LIMIT 1";
101
        $result_last_login = Database::query($sql_last_login);
102
        if (!$result_last_login) {
103
            if (Database::num_rows($result_last_login) > 0) {
104
                $user_last_login_datetime = Database::fetch_array($result_last_login);
105
                $user_last_login_datetime = $user_last_login_datetime[0];
106
                Session::write('user_last_login_datetime',$user_last_login_datetime);
107
            }
108
        }
109
        //Event::event_login();
110
    }
111
    // End login -- if ($_POST['submitAuth'])

main/inc/lib/usermanager.lib.php 1 location

@@ 4160-4169 (lines=10) @@
4157
        }
4158
        $result = Database::query($sql);
4159
4160
        if (Database::num_rows($result) > 0) {
4161
            while ($row = Database::fetch_array($result)) {
4162
                $sql = "DELETE FROM $userRelUserTable 
4163
                        WHERE 
4164
                          user_id = {$row['user_id']} AND 
4165
                          friend_user_id = $userId AND 
4166
                          relation_type = $relationType";
4167
                Database::query($sql);
4168
            }
4169
        }
4170
4171
        if ($deleteUsersBeforeInsert) {
4172
            $sql = "DELETE FROM $userRelUserTable