Changeset View
Changeset View
Standalone View
Standalone View
core/units/forms/form_submissions/form_submissions_eh.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
function OnBuildFormFields($event) | function OnBuildFormFields($event) | ||||
{ | { | ||||
$form_id = $this->Application->GetVar('form_id'); | $form_id = $this->Application->GetVar('form_id'); | ||||
if (!$form_id) return ; | if (!$form_id) return ; | ||||
$conf_fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); | $conf_fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); | ||||
$conf_grids = $this->Application->getUnitOption($event->Prefix, 'Grids'); | $conf_grids = $this->Application->getUnitOption($event->Prefix, 'Grids'); | ||||
/** @var InpCustomFieldsHelper $helper */ | |||||
$helper = $this->Application->recallObject('InpCustomFieldsHelper'); | $helper = $this->Application->recallObject('InpCustomFieldsHelper'); | ||||
/* @var $helper InpCustomFieldsHelper */ | |||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM ' . TABLE_PREFIX . 'FormFields | FROM ' . TABLE_PREFIX . 'FormFields | ||||
WHERE FormId = ' . (int)$form_id . ' | WHERE FormId = ' . (int)$form_id . ' | ||||
ORDER BY Priority DESC'; | ORDER BY Priority DESC'; | ||||
$fields = $this->Conn->Query($sql, 'FormFieldId'); | $fields = $this->Conn->Query($sql, 'FormFieldId'); | ||||
$use_options = Array ('radio', 'select', 'checkbox'); | $use_options = Array ('radio', 'select', 'checkbox'); | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetCustomQuery(kEvent $event) | protected function SetCustomQuery(kEvent $event) | ||||
{ | { | ||||
parent::SetCustomQuery($event); | parent::SetCustomQuery($event); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$object->addFilter('form_filter', '%1$s.FormId = ' . (int)$this->Application->GetVar('form_id')); | $object->addFilter('form_filter', '%1$s.FormId = ' . (int)$this->Application->GetVar('form_id')); | ||||
} | } | ||||
/** | /** | ||||
* Allows user to see it's last feedback form data | * Allows user to see it's last feedback form data | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
Show All 26 Lines | |||||
protected function OnCreate(kEvent $event) | protected function OnCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnCreate($event); | parent::OnCreate($event); | ||||
if ( $event->status != kEvent::erSUCCESS ) { | if ( $event->status != kEvent::erSUCCESS ) { | ||||
return; | return; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
// allows user to view only it's last submission | // allows user to view only it's last submission | ||||
$this->Application->StoreVar('last_submission_id', $object->GetID()); | $this->Application->StoreVar('last_submission_id', $object->GetID()); | ||||
/** @var FormSubmissionHelper $form_submission_helper */ | |||||
$form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | $form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | ||||
/* @var $form_submission_helper FormSubmissionHelper */ | |||||
$form =& $form_submission_helper->getForm($object); | $form =& $form_submission_helper->getForm($object); | ||||
$notify_email = $form->GetDBField('SubmitNotifyEmail'); | $notify_email = $form->GetDBField('SubmitNotifyEmail'); | ||||
if ( $notify_email ) { | if ( $notify_email ) { | ||||
$send_params = Array ( | $send_params = Array ( | ||||
'to_name' => $notify_email, | 'to_name' => $notify_email, | ||||
'to_email' => $notify_email, | 'to_email' => $notify_email, | ||||
); | ); | ||||
$this->Application->emailAdmin('FORM.SUBMITTED', null, $send_params); | $this->Application->emailAdmin('FORM.SUBMITTED', null, $send_params); | ||||
} | } | ||||
else { | else { | ||||
$this->Application->emailAdmin('FORM.SUBMITTED'); | $this->Application->emailAdmin('FORM.SUBMITTED'); | ||||
} | } | ||||
// $this->Application->emailUser('FORM.SUBMITTED', null, Array ('to_email' => '')); | // $this->Application->emailUser('FORM.SUBMITTED', null, Array ('to_email' => '')); | ||||
$event->SetRedirectParam('opener', 's'); | $event->SetRedirectParam('opener', 's'); | ||||
$event->SetRedirectParam('m_cat_id', 0); | $event->SetRedirectParam('m_cat_id', 0); | ||||
/** @var kDBItem $theme */ | |||||
$theme = $this->Application->recallObject('theme.current'); | $theme = $this->Application->recallObject('theme.current'); | ||||
/* @var $theme kDBItem */ | |||||
$template = $this->Application->unescapeRequestVariable($this->Application->GetVar('success_template')); | $template = $this->Application->unescapeRequestVariable($this->Application->GetVar('success_template')); | ||||
$alias_template = $theme->GetField('TemplateAliases', $template); | $alias_template = $theme->GetField('TemplateAliases', $template); | ||||
$event->redirect = $alias_template ? $alias_template : $template; | $event->redirect = $alias_template ? $alias_template : $template; | ||||
} | } | ||||
/** | /** | ||||
* Processes Captcha code | * Processes Captcha code | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemCreate(kEvent $event) | protected function OnBeforeItemCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemCreate($event); | parent::OnBeforeItemCreate($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$object->SetDBField('IPAddress', $this->Application->getClientIp()); | $object->SetDBField('IPAddress', $this->Application->getClientIp()); | ||||
if ( !$object->GetDBField('ReferrerURL') ) { | if ( !$object->GetDBField('ReferrerURL') ) { | ||||
$referrer = $this->Application->GetVar('original_referrer'); | $referrer = $this->Application->GetVar('original_referrer'); | ||||
if ( !$referrer ) { | if ( !$referrer ) { | ||||
$base_url = preg_quote($this->Application->BaseURL(), '/'); | $base_url = preg_quote($this->Application->BaseURL(), '/'); | ||||
$referrer = preg_replace('/^' . $base_url . '/', '/', $_SERVER['HTTP_REFERER'], 1); | $referrer = preg_replace('/^' . $base_url . '/', '/', $_SERVER['HTTP_REFERER'], 1); | ||||
} | } | ||||
$object->SetDBField('ReferrerURL', $referrer); | $object->SetDBField('ReferrerURL', $referrer); | ||||
} | } | ||||
/** @var FormSubmissionHelper $form_submission_helper */ | |||||
$form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | $form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | ||||
/* @var $form_submission_helper FormSubmissionHelper */ | |||||
$form =& $form_submission_helper->getForm($object); | $form =& $form_submission_helper->getForm($object); | ||||
// validate captcha code | // validate captcha code | ||||
if ( $form->GetDBField('UseSecurityImage') && !$this->Application->LoggedIn() ) { | if ( $form->GetDBField('UseSecurityImage') && !$this->Application->LoggedIn() ) { | ||||
/** @var kCaptchaHelper $captcha_helper */ | |||||
$captcha_helper = $this->Application->recallObject('CaptchaHelper'); | $captcha_helper = $this->Application->recallObject('CaptchaHelper'); | ||||
/* @var $captcha_helper kCaptchaHelper */ | |||||
$captcha_helper->validateCode($event, false); | $captcha_helper->validateCode($event, false); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Checks, that target submission was selected for merging | * Checks, that target submission was selected for merging | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemUpdate(kEvent $event) | protected function OnBeforeItemUpdate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemUpdate($event); | parent::OnBeforeItemUpdate($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$object->setRequired('MergeToSubmission', $object->GetDBField('IsMergeToSubmission')); | $object->setRequired('MergeToSubmission', $object->GetDBField('IsMergeToSubmission')); | ||||
} | } | ||||
/** | /** | ||||
* Passes form_id, when using "Prev"/"Next" toolbar buttons | * Passes form_id, when using "Prev"/"Next" toolbar buttons | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | |||||
protected function OnAfterItemLoad(kEvent $event) | protected function OnAfterItemLoad(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemLoad($event); | parent::OnAfterItemLoad($event); | ||||
if ($event->Special == 'merge-to') { | if ($event->Special == 'merge-to') { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$form_id = $object->GetDBField('FormId'); | $form_id = $object->GetDBField('FormId'); | ||||
$email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | $email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | ||||
if (!$email_field) { | if (!$email_field) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $merge_to */ | |||||
$merge_to = $this->Application->recallObject($event->Prefix . '.merge-to', null, Array ('skip_autoload' => true)); | $merge_to = $this->Application->recallObject($event->Prefix . '.merge-to', null, Array ('skip_autoload' => true)); | ||||
Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
Line exceeds 120 characters; contains 126 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 126 characters | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
/* @var $merge_to kDBItem */ | |||||
$sql = $merge_to->GetSelectSQL() . ' WHERE (FormId = ' . $form_id . ') AND (' . $email_field . ' = ' . $this->Conn->qstr( $object->GetDBField($email_field) ) . ')'; | $sql = $merge_to->GetSelectSQL() . ' WHERE (FormId = ' . $form_id . ') AND (' . $email_field . ' = ' . $this->Conn->qstr( $object->GetDBField($email_field) ) . ')'; | ||||
$submissions = $this->Conn->Query($sql, $object->IDField); | $submissions = $this->Conn->Query($sql, $object->IDField); | ||||
// remove this submission | // remove this submission | ||||
unset($submissions[ $object->GetID() ]); | unset($submissions[ $object->GetID() ]); | ||||
if (!$submissions) { | if (!$submissions) { | ||||
return ; | return ; | ||||
} | } | ||||
$options = Array (); | $options = Array (); | ||||
$name_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_NAME); | $name_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_NAME); | ||||
$subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT); | $subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT); | ||||
/** @var kDBItem $language */ | |||||
$language = $this->Application->recallObject('lang.current'); | $language = $this->Application->recallObject('lang.current'); | ||||
/* @var $language kDBItem */ | |||||
$date_format = $language->GetDBField('DateFormat'); | $date_format = $language->GetDBField('DateFormat'); | ||||
foreach ($submissions as $submission_id => $submission_data) { | foreach ($submissions as $submission_id => $submission_data) { | ||||
$option_title = ''; // SenderName (email@address.com) - Subject (06/29/2010) | $option_title = ''; // SenderName (email@address.com) - Subject (06/29/2010) | ||||
$merge_to->LoadFromHash($submission_data); | $merge_to->LoadFromHash($submission_data); | ||||
if ($name_field) { | if ($name_field) { | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnUpdate(kEvent $event) | protected function OnUpdate(kEvent $event) | ||||
{ | { | ||||
parent::OnUpdate($event); | parent::OnUpdate($event); | ||||
if ($event->status == kEvent::erSUCCESS) { | if ($event->status == kEvent::erSUCCESS) { | ||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$merge_to = $object->GetDBField('MergeToSubmission'); | $merge_to = $object->GetDBField('MergeToSubmission'); | ||||
if (!$merge_to) { | if (!$merge_to) { | ||||
return ; | return ; | ||||
} | } | ||||
$form_id = $object->GetDBField('FormId'); | $form_id = $object->GetDBField('FormId'); | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM ' . TABLE_PREFIX . 'Forms | FROM ' . TABLE_PREFIX . 'Forms | ||||
WHERE FormId = ' . $form_id; | WHERE FormId = ' . $form_id; | ||||
$form_info = $this->Conn->GetRow($sql); | $form_info = $this->Conn->GetRow($sql); | ||||
/** @var kDBItem $reply */ | |||||
$reply = $this->Application->recallObject('submission-log.merge', null, Array ('skip_autoload' => true)); | $reply = $this->Application->recallObject('submission-log.merge', null, Array ('skip_autoload' => true)); | ||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
Line exceeds 120 characters; contains 121 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 121 characters | |||||
/* @var $reply kDBItem */ | |||||
$email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | $email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | ||||
$subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT); | $subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT); | ||||
$body_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_BODY); | $body_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_BODY); | ||||
$reply->SetDBField('FormSubmissionId', $merge_to); | $reply->SetDBField('FormSubmissionId', $merge_to); | ||||
if ($email_field) { | if ($email_field) { | ||||
Show All 28 Lines |
PHP keywords must be lowercase; expected "array" but found "Array"