The Framework Code

class/pages/profile.php

File List

<?php
/**
 * A class that contains code to handle any requests for  /profile/
 */
     namespace Pages;

     use \Support\Context as Context;
     use \Config\Config as Config;
/**
 * Support /profile/
 */
    class Profile extends \Framework\Siteaction
    {
/**
 * Handle profile operations
 *
 * @param object	$context	The context object for the site
 *
 * @return string	A template name
 */
        public function handle(Context $context)
        {
            $fdt = $context->formdata();
            if ($context->web()->ispost())
            {
                $user = $context->user();
                $email = $fdt->post('email', '');
                $change = FALSE;
                if ($email !== '' && $email != $user->email)
                {
                    if (filter_var($email, FILTER_VALIDATE_EMAIL) !== FALSE)
                    {
                        $user->email = $email;
                        $change = TRUE;
                    }
                    else
                    {
                        $context->local()->message(\Framework\Local::ERROR, 'Please enter a valid email address');
                    }
                }
                $pw = $fdt->post('password', '');
                $rpw = $fdt->post('repeat', '');
                if ($pw !== '')
                {
                    if ($pw == $rpw)
                    {
                        $user->setpw($pw);
                        $change = TRUE;
                    }
                    else
                    {
                        $context->local()->message(\Framework\Local::ERROR, 'Passwords do not match');
                    }
                }
                if ($change)
                {
                    \R::store($user);
                    $context->local()->message(\Framework\Local::MESSAGE, 'Done');
                }
            }
            return '@content/profile.twig';
        }
    }
?>