Skip to content

Commit b5fdee1

Browse files
author
Christian Bohollo
committed
Fix sessions for editora
1 parent 5f65701 commit b5fdee1

File tree

4 files changed

+27
-36
lines changed

4 files changed

+27
-36
lines changed

src/Omatech/Editora/Connector/ConnectorServiceProvider.php

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class ConnectorServiceProvider extends ServiceProvider
2626
*/
2727
public function boot()
2828
{
29-
30-
if((!isset($_SESSION) || empty($_SESSION)) && !in_array(env('APP_ENV'), array('testing', 'test')) ){
31-
session_start(); //Editora Admin Session
32-
}
33-
3429
//Publicamos el archivo de configuración
3530
$this->publishes([
3631
__DIR__.'/Configuration.php' => config_path('editora.php'),
@@ -76,36 +71,39 @@ public function boot()
7671
public function register()
7772
{
7873
$this->mergeConfigFrom(
79-
__DIR__.'/Configuration.php', 'editora'
74+
__DIR__.'/Configuration.php',
75+
'editora'
8076
);
8177

8278
/* $db = [
83-
'dbname' => env('DB_DATABASE'),
84-
'user' => env('DB_USERNAME'),
85-
'password' => env('DB_PASSWORD'),
86-
'host' => env('DB_HOST'),
87-
'driver' => 'pdo_mysql',
88-
'charset' => 'utf8'
89-
];
79+
'dbname' => env('DB_DATABASE'),
80+
'user' => env('DB_USERNAME'),
81+
'password' => env('DB_PASSWORD'),
82+
'host' => env('DB_HOST'),
83+
'driver' => 'pdo_mysql',
84+
'charset' => 'utf8'
85+
];
9086
*/
91-
$db=DB::connection()->getDoctrineConnection();
92-
$this->app->bind('Extractor', function() use($db) {
87+
$db=DB::connection()->getDoctrineConnection();
88+
$this->app->bind('Extractor', function () use ($db) {
9389
return new Extractor($db);
9490
});
9591

96-
$this->app->bind('Utils', function() use ($db) {
92+
$this->app->bind('Utils', function () use ($db) {
9793
return new Utils($db);
9894
});
99-
100-
$this->app->bind('Loader', function() use ($db) {
101-
return new Loader($db);
102-
});
95+
96+
$this->app->bind('Loader', function () use ($db) {
97+
return new Loader($db);
98+
});
10399

104100
$laravelVersion = explode('.', $this->app->version());
105101
$laravelRelease = (int) $laravelVersion[1];
106102

107103
$middlewareMethod = "middleware";
108-
if($laravelRelease >= 4) $middlewareMethod = "aliasMiddleware";
104+
if ($laravelRelease >= 4) {
105+
$middlewareMethod = "aliasMiddleware";
106+
}
109107

110108
$this->app['router']->$middlewareMethod('setLocale', 'Omatech\Editora\Connector\Middlewares\SetLocaleMiddleware');
111109

@@ -120,14 +118,11 @@ public function register()
120118
public function registerHelpers()
121119
{
122120
// Load the helpers in app/Http/helpers.php
123-
if (file_exists($file = __DIR__.'/Helper/EditoraHelper.php'))
124-
{
121+
if (file_exists($file = __DIR__.'/Helper/EditoraHelper.php')) {
125122
require $file;
126123
}
127-
if (file_exists($file = __DIR__.'/Helper/StaticTextHelper.php'))
128-
{
124+
if (file_exists($file = __DIR__.'/Helper/StaticTextHelper.php')) {
129125
require $file;
130126
}
131127
}
132-
133128
}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<?php
2-
Blade::directive('generate_edit_link', function($instance)
3-
{
2+
Blade::directive('generate_edit_link', function ($instance) {
43
$instanceId = $instance."['metadata']['id']";
54
$classId = $instance."['metadata']['class_id']";
65

76
$php = "<?php
8-
if(isset(\$_SESSION['user_id']) && \$_SESSION['user_id'] !== '') {
7+
if(session()->has('user_id') && session()->get('user_id') !== '') {
98
echo '<a href=\"/'.config('editora.adminAlias').'/view_instance?p_class_id='.{$classId}.'&p_inst_id='.{$instanceId}.'\" class=\"front-edit\" title=\"Editar\" target=\"_blank\" style=\"display: none;\"><img class=\"edit_img\" src=\"/images/editar.png\" alt=\"Editar\"/></a>';
109
}
1110
?>";
1211

1312
return $php;
1413
});
15-
16-

src/Omatech/Editora/Connector/Directives/GenerateEditoraEditScriptsDirective.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
2-
Blade::directive('editora_scripts', function()
3-
{
2+
Blade::directive('editora_scripts', function () {
43
return "<?php
5-
if(isset(\$_SESSION[\"rol_id\"]) && \$_SESSION['rol_id'] !== '')
4+
if(session()->has('rol_id') && session()->get('rol_id') !== '')
65
{
76
echo \Omatech\Editora\Utils\Strings::get_headerEM();
87
echo \Omatech\Editora\Utils\Strings::get_linkEM();

src/Omatech/Editora/Connector/EditoraController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(Request $request)
4444
$currentLang = (config('editora.forcedLanguage') !== '') ? config('editora.forcedLanguage') : $currentLang;
4545

4646
session(['locale' => $currentLang]);
47-
$_SESSION['u_lang'] = $currentLang;
47+
session(['u_lang' => $currentLang]);
4848
App::setLocale(session('locale'));
4949

5050
/**
@@ -130,7 +130,7 @@ private function editMode($req_info)
130130
$preview = false;
131131

132132
if ($req_info !== null && $req_info == 1) {
133-
if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != '') {
133+
if (session()->has('user_id') && session()->get('user_id') != '') {
134134
$preview = true;
135135
} else {
136136
die('Not connected to CMS!');

0 commit comments

Comments
 (0)