Code Duplication    Length = 32-33 lines in 2 locations

models/friends_model.php 1 location

@@ 32-63 (lines=32) @@
29
        $this->user_friends_table = $user_friends_table;
30
    }
31
32
    public function getFriends()
33
    {
34
        $sql = "
35
            SELECT u.user_id, 
36
                   u.username, 
37
                   u.username_clean, 
38
                   u.user_type, 
39
                   u.user_colour, 
40
                   s.session_id, 
41
                   s.session_time
42
            FROM " . $this->user_friends_table . "
43
            LEFT JOIN " . USERS_TABLE . " AS u ON u.user_id = " . $this->user_friends_table . ".friend_id
44
            LEFT JOIN " . SESSIONS_TABLE . " AS s ON s.session_user_id = u.user_id
45
            WHERE " . $this->user_friends_table . ".user_id = " . (int)$this->user->data['user_id'] . "
46
            GROUP BY u.user_id
47
        ";
48
        $result = $this->db->sql_query($sql);
49
50
        $friends = array();
51
        while ($row = $this->db->sql_fetchrow($result)) {
52
            $friends[] = array(
53
                'user_id' => $row['user_id'],
54
                'username' => $row['username_clean'],
55
                'user_colour' => $row['user_colour'],
56
                'user_status' => ($row['session_time'] >= (time() - ($this->config['load_online_time'] * 60))) ? 1 : 0,
57
            );
58
        }
59
        $this->db->sql_freeresult();
60
61
        return $friends;
62
    }
63
64
    public function get_friends_requests()
65
    {
66

models/main_model.php 1 location

@@ 66-98 (lines=33) @@
63
     * get all friends
64
     * @return array the list of friends
65
     */
66
    public function getFriends()
67
    {
68
        $sql = "
69
            SELECT u.user_id,
70
                   u.username,
71
                   u.username_clean,
72
                   u.user_type,
73
                   u.user_colour,
74
                   s.session_id,
75
                   s.session_time
76
            FROM " . $this->user_friends_table . "
77
            LEFT JOIN " . USERS_TABLE . " AS u ON u.user_id = " . $this->user_friends_table . ".friend_id
78
            LEFT JOIN " . SESSIONS_TABLE . " AS s ON s.session_user_id = u.user_id
79
            WHERE " . $this->user_friends_table . ".user_id = " . (int)$this->user->data['user_id'] . "
80
            GROUP BY u.user_id
81
        ";
82
        $result = $this->phpbb_db->sql_query($sql);
83
84
        $friends = array();
85
        while ($row = $this->phpbb_db->sql_fetchrow($result)) {
86
            $friends[] = array(
87
                'user_id' => $row['user_id'],
88
                'username' => $row['username_clean'],
89
                'user_colour' => $row['user_colour'],
90
                'user_status' => ($row['session_time'] >= (time() - ($this->config['load_online_time'] * 60))) ? 1 : 0,
91
                'inbox' => $this->getInboxFromId($row['user_id'])
92
            );
93
        }
94
        $this->phpbb_db->sql_freeresult();
95
96
        return $friends;
97
    }
98
99
    /**
100
     * checks if a user is friend with other user and vice-versa
101
     * @param int $friend_id