mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Version 11.6 Add phone to sign-up screen
This commit is contained in:
parent
176ed7fc02
commit
6727623b0a
13 changed files with 229 additions and 144 deletions
|
@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$installationVersion = "11.5";
|
||||
$installationVersion = "11.6";
|
||||
|
||||
error_log("Installation: ".__LINE__." ". json_encode($_POST));
|
||||
header('Content-Type: application/json');
|
||||
|
|
|
@ -39,6 +39,7 @@ CREATE TABLE IF NOT EXISTS `users` (
|
|||
`city` VARCHAR(100) NULL DEFAULT NULL,
|
||||
`donationLink` VARCHAR(225) NULL DEFAULT NULL,
|
||||
`extra_info` TEXT NULL DEFAULT NULL,
|
||||
`phone` VARCHAR(255) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `user_UNIQUE` (`user` ASC))
|
||||
ENGINE = InnoDB;
|
||||
|
|
44
objects/uploadUserPhoto.json.php
Normal file
44
objects/uploadUserPhoto.json.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
global $global, $config;
|
||||
if (!isset($global['systemRootPath'])) {
|
||||
require_once '../videos/configuration.php';
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
if (!User::isLogged()) {
|
||||
$obj->msg = 'You can\'t edit this file';
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
$users_id = User::getId();
|
||||
|
||||
$imagePath = "videos/userPhoto/";
|
||||
//Check write Access to Directory
|
||||
$dirPath = $global['systemRootPath'] . $imagePath;
|
||||
|
||||
make_path($dirPath);
|
||||
|
||||
|
||||
$fileName = 'photo' . User::getId() . '.png';
|
||||
$photoURL = $imagePath . $fileName;
|
||||
$photoFullPath = $dirPath . $fileName;
|
||||
$obj->url = $photoURL;
|
||||
|
||||
|
||||
$obj->imagePNGResponse = saveCroppieImage($photoFullPath, "image");
|
||||
if ($obj->imagePNGResponse) {
|
||||
$user = new User(User::getId());
|
||||
$user->setPhotoURL($photoURL);
|
||||
if ($user->save()) {
|
||||
User::deleteOGImage(User::getId());
|
||||
User::updateSessionInfo();
|
||||
clearCache(true);
|
||||
$obj->error = false;
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($obj));
|
||||
|
|
@ -40,6 +40,7 @@ class User {
|
|||
private $donationLink;
|
||||
private $modified;
|
||||
private $extra_info;
|
||||
private $phone;
|
||||
public static $DOCUMENT_IMAGE_TYPE = "Document Image";
|
||||
public static $channel_artTV = 'tv';
|
||||
public static $channel_artDesktopMax = 'desktop_max';
|
||||
|
@ -67,6 +68,14 @@ class User {
|
|||
}
|
||||
}
|
||||
|
||||
function getPhone() {
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
function setPhone($phone): void {
|
||||
$this->phone = $phone;
|
||||
}
|
||||
|
||||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
@ -631,7 +640,7 @@ if (typeof gtag !== \"function\") {
|
|||
$values[] = $this->canViewChart;
|
||||
$sql .= "canViewChart = ?, ";
|
||||
}
|
||||
$formats .= "ssssssissssssssssi";
|
||||
$formats .= "ssssssisssssssssssi";
|
||||
$values[] = $this->status;
|
||||
$values[] = $this->photoURL;
|
||||
$values[] = $this->backgroundURL;
|
||||
|
@ -649,21 +658,22 @@ if (typeof gtag !== \"function\") {
|
|||
$values[] = $this->region;
|
||||
$values[] = $this->city;
|
||||
$values[] = $this->donationLink;
|
||||
$values[] = $this->phone;
|
||||
$values[] = $this->id;
|
||||
|
||||
$sql .= "status = ?, "
|
||||
. "photoURL = ?, backgroundURL = ?, "
|
||||
. "recoverPass = ?, about = ?, "
|
||||
. " channelName = ?, emailVerified = ? , analyticsCode = ?, externalOptions = ? , "
|
||||
. " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , "
|
||||
. " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , phone = ? , "
|
||||
. " modified = now() WHERE id = ?";
|
||||
} else {
|
||||
$formats = "ssssiiiissssss";
|
||||
$formats = "ssssiiiisssssss";
|
||||
$values = [$user, $password, $this->email, $name, $this->isAdmin, $this->canStream, $this->canUpload, $this->canCreateMeet,
|
||||
$status, $this->photoURL, $this->recoverPass, $channelName, $this->analyticsCode, $this->externalOptions,];
|
||||
$sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canCreateMeet, canViewChart, status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions) "
|
||||
$status, $this->photoURL, $this->recoverPass, $channelName, $this->analyticsCode, $this->externalOptions, $this->phone];
|
||||
$sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canCreateMeet, canViewChart, status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions, phone) "
|
||||
. " VALUES (?,?,?,?,?,?,?,?, false, "
|
||||
. "?,?,?, now(), now(),?,?,?)";
|
||||
. "?,?,?, now(), now(),?,?,?,?)";
|
||||
}
|
||||
$insert_row = sqlDAL::writeSql($sql, $formats, $values);
|
||||
if ($insert_row) {
|
||||
|
|
|
@ -71,6 +71,7 @@ $user->setUser($_POST['user']);
|
|||
$user->setPassword($_POST['pass']);
|
||||
$user->setEmail($_POST['email']);
|
||||
$user->setName($_POST['name']);
|
||||
$user->setPhone(@$_POST['phone']);
|
||||
|
||||
$user->setCanUpload($config->getAuthCanUploadVideos());
|
||||
|
||||
|
|
|
@ -6,9 +6,12 @@ if (!isset($global['systemRootPath'])) {
|
|||
}
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
$obj->msg = '';
|
||||
$obj->users_id = 0;
|
||||
|
||||
if (!User::isLogged()) {
|
||||
$obj->error = __("Is not logged");
|
||||
$obj->msg = __("Is not logged");
|
||||
die(json_encode($obj));
|
||||
}
|
||||
$_REQUEST["do_not_login"]=1;
|
||||
|
@ -22,25 +25,26 @@ $user->setName($_POST['name']);
|
|||
$user->setAbout($_POST['about']);
|
||||
$user->setAnalyticsCode($_POST['analyticsCode']);
|
||||
$user->setDonationLink($_POST['donationLink']);
|
||||
$user->setPhone($_POST['phone']);
|
||||
$unique = $user->setChannelName($_POST['channelName']);
|
||||
if (!$unique) {
|
||||
$obj->error = __("Channel name already exists");
|
||||
$obj->msg = __("Channel name already exists");
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
if (empty($user->getBdId())) {
|
||||
$obj->error = __("User not found");
|
||||
$obj->msg = __("User not found");
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
if (!empty($advancedCustomUser->emailMustBeUnique)) {
|
||||
if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$obj->error = __("You must specify a valid email")." {$_POST['email']} (update)";
|
||||
$obj->msg = __("You must specify a valid email")." {$_POST['email']} (update)";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
$userFromEmail = User::getUserFromEmail($_POST['email']);
|
||||
if (!empty($userFromEmail) && $userFromEmail['id'] !== $user->getBdId()) {
|
||||
$obj->error = __("Email already exists");
|
||||
$obj->msg = __("Email already exists");
|
||||
die(json_encode($obj));
|
||||
}
|
||||
}
|
||||
|
@ -48,5 +52,9 @@ if (!empty($advancedCustomUser->emailMustBeUnique)) {
|
|||
if (User::isAdmin() && !empty($_POST['status'])) {
|
||||
$user->setStatus($_POST['status']);
|
||||
}
|
||||
echo '{"status":"' . $user->save() . '"}';
|
||||
|
||||
$obj->users_id = $user->save();
|
||||
|
||||
$obj->error = empty($obj->users_id);
|
||||
User::updateSessionInfo();
|
||||
die(json_encode($obj));
|
|
@ -155,7 +155,10 @@ class CustomizeUser extends PluginAbstract
|
|||
self::addDataObjectHelper('enableExtraInfo', 'Enable user extra info', 'You can add custom fields on user´s profile, Edit this plugin to tell what fields should be saved');
|
||||
$obj->videosSearchAlsoSearchesOnChannelName = false;
|
||||
self::addDataObjectHelper('videosSearchAlsoSearchesOnChannelName', 'Videos search also searches on ChannelName', 'With this checked when you searc a video we will also return the results that matches with the channel name');
|
||||
|
||||
|
||||
$obj->doNotShowPhoneMyAccount = true;
|
||||
$obj->doNotShowPhoneOnSignup = true;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,19 @@ require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
|||
|
||||
allowOrigin();
|
||||
$obj = AVideoPlugin::getObjectData("MobileManager");
|
||||
|
||||
$customizeUser = AVideoPlugin::getDataObject('CustomizeUser');
|
||||
$obj->doNotShowPhoneOnSignup = $customizeUser->doNotShowPhoneOnSignup;
|
||||
|
||||
$chat2 = AVideoPlugin::getDataObjectIfEnabled('Chat2');
|
||||
if(!empty($chat2)){
|
||||
$obj->chat2ShowOnLive = $chat2->showOnLive;
|
||||
$obj->chat2ShowOnUserVideos = $chat2->showOnUserVideos;
|
||||
}else{
|
||||
$obj->chat2ShowOnLive = false;
|
||||
$obj->chat2ShowOnUserVideos = false;
|
||||
}
|
||||
|
||||
$obj->EULA = nl2br($obj->EULA->value);
|
||||
$obj->YPTSocket = AVideoPlugin::getDataObjectIfEnabled('YPTSocket');
|
||||
$obj->language = $config->getLanguage();
|
||||
|
|
13
updatedb/updateDb.v11.6.sql
Normal file
13
updatedb/updateDb.v11.6.sql
Normal file
|
@ -0,0 +1,13 @@
|
|||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
||||
|
||||
ALTER TABLE `users`
|
||||
ADD COLUMN `phone` VARCHAR(255) NULL DEFAULT NULL;
|
||||
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||
|
||||
UPDATE configurations SET version = '11.6', modified = now() WHERE id = 1;
|
|
@ -81,7 +81,8 @@
|
|||
</div>
|
||||
<?php
|
||||
foreach ($userGroups as $value) {
|
||||
$gridID = "userGroupGrid{$value['id']}"; ?>
|
||||
$gridID = "userGroupGrid{$value['id']}";
|
||||
?>
|
||||
<div id="userGroupTab<?php echo $value['id']; ?>" class="tab-pane fade">
|
||||
<div class="btn-group pull-left" id="filterButtonsUG<?php echo $value['id']; ?>">
|
||||
<div class="btn-group ">
|
||||
|
@ -136,6 +137,13 @@
|
|||
<input type="email" id="inputEmail" class="form-control" placeholder="<?php echo __("E-mail"); ?>" >
|
||||
<label for="inputName" class="sr-only"><?php echo __("Name"); ?></label>
|
||||
<input type="text" id="inputName" class="form-control " placeholder="<?php echo __("Name"); ?>" >
|
||||
<?php
|
||||
if (empty($advancedCustomUser->doNotShowPhoneOnSignup)) {
|
||||
?>
|
||||
<label for="phone" class="sr-only"><?php echo __("Phone"); ?></label>
|
||||
<input type="text" id="phone" class="form-control " placeholder="<?php echo __("Phone"); ?>" >
|
||||
<?php }
|
||||
?>
|
||||
<label for="inputChannelName" class="sr-only"><?php echo __("Channel Name"); ?></label>
|
||||
<input type="text" id="inputChannelName" class="form-control" placeholder="<?php echo __("Channel Name"); ?>" >
|
||||
<label for="inputAnalyticsCode" class="sr-only"><?php echo __("Analytics Code"); ?></label>
|
||||
|
@ -143,49 +151,49 @@
|
|||
<small>Do not paste the full javascript code, paste only the gtag id</small>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item <?php echo User::isAdmin() ? "" : "hidden"; ?>">
|
||||
<?php echo __("is Admin"); ?>
|
||||
<?php echo __("is Admin"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="isAdmin" id="isAdmin"/>
|
||||
<label for="isAdmin" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("Can Stream Videos"); ?>
|
||||
<?php echo __("Can Stream Videos"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="canStream" id="canStream"/>
|
||||
<label for="canStream" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("Can Upload Videos"); ?>
|
||||
<?php echo __("Can Upload Videos"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="canUpload" id="canUpload"/>
|
||||
<label for="canUpload" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("Can view chart"); ?>
|
||||
<?php echo __("Can view chart"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="canViewChart" id="canViewChart"/>
|
||||
<label for="canViewChart" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("Can create meet"); ?>
|
||||
<?php echo __("Can create meet"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="canCreateMeet" id="canCreateMeet"/>
|
||||
<label for="canCreateMeet" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("E-mail Verified"); ?>
|
||||
<?php echo __("E-mail Verified"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="isEmailVerified" id="isEmailVerified"/>
|
||||
<label for="isEmailVerified" class="label-success"></label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<?php echo __("is Active"); ?>
|
||||
<?php echo __("is Active"); ?>
|
||||
<div class="material-switch pull-right">
|
||||
<input type="checkbox" value="status" id="status"/>
|
||||
<label for="status" class="label-success"></label>
|
||||
|
@ -197,7 +205,7 @@
|
|||
</ul>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active">
|
||||
<?php echo __("User Groups"); ?>
|
||||
<?php echo __("User Groups"); ?>
|
||||
<a href="#" class="btn btn-info btn-xs pull-right" data-toggle="popover" title="<?php echo __("What is User Groups"); ?>" data-placement="bottom" data-content="<?php echo __("By associating groups with this user, they will be able to see all the videos that are related to this group"); ?>"><span class="fa fa-question-circle" aria-hidden="true"></span> <?php echo __("Help"); ?></a>
|
||||
</li>
|
||||
<?php
|
||||
|
@ -205,7 +213,7 @@
|
|||
?>
|
||||
<li class="list-group-item usergroupsLi" id="usergroupsLi<?php echo $value['id']; ?>">
|
||||
<span class="fa fa-unlock"></span>
|
||||
<?php echo $value['group_name']; ?>
|
||||
<?php echo $value['group_name']; ?>
|
||||
<span class="label label-info"><?php echo $value['total_videos']; ?> <?php echo __("Videos linked"); ?></span>
|
||||
<span class="label label-warning dynamicLabel"><i class="fas fa-link"></i> <?php echo __("Dynamic group"); ?></span>
|
||||
<div class="material-switch pull-right">
|
||||
|
@ -335,6 +343,7 @@
|
|||
$('#inputPassword').val('');
|
||||
$('#inputEmail').val('');
|
||||
$('#inputName').val('');
|
||||
$('#phone').val('');
|
||||
$('#inputChannelName').val('');
|
||||
$('#inputAnalyticsCode').val('');
|
||||
$('#isAdmin').prop('checked', false);
|
||||
|
@ -377,6 +386,7 @@ print AVideoPlugin::updateUserFormJS();
|
|||
"pass": $('#inputPassword').val(),
|
||||
"email": $('#inputEmail').val(),
|
||||
"name": $('#inputName').val(),
|
||||
"phone": $('#phone').val(),
|
||||
"channelName": $('#inputChannelName').val(),
|
||||
"analyticsCode": $('#inputAnalyticsCode').val(),
|
||||
"isAdmin": $('#isAdmin').is(':checked'),
|
||||
|
@ -484,6 +494,7 @@ print AVideoPlugin::updateUserFormJS();
|
|||
$('#inputPassword').val('');
|
||||
$('#inputEmail').val(row.email);
|
||||
$('#inputName').val(row.name);
|
||||
$('#phone').val(row.phone);
|
||||
$('#inputChannelName').val(row.channelName);
|
||||
$('#inputAnalyticsCode').val(row.analyticsCode);
|
||||
$('.userGroups').prop('checked', false);
|
||||
|
@ -492,9 +503,9 @@ print AVideoPlugin::updateUserFormJS();
|
|||
|
||||
for (var index in row.groups) {
|
||||
$('#userGroup' + row.groups[index].id).prop('checked', true);
|
||||
if(row.groups[index].isDynamic){
|
||||
if (row.groups[index].isDynamic) {
|
||||
$('#usergroupsLi' + row.groups[index].id).addClass('dynamic');
|
||||
$('#usergroupsLi' + row.groups[index].id+' input').attr("disabled", true);
|
||||
$('#usergroupsLi' + row.groups[index].id + ' input').attr("disabled", true);
|
||||
}
|
||||
}
|
||||
$('#isAdmin').prop('checked', (row.isAdmin == "1" ? true : false));
|
||||
|
|
|
@ -83,6 +83,20 @@ if (!empty($_GET['siteRedirectUri'])) {
|
|||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
<?php
|
||||
if (empty($advancedCustomUser->doNotShowPhoneOnSignup)) {
|
||||
?>
|
||||
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
|
||||
<label class="col-sm-4 control-label hidden-xs"><?php echo __("Phone"); ?></label>
|
||||
<div class="col-sm-8 inputGroupContainer">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fas fa-phone"></i></span>
|
||||
<input id="phone" placeholder="<?php echo __("Phone"); ?>" class="form-control" type="text" value="" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
|
||||
<label class="col-sm-4 control-label hidden-xs"><?php echo __("New Password"); ?></label>
|
||||
<div class="col-sm-8 inputGroupContainer">
|
||||
|
@ -155,6 +169,7 @@ if (!empty($_GET['siteRedirectUri'])) {
|
|||
"user": $('#inputUser').val(),
|
||||
"pass": $('#inputPassword').val(),
|
||||
"email": $('#inputEmail').val(),
|
||||
"phone": $('#Phone').val(),
|
||||
"name": $('#inputName').val(),
|
||||
"captcha": $('#captchaText').val()
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label"><?php echo !empty($advancedCustomUser->forceLoginToBeTheEmail) ? __("E-mail") : __("User"); ?></label>
|
||||
<label class="col-md-4 control-label"><?php echo!empty($advancedCustomUser->forceLoginToBeTheEmail) ? __("E-mail") : __("User"); ?></label>
|
||||
<div class="col-md-8 inputGroupContainer">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
||||
|
@ -81,6 +81,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group <?php
|
||||
if (!empty($advancedCustomUser->doNotShowPhone)) {
|
||||
echo " hidden ";
|
||||
}
|
||||
?>">
|
||||
<label class="col-md-4 control-label"><?php echo __("Phone"); ?></label>
|
||||
<div class="col-md-8 inputGroupContainer">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fas fa-phone"></i></span>
|
||||
<input id="phone" placeholder="<?php echo __("Phone"); ?>" class="form-control" type="text" value="<?php echo $user->getPhone(); ?>" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label"><?php echo __("New Password"); ?></label>
|
||||
<div class="col-md-8 inputGroupContainer">
|
||||
|
@ -161,55 +175,26 @@
|
|||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<?php echo __("Profile Photo"); ?><br>
|
||||
<?php
|
||||
if($vloObj = AVideoPlugin::getDataObjectIfEnabled('VideoLogoOverlay')){
|
||||
if($vloObj->useUserChannelImageAsLogo){
|
||||
?>
|
||||
<small><?php echo __("This image will appear in your livestream"); ?></small><br>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<small><?php echo __("You must click save to confirm"); ?></small>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<div class="col-md-12 ">
|
||||
<div id="croppie"></div>
|
||||
<center>
|
||||
<a id="upload-btn" class="btn btn-primary"><i class="fa fa-upload"></i> <?php echo __("Upload a Photo"); ?></a>
|
||||
</center>
|
||||
<div class="alert alert-info">
|
||||
<?php echo __("Make sure you click on the Save button after change the photo"); ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" id="upload" value="Choose a file" accept="image/*" style="display: none;" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/userPhotoUploadInclude.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<?php
|
||||
$channelArtRelativePath = User::getBackgroundURLFromUserID(User::getId());
|
||||
<?php
|
||||
$channelArtRelativePath = User::getBackgroundURLFromUserID(User::getId());
|
||||
|
||||
$finalWidth = 2560;
|
||||
$finalHeight = 1440;
|
||||
if(isMobile()){
|
||||
$screenWidth = 640;
|
||||
$screenHeight = 360;
|
||||
}else{
|
||||
$screenWidth = 960;
|
||||
$screenHeight = 540;
|
||||
}
|
||||
$factorW = $screenWidth / $finalWidth;
|
||||
include $global['systemRootPath'] . 'view/userChannelArtUploadInclude.php';
|
||||
?>
|
||||
$finalWidth = 2560;
|
||||
$finalHeight = 1440;
|
||||
if (isMobile()) {
|
||||
$screenWidth = 640;
|
||||
$screenHeight = 360;
|
||||
} else {
|
||||
$screenWidth = 960;
|
||||
$screenHeight = 540;
|
||||
}
|
||||
$factorW = $screenWidth / $finalWidth;
|
||||
include $global['systemRootPath'] . 'view/userChannelArtUploadInclude.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -232,27 +217,6 @@
|
|||
str = $('#analyticsCode').val();
|
||||
return str === '' || (/^ua-\d{4,9}-\d{1,4}$/i).test(str.toString());
|
||||
}
|
||||
function readFile(input, crop) {
|
||||
console.log(input);
|
||||
console.log($(input)[0]);
|
||||
console.log($(input)[0].files);
|
||||
if ($(input)[0].files && $(input)[0].files[0]) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
crop.croppie('bind', {
|
||||
url: e.target.result
|
||||
}).then(function () {
|
||||
console.log('jQuery bind complete');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
reader.readAsDataURL($(input)[0].files[0]);
|
||||
} else {
|
||||
avideoAlert("Sorry - you're browser doesn't support the FileReader API");
|
||||
}
|
||||
}
|
||||
|
||||
function updateUserFormSubmit() {
|
||||
|
||||
|
@ -262,6 +226,7 @@
|
|||
"user": $('#inputUser').val(),
|
||||
"pass": $('#inputPassword').val(),
|
||||
"email": $('#inputEmail').val(),
|
||||
"phone": $('#phone').val(),
|
||||
"name": $('#inputName').val(),
|
||||
"about": $('#textAbout').val(),
|
||||
"channelName": $('#channelName').val(),
|
||||
|
@ -270,67 +235,25 @@
|
|||
},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
if (response.status > "0") {
|
||||
uploadCrop.croppie('result', {
|
||||
type: 'canvas',
|
||||
size: 'viewport'
|
||||
}).then(function (resp) {
|
||||
console.log("userSavePhoto");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo $global['webSiteRootURL']; ?>objects/userSavePhoto.php",
|
||||
data: {
|
||||
imgBase64: resp,
|
||||
},
|
||||
success: function (response) {
|
||||
modal.hidePleaseWait();
|
||||
avideoResponse(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (response.error) {
|
||||
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
|
||||
modal.hidePleaseWait();
|
||||
} else {
|
||||
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your user has NOT been updated!"); ?>", "error");
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
avideoResponse(response);
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#upload').on('change', function () {
|
||||
readFile(this, uploadCrop);
|
||||
});
|
||||
$('#upload-btn').on('click', function (ev) {
|
||||
$('#upload').trigger("click");
|
||||
});
|
||||
<?php
|
||||
if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
|
||||
?>
|
||||
?>
|
||||
$('#inputUser').on('keyup', function () {
|
||||
$('#inputEmail').val($(this).val());
|
||||
});
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
uploadCrop = $('#croppie').croppie({
|
||||
url: '<?php echo $user->getPhoto(); ?>',
|
||||
enableExif: true,
|
||||
enforceBoundary: false,
|
||||
mouseWheelZoom: false,
|
||||
viewport: {
|
||||
width: 150,
|
||||
height: 150
|
||||
},
|
||||
boundary: {
|
||||
width: 150,
|
||||
height: 150
|
||||
}
|
||||
});
|
||||
|
||||
$('#updateUserForm').submit(function (evt) {
|
||||
evt.preventDefault();
|
||||
if (!isAnalytics()) {
|
||||
|
@ -348,9 +271,7 @@ if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
|
|||
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your password does not match!"); ?>", "error");
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
updateUserFormSubmit();
|
||||
}, 1000);
|
||||
updateUserFormSubmit();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
45
view/userPhotoUploadInclude.php
Normal file
45
view/userPhotoUploadInclude.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
$finalWidth = 150;
|
||||
$finalHeight = 150;
|
||||
$screenWidth = 150;
|
||||
$caUid = 'Photo_' . uniqid();
|
||||
?>
|
||||
<div class="form-group" id="<?php echo $caUid; ?>">
|
||||
<?php
|
||||
$croppie = getCroppie(__('Profile Photo'), 'userPhotoUpload', $finalWidth, $finalHeight, $screenWidth);
|
||||
echo $croppie['html'];
|
||||
?>
|
||||
</div>
|
||||
<button class="btn btn-success btn-block" type="button" onclick="<?php echo $croppie['getCroppieFunction']; ?>"><i class="fas fa-save"></i> <?php echo __('Save Profile Photo'); ?></button>
|
||||
<?php
|
||||
|
||||
if ($vloObj = AVideoPlugin::getDataObjectIfEnabled('VideoLogoOverlay')) {
|
||||
if ($vloObj->useUserChannelImageAsLogo) {
|
||||
?>
|
||||
<div class="alert alert-info"><?php echo __("This image will appear in your livestream"); ?></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
<?php
|
||||
echo $croppie['restartCroppie'] . "('" . User::getPhoto() . "');";
|
||||
?>
|
||||
});
|
||||
function userPhotoUpload(image) {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL'] . "objects/uploadUserPhoto.json.php"; ?>',
|
||||
data: {
|
||||
image: image
|
||||
},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
avideoResponse(response);
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue