Skip to content

Commit

Permalink
Merge pull request #64 from burnacid/development
Browse files Browse the repository at this point in the history
Merge for release of V2.2
  • Loading branch information
burnacid authored Oct 28, 2017
2 parents 50f02a8 + 080d18b commit 8ab679b
Show file tree
Hide file tree
Showing 25 changed files with 476 additions and 72 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
!.gitignore
!inc\class_formcreator.php
!inc\plugins\formcreator.php
!inc\languages\english\formcreator.lang.php
!inc\languages\english\admin\config_formcreator.lang.php
!inc\languages\*\formcreator.lang.php
!inc\languages\*\admin\config_formcreator.lang.php
!inc\plugins\formcreator\jquery-ui.css
!admin\modules\config\formcreator.php
!admin\jscripts\formcreator.js
Expand All @@ -13,4 +13,5 @@
!images\ui-icons_777777_256x240.png
!images\ui-icons_cc0000_256x240.png
!images\ui-icons_ffffff_256x240.png
!form.php
!images\formcreator\*
!form.php
41 changes: 0 additions & 41 deletions admin/jscripts/formcreator.js

This file was deleted.

71 changes: 63 additions & 8 deletions admin/modules/config/formcreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@

$form_container->output_row($lang->fc_allowed_groups." <em>*</em>", $lang->fc_allowed_groups_desc, $radioboxes . "<br /><br />" . $form->
generate_group_select("allowedgid[]", $formcreator->allowedgid, array("multiple" => true)));
$form_container->output_row($lang->fc_limitusage, $lang->fc_limitusage_desc, $form->generate_numeric_field("limitusage", $formcreator->limitusage));
$form_container->output_row($lang->fc_status." <em>*</em>", $lang->fc_status_desc, $form->generate_yes_no_radio("active", $formcreator->active));
$form_container->end();

Expand Down Expand Up @@ -196,6 +197,10 @@
$form_container->output_row($lang->fc_override_button,
$lang->fc_override_button_desc, $form->
generate_on_off_radio("overridebutton", $formcreator->overridebutton));

$form_container->output_row($lang->fc_custom_success_page,
$lang->fc_custom_success_page_desc, $form->
generate_text_box("customsuccess", $formcreator->customsuccess));
/*
$form_container->output_row("Send Mail to",
"Send a mail to the following E-mail address(es). Leave empty if you don't like to send a email. One address per line.<span style='color:red;font-weight: bold;'> (currently disabled)</span>",
Expand Down Expand Up @@ -256,6 +261,12 @@
$page->output_header($lang->fc_form_output_template);
$page->output_nav_tabs($sub_tabs, 'formcreator_output');

// Load SCEditor scripts
echo '<link rel="stylesheet" href="'.$mybb->settings['bburl'].'/jscripts/sceditor/editor_themes/mybb.css" type="text/css" media="all">
<script type="text/javascript" src="'.$mybb->settings['bburl'].'/jscripts/sceditor/jquery.sceditor.bbcode.min.js?ver=1805"></script>
<script type="text/javascript" src="'.$mybb->settings['bburl'].'/jscripts/bbcodes_sceditor.js?ver=1808"></script>
<script type="text/javascript" src="'.$mybb->settings['bburl'].'/jscripts/sceditor/editor_plugins/undo.js?ver=1805"></script>';

if (!$formcreator->get_form($mybb->input['formid'])) {
flash_message($lang->fc_form_output_not_found, 'error');
admin_redirect("index.php?module=config-formcreator");
Expand All @@ -279,7 +290,7 @@
}

if ($formcreator->update_template()) {
flash_message($lang->fc_message_validation_failed, 'success');
flash_message($lang->fc_output_template_success, 'success');
admin_redirect("index.php?module=config-formcreator&action=output&formid=" . $formcreator->formid);
} else {
flash_message($lang->fc_error_oops, 'error');
Expand All @@ -294,26 +305,31 @@
admin_redirect("index.php?module=config-formcreator");
}

echo "<script src='jscripts/formcreator.js'></script>";
echo "<script>function insertToEditor(text) { $('textarea').sceditor('instance').insert(text); }</script>";

$legend = "<a href='javascript:insertAtCaret(\"msgtemplate\",\"{\$formname}\");'>".$lang->fc_form_name."</a><br />";
$legend .= $lang->fc_user_info .": <a href='javascript:insertAtCaret(\"msgtemplate\",\"{\$username}\");'>".$lang->fc_username."</a> | <a href='javascript:insertAtCaret(\"msgtemplate\",\"{\$uid}\");'>".$lang->fc_id."</a><br /><br />";
$legend = "<a href='javascript:insertToEditor(\"{\$formname}\");'>".$lang->fc_form_name."</a><br />";
$legend .= $lang->fc_user_info .": <a href='javascript:insertToEditor(\"{\$username}\");'>".$lang->fc_username."</a> | <a href='javascript:insertToEditor(\"{\$uid}\");'>".$lang->fc_id."</a><br /><br />";
$legend .= $lang->fc_other .": <a href='javascript:insertToEditor(\"{\$ref}\");'>".$lang->fc_reference_number."</a><br /><br />";

foreach ($formcreator->fields as $field) {
$legend .= "(ID:" . $field->fieldid . ") " . $field->name . ": ";
$legend .= "<a href='javascript:insertAtCaret(\"msgtemplate\",\"{\$fieldname[" . $field->fieldid . "]}\");'>".$lang->fc_fieldname."</a> | <a href='javascript:insertAtCaret(\"msgtemplate\",\"{\$fieldvalue[" .
$legend .= "<a href='javascript:insertToEditor(\"{\$fieldname[" . $field->fieldid . "]}\");'>".$lang->fc_fieldname."</a> | <a href='javascript:insertToEditor(\"{\$fieldvalue[" .
$field->fieldid . "]}\");'>".$lang->fc_fieldvalue."</a><br />";
}

$form = new Form("index.php?module=config-formcreator&amp;action=output&amp;formid=" . $mybb->input['formid'], "post");
$form_container = new FormContainer($lang->fc_edit_output_template);
$form_container->output_row($lang->fc_subject_template, $lang->fc_subject_template_desc, $form->
generate_text_box("subjecttemplate", $formcreator->subjecttemplate));

$code = build_mycode_inserter("msgtemplate", false);

$form_container->output_row($lang->fc_message_template,
$lang->fc_message_template_desc, $form->generate_text_area("messagetemplate",
$formcreator->messagetemplate, array(
"style" => "width: 98%;",
"rows" => 20,
"id" => "msgtemplate")) . "<br /><br /><strong>".$lang->fc_add_variables.":<br /></strong><small>" . $legend . "</small>");
"id" => "msgtemplate")) . $code . "<br /><br /><strong>".$lang->fc_add_variables.":<br /></strong><small>" . $legend . "</small>");

$form_container->end();

Expand Down Expand Up @@ -412,14 +428,20 @@
if ($field->show_admin_field("description")) {
$form_container->output_row($lang->fc_description, $lang->fc_field_description_desc, $form->generate_text_area("description", $field->description));
}
if ($field->show_admin_field("placeholder")) {
$form_container->output_row($lang->fc_placeholder, $lang->fc_field_placeholder_desc, $form->generate_text_box("placeholder", $field->placeholder));
}
if ($field->show_admin_field("maxlength")) {
$form_container->output_row($lang->fc_maxlength, $lang->fc_field_maxlength_desc, $form->generate_numeric_field("maxlength", $field->maxlength));
}
if ($field->show_admin_field("options")) {
$form_container->output_row($lang->fc_options." <em>*</em>", $lang->fc_field_options_desc, $form->generate_text_area("options",
$field->options));
}
if ($field->show_admin_field("format")) {
$form_container->output_row($lang->fc_format,
$form->fc_field_format_desc ,
generate_text_box("format", $field->format));
$form->generate_text_box("format", $field->format));
}
if ($field->show_admin_field("default")) {
$form_container->output_row($lang->fc_default, $lang->fc_field_default_desc, $form->generate_text_box("default", $field->default));
Expand Down Expand Up @@ -455,7 +477,17 @@
} else {
$form_container = new FormContainer($lang->fc_add_field);
echo $form->generate_hidden_field("fieldselect", 1);
$form_container->output_row($lang->fc_field_type, $lang->fc_field_type_desc, $form->generate_select_box("type", $formcreator->types));

$radio = "<table><tr><th>".$lang->fc_field_type."</th><th>".$lang->fc_field_example."</th></tr>";

foreach($formcreator->types as $key => $value){
$radio .= "<tr><td>".$form->generate_radio_button("type",$key,$value)."</td><td><img src='".$mybb->settings['bburl']."/images/formcreator/fields/".$key.".jpg' /></td></tr>";
}

$radio .= "</table>";

$form_container->output_row($lang->fc_field_type, $lang->fc_field_type_desc, $radio);
//$form_container->output_row($lang->fc_field_type, $lang->fc_field_type_desc, $form->generate_select_box("type", $formcreator->types));
}

$form_container->end();
Expand Down Expand Up @@ -574,6 +606,20 @@
} else {
$data['fields'] = array();
}

if($mybb->input['usagelog'] == 1 && $db->table_exists("fc_formusage")){
$query = $db->simple_select("fc_formusage","*", "formid = '".$form."'");
$db->num_rows($query);

$usagelog = array();

while($log = $db->fetch_array($query)){
unset($log['formid']);
$usagelog[] = $log;
}

$data['usage'] = $usagelog;
}

$output_array[] = $data;

Expand Down Expand Up @@ -609,6 +655,8 @@
$lang->fc_export_perms_desc, $form->generate_on_off_radio("permissions"));
$form_container->output_row($lang->fc_export_process_options,
$lang->fc_export_process_options_desc, $form->generate_on_off_radio("process"));
$form_container->output_row($lang->fc_export_usagelog,
$lang->fc_export_usagelog_desc, $form->generate_on_off_radio("usagelog"));

$form_container->end();

Expand Down Expand Up @@ -661,6 +709,13 @@
$formcreator->subjecttemplate = $form['subjecttemplate'];
$formcreator->messagetemplate = $form['messagetemplate'];
$formcreator->update_template();

if($form['usage']){
foreach ($form['usage'] as $log) {
$log['formid'] = $formid;
$db->insert_query("fc_formusage",$log);
}
}
}
$count_forms++;
}
Expand Down
32 changes: 23 additions & 9 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
if ($formcreator->get_form($mybb->input['formid'])) {

if ($formcreator->check_allowed() && $formcreator->active == 1) {

if(!$formcreator->check_usage_limit_reached()){

add_breadcrumb($formcreator->name, "form.php?formid=" . $formcreator->formid);
$display = true;

Expand Down Expand Up @@ -96,10 +99,12 @@
}
} else {
$display = false;
$ref = $formcreator->get_next_ref();

$subject = $formcreator->parse_subject();
$message = $formcreator->parse_output();

$formcreator->log_usage();
$uid = $mybb->user['uid'];
$username = $mybb->user['username'];

Expand Down Expand Up @@ -237,9 +242,9 @@

// Set up the thread options
$new_post['options'] = array(
"signature" => 'yes',
"emailnotify" => 'no',
"disablesmilies" => 'no');
"signature" => '1',
"emailnotify" => '',
"disablesmilies" => '0');

$posthandler->set_data($new_post);

Expand Down Expand Up @@ -278,9 +283,9 @@

// Set up the thread options
$new_thread['options'] = array(
"signature" => 'yes',
"emailnotify" => 'no',
"disablesmilies" => 'no');
"signature" => '1',
"emailnotify" => '',
"disablesmilies" => '0');

$posthandler->set_data($new_thread);

Expand All @@ -300,7 +305,9 @@
}
}

if ($url) {
if(!empty($formcreator->customsuccess)){
redirect($formcreator->customsuccess, $lang->fc_submitted, "", false);
}elseif ($url) {
redirect($url, $lang->fc_submitted, "", false);
} else {
redirect($mybb->settings['bburl'], $lang->fc_submitted, "", false);
Expand All @@ -318,17 +325,24 @@

$formcontent = '<tr><td class="trow1" colspan="2">'.$lang->fc_no_fields.'</td></tr>';
}

}else{
add_breadcrumb($formcreator->name, "form.php?formid=" . $formcreator->formid);

$formtitle = $lang->fc_limit_reached_title;

$formcontent = '<tr><td class="trow1" colspan="2">'.$lang->fc_limit_reached.'</td></tr>';
}
} elseif ($formcreator->active == 0) {
add_breadcrumb($formcreator->name, "form.php?formid=" . $formcreator->formid);

$formtitle = "Form disabled";
$formtitle = $lang->fc_form_disabled_title;

$formcontent = '<tr><td class="trow1" colspan="2">'.$lang->fc_form_disabled.'</td></tr>';
} else {
add_breadcrumb($formcreator->name, "form.php?formid=" . $formcreator->formid);

$formtitle = "Access Denied";
$formtitle = $lang->fc_access_denied;

$formcontent = '<tr><td class="trow1" colspan="2">'.$lang->fc_form_no_permissions.'</td></tr>';
}
Expand Down
Binary file added images/formcreator/fields/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/15.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formcreator/fields/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8ab679b

Please sign in to comment.