You are here

public static function feedback::miniorange_oauth_client_feedback in OAuth2 Login 8

1 call to feedback::miniorange_oauth_client_feedback()
oauth2_login_uninstall in ./oauth2_login.install
hook_uninstall not needed. Configure variables are cleared when module is uninstalled.

File

src/feedback.php, line 4

Class

feedback

Namespace

Drupal\oauth2_login

Code

public static function miniorange_oauth_client_feedback() {
  global $base_url;
  if (!empty(\Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_base_url'))) {
    $baseUrlValue = \Drupal::config('oauth2_login.settings')
      ->get('miniorange_oauth_client_base_url');
  }
  else {
    $baseUrlValue = $base_url;
  }
  $feedback_url = $baseUrlValue . '/feedback';
  $_SESSION['mo_other'] = "True";
  $form_id = $_POST['form_id'];
  $form_token = $_POST['form_token'];
  ?>
        <html>
        <head>
            <title>Feedback</title>
            <link href="https://fonts.googleapis.com/css?family=PT+Serif" rel="stylesheet">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
            <style>
                .sp_loader {
                    margin: auto;
                    display: block;
                    border: 5px solid #f3f3f3; /* Light grey */
                    border-top: 5px solid #3498db; /* Blue */
                    border-radius: 50%;
                    width: 50px;
                    height: 50px;
                    animation: spin 2s linear infinite;
                }
                @keyframes spin {
                    0% { transform: rotate(0deg); }
                    100% { transform: rotate(360deg); }
                }
            </style>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("#myModal").modal({
                        backdrop: 'static',
                        keyboard: false
                    });
                    if(document.getElementById('miniorange_feedback_email').value == '') {
                        document.getElementById('email_error').style.display = "block";
                        document.getElementById('submit_button').disabled = true;
                    }
                });

                function validateEmail(emailField) {
                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

                    if (reg.test(emailField.value) == false) {
                        document.getElementById('email_error').style.display = "block";
                        document.getElementById('submit_button').disabled = true;
                    } else {
                        document.getElementById('email_error').style.display = "none";
                        document.getElementById('submit_button').disabled = false;
                    }
                }

                $(function () {
                    $(".button").click(function () {
                        document.getElementById('sp_loader').style.display = 'block';
                        var reason = $("input[name='deactivate_plugin']:checked").val();
                        var q_feedback = document.getElementById("query_feedback").value;
                        var email = "";
                        <?php

  if (empty(\Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_admin_email'))) {
    ?>
                        email = document.getElementById("miniorange_feedback_email").value;
                        <?php

  }
  ?>
                        return false;
                    });
                })
            </script>
        </head>
        <body>
        <div class="container">
            <div class="modal fade" id="myModal" role="dialog" style="background: rgba(0,0,0,0.1);">
                <div class="modal-dialog" style="width: 500px;">
                    <div class="modal-content" style="border-radius: 20px">
                        <div class="modal-header"
                             style="padding: 25px; border-top-left-radius: 20px; border-top-right-radius: 20px; background-color: #8fc1e3;">

                            <h4 class="modal-title" style="color: white; text-align: center;"> Hey, it seems like you want to deactivate the miniOrange OAuth Login Module</h4>
                            <hr>
                            <h4 style="text-align: center; color: white;">What happened?</h4>
                        </div>
                        <div class="modal-body"
                             style="font-size: 11px; padding-left: 25px; padding-right: 25px; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; background-color: #ececec;">
                            <form name="f" action="<?php

  echo $feedback_url;
  ?>" id="mo_feedback">
                                <div>
                                    <p>
                                        <?php

  if (empty(\Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_admin_email'))) {
    ?>
                                        <br>Email ID: <input onblur="validateEmail(this)" class="form-control"
                                                             type="email" id="miniorange_feedback_email" required
                                                             name="miniorange_feedback_email"/>
                                    <p style="display: none;color:red" id="email_error">Invalid Email</p>
                                    <?php

  }
  ?>
                                    <br>
                                    <?php

  $deactivate_reasons = array(
    "Not Working",
    "Not Receiving OTP During Registration",
    "Does not have the features I'm looking for",
    "Redirecting back to login page after Authentication",
    "Confusing Interface",
    "Bugs in the module",
    "Other Reasons:",
  );
  foreach ($deactivate_reasons as $deactivate_reasons) {
    ?>
                                        <div  class="radio" style="padding:2px;font-size: 8px">
                                            <label style="font-weight:normal;font-size:14.6px;color:maroon" for="<?php

    echo $deactivate_reasons;
    ?>">

                                                <input type="radio" name="deactivate_plugin" value="<?php

    echo $deactivate_reasons;
    ?>" required>
                                                <?php

    echo $deactivate_reasons;
    ?>
                                            </label>
                                        </div>

                                    <?php

  }
  ?>
                                    <input type="hidden" name="mo_oauth_client_check" value="True">
                                    <input type="hidden" name="form_token" value=<?php

  echo $form_token;
  ?> >
                                    <input type="hidden" name="form_id" value= <?php

  echo $form_id;
  ?>>
                                    <br>
                                    <textarea  class="form-control" id="query_feedback" name="query_feedback"  rows="4" style="margin-left:2%" cols="50" placeholder="Write your query here"></textarea>
                                    <br><br>
                                    <div class="mo2f_modal-footer">
                                        <input type="submit" style="margin: auto; display: block; font-size: 11px;" name="miniorange_feedback_submit" class="btn btn-primary btn-large" value="Submit and Continue" />
                                    </div>
                                    <div class="sp_loader" id="sp_loader" style="display: none;"></div>
                                    <?php

  echo "<br><br>";
  foreach ($_POST as $key => $value) {
    self::hiddenOauthClientFields($key, $value);
  }
  ?>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </body>

        </html>
        <?php

  exit;
}