Index: branches/5.2.x/core/admin_templates/forms/forms_edit.tpl =================================================================== diff -u -N -r14244 -r14614 --- branches/5.2.x/core/admin_templates/forms/forms_edit.tpl (.../forms_edit.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/forms/forms_edit.tpl (.../forms_edit.tpl) (revision 14614) @@ -59,10 +59,11 @@
- - - - + + + + +
Index: branches/5.2.x/core/units/forms/form_fields/form_fields_config.php =================================================================== diff -u -N -r14585 -r14614 --- branches/5.2.x/core/units/forms/form_fields/form_fields_config.php (.../form_fields_config.php) (revision 14585) +++ branches/5.2.x/core/units/forms/form_fields/form_fields_config.php (.../form_fields_config.php) (revision 14614) @@ -1,6 +1,6 @@ Array('type' => 'string', 'default' => null, 'required' => 1), 'ElementType' => Array( 'type' => 'string', - 'formatter' => 'kOptionsFormatter', 'options' => Array ('text' => 'la_type_text', 'select' => 'la_type_select', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_SingleCheckbox', 'password' => 'la_type_password', 'textarea' => 'la_type_textarea', 'label' => 'la_type_label'), 'use_phrases' => 1, + 'formatter' => 'kOptionsFormatter', 'options' => Array ('text' => 'la_type_text', 'select' => 'la_type_select', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_SingleCheckbox', 'password' => 'la_type_password', 'textarea' => 'la_type_textarea', 'upload' => 'la_type_upload', 'label' => 'la_type_label'), 'use_phrases' => 1, 'required' => 1, 'not_null' => 1, 'default' => '', ), 'ValueList' => Array('type' => 'string','default' => null), @@ -77,6 +77,8 @@ 'DisplayInGrid' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), 'DefaultValue' => Array('type' => 'string', 'default' => NULL), 'Validation' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_None', 1 => 'la_ValidationEmail'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0), + 'UploadExtensions' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), + 'UploadMaxSize' => Array ('type' => 'int', 'default' => NULL), 'Visibility' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Everyone', 2 => 'la_opt_GuestsOnly'), 'use_phrases' => 1, Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r14596 -r14614 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14596) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14614) @@ -1,6 +1,6 @@ Application->recallObject($formatter_class); /* @var $formatter kMultiLanguage */ - + $field = $formatter->LangFieldName($field); } @@ -1109,7 +1109,7 @@ { $object =& $this->getObject($params); /* @var $object kDBList */ - + $field = $params['field']; $value = array_key_exists('value', $params) ? $params['value'] : $object->GetDBField($field); $field_options = $object->GetFieldOptions($field); @@ -1211,7 +1211,7 @@ } elseif ( $human_format || $edit_size ) { $format = $formatter->HumanFormat($format); - + return $edit_size ? strlen($format) : $format; } } @@ -1822,7 +1822,7 @@ $prefixes = array_key_exists('prefixes', $title_info) ? $title_info['prefixes'] : false; $all_tag_params = array_key_exists('tag_params', $title_info) ? $title_info['tag_params'] : false; /* @var $prefixes Array */ - + if ($prefixes) { // extract tag_params passed directly to SectionTitle tag for specific prefix foreach ($params as $tp_name => $tp_value) { @@ -1930,7 +1930,7 @@ $of_phrase = $this->Application->Phrase('la_of'); return $object->GetRecordsCount() . ' ' . $of_phrase . ' ' . $object->GetRecordsCount(false); } - + return $object->GetRecordsCount(); break; } @@ -2010,6 +2010,7 @@ case 'text': case 'textarea': + case 'upload': $params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field'])); break; @@ -2225,7 +2226,7 @@ if ($formatter_class) { $formatter =& $this->Application->recallObject($formatter_class); /* @var $formatter kFormatter */ - + $human_format = array_key_exists('human', $params) ? $params['human'] : false; $edit_size = array_key_exists('edit_size', $params) ? $params['edit_size'] : false; $sample = array_key_exists('sample', $params) ? $params['sample'] : false; @@ -2330,7 +2331,7 @@ { $export_object =& $this->Application->recallObject('CatItemExportHelper'); /* @var $export_object kCatDBItemExportHelper */ - + $event = new kEvent($this->getPrefixSpecial().':OnDummy'); $action_method = 'perform'.ucfirst($this->Special); Index: branches/5.2.x/core/admin_templates/submissions/submissions_list.tpl =================================================================== diff -u -N -r14244 -r14614 --- branches/5.2.x/core/admin_templates/submissions/submissions_list.tpl (.../submissions_list.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/submissions/submissions_list.tpl (.../submissions_list.tpl) (revision 14614) @@ -53,6 +53,12 @@ "> + + + + + + + + \ No newline at end of file Index: branches/5.2.x/core/install/install_schema.sql =================================================================== diff -u -N -r14605 -r14614 --- branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14605) +++ branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14614) @@ -1027,6 +1027,8 @@ DisplayInGrid tinyint(1) NOT NULL DEFAULT '1', DefaultValue text, Validation tinyint(4) NOT NULL DEFAULT '0', + UploadExtensions varchar(255) NOT NULL DEFAULT '', + UploadMaxSize int(11) DEFAULT NULL, Visibility tinyint(4) NOT NULL DEFAULT '1', EmailCommunicationRole tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (FormFieldId), @@ -1106,6 +1108,7 @@ Description text, RequireLogin tinyint(4) NOT NULL DEFAULT '0', UseSecurityImage tinyint(4) NOT NULL DEFAULT '0', + SubmitNotifyEmail varchar(255) NOT NULL DEFAULT '', EnableEmailCommunication tinyint(4) NOT NULL DEFAULT '0', ProcessUnmatchedEmails tinyint(4) NOT NULL DEFAULT '0', ReplyFromName varchar(255) NOT NULL DEFAULT '', Index: branches/5.2.x/core/install/upgrades.sql =================================================================== diff -u -N -r14606 -r14614 --- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14606) +++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14614) @@ -2122,3 +2122,10 @@ WHERE ModuleOwner = 'In-Portal' AND `Section` = 'in-portal:configure_advanced' AND Heading = 'la_section_SettingsAdmin' AND DisplayOrder > 40.06; INSERT INTO ConfigurationValues VALUES (DEFAULT, 'StickyGridSelection', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsAdmin', 'la_config_StickyGridSelection', 'radio', '', '1=la_Yes||0=la_No', 40.07, 0, 0, NULL); + +ALTER TABLE Forms + ADD SubmitNotifyEmail VARCHAR(255) NOT NULL DEFAULT '' AFTER UseSecurityImage; + +ALTER TABLE FormFields + ADD UploadExtensions VARCHAR(255) NOT NULL DEFAULT '' AFTER Validation, + ADD UploadMaxSize INT NULL AFTER UploadExtensions; Index: branches/5.2.x/core/units/forms/forms/forms_config.php =================================================================== diff -u -N -r14585 -r14614 --- branches/5.2.x/core/units/forms/forms/forms_config.php (.../forms_config.php) (revision 14585) +++ branches/5.2.x/core/units/forms/forms/forms_config.php (.../forms_config.php) (revision 14614) @@ -1,6 +1,6 @@ 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0 ), + 'SubmitNotifyEmail' => Array ( + 'type' => 'string', 'max_len' => 255, + 'formatter' => 'kFormatter', 'regexp'=>'/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', + 'sample_value' => 'email@domain.com', 'error_msgs' => Array ('invalid_format' => '!la_invalid_email!'), + 'not_null' => 1, 'default' => '' + ), 'EnableEmailCommunication' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, @@ -212,6 +218,7 @@ 'RequireLogin' => Array ('filter_block' => 'grid_options_filter', 'width' => 80,), 'UseSecurityImage' => Array ('filter_block' => 'grid_options_filter', 'width' => 110,), 'EnableEmailCommunication' => Array ('title' => 'la_col_EnableEmailCommunication', 'filter_block' => 'grid_options_filter', 'width' => 120,), + 'SubmitNotifyEmail' => Array ('filter_block' => 'grid_like_filter'), ), ), ), Index: branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php =================================================================== diff -u -N -r14585 -r14614 --- branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 14585) +++ branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 14614) @@ -1,6 +1,6 @@ Application->isAdmin) { if ($event->Name == 'OnCreate') { @@ -65,6 +72,7 @@ 'password' => 'grid_like_filter', 'textarea' => 'grid_like_filter', 'label' => 'grid_like_filter', + 'upload' => 'grid_empty_filter', ); return $mapping[$element_type]; @@ -116,6 +124,10 @@ 'filter_block' => $this->_getFilterBlock($options['ElementType']) ); + if ($options['ElementType'] == 'upload') { + $conf_grids['Default']['Fields']['fld_' . $field_id]['data_block'] = 'grid_upload_td'; + } + if ($options['Validation'] == 1) { $conf_grids['Default']['Fields']['fld_' . $field_id]['data_block'] = 'grid_email_td'; } @@ -138,18 +150,40 @@ $field_options['verify_field'] = 'fld_' . $field_id . '_verify'; } + if ($options['ElementType'] == 'upload') { + $field_options['formatter'] = 'kUploadFormatter'; + $field_options['upload_dir'] = WRITEBALE_BASE . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . 'form_submissions'; + + if ( $options['UploadMaxSize'] ) { + $field_options['max_size'] = $options['UploadMaxSize'] * 1024; // convert Kbytes to bytes + } + + if ( $options['UploadExtensions'] ) { + $field_options['file_types'] = '*.' . implode(';*.', explode(',', $options['UploadExtensions'])); + } + } + $conf_fields['fld_' . $field_id] = $field_options; } $this->Application->setUnitOption($event->Prefix, 'Fields', $conf_fields); $this->Application->setUnitOption($event->Prefix, 'Grids', $conf_grids); } - function SetCustomQuery(&$event) + /** + * Apply any custom changes to list's sql query + * + * @param kEvent $event + * @return void + * @access protected + * @see kDBEventHandler::OnListBuild() + */ + protected function SetCustomQuery(&$event) { $object =& $event->getObject(); - $form_id = $this->Application->GetVar('form_id'); - $object->addFilter('form_filter','%1$s.FormId = '.$form_id); + /* @var $object kDBList */ + + $object->addFilter('form_filter', '%1$s.FormId = ' . (int)$this->Application->GetVar('form_id')); } /** @@ -193,7 +227,25 @@ // allows user to view only it's last submission $this->Application->StoreVar('last_submission_id', $object->GetID()); - $this->Application->EmailEventAdmin('FORM.SUBMITTED'); + $form_submission_helper =& $this->Application->recallObject('FormSubmissionHelper'); + /* @var $form_submission_helper FormSubmissionHelper */ + + $form =& $form_submission_helper->getForm($object); + + $notify_email = $form->GetDBField('SubmitNotifyEmail'); + + if ($notify_email) { + $send_params = Array ( + 'to_name' => $notify_email, + 'to_email' => $notify_email, + ); + + $this->Application->EmailEventAdmin('FORM.SUBMITTED', null, $send_params); + } + else { + $this->Application->EmailEventAdmin('FORM.SUBMITTED'); + } + // $this->Application->EmailEventUser('FORM.SUBMITTED', null, 'to_email' => ''); $event->SetRedirectParam('opener', 's'); @@ -202,7 +254,7 @@ $theme =& $this->Application->recallObject('theme.current'); /* @var $theme kDBItem */ - $template = $this->Application->GetVar('success_template'); + $template = kUtil::unhtmlentities( $this->Application->GetVar('success_template') ); // kHTTPQuery do htmlspecialchars on everything $alias_template = $theme->GetField('TemplateAliases', $template); $event->redirect = $alias_template ? $alias_template : $template; @@ -212,8 +264,10 @@ * Processes Captcha code * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(&$event) { parent::OnBeforeItemCreate($event); @@ -225,7 +279,7 @@ if ( !$object->GetDBField('ReferrerURL') ) { $referrer = $this->Application->GetVar('original_referrer'); - if (!$referrer) { + if ( !$referrer ) { $base_url = preg_quote($this->Application->BaseURL(), '/'); $referrer = preg_replace('/^' . $base_url . '/', '/', $_SERVER['HTTP_REFERER'], 1); } @@ -239,7 +293,7 @@ $form =& $form_submission_helper->getForm($object); // validate captcha code - if ($form->GetDBField('UseSecurityImage') && !$this->Application->LoggedIn()) { + if ( $form->GetDBField('UseSecurityImage') && !$this->Application->LoggedIn() ) { $captcha_helper =& $this->Application->recallObject('CaptchaHelper'); /* @var $captcha_helper kCaptchaHelper */ @@ -251,8 +305,10 @@ * Checks, that target submission was selected for merging * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(&$event) { parent::OnBeforeItemUpdate($event); @@ -319,8 +375,10 @@ * Fills merge-to dropdown * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(&$event) { parent::OnAfterItemLoad($event); @@ -382,9 +440,7 @@ $options[$submission_id] = $option_title; } - $field_options = $object->GetFieldOptions('MergeToSubmission'); - $field_options['options'] = $options; - $object->SetFieldOptions('MergeToSubmission', $field_options); + $object->SetFieldOption('MergeToSubmission', 'options', $options); } /** Index: branches/5.2.x/core/admin_templates/submissions/submission_view.tpl =================================================================== diff -u -N -r14585 -r14614 --- branches/5.2.x/core/admin_templates/submissions/submission_view.tpl (.../submission_view.tpl) (revision 14585) +++ branches/5.2.x/core/admin_templates/submissions/submission_view.tpl (.../submission_view.tpl) (revision 14614) @@ -109,6 +109,15 @@ + + /> + + () + + + + + Index: branches/5.2.x/core/install/english.lang =================================================================== diff -u -N -r14606 -r14614 --- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14606) +++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14614) @@ -563,6 +563,7 @@ U3RvcCBXb3Jk U3ViamVjdA== U3VibWl0dGVkIE9u + U3VibWlzc2lvbiBOb3RpZmljYXRpb24gRW1haWw= U3VnZ2VzdGVkIENvcnJlY3Rpb24= UG9pbnRzIHRvIFNlY3Rpb24= VGFibGUgTmFtZSBpbiBEYXRhYmFzZSA= @@ -588,6 +589,8 @@ VHlwZQ== TWVhc3VyZXMgU3lzdGVt VXBsb2FkIEZpbGUgRnJvbSBMb2NhbCBQQw== + QWxsb3dlZCBGaWxlIEV4dGVuc2lvbnM= + TWF4aW11bSBGaWxlIFNpemU= VVJM TGluayB0byBFeHRlcm5hbCBVUkw= VXNlIEN1c3RvbSBNZW51IEljb24= @@ -1435,6 +1438,7 @@ Q2hlY2tib3g= VGV4dCBmaWVsZA== VGV4dCBhcmVh + RmlsZSBVcGxvYWQ= VW5jaGFuZ2Vk VW5pY29kZQ== VXBkYXRpbmcgQ29uZmlndXJhdGlvbg==