Exemplo n.º 1
0
 /**
  * Disables annotations for this entity, optionally based on name.
  *
  * @param string $name An options name of annotations to disable.
  * @return bool
  * @since 1.8
  */
 public function disableAnnotations($name = '')
 {
     $options = array('guid' => $this->guid, 'limit' => 0);
     if ($name) {
         $options['annotation_name'] = $name;
     }
     return elgg_disable_annotations($options);
 }
 /**
  * Ensure that \ElggBatch doesn't go into infinite loop when disabling annotations recursively when show hidden is enabled.
  *
  * https://github.com/Elgg/Elgg/issues/5952
  */
 public function test_disabling_annotations_infinite_loop()
 {
     //let's have some entity
     $group = new \ElggGroup();
     $group->name = 'test_group';
     $group->access_id = ACCESS_PUBLIC;
     $this->assertTrue($group->save() !== false);
     $total = 51;
     //add some annotations
     for ($cnt = 0; $cnt < $total; $cnt++) {
         $group->annotate('test_annotation', 'value_' . $total);
     }
     //disable them
     $show_hidden = access_get_show_hidden_status();
     access_show_hidden_entities(true);
     $options = array('guid' => $group->guid, 'limit' => $total);
     elgg_disable_annotations($options);
     access_show_hidden_entities($show_hidden);
     //confirm all being disabled
     $annotations = $group->getAnnotations(array('limit' => $total));
     foreach ($annotations as $annotation) {
         $this->assertTrue($annotation->enabled == 'no');
     }
     //delete group and annotations
     $group->delete();
 }
Exemplo n.º 3
0
 public function testElggAnnotationExists()
 {
     $e = new ElggObject();
     $e->save();
     $guid = $e->getGUID();
     $this->assertFalse(elgg_annotation_exists($guid, 'test_annotation'));
     $e->annotate('test_annotation', rand(0, 10000));
     $this->assertTrue(elgg_annotation_exists($guid, 'test_annotation'));
     // this metastring should always exist but an annotation of this name should not
     $this->assertFalse(elgg_annotation_exists($guid, 'email'));
     $options = array('guid' => $guid, 'limit' => 0);
     $this->assertTrue(elgg_disable_annotations($options));
     $this->assertTrue(elgg_annotation_exists($guid, 'test_annotation'));
     $this->assertTrue($e->delete());
     $this->assertFalse(elgg_annotation_exists($guid, 'test_annotation'));
 }