protected function prepareBatchOptions(array $options = array()) {

		if (!in_array($this->getter, array(
					'elgg_get_entities',
					'elgg_get_entities_from_metadata',
					'elgg_get_entities_from_relationship',
				))) {
			return $options;
		}

		$sort = elgg_extract('sort', $options);
		unset($options['sort']);

		if (!is_array($sort)) {
			return $options;
		}

		$dbprefix = elgg_get_config('dbprefix');

		$order_by = array();

		foreach ($sort as $field => $direction) {

			$field = sanitize_string($field);
			$direction = strtoupper(sanitize_string($direction));

			if (!in_array($direction, array('ASC', 'DESC'))) {
				$direction = 'ASC';
			}

			switch ($field) {

				case 'alpha' :
					if (elgg_extract('types', $options) == 'user') {
						$options['joins']['ue'] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid";
						$order_by[] = "ue.name  {$direction}";
					} else if (elgg_extract('types', $options) == 'group') {
						$options['joins']['ge'] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = e.guid";
						$order_by[] = "ge.name  {$direction}";
					} else if (elgg_extract('types', $options) == 'object') {
						$options['joins']['oe'] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid";
						$order_by[] = "oe.title {$direction}";
					}
					break;

				case 'type' :
				case 'subtype' :
				case 'guid' :
				case 'owner_guid' :
				case 'container_guid' :
				case 'site_guid' :
				case 'enabled' :
				case 'time_created';
				case 'time_updated' :
				case 'last_action' :
				case 'access_id' :
					$order_by[] = "e.{$field} {$direction}";
					break;
			}
		}

		$options['order_by'] = implode(',', $order_by);

		return $options;
	}
protected function prepareBatchOptions(array $options = array()) {

		if (!in_array($this->getter, array(
					'elgg_get_entities',
					'elgg_get_entities_from_metadata',
					'elgg_get_entities_from_relationship',
				))) {
			return $options;
		}

		$sort = elgg_extract('sort', $options);
		unset($options['sort']);

		if (!is_array($sort)) {
			return $options;
		}

		$dbprefix = elgg_get_config('dbprefix');

		$order_by = array();

		foreach ($sort as $field => $direction) {

			$field = sanitize_string($field);
			$direction = strtoupper(sanitize_string($direction));

			if (!in_array($direction, array('ASC', 'DESC'))) {
				$direction = 'ASC';
			}

			switch ($field) {

				case 'alpha' :
					if (elgg_extract('types', $options) == 'user') {
						$options['joins']['ue'] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid";
						$order_by[] = "ue.name  {$direction}";
					} else if (elgg_extract('types', $options) == 'group') {
						$options['joins']['ge'] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = e.guid";
						$order_by[] = "ge.name  {$direction}";
					} else if (elgg_extract('types', $options) == 'object') {
						$options['joins']['oe'] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid";
						$order_by[] = "oe.title {$direction}";
					}
					break;

				case 'type' :
				case 'subtype' :
				case 'guid' :
				case 'owner_guid' :
				case 'container_guid' :
				case 'site_guid' :
				case 'enabled' :
				case 'time_created';
				case 'time_updated' :
				case 'last_action' :
				case 'access_id' :
					$order_by[] = "e.{$field} {$direction}";
					break;
			}
		}

		$options['order_by'] = implode(',', $order_by);

		return $options;
	}
protected function prepareBatchOptions ( array $ options = array ( ) ) { if ( ! in_array ( $ this -> getter , array ( 'elgg_get_entities' , 'elgg_get_entities_from_metadata' , 'elgg_get_entities_from_relationship' , ) ) ) { return $ options ; } $ sort = elgg_extract ( 'sort' , $ options ) ; unset ( $ options [ 'sort' ] ) ; if ( ! is_array ( $ sort ) ) { return $ options ; } $ dbprefix = elgg_get_config ( 'dbprefix' ) ; $ order_by = array ( ) ; foreach ( $ sort as $ field => $ direction ) { $ field = sanitize_string ( $ field ) ; $ direction = strtoupper ( sanitize_string ( $ direction ) ) ; if ( ! in_array ( $ direction , array ( 'ASC' , 'DESC' ) ) ) { $ direction = 'ASC' ; } switch ( $ field ) { case 'alpha' : if ( elgg_extract ( 'types' , $ options ) == 'user' ) { $ options [ 'joins' ] [ 'ue' ] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid" ; $ order_by [ ] = "ue.name  {$direction}" ; } else if ( elgg_extract ( 'types' , $ options ) == 'group' ) { $ options [ 'joins' ] [ 'ge' ] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = e.guid" ; $ order_by [ ] = "ge.name  {$direction}" ; } else if ( elgg_extract ( 'types' , $ options ) == 'object' ) { $ options [ 'joins' ] [ 'oe' ] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid" ; $ order_by [ ] = "oe.title {$direction}" ; } break ; case 'type' : case 'subtype' : case 'guid' : case 'owner_guid' : case 'container_guid' : case 'site_guid' : case 'enabled' : case 'time_created' ; case 'time_updated' : case 'last_action' : case 'access_id' : $ order_by [ ] = "e.{$field} {$direction}" ; break ; } } $ options [ 'order_by' ] = implode ( ',' , $ order_by ) ; return $ options ; }
Prepares batch options

@param array $options ege* options
@return array
Prepares batch options