lozzd/Nagdash — pull request #21 by mrtazz (2014-05-03 22:35:10+00:00)
Title: Kinda massive refactor

I realize this is a massive change (and it's only half way done), but I wanted to get your opinion on it before proceeding, so it's basically more a PoC right now. While looking at the code and thinking about adding support for another nagios library I constantly got lost trying to understand how it works. The main problems for me were:

- `nagdash.php` basically does everything
- a lot of touching points to add a new API
- decent amount of global variables which makes it hard to follow code

So I took a stab at refactoring it with the following goals in mind:

- separation of concerns in the code
- clear path where code and data comes from
- easy addition of new APIs

So far I have mostly changed backend code, meaning a new API can now be added by implementing the interface `iNagiosConnection` and adding it to the switch statement in `fetch_state`. The rest should just work then. This also opens the door for easier testing of functionality. I still want to move the frontend code to something more template like (still plain php but more HTML with interleaved php so it's easier to edit and see what's going on) and clean up the backend code a bit more. And I also still need to add the action functionalities back in (ack, downtime, silence, etc.).

But first of all I wanted to check if you think that makes sense for the project and if you would like to have that in there or rather keep it the old way? :)