1
0
www.mikescher.com/www/protected/controllers/SiteController.php

97 lines
1.8 KiB
PHP
Raw Normal View History

2014-05-13 12:40:42 +02:00
<?php
class SiteController extends Controller
{
2014-05-14 11:15:32 +02:00
public $selectedNav = '';
2014-05-13 12:40:42 +02:00
public function actionIndex()
{
2014-05-28 09:35:46 +02:00
$data = array();
$data['program'] = ProgramHelper::GetDailyProg();
2014-05-28 09:35:46 +02:00
$this->render('index', $data);
2014-05-13 12:40:42 +02:00
}
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
2014-05-14 11:15:32 +02:00
public function actionAbout()
2014-05-13 12:40:42 +02:00
{
2014-05-14 14:14:45 +02:00
$data = array();
if(isset($_POST['SendMailForm']))
{
$model = new SendMailForm();
$model->attributes=$_POST['SendMailForm'];
if($model->validate()) {
if ($model->send())
{
$data['alerts_success'][] = "Successfully send mail from " . $model->name;
$data['model'] = new SendMailForm();
}
else
{
$data['alerts_error'][] = "Internal error while sending mail";
$data['model'] = $model;
}
}
else
{
$data['model'] = $model;
}
}
else
{
$data['model'] = new SendMailForm();
}
2014-05-28 10:38:11 +02:00
$this->render('about', $data);
}
2014-05-14 14:14:45 +02:00
2014-05-28 10:38:11 +02:00
/**
* Displays the login page
*/
public function actionLogin()
{
$model=new LoginForm;
2014-05-14 14:14:45 +02:00
2014-05-28 10:38:11 +02:00
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo TbActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login', array('model'=>$model));
}
/**
* Logs out the current user and redirect to homepage.
*/
public function actionLogout()
{
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
2014-05-13 12:40:42 +02:00
}
}