mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
related to #2158 update user and guest pop in
- Implementation of a new modal for modifying a user or guest - Addition of a function to allow plugins to add a tab to the new user modal - Fix bug: "badger-number" is updated when a user is added or deleted - Fix bug: When the user who is editing has permissions to delete the user he is modifying, the delete icon is now displayed correctly - Added a new api method for modifying the main user and generating a link to reset a password - Passed $conf[‘webmaster_id’] in database configuration
This commit is contained in:
parent
158e99573b
commit
27cd5cde9e
26 changed files with 2144 additions and 467 deletions
|
@ -938,6 +938,20 @@
|
|||
"code": 59535,
|
||||
"src": "fontawesome"
|
||||
},
|
||||
{
|
||||
"uid": "8154ecb52c685ee2821a4d753b9c4f52",
|
||||
"css": "king",
|
||||
"code": 59487,
|
||||
"src": "custom_icons",
|
||||
"selected": true,
|
||||
"svg": {
|
||||
"path": "M64.2 793.1H1060.9V839.1C1060.9 927.9 1000.8 1000 926.7 1000H198.3C124.2 1000 64.2 927.9 64.2 839.1V793.1ZM64.2 724.1L0.4 198.5C-4.4 158.5 33.2 131 60.6 154.5L275.5 338.6C301.6 360.9 337.9 353.4 356.1 321.8L531 19.8C546.3-6.6 578.7-6.6 594 19.8L768.9 321.8C787.1 353.4 823.4 360.9 849.5 338.6L1064.4 154.5C1091.8 131 1129.4 158.5 1124.6 198.5L1060.8 724.1H64.2Z",
|
||||
"width": 1125
|
||||
},
|
||||
"search": [
|
||||
"vector"
|
||||
]
|
||||
},
|
||||
{
|
||||
"uid": "7411608e7611ffd477aeec7d239f87e9",
|
||||
"css": "dice",
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
.icon-th-list-1:before { content: '\e85c'; } /* '' */
|
||||
.icon-fire:before { content: '\e85d'; } /* '' */
|
||||
.icon-cone:before { content: '\e85e'; } /* '' */
|
||||
.icon-king:before { content: '\e85f'; } /* '' */
|
||||
.icon-user-1:before { content: '\e86c'; } /* '' */
|
||||
.icon-user-minus:before { content: '\e86d'; } /* '' */
|
||||
.icon-robot-head:before { content: '\e87e'; } /* '' */
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -97,6 +97,7 @@
|
|||
.icon-th-list-1 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-fire { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-cone { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-king { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-user-1 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-user-minus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-robot-head { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
.icon-th-list-1 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-fire { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-cone { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-king { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-user-1 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-user-minus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
.icon-robot-head { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
|
||||
|
|
15
admin/themes/default/fontello/css/fontello.css
vendored
15
admin/themes/default/fontello/css/fontello.css
vendored
|
@ -1,11 +1,11 @@
|
|||
@font-face {
|
||||
font-family: 'fontello';
|
||||
src: url('../font/fontello.eot?35196472');
|
||||
src: url('../font/fontello.eot?35196472#iefix') format('embedded-opentype'),
|
||||
url('../font/fontello.woff2?35196472') format('woff2'),
|
||||
url('../font/fontello.woff?35196472') format('woff'),
|
||||
url('../font/fontello.ttf?35196472') format('truetype'),
|
||||
url('../font/fontello.svg?35196472#fontello') format('svg');
|
||||
src: url('../font/fontello.eot?65786956');
|
||||
src: url('../font/fontello.eot?65786956#iefix') format('embedded-opentype'),
|
||||
url('../font/fontello.woff2?65786956') format('woff2'),
|
||||
url('../font/fontello.woff?65786956') format('woff'),
|
||||
url('../font/fontello.ttf?65786956') format('truetype'),
|
||||
url('../font/fontello.svg?65786956#fontello') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
|||
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
||||
@font-face {
|
||||
font-family: 'fontello';
|
||||
src: url('../font/fontello.svg?35196472#fontello') format('svg');
|
||||
src: url('../font/fontello.svg?65786956#fontello') format('svg');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -152,6 +152,7 @@
|
|||
.icon-th-list-1:before { content: '\e85c'; } /* '' */
|
||||
.icon-fire:before { content: '\e85d'; } /* '' */
|
||||
.icon-cone:before { content: '\e85e'; } /* '' */
|
||||
.icon-king:before { content: '\e85f'; } /* '' */
|
||||
.icon-user-1:before { content: '\e86c'; } /* '' */
|
||||
.icon-user-minus:before { content: '\e86d'; } /* '' */
|
||||
.icon-robot-head:before { content: '\e87e'; } /* '' */
|
||||
|
|
|
@ -146,11 +146,11 @@
|
|||
}
|
||||
@font-face {
|
||||
font-family: 'fontello';
|
||||
src: url('./font/fontello.eot?73909361');
|
||||
src: url('./font/fontello.eot?73909361#iefix') format('embedded-opentype'),
|
||||
url('./font/fontello.woff?73909361') format('woff'),
|
||||
url('./font/fontello.ttf?73909361') format('truetype'),
|
||||
url('./font/fontello.svg?73909361#fontello') format('svg');
|
||||
src: url('./font/fontello.eot?58072461');
|
||||
src: url('./font/fontello.eot?58072461#iefix') format('embedded-opentype'),
|
||||
url('./font/fontello.woff?58072461') format('woff'),
|
||||
url('./font/fontello.ttf?58072461') format('truetype'),
|
||||
url('./font/fontello.svg?58072461#fontello') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
@ -553,14 +553,17 @@
|
|||
<div class="span3" title="Code: 0xe85e">
|
||||
<i class="demo-icon icon-cone"></i> <span class="i-name">icon-cone</span><span class="i-code">0xe85e</span>
|
||||
</div>
|
||||
<div class="span3" title="Code: 0xe85f">
|
||||
<i class="demo-icon icon-king"></i> <span class="i-name">icon-king</span><span class="i-code">0xe85f</span>
|
||||
</div>
|
||||
<div class="span3" title="Code: 0xe86c">
|
||||
<i class="demo-icon icon-user-1"></i> <span class="i-name">icon-user-1</span><span class="i-code">0xe86c</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xe86d">
|
||||
<i class="demo-icon icon-user-minus"></i> <span class="i-name">icon-user-minus</span><span class="i-code">0xe86d</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xe87e">
|
||||
<i class="demo-icon icon-robot-head"></i> <span class="i-name">icon-robot-head</span><span class="i-code">0xe87e</span>
|
||||
</div>
|
||||
|
@ -570,11 +573,11 @@
|
|||
<div class="span3" title="Code: 0xe88e">
|
||||
<i class="demo-icon icon-resize-full"></i> <span class="i-name">icon-resize-full</span><span class="i-code">0xe88e</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xe88f">
|
||||
<i class="demo-icon icon-resize-small"></i> <span class="i-name">icon-resize-small</span><span class="i-code">0xe88f</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xe89e">
|
||||
<i class="demo-icon icon-piwigo"></i> <span class="i-name">icon-piwigo</span><span class="i-code">0xe89e</span>
|
||||
</div>
|
||||
|
@ -584,11 +587,11 @@
|
|||
<div class="span3" title="Code: 0xf0a0">
|
||||
<i class="demo-icon icon-hdd"></i> <span class="i-name">icon-hdd</span><span class="i-code">0xf0a0</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf0ae">
|
||||
<i class="demo-icon icon-tasks"></i> <span class="i-name">icon-tasks</span><span class="i-code">0xf0ae</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf0b0">
|
||||
<i class="demo-icon icon-filter"></i> <span class="i-name">icon-filter</span><span class="i-code">0xf0b0</span>
|
||||
</div>
|
||||
|
@ -598,11 +601,11 @@
|
|||
<div class="span3" title="Code: 0xf0ca">
|
||||
<i class="demo-icon icon-list-bullet"></i> <span class="i-name">icon-list-bullet</span><span class="i-code">0xf0ca</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf0e0">
|
||||
<i class="demo-icon icon-mail-alt"></i> <span class="i-name">icon-mail-alt</span><span class="i-code">0xf0e0</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf0e8">
|
||||
<i class="demo-icon icon-sitemap"></i> <span class="i-name">icon-sitemap</span><span class="i-code">0xf0e8</span>
|
||||
</div>
|
||||
|
@ -612,11 +615,11 @@
|
|||
<div class="span3" title="Code: 0xf10c">
|
||||
<i class="demo-icon icon-circle-empty"></i> <span class="i-name">icon-circle-empty</span><span class="i-code">0xf10c</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf125">
|
||||
<i class="demo-icon icon-crop"></i> <span class="i-name">icon-crop</span><span class="i-code">0xf125</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf141">
|
||||
<i class="demo-icon icon-ellipsis"></i> <span class="i-name">icon-ellipsis</span><span class="i-code">0xf141</span>
|
||||
</div>
|
||||
|
@ -626,11 +629,11 @@
|
|||
<div class="span3" title="Code: 0xf15d">
|
||||
<i class="demo-icon icon-sort-name-up"></i> <span class="i-name">icon-sort-name-up</span><span class="i-code">0xf15d</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf160">
|
||||
<i class="demo-icon icon-sort-alt-up"></i> <span class="i-name">icon-sort-alt-up</span><span class="i-code">0xf160</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf161">
|
||||
<i class="demo-icon icon-sort-alt-down"></i> <span class="i-name">icon-sort-alt-down</span><span class="i-code">0xf161</span>
|
||||
</div>
|
||||
|
@ -640,11 +643,11 @@
|
|||
<div class="span3" title="Code: 0xf175">
|
||||
<i class="demo-icon icon-down"></i> <span class="i-name">icon-down</span><span class="i-code">0xf175</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf176">
|
||||
<i class="demo-icon icon-up"></i> <span class="i-name">icon-up</span><span class="i-code">0xf176</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf178">
|
||||
<i class="demo-icon icon-right"></i> <span class="i-name">icon-right</span><span class="i-code">0xf178</span>
|
||||
</div>
|
||||
|
@ -654,11 +657,11 @@
|
|||
<div class="span3" title="Code: 0xf1c0">
|
||||
<i class="demo-icon icon-database"></i> <span class="i-name">icon-database</span><span class="i-code">0xf1c0</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf1c5">
|
||||
<i class="demo-icon icon-file-image"></i> <span class="i-name">icon-file-image</span><span class="i-code">0xf1c5</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf1c9">
|
||||
<i class="demo-icon icon-file-code"></i> <span class="i-name">icon-file-code</span><span class="i-code">0xf1c9</span>
|
||||
</div>
|
||||
|
@ -668,11 +671,11 @@
|
|||
<div class="span3" title="Code: 0xf204">
|
||||
<i class="demo-icon icon-toggle-off"></i> <span class="i-name">icon-toggle-off</span><span class="i-code">0xf204</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf205">
|
||||
<i class="demo-icon icon-toggle-on"></i> <span class="i-name">icon-toggle-on</span><span class="i-code">0xf205</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3" title="Code: 0xf21b">
|
||||
<i class="demo-icon icon-user-secret"></i> <span class="i-name">icon-user-secret</span><span class="i-code">0xf21b</span>
|
||||
</div>
|
||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Copyright (C) 2023 by original authors @ fontello.com</metadata>
|
||||
<metadata>Copyright (C) 2024 by original authors @ fontello.com</metadata>
|
||||
<defs>
|
||||
<font id="fontello" horiz-adv-x="1000" >
|
||||
<font-face font-family="fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
||||
|
@ -202,6 +202,8 @@
|
|||
|
||||
<glyph glyph-name="cone" unicode="" d="M426 833c8 23 42 23 50 0l92-259c-59-43-189-52-233 1l91 258z m-127-360l-56-158c92-131 308-133 416 1l-61 173c-37-52-173-111-299-16z m148-378c141 0 269 113 252 193l172-92c36-20 37-71 2-92l-397-236c-16-10-37-10-54 0l-396 236c-35 21-34 72 2 92l166 90c-14-49 67-191 253-191z" horiz-adv-x="921" />
|
||||
|
||||
<glyph glyph-name="king" unicode="" d="M64 57h997v-46c0-89-60-161-134-161h-729c-74 0-134 72-134 161v46z m0 69l-64 526c-4 40 33 67 61 44l215-185c26-22 62-14 80 17l175 302c15 27 48 27 63 0l175-302c18-31 54-39 81-17l214 185c28 23 65-4 61-44l-64-526h-997z" horiz-adv-x="1125" />
|
||||
|
||||
<glyph glyph-name="user-1" unicode="" d="M438 350c138 0 250 112 250 250s-112 250-250 250-250-112-250-250 111-250 250-250z m175-62h-33c-43-20-92-32-142-32s-99 12-143 32h-32c-145 0-263-118-263-263v-81c0-52 42-94 94-94h687c52 0 94 42 94 94v81c0 145-118 263-262 263z" horiz-adv-x="875" />
|
||||
|
||||
<glyph glyph-name="user-minus" unicode="" d="M1219 444h-375c-17 0-31-14-31-31v-63c0-17 14-31 31-31h375c17 0 31 14 31 31v63c0 17-14 31-31 31z m-781-94c138 0 250 112 250 250s-112 250-250 250-250-112-250-250 111-250 250-250z m175-62h-33c-43-20-92-32-142-32s-99 12-143 32h-32c-145 0-263-118-263-263v-81c0-52 42-94 94-94h687c52 0 94 42 94 94v81c0 145-118 263-262 263z" horiz-adv-x="1250" />
|
||||
|
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 61 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
const color_icons = ["icon-red", "icon-blue", "icon-yellow", "icon-purple", "icon-green"];
|
||||
const status_arr = ['webmaster', 'admin', 'normal', 'generic', 'guest'];
|
||||
const level_arr = ['0', '1', '2', '4', '8'];
|
||||
const king_template = '<span class="icon-king" id="the_king"></span>';
|
||||
let current_users = [];
|
||||
let guest_id = 0;
|
||||
let guest_user = {};
|
||||
|
@ -16,6 +17,11 @@ let selection = [];
|
|||
let first_update = true;
|
||||
let total_users = 0
|
||||
let filter_by = 'id DESC';
|
||||
let plugins_set_functions = {};
|
||||
let plugins_get_functions = {};
|
||||
let plugins_load = [];
|
||||
let plugins_users_infos_table = [];
|
||||
let owner_username = '';
|
||||
/*----------------
|
||||
Escape of pop-in
|
||||
----------------*/
|
||||
|
@ -23,7 +29,8 @@ Escape of pop-in
|
|||
//get out of pop in via escape key
|
||||
$(document).on('keydown', function (e) {
|
||||
if ( e.keyCode === 27) { // ESC button
|
||||
$("#UserList").fadeOut();
|
||||
hide_modals();
|
||||
close_user_list();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -59,6 +66,7 @@ function open_user_list() {
|
|||
|
||||
function close_user_list() {
|
||||
hide_temporary_messages();
|
||||
$('#result_send_mail_copy_input').val('');
|
||||
$("#UserList").fadeOut();
|
||||
}
|
||||
|
||||
|
@ -77,7 +85,6 @@ function isSelectionMode() {
|
|||
return $("#toggleSelectionMode").is(":checked")
|
||||
}
|
||||
|
||||
|
||||
$( document ).ready(function() {
|
||||
$(".user-property-register").tipTip({
|
||||
maxWidth: "300px",
|
||||
|
@ -92,25 +99,42 @@ $( document ).ready(function() {
|
|||
fadeOut: 200
|
||||
});
|
||||
$(".advanced-filter-level select option").eq(1).remove();
|
||||
$('.edit-password').click(function () {
|
||||
$('.user-property-password').hide();
|
||||
$('.user-property-password-change').show().css('display', 'flex');
|
||||
|
||||
/* Edit Password */
|
||||
$('.button-edit-password-icon').click(function () {
|
||||
reset_password_modals();
|
||||
$('.user-property-password-change').fadeIn();
|
||||
})
|
||||
|
||||
$('.edit-password-cancel').click(function () {
|
||||
//possibly reset input value
|
||||
$('.user-property-password').show();
|
||||
$('.user-property-password-change').hide();
|
||||
$('.user-property-password-change').fadeOut();
|
||||
reset_input_password();
|
||||
})
|
||||
|
||||
$('.icon-show-password').on('click', function() {
|
||||
const icon = $(this);
|
||||
const closestInput = icon.siblings();
|
||||
if (closestInput.attr('type') === 'password') {
|
||||
closestInput.attr('type', 'text');
|
||||
icon.removeClass('icon-eye').addClass('icon-eye-off');
|
||||
} else {
|
||||
closestInput.attr('type', 'password');
|
||||
icon.removeClass('icon-eye-off').addClass('icon-eye');
|
||||
}
|
||||
});
|
||||
|
||||
// Password input onkeyup clear error
|
||||
$('#edit_user_password, #edit_user_conf_password').on('keyup', function() {
|
||||
hide_error_edit_user();
|
||||
});
|
||||
|
||||
/* Edit Username */
|
||||
$('.edit-username').click(function () {
|
||||
$('.user-property-username').hide();
|
||||
$('.user-property-username-change').show().css('display', 'flex');
|
||||
$('.user-property-username-change').show();
|
||||
})
|
||||
|
||||
$('.edit-username-cancel').click(function () {
|
||||
//possibly reset input value
|
||||
$('.user-property-username').show();
|
||||
$('.user-property-username-change').hide();
|
||||
})
|
||||
|
||||
|
@ -156,7 +180,16 @@ $( document ).ready(function() {
|
|||
$(this).siblings().attr("data-selected", "0");
|
||||
}
|
||||
})
|
||||
$(".AddUserGenPassword").click(gen_password);
|
||||
$(".AddUserGenPassword").on('click', function() {
|
||||
const password = gen_password();
|
||||
$("#AddUserPassword").val(password);
|
||||
});
|
||||
$('.EditUserGenPassword').on('click', function() {
|
||||
const password = gen_password();
|
||||
$('#edit_user_password').val(password);
|
||||
$('#edit_user_conf_password').val(password);
|
||||
hide_error_edit_user();
|
||||
});
|
||||
$('.AddUserSubmit').click(add_user);
|
||||
$('.AddUserCancel').click(add_user_close);
|
||||
$(".CloseAddUser").click(add_user_close);
|
||||
|
@ -349,6 +382,49 @@ $( document ).ready(function() {
|
|||
}
|
||||
update_user_list();
|
||||
});
|
||||
|
||||
/* tabsheet pop in user */
|
||||
editTabsBind();
|
||||
|
||||
$('.edit-user-slides').on('scroll', function() {
|
||||
const slides = $('.edit-user-slides').children();
|
||||
const rectView = this.getBoundingClientRect();
|
||||
$('.edit-user-tabsheet').removeClass('selected');
|
||||
// for debug
|
||||
// console.log('RECT REFERENCES left / right', rectView.left.toFixed(0), ' / ', rectView.right.toFixed(0));
|
||||
|
||||
slides.each(function() {
|
||||
const rect = this.getBoundingClientRect();
|
||||
// for debug
|
||||
// console.log('rect',$(this).attr('id'), ' left / right : ', rect.left, ' / ', rect.right);
|
||||
if (+rect.left.toFixed(0) >= +rectView.left.toFixed(0) - 1 && +rect.right.toFixed(0) <= +rectView.right.toFixed(0) + 1) {
|
||||
const tabId = $(this).attr('id');
|
||||
$('#name_' + tabId).addClass('selected');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* tabsheet pop in guest */
|
||||
$('.guest-edit-user-tabsheet').off('click').on('click', function() {
|
||||
const tabName = $(this).attr('id').split('_');
|
||||
const tabId = tabName[1] + '_' + tabName[2] + '_' + tabName[3];
|
||||
$('#' + tabId)[0].scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
$('.guest-edit-user-slides').on('scroll', function() {
|
||||
const slides = $('.guest-edit-user-slides').children();
|
||||
const rectView = this.getBoundingClientRect();
|
||||
$('.guest-edit-user-tabsheet').removeClass('selected');
|
||||
slides.each(function() {
|
||||
const rect = this.getBoundingClientRect();
|
||||
if (+rect.left.toFixed(0) >= +rectView.left.toFixed(0) - 1 && +rect.right.toFixed(0) <= +rectView.right.toFixed(0) + 1) {
|
||||
const tabId = $(this).attr('id');
|
||||
$('#name_' + tabId).addClass('selected');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function set_view_selector(view_type) {
|
||||
|
@ -722,9 +798,7 @@ function setupRegisterDates(register_dates) {
|
|||
Add User
|
||||
------------------*/
|
||||
|
||||
function gen_password(e) {
|
||||
e.preventDefault();
|
||||
|
||||
function gen_password() {
|
||||
var characterSet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
|
||||
|
||||
var i;
|
||||
|
@ -736,7 +810,7 @@ function gen_password(e) {
|
|||
password += characterSet.charAt(Math.floor(Math.random() * characterSet.length));
|
||||
}
|
||||
|
||||
jQuery("#AddUserPassword").val(password);
|
||||
return password;
|
||||
}
|
||||
|
||||
function add_user_close() {
|
||||
|
@ -931,6 +1005,260 @@ function get_container_index_from_uid(uid) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
function hide_error_edit_user() {
|
||||
$('#UserList .EditUserErrors').animate({opacity: 0}, 100);
|
||||
}
|
||||
|
||||
function show_error_edit_user() {
|
||||
$('#UserList .EditUserErrors').animate({opacity: 1}, 300);
|
||||
}
|
||||
|
||||
function reset_input_password() {
|
||||
$('#edit_user_password, #edit_user_conf_password').val('');
|
||||
}
|
||||
|
||||
function editTabsBind () {
|
||||
$('.edit-user-tabsheet').off('click').on('click', function() {
|
||||
const tabName = $(this).attr('id').split('_');
|
||||
const tabId = tabName[1] + '_' + tabName[2];
|
||||
|
||||
$('#' + tabId)[0].scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function check_tabs (title_tab_name_id) {
|
||||
if (plugins_load.length > 2) {
|
||||
$('.edit-user-tab-title').css({gap : '0px', justifyContent: 'space-between'});
|
||||
const countMoresPlugins = plugins_load.length - 2;
|
||||
if (!document.getElementById('mores_plugins_expand')) {
|
||||
$('.edit-user-tab-title').append(
|
||||
'<span class="close mores-plugins" id="mores_plugins_expand"></span>' +
|
||||
'<div class="dropdown-mores-plugins" id="dropdown_mores_plugins"></div>'
|
||||
);
|
||||
}
|
||||
$('#mores_plugins_expand').html('+' + countMoresPlugins);
|
||||
|
||||
const dropdown = $('#dropdown_mores_plugins');
|
||||
const tabsheetTitle = $('#' + title_tab_name_id);
|
||||
$('.edit-user-tab-title').css('margin-top', '3px');
|
||||
$('.edit-user-tab-title p:lt(4)').css('padding-top', '5px');
|
||||
tabsheetTitle.css({'max-width': '100%'});
|
||||
tabsheetTitle.appendTo(dropdown);
|
||||
|
||||
if (1 === countMoresPlugins) {
|
||||
tabsheetTitle.css('border-radius', '10px');
|
||||
} else {
|
||||
dropdown.children().css('border-radius', '0');
|
||||
dropdown.children().first().css('border-radius', '10px 10px 0 0');
|
||||
dropdown.children().last().css('border-radius', '0 0 10px 10px');
|
||||
}
|
||||
|
||||
$('#mores_plugins_expand').off('click').on('click', function () {
|
||||
const icon = $(this);
|
||||
if(icon.hasClass('open')) {
|
||||
icon.removeClass('open').addClass('close');
|
||||
dropdown.fadeOut();
|
||||
} else {
|
||||
icon.removeClass('close').addClass('open');
|
||||
dropdown.fadeIn();
|
||||
$(window).off('click.hideUsersModal').on('click.hideUsersModal', function(e) {
|
||||
if (!$(e.target).closest('#dropdown_mores_plugins').length && !$(e.target).is('#mores_plugins_expand')) {
|
||||
$('#dropdown_mores_plugins').fadeOut();
|
||||
icon.removeClass('open').addClass('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new tab to the user's modal
|
||||
* @param {string} tab_name - The tab name (will also be used for the new tab id)
|
||||
* @param {string} content_id - The id of the HTML element
|
||||
* @param {string | null} users_table - The name of the column created in the users table (must be null if the set_data_function and get_data_function functions are used)
|
||||
* @param {() => {} | null} set_data_function - API call set function with ajax (must be null if users_table is used)
|
||||
* @param {() => {} | null} get_data_function - API call get function with ajax (must be null if users_table is used)
|
||||
* @returns {void} Displays the new tab in the user's modal
|
||||
*/
|
||||
function plugin_add_tab_in_user_modal(tab_name, content_id, users_table=null, set_data_function=null, get_data_function=null) {
|
||||
// verification
|
||||
if (typeof tab_name !== 'string') {
|
||||
throw new TypeError('tab_name must be a string.');
|
||||
}
|
||||
const name = tab_name.replace(/ /g, '').toLowerCase();
|
||||
if (document.getElementById('name_tab_' + name)) {
|
||||
throw new TypeError('An element with this tab_name already exists.');
|
||||
}
|
||||
|
||||
if (typeof content_id !== 'string') {
|
||||
throw new TypeError('content_id must be a string.');
|
||||
} else if (!document.getElementById(content_id)) {
|
||||
throw new TypeError('HTML element "' + content_id + '" not found.');
|
||||
} else if (document.querySelector('.edit-user-slides #' + content_id)) {
|
||||
throw new TypeError('An element with this content_id already exists.');
|
||||
}
|
||||
|
||||
if (users_table && typeof users_table !== 'string') {
|
||||
throw new TypeError('users_table must be a string.');
|
||||
}
|
||||
if (users_table && (set_data_function || get_data_function)) {
|
||||
throw new TypeError('users_table must be null if set_data_function or get_data_function is used.');
|
||||
}
|
||||
|
||||
if (set_data_function && typeof set_data_function !== 'function') {
|
||||
throw new TypeError('set_data_function must be a function.');
|
||||
} else if (set_data_function && typeof set_data_function === 'function') {
|
||||
plugins_set_functions[name + '_set_function'] = set_data_function;
|
||||
}
|
||||
|
||||
if (get_data_function && typeof get_data_function !== 'function') {
|
||||
throw new TypeError('get_data_function must be a function.');
|
||||
} else if (get_data_function && typeof get_data_function === 'function') {
|
||||
plugins_get_functions[name + '_get_function'] = get_data_function;
|
||||
}
|
||||
|
||||
if (users_table) {
|
||||
plugins_users_infos_table.push({content_id, users_table});
|
||||
}
|
||||
|
||||
// DOM modification
|
||||
const content = $('#' + content_id);
|
||||
|
||||
$('.edit-user-tab-title').append(
|
||||
'<p class="edit-user-tabsheet" id="name_tab_' + name + '" title="'+ tab_name +'">'+ tab_name +'</p>'
|
||||
);
|
||||
|
||||
$('.edit-user-slides').append(
|
||||
'<div class="edit-user-tabsheet-plugins '+ name +'-container" id="tab_'+ name +'"></div>'
|
||||
);
|
||||
|
||||
content.appendTo('#tab_' + name);
|
||||
content.show();
|
||||
|
||||
editTabsBind();
|
||||
|
||||
$('.edit-user-tabsheet').addClass('tab-with-plugin');
|
||||
|
||||
plugins_load.push('name_tab_' + name);
|
||||
check_tabs('name_tab_' + name);
|
||||
|
||||
if (plugins_load.length <= 2) {
|
||||
$('#name_tab_' + name).tipTip({
|
||||
delay: 0,
|
||||
fadeIn: 200,
|
||||
fadeOut: 200,
|
||||
edgeOffset: 3
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function reset_password_modals() {
|
||||
$('.user-property-password-change').hide();
|
||||
$('.user-property-password-change-inputs').hide();
|
||||
$('#edit_password_success_change').hide();
|
||||
$('#edit_password_result_mail').hide();
|
||||
$('#edit_password_result_mail_copy').hide();
|
||||
$('.user-property-password-choice').show();
|
||||
}
|
||||
|
||||
function reset_username_modals() {
|
||||
$('.edit-username-success').hide();
|
||||
$('.user-property-username-change-input').show();
|
||||
}
|
||||
|
||||
function reset_main_user_modals() {
|
||||
$('#main_user_rewrite').val('');
|
||||
$('#main_user_rewrite_icon').removeClass('icon-ok icon-green icon-cancel icon-red');
|
||||
$('.main-user-rewrite').hide();
|
||||
$('.main-user-validate').hide();
|
||||
$('.main-user-success').hide();
|
||||
$('.main-user-proceed').show();
|
||||
}
|
||||
|
||||
function hide_modals() {
|
||||
$('.user-property-username-change').hide();
|
||||
$('.user-property-password-change').hide();
|
||||
$('.user-property-main-user-change').hide();
|
||||
reset_password_modals();
|
||||
reset_username_modals();
|
||||
reset_main_user_modals();
|
||||
}
|
||||
|
||||
function display_long_string(username) {
|
||||
const formatedUsername = username.length > 20 ? username.slice(0, 17) + '...' : username;
|
||||
return formatedUsername;
|
||||
}
|
||||
|
||||
function generate_random_string() {
|
||||
const string = 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
let result = '';
|
||||
let c = 5;
|
||||
for (let i = 0; i < c; i++) {
|
||||
result += string.charAt(Math.floor(Math.random() * string.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ---------------
|
||||
Who is the king functions (main user)
|
||||
----------------*/
|
||||
function open_main_user_modal(user_to_edit) {
|
||||
const modal = $('.user-property-main-user-change');
|
||||
reset_main_user_modals();
|
||||
$('.main-user-proceed-desc').html(sprintf(mainUserContinue, `<b>${display_long_string(user_to_edit.username)}</b>`, `<b>${display_long_string(owner_username)}</b>`));
|
||||
modal.fadeIn();
|
||||
|
||||
// set event
|
||||
$('.main-user-btn-proceed').off('click').on('click', function() {
|
||||
const gen_string = generate_random_string();
|
||||
$('.main-user-rewrite-desc').html(sprintf(mainUserRewrite, `<b>${gen_string}</b>`) + ' :');
|
||||
$('.main-user-proceed').hide();
|
||||
$('.main-user-rewrite').fadeIn();
|
||||
event_check_string_main_user(user_to_edit.username, user_to_edit.id, gen_string);
|
||||
});
|
||||
|
||||
$('.user-property-main-user-cancel, #main_user_success_close').off('click').on('click', function() {
|
||||
modal.fadeOut();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function set_main_user_success() {
|
||||
const indexKey = current_users.findIndex(u => u.id === owner_id);
|
||||
const new_main = $('.user-container[key="' + indexKey + '"]').find('.user-container-username');
|
||||
let king = $('#the_king');
|
||||
if (!king.length) {
|
||||
king = $(king_template);
|
||||
}
|
||||
king.appendTo(new_main);
|
||||
$('.main-user-validate').hide();
|
||||
$('.main-user-success').fadeIn();
|
||||
}
|
||||
|
||||
function event_check_string_main_user(new_main_username, new_main_id, stringToCheck) {
|
||||
const icon = $('#main_user_rewrite_icon');
|
||||
$('#main_user_rewrite').off('keyup').on('keyup', function() {
|
||||
icon.removeClass('icon-ok icon-green').addClass('icon-cancel icon-red');
|
||||
if (stringToCheck === $(this).val()) {
|
||||
icon.removeClass('icon-cancel icon-red').addClass('icon-ok icon-green');
|
||||
$('.main-user-validate-desc').html(sprintf(mainUserValidate, `<b>${display_long_string(owner_username)}</b>`, `<b>${display_long_string(new_main_username)}</b>`));
|
||||
$('.main-user-success-desc').html(sprintf(mainUserSuccess, display_long_string(new_main_username)));
|
||||
$('.main-user-rewrite').hide();
|
||||
$('.main-user-validate').fadeIn();
|
||||
event_validate_main_user(new_main_username, new_main_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function event_validate_main_user(new_main_username, user_id) {
|
||||
$('.main-user-btn-validate').off('click').on('click', function() {
|
||||
set_main_user(user_id, new_main_username);
|
||||
});
|
||||
}
|
||||
|
||||
/*-----------------------
|
||||
Generate User Containers
|
||||
-----------------------*/
|
||||
|
@ -1006,6 +1334,9 @@ function fill_container_user_info(container, user_index) {
|
|||
let registration_dates = user.registration_date.split(' ');
|
||||
container.attr('key', user_index);
|
||||
container.find(".user-container-username span").html(user.username);
|
||||
if(user.id === owner_id) {
|
||||
container.find(".user-container-username").append(king_template);
|
||||
}
|
||||
container.find(".user-container-initials span").html(get_initials(user.username)).addClass(color_icons[user.id % 5]);
|
||||
container.find(".user-container-status span").html(status_to_str[user.status]);
|
||||
container.find(".user-container-email span").html(user.email);
|
||||
|
@ -1027,6 +1358,9 @@ function generate_user_list() {
|
|||
$(".user-container").click(user_container_click);
|
||||
}
|
||||
|
||||
function copyToClipboard(toCopy) {
|
||||
navigator.clipboard.writeText(toCopy);
|
||||
}
|
||||
/*---------------------
|
||||
Fill the pop-in values
|
||||
---------------------*/
|
||||
|
@ -1083,11 +1417,26 @@ function fill_user_edit_summary(user_to_edit, pop_in, isGuest) {
|
|||
pop_in.find('.user-property-username-change input').val(user_to_edit.username);
|
||||
pop_in.find('.user-property-password-change input').val('');
|
||||
pop_in.find('.user-property-permissions a').attr('href', `admin.php?page=user_perm&user_id=${user_to_edit.id}`);
|
||||
pop_in.find('.user-property-register').html(get_formatted_date(user_to_edit.registration_date));
|
||||
pop_in.find('.user-property-register').html(user_to_edit.registration_date_string);
|
||||
pop_in.find('.user-property-register').tipTip({content:`${registered_str}<br />${user_to_edit.registration_date_since}`});
|
||||
pop_in.find('.user-property-last-visit').html(get_formatted_date(user_to_edit.last_visit));
|
||||
pop_in.find('.user-property-last-visit').html(user_to_edit.last_visit_string);
|
||||
pop_in.find('.user-property-last-visit').tipTip({content: `${last_visit_str}<br />${user_to_edit.last_visit_since}`});
|
||||
pop_in.find('.user-property-history a').attr('href', history_base_url + user_to_edit.id);
|
||||
|
||||
// Hide the copy password button and change modal copy password
|
||||
// if you are not using https
|
||||
if(!window.isSecureContext) {
|
||||
$('#copy_password').hide();
|
||||
$('.update-password-success').css('margin', '40px 0');
|
||||
$('#result_send_mail_copy').hide();
|
||||
$('#result_send_mail_copy_btn')
|
||||
.css({'cursor': 'not-allowed', 'background-color' : 'grey', 'color': '#ffffff'})
|
||||
.attr('title', cantCopy)
|
||||
.on('mouseenter', function() {
|
||||
$(this).css('background-color', 'grey');
|
||||
})
|
||||
.tipTip();
|
||||
}
|
||||
}
|
||||
|
||||
function fill_user_edit_properties(user_to_edit, pop_in) {
|
||||
|
@ -1137,7 +1486,70 @@ function fill_user_edit_update(user_to_edit, pop_in) {
|
|||
pop_in.find('.update-user-button').unbind("click").click(
|
||||
user_to_edit.id === guest_id ? update_guest_info : update_user_info);
|
||||
pop_in.find('.edit-username-validate').unbind("click").click(update_user_username);
|
||||
pop_in.find('.edit-password-validate').unbind("click").click(update_user_password);
|
||||
pop_in.find('#edit_modal_password').off('click').on('click', function() {
|
||||
$('.user-property-password-choice').hide();
|
||||
$('.user-property-password-change-inputs').fadeIn();
|
||||
});
|
||||
if (user_to_edit.email) {
|
||||
pop_in.find('#send_password_link')
|
||||
.removeClass('unavailable tiptip')
|
||||
.attr('title', '')
|
||||
.off('click')
|
||||
.on('click', function () {
|
||||
send_link_password(user_to_edit.email, user_to_edit.username, user_to_edit.id, true);
|
||||
});
|
||||
pop_in.find('#send_password_link').off('mouseenter mouseleave focus blur');
|
||||
} else {
|
||||
pop_in.find('#send_password_link')
|
||||
.addClass('unavailable tiptip')
|
||||
.off('click')
|
||||
.attr('title', cannotSendMail)
|
||||
.tipTip({
|
||||
delay: 0,
|
||||
fadeIn: 200,
|
||||
fadeOut: 200,
|
||||
edgeOffset: 3
|
||||
});
|
||||
}
|
||||
pop_in.find('#copy_password_link').off('click').on('click', function() {
|
||||
const inputValue = $('#result_send_mail_copy_input').val();
|
||||
if (inputValue === '') {
|
||||
send_link_password(user_to_edit.email, user_to_edit.username, user_to_edit.id, false);
|
||||
} else {
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
copyToClipboard(inputValue);
|
||||
};
|
||||
}
|
||||
$('.user-property-password-choice').hide();
|
||||
$('#edit_password_result_mail_copy').fadeIn();
|
||||
$('#close_password_mail_send_close').off('click').on('click', function() {
|
||||
reset_password_modals();
|
||||
});
|
||||
$('#result_send_mail_copy_btn').off('click').on('click', function() {
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
const success = $('#result_send_mail_copy');
|
||||
success.fadeOut(100);
|
||||
copyToClipboard($('#result_send_mail_copy_input').val());
|
||||
success.fadeIn(100);
|
||||
};
|
||||
});
|
||||
$('#result_send_mail_copy_input').trigger('focus');
|
||||
});
|
||||
pop_in.find('.edit-password-validate').unbind("click").click(function() {
|
||||
const errDiv = $('#UserList .EditUserErrors');
|
||||
const inputPassword = $('#edit_user_password').val();
|
||||
const inputConfirmPassword = $('#edit_user_conf_password').val();
|
||||
|
||||
if (inputPassword === '' || inputConfirmPassword === '') {
|
||||
errDiv.html(missingField);
|
||||
show_error_edit_user();
|
||||
} else if (inputPassword !== inputConfirmPassword) {
|
||||
errDiv.html(noMatchPassword);
|
||||
show_error_edit_user();
|
||||
} else {
|
||||
update_user_password();
|
||||
}
|
||||
});
|
||||
pop_in.find('.delete-user-button').unbind("click").click(function () {
|
||||
$.confirm({
|
||||
title: title_msg.replace('%s', user_to_edit.username),
|
||||
|
@ -1172,6 +1584,7 @@ function fill_user_edit_permissions(user_to_edit, pop_in) {
|
|||
pop_in.find(".user-property-status .user-property-select").addClass("notClickable");
|
||||
pop_in.find(".user-property-username .edit-username").hide();
|
||||
} else {
|
||||
pop_in.find(".delete-user-button").show();
|
||||
pop_in.find(".user-property-password.edit-password").show();
|
||||
pop_in.find(".user-property-email .user-property-input").removeAttr('disabled');
|
||||
pop_in.find(".user-property-status .user-property-select").removeClass("notClickable");
|
||||
|
@ -1194,12 +1607,14 @@ function fill_user_edit_permissions(user_to_edit, pop_in) {
|
|||
pop_in.find(".user-property-status .user-property-select").addClass("notClickable");
|
||||
} else if (user_to_edit.status == "webmaster" && connected_user_status == "admin") {
|
||||
// I'm admin and I want to edit webmaster
|
||||
pop_in.find(".delete-user-button").hide();
|
||||
pop_in.find(".user-property-password.edit-password").hide();
|
||||
pop_in.find(".user-property-email .user-property-input").attr('disabled','disabled');
|
||||
pop_in.find(".user-property-status .user-property-select").addClass("notClickable");
|
||||
pop_in.find(".user-property-username .edit-username").hide();
|
||||
} else if (user_to_edit.status == "admin" && connected_user_status == "webmaster") {
|
||||
// I'm webmaster and I want to edit admin
|
||||
pop_in.find(".delete-user-button").show();
|
||||
pop_in.find(".user-property-password.edit-password").show();
|
||||
pop_in.find(".user-property-email .user-property-input").removeAttr('disabled');
|
||||
pop_in.find(".user-property-status .user-property-select").removeClass("notClickable");
|
||||
|
@ -1231,12 +1646,29 @@ function is_owner(user_id) {
|
|||
}
|
||||
|
||||
function fill_user_edit(user_to_edit) {
|
||||
let pop_in = $('.UserListPopInContainer');
|
||||
let pop_in = $('#UserList');
|
||||
fill_user_edit_summary(user_to_edit, pop_in, false);
|
||||
fill_user_edit_properties(user_to_edit, pop_in);
|
||||
fill_user_edit_preferences(user_to_edit, pop_in);
|
||||
fill_user_edit_update(user_to_edit, pop_in);
|
||||
fill_user_edit_permissions(user_to_edit, pop_in);
|
||||
fill_who_is_the_king(user_to_edit, pop_in);
|
||||
|
||||
// plugins get function
|
||||
if (Object.keys(plugins_get_functions).length > 0) {
|
||||
Object.entries(plugins_get_functions).forEach((f) => {
|
||||
f[1]();
|
||||
});
|
||||
}
|
||||
const keyUserToEdit = Object.keys(user_to_edit);
|
||||
plugins_users_infos_table.forEach((i) => {
|
||||
$('#' + i.content_id).val('');
|
||||
if (keyUserToEdit.includes(i.users_table)) {
|
||||
$('#' + i.content_id).val(user_to_edit[i.users_table]);
|
||||
} else {
|
||||
console.error(i.users_table, ' doesn\'t exist in USER_INFOS_TABLE');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fill_guest_edit() {
|
||||
|
@ -1248,6 +1680,53 @@ function fill_guest_edit() {
|
|||
fill_user_edit_update(user_to_edit, pop_in);
|
||||
}
|
||||
|
||||
function fill_who_is_the_king(user_to_edit, pop_in) {
|
||||
const who_is_the_king = pop_in.find("#who_is_the_king");
|
||||
// By default I'm an admin and I only see who is the Main User
|
||||
who_is_the_king
|
||||
.removeClass('princes-of-this-piwigo king-of-this-piwigo can-change')
|
||||
.addClass('royal-court-of-this-piwigo cannot-change')
|
||||
.attr('title', mainAskWebmaster)
|
||||
.tipTip();
|
||||
who_is_the_king.off('click');
|
||||
// I'm an webmaster
|
||||
if (connected_user_status === 'webmaster') {
|
||||
// check user to edit status
|
||||
switch (user_to_edit.status) {
|
||||
// user to edit is an webmaster
|
||||
case 'webmaster':
|
||||
who_is_the_king
|
||||
.removeClass('royal-court-of-this-piwigo king-of-this-piwigo cannot-change')
|
||||
.addClass('princes-of-this-piwigo can-change')
|
||||
.attr('title', mainUserSet)
|
||||
.tipTip();
|
||||
if (!is_owner(user_to_edit.id)) {
|
||||
who_is_the_king.off('click').on('click', function() {
|
||||
open_main_user_modal(user_to_edit);
|
||||
});
|
||||
}
|
||||
break;
|
||||
// if user to edit is not an webmaster he cannot be set as a main user
|
||||
default:
|
||||
who_is_the_king
|
||||
.removeClass('princes-of-this-piwigo king-of-this-piwigo')
|
||||
.addClass('royal-court-of-this-piwigo')
|
||||
.attr('title', mainUserUpgradeWebmaster)
|
||||
.tipTip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Main User also the King
|
||||
if (is_owner(user_to_edit.id)) {
|
||||
who_is_the_king
|
||||
.removeClass('princes-of-this-piwigo royal-court-of-this-piwigo can-change')
|
||||
.addClass('king-of-this-piwigo cannot-change')
|
||||
.attr('title', mainUserStr)
|
||||
.tipTip();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------
|
||||
Fill data for setInfo
|
||||
-------------------*/
|
||||
|
@ -1351,7 +1830,7 @@ function select_whole_set() {
|
|||
}
|
||||
|
||||
function update_user_username() {
|
||||
let pop_in_container = $('.UserListPopInContainer');
|
||||
let pop_in_container = $('#UserList');
|
||||
let ajax_data = {
|
||||
pwg_token: pwg_token,
|
||||
user_id: last_user_id
|
||||
|
@ -1374,16 +1853,20 @@ function update_user_username() {
|
|||
$('#UserList .user-property-initials span').html(get_initials(current_users[last_user_index].username));
|
||||
fill_container_user_info($('#user-table-content .user-container').eq(last_user_index), last_user_index);
|
||||
}
|
||||
$("#UserList .update-user-success").fadeIn().delay(1500).fadeOut(2500);
|
||||
$('.user-property-username').show();
|
||||
$('.user-property-username-change').hide();
|
||||
$('.user-property-username-change-input').hide();
|
||||
$('.edit-username-success').fadeIn();
|
||||
$('#close_username_success').on('click', function () {
|
||||
$('.edit-username-success').hide();
|
||||
$('.user-property-username-change-input').show();
|
||||
$('.user-property-username-change').hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function update_user_password() {
|
||||
let pop_in_container = $('.UserListPopInContainer');
|
||||
let pop_in_container = $('#UserList');
|
||||
let ajax_data = {
|
||||
pwg_token: pwg_token,
|
||||
user_id: last_user_id
|
||||
|
@ -1396,9 +1879,22 @@ function update_user_password() {
|
|||
success: (raw_data) => {
|
||||
data = jQuery.parseJSON(raw_data);
|
||||
if (data.stat == 'ok') {
|
||||
$("#UserList .update-user-success").fadeIn().delay(1500).fadeOut(2500);
|
||||
$('.user-property-password').show();
|
||||
$('.user-property-password-change').hide();
|
||||
$('.user-property-password-change-inputs').hide();
|
||||
$('#edit_password_success_change').fadeIn();
|
||||
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
$('#copy_password').on('click', async function() {
|
||||
copyToClipboard(ajax_data['password'])
|
||||
$('#password_msg_success').html(passwordCopied);
|
||||
});
|
||||
};
|
||||
|
||||
$('#close_password_success').on('click', function() {
|
||||
$('.user-property-password-change').hide();
|
||||
$('#edit_password_success_change').hide();
|
||||
$('.user-property-password-change-inputs').show();
|
||||
reset_input_password();
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -1414,6 +1910,16 @@ function update_user_info() {
|
|||
pwg_token: pwg_token,
|
||||
user_id: last_user_id
|
||||
};
|
||||
if (plugins_users_infos_table.length > 0) {
|
||||
const keyCurrentUsers = Object.keys(current_users[last_user_index]);
|
||||
plugins_users_infos_table.forEach((i) => {
|
||||
if (keyCurrentUsers.includes(i.users_table)) {
|
||||
ajax_data[i.users_table] = $('#' + i.content_id).val();
|
||||
} else {
|
||||
console.error(i.users_table, ' doesn\'t exist in USER_INFOS_TABLE');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ajax_data = fill_ajax_data_from_container(ajax_data, pop_in_container);
|
||||
jQuery.ajax({
|
||||
|
@ -1449,6 +1955,16 @@ function update_user_info() {
|
|||
$(".update-user-button i").removeClass("icon-spin6 animate-spin").addClass("icon-floppy");
|
||||
$(".update-user-button").removeClass("unclickable");
|
||||
|
||||
// update plugins
|
||||
if (Object.keys(plugins_get_functions).length > 0) {
|
||||
Object.entries(plugins_set_functions).forEach((f) => {
|
||||
f[1]();
|
||||
});
|
||||
}
|
||||
|
||||
// update who is the king
|
||||
fill_who_is_the_king(result_user, $('#UserList'));
|
||||
|
||||
} else if (data.stat === 'fail') {
|
||||
$("#UserList .update-user-fail").html(data.message);
|
||||
$("#UserList .update-user-fail").fadeIn();
|
||||
|
@ -1575,6 +2091,9 @@ function update_user_list() {
|
|||
last_user_index = uid_index;
|
||||
fill_user_edit(current_users[uid_index]);
|
||||
$("#UserList").fadeIn();
|
||||
$('#tab_properties')[0].scrollIntoView({
|
||||
behavior: 'instant'
|
||||
});
|
||||
});
|
||||
set_selected_to_selection();
|
||||
|
||||
|
@ -1634,6 +2153,7 @@ function add_user() {
|
|||
})
|
||||
$("#AddUserSuccess label span:first").html(user_added_str.replace("%s", ajax_data.username));
|
||||
$("#AddUserSuccess").css("display", "flex");
|
||||
$('.badge-number').html(+$('.badge-number').html() + 1);
|
||||
}
|
||||
else {
|
||||
$("#AddUser .AddUserErrors").html(data.message)
|
||||
|
@ -1657,6 +2177,7 @@ function delete_user(uid) {
|
|||
success:function(data) {
|
||||
close_user_list();
|
||||
update_user_list();
|
||||
$('.badge-number').html(+$('.badge-number').html() - 1);
|
||||
// msg where user was deleted
|
||||
//jQuery('#showAddUser .infos').html('✔ User '+username+' deleted').show();
|
||||
},
|
||||
|
@ -1690,3 +2211,91 @@ function show_filter_infos(nb_filters) {
|
|||
$(".filter-counter").css('display', 'none').html(0);
|
||||
}
|
||||
}
|
||||
|
||||
function send_link_password(email, username, user_id, send_by_mail) {
|
||||
$.ajax({
|
||||
url: "ws.php?format=json",
|
||||
dataType: "json",
|
||||
data: {
|
||||
method: 'pwg.users.generateResetPasswordLink',
|
||||
user_id: user_id,
|
||||
send_by_mail: send_by_mail,
|
||||
pwg_token: pwg_token
|
||||
},
|
||||
success: function(response) {
|
||||
if('ok' === response.stat) {
|
||||
$('#result_send_mail_copy_input').val(response.result.generated_link);
|
||||
if(send_by_mail) {
|
||||
if(response.result.send_by_mail) {
|
||||
$('#result_send_mail').removeClass('update-password-fail icon-red').addClass('update-password-success icon-green');
|
||||
$('#icon_password_msg_result_mail').removeClass('icon-cancel').addClass('icon-ok');
|
||||
$('#password_msg_result_mail').html(sprintf(mailSentAt, username, email));
|
||||
} else {
|
||||
$('#result_send_mail').removeClass('update-password-success icon-green').addClass('update-password-fail icon-red');
|
||||
$('#icon_password_msg_result_mail').removeClass('icon-ok').addClass('icon-cancel');
|
||||
$('#password_msg_result_mail').html(errorMailSent);
|
||||
}
|
||||
$('.user-property-password-choice').hide();
|
||||
$('#edit_password_result_mail').fadeIn();
|
||||
$('#close_password_mail_close').off('click').on('click', function() {
|
||||
reset_password_modals();
|
||||
});
|
||||
} else {
|
||||
$('#result_send_mail_copy').removeClass('update-password-fail icon-red').addClass('update-password-success icon-green');
|
||||
$('#result_send_mail_copy_icon').removeClass('icon-cancel').addClass('icon-ok');
|
||||
$('#result_send_mail_copy_msg').html(copyLinkStr);
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
copyToClipboard(response.result.generated_link);
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(err) {
|
||||
console.log('Error send_link_password :', err);
|
||||
if (!send_by_mail) {
|
||||
$('#result_send_mail_copy').removeClass('update-password-success icon-green').addClass('update-password-fail icon-red');
|
||||
$('#result_send_mail_copy_icon').removeClass('icon-ok').addClass('icon-cancel');
|
||||
$('#result_send_mail_copy_msg').html(errorStr);
|
||||
} else {
|
||||
$('#result_send_mail').removeClass('update-password-success icon-green').addClass('update-password-fail icon-red');
|
||||
$('#icon_password_msg_result_mail').removeClass('icon-ok').addClass('icon-cancel');
|
||||
$('#password_msg_result_mail').html(errorMailSent);
|
||||
$('.user-property-password-choice').hide();
|
||||
$('#edit_password_result_mail').fadeIn();
|
||||
$('#close_password_mail_close').off('click').on('click', function() {
|
||||
reset_password_modals();
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function set_main_user(user_id, new_username) {
|
||||
$.ajax({
|
||||
url: 'ws.php?format=json',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: {
|
||||
method: 'pwg.users.setMainUser',
|
||||
user_id: user_id,
|
||||
pwg_token: pwg_token
|
||||
},
|
||||
success: function(res) {
|
||||
if('ok' === res.stat) {
|
||||
$('#who_is_the_king')
|
||||
.off('click')
|
||||
.removeClass('princes-of-this-piwigo royal-court-of-this-piwigo can-change')
|
||||
.addClass('king-of-this-piwigo cannot-change')
|
||||
.attr('title', mainUserStr)
|
||||
.tipTip();
|
||||
|
||||
owner_id = user_id;
|
||||
owner_username = new_username;
|
||||
set_main_user_success();
|
||||
}
|
||||
},
|
||||
error: function(err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -5617,7 +5617,7 @@ input:checked + .slider:before, input:checked + .slider::after {
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.AddUserErrors, .update-user-fail, .AddAlbumErrors {
|
||||
.AddUserErrors, .update-user-fail, .AddAlbumErrors, .EditUserErrors, .update-password-fail {
|
||||
background-color: #ffcfcf;
|
||||
color: #ff5252;
|
||||
border-left:solid 3px red;
|
||||
|
@ -5632,7 +5632,9 @@ input:checked + .slider:before, input:checked + .slider::after {
|
|||
border-left: 2px solid #00FF00;
|
||||
color: #0a0;
|
||||
}
|
||||
.update-user-success {
|
||||
.update-user-success,
|
||||
.update-password-success,
|
||||
.update-username-success {
|
||||
border-left: 2px solid #00FF00;
|
||||
}
|
||||
#UserList .AddUserBlock p,
|
||||
|
@ -6588,19 +6590,53 @@ color:#FF7B00;
|
|||
color: #4c4c4c
|
||||
}
|
||||
|
||||
.delete-user-button {
|
||||
color:#353535;
|
||||
background-color: #F3F3F3;
|
||||
}
|
||||
|
||||
.slider-bar-wrapper .ui-slider-horizontal{
|
||||
background-color:#e3e3e3;
|
||||
}
|
||||
|
||||
.preferences-container, .properties-container {
|
||||
.edit-user-tab,
|
||||
.guest-edit-user-tab {
|
||||
border-left: solid 1px #ddd;
|
||||
}
|
||||
|
||||
.edit-user-tab-title,
|
||||
.guest-edit-user-tab-title {
|
||||
border-bottom: solid 1px #ddd;
|
||||
}
|
||||
|
||||
.edit-user-tab-title .selected,
|
||||
.edit-user-tab-title .selected:hover,
|
||||
.guest-edit-user-tab-title .selected,
|
||||
.guest-edit-user-tab-title .selected:hover {
|
||||
color: #323232;
|
||||
border-bottom: solid 4px #323232 !important;
|
||||
}
|
||||
|
||||
.edit-user-tab-title p:hover,
|
||||
.guest-edit-user-tab-title p:hover {
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.edit-user-icons .delete-user-button::before,
|
||||
.princes-of-this-piwigo {
|
||||
color: #777777;
|
||||
}
|
||||
|
||||
.edit-user-icons .icon-trash-1:hover::before,
|
||||
.king-of-this-piwigo {
|
||||
color: #ffa646;
|
||||
}
|
||||
|
||||
.royal-court-of-this-piwigo {
|
||||
color: #dbdbdb;
|
||||
}
|
||||
|
||||
.user-property-username-change-content,
|
||||
.user-property-password-change-content,
|
||||
.user-property-main-user-content {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.update-container {
|
||||
border-top:solid 1px #ddd;
|
||||
}
|
||||
|
@ -6612,6 +6648,11 @@ color:#FF7B00;
|
|||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.password-choice-content .unavailable,
|
||||
.password-choice-content .unavailable:hover {
|
||||
color:#CBCBCB !important;
|
||||
}
|
||||
|
||||
/* Activity Tab in user manager */
|
||||
|
||||
.select-user {
|
||||
|
|
|
@ -998,7 +998,8 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
}
|
||||
|
||||
.cat-modify-actions a::after,
|
||||
.cat-modify-actions .toggle-comment-option::after {
|
||||
.cat-modify-actions .toggle-comment-option::after,
|
||||
.mores-plugins::after {
|
||||
background: #111 !important;
|
||||
}
|
||||
|
||||
|
@ -1650,11 +1651,6 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
color: #c1c1c1
|
||||
}
|
||||
|
||||
.delete-user-button {
|
||||
color:#c1c1c1;
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.slider-bar-wrapper .ui-slider-horizontal{
|
||||
background-color:#666;
|
||||
}
|
||||
|
@ -1664,10 +1660,71 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
border: 1px solid #ffa500;
|
||||
}
|
||||
|
||||
.preferences-container, .properties-container {
|
||||
.edit-user-tab,
|
||||
.guest-edit-user-tab {
|
||||
border-left: solid 1px #333;
|
||||
}
|
||||
|
||||
.edit-user-tab-title,
|
||||
.guest-edit-user-tab-title {
|
||||
border-bottom: solid 1px #333;
|
||||
}
|
||||
|
||||
.edit-user-tab-title .selected,
|
||||
.edit-user-tab-title .selected:hover,
|
||||
.guest-edit-user-tab-title .selected,
|
||||
.guest-edit-user-tab-title:hover .selected{
|
||||
color: #c1c1c1;
|
||||
border-bottom: solid 4px #c1c1c1 !important;
|
||||
}
|
||||
|
||||
.edit-user-tab-title p:hover,
|
||||
.guest-edit-user-tab-title p:hover {
|
||||
border-color: #323232;
|
||||
}
|
||||
|
||||
.edit-user-icons .delete-user-button::before,
|
||||
.princes-of-this-piwigo {
|
||||
color: #c1c1c1;
|
||||
}
|
||||
|
||||
.edit-user-icons .icon-trash-1:hover::before,
|
||||
.king-of-this-piwigo {
|
||||
color: #f70;
|
||||
}
|
||||
|
||||
.royal-court-of-this-piwigo {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.user-property-username-change-content,
|
||||
.user-property-password-change-content,
|
||||
.user-property-main-user-content {
|
||||
background-color: #444;
|
||||
}
|
||||
|
||||
.edit-password-success-reset-link,
|
||||
.user-property-input-icon {
|
||||
background-color: #505050 !important;
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
.edit-password-success-ok .icon-button,
|
||||
.user-property-main-user-close .icon-button {
|
||||
background-color: #333 !important;
|
||||
}
|
||||
|
||||
.edit-password-success-ok .icon-button:hover,
|
||||
.user-property-main-user-close .icon-button:hover {
|
||||
color: #c1c1c1 !important;
|
||||
}
|
||||
|
||||
.main-user-proceed,
|
||||
.main-user-rewrite,
|
||||
.main-user-validate {
|
||||
color: #A4A4A4 !important;
|
||||
}
|
||||
|
||||
.update-container {
|
||||
border-top:solid 1px #333;
|
||||
}
|
||||
|
@ -1679,6 +1736,16 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
background-color: #333;
|
||||
}
|
||||
|
||||
.password-choice-content .unavailable,
|
||||
.password-choice-content .unavailable:hover {
|
||||
color:#777 !important;
|
||||
}
|
||||
|
||||
.password-choice-content .head-button-2,
|
||||
.password-choice-content .head-button-2:hover {
|
||||
color: #CBCBCB;
|
||||
}
|
||||
|
||||
.lineView .user-container-initials-wrapper > span {
|
||||
height: 31px!important;
|
||||
width: 31px!important;
|
||||
|
@ -1801,7 +1868,7 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
background-color: #343434;
|
||||
}
|
||||
|
||||
.AddUserErrors, .update-user-fail {
|
||||
.AddUserErrors, .update-user-fail, .EditUserErrors, .update-password-fail {
|
||||
background-color: #f22;;
|
||||
color: #ffd5dc;
|
||||
border-left:solid 3px #f22;
|
||||
|
@ -1834,7 +1901,9 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
|
|||
color: #a9f6e3;
|
||||
}
|
||||
|
||||
.update-user-success {
|
||||
.update-user-success,
|
||||
.update-password-success,
|
||||
.update-username-success {
|
||||
border-left: 2px solid #a9f6e3;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,15 @@ SELECT
|
|||
$password_protected_users = array_merge($password_protected_users, array_diff($admin_ids, array($user['id'])));
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
username
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE id = '.$conf['webmaster_id'].'
|
||||
;';
|
||||
|
||||
$owner_username = query2array($query, null, 'username');
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'U_HISTORY' => get_root_url().'admin.php?page=history&filter_user_id=',
|
||||
|
@ -117,7 +126,8 @@ $template->assign(
|
|||
'filter_group' => (isset($_GET['group']) ? $_GET['group'] : null),
|
||||
'connected_user' => $user["id"],
|
||||
'connected_user_status' => $user['status'],
|
||||
'owner' => $conf['webmaster_id']
|
||||
'owner' => $conf['webmaster_id'],
|
||||
'owner_username' => $owner_username[0]
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -184,6 +194,23 @@ else
|
|||
//Show 10 users by default
|
||||
$template->assign('pagination', userprefs_get_param('user-manager-pagination', 10));
|
||||
}
|
||||
|
||||
function webmaster_id_is_local()
|
||||
{
|
||||
$conf = array();
|
||||
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
|
||||
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
|
||||
if (isset($conf['local_dir_site']))
|
||||
{
|
||||
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
|
||||
}
|
||||
return $conf['webmaster_id'] ?? false;
|
||||
}
|
||||
|
||||
if (webmaster_id_is_local())
|
||||
{
|
||||
$page['warnings'][] = l10n('You have specified <i>$conf[\'webmaster_id\']</i> in your local configuration file, this parameter in deprecated, please remove it!');
|
||||
}
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | html code display |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -579,9 +579,6 @@ $conf['default_user_id'] = $conf['guest_id'];
|
|||
// if language isn't available PHPWG_DEFAULT_LANGUAGE is used as previously
|
||||
$conf['browser_language'] = true;
|
||||
|
||||
// webmaster_id : webmaster'id.
|
||||
$conf['webmaster_id'] = 1;
|
||||
|
||||
// does the guest have access ?
|
||||
// (not a security feature, set your categories "private" too)
|
||||
// If false it'll be redirected from index.php to identification.php
|
||||
|
|
|
@ -1004,6 +1004,43 @@ function pwg_send_mail_test($success, $mail, $args)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate content mail for reset password
|
||||
*
|
||||
* Return the content mail to send
|
||||
* @since 15
|
||||
* @param string $username
|
||||
* @param string $reset_password_link
|
||||
* @param string $gallery_title
|
||||
* @return string mail content
|
||||
*/
|
||||
function pwg_generate_reset_password_mail($username, $reset_password_link, $gallery_title)
|
||||
{
|
||||
set_make_full_url();
|
||||
|
||||
$message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n";
|
||||
$message.= l10n(
|
||||
'Username "%s" on gallery %s',
|
||||
$username,
|
||||
get_gallery_home_url()
|
||||
);
|
||||
$message.= "\r\n\r\n";
|
||||
$message.= l10n('To reset your password, visit the following address:') . "\r\n";
|
||||
$message.= $reset_password_link;
|
||||
$message.= "\r\n\r\n";
|
||||
$message.= l10n('If this was a mistake, just ignore this email and nothing will happen.')."\r\n";
|
||||
|
||||
unset_make_full_url();
|
||||
|
||||
$message = trigger_change('render_lost_password_mail_content', $message);
|
||||
|
||||
return array(
|
||||
'subject' => '['.$gallery_title.'] '.l10n('Password Reset'),
|
||||
'content' => $message,
|
||||
'email_format' => 'text/plain',
|
||||
);
|
||||
}
|
||||
|
||||
trigger_notify('functions_mail_included');
|
||||
|
||||
?>
|
||||
|
|
|
@ -1733,6 +1733,41 @@ function deactivate_password_reset_key($user_id)
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate reset password link
|
||||
*
|
||||
* @since 15
|
||||
* @param int $user_id
|
||||
* @param string $user_email
|
||||
* @return array activation_key and reset password link
|
||||
*/
|
||||
function generate_reset_password_link($user_id)
|
||||
{
|
||||
$activation_key = generate_key(20);
|
||||
|
||||
list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)'));
|
||||
|
||||
single_update(
|
||||
USER_INFOS_TABLE,
|
||||
array(
|
||||
'activation_key' => pwg_password_hash($activation_key),
|
||||
'activation_key_expire' => $expire,
|
||||
),
|
||||
array('user_id' => $user_id)
|
||||
);
|
||||
|
||||
set_make_full_url();
|
||||
|
||||
$reset_password_link = get_root_url().'password.php?key='.$activation_key;
|
||||
|
||||
unset_make_full_url();
|
||||
|
||||
return array(
|
||||
'activation_key' => $activation_key,
|
||||
'reset_password_link' => $reset_password_link,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last visit (datetime) of a user, based on history table
|
||||
*
|
||||
|
|
|
@ -961,4 +961,108 @@ SELECT
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API method
|
||||
* Returns the reset password link of the current user
|
||||
* @since 15
|
||||
* @param mixed[] $params
|
||||
* @option int user_id
|
||||
* @option string pwg_token
|
||||
* @option boolean send_by_mail
|
||||
*/
|
||||
function ws_users_generate_reset_password_link($params, &$service)
|
||||
{
|
||||
global $user, $conf;
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
|
||||
if (get_pwg_token() != $params['pwg_token'])
|
||||
{
|
||||
return new PwgError(403, 'Invalid security token');
|
||||
}
|
||||
|
||||
// check if user exist
|
||||
if (get_username($params['user_id']) === false)
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'This user does not exist.');
|
||||
}
|
||||
|
||||
$user_lost = getuserdata($params['user_id']);
|
||||
|
||||
// Cannot perform this action for a guest or generic user
|
||||
if (is_a_guest($user_lost['status']) or is_generic($user_lost['status']))
|
||||
{
|
||||
return new PwgError(403, 'Password reset is not allowed for this user');
|
||||
}
|
||||
|
||||
// Only webmaster can perform this action for another webmaster
|
||||
if ('admin' === $user['status'] && 'webmaster' === $user_lost['status'])
|
||||
{
|
||||
return new PwgError(403, 'You cannot perform this action');
|
||||
}
|
||||
|
||||
$generate_link = generate_reset_password_link($params['user_id']);
|
||||
$send_by_mail_response = null;
|
||||
|
||||
if ($params['send_by_mail'] and !empty($user_lost['email']))
|
||||
{
|
||||
$email_params = pwg_generate_reset_password_mail($user_lost['username'], $generate_link['reset_password_link'], $conf['gallery_title']);
|
||||
// Here we remove the display of errors because they prevent the response from being parsed
|
||||
if (@pwg_mail($user_lost['email'], $email_params))
|
||||
{
|
||||
$send_by_mail_response = 'Mail sent at : ' . $user_lost['email'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$send_by_mail_response = false;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'generated_link' => $generate_link['reset_password_link'],
|
||||
'send_by_mail' => $send_by_mail_response,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API method
|
||||
* Set a user as the main user
|
||||
* @since 15
|
||||
* @param mixed[] $params
|
||||
* @option int user_id
|
||||
* @option string pwg_token
|
||||
*/
|
||||
function ws_set_main_user($params, &$service)
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
// check if not webmaster
|
||||
if (!is_webmaster())
|
||||
{
|
||||
return new PwgError(403, 'You cannot perform this action');
|
||||
}
|
||||
|
||||
//check pwg_token
|
||||
if (get_pwg_token() != $params['pwg_token'])
|
||||
{
|
||||
return new PwgError(403, 'Invalid security token');
|
||||
}
|
||||
|
||||
// checl if user exist
|
||||
if (get_username($params['user_id']) === false)
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'This user does not exist.');
|
||||
}
|
||||
|
||||
$new_main_user = getuserdata($params['user_id']);
|
||||
|
||||
// check if the user to set as main user is not webmaster
|
||||
if ('webmaster' !== $new_main_user['status'])
|
||||
{
|
||||
return new PwgError(403, 'This user cannot become a main user because he is not a webmaster.');
|
||||
}
|
||||
|
||||
conf_update_param('webmaster_id', $params['user_id']);
|
||||
return 'The main user has been changed.';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -387,7 +387,7 @@ INSERT INTO '.$prefixeTable.'config (param,value,comment)
|
|||
// webmaster admin user
|
||||
$inserts = array(
|
||||
array(
|
||||
'id' => 1,
|
||||
'id' => 1, // must be the same value as webmaster_id in config.sql
|
||||
'username' => $admin_name,
|
||||
'password' => md5($admin_pass1),
|
||||
'mail_address' => $admin_mail,
|
||||
|
|
|
@ -78,3 +78,4 @@ INSERT INTO piwigo_config (param,value) VALUES ('show_mobile_app_banner_in_galle
|
|||
INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_button','false');
|
||||
INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_action','true');
|
||||
INSERT INTO piwigo_config (param,value) VALUES ('upload_detect_duplicate','true');
|
||||
INSERT INTO piwigo_config (param,value) VALUES ('webmaster_id','1');
|
||||
|
|
22
install/db/171-database.php
Normal file
22
install/db/171-database.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This file is part of Piwigo. |
|
||||
// | |
|
||||
// | For copyright and license information, please view the COPYING.txt |
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH'))
|
||||
{
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
$upgrade_description = 'convert file configuration setting webmaster_id to database';
|
||||
|
||||
// If the webmaster_id has been modified, it must be present in local/config/config.inc.php
|
||||
// so we retrieve it and insert it into the database.
|
||||
conf_update_param('webmaster_id', $conf['webmaster_id'] ?? 1);
|
||||
|
||||
echo "\n".$upgrade_description."\n";
|
||||
|
||||
?>
|
75
password.php
75
password.php
|
@ -76,44 +76,11 @@ function process_password_request()
|
|||
return false;
|
||||
}
|
||||
|
||||
$activation_key = generate_key(20);
|
||||
|
||||
list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)'));
|
||||
|
||||
single_update(
|
||||
USER_INFOS_TABLE,
|
||||
array(
|
||||
'activation_key' => pwg_password_hash($activation_key),
|
||||
'activation_key_expire' => $expire,
|
||||
),
|
||||
array('user_id' => $user_id)
|
||||
);
|
||||
$generate_link = generate_reset_password_link($user_id);
|
||||
|
||||
$userdata['activation_key'] = $activation_key;
|
||||
$userdata['activation_key'] = $generate_link['activation_key'];
|
||||
|
||||
set_make_full_url();
|
||||
|
||||
$message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n";
|
||||
$message.= l10n(
|
||||
'Username "%s" on gallery %s',
|
||||
$userdata['username'],
|
||||
get_gallery_home_url()
|
||||
);
|
||||
$message.= "\r\n\r\n";
|
||||
$message.= l10n('To reset your password, visit the following address:') . "\r\n";
|
||||
$message.= get_root_url().'password.php?key='.$activation_key.'-'.urlencode($userdata['email']);
|
||||
$message.= "\r\n\r\n";
|
||||
$message.= l10n('If this was a mistake, just ignore this email and nothing will happen.')."\r\n";
|
||||
|
||||
unset_make_full_url();
|
||||
|
||||
$message = trigger_change('render_lost_password_mail_content', $message);
|
||||
|
||||
$email_params = array(
|
||||
'subject' => '['.$conf['gallery_title'].'] '.l10n('Password Reset'),
|
||||
'content' => $message,
|
||||
'email_format' => 'text/plain',
|
||||
);
|
||||
$email_params = pwg_generate_reset_password_mail($userdata['username'], $generate_link['reset_password_link'], $conf['gallery_title']);
|
||||
|
||||
if (pwg_mail($userdata['email'], $email_params))
|
||||
{
|
||||
|
@ -137,54 +104,27 @@ function check_password_reset_key($reset_key)
|
|||
{
|
||||
global $page, $conf;
|
||||
|
||||
list($key, $email) = explode('-', $reset_key, 2);
|
||||
|
||||
$key = $reset_key;
|
||||
if (!preg_match('/^[a-z0-9]{20}$/i', $key))
|
||||
{
|
||||
$page['errors'][] = l10n('Invalid key');
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_ids = array();
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
'.$conf['user_fields']['id'].' AS id
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['email'].' = \''.pwg_db_real_escape_string($email).'\'
|
||||
;';
|
||||
$user_ids = query2array($query, null, 'id');
|
||||
|
||||
if (count($user_ids) == 0)
|
||||
{
|
||||
$page['errors'][] = l10n('Invalid username or email');
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_id = null;
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
user_id,
|
||||
status,
|
||||
activation_key,
|
||||
activation_key_expire,
|
||||
NOW() AS dbnow
|
||||
activation_key
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE user_id IN ('.implode(',', $user_ids).')
|
||||
WHERE activation_key IS NOT NULL
|
||||
AND activation_key_expire > NOW()
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (pwg_password_verify($key, $row['activation_key']))
|
||||
{
|
||||
if (strtotime($row['dbnow']) > strtotime($row['activation_key_expire']))
|
||||
{
|
||||
// key has expired
|
||||
$page['errors'][] = l10n('Invalid key');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_a_guest($row['status']) or is_generic($row['status']))
|
||||
{
|
||||
$page['errors'][] = l10n('Password reset is not allowed for this user');
|
||||
|
@ -192,6 +132,7 @@ SELECT
|
|||
}
|
||||
|
||||
$user_id = $row['user_id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
36
ws.php
36
ws.php
|
@ -1453,6 +1453,42 @@ enabled_high, registration_date, registration_date_string, registration_date_sin
|
|||
'',
|
||||
$ws_functions_root . 'pwg.images.php'
|
||||
);
|
||||
|
||||
$service->addMethod(
|
||||
'pwg.users.generateResetPasswordLink',
|
||||
'ws_users_generate_reset_password_link',
|
||||
array(
|
||||
'user_id' => array(
|
||||
'type'=>WS_TYPE_ID
|
||||
),
|
||||
'pwg_token' => array(),
|
||||
'send_by_mail' => array(
|
||||
'flags' => WS_PARAM_OPTIONAL,
|
||||
'type' => WS_TYPE_BOOL,
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
'Return the reset password link <br />
|
||||
(Only webmaster can perform this action for another webmaster)',
|
||||
$ws_functions_root . 'pwg.users.php',
|
||||
array('admin_only'=>true)
|
||||
);
|
||||
|
||||
$service->addMethod(
|
||||
'pwg.users.setMainUser',
|
||||
'ws_set_main_user',
|
||||
array(
|
||||
'user_id' => array(
|
||||
'type'=>WS_TYPE_ID
|
||||
),
|
||||
'pwg_token' => array(),
|
||||
),
|
||||
'Update the main user (owner) <br />
|
||||
- To be the main user, the user must have the status "webmaster".<br />
|
||||
- Only a webmaster can perform this action',
|
||||
$ws_functions_root . 'pwg.users.php',
|
||||
array('admin_only'=>true, 'post_only'=>true)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue