/sundial-xc

Time banking web application

Primary LanguagePHP

About Sundial XC

Sundial XC is a software to facilitate time bakning and to support local communities built around the idea of time bank. If you want to know more about the concept of "time banks" - and you really should - just look up prof. Edgar Cahn on YouTube.

This software is not of production quality yet. You are advised to test it thoroughly before running your time bank on it.

Sundial XC is distributed under terms of GNU Affero General Public License version 3.0 or later.

Credits and history

Sundial XC is a fork followed by rewrite of:

Setup

To install Sundial XC you need a web server with PHP 5.3+ and MySQL 5.1+.

Refactoring old code

So far the following architectural changes were made:

  • Global defines were replaced with Config singleton and can be controlled via config/*.json file. Existing config parameters can be found in legacy section.
  • Use of global $cDB object was replaced with PDO and PDOHelper singleton. All database queries are now run as prepared statements. Parameter escaping is handled automatically via bound parameters. Database connection details are controlled by config section database. Separate db silos are provided for testing and normal opration.
  • Use of global $cErr class was replaced with Debug class and multiple logging backend. File logging is handled by class LogWriterFile, while on-screen logging is handled by class LogWriterScreen. Writers can be controlled in config section log. Error and exception handlers are set up to intercepts all such events and forward them to Debug.
  • In-line HTML was separated from business logic and replaced with templates and views. Page wrapper was created to provide common header/footer and notification area. All template strings are automatically escaped.
  • Forms were extracted from pages and moved to separate files. Unified form validation was added. CSRF checks were added. Fixes in QuickForm component were made to make it compatible with PHP 5.3.
  • Code from page files was moved to controllers. Essential controllers completely replaced existing page files, other are used as wrappers for such files. Controllers can be annotated to allow access control, page title setting, HTTP response codes, etc.
  • Model code was extracted to separate files. UI related code removed or replaced with views and templates.
  • Leftovers from legacy code were moved to legacy directory.
  • Fully asynchronous Cron mechanism was added. Email messages are now being recorded and dispatched by cron job.
  • Database migration system was developed with schema versioning and full upgrade/downgrade track.
  • REST API endpoint was created.

Code refactor is progressing in many fronts simultaneously:

  • Controllers. Legacy php files from root directory are being trainsitioned into controller actions. See directory controllers/ to see how this is done. Files not yet transitioned are included from within controllers. If you want to help moving this code, this is probably the easiest bit to start with.
  • Forms. Old in-line forms are extracted to forms/ directory as standalone, reusable, loosely coupled components. This is also a good place to begin helping. Look at some of existing forms and start extracting in-code ones from legacy php files to separate classes.
  • Templates. PHTML templates are extracted from old in-line code to separate files that match controller action names. See directory templates/pages/ to get to the core of this change.
  • Model. Business logic is broken into separate files in model/legacy/ directory. The biggest part in this field is to migrate from using global $cDB object to PDOHelper. Another challenge is to free the model from UI rendering code.

Controllers are now heavily annotated. This is the meaning of some annotations:

  • @Title "some string" - HTML page title.
  • @Public - page accessible to non logged in users.
  • @Level 1 - access allowed only to users with given privilege level.
  • @ResponseCode 404 - HTTP response code.
  • @Page "some_file.phtml" - directive to use different than default template file for certain action.

Future versions

  • Internationalization with gettext. Yeah, currently it's in Spanish.
  • Database normalization. You will see the need for this one as soon as you look into existing database.
  • Migration script from Local-Excahnge-UK.
  • Restful API version 0.0. API for existing model classes shielded by authorization layer. Covered in 100% with tests.
  • Android client. Nice to have to explore correctness and completeness of API v 0.0.
  • Interoperability between instances of Sundial XC. Very important to connect members not only within community but also across communities.