Code Duplication    Length = 7-10 lines in 4 locations

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

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

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

@@ 4176-4185 (lines=10) @@
4173
        }
4174
        $result = Database::query($sql);
4175
4176
        if (Database::num_rows($result) > 0) {
4177
            while ($row = Database::fetch_array($result)) {
4178
                $sql = "DELETE FROM $userRelUserTable 
4179
                        WHERE 
4180
                          user_id = {$row['user_id']} AND 
4181
                          friend_user_id = $userId AND 
4182
                          relation_type = $relationType";
4183
                Database::query($sql);
4184
            }
4185
        }
4186
4187
        if ($deleteUsersBeforeInsert) {
4188
            $sql = "DELETE FROM $userRelUserTable