mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Adding add usergroup to all users and videos
This commit is contained in:
parent
aad532e381
commit
7a97a9d196
5 changed files with 102 additions and 41 deletions
51
install/addAllUsersIntoUserGroup.php
Normal file
51
install/addAllUsersIntoUserGroup.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
//streamer config
|
||||
require_once '../videos/configuration.php';
|
||||
|
||||
if (!isCommandLineInterface()) {
|
||||
return die('Command Line only');
|
||||
}
|
||||
|
||||
$rows = UserGroups::getAllUsersGroupsArray();
|
||||
|
||||
if(empty($rows)){
|
||||
die('You do not have any user group');
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
echo "[$key] {$value}".PHP_EOL;
|
||||
}
|
||||
$_REQUEST['rowCount'] = 999999;
|
||||
|
||||
echo "Enter the user group number or press enter to skip:".PHP_EOL;
|
||||
ob_flush();
|
||||
$userGroup = trim(readline(""));
|
||||
|
||||
if(empty($rows[$userGroup])){
|
||||
die('This user group does not exists');
|
||||
}
|
||||
|
||||
if (!empty($userGroup)) {
|
||||
|
||||
$users = User::getAllUsers(true);
|
||||
|
||||
foreach ($users as $value) {
|
||||
$user = new User($value['id']);
|
||||
$addToUG = array($userGroup);
|
||||
$currentUG =UserGroups::getUserGroups($value['id']);
|
||||
if(!empty($currentUG)){
|
||||
foreach ($currentUG as $ug) {
|
||||
$addToUG[] = $ug["users_groups_id"];
|
||||
}
|
||||
}
|
||||
$user->setUserGroups($addToUG);
|
||||
if($user->save(true)){
|
||||
echo "Success: saved user [{$value['id']}] {$value['user']} :". json_encode($addToUG).PHP_EOL;
|
||||
}else{
|
||||
echo "**ERROR: saving user [{$value['id']}] {$value['user']} :". json_encode($addToUG).PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Bye";
|
||||
echo "\n";
|
||||
die();
|
42
install/addAllVideosIntoUserGroup.php
Normal file
42
install/addAllVideosIntoUserGroup.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
//streamer config
|
||||
require_once '../videos/configuration.php';
|
||||
|
||||
if (!isCommandLineInterface()) {
|
||||
return die('Command Line only');
|
||||
}
|
||||
|
||||
$rows = UserGroups::getAllUsersGroupsArray();
|
||||
|
||||
if(empty($rows)){
|
||||
die('You do not have any user group');
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
echo "[$key] {$value}".PHP_EOL;
|
||||
}
|
||||
$_REQUEST['rowCount'] = 999999;
|
||||
|
||||
echo "Enter the user group number or press enter to skip:".PHP_EOL;
|
||||
ob_flush();
|
||||
$userGroup = trim(readline(""));
|
||||
|
||||
if(empty($rows[$userGroup])){
|
||||
die('This user group does not exists');
|
||||
}
|
||||
|
||||
if (!empty($userGroup)) {
|
||||
|
||||
$videos = Video::getAllVideosLight('');
|
||||
|
||||
foreach ($videos as $value) {
|
||||
if(UserGroups::updateVideoGroups($value['id'], $userGroup, true)){
|
||||
echo "Success: saved video [{$value['id']}] {$value['title']} :". json_encode($addToUG).PHP_EOL;
|
||||
}else{
|
||||
echo "**ERROR: saving video [{$value['id']}] {$value['title']} :". json_encode($addToUG).PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Bye";
|
||||
echo "\n";
|
||||
die();
|
|
@ -60,12 +60,6 @@ ini_set('error_log', $global['logfile']);
|
|||
global $global, $config, $advancedCustom, $advancedCustomUser;
|
||||
|
||||
require_once $global['systemRootPath'] . 'objects/functions.php';
|
||||
if(isCommandLineInterface()){
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
if (empty($doNotConnectDatabaseIncludeConfig)) {
|
||||
_mysql_connect();
|
||||
} else {
|
||||
|
@ -75,9 +69,6 @@ require_once $global['systemRootPath'] . 'objects/mysql_dal.php';
|
|||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'objects/security.php';
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
// for update config from old versions 2020-05-11
|
||||
if (empty($global['webSiteRootPath']) || $global['configurationVersion'] < 3.1) {
|
||||
Configuration::rewriteConfigFile();
|
||||
|
@ -106,17 +97,11 @@ if (empty($doNotStartSessionbaseIncludeConfig)) {
|
|||
|
||||
session_start();
|
||||
}
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
// DDOS protection can be disabled in video/configuration.php
|
||||
if (!empty($global['enableDDOSprotection'])) {
|
||||
ddosProtection();
|
||||
}
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
// set the referrer for aVideo
|
||||
$url1['host'] = '';
|
||||
$global['HTTP_REFERER'] = '';
|
||||
|
@ -156,17 +141,11 @@ if (!empty($url1['host']) && !empty($url2['host']) && $url1['host'] !== $url2['h
|
|||
$_SESSION['LAST_HTTP_REFERER'] = $global['HTTP_REFERER'];
|
||||
//var_dump($global['HTTP_REFERER'], $url1);exit;
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
_ob_end_clean();
|
||||
//$output = _ob_get_clean();
|
||||
_ob_start(true);
|
||||
//echo $output;
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
$_SESSION['lastUpdate'] = time();
|
||||
$_SESSION['savedQuerys'] = 0;
|
||||
require_once $global['systemRootPath'] . 'objects/Object.php';
|
||||
|
@ -198,18 +177,12 @@ if (empty($global['avideo_resolutions'])) {
|
|||
$global['avideo_resolutions'] = [240, 360, 480, 540, 720, 1080, 1440, 2160];
|
||||
}
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
sort($global['avideo_resolutions']);
|
||||
if (!empty($doNotConnectDatabaseIncludeConfig)) {
|
||||
return false;
|
||||
}
|
||||
$advancedCustom = AVideoPlugin::getObjectData('CustomizeAdvanced');
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
if (empty($global['disableTimeFix'])) {
|
||||
/*
|
||||
$now = new DateTime();
|
||||
|
@ -224,18 +197,12 @@ if (empty($global['disableTimeFix'])) {
|
|||
ObjectYPT::setGlobalTimeZone();
|
||||
}
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
$avideoLayout = AVideoPlugin::getObjectData('Layout');
|
||||
$avideoCustomizeUser = $advancedCustomUser = AVideoPlugin::getObjectData('CustomizeUser');
|
||||
$avideoCustomize = $customizePlugin = AVideoPlugin::getObjectData('Customize');
|
||||
$avideoPermissions = $permissionsPlugin = AVideoPlugin::getObjectData('Permissions');
|
||||
$avideoPlayerSkins = AVideoPlugin::getObjectData('PlayerSkins');
|
||||
|
||||
if(isCommandLineInterface()){
|
||||
echo 'Include config line '.__LINE__.PHP_EOL;
|
||||
}
|
||||
if (!empty($_GET['type'])) {
|
||||
$metaDescription = " {$_GET['type']}";
|
||||
} elseif (!empty($_GET['showOnly'])) {
|
||||
|
|
|
@ -616,12 +616,12 @@ if (typeof gtag !== \"function\") {
|
|||
//echo "u:" . $this->user . "|p:" . strlen($this->password);
|
||||
if (empty($this->user)) {
|
||||
//echo "u:" . $this->user . "|p:" . strlen($this->password);
|
||||
_error_log('Error : 1 ' . __("You need a user and passsword to register"));
|
||||
_error_log('Error : 1 ' . __("You need a user to register"));
|
||||
return false;
|
||||
}
|
||||
if (empty($this->password)) {
|
||||
//echo "u:" . $this->user . "|p:" . strlen($this->password);
|
||||
_error_log('Error : 2 ' . __("You need a user and passsword to register"));
|
||||
_error_log('Error : 2 ' . __("You need a passsword to register"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,9 +213,8 @@ class UserGroups
|
|||
|
||||
// for users
|
||||
|
||||
public static function updateUserGroups($users_id, $array_groups_id, $byPassAdmin=false, $mergeWithCurrentUserGroups=false)
|
||||
{
|
||||
if (!$byPassAdmin && !Permissions::canAdminUsers()) {
|
||||
public static function updateUserGroups($users_id, $array_groups_id, $byPassAdmin=false, $mergeWithCurrentUserGroups=false){
|
||||
if (!$byPassAdmin && !Permissions::canAdminUsers() && !isCommandLineInterface()) {
|
||||
return false;
|
||||
}
|
||||
if (!is_array($array_groups_id)) {
|
||||
|
@ -383,21 +382,23 @@ class UserGroups
|
|||
|
||||
public static function updateVideoGroups($videos_id, $array_groups_id, $mergeWithCurrentUserGroups=false)
|
||||
{
|
||||
if (!User::canUpload()) {
|
||||
if (empty($array_groups_id) || (!isCommandLineInterface() && !User::canUpload())) {
|
||||
return false;
|
||||
}
|
||||
if (!is_array($array_groups_id)) {
|
||||
return false;
|
||||
$array_groups_id = array($array_groups_id);
|
||||
}
|
||||
|
||||
if ($mergeWithCurrentUserGroups) {
|
||||
$current_user_groups = self::getVideosAndCategoriesUserGroups($videos_id);
|
||||
foreach ($current_user_groups as $value) {
|
||||
if (!in_array($value['id'], $array_groups_id)) {
|
||||
if($value['isVideoUserGroup']){
|
||||
$array_groups_id[] = $value['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::deleteGroupsFromVideo($videos_id);
|
||||
global $global;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue