nazar-pc /
CleverStyle-Framework
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * @package HybridAuth |
||||||
| 4 | * @category modules |
||||||
| 5 | * @author Nazar Mokrynskyi <[email protected]> |
||||||
| 6 | * @license 0BSD |
||||||
| 7 | */ |
||||||
| 8 | namespace cs\modules\HybridAuth; |
||||||
| 9 | use |
||||||
| 10 | cs\Config, |
||||||
| 11 | cs\DB, |
||||||
| 12 | cs\Event, |
||||||
| 13 | cs\Language\Prefix, |
||||||
| 14 | cs\Page, |
||||||
| 15 | cs\Request, |
||||||
| 16 | cs\Response; |
||||||
| 17 | |||||||
| 18 | require_once __DIR__.'/functions.php'; |
||||||
| 19 | |||||||
| 20 | Event::instance() |
||||||
| 21 | ->on( |
||||||
| 22 | 'System/Page/render/before', |
||||||
| 23 | function () { |
||||||
| 24 | if (!Config::instance()->module('HybridAuth')->enabled()) { |
||||||
| 25 | return; |
||||||
| 26 | } |
||||||
| 27 | $Config = Config::instance(); |
||||||
| 28 | $L = new Prefix('hybridauth_'); |
||||||
| 29 | $icons_mapping = function ($provider) { |
||||||
| 30 | switch ($provider) { |
||||||
| 31 | case 'Facebook': |
||||||
| 32 | return 'facebook-f'; |
||||||
| 33 | case 'Google': |
||||||
| 34 | return 'google-plus-g'; |
||||||
| 35 | case 'Vkontakte': |
||||||
| 36 | return 'vk'; |
||||||
| 37 | default: |
||||||
| 38 | return strtolower($provider); |
||||||
| 39 | } |
||||||
| 40 | }; |
||||||
| 41 | $providers = []; |
||||||
| 42 | foreach ($Config->module('HybridAuth')->providers as $provider => $provider_settings) { |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||||
| 43 | if ($provider_settings['enabled']) { |
||||||
| 44 | $providers[$provider] = [ |
||||||
| 45 | 'name' => $L->$provider, |
||||||
| 46 | 'icon' => $icons_mapping($provider) |
||||||
| 47 | ]; |
||||||
| 48 | } |
||||||
| 49 | } |
||||||
| 50 | if ($providers) { |
||||||
| 51 | Page::instance()->config($providers, 'cs.hybridauth.providers'); |
||||||
| 52 | } |
||||||
| 53 | } |
||||||
| 54 | ) |
||||||
| 55 | ->on( |
||||||
| 56 | 'System/User/registration/confirmation/after', |
||||||
| 57 | function () { |
||||||
| 58 | if (!Config::instance()->module('HybridAuth')->enabled()) { |
||||||
| 59 | return; |
||||||
| 60 | } |
||||||
| 61 | $redirect_to = Request::instance()->cookie('HybridAuth_referer'); |
||||||
| 62 | if ($redirect_to) { |
||||||
| 63 | $Response = Response::instance(); |
||||||
| 64 | $Response->header('refresh', "5; url=$redirect_to"); |
||||||
|
0 ignored issues
–
show
The method
header() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 65 | $Response->cookie('HybridAuth_referer', ''); |
||||||
|
0 ignored issues
–
show
The method
cookie() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 66 | } |
||||||
| 67 | } |
||||||
| 68 | ) |
||||||
| 69 | ->on( |
||||||
| 70 | 'System/User/del/after', |
||||||
| 71 | function ($data) { |
||||||
| 72 | /** |
||||||
| 73 | * @var \cs\DB\_Abstract $cdb |
||||||
| 74 | */ |
||||||
| 75 | $cdb = DB::instance()->db_prime(Config::instance()->module('HybridAuth')->db('integration')); |
||||||
| 76 | $cdb->q( |
||||||
| 77 | [ |
||||||
| 78 | "DELETE FROM `[prefix]users_social_integration` |
||||||
| 79 | WHERE `id` = '%s'", |
||||||
| 80 | "DELETE FROM `[prefix]users_social_integration_contacts` |
||||||
| 81 | WHERE `id` = '%s'" |
||||||
| 82 | ], |
||||||
| 83 | $data['id'] |
||||||
| 84 | ); |
||||||
| 85 | } |
||||||
| 86 | ) |
||||||
| 87 | ->on( |
||||||
| 88 | 'admin/System/modules/install/after', |
||||||
| 89 | function ($data) { |
||||||
| 90 | if ($data['name'] != 'HybridAuth') { |
||||||
| 91 | return; |
||||||
| 92 | } |
||||||
| 93 | Config::instance()->module('HybridAuth')->providers = []; |
||||||
|
0 ignored issues
–
show
The property
providers does not exist on cs\Config\Module_Properties. Since you implemented __set, consider adding a @property annotation.
Loading history...
|
|||||||
| 94 | } |
||||||
| 95 | ); |
||||||
| 96 |