disable() public method

Disabled entities are not returned by getter functions. To enable an entity, use {@link \ElggEntity::enable()}. Recursively disabling an entity will disable all entities owned or contained by the parent entity. You can ignore the disabled field by using {@link access_show_hidden_entities()}.
See also: ElggEntity::enable()
public disable ( string $reason = "", boolean $recursive = true ) : boolean
$reason string Optional reason
$recursive boolean Recursively disable all contained entities?
return boolean
Example #1
0
 public function testElggEntityRecursiveDisableAndEnable()
 {
     global $CONFIG;
     $obj1 = new \ElggObject();
     $obj1->container_guid = $this->entity->getGUID();
     $obj1->save();
     $obj2 = new \ElggObject();
     $obj2->container_guid = $this->entity->getGUID();
     $obj2->save();
     // disable $obj2 before disabling the container
     $this->assertTrue($obj2->disable());
     // disable entities container by $this->entity
     $this->assertTrue($this->entity->disable());
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'");
     $this->assertIdentical($entity->enabled, 'no');
     // enable entities that were disabled with the container (but not $obj2)
     $this->assertTrue($this->entity->enable());
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'");
     $this->assertIdentical($entity->enabled, 'yes');
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj2->guid}'");
     $this->assertIdentical($entity->enabled, 'no');
     // cleanup
     $this->assertTrue($obj2->enable());
     $this->assertTrue($obj2->delete());
     $this->assertTrue($obj1->delete());
 }
Example #2
0
 public function testDisableBeforeSaved()
 {
     // false on disable because it's not saved yet.
     $this->assertFalse($this->obj->disable());
 }
Example #3
0
 /**
  * Disable the site
  *
  * @note You cannot disable the current site.
  *
  * @param string $reason Optional reason for disabling
  *
  * @return bool
  * @throws SecurityException
  */
 public function disable($reason = "")
 {
     global $CONFIG;
     if ($CONFIG->site->getGUID() == $this->guid) {
         throw new SecurityException('SecurityException:deletedisablecurrentsite');
     }
     return parent::disable($reason);
 }
Example #4
0
 /**
  * Disable the site
  *
  * @note You cannot disable the current site.
  *
  * @param string $reason    Optional reason for disabling
  * @param bool   $recursive Recursively disable all contained entities?
  *
  * @return bool
  * @throws SecurityException
  */
 public function disable($reason = "", $recursive = true)
 {
     global $CONFIG;
     if ($CONFIG->site->getGUID() == $this->guid) {
         throw new \SecurityException('You cannot disable the current site');
     }
     return parent::disable($reason, $recursive);
 }