Code Duplication    Length = 31-32 lines in 2 locations

mod/gc_mobile_api/models/opportunity.php 1 location

@@ 103-134 (lines=32) @@
100
	}
101
102
	$filter_data = json_decode($filters);
103
	if (!empty($filter_data)) {
104
		$params = array(
105
			'type' => 'object',
106
			'subtype' => 'mission',
107
			'limit' => $limit,
108
			'offset' => $offset
109
		);
110
111
		if ($filter_data->type) {
112
			$params['metadata_name'] = 'job_type';
113
			$params['metadata_value'] = $filter_data->type;
114
		}
115
116
		if ($filter_data->name) {
117
			$db_prefix = elgg_get_config('dbprefix');
118
			$params['joins'] = array("JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid");
119
			$params['wheres'] = array("(oe.title LIKE '%" . $filter_data->name . "%' OR oe.description LIKE '%" . $filter_data->name . "%')");
120
		}
121
122
		if ($filter_data->mine) {
123
			$all_opportunities = elgg_list_entities_from_relationship($params);
124
		} else {
125
			$all_opportunities = elgg_list_entities_from_metadata($params);
126
		}
127
	} else {
128
		$all_opportunities = elgg_list_entities(array(
129
			'type' => 'object',
130
			'subtype' => 'mission',
131
			'limit' => $limit,
132
			'offset' => $offset
133
		));
134
	}
135
136
	$opportunities = json_decode($all_opportunities);
137

mod/gc_mobile_api/models/discussion.php 1 location

@@ 119-149 (lines=31) @@
116
	}
117
118
	$filter_data = json_decode($filters);
119
	if (!empty($filter_data)) {
120
		$params = array(
121
			'type' => 'object',
122
			'subtype' => 'groupforumtopic',
123
			'limit' => $limit,
124
			'offset' => $offset
125
		);
126
127
		if ($filter_data->mine) {
128
			$params['owner_guid'] = $user_entity->guid;
129
		}
130
131
		if ($filter_data->name) {
132
			$db_prefix = elgg_get_config('dbprefix');
133
			$params['joins'] = array("JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid");
134
			$params['wheres'] = array("(oe.title LIKE '%" . $filter_data->name . "%' OR oe.description LIKE '%" . $filter_data->name . "%')");
135
		}
136
137
		if ($filter_data->mine) {
138
			$all_discussions = elgg_list_entities_from_relationship($params);
139
		} else {
140
			$all_discussions = elgg_list_entities_from_metadata($params);
141
		}
142
	} else {
143
		$all_discussions = elgg_list_entities(array(
144
			'type' => 'object',
145
			'subtype' => 'groupforumtopic',
146
			'limit' => $limit,
147
			'offset' => $offset
148
		));
149
	}
150
151
	$discussions = json_decode($all_discussions);
152