<?php

class PaperController extends Controller
{
	/**
	* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	* using two-column layout. See 'protected/views/layouts/column2.php'.
	*/
	public $layout = '//layouts/column2';

	/**
	* @return array action filters
	*/
	public function filters()
	{
		return array(
			// 'accessControl', // perform access control for CRUD operations
			'postOnly + delete', // we only allow deletion via POST request
		);
	}

	/**
	* 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('verified', 'update', 'view', 'delete', 'admin', 'index', 'enable', 'disable', 'upload'),
				'users' => array('@'),
				'expression' => 'Yii::app()->user->record->level==1',
			),
			array(
				'allow',
				'actions' => array('view', 'list', 'verified', 'review'),
				'users' => array('@'),
				'expression' => 'Yii::app()->user->record->level==2',
			),
			array(
				'allow',
				'actions' => array('view', 'my', 'add', 'update', 'delete', 'upload', 'verified'),
				'users' => array('@'),
				'expression' => 'Yii::app()->user->record->level==3',
			),
			array(
				'allow',
				'actions' => array('download', 'detail', 'link', 'update', 'preview'),
				'users' => array('@'),
			),
			array(
				'deny',
				'users' => array('*'),
			),
		);
	}


	/**
	* Displays a particular model.
	* @param integer $id the ID of the model to be displayed
	*/
	public function actionView($id)
	{
		$model = $this->loadVideo($id);
		if (isset($_POST['Paper'])) {
			$model->attributes = $_POST['Paper'];
			$model->update_id = YII::app()->user->id;
			$model->update_date = date('Y-m-d h:i:s');
			if ($model->save()) {
				$user = $this->loadUser($model->researchers_id);
				if ($model->paper_file != NULL || $model->paper_file != '') {
					$user->status_video = 1;
					$user->update();
				}
				$this->redirect(array('view', 'id' => $model->id_paper));
			}
		}


		if (Yii::app()->user->record->level == 1) {
			$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $id)));
		} elseif (Yii::app()->user->record->level == 2) {
			$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $id . ' AND evaluator_id=' . Yii::app()->user->record->id_user)));
		} elseif (Yii::app()->user->record->level == 3) {
			$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $id)));
		}
		$dataMember = new CActiveDataProvider('Member', array('criteria' => array('condition' => 'team_id=' . $model->researchers_id)));
		if (Yii::app()->request->isAjaxRequest) {
			$this->renderPartial('view', array(
				'dataMember' => $dataMember,
				'model' => $model,
				'weight' => $this->loadWeight(),
				'dataProvider' => $dataProvider,
			), false, true);
		} else {
			$this->render('view', array(
				'dataMember' => $dataMember,
				'model' => $model,
				'weight' => $this->loadWeight(),
				'dataProvider' => $dataProvider,
			));
		}
	}

	/**
	* Creates a new model.
	* If creation is successful, the browser will be redirected to the 'view' page.
	*/
	public function actionVerified($id)
	{
		$model = $this->loadVideo($id);

		$dataMember = new CActiveDataProvider('Member', array('criteria' => array('condition' => 'team_id=' . $id)));
		if ($model === NULL && Yii::app()->user->record->level == 1) {
			$model = new Paper;
			// Uncomment the following line if AJAX validation is needed
			// $this->performAjaxValidation($model);
			if (isset($_POST['Paper'])) {
				$model->attributes = $_POST['Paper'];
				$model->researchers_id = $id;
				$model->created_id = YII::app()->user->id;
				$model->created_date = date('Y-m-d h:i:s');
				// $model->status = 1;
				if ($model->save()) {
					$user = $this->loadUser($model->researchers_id);
					if ($model->status == 1) {
						$user->reject_time = NULL;
						$user->verified_time = date('Y-m-d h:i:s');
						$user->status = 1;
						$user->active = 1;
						$model->status = 1;
						$model->update();
						Yii::import('ext.yii-mail.YiiMailMessage');
						$email = new YiiMailMessage;
						$message_title = "Aktivasi Akun";
						$message_content =
						"Halo " . $user->fullname . ",

						Akun Anda sudah aktif.
						Anda dapat login di Aplikasi ".Setting::model()->description()." melalui tautan berikut ini:

						<a href='https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login'>https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login</a>

						Berikut username dan password Anda:
						Username: <b>" . $user->username . "</b>
						Password: <b>" . $user->password . "</b>

						Silahkan upload hasil karya Anda di Google Drive dengan share link 'Anyone with the link', kemudian input link Google Drive Anda di menu Detail Aplikasi Lomba Logo Badan Kebijakan Transportasi (BKT) dengan alamat dan user password Anda di atas.

						Terimakasih
						Panitia Lomba.
						";
						$message_link = "";
						$message_button = "Upload File";
						$email->subject = "Aktivasi Akun ".Setting::model()->description()." an. " . $user->fullname;
						$email->addTo($user->email);
						$email->setFrom(array(Setting::model()->email() => Setting::model()->name()));
						$message_template = $this->renderPartial(
							'/email/default',
							array(
								'email' => $user->email,
								'title' => $message_title,
								'message' => $message_content,
								'link' => $message_link,
								'button' => $message_button
							),
							TRUE
						);
						$email->setBody($message_template, 'text/html');
						if (Yii::app()->mail->send($email)) {
							$user->password = md5($user->password);
							$user->update();
							$user->save();
							$this->redirect(array('integration/users/team'));
						} else {
							throw new CHttpException(500, 'Email Tidak Valid.');
						}
					} else {
						$user->reject_time = date('Y-m-d h:i:s');
						$user->verified_time = date('Y-m-d h:i:s');
						$user->status = 2;
						$user->active = 2;
						$model->status = 2;
						$model->update();
						Yii::import('ext.yii-mail.YiiMailMessage');
						$email = new YiiMailMessage;
						$message_title = "Aktivasi Akun";
						$message_content =
						"Halo " . $user->fullname . ",

						Bersama ini kami informasikan bahwa pendaftaran Anda sebagai peserta ".Setting::model()->description()." belum bisa kami setujui dikarenakan:
						<b>" . $model->status_description . "</b>

						Silahkan Anda perbaiki data Anda kembali di Aplikasi ".Setting::model()->description()." melalui tautan berikut ini:

						<a href='https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login'>https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login</a>

						Berikut username dan password Anda:
						Username: <b>" . $user->username . "</b>
						Password: <b>" . $user->password . "</b>

						Terimakasih.
						Panitia Lomba.
						";
						$message_link = "";
						$message_button = "Upload Video Lomba";
						$email->subject = "Aktivasi Akun ".Setting::model()->description()." an. " . $user->fullname;
						$email->addTo($user->email);
						$email->setFrom(array(Setting::model()->email() => Setting::model()->name()));
						$message_template = $this->renderPartial(
							'/email/default',
							array(
								'email' => $user->email,
								'title' => $message_title,
								'message' => $message_content,
								'link' => $message_link,
								'button' => $message_button
							),
							TRUE
						);
						$email->setBody($message_template, 'text/html');
						if (Yii::app()->mail->send($email)) {
							$user->password = md5($user->password);
							$user->update();
							$user->save();
							$this->redirect(array('integration/users/team'));
						} else {
							throw new CHttpException(500, 'Email Tidak Valid.');
						}
					}
				}
			}

			$this->render('create', array(
				'id' => $id,
				'model' => $model,
				'dataMember' => $dataMember,
			));
		} else {
			if ($model->status == 1) {
				$this->redirect(array('view', 'id' => $id));
			} else {
				$this->redirect(array('update', 'id' => $id));
			}
		}
	}


			/**
			* Updates a particular model.
			* If update is successful, the browser will be redirected to the 'view' page.
			* @param integer $id the ID of the model to be updated
			*/
			public function actionUpdate($id)
			{
				$model = $this->loadVideo($id);
				if (Yii::app()->user->record->level == 1) {
					$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $model->id_paper)));
				} elseif (Yii::app()->user->record->level == 2) {
					$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $model->id_paper . ' AND evaluator_id=' . Yii::app()->user->record->id_user)));
				} elseif (Yii::app()->user->record->level == 3) {
					$model->setScenario('upload_karyatulis');
					$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $model->id_paper)));
				}
				$dataMember = new CActiveDataProvider('Member', array('criteria' => array('condition' => 'team_id=' . $model->researchers_id)));

				// Uncomment the following line if AJAX validation is needed
				// $this->performAjaxValidation($model);

				if (isset($_POST['Paper'])) {
					$model->attributes = $_POST['Paper'];
					$model->update_id = YII::app()->user->id;
					$model->update_date = date('Y-m-d h:i:s');
					$tmp;
					if (strlen(trim(CUploadedFile::getInstance($model, 'paper_file'))) > 0) {
						$tmp = CUploadedFile::getInstance($model, 'paper_file');
						$model->paper_file = 'karya-tulis-'.Users::model()->seo($model->paper_name) . '-' . sha1($model->created_date) . '.' . $tmp->extensionName;
					}

					$tmp2;
					if (strlen(trim(CUploadedFile::getInstance($model, 'paper_image'))) > 0) {
						$tmp2 = CUploadedFile::getInstance($model, 'paper_image');
						$model->paper_image = 'paparan-'.Users::model()->seo($model->paper_name) . '-' . sha1($model->created_date) . '.' . $tmp->extensionName;
					}
					if ($model->save()) {
						$user = $this->loadUser($model->researchers_id);
						if ($model->paper_file != NULL || $model->paper_file != '') {
							$user->status_video = 1;
							// $description,$activityid,$type,$point,$part,$object
							Activities::model()->my("Peserta an. " . YII::app()->user->record->fullname . " Kirim File Karya Tulis", 1, 7, 1, 1, 1);
							$user->update();
							if (strlen(trim($model->paper_file)) > 0) {
								$tmp->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/pdf/' . $model->paper_file);
							}
							if (strlen(trim($model->paper_image)) > 0) {
								$tmp2->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/ppt/' . $model->paper_image);
							}
						}

						if (Yii::app()->user->record->level == 1) :
							$user = $this->loadUser($model->researchers_id);
							if ($model->status == 1) {
								$user->verified_time = date('Y-m-d h:i:s');
								$user->status = 1;
								$user->active = 1;
								Yii::import('ext.yii-mail.YiiMailMessage');
								$email = new YiiMailMessage;
								$message_title = "Aktivasi Akun";
								$message_content =
								"Halo " . $user->fullname . ",

								Akun Anda sudah aktif.
								Anda dapat login di Aplikasi ".Setting::model()->description()." melalui tautan berikut ini:

								<a href='https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login'>https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login</a>

								Silahkan upload hasil karya Anda di Google Drive dengan share link 'Anyone with the link', kemudian input link Google Drive Anda di menu Detail Aplikasi Lomba Logo Badan Kebijakan Transportasi (BKT) dengan alamat dan user password Anda di atas.

								Terimakasih
								Panitia Lomba.
								";
								$message_link = "";
								$message_button = "Upload Video Lomba";
								$email->subject = "Aktivasi Akun ".Setting::model()->description()." an. " . $user->fullname;
								$email->addTo($user->email);
								$email->setFrom(array(Setting::model()->email() => Setting::model()->name()));
								$message_template = $this->renderPartial(
									'/email/default',
									array(
										'email' => $user->email,
										'title' => $message_title,
										'message' => $message_content,
										'link' => $message_link,
										'button' => $message_button
									),
									TRUE
								);
								$email->setBody($message_template, 'text/html');
								if (Yii::app()->mail->send($email)) {
									// $user->password = md5($user->password);
									$user->update();
									$user->save();
									$this->redirect(array('integration/users/team'));
								}
							} else {
								$user->verified_time = date('Y-m-d h:i:s');
								$user->reject_time = date('Y-m-d h:i:s');
								$user->status = 2;
								$user->active = 2;
								$model->status = 2;
								$model->update();
								Yii::import('ext.yii-mail.YiiMailMessage');
								$email = new YiiMailMessage;
								$message_title = "Aktivasi Akun Lomba";
								$message_content =
								"Halo " . $user->fullname . ",

								Bersama ini kami informasikan bahwa pendaftaran Anda sebagai peserta ".Setting::model()->description()." belum bisa kami setujui dikarenakan:
								<b>" . $model->status_description . "</b>

								Silahkan Anda perbaiki data Anda kembali di Aplikasi ".Setting::model()->description()." melalui tautan berikut ini:

								<a href='https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login'>https://balitbanghub.dephub.go.id/transhub_challenge/lombalogo/login</a>

								Terimakasih.
								Panitia Lomba.
								";
								$message_link = "";
								$message_button = "Upload Video Lomba";
								$email->subject = "Aktivasi Akun ".Setting::model()->description()." an. " . $user->fullname;
								$email->addTo($user->email);
								$email->setFrom(array(Setting::model()->email() => Setting::model()->name()));
								$message_template = $this->renderPartial(
									'/email/default',
									array(
										'email' => $user->email,
										'title' => $message_title,
										'message' => $message_content,
										'link' => $message_link,
										'button' => $message_button
									),
									TRUE
								);
								$email->setBody($message_template, 'text/html');
								if (Yii::app()->mail->send($email)) {
											// $user->password = md5($user->password);
									$user->update();
									$user->save();
									$this->redirect(array('integration/users/team'));
								}
							}
						endif;
					}
				}

				$this->render('update', array(
					'model' => $model,
					'dataProvider' => $dataProvider,
					'weight' => $this->loadWeight(),
					'dataMember' => $dataMember,
				));
			}

					/**
					* Deletes a particular model.
					* If deletion is successful, the browser will be redirected to the 'admin' page.
					* @param integer $id the ID of the model to be deleted
					*/
					public function actionDelete($id)
					{
						$model = $this->loadVideo($id);
						if($model!=NULL){
							Review::model()->deleteAll(array("condition" => "paper_id=" . $model->id_paper));
						}
						Member::model()->deleteAll(array("condition" => "team_id=" . $id));
						Users::model()->deleteAll(array("condition" => "id_user=" . $id));
						Paper::model()->deleteAll(array("condition" => "researchers_id=" . $id));

						$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('integration/users/team'));

						// $dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $id)));
						// if ($dataProvider->totalItemCount > 0) {
							// 	throw new CHttpException(403, 'Makalah Sudah Di Nilai (Tidak Dapat Dihapus).');
							// } else {
								// 	$this->loadModel($id)->delete();
								// 	if (Yii::app()->user->record->level == 1) {
									// 		if (!isset($_GET['ajax']))
									// 			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
									// 	} else {
										// 		$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('my'));
										// 	}
										// 	// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
										// }
					}

									/**
									* Lists all models.
									*/
									public function actionIndex()
									{
										$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'researchers_id=' . Yii::app()->user->record->id_user)));
										$this->render('index', array(
											'dataProvider' => $dataProvider,
										));
									}

									public function actionMy()
									{
										$dataProvider = new CActiveDataProvider('Paper', array('criteria' => array('condition' => 'researchers_id=' . Yii::app()->user->record->id_user)));
										$this->render('my', array(
											'dataProvider' => $dataProvider,
										));
									}

									/**
									* Manages all models.
									*/
									public function actionAdmin()
									{
										$model = new Paper('search');
										$model->unsetAttributes();  // clear any default values
										if (isset($_GET['Paper']))
											$model->attributes = $_GET['Paper'];

										$data = new Paper;
										if (isset($_POST['Paper'])) {
											$data->attributes = $_POST['Paper'];
											$data->created_id = YII::app()->user->id;
											$data->created_date = date('Y-m-d h:i:s');
											$data->status = 1;
											$tmp;
											if (strlen(trim(CUploadedFile::getInstance($data, 'paper_image'))) > 0) {
												$tmp = CUploadedFile::getInstance($data, 'paper_image');
												$data->paper_image = Users::model()->seo($data->paper_name) . '-' . sha1($data->created_date) . '.' . $tmp->extensionName;
											}

											$tmp2;
											if (strlen(trim(CUploadedFile::getInstance($data, 'paper_file'))) > 0) {
												$tmp2 = CUploadedFile::getInstance($data, 'paper_file');
												$data->paper_file = Users::model()->seo($data->paper_name) . '-' . sha1($data->created_date) . '.' . $tmp2->extensionName;
											}

											if ($data->save()) {
												if (strlen(trim($model->paper_image)) > 0) {
													$tmp->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/presentation/' . $model->paper_image);
												}

												if (strlen(trim($model->paper_file)) > 0) {
													$tmp2->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/file/' . $model->paper_file);
												}
												$this->redirect(array('view', 'id' => $data->id_paper));
											}
										}

										$this->render('admin', array(
											'model' => $model,
											'data' => $data,
										));
									}

									/**
									* Returns the data model based on the primary key given in the GET variable.
									* If the data model is not found, an HTTP exception will be raised.
									* @param integer $id the ID of the model to be loaded
									* @return Paper the loaded model
									* @throws CHttpException
									*/
									public function loadModel($id)
									{
										$model = Paper::model()->findByPk($id);
										if ($model === null)
											throw new CHttpException(404, 'The requested page does not exist.');
										return $model;
									}

									public function loadUser($id)
									{
										$model = Users::model()->findByPk($id);
										if ($model === null)
											throw new CHttpException(404, 'The requested page does not exist.');
										return $model;
									}

									public function loadVideo($id)
									{
										$model = Paper::model()->findByAttributes(array('researchers_id' => $id));
										if (YII::app()->user->record->level == 1 || YII::app()->user->record->level == 2) {
											return $model;
										} else {
											if (YII::app()->user->id == $model->researchers_id) {
												return $model;
											} else {
												throw new CHttpException(403, 'Anda Tidak di Izinkan untuk Melakukan Aksi Ini.');
											}
										}
									}


									/**
									* Performs the AJAX validation.
									* @param Paper $model the model to be validated
									*/
									protected function performAjaxValidation($model)
									{
										if (isset($_POST['ajax']) && $_POST['ajax'] === 'paper-form') {
											echo CActiveForm::validate($model);
											Yii::app()->end();
										}
									}

									public function actionEnable($id)
									{
										$model = $this->loadModel($id);
										$model->status = 1;
										$model->save();
										$this->redirect(array('index'));
									}

									public function actionDisable($id)
									{
										$model = $this->loadModel($id);
										$model->status = 0;
										$model->save();
										$this->redirect(array('index'));
									}

									public function actionAdd()
									{
										$model = new Paper;
										$model->setScenario('upload_cover');
										$model->setScenario('upload_pdf');

										// Uncomment the following line if AJAX validation is needed
										// $this->performAjaxValidation($model);

										if (isset($_POST['Paper'])) {
											$model->attributes = $_POST['Paper'];
											$model->created_id = YII::app()->user->id;
											$model->created_date = date('Y-m-d h:i:s');
											$model->status = 1;

											$tmp;
											if (strlen(trim(CUploadedFile::getInstance($model, 'paper_image'))) > 0) {
												$tmp = CUploadedFile::getInstance($model, 'paper_image');
												$model->paper_image = Users::model()->seo($model->paper_name) . '-' . sha1($model->created_date) . '.' . $tmp->extensionName;
											}

											$tmp2;
											if (strlen(trim(CUploadedFile::getInstance($model, 'paper_file'))) > 0) {
												$tmp2 = CUploadedFile::getInstance($model, 'paper_file');
												$model->paper_file = Users::model()->seo($model->paper_name) . '-' . sha1($model->created_date) . '.' . $tmp2->extensionName;
											}

											if ($model->save()) {
												if (strlen(trim($model->paper_image)) > 0) {
													$tmp->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/presentation/' . $model->paper_image);
												}

												if (strlen(trim($model->paper_file)) > 0) {
													$tmp2->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/file/' . $model->paper_file);
												}

												$this->redirect(array('view', 'id' => $model->id_paper));
											}
										}

										$this->render('add', array(
											'model' => $model,
										));
									}

									public function actionList()
									{
										$model = new Paper('search');
										$model->unsetAttributes();  // clear any default values
										if (isset($_GET['Paper']))
											$model->attributes = $_GET['Paper'];
										$this->render('list', array(
											'model' => $model,
										));
									}

									public function loadWeight()
									{
										$model = Weight::model()->findByPk(1);
										if ($model === null)
											throw new CHttpException(404, 'The requested page does not exist.');
										return $model;
									}

									public function actionUpload($id, $type)
									{
										$model = $this->loadModel($id);


										// Uncomment the following line if AJAX validation is needed
										// $this->performAjaxValidation($model);

										if (isset($_POST['Paper'])) {
											$model->attributes = $_POST['Paper'];
											$model->update_id = YII::app()->user->id;
											$model->update_date = date('Y-m-d h:i:s');
											if ($type == 1) {
												$model->setScenario('upload_pdf');
												$tmp2;
												if (strlen(trim(CUploadedFile::getInstance($model, 'paper_file'))) > 0) {
													$tmp2 = CUploadedFile::getInstance($model, 'paper_file');
													$model->paper_file = Users::model()->seo($model->paper_name) . '-' . sha1($model->id_paper) . '.' . $tmp2->extensionName;
												}
											} else {
												$model->setScenario('upload_cover');
												$tmp2;
												if (strlen(trim(CUploadedFile::getInstance($model, 'paper_image'))) > 0) {
													$tmp2 = CUploadedFile::getInstance($model, 'paper_image');
													$model->paper_image = Users::model()->seo($model->paper_name) . '-' . sha1($model->id_paper) . '.' . $tmp2->extensionName;
												}
											}

											if ($model->save()) {
												if ($type == 1) {
													if (strlen(trim($model->paper_file)) > 0) {
														$tmp2->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/file/' . $model->paper_file);
													}
												} else {
													if (strlen(trim($model->paper_image)) > 0) {
														$tmp2->saveAs(Yii::getPathOfAlias('webroot') . '/image/paper/presentation/' . $model->paper_image);
													}
												}
												$this->redirect(array('view', 'id' => $model->id_paper));
											}
										}

										$this->render('upload', array(
											'model' => $model,
											'type' => $type,
										));
									}

									public function actionDownload($id)
									{
										$model = $this->loadUser($id);
										$this->redirect(YII::app()->baseUrl . '/image/files/document/' . $model->image);
									}

									public function actionDetail($id)
									{
										$model = $this->loadUser($id);
										$dataProvider = new CActiveDataProvider('Review', array('criteria' => array('condition' => 'paper_id=' . $id)));
										$dataMember = new CActiveDataProvider('Member', array('criteria' => array('condition' => 'team_id=' . $id)));
										$this->render('detail', array(
											'dataMember' => $dataMember,
											'model' => $model,
											'weight' => $this->loadWeight(),
											'dataProvider' => $dataProvider,
										));
									}

									public function actionLink($id)
									{
										$model = $this->LoadModel($id);
										$this->redirect(YII::app()->baseUrl . '/image/paper/pdf/' . $model->paper_file);
									}

									public function actionLinkPpt($id)
									{
										$model = $this->LoadModel($id);
										$this->redirect(YII::app()->baseUrl . '/image/paper/ppt/' . $model->paper_image);
									}

									public function actionReview($id)
									{
										$model = $this->loadVideo($id);
										$this->redirect(array('main/review/add', 'id' => $model->id_paper, 'team' => $model->researchers_id));
									}


									public function actionPreview($id)
									{
										$model = $this->loadUser($id);
										$this->redirect(YII::app()->baseUrl . '/image/files/document/' . $model->image);
									}
								}
