Disabling entity in elgg

I want to disable a river item, but not want to delete it , is the enable option is setting to "no" in entity table is the best idea for this ? Also how can i setup to show the disabled item for admin user only ?

  • somebody, please help?

  • River table has it's own enabled column. I guess you could change the value there, though updating the database entries directly is discouraged, but I don't see any public API in core to do that.

    You can disable an entity using:

    $object = $river->getObjectEntity();
    if ($object) {
       $object->disable('Some reason for disabling');
    }
    
  • @Ismayil Thanks

    Why it is discouraged updating the database entry directly ? The problem is Iam using elgg 1.8 which doesn't support river item have its own enabled colom in database, can you provide a solution on this ?

  • Status updates trigger a series of hooks and events. If you update the database directly you may break data integrity that plugins maybe relying on. Disabling an entity is a recursive process - you will want all other entities contained by the entity disabled as well.

  • show the disabled item for admin user only

    AFAIK none of the built-in Elgg pages show disabled entities. Before a query you can "turn them on" via access_show_hidden_entities(true) (not meant to be used by plugins!) to allow them to be found by queries, but I don't know how well they'll behave in the process of rendering them. We don't test this.

  • @Steve

    would you please explain where we can call this function to make it work even as currently the entity is disabled in entities table, can you trace out that coding part ?

     

    @Ismayil

    Yes, that refers comments and likes of the content will also disabled as well is it?, can you shed an idea how can we achieve this ?is elgg_delete_river() is achieving same by keeping the integrity ?

     

  • Disabling an entity is a recursive process - you will want all other entities contained by the entity disabled as well.

     Can you explain is it about setting enabled=no for the comments and likes of the entity in annotation and metadata table ?

  • Start by explaining what you are trying to do. You seem to be operating under wrong impressions about the data model.

    River represents an event on the system and it references the actor and the object. Disabling or deleting a river has no effect on entities. You can have mutiple river entries for the same event (e.g. with different access levels).

    Deleting or disabling an actor or an object will also delete ir disable all river items associated with it.

    Deleting or disabling an entity will recursively delete or diable contained entities including comments. I am not sure about annotations off-hand.

  • Start by explaining what you are trying to do. You seem to be operating under wrong impressions about the data model.

    @Ismayil Thanks for your feedback. I already represented it in my previous posts that

    I want to disable a river item, but not want to delete it , is the enable option is setting to "no" in entity table is the best idea for this ?

    But Iam using elgg 1.8 and it doesn't have option to disable the river item in river table but new version may have..

    River represents an event on the system and it references the actor and the object. Disabling or deleting a river has no effect on entities.

    But when we set enable = no in entities table for the corresponding river item, it got hidden from the river list. why ?

    Deleting or disabling an actor or an object will also delete ir disable all river items associated with it.

    Sorry I don't understand the above scenario can you please explain and how we can achieve it ?

  • Can anybody explain ? above ? having good knowledge in elgg core ?