소스 검색

Added confirm disable plugin
add error pages

causefx 8 년 전
부모
커밋
261f0beec1
5개의 변경된 파일110개의 추가작업 그리고 23개의 파일을 삭제
  1. 9 8
      api/plugins/php-mailer.php
  2. 7 0
      css/colors/blue-dark.css
  3. 1 0
      index.php
  4. 35 15
      js/custom.js
  5. 58 0
      js/functions.js

+ 9 - 8
api/plugins/php-mailer.php

@@ -23,12 +23,13 @@ function phpmSendTestEmail(){
 	try {
 		$mail = new PHPMailer\PHPMailer\PHPMailer(true);
 		$mail->isSMTP();
+		//$mail->SMTPDebug = 3;
 		$mail->Host = $GLOBALS['PHPMAILER-smtpHost'];
+		$mail->Port = $GLOBALS['PHPMAILER-smtpHostPort'];
+		$mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
 		$mail->SMTPAuth = $GLOBALS['PHPMAILER-smtpHostAuth'];
 		$mail->Username = $GLOBALS['PHPMAILER-smtpHostUsername'];
 		$mail->Password = decrypt($GLOBALS['PHPMAILER-smtpHostPassword']);
-		$mail->SMTPSecure = $GLOBALS['PHPMAILER-smtpHostType'];
-		$mail->Port = $GLOBALS['PHPMAILER-smtpHostPort'];
 		$mail->setFrom($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
 		$mail->addReplyTo($GLOBALS['PHPMAILER-smtpHostSenderEmail'], $GLOBALS['PHPMAILER-smtpHostSenderName']);
 		$mail->isHTML(true);
@@ -102,6 +103,12 @@ function phpmGetSettings(){
 			'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
 			'placeholder' => 'i.e. same as username'
 		),
+		array(
+			'type' => 'switch',
+			'name' => 'PHPMAILER-smtpHostAuth',
+			'label' => 'Authentication',
+			'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
+		),
 		array(
 			'type' => 'select',
 			'name' => 'PHPMAILER-smtpHostType',
@@ -122,12 +129,6 @@ function phpmGetSettings(){
 				)
 			)
 		),
-		array(
-			'type' => 'switch',
-			'name' => 'PHPMAILER-smtpHostAuth',
-			'label' => 'Authentication',
-			'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
-		),
 		array(
 			'type' => 'button',
 			'label' => 'Send Test',

+ 7 - 0
css/colors/blue-dark.css

@@ -420,6 +420,13 @@ body.stop-scrolling {
 	background: #707cd2;
 	border-color: #707cd2;
 }
+.error-page {
+  width: 100%;
+  background: #1b1a1a;
+  height: 100%;
+  position: fixed;
+  display: none;
+}
 .table-hover>tbody>tr:hover, .table-striped>tbody>tr:nth-of-type(odd), .table>tbody>tr.active>td, .table>tbody>tr.active>th, .table>tbody>tr>td.active, .table>tbody>tr>th.active, .table>tfoot>tr.active>td, .table>tfoot>tr.active>th, .table>tfoot>tr>td.active, .table>tfoot>tr>th.active, .table>thead>tr.active>td, .table>thead>tr.active>th, .table>thead>tr>td.active, .table>thead>tr>th.active {
   background-color: #1f1f1f!important;
 }

+ 1 - 0
index.php

@@ -86,6 +86,7 @@
 		<!-- ============================================================== -->
 		<!-- Page Content -->
 		<!-- ============================================================== -->
+		<div class="error-page"></div>
 		<div class="login-area hidden"></div>
 		<div class="p-0" id="page-wrapper">
 			<div class="organizr-area"></div>

+ 35 - 15
js/custom.js

@@ -1051,22 +1051,42 @@ $(document).on('click', '.enablePlugin', function() {
 });
 // DISABLE PLUGIN
 $(document).on('click', '.disablePlugin', function() {
-	var post = {
-        action:'disable',
-        api:'api/?v1/settings/plugins/list',
-        name:$(this).attr('data-plugin-name'),
-        configName:$(this).attr('data-config-name'),
-        messageTitle:'',
-        messageBody:'Disabling '+$(this).attr('data-plugin-name'),
-        error:'Organizr Function: API Connection Failed'
-    };
-    //$('#customize-appearance-reload').removeClass('hidden');
-	var callbacks = $.Callbacks();
-    //callbacks.add( buildCustomizeAppearance );
-    settingsAPI(post,callbacks);
-    ajaxloader(".content-wrap","in");
-    setTimeout(function(){ buildPlugins();ajaxloader(); }, 3000);
+    var plugin = $(this);
+    swal({
+        title: window.lang.translate('Disable')+' '+plugin.attr("data-plugin-name")+'?',
+        type: "warning",
+        showCancelButton: true,
+        confirmButtonColor: "#DD6B55",
+        confirmButtonText: window.lang.translate('Yes'),
+        cancelButtonText: window.lang.translate('No'),
+        closeOnConfirm: true,
+        closeOnCancel: true
+    }, function(isConfirm){
+        if (isConfirm) {
+            //Create POST Array
+            var post = {
+                action:'disable',
+                api:'api/?v1/settings/plugins/list',
+                name:plugin.attr('data-plugin-name'),
+                configName:plugin.attr('data-config-name'),
+                messageTitle:'',
+                messageBody:'Disabling '+plugin.attr('data-plugin-name'),
+                error:'Organizr Function: API Connection Failed'
+            };
+            //$('#customize-appearance-reload').removeClass('hidden');
+        	var callbacks = $.Callbacks();
+            //callbacks.add( buildCustomizeAppearance );
+            settingsAPI(post,callbacks);
+            ajaxloader(".content-wrap","in");
+            setTimeout(function(){ buildPlugins();ajaxloader(); }, 3000);
+        }
+    });
+
+});
 
+$(document).on("click", ".closeErrorPage", function () {
+    $('.error-page').html('');
+    $('.error-page').fadeOut();
 });
 /* ===== Open-Close Right Sidebar ===== */
 

+ 58 - 0
js/functions.js

@@ -1635,6 +1635,63 @@ function checkMessage(){
 		messageSingle(window.lang.translate(message[0]),window.lang.translate(message[1]),'bottom-right','#FFF',message[2],'10000');
 	}
 }
+function setError(error){
+	local('set','error',error);
+	var url = window.location.href.split('?')[0];
+	url = url.split('#')[0];
+	window.location.href = url+'?error';
+}
+function buildErrorPage(error){
+	var description = '';
+	var message = '';
+	var color = '';
+	switch (error) {
+		case '401':
+			description = 'Unauthorized';
+			message = 'Look, you dont belong here';
+			color = 'danger';
+			break;
+		case '404':
+			description = 'Not Found';
+			message = 'I think I lost it...';
+			color = 'primary';
+			break;
+		default:
+			description = 'Something happened';
+			message = 'But I dont know what';
+			color = 'muted';
+	}
+	return `
+	<div class="error-box">
+		<div class="error-body text-center">
+			<h1 class="text-`+color+`">`+error+`</h1>
+			<h3 class="text-uppercase">`+description+`</h3>
+			<p class="text-muted m-t-30 m-b-30" lang="en">`+message+`</p>
+			<a href="javascript:void(0);" class="btn btn-`+color+` btn-rounded waves-effect waves-light m-b-40 closeErrorPage" lang="en">OK</a>
+		</div>
+		<footer class="footer text-center">Organizr</footer>
+	</div>
+	`;
+}
+function errorPage(error=null){
+	if(error){
+		local('set','error',error);
+	}
+	var urlParams = new URLSearchParams(window.location.search);
+	if(urlParams.has('error')){
+		if(urlParams.get('error')){
+			local('set','error',urlParams.get('error'));
+		}
+	}
+	if(local('get', 'error')){
+		//show error page
+		$('.error-page').html(buildErrorPage(local('get', 'error')));
+		$('.error-page').fadeIn();
+		local('remove', 'error');
+		window.history.pushState({}, document.title, "/" );
+	}
+
+}
 function launch(){
 	organizrConnect('api/?v1/launch_organizr').success(function (data) {
 		var json = JSON.parse(data);
@@ -1677,4 +1734,5 @@ function launch(){
 		}
 	});
 	checkMessage();
+	errorPage();
 }