public function enable($recursive = true)
{
$guid = (int) $this->guid;
if (!$guid) {
return false;
}
if (!_elgg_services()->events->trigger('enable', $this->type, $this)) {
return false;
}
if (!$this->canEdit()) {
return false;
}
global $CONFIG;
// Override access only visible entities
$old_access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$result = $this->getDatabase()->updateData("UPDATE {$CONFIG->dbprefix}entities\n\t\t\tSET enabled = 'yes'\n\t\t\tWHERE guid = {$guid}");
$this->deleteMetadata('disable_reason');
$this->enableMetadata();
$this->enableAnnotations();
if ($recursive) {
$disabled_with_it = elgg_get_entities_from_relationship(array('relationship' => 'disabled_with', 'relationship_guid' => $guid, 'inverse_relationship' => true, 'limit' => 0));
foreach ($disabled_with_it as $e) {
$e->enable();
remove_entity_relationship($e->guid, 'disabled_with', $guid);
}
}
access_show_hidden_entities($old_access_status);
if ($result) {
$this->attributes['enabled'] = 'yes';
_elgg_services()->events->trigger('enable:after', $this->type, $this);
}
return $result;
}