Beispiel #1
0
    $ROOT_PATH = $_SERVER['DOCUMENT_ROOT'];
    include_once $ROOT_PATH . '/src/bootstrap.php';

    use Moood\User\UserActions;
    use Moood\helpers\Utils;

    // Execute the current action (if any)
    // In real application i will not do it this way,
    // i would have use Zend framework with views actions and forms.

    // We need to execute action only after the user has filled in the details.
    // we can know it by checking if there is a userId in the form
    if (Utils::getParam("id", null) != null) {
        $action = new UserActions();
        $action->processRequest();
    }

    // We use this page for registration and for updating the user details.
    // First of all check to see if this is a register or details page
    $isUpdate = isset($_GET['action']) && $_GET['action'] === 'update';

    // We use the same form for registration and for updating user information.
    // Find out if this is a registration or update action
    if ($isUpdate) {
        $userData = $_SESSION['user']->getUserData();
        $id = $userData['id'];
        $username = $userData['username'];
        $password = $userData['password'];

        $nick_name = $userData['nick_name'];
<?php

use Moood\User\UserActions;
// This file will simply execute the desired action.
// It will contain no code. All the logic is inside the Actions class.
// The file is invoked using Ajax
include_once $_SERVER['DOCUMENT_ROOT'] . '/src/bootstrap.php';
// Simply execute the action and return JSON as reply
$users = new UserActions();
$users->processRequest();