2014-05-13 12:40:42 +02:00
|
|
|
<?php
|
|
|
|
|
2014-06-04 09:33:24 +02:00
|
|
|
class MSMainController extends MSController
|
2014-05-13 12:40:42 +02:00
|
|
|
{
|
2014-06-06 19:31:05 +02:00
|
|
|
/**
|
|
|
|
* @return array action filters
|
|
|
|
*/
|
|
|
|
public function filters()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'accessControl',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies the access control rules.
|
|
|
|
* This method is used by the 'accessControl' filter.
|
|
|
|
* @return array access control rules
|
|
|
|
*/
|
|
|
|
public function accessRules()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('allow',
|
|
|
|
'actions'=>array('index', 'about', 'debugerror', 'error', 'login', 'logout'),
|
|
|
|
'users'=>array('*'),
|
|
|
|
),
|
|
|
|
array('allow',
|
|
|
|
'actions'=>array('admin'),
|
|
|
|
'users'=>array('admin'),
|
|
|
|
),
|
|
|
|
array('deny',
|
|
|
|
'users'=>array('*'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-05-13 12:40:42 +02:00
|
|
|
public function actionIndex()
|
|
|
|
{
|
2014-06-06 12:02:56 +02:00
|
|
|
$criteria = new CDbCriteria;
|
|
|
|
$criteria->order = "date DESC";
|
|
|
|
|
|
|
|
$all_log = Log::model()->findAll($criteria);
|
|
|
|
/* @var $all_log Log[] */
|
2014-05-28 09:35:46 +02:00
|
|
|
|
2014-06-06 12:02:56 +02:00
|
|
|
$data = array();
|
2014-05-28 11:02:52 +02:00
|
|
|
$data['program'] = ProgramHelper::GetDailyProg();
|
2014-06-06 12:02:56 +02:00
|
|
|
$data['logs'] = $all_log;
|
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-28 17:19:57 +02:00
|
|
|
public function actionDebugError()
|
|
|
|
{
|
|
|
|
if($error=Yii::app()->errorHandler->error)
|
|
|
|
{
|
|
|
|
if(Yii::app()->request->isAjaxRequest)
|
|
|
|
echo $error['message'];
|
|
|
|
else
|
|
|
|
$this->render('debugerror', $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();
|
|
|
|
|
2014-06-07 19:53:13 +02:00
|
|
|
$this->js_scripts[] = file_get_contents('protected/components/extendedGitGraph/script.js');
|
|
|
|
|
2014-05-14 14:14:45 +02:00
|
|
|
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
|
|
|
public function actionLogin()
|
|
|
|
{
|
2014-06-06 19:31:05 +02:00
|
|
|
$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));
|
|
|
|
}
|
|
|
|
|
2014-06-06 19:31:05 +02:00
|
|
|
public function actionAdmin()
|
|
|
|
{
|
2014-06-07 19:53:13 +02:00
|
|
|
if (isset($_GET['do_egh_update']) && $_GET['do_egh_update'] == '1') {
|
|
|
|
$this->layout = null;
|
|
|
|
$this->render('admin_updateEGH', array());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-06 19:31:05 +02:00
|
|
|
$this->render('admin', array());
|
|
|
|
}
|
|
|
|
|
2014-05-28 10:38:11 +02:00
|
|
|
public function actionLogout()
|
|
|
|
{
|
|
|
|
Yii::app()->user->logout();
|
|
|
|
$this->redirect(Yii::app()->homeUrl);
|
2014-05-13 12:40:42 +02:00
|
|
|
}
|
2014-06-06 12:02:56 +02:00
|
|
|
|
|
|
|
public function actionLog($logid) {
|
|
|
|
|
|
|
|
}
|
2014-05-13 12:40:42 +02:00
|
|
|
}
|