Code Duplication    Length = 10-16 lines in 5 locations

migrations/v10x/m2_acp_module.php 1 location

@@ 18-29 (lines=12) @@
15
	/**
16
	 * {@inheritDoc}
17
	 */
18
	public function effectively_installed()
19
	{
20
		$sql = 'SELECT module_id
21
			FROM ' . $this->table_prefix . "modules
22
			WHERE module_class = 'acp'
23
				AND module_langname = 'ACP_PHPBB_ADS_TITLE'";
24
		$result = $this->db->sql_query($sql);
25
		$module_id = (int) $this->db->sql_fetchfield('module_id');
26
		$this->db->sql_freeresult($result);
27
28
		return $module_id;
29
	}
30
31
	/**
32
	 * {@inheritDoc}

ad/manager.php 4 locations

@@ 49-64 (lines=16) @@
46
	 * @param	int	$ad_id	Advertisement ID
47
	 * @return	array	Array with advertisement data
48
	 */
49
	public function get_ad($ad_id)
50
	{
51
		$sql = 'SELECT *
52
			FROM ' . $this->ads_table . '
53
			WHERE ad_id = ' . (int) $ad_id;
54
		$result = $this->db->sql_query($sql);
55
		$data = $this->db->sql_fetchrow($result);
56
		$this->db->sql_freeresult($result);
57
58
		if ($data === false)
59
		{
60
			return array();
61
		}
62
63
		return $data;
64
	}
65
66
	/**
67
	 * Get one ad per every location
@@ 111-120 (lines=10) @@
108
	 *
109
	 * @return    array    List of all ads
110
	 */
111
	public function get_all_ads()
112
	{
113
		$sql = 'SELECT ad_id, ad_priority, ad_name, ad_enabled, ad_end_date, ad_views, ad_clicks, ad_views_limit, ad_clicks_limit
114
			FROM ' . $this->ads_table;
115
		$result = $this->db->sql_query($sql);
116
		$data = $this->db->sql_fetchrowset($result);
117
		$this->db->sql_freeresult($result);
118
119
		return $data;
120
	}
121
122
	/**
123
	 * Get all owner's ads
@@ 128-138 (lines=11) @@
125
	 * @param    int $user_id Ad owner
126
	 * @return    array    List of owner's ads
127
	 */
128
	public function get_ads_by_owner($user_id)
129
	{
130
		$sql = 'SELECT ad_name, ad_views, ad_clicks
131
			FROM ' . $this->ads_table . '
132
			WHERE ad_owner = ' . (int) $user_id;
133
		$result = $this->db->sql_query($sql);
134
		$data = $this->db->sql_fetchrowset($result);
135
		$this->db->sql_freeresult($result);
136
137
		return $data;
138
	}
139
140
	/**
141
	 * Increment views for specified ads
@@ 326-336 (lines=11) @@
323
	 *
324
	 * @return	array	List of groups
325
	 */
326
	public function load_groups()
327
	{
328
		$sql = 'SELECT group_id, group_name, group_type
329
			FROM ' . GROUPS_TABLE . "
330
			WHERE group_name <> 'BOTS'
331
			ORDER BY group_name ASC";
332
		$result = $this->db->sql_query($sql);
333
		$groups = $this->db->sql_fetchrowset($result);
334
		$this->db->sql_freeresult($result);
335
336
		return $groups;
337
	}
338
339
	/**