Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3b76375
Initial support for editing forms with data. Adding fields works perf…
nathanielwarner Sep 25, 2017
3c8d510
Prevent user from editing field types in forms with data
nathanielwarner Oct 8, 2017
4c4028a
WIP: form elements are marked "hidden" when deleted. Frontend and bac…
nathanielwarner Oct 25, 2017
15c1fdc
Change name of attribute from "hidden" to "deleted" to prevent collis…
nathanielwarner Oct 27, 2017
5250ff0
Fixed backend awareness of "deleted" attribute
nathanielwarner Oct 27, 2017
d557f43
Deleted fields no longer show up in formbuilder
nathanielwarner Nov 1, 2017
a72f0f7
Added frontend awareness for deleted fields
nathanielwarner Nov 3, 2017
3373e41
Merge branch 'production' of https://github.com/carleton/reasoncms in…
nathanielwarner Jan 9, 2018
83e2764
Validate timestamp on event ticket cutoff entry
nathanielwarner Jan 9, 2018
473fd44
Prevent user from editing forms with custom thor view
nathanielwarner Jan 11, 2018
cb7d676
WIP: Add editing ability to sold out and cutoff message
nathanielwarner Jan 11, 2018
a0bbcf7
Add editing ability to sold out and cutoff messages
nathanielwarner Jan 16, 2018
6919087
Merge branch 'production' of https://github.com/carleton/reasoncms in…
nathanielwarner Jan 16, 2018
bbc3e29
formatting
Jan 18, 2018
c1d45be
formatting
Jan 18, 2018
434e630
define a default value to avoid undefined var conditions
Jan 18, 2018
7c05653
only check for properties on real objects
Jan 18, 2018
4ead389
Update messages as requested
nathanielwarner Jan 18, 2018
b99d142
Merge branch 'feature/editing_forms_with_data' of https://github.com/…
nathanielwarner Jan 18, 2018
3d209f1
Fixed event ticket datetime validation is broken for forms with more …
nathanielwarner Jan 18, 2018
65cde2b
Fix php warning
nathanielwarner Jan 18, 2018
0307920
inject the js value with disco
Jan 19, 2018
3973faf
improve detection and handling of the deleted attribute
Jan 19, 2018
8761384
Added remove deleted columns from xml
nathanielwarner Jan 30, 2018
cb024fb
swap username to user_id
Jan 31, 2018
a0843b0
remove all deleted elements
Jan 31, 2018
b2cbfaf
ensure the variable is only set when a number is present
Jan 31, 2018
715863b
capture all element types in the query
Jan 31, 2018
201866e
don't try to parse uploads on deleted elements
Jan 31, 2018
1a0a546
Merge branch 'production' into nathanielwarner-feature/editing_forms_…
May 21, 2018
da2a3fe
update message text
May 21, 2018
888f24f
Specify versions for npm dependencies, update node stuff
nathanielwarner Jun 13, 2018
b6616e8
Merge branch 'production' of github.com:carleton/reasoncms into featu…
nathanielwarner Aug 1, 2018
9bff204
WIP 8/16
nathanielwarner Aug 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions carl_util/db/table_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1529,10 +1529,18 @@ function run_action()

function run_row_action()
{
// A group of checkboxes in disco are grouped under the same id. For example checkboxgroup with id 15 will have 15[0], 15[1], etc for individual checkboxes
// Here, each checkbox has its own id (e.g. 14 and 16). So the challenge is to map between the two.
if ($this->table_row_action == 'view' || $this->table_row_action == 'edit' || $this->table_row_action == 'delete' || $this->table_row_action == 'new' || $this->table_row_action == "download_file")
{
var_dump($this->admin_form->table_action_id);
$form =& $this->get_admin_form();
$children = $form->_thor_core->_xml->document->tagChildren;
var_dump($children);
$data = $this->_build_data();
var_dump($data[$this->admin_form->table_action_id]);
$form->run();
var_dump($this->admin_form->get_element_group_names());
}
}

Expand Down
5 changes: 3 additions & 2 deletions disco/disco.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ function _prepopulate()
{
// Make sure we enable userland_changeable for prepopulatable elements
$ele = $this->get_element($element_name);
if (property_exists($ele, 'userland_changeable')) {
if (is_object($ele) && property_exists($ele, 'userland_changeable')) {
$ele->userland_changeable = true;
}

Expand Down Expand Up @@ -1627,8 +1627,9 @@ function get_element_names() // {{{
{
$element_names[] = $member_name;
}
}
}
}
var_dump($this->get_order());
return $element_names;
} // }}}

Expand Down
2 changes: 2 additions & 0 deletions reason_4.0/lib/core/classes/admin/modules/thor_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function &get_thor_admin()
$this->_thor_admin = new ThorAdmin();
$this->_thor_admin->set_thor_core($tc);
$this->_thor_admin->set_admin_form($af);
$this->_thor_admin->set_form($form);
$this->_thor_admin->set_user_id($this->admin_page->user_id);
}
else $this->_thor_admin = false;
}
Expand Down
143 changes: 109 additions & 34 deletions reason_4.0/lib/core/content_managers/thor.php3
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{
$this->head_items->add_javascript(JQUERY_UI_URL, true);
$this->head_items->add_javascript(JQUERY_URL, true);
$this->head_items->add_stylesheet(JQUERY_UI_CSS_URL);
$this->head_items->add_stylesheet(JQUERY_UI_CSS_URL);
$this->head_items->add_javascript(REASON_PACKAGE_HTTP_BASE_PATH . 'formbuilder/js/formbuilder_translation.js');
$this->head_items->add_javascript(REASON_PACKAGE_HTTP_BASE_PATH . 'formbuilder/js/jquery.formbuilder.js');
$this->head_items->add_stylesheet(REASON_PACKAGE_HTTP_BASE_PATH . 'formbuilder/css/jquery.formbuilder.css');
Expand Down Expand Up @@ -126,7 +126,7 @@

$this->set_element_properties('submission_limit', array('size'=>'4'));
// echo "<HR>using thor version...[" . USE_THOR_VERSION . "]<hr>";

$published = false;
$publish_status_text = '';

Expand Down Expand Up @@ -178,6 +178,30 @@
{
$publish_status_text .= '<strong>Status:</strong> Unpublished. <a target="_blank" href="http://reasoncms.org/userdocs/managing-content/other-types/forms/#attaching_a_form_to_a_page">How to publish your form</a>';
}

$form_entity = new entity ($this->admin_page->id);
$thor_view_value = $form_entity->get_value('thor_view');

if ($this->db_table_exists_check()) {
if (empty($thor_view_value)) {
$form_entity = new entity ($this->admin_page->id);
$old_thor_content = $form_entity->get_value('thor_content');
$new_thor_content = ($this->get_value('thor_content')) ? $this->get_value('thor_content') : $old_thor_content;
if ($new_thor_content != $old_thor_content) {
$data_manager_link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'ThorData')));
$this->set_error('thor_content', 'Changes could not be saved because of associated data. You can change the form contents if you first <a href="' . $data_manager_link . '">delete the data</a> associated with the form.');
$this->show_error_jumps = false;
}
$data_manager_link = $this->admin_page->make_link(array('cur_module' => 'ThorData'));
$publish_status_text .= '<p><strong>This form has stored data. </strong><a href="' . $data_manager_link . '">Manage stored data</a><br>If you remove a field, the field\'s data will remain available until you delete the stored data for this form. You cannot change the type of existing fields.</p>';
}

$databaseTableExistsJsValue = "true";
} else {
$databaseTableExistsJsValue = "false";
}
$databaseTableExistsFlag = '<script type="text/javascript">window.dbTableExists = ' . $databaseTableExistsJsValue . ';</script>';
$this->add_element('database_table_exists_flag', 'comment', array('text' => $databaseTableExistsFlag));

$this->add_element('publish_status', 'comment', array('text'=>$publish_status_text));

Expand Down Expand Up @@ -215,12 +239,12 @@
$advanced_option_display_names = array(
'thor_view' => 'Choose Thor View:',
'is_editable' => 'Are Submissions Editable by the Submitter?',
'allow_multiple' => 'Allow Multiple Submissions per User?',
'email_submitter' => 'Email Form Results to Submitter?',
'include_thank_you_in_email' => 'Include the Thank You message (with html) in email?',
'email_link' => 'Include Edit Link When Possible?',
'email_data' => 'Include Submitted Data in E-mails?',
'email_empty_fields' => 'Include Empty Fields in E-mails?',
'allow_multiple' => 'Allow Multiple Submissions per User?',
'email_submitter' => 'Email Form Results to Submitter?',
'include_thank_you_in_email' => 'Include the Thank You message (with html) in email?',
'email_link' => 'Include Edit Link When Possible?',
'email_data' => 'Include Submitted Data in E-mails?',
'email_empty_fields' => 'Include Empty Fields in E-mails?',
'apply_akismet_filter' => 'Apply Akismet Filtering?');
if(reason_user_has_privs($this->admin_page->user_id, 'edit_form_advanced_options'))
{
Expand Down Expand Up @@ -250,6 +274,43 @@
}
$this->setup_tableless_element();
}

function run_error_checks_deleted_fields()
{
$pendingXmlString = $this->get_value('thor_content');
$pendingXml = simplexml_load_string($pendingXmlString);
$pendingElIds = array();
foreach ($pendingXml->children() as $childEl) {
$childAttribs = $childEl->attributes();
$elId = $childAttribs->id;
array_push($pendingElIds, $elId);
}

$dbXmlString = $this->entity->get_value('thor_content');
$dbXml = simplexml_load_string($dbXmlString);
if ($dbXml != null && $this->db_table_exists_check()) {
foreach ($dbXml->children() as $childEl) {
$childAttribs = $childEl->attributes();
$dbElId = $childAttribs->id;
$in_array = false;
foreach ($pendingElIds as $pendingElId) {
if (((string)$pendingElId) === ((string)$dbElId)) {
$in_array = true;
}
}
if (!$in_array) {
$domVersionE = dom_import_simplexml($pendingXml);
$domVersion = new DOMDocument();
$domVersion->appendChild($domVersion->importNode($domVersionE, true));
$domNode = dom_import_simplexml($childEl);
$domNode->setAttribute('deleted', 'true');
$domVersion->documentElement->appendChild($domVersion->importNode($domNode, true));
$pendingXml = simplexml_import_dom($domVersion);
}
}
$this->set_value('thor_content', $pendingXml->asXML());
}
}

function pre_error_check_advanced_options()
{
Expand Down Expand Up @@ -319,22 +380,23 @@

function pre_error_check_actions()
{
if ($this->db_table_exists_check())
{
$form_entity = new entity ($this->admin_page->id);
$thor_view_value = $form_entity->get_value('thor_view');

if ($this->db_table_exists_check() && !empty($thor_view_value)) {
$form_entity = new entity ($this->admin_page->id);
$old_thor_content = $form_entity->get_value( 'thor_content' );
$new_thor_content = ($this->get_value( 'thor_content' )) ? $this->get_value( 'thor_content' ) : $old_thor_content;
if ($new_thor_content != $old_thor_content)
{
$data_manager_link = unhtmlentities($this->admin_page->make_link( array( 'cur_module' => 'ThorData' )));
$this->set_error( 'thor_content', 'Changes could not be saved because of associated data. You can change the form contents if you first <a href="'.$data_manager_link.'">delete the data</a> associated with the form.');
$this->show_error_jumps = false;
$old_thor_content = $form_entity->get_value('thor_content');
$new_thor_content = ($this->get_value('thor_content')) ? $this->get_value('thor_content') : $old_thor_content;
if ($new_thor_content != $old_thor_content) {
$data_manager_link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'ThorData')));
$this->set_error('thor_content', 'Changes could not be saved because of associated data. You can change the form contents if you first <a href="' . $data_manager_link . '">delete the data</a> associated with the form.');
$this->show_error_jumps = false;
}
$this->remove_element('thor_content');
$data_manager_link = $this->admin_page->make_link( array( 'cur_module' => 'ThorData' ));
$data_comment= '<div id="manageDataNote"><p><strong>This form has stored data. </strong><a href="'.$data_manager_link.'">Manage stored data</a></p>';
$data_comment.='<p>To edit this form, you will first need to delete the stored data.</p></div>';
$this->change_element_type('thor_comment','comment',array('text'=>$data_comment));
$data_manager_link = $this->admin_page->make_link(array('cur_module' => 'ThorData'));
$data_comment = '<div id="manageDataNote"><p><strong>This form has stored data, and has custom form logic installed. </strong><a href="' . $data_manager_link . '">Manage stored data</a></p>';
$data_comment .= '<p>To edit this form, you will first need to delete the stored data.</p></div>';
$this->change_element_type('thor_comment', 'comment', array('text' => $data_comment));
}
$this->pre_error_check_advanced_options();
}
Expand Down Expand Up @@ -386,6 +448,12 @@
{
$this->set_error('submission_limit','You have set a submission limit, but this form is not saving data to a database. Please enable the database option or remove the submission limit.');
}

$form_entity = new entity ($this->admin_page->id);
$thor_view_value = $form_entity->get_value('thor_view');

if (empty($thor_view_value))
$this->run_error_checks_deleted_fields();
$this->run_error_checks_advanced_options();
$this->run_error_checks_event_tickets();
}
Expand Down Expand Up @@ -523,6 +591,15 @@
if (empty($emailNode)) {
$this->set_error('thor_content', "An event ticket form requires a short text input with the exact label 'Your Email'. Please add that element or change the email field label to 'Your Email'.");
}
$eventTickets = $xml->xpath("/*/event_tickets");
for ($i = 0; $i < sizeof($eventTickets); $i++) {
$eventTicketsClose = $eventTickets[$i]['event_close_datetime'];
try {
new Datetime($eventTicketsClose);
} catch (Exception $e) {
$this->set_error('thor_content', "Invalid datetime cutoff entered in event registration formbuilder: $eventTicketsClose");
}
}
}
} catch (Exception $exc) {
trigger_error($exc->getTraceAsString());
Expand Down Expand Up @@ -603,12 +680,11 @@
$table = $this->form_prefix . $this->admin_page->id;
// connect with thor database defined in settings.php3
connectDB(THOR_FORM_DB_CONN);
$q = 'check table ' . $table . ' fast quick' or trigger_error( 'Error: mysql error in Thor: '.mysql_error() );
$res = mysql_query($q);
$results = mysql_fetch_assoc($res);
if (strstr($results['Msg_text'],"doesn't exist") ) $ret = false;
else
{
$q = 'check table ' . $table . ' fast quick' or trigger_error('Error: mysql error in Thor: ' . mysql_error());
$res = mysql_query($q);
$results = mysql_fetch_assoc($res);
if (strstr($results['Msg_text'], "doesn't exist")) $ret = false;
else {
$ret = true;
$this->type = 'db';
}
Expand All @@ -619,18 +695,17 @@
function ensure_temp_db_table_exists()
{
connectDB(THOR_FORM_DB_CONN);
$q = 'check table thor fast quick' or trigger_error( 'Error: mysql error in Thor: '.mysql_error() );
$res = mysql_query($q);
$results = mysql_fetch_assoc($res);
if (strstr($results['Msg_text'],"doesn't exist") )
{
$q = 'check table thor fast quick' or trigger_error('Error: mysql error in Thor: ' . mysql_error());
$res = mysql_query($q);
$results = mysql_fetch_assoc($res);
if (strstr($results['Msg_text'], "doesn't exist")) {
// create table thor
$q = 'create table thor (
id int(10) NOT NULL auto_increment,
content text NULL, PRIMARY KEY (id))';
$res = db_query($q, 'could not create thor temporary data storage using db connection '.THOR_FORM_DB_CONN);
$res = db_query($q, 'could not create thor temporary data storage using db connection ' . THOR_FORM_DB_CONN);
}
connectDB(REASON_DB);
connectDB(REASON_DB);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,15 @@ function get_event_full_html()
$model =& $this->get_model();
$eventTitle = $model->get_event_ticket_title();
$message = "<h3>Tickets for $eventTitle</h3>";
$message .= "<p>No tickets are available for this event.</p>";
$custom_message = $model->event_tickets_get_request()['thor_info']['sold_out_message'];
if (!empty($custom_message))
{
$message .= $custom_message;
}
else
{
$message .= "<p>No tickets are available for this event.</p>";
}

return $message;
}
Expand Down Expand Up @@ -317,6 +325,7 @@ function get_event_closed_html()
}

$closedMessage = "Registration closed at {$dt->format("g:i a")} on {$dt->format("F jS")}.";
$closedMessage .= " " . $remainingSeatsForCurrentEvent['thor_info']['cutoff_passed_message'];

return $closedMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ function &get_admin_object()
$this->_admin_obj = new ThorAdmin();
$this->_admin_obj->set_thor_core($thor_core);
$this->_admin_obj->set_admin_form($disco_admin_obj);
$netid = $this->get_user_netid();
$user_id = ($netid) ? get_user_id($netid) : false;
$this->_admin_obj->set_user_id($user_id);
$this->_admin_obj->set_form($form);

// if the user has editing access to the site lets give the same privileges that we give there.
if ($this->_user_has_site_editing_access())
Expand Down
1 change: 1 addition & 0 deletions sources/formbuilder-rsn/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bower_components/
Loading