Code Duplication    Length = 18-20 lines in 2 locations

include/classes/user.class.php 2 locations

@@ 150-167 (lines=18) @@
147
   * @param none
148
   * @return data array All users with db columns as array fields
149
   **/
150
  public function getLastRegisteredUsers($limit=10,$start=0) {
151
    $this->debug->append("STA " . __METHOD__, 4);
152
    $invitation = new Invitation();
153
    $invitation->setMysql($this->mysqli);
154
    $invitation->setDebug($this->debug);
155
    $invitation->setLog($this->log);
156
    $stmt = $this->mysqli->prepare("
157
    	SELECT a.id,a.username as mposuser,a.email,a.signup_timestamp,u.username AS inviter FROM " . $this->getTableName() . " AS a
158
    	LEFT JOIN " . $invitation->getTableName() . " AS i
159
    	ON a.email = i.email
160
    	LEFT JOIN " . $this->getTableName() . " AS u
161
    	ON i.account_id = u.id
162
    	ORDER BY a.id DESC LIMIT ?,?");
163
    if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
164
      return $result->fetch_all(MYSQLI_ASSOC);
165
    }
166
  }
167
168
  /**
169
   * Fetch Top 10 Inviters
170
   * @param none
@@ 173-192 (lines=20) @@
170
   * @param none
171
   * @return data array All users with db columns as array fields
172
   **/
173
  public function getTopInviters($limit=10,$start=0) {
174
    $this->debug->append("STA " . __METHOD__, 4);
175
    $invitation = new Invitation();
176
    $invitation->setMysql($this->mysqli);
177
    $invitation->setDebug($this->debug);
178
    $invitation->setLog($this->log);
179
    $stmt = $this->mysqli->prepare("
180
    	SELECT COUNT(i.account_id) AS invitationcount,a.id,a.username,a.email,
181
    	(SELECT COUNT(account_id) FROM " . $invitation->getTableName() . " WHERE account_id = i.account_id AND is_activated = 1 GROUP BY account_id) AS activated
182
    	FROM " . $invitation->getTableName() . " AS i
183
    	LEFT JOIN " . $this->getTableName() . " AS a
184
    	ON a.id = i.account_id
185
    	GROUP BY i.account_id
186
    	ORDER BY invitationcount ASC
187
    	LIMIT ?,?");
188
    if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
189
      return $result->fetch_all(MYSQLI_ASSOC);
190
    }
191
  }
192
193
  /**
194
   * Check user login
195
   * @param username string Username