AJAXMethods); } /** * Constructor. * * @param string $ajax_controller Controller. * * @return object */ public function __construct($ajax_controller) { $this->ajaxController = $ajax_controller; return $this; } /** * Main method. * * @return void */ public function run() { ui_require_css_File('discovery'); ui_require_css_file('help_feedback'); $help_url = get_parameter('b', null); $help_url = io_safe_input(base64_decode($help_url)); if ($help_url === null) { echo __('Page not found'); } else { ?> '; echo $hidden; echo '
'; // Load feedback form. echo $this->loadFeedbackForm(); echo '
'; } /** * Loads a feedback form * * @return​ ​string HTML code for form. * * @return Function loadFeedbackForm. */ public function loadFeedbackForm() { global $config; $form = [ 'action' => '#', 'id' => 'feedback_form', 'onsubmit' => 'return false;', ]; $inputs = [ [ 'wrapper' => 'div', 'block_id' => 'flex-row-baseline w100p', 'class' => 'flex-row-baseline w100p', 'direct' => 1, 'block_content' => [ [ 'arguments' => [ 'label' => __('Suggestion'), 'type' => 'radio_button', 'attributes' => 'class="btn"', 'name' => 'suggestion', 'id' => 'suggestion', 'script' => 'disableRadio(\'report\')', 'return' => true, ], ], [ 'arguments' => [ 'label' => __('Something is wrong'), 'type' => 'radio_button', 'attributes' => 'class="btn"', 'name' => 'report', 'id' => 'report', 'script' => 'disableRadio(\'suggestion\')', 'return' => true, ], ], ], ], [ 'label' => __('What happened?'), 'class' => 'explain', 'arguments' => [ 'class' => 'textarea_feedback', 'id' => 'feedback_text', 'type' => 'textarea', 'name' => 'feedback_text', ], ], [ 'label' => __('Your Email'), 'arguments' => [ 'id' => 'feedback_email', 'name' => 'feedback_email', 'input_class' => 'email_feedback', 'class' => 'email_feedback', 'type' => 'email', 'required' => true, ], ], [ 'arguments' => [ 'button_class' => 'btn_submit', 'class' => 'btn_submit', 'attributes' => 'class="sub next btn_submit_feed_back"', 'type' => 'submit', 'id' => 'submit_feedback', 'label' => __('Submit'), ], ], ]; $output = ui_print_toggle( [ 'id' => 'toggle_help_feedback', 'content' => $this->printForm( [ 'form' => $form, 'inputs' => $inputs, ], true ), 'name' => __('Feedback'), 'return' => true, 'class' => 'no-border', 'img_a' => 'images/arrow_down_white.png', 'img_b' => 'images/arrow_up_white.png', ] ); $output .= $this->loadJS(); return $output; } /** * Function send_mail_method,we use send_email_attachment method * from functions_cron.php. * * @param​ ​string​ $feedback_option type fo mail. * @param​ ​string​ $feedback_text text mail. * @param​ ​string​ $feedback_mail costumer mail. * * @return void. */ public function sendMailMethod() { global $config; $suggestion = get_parameter('type', 'false'); $feedback_text = get_parameter('feedback_text', null); $feedback_mail = get_parameter('feedback_email', null); $help_url = get_parameter('help_url', 'unknown'); $section = explode('title=', $help_url, 2); $subject = ''; if (is_array($section) === true && isset($section[1]) === true) { $subject = '['.$section[1].']'; } if ($suggestion !== 'false') { $subject .= __('[pandorafms wiki] New suggestion'); } else { $subject .= __('[pandorafms wiki] New report'); } if (empty($feedback_mail) === true) { $error = [ 'error' => __( 'Please provide your email address, we promise not to bother you' ), ]; } if (empty($feedback_text) === true) { if ($suggestion !== 'false') { $msg = 'Please provide some feedback. Write something awesome!'; } else { $msg = 'Please provide some feedback. We\'ll appreciate it!'; } $error = [ 'error' => __($msg), ]; } if ($error !== null) { echo json_encode($error); exit; } enterprise_include_once('include/functions_cron.php'); $uid = $config['pandora_uid']; if (empty($uid) === true) { $uid = 'not registered'; } $body = ''; $body .= '

Message

'; $body .= '

'.$feedback_text.'

'; $res = enterprise_hook( 'send_email_attachment', [ 'feedback@artica.es', $body, $subject, ] ); // Response. if ($res == 1) { $r = ['error' => '']; } else { $r = ['error' => __('Something went wrong while sending the report.')]; } echo json_encode($r); exit; } /** * Load extra JS. * * @return string JS content. */ public function loadJS() { ob_start(); ?>