Code Duplication    Length = 9-12 lines in 3 locations

modules/abstract_module.php 1 location

@@ 67-78 (lines=12) @@
64
	 *
65
	 * @return bool
66
	 */
67
	protected function check_table_for_user($table, $user_id)
68
	{
69
		$sql = 'SELECT COUNT(registration_id) as reg_id 
70
					FROM ' . $table . ' 
71
					WHERE 
72
						user_id = ' . (int) $user_id;
73
		$result = $this->db->sql_query($sql);
74
		$row = $this->db->sql_fetchrow($result);
75
		$this->db->sql_freeresult($result);
76
77
		return $row && $row['reg_id'] > 0;
78
	}
79
}

modules/otp.php 2 locations

@@ 107-118 (lines=12) @@
104
	 *
105
	 * @return bool
106
	 */
107
	public function is_usable($user_id)
108
	{
109
		$sql = 'SELECT COUNT(registration_id) as reg_id 
110
					FROM ' . $this->otp_registration_table . ' 
111
					WHERE 
112
						user_id = ' . (int) $user_id;
113
		$result = $this->db->sql_query($sql);
114
		$row = $this->db->sql_fetchrow($result);
115
		$this->db->sql_freeresult($result);
116
117
		return $row && $row['reg_id'] > 0;
118
	}
119
120
	/**
121
	 * Check if the user can potentially use this.
@@ 284-292 (lines=9) @@
281
	 * @param integer $user_id
282
	 * @return array
283
	 */
284
	private function getRegistrations($user_id)
285
	{
286
		$sql = 'SELECT * FROM ' . $this->otp_registration_table . ' WHERE user_id = ' . (int) $user_id;
287
		$result = $this->db->sql_query($sql);
288
		$rows = $this->db->sql_fetchrowset($result);
289
290
		$this->db->sql_freeresult($result);
291
		return $rows;
292
	}
293
}
294