1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Pre Update for new version

This commit is contained in:
Daniel 2022-03-03 21:07:08 -03:00
parent 038b384d90
commit 3a0eb0298e
42 changed files with 1976 additions and 392 deletions

View file

@ -98,6 +98,7 @@ Options All -Indexes
RewriteRule ^meet/([0-9]+)$ plugin/Meet/iframe.php?meet_schedule_id=$1 [NC,L,QSA]
RewriteRule ^live/([0-9]+)/(.+)/(.+)$ plugin/Live/?live_servers_id=$1&c=$2&live_index=$3 [NC,L,QSA]
RewriteRule ^live/([0-9]+)/(.+)$ plugin/Live/?live_servers_id=$1&c=$2 [NC,L,QSA]
RewriteRule ^live/?$ plugin/Gallery/view/mainAreaLive.php [NC,L,QSA]
RewriteRule ^liveLink/([0-9]+).*$ plugin/LiveLinks/view/Live.php?link=$1 [NC,L,QSA]
RewriteRule ^liveLinkEmbed/([0-9]+).*$ plugin/LiveLinks/view/Live.php?link=$1&embed=1 [NC,L,QSA]

View file

@ -4,9 +4,9 @@ $filter = [
'disableNativeSignIn'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
'disablePersonalInfo'=>__('Disable the My Account personal info like: First and Last Name and address'),
'newUsersCanStream'=>__('Automatic allow new users to use your Livestream Platform'),
'doNotIndentifyByEmail'=>__('Do not show user\'s email on the site'),
'doNotIndentifyByName'=>__('Do not show user\'s name on the site'),
'doNotIndentifyByUserName'=>__('Do not show user\'s username on the site'),
'doNotIdentifyByEmail'=>__('Do not show user\'s email on the site'),
'doNotIdentifyByName'=>__('Do not show user\'s name on the site'),
'doNotIdentifyByUserName'=>__('Do not show user\'s username on the site'),
'unverifiedEmailsCanNOTLogin'=>__('Users must verify their emails before login'),
'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'),
'sendVerificationMailAutomatic'=>__('After sign up we will automatic send a verification email'),

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit;
}
$installationVersion = "11.6";
$installationVersion = "11.7";
error_log("Installation: ".__LINE__." ". json_encode($_POST));
header('Content-Type: application/json');

View file

@ -40,10 +40,35 @@ CREATE TABLE IF NOT EXISTS `users` (
`donationLink` VARCHAR(225) NULL DEFAULT NULL,
`extra_info` TEXT NULL DEFAULT NULL,
`phone` VARCHAR(255) NULL DEFAULT NULL,
`is_company` TINYINT(4) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `user_UNIQUE` (`user` ASC))
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `users_affiliations` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`created` DATETIME NULL DEFAULT NULL,
`modified` DATETIME NULL DEFAULT NULL,
`users_id_company` INT(11) NOT NULL,
`users_id_affiliate` INT(11) NOT NULL,
`status` CHAR(1) NULL DEFAULT NULL,
`company_agree_date` DATETIME NULL DEFAULT NULL,
`affiliate_agree_date` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_users_affiliations_users1_idx` (`users_id_company` ASC),
INDEX `fk_users_affiliations_users2_idx` (`users_id_affiliate` ASC),
CONSTRAINT `fk_users_affiliations_users1`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_users_affiliations_users2`
FOREIGN KEY (`users_id_affiliate`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `users_blob` (
`id` INT NOT NULL AUTO_INCREMENT,
@ -155,7 +180,9 @@ CREATE TABLE IF NOT EXISTS `videos` (
`duration_in_seconds` INT NULL DEFAULT NULL,
`likes` INT(11) NULL DEFAULT NULL,
`dislikes` INT(11) NULL DEFAULT NULL,
`users_id_company` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_videos_users1_idx` (`users_id_company` ASC),
INDEX `fk_videos_users_idx` (`users_id` ASC),
INDEX `fk_videos_categories1_idx` (`categories_id` ASC),
UNIQUE INDEX `clean_title_UNIQUE` (`clean_title` ASC),
@ -196,7 +223,12 @@ CONSTRAINT `fk_videos_playlists1`
FOREIGN KEY (`serie_playlists_id`)
REFERENCES `playlists` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ON UPDATE CASCADE,
CONSTRAINT `fk_videos_users1`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE SET NULL
ON UPDATE SET NULL)
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `videos_metadata` (

View file

@ -4594,18 +4594,25 @@ function isHLS() {
return false;
}
function getRedirectUri() {
if (!empty($_GET['redirectUri'])) {
function getRedirectUri($returnThisIfRedirectUriIsNotSet = false) {
if (isValidURL(@$_GET['redirectUri'])) {
return $_GET['redirectUri'];
}
if (!empty($_SESSION['redirectUri'])) {
if (isValidURL(@$_SESSION['redirectUri'])) {
return $_SESSION['redirectUri'];
}
if (!empty($_SERVER["HTTP_REFERER"])) {
if (isValidURL(@$_REQUEST["redirectUri"])) {
return $_REQUEST["redirectUri"];
}
if (isValidURL(@$_SERVER["HTTP_REFERER"])) {
return $_SERVER["HTTP_REFERER"];
}
if (isValidURL($returnThisIfRedirectUriIsNotSet)) {
return $returnThisIfRedirectUriIsNotSet;
} else {
return getRequestURI();
}
}
function setRedirectUri($redirectUri) {
_session_start();
@ -5458,8 +5465,17 @@ function _json_encode($object) {
if (empty($json) && json_last_error()) {
_error_log("_json_encode: Error 6 Found: " . json_last_error_msg());
$json = json_encode($objectDecoded, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
if (empty($json) && json_last_error()) {
_error_log("_json_encode: Error 7 Found: " . json_last_error_msg());
array_walk_recursive($objectDecoded, function (&$item) {
if (is_string($item)) {
$item = cleanString($item);
}
});
$json = json_encode($users);
if (json_last_error()) {
_error_log("_json_encode: Error 8 Found: " . json_last_error_msg());
}
}
}
}
@ -6822,7 +6838,7 @@ function deleteStatsNotifications() {
ObjectYPT::deleteCache($cacheName);
}
function getStatsNotifications($force_recreate = false) {
function getStatsNotifications($force_recreate = false, $listItIfIsAdminOrOwner = true) {
$cacheName = "getStats" . DIRECTORY_SEPARATOR . "getStatsNotifications";
unset($_POST['sort']);
if ($force_recreate) {
@ -6905,6 +6921,14 @@ function getStatsNotifications($force_recreate = false) {
//_error_log('getStatsNotifications: 2 cached result');
$json = object_to_array($json);
}
foreach ($json['applications'] as $key => $value) {
if (!Live::isApplicationListed(@$value['key'], $listItIfIsAdminOrOwner)) {
$json['hidden_applications'][] = $value;
unset($json['applications'][$key]);
}
}
$json['countLiveStream'] = count($json['applications']);
return $json;
}

View file

@ -41,6 +41,7 @@ class User {
private $modified;
private $extra_info;
private $phone;
private $is_company;
public static $DOCUMENT_IMAGE_TYPE = "Document Image";
public static $channel_artTV = 'tv';
public static $channel_artDesktopMax = 'desktop_max';
@ -52,6 +53,10 @@ class User {
'tablet' => array('tablet', 1855, 423),
'DesktopMin' => array('desktop_min', 1546, 423)
);
public static $is_company_status_NOTCOMPANY = 0;
public static $is_company_status_ISACOMPANY = 1;
public static $is_company_status_WAITINGAPPROVAL = 2;
public static $is_company_status = array(0=>'Not a Company', 1=>'Active Company', 2=>'Company waiting for approval');
public function __construct($id, $user = "", $password = "") {
if (empty($id)) {
@ -68,6 +73,27 @@ class User {
}
}
function getIs_company(): int {
return intval($this->is_company);
}
function setIs_company($is_company): void {
if($is_company === 'true'){
$is_company = 1;
}
if (empty($is_company) || $is_company === "false") {
$is_company = self::$is_company_status_NOTCOMPANY;
} else {
if(Permissions::canAdminUsers()){
$is_company = intval($is_company);
}else{
// only admin can approve a company
$is_company = self::$is_company_status_WAITINGAPPROVAL;
}
}
$this->is_company = $is_company;
}
function getPhone() {
return $this->phone;
}
@ -346,13 +372,13 @@ if (typeof gtag !== \"function\") {
public static function getNameIdentification() {
global $advancedCustomUser;
if (self::isLogged()) {
if (!empty(self::getName()) && empty($advancedCustomUser->doNotIndentifyByName)) {
if (!empty(self::getName()) && empty($advancedCustomUser->doNotIdentifyByName)) {
return self::getName();
}
if (!empty(self::getMail()) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
if (!empty(self::getMail()) && empty($advancedCustomUser->doNotIdentifyByEmail)) {
return self::getMail();
}
if (!empty(self::getUserName()) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
if (!empty(self::getUserName()) && empty($advancedCustomUser->doNotIdentifyByUserName)) {
return self::getUserName();
}
if (!empty(self::getUserChannelName())) {
@ -368,13 +394,13 @@ if (typeof gtag !== \"function\") {
*/
public function getNameIdentificationBd() {
global $advancedCustomUser;
if (!empty($this->name) && empty($advancedCustomUser->doNotIndentifyByName)) {
if (!empty($this->name) && empty($advancedCustomUser->doNotIdentifyByName)) {
return $this->name;
}
if (!empty($this->email) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
if (!empty($this->email) && empty($advancedCustomUser->doNotIdentifyByEmail)) {
return $this->email;
}
if (!empty($this->user) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
if (!empty($this->user) && empty($advancedCustomUser->doNotIdentifyByUserName)) {
return $this->user;
}
if (!empty($this->channelName)) {
@ -619,6 +645,8 @@ if (typeof gtag !== \"function\") {
$this->emailVerified = "false";
}
$this->is_company = $this->getIs_company();
$user = ($this->user);
$password = ($this->password);
$name = ($this->name);
@ -665,15 +693,16 @@ if (typeof gtag !== \"function\") {
. "photoURL = ?, backgroundURL = ?, "
. "recoverPass = ?, about = ?, "
. " channelName = ?, emailVerified = ? , analyticsCode = ?, externalOptions = ? , "
. " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , phone = ? , "
. " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , phone = ? , is_company = ".(empty($this->is_company)?'NULL':intval($this->is_company)).", "
. " modified = now() WHERE id = ?";
} else {
$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, $this->phone];
$sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canCreateMeet, canViewChart, status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions, phone) "
$sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canCreateMeet, canViewChart, "
. " status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions, phone, is_company) "
. " VALUES (?,?,?,?,?,?,?,?, false, "
. "?,?,?, now(), now(),?,?,?,?)";
. "?,?,?, now(), now(),?,?,?,?,".(empty($this->is_company)?'NULL':intval($this->is_company)).")";
}
$insert_row = sqlDAL::writeSql($sql, $formats, $values);
if ($insert_row) {
@ -1076,6 +1105,16 @@ if (typeof gtag !== \"function\") {
return !empty($_SESSION['user']['isAdmin']);
}
public static function isACompany($users_id = 0) {
if (!empty($users_id)) {
$user = new User($users_id);
return !empty($user->getIs_company());
}
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['is_company']);
}
public static function canStream() {
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['isAdmin']) || !empty($_SESSION['user']['canStream']);
@ -1305,11 +1344,12 @@ if (typeof gtag !== \"function\") {
public static function getUserFromID($users_id) {
global $global;
$users_id = intval($users_id);
if (empty($users_id)) {
return false;
}
$sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", [$users_id]);
$res = sqlDAL::readSql($sql, "i", [$users_id]);
$user = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($user !== false) {
@ -1536,7 +1576,7 @@ if (typeof gtag !== \"function\") {
return $result;
}
public static function getAllUsers($ignoreAdmin = false, $searchFields = ['name', 'email', 'user', 'channelName', 'about'], $status = "", $isAdmin = null) {
public static function getAllUsers($ignoreAdmin = false, $searchFields = ['name', 'email', 'user', 'channelName', 'about'], $status = "", $isAdmin = null, $isCompany = null) {
if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
return false;
}
@ -1558,8 +1598,15 @@ if (typeof gtag !== \"function\") {
$sql .= " AND isAdmin = 1 ";
}
}
if (isset($isCompany)) {
if (!empty($isCompany) && $isCompany == self::$is_company_status_ISACOMPANY || $isCompany == self::$is_company_status_WAITINGAPPROVAL){
$sql .= " AND is_company = $isCompany ";
} else{
$sql .= " AND (is_company = 0 OR is_company IS NULL) ";
}
}
$sql .= BootGrid::getSqlFromPost($searchFields);
//var_dump($isCompany, $sql);exit;
$user = [];
require_once $global['systemRootPath'] . 'objects/userGroups.php';
$res = sqlDAL::readSql($sql . ";");
@ -1667,7 +1714,7 @@ if (typeof gtag !== \"function\") {
return $user;
}
public static function getTotalUsers($ignoreAdmin = false, $status = "", $isAdmin = null) {
public static function getTotalUsers($ignoreAdmin = false, $status = "", $isAdmin = null, $isCompany = null) {
if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
return false;
}
@ -1690,6 +1737,14 @@ if (typeof gtag !== \"function\") {
$sql .= " AND isAdmin = 1 ";
}
}
if (isset($isCompany)) {
if (!empty($isCompany) && $isCompany == self::$is_company_status_ISACOMPANY || $isCompany == self::$is_company_status_WAITINGAPPROVAL){
$sql .= " AND is_company = $isCompany ";
} else{
$sql .= " AND (is_company = 0 OR is_company IS NULL) ";
}
}
$sql .= BootGrid::getSqlSearchFromPost(['name', 'email', 'user']);
$res = sqlDAL::readSql($sql);
@ -1914,6 +1969,17 @@ if (typeof gtag !== \"function\") {
$tags[] = $obj;
}
if ($status = $user->getIs_company()) {
$obj = new stdClass();
if($status !== self::$is_company_status_ISACOMPANY){
$obj->type = "warning";
}else{
$obj->type = "success";
}
$obj->text = '<i class="fas fa-building"></i> '.__(self::$is_company_status[$status]);
$tags[] = $obj;
}
if ($user->getStatus() == "a") {
$obj = new stdClass();
$obj->type = "success";

View file

@ -1,4 +1,5 @@
<?php
header('Content-Type: application/json');
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../';
@ -6,8 +7,14 @@ if (empty($global['systemRootPath'])) {
$_REQUEST["do_not_login"] = 1;
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$obj->status = 0;
if (!Permissions::canAdminUsers()) {
die('{"error":"'.__("Permission denied").'"}');
forbiddenPage();
}
session_write_close();
if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
@ -27,6 +34,7 @@ $user->setEmail($_POST['email']);
$user->setName($_POST['name']);
$user->setIsAdmin($_POST['isAdmin']);
$user->setCanStream($_POST['canStream']);
$user->setIs_company($_POST['is_company']);
$user->setCanUpload($_POST['canUpload']);
$user->setCanViewChart($_POST['canViewChart']);
$user->setCanCreateMeet($_POST['canCreateMeet']);
@ -75,5 +83,13 @@ if($originalChannelName !== $finalChannelName){
}
_error_log("userAddNew.json.php: saving");
$users_id = $user->save(true);
echo '{"status":"'.$users_id.'"}';
if (!empty($users_id) && !empty($_POST['usersExtraInfo'])) {
$obj->error = false;
$obj->status = $users_id;
if (!empty($_POST['usersExtraInfo'])) {
User::saveExtraInfo(json_encode($_POST['usersExtraInfo']), $users_id);
}
}
_error_log("userAddNew.json.php: saved users_id ($users_id)");
die(_json_encode($obj));

View file

@ -20,6 +20,8 @@ if (!empty($input)) {
}
}
$obj = new stdClass();
$obj->error = true;
$obj->msg = '';
if (empty($ignoreCaptcha)) {
if (empty($_POST['captcha'])) {
$obj->error = __("The captcha is empty");
@ -56,6 +58,10 @@ if (!empty($advancedCustomUser->emailMustBeUnique)) {
}
}
if(empty($_POST['pass']) && !empty($_POST['inputPassword'])){
$_POST['pass'] = $_POST['inputPassword'];
}
if (empty($_POST['user']) || empty($_POST['pass']) || empty($_POST['email']) || empty($_POST['name'])) {
$obj->error = __("You must fill all fields");
die(json_encode($obj));
@ -72,6 +78,7 @@ $user->setPassword($_POST['pass']);
$user->setEmail($_POST['email']);
$user->setName($_POST['name']);
$user->setPhone(@$_POST['phone']);
$user->setIs_company($_POST['is_company']);
$user->setCanUpload($config->getAuthCanUploadVideos());
@ -86,6 +93,15 @@ if (!empty($users_id)) {
UserGroups::updateUserGroups($users_id, [$advancedCustomUser->userDefaultUserGroup->value], true);
}
AVideoPlugin::onUserSignup($users_id);
$obj->status = $users_id;
$obj->error = false;
$obj->msg = __("Your user account has been created!");
if(!empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)){
$obj->msg .= '<br>'.__("Sign in to your email to verify your account!");
}
if (!empty($_POST['usersExtraInfo'])) {
User::saveExtraInfo(json_encode($_POST['usersExtraInfo']), $users_id);
}
}
echo '{"status":"' . $users_id . '"}';
die(json_encode($obj));

View file

@ -1,4 +1,5 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
@ -13,36 +14,50 @@ if (empty($_POST['current'])) {
if (empty($_REQUEST['rowCount'])) {
$_REQUEST['rowCount'] = 10;
}
if (empty($_REQUEST['user_groups_id'])) {
if (!empty($_REQUEST['users_id'])) {
//echo __LINE__, PHP_EOL;
$users = User::getUserFromID($_REQUEST['users_id']);
if (!empty($users)) {
$users = array($users);
$total = 1;
} else {
$users = array();
$total = 0;
}
} else if (empty($_REQUEST['user_groups_id'])) {
//echo __LINE__, PHP_EOL;
$isAdmin = null;
$isCompany = null;
$ignoreAdmin = $advancedCustomUser->userCanChangeVideoOwner ? true : false;
if (isset($_REQUEST['isAdmin'])) {
$isAdmin = 1;
}
$users = User::getAllUsers($advancedCustomUser->userCanChangeVideoOwner ? true : false, ['name', 'email', 'user', 'channelName', 'about'], @$_GET['status'], $isAdmin);
$total = User::getTotalUsers($advancedCustomUser->userCanChangeVideoOwner ? true : false, @$_GET['status'], $isAdmin);
if (isset($_REQUEST['isCompany'])) {
$isCompany = intval($_REQUEST['isCompany']);
if (!User::isAdmin()) {
if (User::isACompany()) {
$isCompany = 0;
} else {
$isCompany = 1;
}
$ignoreAdmin = true;
}
}
$users = User::getAllUsers($ignoreAdmin, ['name', 'email', 'user', 'channelName', 'about'], @$_GET['status'], $isAdmin, $isCompany);
$total = User::getTotalUsers($ignoreAdmin, @$_GET['status'], $isAdmin, $isCompany);
} else {
//echo __LINE__, PHP_EOL;
$users = User::getAllUsersFromUsergroup($_REQUEST['user_groups_id'], $advancedCustomUser->userCanChangeVideoOwner ? true : false, ['name', 'email', 'user', 'channelName', 'about'], @$_GET['status']);
$total = User::getTotalUsersFromUsergroup($_REQUEST['user_groups_id'], $advancedCustomUser->userCanChangeVideoOwner ? true : false, @$_GET['status']);
}
//echo examineJSONError($users);exit;
$json = json_encode($users);
if (json_last_error()) {
_error_log("users.json error 1: " . print_r($users, true));
$users = object_to_array($users);
//echo examineJSONError($users);exit;
array_walk_recursive($users, function (&$item) {
if (is_string($item)) {
$item = cleanString($item);
}
});
$json = json_encode($users);
}
if (json_last_error()) {
_error_log("users.json error 2 ");
foreach ($users as $key => $value) {
$users[$key]['about'] = '';
}
$json = json_encode($users);
if (empty($users)) {
$json = '[]';
$total = 0;
} else {
$json = _json_encode($users);
}
//var_dump($users, $json);
echo '{ "current": ' . $_POST['current'] . ',"rowCount": ' . $_REQUEST['rowCount'] . ', "total": ' . $total . ', "rows":' . $json . '}';

View file

@ -7,6 +7,7 @@ if (empty($global['systemRootPath'])) {
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_affiliations.php';
class CustomizeUser extends PluginAbstract
{
@ -41,7 +42,7 @@ class CustomizeUser extends PluginAbstract
public function getEmptyDataObject()
{
global $advancedCustom;
global $advancedCustom, $advancedCustomUser;
$obj = new stdClass();
$obj->nonAdminCannotDownload = false;
$obj->userCanAllowFilesDownload = false;
@ -77,9 +78,12 @@ class CustomizeUser extends PluginAbstract
$obj->unverifiedEmailsCanNOTLogin = !isset($advancedCustom->unverifiedEmailsCanNOTLogin) ? false : $advancedCustom->unverifiedEmailsCanNOTLogin;
$obj->unverifiedEmailsCanNOTComment = false;
$obj->newUsersCanStream = !isset($advancedCustom->newUsersCanStream) ? false : $advancedCustom->newUsersCanStream;
$obj->doNotIndentifyByEmail = !isset($advancedCustom->doNotIndentifyByEmail) ? false : $advancedCustom->doNotIndentifyByEmail;
$obj->doNotIndentifyByName = !isset($advancedCustom->doNotIndentifyByName) ? false : $advancedCustom->doNotIndentifyByName;
$obj->doNotIndentifyByUserName = !isset($advancedCustom->doNotIndentifyByUserName) ? false : $advancedCustom->doNotIndentifyByUserName;
$obj->doNotIdentifyByName = !isset($advancedCustomUser->doNotIndentifyByName) ? false : $advancedCustomUser->doNotIndentifyByName;
self::addDataObjectHelper('doNotIdentifyByName', 'Do NOT identify user by Name', 'The identification order will be: <br>1. Name<br>2. email<br>3. Username<br>4. Channel Name');
$obj->doNotIdentifyByEmail = !isset($advancedCustomUser->doNotIndentifyByEmail) ? false : $advancedCustomUser->doNotIndentifyByEmail;
self::addDataObjectHelper('doNotIdentifyByEmail', 'Do NOT identify user by Email', 'The identification order will be: <br>1. Name<br>2. email<br>3. Username<br>4. Channel Name');
$obj->doNotIdentifyByUserName = !isset($advancedCustomUser->doNotIndentifyByUserName) ? false : $advancedCustomUser->doNotIndentifyByUserName;
self::addDataObjectHelper('doNotIdentifyByUserName', 'Do NOT identify user by Username', 'The identification order will be: <br>1. Name<br>2. email<br>3. Username<br>4. Channel Name');
$obj->hideRemoveChannelFromModeYoutube = !isset($advancedCustom->hideRemoveChannelFromModeYoutube) ? false : $advancedCustom->hideRemoveChannelFromModeYoutube;
$obj->showChannelBannerOnModeYoutube = !isset($advancedCustom->showChannelBannerOnModeYoutube) ? false : $advancedCustom->showChannelBannerOnModeYoutube;
$obj->showChannelHomeTab = true;
@ -90,6 +94,8 @@ class CustomizeUser extends PluginAbstract
$obj->requestCaptchaAfterLoginsAttempts = !isset($advancedCustom->requestCaptchaAfterLoginsAttempts) ? 0 : $advancedCustom->requestCaptchaAfterLoginsAttempts;
$obj->disableSignOutButton = false;
$obj->disableNativeSignUp = !isset($advancedCustom->disableNativeSignUp) ? false : $advancedCustom->disableNativeSignUp;
$obj->disableCompanySignUp = true;
self::addDataObjectHelper('disableCompanySignUp', 'Disable Company SignUp', 'Company SignUp will enable a form with sone extra fields specific for companies');
$obj->disableNativeSignIn = !isset($advancedCustom->disableNativeSignIn) ? false : $advancedCustom->disableNativeSignIn;
$obj->disablePersonalInfo = !isset($advancedCustom->disablePersonalInfo) ? true : $advancedCustom->disablePersonalInfo;
@ -160,6 +166,10 @@ class CustomizeUser extends PluginAbstract
$obj->doNotShowPhoneMyAccount = true;
$obj->doNotShowPhoneOnSignup = true;
$obj->enableAffiliation = false;
self::addDataObjectHelper('enableAffiliation', 'Enable user affiliation', 'Users that are marked as company can select other users to be afiliated to him');
return $obj;
}
@ -175,6 +185,7 @@ class CustomizeUser extends PluginAbstract
{
$obj = $this->getDataObject();
$userOptions = [];
if ($obj->Checkmark1Enabled) {
$userOptions["Checkmark 1"] = "checkmark1";
}
@ -502,6 +513,9 @@ class CustomizeUser extends PluginAbstract
if($obj->allowWalletDirectTransferDonation && $obj->UsersCanCustomizeWalletDirectTransferDonation){
$btn .= '<li><a data-toggle="tab" href="#tabWalletDonation' . $p->getUUID() . '">' . __('Donations Options') . '</a></li>';
}
if($obj->enableAffiliation){
$btn .= '<li><a data-toggle="tab" href="#tabAffiliation' . $p->getUUID() . '">' . __('Affiliations') . '</a></li>';
}
return $btn;
}
@ -521,8 +535,9 @@ class CustomizeUser extends PluginAbstract
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabDonation.php';
}
if($obj->allowWalletDirectTransferDonation && $obj->UsersCanCustomizeWalletDirectTransferDonation){
if($obj->enableAffiliation){
$tabId = 'tabAffiliation' . $p->getUUID();
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabAffiliation.php';
}
return $btn;

View file

@ -0,0 +1,147 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Users_affiliations extends ObjectYPT {
protected $id, $users_id_company, $users_id_affiliate, $status, $company_agree_date, $affiliate_agree_date;
static function getSearchFieldsNames() {
return array();
}
static function getTableName() {
return 'users_affiliations';
}
static function getAllUsers($companyOnly = false) {
if ($companyOnly) {
$isCompany = User::$is_company_status_ISACOMPANY;
} else {
$isCompany = User::$is_company_status_NOTCOMPANY;
}
$rows = User::getAllUsers(false, ['name', 'email', 'user', 'channelName', 'about'], 'a', null, $isCompany);
return $rows;
}
function setId($id) {
$this->id = intval($id);
}
function setUsers_id_company($users_id_company) {
$this->users_id_company = intval($users_id_company);
}
function setUsers_id_affiliate($users_id_affiliate) {
$this->users_id_affiliate = intval($users_id_affiliate);
}
function setStatus($status) {
$this->status = $status;
}
function setCompany_agree_date($company_agree_date) {
$this->company_agree_date = $company_agree_date;
}
function setAffiliate_agree_date($affiliate_agree_date) {
$this->affiliate_agree_date = $affiliate_agree_date;
}
function getId() {
return intval($this->id);
}
function getUsers_id_company() {
return intval($this->users_id_company);
}
function getUsers_id_affiliate() {
return intval($this->users_id_affiliate);
}
function getStatus() {
return $this->status;
}
function getCompany_agree_date() {
return $this->company_agree_date;
}
function getAffiliate_agree_date() {
return $this->affiliate_agree_date;
}
public static function getAll($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false) {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$users_id_company = intval($users_id_company);
$users_id_affiliate = intval($users_id_affiliate);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
if(!empty($users_id_company)){
$sql .= "AND users_id_company = $users_id_company ";
}
if(!empty($users_id_affiliate)){
$sql .= "AND users_id_affiliate = $users_id_affiliate ";
}
if(!empty($activeOnly)){
$sql .= "AND status = 'a' ";
}
$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = [];
if ($res !== false) {
foreach ($fullData as $row) {
$row['company'] = User::getNameIdentificationById($row['users_id_company']);
$row['affiliate'] = User::getNameIdentificationById($row['users_id_affiliate']);
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
public static function getTotal($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false)
{
//will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global;
if (!static::isTableInstalled()) {
return 0;
}
$sql = "SELECT id FROM " . static::getTableName() . " WHERE 1=1 ";
if(!empty($users_id_company)){
$sql .= "AND users_id_company = $users_id_company ";
}
if(!empty($users_id_affiliate)){
$sql .= "AND users_id_affiliate = $users_id_affiliate ";
}
if(!empty($activeOnly)){
$sql .= "AND status = 'a' ";
}
$sql .= self::getSqlSearchFromPost();
$res = sqlDAL::readSql($sql);
$countRow = sqlDAL::num_rows($res);
sqlDAL::close($res);
return $countRow;
}
public function save() {
if(!empty($this->company_agree_date) && !empty($this->affiliate_agree_date)){
$this->status = 'a';
}else{
$this->status = 'i';
}
return parent::save();
}
}

View file

@ -2,8 +2,8 @@
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Users_extra_info extends ObjectYPT
{
class Users_extra_info extends ObjectYPT {
protected $id;
protected $field_name;
protected $field_type;
@ -12,119 +12,126 @@ class Users_extra_info extends ObjectYPT
protected $parameters;
protected $status;
protected $order;
public static $status_INACTIVE = 'i';
public static $status_ACTIVE_ALL_USERS = 'a';
public static $status_ACTIVE_FORCED_ON_SIGNUP_ALL_USERS = 'b';
public static $status_ACTIVE_OPTIONAL_ON_SIGNUP_ALL_USERS = 'c';
public static $status_ACTIVE_COMPANIES_ONLY = 'd';
public static $status_ACTIVE_FORCED_ON_SIGNUP_COMPANIES_ONLY = 'e';
public static $status_ACTIVE_OPTIONAL_ON_SIGNUP_COMPANIES_ONLY = 'f';
public static $status_options = array(
'i' => 'Inactive',
'a' => 'Active all users',
'b' => 'Forced on Signup all users',
'c' => 'Optional on signup all users',
'd' => 'Active companies only',
'e' => 'Forced on Signup companies only',
'f' => 'Optional on signup companies only'
);
public static function getSearchFieldsNames()
{
public static function getSearchFieldsNames() {
return ['field_name', 'field_type', 'field_options', 'field_default_value', 'parameters'];
}
public static function getTableName()
{
public static function getTableName() {
return 'users_extra_info';
}
public function setId($id)
{
public function setId($id) {
$this->id = intval($id);
}
public function setField_name($field_name)
{
public function setField_name($field_name) {
$this->field_name = $field_name;
}
public function setField_type($field_type)
{
public function setField_type($field_type) {
$this->field_type = $field_type;
}
public function setField_options($field_options)
{
public function setField_options($field_options) {
$this->field_options = $field_options;
}
public function setField_default_value($field_default_value)
{
public function setField_default_value($field_default_value) {
$this->field_default_value = $field_default_value;
}
public function setParameters($parameters)
{
public function setParameters($parameters) {
$this->parameters = $parameters;
}
public function setStatus($status)
{
public function setStatus($status) {
$this->status = $status;
}
public function getId()
{
public function getId() {
return intval($this->id);
}
public function getField_name()
{
public function getField_name() {
return $this->field_name;
}
public function getField_type()
{
public function getField_type() {
return $this->field_type;
}
public function getField_options()
{
public function getField_options() {
return $this->field_options;
}
public function getField_default_value()
{
public function getField_default_value() {
return $this->field_default_value;
}
public function getParameters()
{
public function getParameters() {
return $this->parameters;
}
public function getStatus()
{
public function getStatus() {
return $this->status;
}
public function getOrder()
{
public function getOrder() {
return $this->order;
}
public function setOrder($order)
{
public function setOrder($order) {
$this->order = intval($order);
}
public static function getTypesOptionArray()
{
public static function getTypesOptionArray() {
return ['input' => 'Text', 'number' => 'Number', 'select' => 'Predefined options (select one)', 'textarea' => 'Textarea'];
}
public static function typeToHTML($row)
{
public static function typeToHTML($row, $class1 = '', $class2 = '') {
$required = '';
if(self::isRequiredField($row['status'])){
$required = 'required';
}
$html = "";
if (isset($row['value'])) {
$row['field_default_value'] = $row['value'];
}
if ($row['field_type'] == 'input') {
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
$html .= "<label for=\"usersExtraInfo_{$row['id']}\" class=\"$class1\">{$row['field_name']}:</label>";
$html .= "<div class=\"$class2\">";
$html .= "<input type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\" {$required}>";
$html .= "</div>";
} elseif ($row['field_type'] == 'number') {
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
$html .= "<label for=\"usersExtraInfo_{$row['id']}\" class=\"$class1\">{$row['field_name']}:</label>";
$html .= "<div class=\"$class2\">";
$html .= "<input type=\"number\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\" {$required}>";
$html .= "</div>";
} elseif ($row['field_type'] == 'select') {
$html = "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>
<select class=\"form-control input-sm usersExtraInfoInput\" name=\"usersExtraInfo[{$row['id']}]\" id=\"usersExtraInfo_{$row['id']}\">";
$html .= "<label for=\"usersExtraInfo_{$row['id']}\" class=\"$class1\">{$row['field_name']}:</label>";
$html .= "<div class=\"$class2\">";
$html .= "<select class=\"form-control input-sm usersExtraInfoInput\" name=\"usersExtraInfo[{$row['id']}]\" id=\"usersExtraInfo_{$row['id']}\" {$required}>";
foreach (preg_split("/((\r?\n)|(\r\n?))/", $row['field_options']) as $line) {
$line = trim($line);
if (empty($line)) {
@ -137,21 +144,74 @@ class Users_extra_info extends ObjectYPT
$html .= "<option {$selected}>" . htmlentities($line) . "</option>";
}
$html .= "</select>";
$html .= "</div>";
} elseif ($row['field_type'] == 'textarea') {
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
$html .= "<label for=\"usersExtraInfo_{$row['id']}\" class=\"$class1\">{$row['field_name']}:</label>";
$html .= "<div class=\"$class2\">";
$html .= "<textarea type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" rows=\"6\">{$row['field_default_value']}</textarea>";
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" rows=\"6\" {$required}>{$row['field_default_value']}</textarea>";
$html .= "</div>";
}
return $html;
}
public static function getAllActive($users_id=0)
{
public static function getActiveStatusList($includeCompany = false): array {
$list = array(
self::$status_ACTIVE_ALL_USERS,
self::$status_ACTIVE_FORCED_ON_SIGNUP_ALL_USERS,
self::$status_ACTIVE_OPTIONAL_ON_SIGNUP_ALL_USERS,
);
if ($includeCompany) {
$list[] = self::$status_ACTIVE_COMPANIES_ONLY;
$list[] = self::$status_ACTIVE_FORCED_ON_SIGNUP_COMPANIES_ONLY;
$list[] = self::$status_ACTIVE_OPTIONAL_ON_SIGNUP_COMPANIES_ONLY;
}
//var_dump($includeCompany, $list);
return $list;
}
public static function isRequiredField($status): bool {
$list = array(
self::$status_ACTIVE_FORCED_ON_SIGNUP_ALL_USERS,
self::$status_ACTIVE_FORCED_ON_SIGNUP_COMPANIES_ONLY
);
return in_array($status, $list);
}
public static function isAllUserField($status): bool {
if ($status == self::$status_INACTIVE) {
return false;
}
$list = self::getActiveStatusList();
return in_array($status, $list);
}
public static function isCompanyOnlyField($status): bool {
if ($status == self::$status_INACTIVE) {
return false;
}
return !self::isAllUserField($status);
}
public static function getAllActive($users_id = 0, $includeCompany = false) {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$sql = "SELECT * FROM " . static::getTableName() . " WHERE status='a' ORDER BY `order` ASC ";
if (!empty($users_id)) {
if (User::isACompany($users_id)) {
$includeCompany = true;
}
}
$statusList = self::getActiveStatusList($includeCompany);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE status IN ('" . implode("','", $statusList) . "') ORDER BY `order` ASC ";
//var_dump($includeCompany, $sql);
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
@ -175,9 +235,32 @@ class Users_extra_info extends ObjectYPT
return $rows;
}
public static function getFromUser($users_id)
{
public static function getFromUser($users_id) {
$u = new User($users_id);
return object_to_array(_json_decode($u->getExtra_info()));
}
static function getAll() {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
foreach ($fullData as $row) {
$row['status_description'] = self::$status_options[$row['status']];
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
}

View file

@ -0,0 +1,41 @@
<?php
header('Content-Type: application/json');
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_affiliations.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
if(!User::isLogged()){
forbiddenPage();
}
$o = new Users_affiliations(@$_POST['id']);
if(!User::isAdmin()){
if(User::isACompany()){
$_POST['users_id_company'] = User::getId();
$_POST['company_agree_date'] = date('Y-m-d H:i:s');
_error_log('Users_affiliations: save is a company');
}else{
$_POST['users_id_affiliate'] = User::getId();
$_POST['affiliate_agree_date'] = date('Y-m-d H:i:s');
_error_log('Users_affiliations: save is NOT a company');
}
}
_error_log('Users_affiliations: save '. _json_encode($_POST));
$o->setUsers_id_company($_POST['users_id_company']);
$o->setUsers_id_affiliate($_POST['users_id_affiliate']);
$o->setStatus(@$_POST['status']);
$o->setCompany_agree_date(@$_POST['company_agree_date']);
$o->setAffiliate_agree_date(@$_POST['affiliate_agree_date']);
if($id = $o->save()){
$obj->error = false;
}
echo json_encode($obj);

View file

@ -0,0 +1,20 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_affiliations.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$id = intval($_POST['id']);
$row = new Users_affiliations($id);
$obj->error = !$row->delete();
die(json_encode($obj));
?>

View file

@ -0,0 +1,29 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: CustomizeUser</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/{$classname}/index_head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/{$classname}/index_body.php';
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
</body>
</html>

View file

@ -0,0 +1,230 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
}
?>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fas fa-cog"></i> <?php echo __("Configurations"); ?>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-4">
<div class="panel panel-default ">
<div class="panel-heading"><i class="far fa-plus-square"></i> <?php echo __("Create"); ?></div>
<div class="panel-body">
<form id="panelUsers_affiliationsForm">
<div class="row">
<input type="hidden" name="id" id="Users_affiliationsid" value="" >
<div class="form-group col-sm-12">
<label for="Users_affiliationsusers_id_company"><?php echo __("Company"); ?>:</label>
<select class="form-control input-sm" name="users_id_company" id="Users_affiliationsusers_id_company">
<?php
$options = Users_affiliations::getAllUsers(true);
foreach ($options as $value) {
echo '<option value="' . $value['id'] . '">[' . $value['id'] . '] ' . $value['user'] . ' - ' . $value['email'] . '</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-12">
<label for="users_id_affiliate"><?php echo __("Affiliate"); ?>:</label>
<?php
$updateUserAutocomplete = Layout::getUserAutocomplete(0, 'users_id_affiliate');
?>
</div>
<div class="form-group col-sm-12">
<label for="status"><?php echo __("Status"); ?>:</label>
<select class="form-control input-sm" name="status" id="Users_affiliationsstatus">
<option value="a"><?php echo __("Active"); ?></option>
<option value="i"><?php echo __("Inactive"); ?></option>
</select>
</div>
<div class="form-group col-sm-12">
<label for="Users_affiliationscompany_agree_date"><?php echo __("Company Agree Date"); ?>:</label>
<input type="text" id="Users_affiliationscompany_agree_date" name="company_agree_date" class="form-control input-sm" placeholder="<?php echo __("Company Agree Date"); ?>" autocomplete="off">
</div>
<div class="form-group col-sm-12">
<label for="Users_affiliationsaffiliate_agree_date"><?php echo __("Affiliate Agree Date"); ?>:</label>
<input type="text" id="Users_affiliationsaffiliate_agree_date" name="affiliate_agree_date" class="form-control input-sm" placeholder="<?php echo __("Affiliate Agree Date"); ?>" autocomplete="off">
</div>
<div class="form-group col-sm-12">
<div class="btn-group pull-right">
<span class="btn btn-success" id="newUsers_affiliationsLink" onclick="clearUsers_affiliationsForm()"><i class="fas fa-plus"></i> <?php echo __("New"); ?></span>
<button class="btn btn-primary" type="submit"><i class="fas fa-save"></i> <?php echo __("Save"); ?></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="panel panel-default ">
<div class="panel-heading"><i class="fas fa-edit"></i> <?php echo __("Edit"); ?></div>
<div class="panel-body">
<table id="Users_affiliationsTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th><?php echo __("Status"); ?></th>
<th><?php echo __("Company Agree Date"); ?></th>
<th><?php echo __("Affiliate Agree Date"); ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th><?php echo __("Status"); ?></th>
<th><?php echo __("Company Agree Date"); ?></th>
<th><?php echo __("Affiliate Agree Date"); ?></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="Users_affiliationsbtnModelLinks" style="display: none;">
<div class="btn-group pull-right">
<button href="" class="edit_Users_affiliations btn btn-default btn-xs">
<i class="fa fa-edit"></i>
</button>
<button href="" class="delete_Users_affiliations btn btn-danger btn-xs">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
<script type="text/javascript">
function clearUsers_affiliationsForm() {
$('#Users_affiliationsid').val('');
$('#Users_affiliationsusers_id_company').val('');
$('#users_id_affiliate').val('');
$('#Users_affiliationsstatus').val('');
$('#Users_affiliationscompany_agree_date').val('');
$('#Users_affiliationsaffiliate_agree_date').val('');
<?php echo $updateUserAutocomplete; ?>
}
$(document).ready(function () {
$('#addUsers_affiliationsBtn').click(function () {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/addUsers_affiliationsVideo.php',
data: $('#panelUsers_affiliationsForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelUsers_affiliationsForm").trigger("reset");
}
clearUsers_affiliationsForm();
tableVideos.ajax.reload();
modal.hidePleaseWait();
}
});
});
var Users_affiliationstableVar = $('#Users_affiliationsTable').DataTable({
serverSide: true,
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/list.json.php",
"columns": [
{"data": "id"},
{"data": "status"},
{"data": "company_agree_date"},
{"data": "affiliate_agree_date"},
{
sortable: false,
data: null,
defaultContent: $('#Users_affiliationsbtnModelLinks').html()
}
],
select: true,
});
$('#newUsers_affiliations').on('click', function (e) {
e.preventDefault();
$('#panelUsers_affiliationsForm').trigger("reset");
$('#Users_affiliationsid').val('');
});
$('#panelUsers_affiliationsForm').on('submit', function (e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/add.json.php',
data: $('#panelUsers_affiliationsForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelUsers_affiliationsForm").trigger("reset");
}
Users_affiliationstableVar.ajax.reload();
$('#Users_affiliationsid').val('');
modal.hidePleaseWait();
}
});
});
$('#Users_affiliationsTable').on('click', 'button.delete_Users_affiliations', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_affiliationstableVar.row(tr).data();
swal({
title: "<?php echo __("Are you sure?"); ?>",
text: "<?php echo __("You will not be able to recover this action!"); ?>",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then(function (willDelete) {
if (willDelete) {
modal.showPleaseWait();
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/delete.json.php",
data: data
}).done(function (resposta) {
if (resposta.error) {
avideoAlertError(resposta.msg);
}
Users_affiliationstableVar.ajax.reload();
modal.hidePleaseWait();
});
} else {
}
});
});
$('#Users_affiliationsTable').on('click', 'button.edit_Users_affiliations', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_affiliationstableVar.row(tr).data();
$('#Users_affiliationsid').val(data.id);
$('#Users_affiliationsusers_id_company').val(data.users_id_company);
$('#users_id_affiliate').val(data.users_id_affiliate);
$('#Users_affiliationsstatus').val(data.status);
$('#Users_affiliationscompany_agree_date').val(data.company_agree_date);
$('#Users_affiliationsaffiliate_agree_date').val(data.affiliate_agree_date);
<?php echo $updateUserAutocomplete; ?>
});
});
</script>
<script> $(document).ready(function () {
$('#Users_affiliationscompany_agree_date').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose: true});
});</script>
<script> $(document).ready(function () {
$('#Users_affiliationsaffiliate_agree_date').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose: true});
});</script>

View file

@ -0,0 +1,5 @@
<?php
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
<link href="<?php echo $global['webSiteRootURL']; ?>view/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>

View file

@ -0,0 +1,22 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_affiliations.php';
header('Content-Type: application/json');
$users_id_company = 0;
$users_id_affiliate = 0;
if(!User::isAdmin()){
if(User::isACompany()){
$users_id_company = User::getId();
}else{
$users_id_affiliate = User::getId();
}
}
$rows = Users_affiliations::getAll($users_id_company, $users_id_affiliate);
$total = Users_affiliations::getTotal($users_id_company, $users_id_affiliate);
?>
{"data": <?php echo json_encode($rows); ?>, "draw": <?php echo intval(@$_REQUEST['draw']); ?>, "recordsTotal":<?php echo $total; ?>, "recordsFiltered":<?php echo $total; ?>}

View file

@ -8,7 +8,10 @@ if (!User::isAdmin()) {
}
?>
<div class="alert alert-info">
This will let you create new custom fields for your users.
You can create fields for the signup or for the profile only.
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fas fa-cog"></i> <?php echo __("Configurations"); ?>
@ -59,8 +62,11 @@ if (!User::isAdmin()) {
<div class="form-group col-sm-6">
<label for="status"><?php echo __("Status"); ?>:</label>
<select class="form-control input-sm" name="status" id="Users_extra_infostatus">
<option value="a"><?php echo __("Active"); ?></option>
<option value="i"><?php echo __("Inactive"); ?></option>
<?php
foreach (Users_extra_info::$status_options as $key => $value) {
echo '<option value="' . $key . '">' . __($value) . '</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-12" style="display: none;">
@ -171,7 +177,10 @@ if (!User::isAdmin()) {
{"data": "field_type"},
{"data": "field_options"},
{"data": "field_default_value"},
{"data": "status"},
{"data": "status",
"render": function (data, type, row, meta) {
return row.status_description;
}},
{"data": "order"},
{
sortable: false,

View file

@ -26,6 +26,7 @@ AVideoPlugin::loadPlugin("CustomizeUser");
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Categories_has_users_groups"><i class="fas fa-list"></i> <?php echo __("Categories"); ?> <i class="fas fa-times"></i> <i class="fas fa-users"></i> <?php echo __("Categories Has Users Groups"); ?></a></li>
<li class=""><a data-toggle="tab" href="#Users_extra_info"><i class="fas fa-address-book"></i> <?php echo __("Users Extra Info"); ?></a></li>
<li class=""><a data-toggle="tab" href="#Users_affiliations"><i class="fas fa-child"></i> <?php echo __("Users Affiliations"); ?></a></li>
</ul>
<div class="tab-content">
<div id="Categories_has_users_groups" class="tab-pane fade in active" style="padding: 10px;">
@ -38,6 +39,11 @@ AVideoPlugin::loadPlugin("CustomizeUser");
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/Users_extra_info/index_body.php';
?>
</div>
<div id="Users_affiliations" class="tab-pane fade" style="padding: 10px;">
<?php
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/Users_affiliations/index_body.php';
?>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,13 @@
<?php
$isACompany = User::isACompany();
?>
<div id="<?php echo $tabId; ?>" class="tab-pane fade in" style="padding: 10px 0;">
<?php
if($isACompany){
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabAffiliationCompany.php';
}else{
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabAffiliationAffiliate.php';
}
?>
</div>

View file

@ -0,0 +1,18 @@
<div class="row">
<div class="col-md-12">
Affiliate
<center>
<button type="button" class="btn btn-primary btn-block btn-lg" id="saveDonationBTN">
<span class="fa fa-save"></span> <?php echo __("Save Affiliations"); ?>
</button>
</center>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
});
</script>

View file

@ -0,0 +1,199 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isACompany()) {
forbiddenPage("You must be a company to see this");
}
?>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fas fa-cog"></i> <?php echo __("Configurations"); ?>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-4">
<div class="panel panel-default ">
<div class="panel-heading"><i class="far fa-plus-square"></i> <?php echo __("Add a new affiliate"); ?></div>
<div class="panel-body">
<form id="panelUsers_affiliationsForm">
<div class="row">
<input type="hidden" name="id" id="Users_affiliationsid" value="" >
<div class="form-group col-sm-12">
<?php
$updateUserAutocomplete = Layout::getUserAutocomplete(0, 'users_id_affiliate', array('isCompany'=>0));
?>
</div>
<div class="form-group col-sm-12">
<div class="btn-group pull-right">
<span class="btn btn-success" id="newUsers_affiliationsLink" onclick="clearUsers_affiliationsForm()"><i class="fas fa-plus"></i> <?php echo __("New"); ?></span>
<button class="btn btn-primary" type="submit"><i class="fas fa-save"></i> <?php echo __("Save"); ?></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="panel panel-default ">
<div class="panel-heading"><i class="fas fa-edit"></i> <?php echo __("Edit"); ?></div>
<div class="panel-body">
<table id="Users_affiliationsTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th><?php echo __("Affiliate"); ?></th>
<th><?php echo __("Status"); ?></th>
<th><?php echo __("Company Agree Date"); ?></th>
<th><?php echo __("Affiliate Agree Date"); ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th><?php echo __("Affiliate"); ?></th>
<th><?php echo __("Status"); ?></th>
<th><?php echo __("Company Agree Date"); ?></th>
<th><?php echo __("Affiliate Agree Date"); ?></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="Users_affiliationsbtnModelLinks" style="display: none;">
<div class="btn-group pull-right">
<button href="" class="edit_Users_affiliations btn btn-default btn-xs">
<i class="fa fa-edit"></i>
</button>
<button href="" class="delete_Users_affiliations btn btn-danger btn-xs">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
<script type="text/javascript">
function clearUsers_affiliationsForm() {
$('#Users_affiliationsid').val('');
$('#Users_affiliationsusers_id_company').val('');
$('#users_id_affiliate').val('');
$('#Users_affiliationsstatus').val('');
$('#Users_affiliationscompany_agree_date').val('');
$('#Users_affiliationsaffiliate_agree_date').val('');
<?php echo $updateUserAutocomplete; ?>
}
$(document).ready(function () {
$('#addUsers_affiliationsBtn').click(function () {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/addUsers_affiliationsVideo.php',
data: $('#panelUsers_affiliationsForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelUsers_affiliationsForm").trigger("reset");
}
clearUsers_affiliationsForm();
tableVideos.ajax.reload();
modal.hidePleaseWait();
}
});
});
var Users_affiliationstableVar = $('#Users_affiliationsTable').DataTable({
serverSide: true,
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/list.json.php",
"columns": [
{"data": "id"},
{"data": "affiliate"},
{"data": "status"},
{"data": "company_agree_date"},
{"data": "affiliate_agree_date"},
{
sortable: false,
data: null,
defaultContent: $('#Users_affiliationsbtnModelLinks').html()
}
],
select: true,
});
$('#newUsers_affiliations').on('click', function (e) {
e.preventDefault();
$('#panelUsers_affiliationsForm').trigger("reset");
$('#Users_affiliationsid').val('');
});
$('#panelUsers_affiliationsForm').on('submit', function (e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/add.json.php',
data: $('#panelUsers_affiliationsForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelUsers_affiliationsForm").trigger("reset");
}
Users_affiliationstableVar.ajax.reload();
$('#Users_affiliationsid').val('');
modal.hidePleaseWait();
}
});
});
$('#Users_affiliationsTable').on('click', 'button.delete_Users_affiliations', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_affiliationstableVar.row(tr).data();
swal({
title: "<?php echo __("Are you sure?"); ?>",
text: "<?php echo __("You will not be able to recover this action!"); ?>",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then(function (willDelete) {
if (willDelete) {
modal.showPleaseWait();
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/View/Users_affiliations/delete.json.php",
data: data
}).done(function (resposta) {
if (resposta.error) {
avideoAlertError(resposta.msg);
}
Users_affiliationstableVar.ajax.reload();
modal.hidePleaseWait();
});
} else {
}
});
});
$('#Users_affiliationsTable').on('click', 'button.edit_Users_affiliations', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_affiliationstableVar.row(tr).data();
$('#Users_affiliationsid').val(data.id);
$('#Users_affiliationsusers_id_company').val(data.users_id_company);
$('#users_id_affiliate').val(data.users_id_affiliate);
$('#Users_affiliationsstatus').val(data.status);
$('#Users_affiliationscompany_agree_date').val(data.company_agree_date);
$('#Users_affiliationsaffiliate_agree_date').val(data.affiliate_agree_date);
<?php echo $updateUserAutocomplete; ?>
});
});
</script>

View file

@ -159,6 +159,7 @@ foreach ($donation as $value) {
$(".donationFlyIcon").emojioneArea({
standalone: true,
autocomplete: false,
useInternalCDN: false,
pickerPosition: "right"
});

View file

@ -0,0 +1,53 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
$isFirstPage = 1;
include $global['systemRootPath'] . 'plugin/Gallery/view/topLogic.php';
$leaderBoardTop = getAdsLeaderBoardTop();
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php
echo $siteTitle;
?></title>
<?php include $global['systemRootPath'] . 'view/include/head.php'; ?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
<div class="container-fluid gallery">
<?php
if (!empty($leaderBoardTop)) {
echo '<div class="row text-center" style="padding: 10px;">' . $leaderBoardTop . '</div>';
} else {
echo '<!-- getAdsLeaderBoardTop is empty -->';
}
?>
<div class="col-lg-10 col-lg-offset-1">
<div class="panel panel-default">
<div class="panel-body">
<div class="row mainArea">
<!-- For Live Videos -->
<div id="liveVideos" class="clear clearfix" style="display: none;">
<h3 class="galleryTitle text-danger"> <i class="fas fa-play-circle"></i> <?php echo __("Live"); ?></h3>
<div class="extraVideos"></div>
</div>
<!-- For Live Schedule Videos -->
<div id="liveScheduleVideos" class="clear clearfix" style="display: none;">
<h3 class="galleryTitle"> <i class="far fa-calendar-alt"></i> <?php echo __($objLive->live_schedule_label); ?></h3>
<div class="extraVideos"></div>
</div>
<!-- For Live Videos End -->
</div>
</div>
</div>
</div>
</div>
<?php
include $global['systemRootPath'] . 'plugin/Gallery/view/footer.php';
?>
</body>
</html>
<?php include_once $global['systemRootPath'] . 'objects/include_end.php'; ?>

View file

@ -473,4 +473,14 @@ class Layout extends PluginAbstract {
}
}
static function getUserAutocomplete($default_users_id=0, $id = '', $parameters = array()){
global $global;
$default_users_id = intval($default_users_id);
if(empty($id)){
$id = 'getUserAutocomplete_'.uniqid();
}
include $global['systemRootPath'] . 'plugin/Layout/userAutocomplete.php';
return "updateUserAutocomplete{$id}();";
}
}

View file

@ -0,0 +1,100 @@
<?php
if (!empty($default_users_id)) {
$u = new User($default_users_id);
if (!empty($u->getUser())) {
$name = $u->getUser();
$user_image = $u->getPhotoDB();
}
}
if (empty($name)) {
$name = '';
$user_image = getURL('view/img/userSilhouette.jpg');
$default_users_id = 0;
}
?>
<div class="col-md-2">
<img id="user-img<?php echo $id; ?>" src="<?php echo $user_image; ?>" class="img img-responsive img-circle" style="max-height: 60px;" alt="User Photo">
</div>
<div class="col-md-10">
<input id="user<?php echo $id; ?>" placeholder="<?php echo __("User"); ?>" class="form-control" name="user<?php echo $id; ?>" value="<?php echo $name; ?>">
<input type="hidden" id="<?php echo $id; ?>" value="<?php echo $default_users_id; ?>" name="<?php echo $id; ?>">
</div>
<script>
function updateUserAutocomplete<?php echo $id; ?>() {
var data = <?php echo _json_encode((object) $parameters); ?>;
data.users_id = $('#<?php echo $id; ?>').val();
console.log('updateUserAutocomplete<?php echo $id; ?>', users_id);
resetUserAutocomplete<?php echo $id; ?>();
if (users_id && users_id !== '0') {
modal.showPleaseWait();
$.ajax({
url: webSiteRootURL + 'objects/users.json.php',
type: "POST",
data: data,
success: function (data) {
if (data.rows && data.rows[0]) {
$("#user<?php echo $id; ?>").val(data.rows[0].user);
$("#<?php echo $id; ?>").val(users_id);
var photoURL = data.rows[0].photo
$("#user-img<?php echo $id; ?>").attr("src", photoURL);
}
modal.hidePleaseWait();
}
});
}
}
function resetUserAutocomplete<?php echo $id; ?>() {
$("#user<?php echo $id; ?>").val('');
$("#<?php echo $id; ?>").val(0);
var photoURL = webSiteRootURL + 'img/userSilhouette.jpg'
$("#user-img<?php echo $id; ?>").attr("src", photoURL);
}
$(document).ready(function () {
$("#<?php echo $id; ?>").change(function () {
updateUserAutocomplete<?php echo $id; ?>();
});
$("#<?php echo $id; ?>").bind("change", function () {
updateUserAutocomplete<?php echo $id; ?>();
});
$("#user<?php echo $id; ?>").autocomplete({
minLength: 0,
source: function (req, res) {
var data = <?php echo _json_encode((object) $parameters); ?>;
data.searchPhrase = req.term;
$.ajax({
url: webSiteRootURL + 'objects/users.json.php',
type: "POST",
data: data,
success: function (data) {
res(data.rows);
}
});
},
focus: function (event, ui) {
$("#user<?php echo $id; ?>").val(ui.item.user);
return false;
},
select: function (event, ui) {
$("#user<?php echo $id; ?>").val(ui.item.user);
$("#<?php echo $id; ?>").val(ui.item.id);
var photoURL = webSiteRootURL + 'img/userSilhouette.jpg'
if (ui.item.photoURL) {
photoURL = webSiteRootURL + ui.item.photoURL + '?rand=' + Math.random();
}
$("#user-img<?php echo $id; ?>").attr("src", photoURL);
return false;
}
}).autocomplete("instance")._renderItem = function (ul, item) {
return $("<li>").append("<div>" + item.creator + item.email + "</div>").appendTo(ul);
};
});
</script>

View file

@ -237,7 +237,10 @@ class Live extends PluginAbstract {
}
$link = addQueryStringParameter($link, 'live_schedule', intval($value['id']));
$LiveUsersLabelLive = ($liveUsersEnabled ? getLiveUsersLabelLive($value['key'], $value['live_servers_id']) : '');
$app = self::getLiveApplicationModelArray($value['users_id'], $value['title'], $link, Live_schedule::getPosterURL($value['id']), '', 'scheduleLive', $LiveUsersLabelLive, 'LiveSchedule_' . $value['id'], $callback, date('Y-m-d H:i:s', $timestamp), 'live_' . $value['key']);
$title = self::getTitleFromKey($value['key'], $value['title']);
$app = self::getLiveApplicationModelArray($value['users_id'], $title, $link, Live_schedule::getPosterURL($value['id']), '', 'scheduleLive', $LiveUsersLabelLive, 'LiveSchedule_' . $value['id'], $callback, date('Y-m-d H:i:s', $timestamp), 'live_' . $value['key']);
$app['live_servers_id'] = $value['live_servers_id'];
$app['key'] = $value['key'];
$app['isPrivate'] = false;
@ -268,13 +271,17 @@ class Live extends PluginAbstract {
}
$currentLives[] = $link;
$LiveUsersLabelLive = ($liveUsersEnabled ? getLiveUsersLabelLive($value['key'], $value['live_servers_id']) : '');
$app = self::getLiveApplicationModelArray($value['users_id'], $value['title'], $link, self::getPoster($value['users_id'], $value['live_servers_id']), '', 'LiveDB', $LiveUsersLabelLive, 'LiveObject_' . $value['id'], '', '', "live_{$value['key']}");
$title = self::getTitleFromKey($value['key'], $value['title']);
$app = self::getLiveApplicationModelArray($value['users_id'], $title, $link, self::getPoster($value['users_id'], $value['live_servers_id']), '', 'LiveDB', $LiveUsersLabelLive, 'LiveObject_' . $value['id'], '', '', "live_{$value['key']}");
$app['live_servers_id'] = $value['live_servers_id'];
$app['key'] = $value['key'];
$app['live_transmitions_history_id'] = $value['id'];
$app['isPrivate'] = LiveTransmitionHistory::isPrivate($value['id']);
$app['isPasswordProtected'] = LiveTransmitionHistory::isPasswordProtected($value['id']);
$app['method'] = 'Live::getLiveApplicationArray::LiveTransmitionHistory';
$array[] = $app;
}
@ -1573,15 +1580,28 @@ class Live extends PluginAbstract {
}
public static function isPasswordProtected($key) {
global $_isPasswordProtected;
if (empty($key)) {
return false;
}
if (!isset($_isPasswordProtected)) {
$_isPasswordProtected = array();
}
if (!isset($_isPasswordProtected[$key])) {
$lt = self::getLiveTransmitionObjectFromKey($key);
if (empty($lt)) {
return false;
}
$_isPasswordProtected[$key] = false;
} else {
$password = $lt->getPassword();
if (!empty($password)) {
return true;
$_isPasswordProtected[$key] = true;
} else {
$_isPasswordProtected[$key] = false;
}
return false;
}
}
//var_dump($key, $_isPasswordProtected[$key]);
return $_isPasswordProtected[$key];
}
public static function canManageLiveFromLiveKey($key, $users_id) {
@ -1609,8 +1629,14 @@ class Live extends PluginAbstract {
}
public static function getTitleFromUsers_Id($users_id) {
if (empty($users_id)) {
return '';
}
$lt = self::getLiveTransmitionObjectFromUsers_id($users_id);
return $lt->getTitle();
if (empty($lt)) {
return '';
}
return self::getTitleFromKey($lt->getKey(), $lt->getTitle());
}
public static function getLiveTransmitionObjectFromUsers_id($users_id) {
@ -1750,14 +1776,11 @@ class Live extends PluginAbstract {
if (!empty($row) && $value->name === $obj->name) {
$obj->msg = "ONLINE";
}
$title = $row['title'];
$title = self::getTitleFromKey($row['key'], $row['title']);
self::getTitleFromUsers_Id($users_id);
$u = new User($row['users_id']);
$hiddenName = preg_replace('/^(.{5})/', '*****', $value->name);
if (self::isPasswordProtected($value->name)) {
$title = "<i class=\"fas fa-lock\"></i> {$title}";
}
//_error_log('Live::isLiveFromKey:_getStats '. json_encode($_SERVER));
if (!self::canSeeLiveFromLiveKey($value->name)) {
$obj->hidden_applications[] = [
@ -1766,15 +1789,6 @@ class Live extends PluginAbstract {
"user" => $row['channelName'],
"title" => "{$row['channelName']} ($hiddenName} is a private live",
];
if (empty($row['live_password']) && !User::isAdmin()) {
continue;
} else {
$title .= " (private live)";
}
} elseif (self::isPrivate($row['key'])) {
$title .= __(" (set to not be listed)");
} elseif (self::isPasswordProtected($row['key'])) {
$title .= __(" (Password Protected)");
} elseif ($u->getStatus() !== 'a') {
$obj->hidden_applications[] = [
"key" => $value->name,
@ -1784,8 +1798,6 @@ class Live extends PluginAbstract {
];
if (!User::isAdmin()) {
continue;
} else {
$title .= __(" (user is inactive)");
}
}
@ -1818,10 +1830,6 @@ class Live extends PluginAbstract {
$_REQUEST['live_index'] = $live_index;
}
if (!empty($live_index) || $live_index === 'false') {
$title .= " ({$live_index})";
}
$LiveUsersLabelLive = ($liveUsersEnabled ? getLiveUsersLabelLive($value->name, $live_servers_id) : '');
$uid = "live_{$live_servers_id}_{$value->name}";
$live_schedule_id = 0;
@ -1868,12 +1876,51 @@ class Live extends PluginAbstract {
return $obj;
}
public static function isApplicationListed($key) {
static function getTitleFromKey($key, $title = '') {
if (empty($key)) {
return $title;
}
$row = LiveTransmition::keyExists($key);
if (empty($row)) {
return $title;
}
if (empty($title)) {
$title = $row['title'];
}
$Char = "&zwnj;";
if(str_contains($title, $Char)){
return $title;
}
$title = "{$Char}{$title}";
//var_dump($title);
if (self::isPrivate($row['key'])) {
$title = " <i class=\"fas fa-eye-slash\"></i> {$title}";
}
if (self::isPasswordProtected($row['key'])) {
$title = " <i class=\"fas fa-lock\"></i> {$title}";
}
$u = new User($row['users_id']);
if ($u->getStatus() !== 'a') {
$title = " <i class=\"fas fa-user-alt-slash\"></i> {$title}";
}
$parameters = self::getLiveParametersFromKey($key);
$playlists_id_live = $parameters['playlists_id_live'];
$live_index = $parameters['live_index'];
if (!empty($live_index) && $live_index !== 'false') {
$title .= " ({$live_index})";
}
return $title;
}
public static function isApplicationListed($key, $listItIfIsAdminOrOwner = true) {
global $_isApplicationListed;
if (empty($key)) {
return __LINE__;
}
if (User::isAdmin()) {
if ($listItIfIsAdminOrOwner && User::isAdmin()) {
return __LINE__;
}
if (!isset($_isApplicationListed)) {
@ -1887,7 +1934,7 @@ class Live extends PluginAbstract {
$_isApplicationListed[$key] = __LINE__;
} else if (!empty($row['public'])) {
$_isApplicationListed[$key] = __LINE__;
} else if (User::getId() == $row['users_id']) {
} else if ($listItIfIsAdminOrOwner && User::getId() == $row['users_id']) {
$_isApplicationListed[$key] = __LINE__;
} else {
$_isApplicationListed[$key] = false;

View file

@ -306,7 +306,7 @@ class LiveTransmition extends ObjectYPT
Category::clearCacheCount();
Live::deleteStatsCache(true);
$socketObj = sendSocketMessageToAll(['stats'=>getStatsNotifications()], "socketLiveONCallback");
$socketObj = sendSocketMessageToAll(['stats'=>getStatsNotifications(false, false)], "socketLiveONCallback");
return $id;
}

View file

@ -19,6 +19,7 @@ class LiveTransmitionHistory extends ObjectYPT {
protected $json;
protected $max_viewers_sametime;
protected $total_viewers;
protected $users_id_companny;
public static function getSearchFieldsNames() {
return ['title', 'description'];
@ -28,6 +29,14 @@ class LiveTransmitionHistory extends ObjectYPT {
return 'live_transmitions_history';
}
function getUsers_id_companny(): int {
return intval($this->users_id_companny);
}
function setUsers_id_companny($users_id_companny): void {
$this->users_id_companny = intval($users_id_companny);
}
public function getId() {
return $this->id;
}
@ -172,14 +181,39 @@ class LiveTransmitionHistory extends ObjectYPT {
$liveUsersEnabled = AVideoPlugin::isEnabledByName("LiveUsers");
$LiveUsersLabelLive = ($liveUsersEnabled ? getLiveUsersLabelLive($key, $live_servers_id) : '');
$uid = "{$type}_{$liveTransmitionHistory_id}";
$title = Live::getTitleFromKey($key, $title);
//getLiveApplicationModelArray($users_id, $title, $link, $imgJPG, $imgGIF, $type, $LiveUsersLabelLive='', $uid ='', $callback='', $startsOnDate='', $class='')
$obj = Live::getLiveApplicationModelArray($users_id, $title, $link, $imgJPG, $imgGIF, $type, $LiveUsersLabelLive, $uid, '', '', "live_{$key}");
$obj['key'] = $key;
$obj['live_transmitions_history_id'] = $liveTransmitionHistory_id;
$obj['isPrivate'] = self::isPrivate($liveTransmitionHistory_id);
$obj['isPasswordProtected'] = self::isPasswordProtected($liveTransmitionHistory_id);
$obj['method'] = 'LiveTransmitionHistory::getApplicationObject';
return $obj;
}
public static function isPrivate($liveTransmitionHistory_id) {
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
$key = $lth->getKey();
if(!empty($key)){
$lt = LiveTransmition::getFromKey($key);
if(empty($lt['public'])){
return true;
}
}
return false;
}
public static function isPasswordProtected($liveTransmitionHistory_id) {
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
$key = $lth->getKey();
if(!empty($key)){
return Live::isPasswordProtected($key);
}
return false;
}
public static function getStatsAndAddApplication($liveTransmitionHistory_id) {
$stats = getStatsNotifications();
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
@ -588,6 +622,9 @@ class LiveTransmitionHistory extends ObjectYPT {
if (empty($this->finished)) {
$this->finished = 'NULL';
}
if (empty($this->users_id_companny)) {
$this->users_id_companny = 'NULL';
}
$this->max_viewers_sametime = intval($this->max_viewers_sametime);
$this->total_viewers = intval($this->total_viewers);

View file

@ -18,6 +18,7 @@ class Live_schedule extends ObjectYPT
protected $saveTransmition;
protected $showOnTV;
protected $scheduled_password;
protected $users_id_companny;
public static function getSearchFieldsNames()
{
@ -29,6 +30,14 @@ class Live_schedule extends ObjectYPT
return 'live_schedule';
}
function getUsers_id_companny(): int {
return intval($this->users_id_companny);
}
function setUsers_id_companny($users_id_companny): void {
$this->users_id_companny = intval($users_id_companny);
}
public static function getAllUsers()
{
global $global;
@ -325,6 +334,10 @@ class Live_schedule extends ObjectYPT
$this->showOnTV = 'NULL';
}
if (empty($this->users_id_companny)) {
$this->users_id_companny = 'NULL';
}
if (empty($this->key)) {
$this->key = uniqid();
}

View file

@ -80,13 +80,25 @@ CREATE TABLE IF NOT EXISTS `live_transmitions_history` (
`json` TEXT NULL DEFAULT NULL,
`max_viewers_sametime` INT(10) UNSIGNED NULL DEFAULT NULL,
`total_viewers` INT(10) UNSIGNED NULL DEFAULT NULL,
`users_id_companny` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_live_transmitions_history_users1_idx` (`users_id_companny` ASC),
INDEX `fk_live_transmitions_history_users_idx` (`users_id` ASC),
INDEX `fk_live_transmitions_history_live_servers1_idx` (`live_servers_id` ASC),
CONSTRAINT `fk_live_transmitions_history_users`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_live_transmitions_history_live_servers1`
FOREIGN KEY (`live_servers_id`)
REFERENCES `live_servers` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_live_transmitions_history_users1`
FOREIGN KEY (`users_id_companny`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
@ -166,7 +178,9 @@ CREATE TABLE IF NOT EXISTS `live_schedule` (
`saveTransmition` TINYINT(1) NULL,
`showOnTV` TINYINT(4) NULL,
`scheduled_password` VARCHAR(255) NULL,
`users_id_company` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_live_schedule_users2_idx` (`users_id_company` ASC),
INDEX `fk_live_schedule_users1_idx` (`users_id` ASC),
INDEX `fk_live_schedule_live_servers1_idx` (`live_servers_id` ASC),
CONSTRAINT `fk_live_schedule_users1`
@ -177,8 +191,13 @@ CREATE TABLE IF NOT EXISTS `live_schedule` (
CONSTRAINT `fk_live_schedule_live_servers1`
FOREIGN KEY (`live_servers_id`)
REFERENCES `live_servers` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_live_schedule_users2`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;

View file

@ -0,0 +1,53 @@
-- MySQL Workbench Synchronization
-- Generated: 2022-03-01 11:10
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: msn
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 `live_transmitions_history`
DROP FOREIGN KEY `fk_live_transmitions_history_live_servers1`;
ALTER TABLE `live_schedule`
DROP FOREIGN KEY `fk_live_schedule_live_servers1`;
ALTER TABLE `live_transmitions_history`
ADD COLUMN `users_id_companny` INT(11) NULL DEFAULT NULL AFTER `total_viewers`,
ADD INDEX `fk_live_transmitions_history_users1_idx` (`users_id_companny` ASC);
ALTER TABLE `live_schedule`
ADD COLUMN `users_id_company` INT(11) NULL DEFAULT NULL AFTER `scheduled_password`,
ADD INDEX `fk_live_schedule_users2_idx` (`users_id_company` ASC);
ALTER TABLE `live_transmitions_history`
ADD CONSTRAINT `fk_live_transmitions_history_live_servers1`
FOREIGN KEY (`live_servers_id`)
REFERENCES `live_servers` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `fk_live_transmitions_history_users1`
FOREIGN KEY (`users_id_companny`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
ALTER TABLE `live_schedule`
ADD CONSTRAINT `fk_live_schedule_live_servers1`
FOREIGN KEY (`live_servers_id`)
REFERENCES `live_servers` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `fk_live_schedule_users2`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

View file

@ -45,8 +45,12 @@ if (AVideoPlugin::isEnabledByName('YPTSocket')) {
}
}
$array['live_transmitions_history_id'] = $liveTransmitionHistory_id;
$array['isPrivate'] = LiveTransmitionHistory::isPrivate($liveTransmitionHistory_id);
$array['isPasswordProtected'] = LiveTransmitionHistory::isPasswordProtected($liveTransmitionHistory_id);
$array['users_id'] = $users_id;
$array['title'] = Live::getTitleFromKey($array['key'], $array['title']);
if ($isLive) {
_error_log("NGINX Live::on_publish_socket_notification is200");
$array['stats'] = LiveTransmitionHistory::getStatsAndAddApplication($liveTransmitionHistory_id);

View file

@ -0,0 +1,55 @@
-- MySQL Workbench Synchronization
-- Generated: 2022-03-01 11:10
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: msn
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 `is_company` TINYINT(4) NULL DEFAULT NULL AFTER `phone`;
ALTER TABLE `videos`
ADD COLUMN `users_id_company` INT(11) NULL DEFAULT NULL AFTER `dislikes`,
ADD INDEX `fk_videos_users1_idx` (`users_id_company` ASC);
CREATE TABLE IF NOT EXISTS `users_affiliations` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`created` DATETIME NULL DEFAULT NULL,
`modified` DATETIME NULL DEFAULT NULL,
`users_id_company` INT(11) NOT NULL,
`users_id_affiliate` INT(11) NOT NULL,
`status` CHAR(1) NULL DEFAULT NULL,
`company_agree_date` DATETIME NULL DEFAULT NULL,
`affiliate_agree_date` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_users_affiliations_users1_idx` (`users_id_company` ASC),
INDEX `fk_users_affiliations_users2_idx` (`users_id_affiliate` ASC),
CONSTRAINT `fk_users_affiliations_users1`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_users_affiliations_users2`
FOREIGN KEY (`users_id_affiliate`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
ALTER TABLE `videos`
ADD CONSTRAINT `fk_videos_users1`
FOREIGN KEY (`users_id_company`)
REFERENCES `users` (`id`)
ON DELETE SET NULL
ON UPDATE SET NULL;
UPDATE configurations SET version = '11.7', modified = now() WHERE id = 1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

View file

@ -443,8 +443,8 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if (User::canUpload() && empty($advancedCustom->doNotShowUploadButton)) {
?>
<li>
<div data-toggle="tooltip" title="<?php echo __("Submit your videos"); ?>" data-placement="left" class="btn-group faa-parent animated-hover">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left" data-toggle="dropdown">
<div data-toggle="tooltip" title="<?php echo __("Submit your videos"); ?>" data-placement="left" class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left faa-parent animated-hover" data-toggle="dropdown">
<i class="<?php echo $advancedCustom->uploadButtonDropdownIcon ?? "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? __($advancedCustom->uploadButtonDropdownText) : ""; ?> <span class="caret"></span>
</button>
<?php
@ -520,8 +520,8 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if (!empty($getUploadMenuButton)) {
?>
<li>
<div data-toggle="tooltip" title="<?php echo __("Submit your videos"); ?>" data-placement="left" class="btn-group faa-parent animated-hover">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left" data-toggle="dropdown">
<div data-toggle="tooltip" title="<?php echo __("Submit your videos"); ?>" data-placement="left" class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left faa-parent animated-hover" data-toggle="dropdown">
<i class="<?php echo $advancedCustom->uploadButtonDropdownIcon ?? "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? __($advancedCustom->uploadButtonDropdownText) : ""; ?> <span class="caret"></span>
</button>
<?php echo '<!-- navbar line ' . __LINE__ . '-->'; ?>

View file

@ -53,8 +53,8 @@ if (empty($advancedCustom->openEncoderInIFrame) || !isSameDomainAsMyAVideo($conf
if (!empty($config->getEncoderURL())) {
?>
<li>
<a href="#" onclick="avideoModalIframeFull(webSiteRootURL+'i/upload');return false;" data-toggle="tooltip" title="<?php echo __("Upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cog"></span> <?php echo empty($advancedCustom->encoderButtonLabel) ? __("Encode video and audio") : __($advancedCustom->encoderButtonLabel); ?>
<a class="faa-parent animated-hover" href="#" onclick="avideoModalIframeFull(webSiteRootURL+'i/upload');return false;" data-toggle="tooltip" title="<?php echo __("Upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cog faa-spin"></span> <?php echo empty($advancedCustom->encoderButtonLabel) ? __("Encode video and audio") : __($advancedCustom->encoderButtonLabel); ?>
</a>
</li>
<?php

View file

@ -1456,14 +1456,18 @@ function avideoModalIframeRemove() {
function avideoResponse(response) {
console.log('avideoResponse', response);
if (typeof response == 'string') {
if (typeof response === 'string') {
response = JSON.parse(response);
}
console.log('avideoResponse', response);
if (response.error) {
if (!response.msg) {
if(typeof response.error === 'string'){
response.msg = response.error;
}else{
response.msg = 'Error';
}
}
avideoAlertError(response.msg);
} else {
if (!response.msg) {

View file

@ -13,18 +13,24 @@
<a href="<?php echo $global['webSiteRootURL']; ?>objects/getAllEmails.csv.php" class="btn btn-primary">
<i class="fas fa-file-csv"></i> <?php echo __("CSV File"); ?>
</a>
<a href="#" class="btn btn-primary">
<i class="fas fa-users"></i> <span class="totalDevicesOnline">0</span>
</a>
<div class="btn btn-primary" data-toggle="tooltip" title="<?php echo __('Online users'); ?>">
<i class="fas fa-users"></i> <span class="total_users_online">0</span>
</div>
</div>
<div class="clearfix"></div>
<ul class="nav nav-tabs nav-tabs-horizontal">
<li class="active"><a data-toggle="tab" href="#usersTab"><?php echo __('Active Users'); ?></a></li>
<li><a data-toggle="tab" href="#inactiveUsersTab" onclick="startUserGrid('#gridInactive', '?status=i', 0);"><?php echo __('Inactive Users'); ?></a></li>
<li><a data-toggle="tab" href="#adminUsersTab" onclick="startUserGrid('#gridAdmin', '?isAdmin=1', 0);"><?php echo __('Admin Users'); ?></a></li>
<li class="active"><a data-toggle="tab" href="#usersTab" onclick="startUserGrid('#grid', '?status=a', 0);"><i class="fas fa-user"></i> <?php echo __('Active Users'); ?></a></li>
<li><a data-toggle="tab" href="#inactiveUsersTab" onclick="startUserGrid('#gridInactive', '?status=i', 0);"><i class="fas fa-user-slash"></i> <?php echo __('Inactive Users'); ?></a></li>
<li><a data-toggle="tab" href="#adminUsersTab" onclick="startUserGrid('#gridAdmin', '?isAdmin=1', 0);"><i class="fas fa-user-tie"></i> <?php echo __('Admin Users'); ?></a></li>
<?php
if (empty($advancedCustomUser->disableCompanySignUp)) {
?>
<li><a data-toggle="tab" href="#companyUsersTab" onclick="startUserGrid('#companyAdmin', '?isCompany=1', 0);"><i class="fas fa-building"></i> <?php echo __('Company Users'); ?></a></li>
<li><a data-toggle="tab" href="#companyApUsersTab" onclick="startUserGrid('#companyApAdmin', '?isCompany=2', 0);"><i class="fas fa-building"></i> <?php echo __('Company Waiting Approval'); ?></a></li>
<?php
}
foreach ($userGroups as $value) {
echo '<li><a data-toggle="tab" href="#userGroupTab' . $value['id'] . '" onclick="startUserGrid(\'#userGroupGrid' . $value['id'] . '\', \'?status=a&user_groups_id=' . $value['id'] . '\', ' . $value['id'] . ');">' . $value['group_name'] . '</a></li>';
echo '<li><a data-toggle="tab" href="#userGroupTab' . $value['id'] . '" onclick="startUserGrid(\'#userGroupGrid' . $value['id'] . '\', \'?status=a&user_groups_id=' . $value['id'] . '\', ' . $value['id'] . ');"><i class="fas fa-users"></i> ' . $value['group_name'] . '</a></li>';
}
?>
</ul>
@ -79,7 +85,44 @@
</thead>
</table>
</div>
<?php
if (empty($advancedCustomUser->disableCompanySignUp)) {
?>
<div id="companyUsersTab" class="tab-pane fade">
<table id="companyAdmin" class="table table-condensed table-hover table-striped">
<thead>
<tr>
<th data-column-id="id" data-width="80px"><?php echo __("#"); ?></th>
<th data-column-id="user" data-formatter="user"><?php echo __("User"); ?></th>
<th data-column-id="name" data-order="desc"><?php echo __("Name"); ?></th>
<th data-column-id="email" ><?php echo __("E-mail"); ?></th>
<th data-column-id="created" ><?php echo __("Created"); ?></th>
<th data-column-id="modified" ><?php echo __("Modified"); ?></th>
<th data-column-id="tags" data-formatter="tags" data-sortable="false" ><?php echo __("Tags"); ?></th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false" data-width="200px"></th>
</tr>
</thead>
</table>
</div>
<div id="companyApUsersTab" class="tab-pane fade">
<table id="companyApAdmin" class="table table-condensed table-hover table-striped">
<thead>
<tr>
<th data-column-id="id" data-width="80px"><?php echo __("#"); ?></th>
<th data-column-id="user" data-formatter="user"><?php echo __("User"); ?></th>
<th data-column-id="name" data-order="desc"><?php echo __("Name"); ?></th>
<th data-column-id="email" ><?php echo __("E-mail"); ?></th>
<th data-column-id="created" ><?php echo __("Created"); ?></th>
<th data-column-id="modified" ><?php echo __("Modified"); ?></th>
<th data-column-id="tags" data-formatter="tags" data-sortable="false" ><?php echo __("Tags"); ?></th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false" data-width="200px"></th>
</tr>
</thead>
</table>
</div>
<?php
}
foreach ($userGroups as $value) {
$gridID = "userGroupGrid{$value['id']}";
?>
@ -149,6 +192,22 @@
<label for="inputAnalyticsCode" class="sr-only"><?php echo __("Analytics Code"); ?></label>
<input type="text" id="inputAnalyticsCode" class="form-control last" placeholder="Google Analytics Code: UA-123456789-1" >
<small>Do not paste the full javascript code, paste only the gtag id</small>
<br>
<?php
if (empty($advancedCustomUser->disableCompanySignUp)) {
?>
<label for="is_company" class="sr-only"><?php echo __("is a Company"); ?></label>
<select name="is_company" id="is_company" class="form-control last">
<?php
foreach (User::$is_company_status as $key => $value) {
echo "<option value='{$key}'>" . __($value) . "</option>";
}
?>
</select>
<?php }
?>
<ul class="list-group">
<li class="list-group-item <?php echo User::isAdmin() ? "" : "hidden"; ?>">
<?php echo __("is Admin"); ?>
@ -346,6 +405,7 @@
$('#phone').val('');
$('#inputChannelName').val('');
$('#inputAnalyticsCode').val('');
$('#is_company').val(0);
$('#isAdmin').prop('checked', false);
$('#canStream').prop('checked', false);
$('#canUpload').prop('checked', false);
@ -391,6 +451,7 @@ print AVideoPlugin::updateUserFormJS();
"analyticsCode": $('#inputAnalyticsCode').val(),
"isAdmin": $('#isAdmin').is(':checked'),
"canStream": $('#canStream').is(':checked'),
"is_company": $('#is_company').val(),
"canUpload": $('#canUpload').is(':checked'),
"canViewChart": $('#canViewChart').is(':checked'),
"canCreateMeet": $('#canCreateMeet').is(':checked'),
@ -500,6 +561,7 @@ print AVideoPlugin::updateUserFormJS();
$('.userGroups').prop('checked', false);
$('.usergroupsLi').removeClass('dynamic');
$('.usergroupsLi input').removeAttr('disabled');
$('#is_company').val(row.is_company);
for (var index in row.groups) {
$('#userGroup' + row.groups[index].id).prop('checked', true);

View file

@ -3,7 +3,11 @@ global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
if (User::isLogged()) {
header("Location: {$global['webSiteRootURL']}user");
exit;
}
//$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php");
// convert the string to a json object
@ -14,9 +18,12 @@ if (!empty($advancedCustomUser->disableNativeSignUp)) {
$agreement = AVideoPlugin::loadPluginIfEnabled("SignUpAgreement");
$signInLink = "{$global['webSiteRootURL']}user?redirectUri=" . urlencode($_GET['redirectUri'] ?? "");
if (!empty($_GET['siteRedirectUri'])) {
$signInLink = $_GET['siteRedirectUri'];
$redirectUri = getRedirectUri($global['webSiteRootURL']);
$siteRedirectUri = "{$global['webSiteRootURL']}user";
$siteRedirectUri = addQueryStringParameter($siteRedirectUri, 'redirectUri', $redirectUri);
if (isValidURL(@$_GET['siteRedirectUri'])) {
$siteRedirectUri = $_GET['siteRedirectUri'];
}
?>
<!DOCTYPE html>
@ -37,9 +44,38 @@ if (!empty($_GET['siteRedirectUri'])) {
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-2"></div>
<div class="col-xs-12 col-sm-12 col-lg-8">
<form class="form-compact well form-horizontal <?php echo getCSSAnimationClassAndStyle();getCSSAnimationClassAndStyleAddWait(0.5); ?>" id="updateUserForm" onsubmit="">
<fieldset>
<legend class="hidden-xs <?php echo getCSSAnimationClassAndStyle(); ?>"><?php echo __("Sign Up"); ?></legend>
<div class="panel panel-default <?php
echo getCSSAnimationClassAndStyle();
getCSSAnimationClassAndStyleAddWait(0.5);
?>">
<div class="panel-heading tabbable-line">
<ul class="nav nav-tabs" id="signupNavTabs">
<li class="nav-item active" id="sinupBasic">
<a class="nav-link " href="#" data-toggle="tab" onclick="showCompanyFields(false)">
<i class="fas fa-user"></i>
<?php echo __("Sign Up"); ?>
</a>
</li>
<?php
if (empty($advancedCustomUser->disableCompanySignUp)) {
?>
<li class="nav-item" id="sinupCompany">
<a class="nav-link " href="#" data-toggle="tab" onclick="showCompanyFields(true)">
<i class="fas fa-building"></i>
<?php echo __("Company Sign Up"); ?>
</a>
</li>
<?php
}
?>
</ul>
</div>
<div class="panel-body">
<div class="tab-content" id="signupTabContent">
<div class="tab-pane active" id="signupRegular" >
<form id="updateUserForm" onsubmit="">
<div class="form-group">
<div class="col-md-12 inputGroupContainer">
<div class="input-group">
@ -51,54 +87,54 @@ if (!empty($_GET['siteRedirectUri'])) {
</div>
</div>
</div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs"><?php echo __("Name"); ?></label>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="inputName"><?php echo __("Name"); ?></label>
<div class="col-sm-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<input id="inputName" placeholder="<?php echo __("Name"); ?>" class="form-control" type="text" value="" required >
<input id="inputName" placeholder="<?php echo __("Name"); ?>" name="name" class="form-control" type="text" value="" required >
</div>
</div>
</div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs"><?php echo !empty($advancedCustomUser->forceLoginToBeTheEmail) ? __("E-mail") : __("User"); ?></label>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="inputUser"><?php echo!empty($advancedCustomUser->forceLoginToBeTheEmail) ? __("E-mail") : __("User"); ?></label>
<div class="col-sm-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="inputUser" placeholder="<?php echo!empty($advancedCustomUser->forceLoginToBeTheEmail) ? "me@example.com" : __("User"); ?>" class="form-control" type="<?php echo empty($advancedCustomUser->forceLoginToBeTheEmail) ? "text" : "email"; ?>" value="" required >
<input id="inputUser" placeholder="<?php echo!empty($advancedCustomUser->forceLoginToBeTheEmail) ? "me@example.com" : __("User"); ?>" class="form-control" type="<?php echo empty($advancedCustomUser->forceLoginToBeTheEmail) ? "text" : "email"; ?>" value="" name="user" required >
</div>
</div>
</div>
<?php
if (empty($advancedCustomUser->forceLoginToBeTheEmail)) {
?>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs"><?php echo __("E-mail"); ?></label>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="inputEmail"><?php echo __("E-mail"); ?></label>
<div class="col-sm-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input id="inputEmail" placeholder="<?php echo __("E-mail"); ?>" class="form-control" type="email" value="" required >
<input id="inputEmail" placeholder="<?php echo __("E-mail"); ?>" name="email" class="form-control" type="email" value="" required >
</div>
</div>
</div>
<?php
} ?>
<?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="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="phone"><?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="" >
<input id="phone" placeholder="<?php echo __("Phone"); ?>" name="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>
<?php }
?>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="inputPassword"><?php echo __("New Password"); ?></label>
<div class="col-sm-8 inputGroupContainer">
<?php
getInputPassword("inputPassword", 'class="form-control" autocomplete="off" ', __("New Password"));
@ -106,24 +142,57 @@ if (!empty($_GET['siteRedirectUri'])) {
</div>
</div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs"><?php echo __("Confirm New Password"); ?></label>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="inputPasswordConfirm"><?php echo __("Confirm New Password"); ?></label>
<div class="col-sm-8 inputGroupContainer">
<?php
getInputPassword("inputPasswordConfirm", 'class="form-control" autocomplete="off" ', __("Confirm New Password"));
?>
</div>
</div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<div class="clearfix"></div>
<?php
if (empty($advancedCustomUser->disableCompanySignUp)) {
$extra_info_fields = Users_extra_info::getAllActive(0, true);
echo '<!-- Show CompanySignUp -->';
echo '<input id="is_company" name="is_company" type="hidden" value="'.User::$is_company_status_WAITINGAPPROVAL.'" >';
} else {
$extra_info_fields = Users_extra_info::getAllActive();
echo '<!-- DO NOT Show CompanySignUp -->';
}
//var_dump($extra_info_fields);
foreach ($extra_info_fields as $value) {
if (Users_extra_info::isCompanyOnlyField($value['status'])) {
$class = 'companyField';
$style = 'display: none;';
?>
<div class="row form-group <?php echo $class; ?>" style="<?php echo $style; ?>">
<?php echo Users_extra_info::typeToHTML($value, 'col-sm-4 control-label hidden-xs', 'col-sm-8 inputGroupContainer'); ?>
</div>
<?php
} else {
?>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>" >
<?php echo Users_extra_info::typeToHTML($value, 'col-sm-4 control-label hidden-xs', 'col-sm-8 inputGroupContainer'); ?>
</div>
<?php
}
?>
<div class="clearfix"></div>
<?php
}
?>
<div class="clearfix"></div>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<?php
if (!empty($agreement)) {
$agreement->getSignupCheckBox();
}
?>
</div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs"><?php echo __("Type the code"); ?></label>
<div class="clearfix"></div>
<div class="row form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<label class="col-sm-4 control-label hidden-xs" for="captchaText"><?php echo __("Type the code"); ?></label>
<div class="col-sm-8 inputGroupContainer captcha">
<div class="input-group">
<span class="input-group-addon"><img src="<?php echo $global['webSiteRootURL']; ?>captcha?PHPSESSID=<?php echo session_id(); ?>&<?php echo time(); ?>" id="captcha"></span>
@ -132,80 +201,130 @@ if (!empty($_GET['siteRedirectUri'])) {
</div>
</div>
</div>
<!-- Button -->
<div class="form-group <?php echo getCSSAnimationClassAndStyle(); ?>">
<div class="col-md-12">
<button type="submit" class="btn btn-primary btn-block btn-lg" ><i class="fas fa-user-plus"></i> <?php echo __("Sign Up"); ?></button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<div class="panel-footer">
<button class="btn btn-primary btn-block btn-lg <?php echo getCSSAnimationClassAndStyle(); ?>" onclick="$('#updateUserForm').submit();" ><i class="fas fa-user-plus"></i> <?php echo __("Sign Up"); ?></button>
<?php
if (!empty($redirectUri)) {
?>
<a href="<?php echo $redirectUri; ?>" class="btn btn-default btn-block btn-xs <?php echo getCSSAnimationClassAndStyle(); ?>" ><i class="fas fa-times"></i> <?php echo __("Cancel"); ?></a>
<?php
}
?>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-2"></div>
</div>
<script>
function showCompanyFields(show) {
$('#signupNavTabs .nav-item').removeClass('active');
if (show) {
$('#sinupCompany').addClass('active');
$('.companyField').slideDown();
$('#is_company').val(<?php echo User::$is_company_status_WAITINGAPPROVAL; ?>);
} else {
$('#sinupBasic').addClass('active');
$('.companyField').slideUp();
$('#is_company').val(0);
}
}
function validateSignupForm() {
var errorFound = false;
var errorClass = 'glowBox';
$('#updateUserForm .input-group').removeClass(errorClass);
$('#updateUserForm input').each(function () {
console.log('found', $( this ).attr( 'name' ));
if($(this).prop('required') && $(this).is(":visible")){
if($( this ).attr( 'type' )==='checkbox'){
if(!$( this ).is(':checked')){
$( this ).closest('.input-group').addClass(errorClass);
errorFound = 'Confirmation Required';
return false;
}
}else{
console.log('is required', $( this ).attr( 'name' ));
if (!$( this ).val().match(/[0-9a-z]+/i)) {
$( this ).closest('.input-group').addClass(errorClass);
var label = $("label[for='" + $(this).attr('id') + "']").text();
if(!label){
label = $( this ).attr( 'name' );
}
errorFound = label+' is required';
return false;
}
}
}
});
console.log(errorFound);
if(errorFound){
avideoAlertError(errorFound);
return false;
}
var pass1 = $('#inputPassword').val();
var pass2 = $('#inputPasswordConfirm').val();
// Password doesn't match
if (!pass1.match(/[0-9a-z]+/i)) {
$('#inputPassword').closest('.input-group').addClass(errorClass);
avideoAlertError("<?php echo __("Your password cannot be blank"); ?>");
return false;
}
if (pass1 != pass2) {
$('#inputPassword').closest('.input-group').addClass(errorClass);
$('#inputPasswordConfirm').closest('.input-group').addClass(errorClass);
avideoAlertError("<?php echo __("Your password does not match!"); ?>");
return false;
}
if (!$('#captchaText').val().match(/^[0-9a-z]{5}$/i)) {
$('#captchaText').closest('.input-group').addClass(errorClass);
avideoAlertError("<?php echo __("The captcha is wrong"); ?>");
return false;
}
if(!isEmailValid($('#inputEmail').val())){
$('#inputEmail').closest('.input-group').addClass(errorClass);
avideoAlertError("<?php echo __("You must specify a valid email"); ?>");
return false;
}
if(!$('#inputUser').val().match(/^[0-9a-z]{3,}$/i)){
$('#inputUser').closest('.input-group').addClass(errorClass);
avideoAlertError("<?php echo __("Invalid user"); ?>");
return false;
}
return true;
}
$(document).ready(function () {
$('#btnReloadCapcha').click(function () {
$('#captcha').attr('src', '<?php echo $global['webSiteRootURL']; ?>captcha?PHPSESSID=<?php echo session_id(); ?>&' + Math.random());
$('#captchaText').val('');
});
$('#updateUserForm').submit(function (evt) {
evt.preventDefault();
if (validateSignupForm()) {
modal.showPleaseWait();
var pass1 = $('#inputPassword').val();
var pass2 = $('#inputPasswordConfirm').val();
// Password doesn't match
if (pass1 != '' && pass1 != pass2) {
modal.hidePleaseWait();
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your password does not match!"); ?>", "error");
return false;
} else {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/userCreate.json.php?PHPSESSID=<?php echo session_id(); ?>',
data: {
"user": $('#inputUser').val(),
"pass": $('#inputPassword').val(),
"email": $('#inputEmail').val(),
"phone": $('#Phone').val(),
"name": $('#inputName').val(),
"captcha": $('#captchaText').val()
},
url: webSiteRootURL + 'objects/userCreate.json.php?PHPSESSID=<?php echo session_id(); ?>',
data: $('#updateUserForm').serialize(),
type: 'post',
success: function (response) {
if (response.status > 0) {
var span = document.createElement("span");
span.innerHTML = "<?php echo __("Your user account has been created!"); ?><br><?php echo!empty($advancedCustomUser->unverifiedEmailsCanNOTLogin) ? __("Sign in to your email to verify your account!") : ""; ?>";
swal({
title: "<?php echo __("Congratulations!"); ?>",
content: span,
icon: "success",
}).then(function () {
<?php
if (!empty($_GET['siteRedirectUri'])) {
?>
window.location.href = '<?php echo $_GET['siteRedirectUri']; ?>';
<?php
avideoResponse(response);
if (!response.error) {
window.location.href = '<?php echo $siteRedirectUri; ?>';
} else {
?>
window.location.href = '<?php echo $global['webSiteRootURL']; ?>user?redirectUri=<?php echo urlencode($_GET['redirectUri'] ?? ""); ?>';
<?php
}
?>
});
} else {
if (response.error) {
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
} else {
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your user has NOT been created!"); ?>", "error");
}
}
modal.hidePleaseWait();
}
}
});
return false;
}

View file

@ -144,7 +144,7 @@ getCSSAnimationClassAndStyleAddWait(0.5); ?>">
<div class="row <?php echo getCSSAnimationClassAndStyle(); ?>" data-toggle="tooltip" title="<?php echo __("Are you new here?"); ?>">
<div class="col-md-12">
<a href="<?php echo $global['webSiteRootURL']; ?>signUp?redirectUri=<?php print $_GET['redirectUri'] ?? ""; ?>"
class="btn btn-default btn-block"><i class="fas fa-plus"></i> <?php echo __("Sign up"); ?></a>
class="btn btn-primary btn-block"><i class="fas fa-plus"></i> <?php echo __("Sign up"); ?></a>
</div>
</div>
<?php