Example #1
0
/**
 * Returns metadata.  Accepts all elgg_get_entities() options for entity
 * restraints.
 *
 * @see elgg_get_entities
 *
 * @warning 1.7's find_metadata() didn't support limits and returned all metadata.
 *          This function defaults to a limit of 25. There is probably not a reason
 *          for you to return all metadata unless you're exporting an entity,
 *          have other restraints in place, or are doing something horribly
 *          wrong in your code.
 *
 * @param array $options Array in format:
 *
 * metadata_names               => NULL|ARR metadata names
 * metadata_values              => NULL|ARR metadata values
 * metadata_ids                 => NULL|ARR metadata ids
 * metadata_case_sensitive      => BOOL Overall Case sensitive
 * metadata_owner_guids         => NULL|ARR guids for metadata owners
 * metadata_created_time_lower  => INT Lower limit for created time.
 * metadata_created_time_upper  => INT Upper limit for created time.
 * metadata_calculation         => STR Perform the MySQL function on the metadata values returned.
 *                                   The "metadata_calculation" option causes this function to
 *                                   return the result of performing a mathematical calculation on
 *                                   all metadata that match the query instead of returning
 *                                   ElggMetadata objects.
 *
 * @return mixed
 * @since 1.8.0
 */
function elgg_get_metadata(array $options = array())
{
    $options['metastring_type'] = 'metadata';
    return elgg_get_metastring_based_objects($options);
}
Example #2
0
/**
 * Returns annotations.  Accepts all elgg_get_entities() options for entity
 * restraints.
 *
 * @see elgg_get_entities
 *
 * @param array $options Array in format:
 *
 * 	annotation_names => NULL|ARR Annotation names
 *
 * 	annotation_values => NULL|ARR Annotation values
 *
 * 	annotation_ids => NULL|ARR annotation ids
 *
 * 	annotation_case_sensitive => BOOL Overall Case sensitive
 *
 *  annotation_owner_guids => NULL|ARR guids for annotation owners
 *
 *  annotation_created_time_lower => INT Lower limit for created time.
 *
 *  annotation_created_time_upper => INT Upper limit for created time.
 *
 *  annotation_calculation => STR Perform the MySQL function on the annotation values returned.
 *
 * @return mixed
 * @since 1.8.0
 */
function elgg_get_annotations(array $options = array())
{
    $options['metastring_type'] = 'annotations';
    return elgg_get_metastring_based_objects($options);
}
Example #3
0
/**
 * Returns a singular metastring-based object by its ID.
 *
 * @param int    $id   The metastring-based object's ID
 * @param string $type The type: annotation or metadata
 * @return mixed
 *
 * @since 1.8.0
 * @access private
 */
function elgg_get_metastring_based_object_from_id($id, $type)
{
    $id = (int) $id;
    if (!$id) {
        return false;
    }
    $options = array('metastring_type' => $type, 'metastring_id' => $id);
    $obj = elgg_get_metastring_based_objects($options);
    if ($obj && count($obj) == 1) {
        return $obj[0];
    }
    return false;
}
Example #4
0
/**
 * Returns metadata.  Accepts all elgg_get_entities() options for entity
 * restraints.
 *
 * @see elgg_get_entities
 *
 * @warning 1.7's find_metadata() didn't support limits and returned all metadata.
 *          This function defaults to a limit of 25. There is probably not a reason
 *          for you to return all metadata unless you're exporting an entity,
 *          have other restraints in place, or are doing something horribly
 *          wrong in your code.
 *
 * @param array $options Array in format:
 *
 * metadata_names               => NULL|ARR metadata names
 * metadata_values              => NULL|ARR metadata values
 * metadata_ids                 => NULL|ARR metadata ids
 * metadata_case_sensitive      => BOOL Overall Case sensitive
 * metadata_owner_guids         => NULL|ARR guids for metadata owners
 * metadata_created_time_lower  => INT Lower limit for created time.
 * metadata_created_time_upper  => INT Upper limit for created time.
 * metadata_calculation         => STR Perform the MySQL function on the metadata values returned.
 *                                   The "metadata_calculation" option causes this function to
 *                                   return the result of performing a mathematical calculation on
 *                                   all metadata that match the query instead of returning
 *                                   ElggMetadata objects.
 *
 * @return ElggMetadata[]|mixed
 * @since 1.8.0
 */
function elgg_get_metadata(array $options = array())
{
    // @todo remove support for count shortcut - see #4393
    // support shortcut of 'count' => true for 'metadata_calculation' => 'count'
    if (isset($options['count']) && $options['count']) {
        $options['metadata_calculation'] = 'count';
        unset($options['count']);
    }
    $options['metastring_type'] = 'metadata';
    return elgg_get_metastring_based_objects($options);
}
Example #5
0
 public function testGetMetastringBasedObjectWithDisabledAnnotation()
 {
     $name = 'test_annotation_name' . rand();
     $value = 'test_annotation_value' . rand();
     $id = create_annotation($this->object->guid, $name, $value);
     $annotation = elgg_get_annotation_from_id($id);
     $this->assertTrue($annotation->disable());
     $test = elgg_get_metastring_based_objects(array('metastring_type' => 'annotations', 'guid' => $this->object->guid));
     $this->assertEqual(array(), $test);
 }
Example #6
0
/**
 * Returns annotations.  Accepts all elgg_get_entities() options for entity
 * restraints.
 *
 * @see elgg_get_entities
 *
 * @param array $options Array in format:
 *
 * annotation_names              => NULL|ARR Annotation names
 * annotation_values             => NULL|ARR Annotation values
 * annotation_ids                => NULL|ARR annotation ids
 * annotation_case_sensitive     => BOOL Overall Case sensitive
 * annotation_owner_guids        => NULL|ARR guids for annotation owners
 * annotation_created_time_lower => INT Lower limit for created time.
 * annotation_created_time_upper => INT Upper limit for created time.
 * annotation_calculation        => STR Perform the MySQL function on the annotation values returned.
 *                                   Do not confuse this "annotation_calculation" option with the
 *                                   "calculation" option to elgg_get_entities_from_annotation_calculation().
 *                                   The "annotation_calculation" option causes this function to
 *                                   return the result of performing a mathematical calculation on
 *                                   all annotations that match the query instead of ElggAnnotation
 *                                   objects.
 *                                   See the docs for elgg_get_entities_from_annotation_calculation()
 *                                   for the proper use of the "calculation" option.
 *
 *
 * @return ElggAnnotation[]|mixed
 * @since 1.8.0
 */
function elgg_get_annotations(array $options = array())
{
    // @todo remove support for count shortcut - see #4393
    if (isset($options['__egefac']) && $options['__egefac']) {
        unset($options['__egefac']);
    } else {
        // support shortcut of 'count' => true for 'annotation_calculation' => 'count'
        if (isset($options['count']) && $options['count']) {
            $options['annotation_calculation'] = 'count';
            unset($options['count']);
        }
    }
    $options['metastring_type'] = 'annotations';
    return elgg_get_metastring_based_objects($options);
}