Code Duplication    Length = 45-46 lines in 2 locations

engine/lib/deprecated-1.8.php 2 locations

@@ 89-134 (lines=46) @@
86
 *
87
 * @return mixed
88
 */
89
function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
90
91
	$msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
92
93
	elgg_deprecated_notice($msg, 1.8);
94
95
	$options = array();
96
97
	$options['calculation'] = $sum;
98
99
	if ($entity_type) {
100
		$options['types'] = $entity_type;
101
	}
102
103
	if ($entity_subtype) {
104
		$options['subtypes'] = $entity_subtype;
105
	}
106
107
	$options['annotation_names'] = $name;
108
109
	if ($mdname) {
110
		$options['metadata_names'] = $mdname;
111
	}
112
113
	if ($mdvalue) {
114
		$options['metadata_values'] = $mdvalue;
115
	}
116
117
	// original function rewrote this to container guid.
118
	if ($owner_guid) {
119
		if (is_array($owner_guid)) {
120
			$options['container_guids'] = $owner_guid;
121
		} else {
122
			$options['container_guid'] = $owner_guid;
123
		}
124
	}
125
126
	$options['limit'] = $limit;
127
	$options['offset'] = $offset;
128
129
	$options['order_by'] = "annotation_calculation $orderdir";
130
131
	$options['count'] = $count;
132
133
	return elgg_get_entities_from_annotation_calculation($options);
134
}
135
136
/**
137
 * Returns entities ordered by the sum of an annotation
@@ 160-204 (lines=45) @@
157
 *
158
 * @return ElggEntity[]|int
159
 */
160
function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
161
162
	$msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
163
164
	elgg_deprecated_notice($msg, 1.8);
165
166
	$options = array();
167
168
	$options['calculation'] = 'sum';
169
170
	if ($entity_type) {
171
		$options['types'] = $entity_type;
172
	}
173
174
	if ($entity_subtype) {
175
		$options['subtypes'] = $entity_subtype;
176
	}
177
178
	$options['annotation_names'] = $name;
179
180
	if ($mdname) {
181
		$options['metadata_names'] = $mdname;
182
	}
183
184
	if ($mdvalue) {
185
		$options['metadata_values'] = $mdvalue;
186
	}
187
188
	if ($owner_guid) {
189
		if (is_array($owner_guid)) {
190
			$options['owner_guids'] = $owner_guid;
191
		} else {
192
			$options['owner_guid'] = $owner_guid;
193
		}
194
	}
195
196
	$options['limit'] = $limit;
197
	$options['offset'] = $offset;
198
199
	$options['order_by'] = "annotation_calculation $orderdir";
200
201
	$options['count'] = $count;
202
203
	return elgg_get_entities_from_annotation_calculation($options);
204
}
205
206
/**
207
 * Lists entities by the totals of a particular kind of annotation