From 153da7c63bd421f922d666011991c48a86a900d9 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Wed, 20 Nov 2024 14:44:23 +0700 Subject: [PATCH] registration can force to upload photo --- system/controllers/register.php | 19 ++++++ system/lan/english.json | 5 +- ui/ui/app-settings.tpl | 109 +++++++++++++++++++++----------- ui/ui/customer/register-otp.tpl | 16 +++-- ui/ui/customer/register.tpl | 6 ++ ui/ui/customfield.tpl | 4 +- version.json | 2 +- 7 files changed, 115 insertions(+), 46 deletions(-) diff --git a/system/controllers/register.php b/system/controllers/register.php index 62fa0c54..63787dd1 100644 --- a/system/controllers/register.php +++ b/system/controllers/register.php @@ -95,6 +95,25 @@ switch ($do) { $d->phonenumber = $phone_number; if ($d->save()) { $user = $d->id(); + if ($config['photo_register'] == 'yes' && !empty($_FILES['photo']['name']) && file_exists($_FILES['photo']['tmp_name'])) { + if (function_exists('imagecreatetruecolor')) { + $hash = md5_file($_FILES['photo']['tmp_name']); + $subfolder = substr($hash, 0, 2); + $folder = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR; + if (!file_exists($folder)) { + mkdir($folder); + } + $folder = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR . $subfolder . DIRECTORY_SEPARATOR; + if (!file_exists($folder)) { + mkdir($folder); + } + $imgPath = $folder . $hash . '.jpg'; + File::resizeCropImage($_FILES['photo']['tmp_name'], $imgPath, 1600, 1600, 100); + $d->photo = '/photos/' . $subfolder . '/' . $hash . '.jpg'; + $d->save(); + } + } + if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']); User::setFormCustomField($user); run_hook('register_user'); #HOOK r2(U . 'login', 's', Lang::T('Register Success! You can login now')); diff --git a/system/lan/english.json b/system/lan/english.json index 73189be7..060d9165 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -915,5 +915,8 @@ "Data_Change": "Data Change", "Photo": "Photo", "Home_Address": "Home Address", - "Email_Address": "Email Address" + "Email_Address": "Email Address", + "Photo_Required": "Photo Required", + "Customer_Registration_need_to_upload_their_photo": "Customer Registration need to upload their photo", + "Account_already_exists": "Account already exists" } \ No newline at end of file diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index eadbf901..882d9507 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -20,23 +20,19 @@
- +
- {Lang::T('This Name will be shown on the - Title')} + {Lang::T('This Name will be shown on the Title')}
- {Lang::T('For PDF Reports | Best size 1078 x 200 | - uploaded image - will be - autosize')} + {Lang::T('For PDF Reports | Best size 1078 x 200 | uploaded image will be autosize')}
logo for PDF @@ -166,12 +162,14 @@
-
+
- +
- {Lang::T('This Name will be shown on the login wallpaper')} + {Lang::T('This Name will be shown on the login wallpaper')}
- +
- {Lang::T('This will also display on wallpaper, You can use html tag')} + {Lang::T('This will also display on wallpaper, You can use html tag')}
- - {Lang::T('Best size 30 x 30 | uploaded image will be autosize')} + + {Lang::T('Best size 30 x 30 | uploaded image will be autosize')}
- Favicon + Favicon
- - {Lang::T('Best size 300 x 60 | uploaded image will be autosize')} + + {Lang::T('Best size 300 x 60 | uploaded image will be autosize')}
- Logo + Logo
- - {Lang::T('Best size 1920 x 1080 | uploaded image will be autosize')} + + {Lang::T('Best size 1920 x 1080 | uploaded image will be autosize')}
- Wallpaper + Wallpaper
@@ -304,6 +320,22 @@
+
+ +
+ +
+

+ {Lang::T('Customer Registration need to upload their photo')} +

+
@@ -362,8 +394,8 @@
@@ -409,7 +441,8 @@

- {Lang::T('Cross-site request forgery')} + {Lang::T('Cross-site request forgery')}