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/usermanager.lib.php 1 location

@@ 4153-4162 (lines=10) @@
4150
        }
4151
        $result = Database::query($sql);
4152
4153
        if (Database::num_rows($result) > 0) {
4154
            while ($row = Database::fetch_array($result)) {
4155
                $sql = "DELETE FROM $userRelUserTable 
4156
                        WHERE 
4157
                          user_id = {$row['user_id']} AND 
4158
                          friend_user_id = $userId AND 
4159
                          relation_type = $relationType";
4160
                Database::query($sql);
4161
            }
4162
        }
4163
4164
        if ($deleteUsersBeforeInsert) {
4165
            $sql = "DELETE FROM $userRelUserTable 

index.php 1 location

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

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']) {