120 lines
4.6 KiB
PHP
120 lines
4.6 KiB
PHP
<?php
|
|
/**
|
|
* app/controllers/home.php
|
|
*
|
|
* This is the home or 'index' controller.
|
|
*
|
|
* @version 3.0
|
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
* @link https://TheTempusProject.com
|
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
*/
|
|
namespace TheTempusProject\Controllers;
|
|
|
|
use TheTempusProject\Hermes\Functions\Redirect;
|
|
use TheTempusProject\Bedrock\Functions\Session;
|
|
use TheTempusProject\Bedrock\Functions\Check;
|
|
use TheTempusProject\Bedrock\Functions\Input;
|
|
use TheTempusProject\Hermes\Functions\Route as Routes;
|
|
use TheTempusProject\Houdini\Classes\Issues;
|
|
use TheTempusProject\Houdini\Classes\Views;
|
|
use TheTempusProject\Houdini\Classes\Components;
|
|
use TheTempusProject\Houdini\Classes\Template;
|
|
use TheTempusProject\Classes\Controller;
|
|
use TheTempusProject\Classes\Forms;
|
|
use TheTempusProject\TheTempusProject as App;
|
|
|
|
class Home extends Controller {
|
|
public function index() {
|
|
self::$title = '{SITENAME}';
|
|
self::$pageDescription = 'This is the homepage of your new Tempus Project Installation. Thank you for installing. find more info at https://thetempusproject.com';
|
|
Views::view( 'index' );
|
|
}
|
|
|
|
public function login() {
|
|
self::$title = 'Portal - {SITENAME}';
|
|
self::$pageDescription = 'Please log in to use {SITENAME} member features.';
|
|
if ( App::$isLoggedIn ) {
|
|
return Issues::add( 'notice', 'You are already logged in. Please <a href="' . Routes::getAddress() . 'home/logout">click here</a> to log out.' );
|
|
}
|
|
if ( !Input::exists() ) {
|
|
return Views::view( 'login' );
|
|
}
|
|
if ( !Forms::check( 'login' ) ) {
|
|
Issues::add( 'error', [ 'There was an error with your login.' => Check::userErrors() ] );
|
|
return Views::view( 'login' );
|
|
}
|
|
if ( !self::$user->logIn( Input::post( 'username' ), Input::post( 'password' ), Input::post( 'remember' ) ) ) {
|
|
Issues::add( 'error', 'Username or password was incorrect.' );
|
|
return Views::view( 'login' );
|
|
}
|
|
Session::flash( 'success', 'You have been logged in.' );
|
|
if ( Input::exists( 'rurl' ) ) {
|
|
Redirect::to( Input::post( 'rurl' ) );
|
|
} else {
|
|
Redirect::to( 'home/index' );
|
|
}
|
|
}
|
|
|
|
public function logout() {
|
|
self::$title = 'Log Out - {SITENAME}';
|
|
Template::noIndex();
|
|
if ( !App::$isLoggedIn ) {
|
|
return Issues::add( 'notice', 'You are not logged in.' );
|
|
}
|
|
self::$user->logOut();
|
|
Session::flash( 'success', 'You have been logged out.' );
|
|
Redirect::to( 'home/index' );
|
|
}
|
|
|
|
public function profile( $id = null ) {
|
|
self::$title = 'User Profile - {SITENAME}';
|
|
self::$pageDescription = 'User Profiles for {SITENAME}';
|
|
if ( !App::$isLoggedIn ) {
|
|
return Issues::add( 'notice', 'You must be logged in to view this page.' );
|
|
}
|
|
$user = self::$user->get( $id );
|
|
if ( !$user ) {
|
|
return Issues::add( 'notice', 'No user found.' );
|
|
}
|
|
self::$title = $user->username . '\'s Profile - {SITENAME}';
|
|
self::$pageDescription = 'User Profile for ' . $user->username . ' - {SITENAME}';
|
|
Views::view( 'profile', $user );
|
|
}
|
|
|
|
public function terms() {
|
|
self::$title = 'Terms and Conditions - {SITENAME}';
|
|
self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
|
|
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
|
|
Views::raw( '<div class="terms-page">{TERMS}</div>' );
|
|
}
|
|
|
|
public function hashtag( $id = null ) {
|
|
self::$title = 'HashTag - {SITENAME}';
|
|
self::$pageDescription = 'HashTags for {SITENAME}';
|
|
if ( !App::$isLoggedIn ) {
|
|
return Issues::add( 'notice', 'You must be logged in to view this page.' );
|
|
}
|
|
// this should look up comments and blog posts with the hashtag in them
|
|
Views::view( 'hashtags' );
|
|
}
|
|
|
|
public function about() {
|
|
self::$title = 'About - {SITENAME}';
|
|
self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
|
|
Views::view( 'switches' );
|
|
}
|
|
|
|
public function contact() {
|
|
self::$title = 'contact - {SITENAME}';
|
|
self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
|
|
Views::view( 'contact' );
|
|
}
|
|
|
|
public function privacy() {
|
|
self::$title = 'privacy - {SITENAME}';
|
|
self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
|
|
Views::view( 'privacy' );
|
|
}
|
|
}
|