causefx 8 лет назад
Родитель
Сommit
43674ba2f3
4 измененных файлов с 90 добавлено и 94 удалено
  1. 15 0
      api/functions/organizr-functions.php
  2. 1 28
      api/plugins/js/php-mailer.js
  3. 73 65
      api/plugins/php-mailer.php
  4. 1 1
      js/functions.js

+ 15 - 0
api/functions/organizr-functions.php

@@ -154,6 +154,21 @@ function getSettingsMain(){
     			'text' => 'Retrieve'
     		)
         ),
+        'API' => array(
+            array(
+    			'type' => 'input',
+    			'name' => 'organizrAPI',
+    			'label' => 'Organizr API',
+    			'value' => $GLOBALS['organizrAPI']
+    		),
+    		array(
+    			'type' => 'button',
+    			'label' => 'Generate New API Key',
+    			'class' => 'newAPIKey',
+    			'icon' => 'fa fa-paper-plane',
+    			'text' => 'Generate'
+    		)
+        ),
         'Authentication' => array(
     		array(
     			'type' => 'select',

+ 1 - 28
api/plugins/js/php-mailer.js

@@ -19,33 +19,6 @@ $(document).on('click', '#PHPMAILER-settings-button', function() {
 */
 
 // FUNCTIONS
-function phpmBuildSettingsItems(array){
-    if (Array.isArray(array)) {
-        var preRow = `
-            <!-- FORM GROUP -->
-            <h3 class="box-title" lang="en">Mail Settings</h3>
-            <hr class="m-t-0 m-b-40">
-            <div class="row">
-        `;
-        var mailItems = preRow;
-        $.each(array, function(i,v) {
-            mailItems += `
-                <!-- INPUT BOX -->
-                <div class="col-md-6 p-b-10">
-                    <div class="form-group">
-                        <label class="control-label col-md-3" lang="en">`+v.label+`</label>
-                        <div class="col-md-9">
-                            `+buildFormItem(v)+`
-                        </div>
-                    </div>
-                </div>
-                <!--/ INPUT BOX -->
-            `;
-        });
-        mailItems += '</div>';
-    }
-    return mailItems;
-}
 
 // EVENTS and LISTENERS
 // CHANGE CUSTOMIZE Options
@@ -89,7 +62,7 @@ $(document).on('click', '#PHPMAILER-settings-button', function() {
     ajaxloader(".content-wrap","in");
     organizrAPI('POST','api/?v1/plugin',post).success(function(data) {
         var response = JSON.parse(data);
-        $('#PHPMAILER-settings-items').html(phpmBuildSettingsItems(response.data));
+        $('#PHPMAILER-settings-items').html(buildFormGroup(response.data));
     }).fail(function(xhr) {
         console.error("Organizr Function: API Connection Failed");
     });

+ 73 - 65
api/plugins/php-mailer.php

@@ -48,75 +48,83 @@ function phpmSendTestEmail(){
 /* GET PHPMAILER SETTINGS */
 function phpmGetSettings(){
 	return array(
-		array(
-			'type' => 'input',
-			'name' => 'PHPMAILER-smtpHost',
-			'label' => 'SMTP Host',
-			'value' => $GLOBALS['PHPMAILER-smtpHost']
-		),
-		array(
-			'type' => 'input',
-			'name' => 'PHPMAILER-smtpHostPort',
-			'label' => 'SMTP Port',
-			'value' => $GLOBALS['PHPMAILER-smtpHostPort']
-		),
-		array(
-			'type' => 'input',
-			'name' => 'PHPMAILER-smtpHostUsername',
-			'label' => 'Username',
-			'value' => $GLOBALS['PHPMAILER-smtpHostUsername']
-		),
-		array(
-			'type' => 'password',
-			'name' => 'PHPMAILER-smtpHostPassword',
-			'label' => 'Password',
-			'value' => $GLOBALS['PHPMAILER-smtpHostPassword']
-		),
-		array(
-			'type' => 'input',
-			'name' => 'PHPMAILER-smtpHostSenderName',
-			'label' => 'Sender Name',
-			'value' => $GLOBALS['PHPMAILER-smtpHostSenderName']
-		),
-		array(
-			'type' => 'input',
-			'name' => 'PHPMAILER-smtpHostSenderEmail',
-			'label' => 'Sender Email',
-			'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
-			'placeholder' => 'i.e. same as username'
-		),
-		array(
-			'type' => 'switch',
-			'name' => 'PHPMAILER-smtpHostAuth',
-			'label' => 'Authentication',
-			'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
+		'Host' => array(
+			array(
+				'type' => 'input',
+				'name' => 'PHPMAILER-smtpHost',
+				'label' => 'SMTP Host',
+				'value' => $GLOBALS['PHPMAILER-smtpHost']
+			),
+			array(
+				'type' => 'input',
+				'name' => 'PHPMAILER-smtpHostPort',
+				'label' => 'SMTP Port',
+				'value' => $GLOBALS['PHPMAILER-smtpHostPort']
+			)
 		),
-		array(
-			'type' => 'select',
-			'name' => 'PHPMAILER-smtpHostType',
-			'label' => 'Authentication Type',
-			'value' => $GLOBALS['PHPMAILER-smtpHostType'],
-			'options' => array(
-				array(
-					'name'=>'tls',
-					'value'=>'tls'
-				),
-				array(
-					'name'=>'ssl',
-					'value'=>'ssl'
-				),
-				array(
-					'name'=>'off',
-					'value'=>'false'
+		'Authentication' => array(
+			array(
+				'type' => 'input',
+				'name' => 'PHPMAILER-smtpHostUsername',
+				'label' => 'Username',
+				'value' => $GLOBALS['PHPMAILER-smtpHostUsername']
+			),
+			array(
+				'type' => 'password',
+				'name' => 'PHPMAILER-smtpHostPassword',
+				'label' => 'Password',
+				'value' => $GLOBALS['PHPMAILER-smtpHostPassword']
+			),
+			array(
+				'type' => 'switch',
+				'name' => 'PHPMAILER-smtpHostAuth',
+				'label' => 'Authentication',
+				'value' => $GLOBALS['PHPMAILER-smtpHostAuth']
+			),
+			array(
+				'type' => 'select',
+				'name' => 'PHPMAILER-smtpHostType',
+				'label' => 'Authentication Type',
+				'value' => $GLOBALS['PHPMAILER-smtpHostType'],
+				'options' => array(
+					array(
+						'name'=>'tls',
+						'value'=>'tls'
+					),
+					array(
+						'name'=>'ssl',
+						'value'=>'ssl'
+					),
+					array(
+						'name'=>'off',
+						'value'=>'false'
+					)
 				)
 			)
 		),
-		array(
-			'type' => 'button',
-			'label' => 'Send Test',
-			'class' => 'phpmSendTestEmail',
-			'icon' => 'fa fa-paper-plane',
-			'text' => 'Send'
+		'Sender Information' => array(
+			array(
+				'type' => 'input',
+				'name' => 'PHPMAILER-smtpHostSenderName',
+				'label' => 'Sender Name',
+				'value' => $GLOBALS['PHPMAILER-smtpHostSenderName']
+			),
+			array(
+				'type' => 'input',
+				'name' => 'PHPMAILER-smtpHostSenderEmail',
+				'label' => 'Sender Email',
+				'value' => $GLOBALS['PHPMAILER-smtpHostSenderEmail'],
+				'placeholder' => 'i.e. same as username'
+			)
+		),
+		'Test' => array(
+			array(
+				'type' => 'button',
+				'label' => 'Send Test',
+				'class' => 'phpmSendTestEmail',
+				'icon' => 'fa fa-paper-plane',
+				'text' => 'Send'
+			)
 		)
 	);
 }

+ 1 - 1
js/functions.js

@@ -652,7 +652,7 @@ function buildFormGroup(array){
 			if(count%2 !== 0 ){ group += '<div class="row start">'; };
 			group += `
 				<!-- INPUT BOX -->
-				<div class="col-md-6">
+				<div class="col-md-6 p-b-10">
 					<div class="form-group">
 						<label class="control-label col-md-3" lang="en">`+v.label+`</label>
 						<div class="col-md-9">