1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Delete specific Contenttype Attachments

Discussion in 'XenForo Development Discussions' started by ragtek, Mar 1, 2011.

  1. ragtek

    ragtek Guest

    I have several ADd-ons using an own attachment handler.

    When i uninstall the add-on, the attachments are still in the database, associated to articles and my downloadmanager.

    So when i install the add-on again, the attachments will be shown again in the new articles.

    Is there a method providen by the framework i can use on uninstall, or do i need to delete them which an own query?

    thx
     
  2. Mike

    Mike XenForo Developer Staff Member

    You'd need to delete them with your own query - or at least remove the association.
     
  3. ajnos

    ajnos Member

    Would it be possible, that you guys create some delete methods for the node & content type models, so that 3rd party add-ons which are creating own contenttypes & nodetypes could use them for the unstinall process?
    I think this should be handled with the framework and not through "own uninstall code"


    I'm working on our uninstall code and it "sucks" a little bit.

    I have to:

    1. delete my own tables
    2. delete the new node type from the node_type table
    3. delete all existing nodes with my own node type
    4. delete own content types from xf_content_type
    5. delete own content type fields from xf_content_type_field
    6. delete attachments from attachment, attachment_data & attachment_view or unassociate the attachments associated to this content_type

    thx
    ajnos
     
  4. ajnos

    ajnos Member

    PHP:
          $queries['delete_attachments'] = "
            UPDATE xf_attachment
            set unassociated = 1
            WHERE content_type = '" 
    Ragtek_AS_Constants::CONTENT_TYPE "'
            "
    ;
    It seems that this is the easiest way, because the cleanup cronjob would delete them:)
     
    Mike likes this.
  5. ragtek

    ragtek Guest

    Oh man:(
    There are much more things, where the uninstall code needs to take care:(
    It also needs to delete all mod & reportcenter entries:(, likes, alerts, news,etc...

    It would be really nice, if this should be handled by the framework
     
    Onimua and Jeremy P like this.
  6. ragtek

    ragtek Guest

Share This Page