Beispiel #1
0
 /**
  * Disable this entity.
  *
  * Disabled entities are not returned by getter functions.
  * To enable an entity, use {@link enable_entity()}.
  *
  * Recursively disabling an entity will disable all entities
  * owned or contained by the parent entity.
  *
  * @internal Disabling an entity sets the 'enabled' column to 'no'.
  *
  * @param string $reason    Optional reason
  * @param bool   $recursive Recursively disable all contained entities?
  *
  * @return bool
  * @see enable_entity()
  * @see ElggEntity::enable()
  */
 public function disable($reason = "", $recursive = true)
 {
     if ($r = disable_entity($this->get('guid'), $reason, $recursive)) {
         $this->attributes['enabled'] = 'no';
     }
     return $r;
 }
Beispiel #2
0
 /**
  * Disable this entity.
  * 
  * @param string $reason Optional reason
  * @param bool $recursive Recursively disable all contained entities?
  */
 public function disable($reason = "", $recursive = true)
 {
     return disable_entity($this->get('guid'), $reason, $recursive);
 }
Beispiel #3
0
 public function testElggEntityRecursiveDisableWhenLoggedOut()
 {
     $e1 = new ElggObject();
     $e1->access_id = ACCESS_PUBLIC;
     $e1->owner_guid = 0;
     $e1->container_guid = 0;
     $e1->save();
     $guid1 = $e1->getGUID();
     $e2 = new ElggObject();
     $e2->container_guid = $guid1;
     $e2->access_id = ACCESS_PUBLIC;
     $e2->owner_guid = 0;
     $e2->save();
     $guid2 = $e2->getGUID();
     // fake being logged out
     $user = $_SESSION['user'];
     unset($_SESSION['user']);
     $ia = elgg_set_ignore_access(true);
     $this->assertTrue(disable_entity($guid1, null, true));
     // "log in" original user
     $_SESSION['user'] = $user;
     elgg_set_ignore_access($ia);
     $this->assertFalse(get_entity($guid1));
     $this->assertFalse(get_entity($guid2));
     $db_prefix = get_config('dbprefix');
     $q = "SELECT * FROM {$db_prefix}entities WHERE guid = {$guid1}";
     $r = get_data_row($q);
     $this->assertEqual('no', $r->enabled);
     $q = "SELECT * FROM {$db_prefix}entities WHERE guid = {$guid2}";
     $r = get_data_row($q);
     $this->assertEqual('no', $r->enabled);
     access_show_hidden_entities(true);
     delete_entity($guid1);
     delete_entity($guid2);
     access_show_hidden_entities(false);
 }
Beispiel #4
0
 /**
  * Disable entities but don't delete them
  *
  * @param string $reason Reason of deletion
  * @param int $limit
  * @param int $offset
  * @return int
  */
 public function disable($reason = '', $limit = null, $offset = null)
 {
     $entities = $this->find($limit, $offset);
     $count = 0;
     foreach ($entities as $entity) {
         disable_entity($entity->guid, $reason);
         $count++;
     }
     return $count;
 }
Beispiel #5
0
 /**
  * Disable this entity.
  * 
  * @param string $reason Optional reason
  */
 public function disable($reason = "")
 {
     return disable_entity($this->get('guid'), $reason);
 }