Initial import

This commit is contained in:
Admin Nasledstvo
2026-05-01 20:52:04 +03:00
commit ac168868ee
10028 changed files with 2337954 additions and 0 deletions
@@ -0,0 +1,16 @@
<?php
namespace app\controllers;
class BaseController extends \yii\web\Controller
{
public function beforeAction($action)
{
$data = explode('/', $_SERVER['REQUEST_URI']);
if(!empty($data[1]) && in_array($data[1], \Yii::$app->params['languages']))
\Yii::$app->language = $data[1];
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
}
@@ -0,0 +1,76 @@
<?php
namespace app\controllers;
use app\models\FileCms;
use app\models\RegisterObjectFiles;
use app\services\IdServer;
use app\services\JWT;
class FileSystemController extends BaseController
{
public function actionFilePreviewDelivery($id)
{
if ($id) {
$decode = JWT::decode($id, JWT::SECRET_KEY);
/** @var RegisterObjectFiles $objectFile */
$objectFile = RegisterObjectFiles::findOne($decode->id);
if ($objectFile) {
if ($objectFile->file_content_type == 1 && $objectFile->extension == 'pdf') {
if(empty($_GET['preview'])) {
return $this->renderPartial('pdf-preview', ['objectFile' => $objectFile]);
} else {
return $this->renderPartial('viewer', ['objectFile' => $objectFile]);
}
}
}
}
// die('You do not have permission to open this address');
}
public function actionFilePreviewDeliveryMobile($id)
{
return $this->renderPartial('pdf-preview-mobile', ['id' => $id]);
// die('You do not have permission to open this address');
}
public function actionPublic($id)
{
return $this->renderPartial('pdf-public-preview', ['file_name' => $id]);
}
public function actionDelivery($id)
{
$file = RegisterObjectFiles::findOne($id);
IdServer::url($file->file_url);
exit;
}
public function actionDeliveryImg($id)
{
$file = RegisterObjectFiles::findOne($id);
IdServer::url($file->file_url);
exit;
}
public function actionVideoThumb($id)
{
$file = RegisterObjectFiles::findOne($id);
IdServer::url($file->video_thumbnail);
exit;
}
public function actionStream($id)
{
$file = RegisterObjectFiles::findOne($id);
echo $file->streaming_url;
exit;
}
}
@@ -0,0 +1,181 @@
<?php
namespace app\controllers;
use app\models\UserPublic;
use app\services\Cart;
use app\services\JWT;
class MobileApiController extends BaseController
{
public function beforeAction($action)
{
/*
header("Access-Control-Expose-Headers: Access-Control-*");
header("Access-Control-Allow-Headers: Access-Control-*, Origin, X-Requested-With, Content-Type, Accept, Auth");
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD');
header('Access-Control-Allow-Origin: *');
header('Allow', 'GET, POST, PUT, DELETE, OPTIONS, HEAD');
*/
Header('Access-Control-Allow-Origin: *'); //for allow any domain, insecure
Header('Access-Control-Allow-Headers: *'); //for allow any headers, insecure
Header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE'); //method allowed
return parent::beforeAction($action);
}
public function actionArticles()
{
return $this->renderPartial('articles');
}
public function actionArticle()
{
return $this->renderPartial('article');
}
public function actionCollections()
{
return $this->renderPartial('collections');
}
public function actionCollection()
{
return $this->renderPartial('collection');
}
public function actionExpositions()
{
return $this->renderPartial('expositions');
}
public function actionExposition()
{
return $this->renderPartial('exposition');
}
public function actionObject()
{
return $this->renderPartial('object');
}
public function actionBrowserClose()
{
Cart::clearCartOnly();
exit;
}
public function actionBrowserCloseCompleteOrder()
{
Cart::clearCartOnly();
exit;
}
public function actionBrowserRegisterClose() {
exit;
}
public function actionGetAccessToken()
{
return $this->renderPartial('access-token');
}
public function actionGetAccessTokenByDeviceId()
{
return $this->renderPartial('access-token-by-device-id');
}
public function actionGenerateUserUid()
{
return $this->renderPartial('generate-user-uid');
}
public function actionGetRemoteAddress()
{
echo '<html><head><title>Remote address</title></head><body>' . $_SERVER['REMOTE_ADDR'] . '</body></html>';
exit;
}
public function actionGetMapPointData()
{
return $this->renderPartial('map-point-data');
}
public function actionExploreObjectsMap()
{
return $this->renderPartial('explore-objects-map');
}
public function actionExploreObjectsList()
{
return $this->renderPartial('explore-objects-list');
}
public function actionExploreObjectVisitByUser()
{
return $this->renderPartial('explore-object-visit-by-user');
}
public function actionFavorites() {
return $this->render('favorites');
}
public function actionUpdateFavorites() {
return $this->render('update-favorites');
}
public function actionVisitedplaces() {
return $this->render('visited-places');
}
public function actionGetProfile() {
return $this->render('get-profile');
}
public function actionUpdateCardStatus() {
return $this->render('update-cart-status');
}
public function actionMaintab() {
return $this->render('main-tab');
}
public function actionCollectionFilter(){
if(empty($_GET['parent_value_id'])) {
return $this->renderPartial('collection-filter');
} else {
return $this->render('collection-filter-dynamic');
}
}
public function actionExpositionFilter(){
return $this->renderPartial('exposition-filter');
}
public function actionOrders() {
return $this->renderPartial('orders');
}
public function actionOrdersForQrValidator() {
return $this->renderPartial('orders-for-qr-validator');
}
public function actionOrder() {
return $this->renderPartial('order');
}
public function actionValidateTickets() {
return $this->renderPartial('validate-tickets');
}
public function actionGetEventsByQrValidator() {
return $this->renderPartial('get-events-by-validator');
}
public function actionQrCodeScanner() {
return $this->renderPartial('qr-scanner');
}
}
@@ -0,0 +1,86 @@
<?php
namespace app\controllers;
use app\models\Articles;
use app\services\ViewReg;
class PartnerController extends BaseController
{
public $layout = 'portal';
public $partnerSlug;
public function actionIndex($partnerSlug)
{
$this->partnerSlug = $partnerSlug;
ViewReg::partnerLocaleSwitch($partnerSlug);
return $this->render('partner', ['slug' => $partnerSlug]);
}
public function actionPage($partnerSlug, $webPage, $slug = null)
{
$this->partnerSlug = $partnerSlug;
$page = ViewReg::find($webPage);
if ($page) {
//list page
if (!$slug) {
ViewReg::partnerLocaleSwitch($partnerSlug, $page->model);
return $this->render($page->view, ['model' => $page->model, 'partnerSlug' => $partnerSlug]);
}
}
switch ($webPage) {
case 'news':
case 'novini':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('news', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'news', 'partnerSlug' => $partnerSlug]);
}
break;
case 'events':
case 'sabitia':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('events', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'events', 'partnerSlug' => $partnerSlug]);
}
break;
case 'campaigns':
case 'kampanii':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('campaigns', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'campaigns', 'partnerSlug' => $partnerSlug]);
}
break;
case 'projects':
case 'proekti':
return $this->render('detail_pages/project', ['slug' => $slug, 'partnerSlug' => $partnerSlug]);
case 'objects':
case 'obekti':
case 'collections-objects':
case 'kolektsii-obekti':
case 'expositions-objects':
case 'ekspozitsii-obekti':
return $this->render('detail_pages/object', ['webPage' => $webPage, 'slug' => $slug, 'partnerSlug' => $partnerSlug]);
case 'collections':
case 'kolektsii':
return $this->render('detail_pages/collection', ['slug' => $slug, 'partnerSlug' => $partnerSlug]);
case 'expositions':
case 'ekspozitsii':
return $this->render('detail_pages/exposition', ['slug' => $slug, 'partnerSlug' => $partnerSlug]);
case 'e-biblioteka':
case 'e-library':
return $this->render('detail_pages/e-library', ['slug' => $slug, 'partnerSlug' => $partnerSlug]);
}
}
}
@@ -0,0 +1,345 @@
<?php
namespace app\controllers;
use app\models\Articles;
use app\models\Expositions;
use app\models\Navigation;
use app\models\News;
use app\models\Pages;
use app\models\parsed\SearchResultModel;
use app\models\Projects;
use app\models\register\Collections;
use app\models\register\CollectionsObjects;
use app\models\register\Partner;
use app\models\RegisterObjects;
use app\models\Ts;
use app\models\UserFavorites;
use app\models\UserSession;
use app\services\Auth;
use app\services\Formatter;
use app\services\GeoService;
use app\services\ViewReg;
class RemoteController extends BaseController
{
public function beforeAction($action)
{
if (!empty($_GET['partner_id'])) {
$partner = Partner::findOne($_GET['partner_id']);
$this->partnerSlug = Formatter::encodeId($partner->id) . '-' . Formatter::cyrillicTrans($partner->getTsName());
}
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
public function actionGetArticles()
{
Ts::set([12, 13, 14]);
return $this->renderPartial('list_article');
}
public function actionGetProjects()
{
return $this->renderPartial('list_project');
}
public function actionGetELibrary()
{
Ts::set([155, 162, 163, 164, 165]);
return $this->renderPartial('list_e_library_new');
}
public function actionGetCollections()
{
Ts::set([12, 13, 14, 155, 162, 163, 164, 165, 184]);
return $this->renderPartial('list_collection');
}
public function actionGetCollectionObjects()
{
return $this->renderPartial('list_collection_objects');
}
public function actionGetExpositionObjects()
{
return $this->renderPartial('list_exposition_objects');
}
public function actionGetExpositions()
{
Ts::set([12, 13, 14]);
return $this->renderPartial('list_exposition');
}
public function actionGetObjectsVideos()
{
return $this->renderPartial('list_collection_objects_videos', ['object_id' => $_GET['object_id']]);
}
public function actionGetObjectsModels()
{
return $this->renderPartial('list_collection_objects_models', ['object_id' => $_GET['object_id']]);
}
public function actionGetSpecificFilter()
{
if (!empty($_GET['parent_id'])) {
return $this->renderPartial('specific_filter', ['parent_id' => $_GET['parent_id'], 'content_lib_type' => null]);
}
}
public function actionSearch()
{
Ts::set([185, 186, 187, 117, 118, 170, 188, 189]);
$lg = \Yii::$app->language;
$data = [];
$q = $_GET['q'];
//$_GET['q'] = '&#x42F;в&#x43E;р&#x43E;в,%20&#x41F;ей&#x43E;%20&#x41A;рач&#x43E;&#x43B;&#x43E;в';
//region [INTERNAL PAGES]
$pages = Pages::find()->andWhere(['or', ['LIKE', 'name', $_GET['q']], ['LIKE', 'name_en', $_GET['q']]])->limit(20)->all();
foreach ($pages as $page) {
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $page->name_en ?? $page->name : $page->name;
$model->type = $lg == 'en' ? 'Web page' : 'Вътрешна страница';
$model->url = '/' . $lg . '/' . ($lg == 'en' ? $page->slug_en : $page->slug) . '/';
$model->id = $page->id;
if ($model->text)
$data[] = $model;
}
//endregion
//region [EXTERNAL PAGES]
$links = Navigation::find()
->where(['IS NOT', 'url', NULL])
->andWhere(['or', ['LIKE', 'name', $_GET['q']], ['LIKE', 'ts_en_name', $_GET['q']]])->limit(20)->all();
$bufferDuplicates = [];
foreach ($links as $link) {
if ($link->url) {
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $link->ts_en_name ?? $link->name : $link->name;
$model->type = $lg == 'en' ? 'External web page' : 'Външна страница';
$model->url = $link->url;
$model->id = $link->id;
$buffer = (object)[$model->text, $link->url];
if (!in_array($buffer, $bufferDuplicates)) {
$bufferDuplicates[] = $buffer;
if ($model->text)
$data[] = $model;
}
}
}
//endregion
//region [Articles]
$articles = Articles::find()->where(['is_active' => 1])->andWhere(['or', ['LIKE', 'title', $_GET['q']], ['LIKE', 'title_en', $_GET['q']]])->limit(20)->all();
foreach ($articles as $article) {
if ($article->article) {
$title_en = $article->title_en ?? $article->title;
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $title_en : $article->title;
$model->type = $article->getSingleArticleLabel();
$model->url = ViewReg::generateDetailPageUrl($article);
$model->id = $article->id;
if ($model->text)
$data[] = $model;
}
}
//endregion
//region [Collection]
$collections = Collections::find()->where(['published' => 1, 'deleted' => 0])->andWhere(['or', ['LIKE', 'name', $_GET['q']], ['LIKE', 'name_en', $_GET['q']]])->limit(20)->all();
foreach ($collections as $collection) {
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $collection->name_en ?? $collection->name : $collection->name;
$model->type = Ts::get(117);
$model->url = $collection->getUrl();
$model->id = $collection->id;
if ($model->text)
$data[] = $model;
}
//endregion
//region [Expositions]
$expositions = Expositions::find()->where(['is_active' => 1])->andWhere(['or', ['LIKE', 'name', $_GET['q']], ['LIKE', 'ts_en_name', $_GET['q']]])->limit(20)->all();
foreach ($expositions as $exposition) {
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $exposition->ts_en_name ?? $exposition->name : $exposition->name;
$model->type = Ts::get(188);
$model->url = $exposition->getUrl();
$model->id = $exposition->id;
if ($model->text)
$data[] = $model;
}
//endregion
//region [Objects]
$objects = RegisterObjects::find()
->where(['is_active' => 1, 'lib_type' => 1])
->andWhere(['or',
['LIKE', 'created_by', $q],
['LIKE', 'name', $q],
['LIKE', 'ts_en_name', $q]
])
->limit(20)->all();
foreach ($objects as $object) {
$model = new SearchResultModel();
$name_en = !empty($object->ts_en_name) ? $object->ts_en_name : $object->name;
$model->text = $lg == 'en' ? $name_en : $object->name;
$model->type = Ts::get(118);
$model->url = $object->getUrl();
$model->id = $object->id;
if ($model->text)
$data[] = $model;
}
//endregion
//region [E-library]
$objects = RegisterObjects::find()
->where(['is_active' => 1, 'lib_type' => 2])
->andWhere(['or',
['LIKE', 'created_by', $_GET['q']],
['LIKE', 'name', $_GET['q']],
['LIKE', 'ts_en_name', $_GET['q']]
])->limit(20)->all();
foreach ($objects as $object) {
$model = new SearchResultModel();
$name_en = !empty($object->ts_en_name) ? $object->ts_en_name : $object->name;
$model->text = $lg == 'en' ? $name_en : $object->name;
$model->type = Ts::get(170);
$model->url = $object->getLibraryUrl();
$model->id = $object->id;
//if ($model->text)
$data[] = $model;
}
//endregion
//region [Projects]
$projects = Projects::find()->where(['is_active' => 1])->andWhere(['or', ['LIKE', 'title', $_GET['q']], ['LIKE', 'ts_en_title', $_GET['q']]])->limit(20)->all();
foreach ($projects as $project) {
$title_en = $project->ts_en_title ?? $project->title;
$model = new SearchResultModel();
$model->text = $lg == 'en' ? $title_en : $project->title;
$model->type = Ts::get(189);
$model->url = ViewReg::generateDefaultDetailUrl('projects', $project->id, $project->title());
$model->id = $project->id;
if ($model->text)
$data[] = $model;
}
//endregion
return $this->renderPartial('search-result', ['data' => $data]);
}
public function actionFavorites()
{
$data = json_decode(\Yii::$app->request->getRawBody());
$user = Auth::getUser();
if (!empty($data->fid) && !empty($data->table) && $user) {
$fav = UserFavorites::find()->where(['fid' => $data->fid, 'table' => $data->table, 'user_id' => $user->id])->one();
if ($fav) {
$data->{'action'} = 'remove';
$fav->delete();
} else {
$fav = new UserFavorites();
$fav->fid = $data->fid;
$fav->table = $data->table;
$fav->user_id = $user->id;
$fav->date_added = date('Y-m-d H:i:s');
$fav->save();
$data->{'action'} = 'add';
}
}
return $this->asJson($data);
}
public function actionCheckActivity()
{
$user = Auth::getUser();
if ($user && $user->open_id) {
$us = UserSession::find()->where(['sub' => $user->open_id])->one();
if (!$us) {
Auth::setUser();
return $this->asJson(['status' => 'inactive', 'redirect' => \Yii::$app->goHome()]);
} else {
return $this->asJson(['status' => 'active']);
}
} else if (!empty($_SESSION['register_user'])) {
$us = UserSession::find()->where(['sub' => $_SESSION['register_user']])->one();
if (!$us) {
unset($_SESSION['register_user']);
return $this->asJson(['status' => 'inactive', 'redirect' => \Yii::$app->goHome()]);
} else {
return $this->asJson(['status' => 'active']);
}
}
}
public function actionGetNearestObjects()
{
if (!empty($_GET['lat']) && !empty($_GET['lon']) && !empty($_GET['dist'])) {
$lat = $_GET['lat'];
$lon = $_GET['lon'];
$dist = $_GET['dist'];
if (empty($_GET['explorer'])) {
return $this->asJson(GeoService::getNearestObjects($lat, $lon, $dist)['data']);
} else {
$nearest = GeoService::getNearestObjects($lat, $lon, $dist);
return $this->asJson(GeoService::orderList($nearest));
}
}
}
public function actionUserCardEnable()
{
$user = Auth::getUser();
if ($user) {
$user->club_card = 1;
$user->save();
echo json_encode(['success' => 1]);
} else {
echo json_encode(['success' => 0]);
}
exit;
}
public function actionUserCardDisable()
{
$user = Auth::getUser();
if ($user) {
$user->club_card = null;
$user->save();
echo json_encode(['success' => 1]);
} else {
echo json_encode(['success' => 0]);
}
exit;
}
public function actionObjectGallery()
{
if (!empty($_GET['object_id']))
return $this->renderPartial('object_gallery_preview');
exit;
}
}
@@ -0,0 +1,124 @@
<?php
namespace app\controllers;
use app\models\Articles;
use app\models\SeoManagement;
use app\models\Ts;
use app\services\Formatter;
use app\services\UserRequest;
use app\services\ViewReg;
class SiteController extends BaseController
{
public $layout = 'portal';
/** @var UserRequest */
private $userRequest;
public function beforeAction($action)
{
date_default_timezone_set('Europe/Sofia');
$this->userRequest = new UserRequest();
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
public function actionIndex()
{
ViewReg::localeSwitch();
$seo = SeoManagement::findOne(1);
$this->pageTitle = $seo->getTitle();
$this->description = $seo->getDescription();
$this->keywords = $seo->getKeyWords();
return $this->render('index');
}
public function actionPage($webPage, $slug = null)
{
$this->userRequest->call('contact');
$page = ViewReg::find($webPage);
if ($page) {
if ($slug == null) {
$this->pageTitle = $page->model->headerTitle();
ViewReg::localeSwitch($page->model);
return $this->render($page->view, ['model' => $page->model]);
} else {
switch ($webPage) {
case 'projects':
case 'proekti':
return $this->render('detail_pages/project', ['slug' => $slug]);
case 'objects':
case 'obekti':
return $this->render('detail_pages/object', ['slug' => $slug, 'webPage' => $webPage]);
case 'collections':
case 'kolektsii':
return $this->render('detail_pages/collection', ['slug' => $slug]);
case 'expositions':
case 'ekspozitsii':
return $this->render('detail_pages/exposition', ['slug' => $slug]);
case 'e-library':
case 'e-biblioteka':
return $this->render('detail_pages/e-library', ['slug' => $slug]);
}
//die('No action found');
}
} else {
switch ($webPage) {
case 'news':
case 'novini':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('news', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'news']);
}
break;
case 'events':
case 'sabitia':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('events', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'events']);
}
break;
case 'campaigns':
case 'kampanii':
$article = Articles::getArticleBySlug($slug);
if ($article) {
ViewReg::localeSwitchArticle('campaigns', $article);
return $this->render('detail_pages/article', ['model' => $article, 'type' => 'campaigns']);
}
break;
case 'collections-objects':
case 'kolektsii-obekti':
case 'expositions-objects':
case 'ekspozitsii-obekti':
case 'objects':
case 'obekti':
return $this->render('detail_pages/object', ['webPage' => $webPage, 'slug' => $slug]);
case 'app-download':
$file = $_SERVER['DOCUMENT_ROOT'].'/_public/nasledstvo.apk';
header('Content-Disposition: attachment; filename=nasledstvo.apk');
header('Content-Type: application/octet-stream'); // Downloading on Android might fail without this
ob_clean();
readfile($file);
exit;
case 'master':
return $this->renderPartial('master');
}
}
echo 'Page not found 404';
exit;
}
//public function
}
@@ -0,0 +1,380 @@
<?php
namespace app\controllers;
use app\models\Order;
use app\models\register\PhplistUserUser;
use app\models\Ts;
use app\models\UserSession;
use app\services\Auth;
use app\services\Cart;
use app\services\IdServer;
use app\services\payment\Payment;
use app\services\UserRequest;
use app\services\ViewReg;
use app\services\OpenIdService;
use app\services\ZipCollection;
class UserController extends BaseController
{
public $layout = 'portal';
public $partnerSlug;
/** @var UserRequest */
private $userRequest;
/** @var \app\models\UserPublic */
private $user;
private function base64_urlencode($string)
{
return rtrim(strtr(base64_encode($string), '+/', '-_'), '=');
}
public function beforeAction($action)
{
date_default_timezone_set("Europe/Sofia");
ViewReg::localeSwitchUser();
$this->userRequest = new UserRequest();
$this->user = Auth::getUser();
if ($this->user && $this->user->open_id) {
$us = UserSession::find()->where(['sub' => $this->user->open_id])->one();
if (!$us) {
Auth::setUser();
return $this->redirect(\Yii::$app->goHome());
}
}
return parent::beforeAction($action); // TODO: Change the autogenerated stub
//\Yii::$app->language = 'en';
//exit;
}
public function actionDashboard()
{
if (!$this->user) return $this->redirect(\Yii::$app->goTo('login'));
if (!empty($_COOKIE['redirect'])) {
return $this->redirect(\Yii::$app->goToAction($_COOKIE['redirect']));
}
Ts::set([56, 57, 58, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 195, 204, 198, 205, 206, 207, 208, 209, 210, 211, 217, 220, 221, 222, 239, 241, 242, 243, 251]);
if (!empty($_GET['da'])) {
if ($_GET['da'] == 'off') {
$this->user->has_double_auth = null;
\Yii::$app->flash('success', Ts::get(208));
} else {
$this->user->has_double_auth = 1;
\Yii::$app->flash('success', Ts::get(207));
}
$idServer = new IdServer();
$idServer->turnTFA($this->user->open_id);
$this->user->save();
return $this->redirect('/user/dashboard');
}
if (!empty($_GET['na'])) {
$phpListUser = PhplistUserUser::find()->where(['email' => $this->user->email])->one();
if ($_GET['na'] == 'off') {
if ($phpListUser)
$phpListUser->delete();
$this->user->has_newsletter = null;
\Yii::$app->flash('success', Ts::get(222));
} else {
$phpListUser = PhplistUserUser::find()->where(['email' => $this->user->email])->one();
if (!$phpListUser) {
PhplistUserUser::add($this->user->email);
}
$this->user->has_newsletter = 1;
\Yii::$app->flash('success', Ts::get(221));
}
$this->user->save();
return $this->redirect('/user/dashboard');
}
$this->pageTitle = Ts::get(75);
$this->userRequest->call('editProfile');
return $this->render('dashboard', ['user' => $this->user]);
}
public function actionProfileTabs()
{
if (!empty($_GET['tab'])) {
return $this->renderPartial('profile-tabs/' . $_GET['tab']);
}
}
public function actionCheckout()
{
if (!$this->user) {
(new OpenIdService())->authenticationServerCheckout();
} else {
return $this->redirect(\Yii::$app->goHome() . 'user/');
}
}
public function actionLogin()
{
if (!$this->user) {
(new OpenIdService())->authenticationServerCheckout();
} else {
return $this->redirect('user');
}
}
public function actionLogoutAll()
{
$user = Auth::getUser();
//die('test');
if ($user && $user->open_id || !empty($_SESSION['register_user'])) {
$q = "";
if (!empty($_SESSION['id_token_hint'])) {
$redirect = \Yii::$app->params['portal'] . '/bg/user/checkout/';
$q = '?id_token_hint=' . $_SESSION['id_token_hint'] . '&post_logout_redirect_uri=' . $redirect;
}
$logoutUrl = \Yii::$app->params['sso_logout_url'] . $q;
header('Location: ' . $logoutUrl);
exit;
} else {
header('Location: ' . \Yii::$app->params['sso_logout_url']);
}
exit;
}
public function actionLogoutRedirect()
{
Auth::setUser();
$logoutUrl = \Yii::$app->params['id_server'] . '/realms/' . \Yii::$app->params['realm'] . '/protocol/openid-connect/logout';
header('Location: ' . $logoutUrl);
exit;
}
public function actionWrongUser()
{
Ts::set([219, 218, 73]);
$lg = "/bg/user/logout-redirect/";
\Yii::$app->flash('error', Ts::get(219) . '. ' . Ts::get(218) . ' <a style=\'color: #ffffff\' href=\'' . $lg . '\'>' . Ts::get(73) . '</a>');
header('Location: ' . \Yii::$app->goHome());
exit;
}
public function actionSignUp()
{
Ts::set([53, 55, 56, 57, 58, 59, 60, 61, 62, 72, 194, 195, 196, 198, 199, 201]);
$this->userRequest->call('signUp');
if (empty($_GET['webview_mode'])) {
return $this->render('sign-up');
} else {
return $this->render('sign-up-webview');
}
}
public function actionChangePassword()
{
Ts::set([67, 68, 212, 213, 214, 215, 216]);
$this->userRequest->call('changePassword');
}
public function actionIdAuth()
{
$idServer = new IdServer();
echo json_encode($idServer->customGetRequest(($_GET['req'] ?? '')));
exit;
}
// region STEP 1
public function actionCart()
{
Ts::set([85, 86, 88, 89, 90, 91, 94, 96, 97, 98, 99, 100, 101, 102, 103, 117, 170, 176, 106, 191, 194]);
$this->pageTitle = Ts::get(96);
return $this->render('order/cart', ['cartData' => Cart::getFormatedData()]);
}
public function actionAddToCart()
{
Ts::set([122, 194]);
Cart::add();
return $this->asJson(Cart::getData());
}
public function actionAddBookingToCart()
{
Ts::set([122, 194]);
Cart::addBooking();
return $this->asJson(Cart::getData());
}
public function actionGetCart()
{
return $this->asJson(Cart::getData());
}
public function actionCartClear()
{
Cart::clear();
return $this->asJson(['message' => 'Cart is cleared']);
}
public function actionUpdateCartQuantity()
{
Cart::updateItemQuantity();
return $this->asJson(['success' => 1]);
}
public function actionRemoveFromCart()
{
Cart::remove();
return $this->asJson(Cart::getData());
}
//endregion
//region STEP 2
public function actionOrderData()
{
if (empty($_COOKIE['cart_data']))
return $this->redirect(\Yii::$app->goToAction('user/cart'));
Ts::set([
88, 89, 90, 91, 100, 101, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 143, 144, 145, 146, 147, 191, 194
]);
$this->pageTitle = Ts::get(89);
return $this->render('order/data', ['data' => Cart::getFormatedData()]);
}
public function actionAddInvoiceData()
{
$this->userRequest->call('setInvoiceData');
}
//endregion
//region STEP 3
public function actionPurchaseInfo()
{
$user = null;
if (!empty($_SESSION['token'])) {
$user = Auth::getUserByToken($_SESSION['token']);
} else {
$user = Auth::getUser();
}
if ($user) {
setcookie('redirect', '', time() + (86400 * 30), "/");
if (empty($_COOKIE['cart_data']) || empty($_COOKIE['invoice_data']) || empty($_COOKIE['payment_method']))
return $this->redirect(\Yii::$app->goToAction('user/cart'));
Ts::set([
88, 89, 90, 91, 97, 99, 100, 101, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 194
]);
$this->pageTitle = Ts::get(90);
return $this->render('order/purchase-info', [
'cart_data' => Cart::getFormatedData(),
'invoice_data' => json_decode($_COOKIE['invoice_data']),
'payment_method' => $_COOKIE['payment_method']
]);
} else {
Ts::set([53, 54, 88, 89, 90, 91, 154, 191]);
setcookie('redirect', 'user/purchase-info', time() + (86400 * 30), "/");
return $this->render('order/user-authentication');
}
}
//endregion
//region STEP 4
public function actionSendOrder()
{
$user = Auth::getUser();
if (!empty($_GET['webview_mode'])) {
if (!empty($_SESSION['token']))
$user = Auth::getUserByToken($_SESSION['token']);
}
//if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//echo json_encode($_COOKIE);
//exit;
if (!empty($_COOKIE['cart_data']) &&
!empty($_COOKIE['cart_key']) &&
!empty($_COOKIE['payment_method']) &&
!empty($_COOKIE['invoice_data']) &&
$user
) {
$order = Order::record($_COOKIE, $user);
if ($order) {
$_SESSION['order_id'] = $order->id;
Cart::clear();
return $this->asJson(['success' => 1, 'paymentCheckout' => Payment::getCheckOut($order, $_COOKIE['payment_method'])]);
}
} else {
return $this->asJson(['error' => 1]);
}
//}
}
//endregion
//region STEP 5
public function actionFinalizeOrder()
{
if (!empty($_GET['webview_mode'])) {
header('Location: /bg/mobile-api/browser-close-complete-order/');
exit;
}
if (!empty($_SESSION['order_id'])) {
$message = [
'bg' => 'Поръчката е направена успешно. Вижте направените от Вас поръчки в рездел "Покупки" във Вашия порофил.',
'en' => 'The order has been placed successfully. View your orders in the "Purchases" section of your profile.'
];
$_SESSION['flash'] = [];
$_SESSION['flash']['success'] = true;
$_SESSION['flash']['msg'] = $message[\Yii::$app->language];
header('Location: /'.\Yii::$app->language . '/user/?orders=1');
}
exit;
}
public function actionFinalizeOrderCancel() {
return $this->render('finalize-order-cancel');
}
public function actionReceivePaymentNotification()
{
Payment::setPaymentNotification();
}
//endregion
public function actionTicketDetails() {
return $this->renderPartial('ticket-details');
}
public function actionCollectionZip() {
if (!$this->user) return $this->redirect(\Yii::$app->goTo('login'));
ZipCollection::zipByCollectionId();
//echo phpinfo();
exit;
}
public function actionCollectionDownloadZip() {
if (!$this->user) return $this->redirect(\Yii::$app->goTo('login'));
ZipCollection::downloadZip();
//echo phpinfo();
exit;
}
}