Skip Navigation

Text Only/ Printer-Friendly

The No Delete Module

The NoDeleteModule is a new concept to reason3. In reason2, on the lister page for the tree module, we didn’t show the delete button for things that had children. The idea behind this is clear. If something has children and gets deleted, then its children are essentially no longer part of the site. In reason3, the delete button no longer shows up as part of the lister, but as an option for the entity. We took the idea of not being able to delete something, and extended it to anything that was on the right side of a required one-to-many relationship.

For instance, in the past, there was an athletics event that was not associated with a sport. This (due partly to programming errors) cause the main page of the athletics site to crash. In theory, everything should be associated with a sport, so we programmed it in that way. The point of this is, that if somebody tried to delete a sport, there would be many entities that would be hung out to dry. Now, if somebody wanted to delete a sport, they would have to go to that entity and either preview and edit it. When they look over to the side for the link that says “Delete”, they will instead see something that says “Deletion not available”, and then in small text, a link that says “Explain”. This link takes you to the no delete page.

How it works

We will start with the run module, and will talk about the init module later. One of the first things you see at the top of the module is an array called $text. This array is the text that is to be printed out. There are two that are set up as defaults. One which is actually called default, which is shown in most cases, and a second called root node.

The root node is a very specific case which requires some explanation. First of all, you have to understand the defenition of a root node. In our system, a root node is defined to be a page (or some other type) which is the parent of itself. Defining it this way makes thingsa bit simpler. If you instead didn’t give the root node a parent, it would be impossible to distinguish between the root page, and a page that just doesn’t have a parent for some reason. So, since the root node is the parent of itself, it falls on the left and right side of a required one-to-many relationship. So in order to delete a root node, you would first have to delete that root node, or change its relationship. This is clearly bad, so if something is a root node, we simply give the user saying that if they really want to delete that entity, they need to contact a system administrator.

The other nodes have a bigger task. We check to see if there is an index in our $text array that is the same as the current type_id. If there is, we use that text, otherwise, we use the default. After that, we loop through all the entities that are associated and make links to the preview page for each of them. These links should open in a new window.

Now back to the init function. Since each of the links open in a new page, people can go through these one by one, and then come back to the explanation page. If they’ve successfully changed or deleted all these entities, they will then be redirected to the delete page.