/** * Disables metadata based on $options. * * @warning Unlike elgg_get_metadata() this will not accept an empty options array! * * @param array $options An options array. {@link elgg_get_metadata()} * @return bool|null true on success, false on failure, null if no metadata disabled. * @since 1.8.0 */ function elgg_disable_metadata(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'metadata')) { return false; } _elgg_get_metadata_cache()->invalidateByOptions('disable', $options); // if we can see hidden (disabled) we need to use the offset // otherwise we risk an infinite loop if there are more than 50 $inc_offset = access_get_show_hidden_status(); $options['metastring_type'] = 'metadata'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', $inc_offset); }
/** * Disables annotations based on $options. * * @warning Unlike elgg_get_annotations() this will not accept an empty options array! * * @param array $options An options array. {@link elgg_get_annotations()} * @return bool|null true on success, false on failure, null if no annotations disabled. */ function disableAll(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'annotation')) { return false; } // if we can see hidden (disabled) we need to use the offset // otherwise we risk an infinite loop if there are more than 50 $inc_offset = access_get_show_hidden_status(); $options['metastring_type'] = 'annotations'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', $inc_offset); }
public function testKeepMeFromDeletingEverything() { foreach ($this->metastringTypes as $type) { $required = array('guid', 'guids'); switch ($type) { case 'metadata': $metadata_required = array('metadata_owner_guid', 'metadata_owner_guids', 'metadata_name', 'metadata_names', 'metadata_value', 'metadata_values'); $required = array_merge($required, $metadata_required); break; case 'annotation': $annotations_required = array('annotation_owner_guid', 'annotation_owner_guids', 'annotation_name', 'annotation_names', 'annotation_value', 'annotation_values'); $required = array_merge($required, $annotations_required); break; } $options = array(); $this->assertFalse(_elgg_is_valid_options_for_batch_operation($options, $type)); // limit alone isn't valid: $options = array('limit' => 10); $this->assertFalse(_elgg_is_valid_options_for_batch_operation($options, $type)); foreach ($required as $key) { $options = array(); $options[$key] = ELGG_ENTITIES_ANY_VALUE; $this->assertFalse(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = ELGG_ENTITIES_ANY_VALUE"); $options[$key] = ELGG_ENTITIES_NO_VALUE; $this->assertFalse(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = ELGG_ENTITIES_NO_VALUE"); $options[$key] = false; $this->assertFalse(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = bool false"); $options[$key] = true; $this->assertTrue(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = bool true"); $options[$key] = 'test'; $this->assertTrue(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = 'test'"); $options[$key] = array('test'); $this->assertTrue(_elgg_is_valid_options_for_batch_operation($options, $type), "Sent {$key} = array('test')"); } } }
/** * Disables annotations based on $options. * * @warning Unlike elgg_get_annotations() this will not accept an empty options array! * * @param array $options An options array. {@See elgg_get_annotations()} * @return bool|null true on success, false on failure, null if no annotations disabled. * @since 1.8.0 */ function elgg_disable_annotations(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'annotation')) { return false; } $options['metastring_type'] = 'annotations'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', false); }
/** * Disables metadata based on $options. * * @warning Unlike elgg_get_metadata() this will not accept an empty options array! * * @param array $options An options array. {@See elgg_get_metadata()} * @return bool|null true on success, false on failure, null if no metadata disabled. * @since 1.8.0 */ function elgg_disable_metadata(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'metadata')) { return false; } _elgg_get_metadata_cache()->invalidateByOptions('disable', $options); $options['metastring_type'] = 'metadata'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', false); }