fossasia / engelsystem

Shift planning system for events.

Home Page:http://engelsystem.de

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement MVC model

mariobehling opened this issue · comments

Due to the process the application was developed there is no clear MVC model.

  • Please propose a way to change all components and code structure to a clean Model View Controller model (MVC).
  • Create a list of issues here (in this parent issue) and link them.
  • Get other contributors around you to take on issues
  • Document all changes in a blog post.

Current condition:

  • The code base seems to be structured in MVC. There are folders: model, view, controller, pages.
  • Code in pages seems to be a mix of model and controller. By reading public/index.php, you can see that functions in pages act as controller. But it has SQL queries inside, which should be placed in model.

So I think what we have to do is to redo the pages code.

MVC is a standard 3-tier architecture.
By adding a new tier "page", I think there must be some intention for doing that. We should ask the creator before making change to the architecture.

@vuhung The origin of Engelsystem is long ago and @msquare has already started to implement MVC. So, he would be happy if this is implemented as it would make life easier for everyone.

@kamishettysreeja25 Please outline your ideas and what you plan to do before you start.

@mariobehling I will propose a plan and outline a way to change all components and code structure to a clean Model View Controller model by today.

Presently there are 26 pages. we need to create controller files for all of them. For the pages which access SQL query we need to separate them into model files. There are only model files for a few pages. We should also add view to render the html or forms for some of the pages.
Pages

admin_active.php
admin_arrive.php
admin_export.php
admin_free.php
admin_groups.php
admin_import.php
admin_log.php
admin_news.php
admin_questions.php
admin_rooms.php
admin_settings.php
admin_shifts.php
admin_user.php
guest_credits.php
guest_login.php
guest_start.php
guest_stats.php
user_atom.php
user_ical.php
user_messages.php
user_myshifts.php
user_news.php
user_questions.php
user_settings.php
user_shifts.php

Model

AngelType_model.php
LogEntries_model.php
Message_model.php
NeededAngelTypes_model.php
Room_model.php
Settings_model.php
ShiftEntry_model.php
ShiftTypes_model.php
Shifts_model.php
UserAngelTypes_model.php
UserDriverLicenses.model.php
User_model.php

Controller

angeltype_controller.php
rooms_controller.php
shifts_controller.php
shifttypes_controller.php
user_angeltypes_controller.php
user_driver_licenses_controller.php
user_controller.php

view

AngelTypes_view.php
Questions_view.php
Rooms_view.php
ShiftEntry_view.php
ShiftTypes_view.php
Shifts_view.php
UserAngelTypes_view.php
UserDriverLicenses_view.php
User_view.php


For Example, We are having admin_shifts.php which access both theshifts model and controller file.We need to move the content to controller and create a view file for admin_shifts.

This is a big issue. I will create smaller issues. There are 26 pages. I would like to even reduce the NP complexity by re factoring the code into smaller functions. Each will consists of modifying 3 pages and making them MVC structured.

Deleted all the admin pages and created admin controller pages. Updates install.sql, update.sql, engelsystem_provider.php, sys_menu.php.
#168
#169
#170
#171
#172
Commits: a2b3d06

Where is the pull request? Who reviewed this?

@mariobehling This issue is completed. Now code structure is in MVC model.
There are sys files like template, auth, log, menu, page. These files can also be moved to controller, model, view folder. Should I move them and remove includes folder or should I leave it in the same structure.

@mariobehling
This issue is completed. Implemented a MVC model for all the pages. We can close this.

Great! Good job both of you!