Code Duplication    Length = 34-34 lines in 2 locations

engine/lib/deprecated-1.7.php 2 locations

@@ 777-810 (lines=34) @@
774
 * @return int|false
775
 * @deprecated 1.7
776
 */
777
function search_for_object($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
778
	elgg_deprecated_notice('search_for_object() was deprecated by new search plugin.', 1.7);
779
	global $CONFIG;
780
781
	$criteria = sanitise_string($criteria);
782
	$limit = (int)$limit;
783
	$offset = (int)$offset;
784
	$order_by = sanitise_string($order_by);
785
786
	$access = _elgg_get_access_where_sql();
787
788
	if ($order_by == "") {
789
		$order_by = "e.time_created desc";
790
	}
791
792
	if ($count) {
793
		$query = "SELECT count(e.guid) as total ";
794
	} else {
795
		$query = "SELECT e.* ";
796
	}
797
	$query .= "from {$CONFIG->dbprefix}entities e
798
		join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid
799
		where match(o.title,o.description) against ('$criteria') and $access";
800
801
	if (!$count) {
802
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
803
		return get_data($query, "entity_row_to_elggstar");
804
	} else {
805
		if ($count = get_data_row($query)) {
806
			return $count->total;
807
		}
808
	}
809
	return false;
810
}
811
812
/**
813
 * Returns a formatted list of objects suitable for injecting into search.
@@ 930-963 (lines=34) @@
927
 * @return mixed
928
 * @deprecated 1.7
929
 */
930
function search_for_site($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
931
	elgg_deprecated_notice('search_for_site() was deprecated by new search plugin.', 1.7);
932
	global $CONFIG;
933
934
	$criteria = sanitise_string($criteria);
935
	$limit = (int)$limit;
936
	$offset = (int)$offset;
937
	$order_by = sanitise_string($order_by);
938
939
	$access = _elgg_get_access_where_sql();
940
941
	if ($order_by == "") {
942
		$order_by = "e.time_created desc";
943
	}
944
945
	if ($count) {
946
		$query = "SELECT count(e.guid) as total ";
947
	} else {
948
		$query = "SELECT e.* ";
949
	}
950
	$query .= "from {$CONFIG->dbprefix}entities e
951
		join {$CONFIG->dbprefix}sites_entity s on e.guid=s.guid
952
		where match(s.name, s.description, s.url) against ('$criteria') and $access";
953
954
	if (!$count) {
955
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
956
		return get_data($query, "entity_row_to_elggstar");
957
	} else {
958
		if ($count = get_data_row($query)) {
959
			return $count->total;
960
		}
961
	}
962
	return false;
963
}
964
965
/**
966
 * Searches for a user based on a complete or partial name or username.