From 06b9e82b6ed182c89a6bd5ad7aa860f574d745e5 Mon Sep 17 00:00:00 2001 From: nilsteampassnet Date: Tue, 4 Sep 2018 21:35:19 +0200 Subject: [PATCH] 2.1.27 Fix for #2326 --- changelog.txt | 2 + includes/config/include.php | 2 +- includes/js/clipboard/clipboard.min.js | 6 +-- items.load.php | 71 ++++++++++++-------------- items.php | 9 +++- load.php | 17 ++++++ sources/items.queries.php | 8 +-- ssh.php | 2 +- 8 files changed, 68 insertions(+), 49 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6ef52c112..a753ca253 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,6 @@ 2.1.27 +22/ + #2326 link copy doesn't work corectly 21/ #2398 User unable to change their own password from profile window diff --git a/includes/config/include.php b/includes/config/include.php index 6b15efa37..07b0aa137 100644 --- a/includes/config/include.php +++ b/includes/config/include.php @@ -12,7 +12,7 @@ global $SETTINGS, $languagesList, $SETTINGS_EXT; $SETTINGS_EXT['version'] = "2.1.27"; -$SETTINGS_EXT['version_full'] = $SETTINGS_EXT['version'].".21"; +$SETTINGS_EXT['version_full'] = $SETTINGS_EXT['version'].".22"; $SETTINGS_EXT['tool_name'] = "TeamPass"; $SETTINGS_EXT['one_day_seconds'] = 86400; $SETTINGS_EXT['one_week_seconds'] = 604800; diff --git a/includes/js/clipboard/clipboard.min.js b/includes/js/clipboard/clipboard.min.js index 580433f1d..b00ee5153 100644 --- a/includes/js/clipboard/clipboard.min.js +++ b/includes/js/clipboard/clipboard.min.js @@ -1,7 +1,7 @@ /*! - * clipboard.js v1.5.12 + * clipboard.js v2.0.0 * https://zenorocha.github.io/clipboard.js - * + * * Licensed MIT © Zeno Rocha */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ao;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;a>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,o.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,o.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=a})},function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return r(t,e,n);if(c.nodeList(t))return i(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function r(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function i(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return u(document.body,t,e,n)}var c=n(6),u=n(5);t.exports=o},function(t,e){function n(){}n.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){r.off(t,o),e.apply(n,arguments)}var r=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;for(o;o0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===d(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,f.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return u("action",t)}},{key:"defaultTarget",value:function(t){var e=u("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return u("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),e}(s.default);t.exports=p})},function(t,e){function n(t,e){for(;t&&t.nodeType!==o;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var o=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=n},function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function r(t,e,n,r,i){return"function"==typeof t.addEventListener?o.apply(null,arguments):"function"==typeof n?o.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return o(t,e,n,r,i)}))}function i(t,e,n,o){return function(n){n.delegateTarget=a(n.target,e),n.delegateTarget&&o.call(t,n)}}var a=n(4);t.exports=r},function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var n=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e){function n(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),r=document.createRange();r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r),e=o.toString()}return e}t.exports=n}])}); \ No newline at end of file diff --git a/items.load.php b/items.load.php index 3494ba919..50b9d9910 100755 --- a/items.load.php +++ b/items.load.php @@ -1305,7 +1305,7 @@ function(data) { //Prepare clipboard copies if ($('#edit_pw1').val() !== "") { - new Clipboard("#menu_button_copy_pw, #button_quick_pw_copy", { + new ClipboardJS("#menu_button_copy_pw, #button_quick_pw_copy", { text: function() { return unsanitizeString($('#edit_pw1').val()); } @@ -1316,7 +1316,7 @@ function(data) { $("#button_quick_pw_copy").addClass("hidden"); } if ($('#edit_item_login').val() != "") { - var clipboard_elogin = new Clipboard("#menu_button_copy_login, #button_quick_login_copy", { + var clipboard_elogin = new ClipboardJS("#menu_button_copy_login, #button_quick_login_copy", { text: function() { return unsanitizeString($('#edit_item_login').val()); } @@ -1830,7 +1830,7 @@ function(data_raw) { //Prepare clipboard copies if (data.pw != "") { - var clipboard_pw = new Clipboard("#menu_button_copy_pw, #button_quick_pw_copy", { + var clipboard_pw = new ClipboardJS("#menu_button_copy_pw, #button_quick_pw_copy", { text: function() { return (unsanitizeString(data.pw)); } @@ -1851,7 +1851,7 @@ function(data_raw) { $("#button_quick_pw_copy").addClass("hidden"); } if (data.login != "") { - var clipboard_login = new Clipboard("#menu_button_copy_login, #button_quick_login_copy", { + var clipboard_login = new ClipboardJS("#menu_button_copy_login, #button_quick_login_copy", { text: function() { return (data.login); } @@ -1867,7 +1867,7 @@ function(data_raw) { } // #525 if (data.url != "") { - var clipboard_url = new Clipboard("#menu_button_copy_url", { + var clipboard_url = new ClipboardJS("#menu_button_copy_url", { text: function() { return unsanitizeString(data.url); } @@ -1880,7 +1880,7 @@ function(data_raw) { } //prepare link to clipboard - var clipboard_link = new Clipboard("#menu_button_copy_link", { + var clipboard_link = new ClipboardJS("#menu_button_copy_link", { text: function() { return ""+"/index.php?page=items&group="+data.folder+"&id="+data.id; } @@ -2839,16 +2839,11 @@ function openReasonToAccess() { //########### $(function() { - var clear_tp_clipboard = new Clipboard("#but_empty_clipboard", { + var clear_tp_clipboard = new ClipboardJS("#but_empty_clipboard", { text: function() { return "cleared"; } }); - clear_tp_clipboard.on('success', function(e) { - $("#message_box").html("super").show().fadeOut(1000); - - e.clearSelection(); - }); $.ajaxSetup({ error: function(jqXHR, exception) { @@ -3967,6 +3962,22 @@ function(data) { }); //<= + + // => OTV LINK + $("#dialog_otv").dialog({ + bgiframe: true, + modal: true, + height:300, + autoOpen: false, + minWidth:750, + title: "", + close: function(event,ui) { + $(this).dialog('close'); + } + }); + //<= + + // => ATTACHMENTS INIT var uploader_attachments = new plupload.Uploader({ runtimes : "html5,flash,silverlight,html4", @@ -4644,13 +4655,13 @@ function proceed_list_update(stop_proceeding) $("#items_list_loader").addClass("hidden"); // prepare clipboard items - clipboard = new Clipboard('.mini_login'); + clipboard = new ClipboardJS('.mini_login'); clipboard.on('success', function(e) { $("#message_box").html("").show().fadeOut(1000); e.clearSelection(); }); - clipboard = new Clipboard('.mini_pw'); + clipboard = new ClipboardJS('.mini_pw'); clipboard.on('success', function(e) { $("#message_box").html("").show().fadeOut(1000); itemLog( @@ -4832,6 +4843,7 @@ function(data) { } + /* * Launch the redirection to OTV page */ @@ -4851,30 +4863,15 @@ function prepareOneTimeView() function(data) { //check if format error if (data.error == "") { - $("#div_dialog_message").dialog({ - height:300, - minWidth:750, - close: function(event,ui) { - $("#div_dialog_message_text").html(''); - $(this).dialog('close'); - } - }); - $("#div_dialog_message").dialog('open'); - $("#div_dialog_message_text").html(data.url+ - '
' - ); - - var clipboard = new Clipboard("#" + data.element_id, { - text: function(trigger) { - return $('#' + data.element_id).data('clipboard-text'); - } - }); - clipboard.on('success', function(e) { - $("#show_otv_copied").html("").show().fadeOut(2000); - e.clearSelection(); - }); + var str = ""; + var html = str.replace("#URL#", data.url + ''); + html = html.replace("#DAY#", data.date); + $('#dialog_otv_text').html(html); + + $('.tip').tooltipster({multiple: true}); - $(".tip").tooltipster({multiple: true}); + $('#otv-url').val(data.url); + $("#dialog_otv").dialog('open'); } else { $("#item_history_log_error").html(data.error).show(); } diff --git a/items.php b/items.php index acd168f36..0dd27c99f 100644 --- a/items.php +++ b/items.php @@ -146,7 +146,8 @@ -'; + +'; echo '
'; @@ -1083,4 +1084,10 @@
'; +// Alert BOX +echo ' + '; + require_once 'items.load.php'; diff --git a/load.php b/load.php index f627421ad..49dccacc4 100644 --- a/load.php +++ b/load.php @@ -1481,6 +1481,23 @@ function(data) { } $htmlHeaders .= ' + + var clipboardOTV = new ClipboardJS(".otv-link", { + container: document.getElementById("dialog_otv"), + text: function(trigger) { + return $("#otv-url").val(); + } + }); + + clipboardOTV.on("success", function(e) { + $("#dialog_otv").dialog("close"); + $("#message_box") + .html("'.addslashes($LANG['url_copied_clipboard']).'") + .show() + .fadeOut(1000); + e.clearSelection(); + }); + setTimeout(function() { NProgress.done(); $(".fade").removeClass("out"); }, 1000); });'; diff --git a/sources/items.queries.php b/sources/items.queries.php index 198ab1308..dd35c2c37 100644 --- a/sources/items.queries.php +++ b/sources/items.queries.php @@ -4026,12 +4026,8 @@ echo json_encode( array( "error" => "", - "url" => str_replace( - array("#URL#", "#DAY#"), - array(''.$url.' ', $exp_date), - $LANG['one_time_view_item_url_box'] - ), - 'element_id' => $element_id + 'url' => $url, + 'date' => $exp_date, ) ); break; diff --git a/ssh.php b/ssh.php index 4cfbf9d15..63c0f6027 100644 --- a/ssh.php +++ b/ssh.php @@ -208,7 +208,7 @@ function(data) { $('#edit_pw1').val($('#ausp_pwd').val()); $("#hid_pw").val($('#ausp_pwd').val()); // change quick password - new Clipboard("#menu_button_copy_pw, #button_quick_pw_copy", { + new ClipboardJS("#menu_button_copy_pw, #button_quick_pw_copy", { text: function() { return unsanitizeString($('#edit_pw1').val()); }