Changeset View
Standalone View
core/units/forms/submission_log/submission_log_eh.php
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnNew(kEvent $event) | protected function OnNew(kEvent $event) | ||||
{ | { | ||||
parent::OnNew($event); | parent::OnNew($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
/** @var kDBItem $form_submission */ | |||||
$form_submission = $this->Application->recallObject('formsubs'); | $form_submission = $this->Application->recallObject('formsubs'); | ||||
/* @var $form_submission kDBItem */ | |||||
/** @var FormSubmissionHelper $form_submission_helper */ | |||||
$form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | $form_submission_helper = $this->Application->recallObject('FormSubmissionHelper'); | ||||
/* @var $form_submission_helper FormSubmissionHelper */ | |||||
/** @var kDBItem $form */ | |||||
$form =& $form_submission_helper->getForm($form_submission); | $form =& $form_submission_helper->getForm($form_submission); | ||||
/* @var $form kDBItem */ | |||||
$from_email = $form->GetDBField('ReplyFromEmail'); | $from_email = $form->GetDBField('ReplyFromEmail'); | ||||
$to_email = $form_submission_helper->getFieldByRole($form_submission, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | $to_email = $form_submission_helper->getFieldByRole($form_submission, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); | ||||
if ( $this->Application->GetVar('client_mode') ) { | if ( $this->Application->GetVar('client_mode') ) { | ||||
// debug code for sending email from client | // debug code for sending email from client | ||||
$object->SetDBField('FromEmail', $to_email); | $object->SetDBField('FromEmail', $to_email); | ||||
$object->SetDBField('ToEmail', $from_email); | $object->SetDBField('ToEmail', $from_email); | ||||
} | } | ||||
else { | else { | ||||
$object->SetDBField('FromEmail', $from_email); | $object->SetDBField('FromEmail', $from_email); | ||||
$object->SetDBField('ToEmail', $to_email); | $object->SetDBField('ToEmail', $to_email); | ||||
} | } | ||||
$object->SetDBField('Cc', $form->GetDBField('ReplyCc')); | $object->SetDBField('Cc', $form->GetDBField('ReplyCc')); | ||||
$object->SetDBField('Bcc', $form->GetDBField('ReplyBcc')); | $object->SetDBField('Bcc', $form->GetDBField('ReplyBcc')); | ||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
/** @var kDBItem $org_message */ | |||||
$org_message = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); | $org_message = $this->Application->recallObject($event->Prefix . '.-item', 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 130 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 130 characters | |||||
/* @var $org_message kDBItem */ | |||||
$org_message->Load(array_shift($ids)); | $org_message->Load(array_shift($ids)); | ||||
// client could reply from different email, so compare to admin email! | // client could reply from different email, so compare to admin email! | ||||
if ( $org_message->GetDBField('ToEmail') == $from_email ) { | if ( $org_message->GetDBField('ToEmail') == $from_email ) { | ||||
// can reply only to client email, not own :) | // can reply only to client email, not own :) | ||||
// transform subject | // transform subject | ||||
$message_subject = $org_message->GetDBField('Subject'); | $message_subject = $org_message->GetDBField('Subject'); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | |||||
function OnResendReply($event) | function OnResendReply($event) | ||||
{ | { | ||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if (!$ids) { | if (!$ids) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject( Array('skip_autoload' => true) ); | $object = $event->getObject( Array('skip_autoload' => true) ); | ||||
Expected 0 spaces before closing bracket; 1 found Lint: CodingStandard.Functions.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
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" | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
/* @var $object kDBItem */ | |||||
$sql = 'SELECT f.ReplyFromEmail, sl.' . $object->IDField . ' | $sql = 'SELECT f.ReplyFromEmail, sl.' . $object->IDField . ' | ||||
FROM ' . $object->TableName . ' sl | FROM ' . $object->TableName . ' sl | ||||
JOIN ' . $this->Application->getUnitOption('formsubs', 'TableName') . ' fs ON fs.FormSubmissionId = sl.FormSubmissionId | JOIN ' . $this->Application->getUnitOption('formsubs', 'TableName') . ' fs ON fs.FormSubmissionId = sl.FormSubmissionId | ||||
JOIN ' . $this->Application->getUnitOption('form', 'TableName') . ' f ON f.FormId = fs.FormId | JOIN ' . $this->Application->getUnitOption('form', 'TableName') . ' f ON f.FormId = fs.FormId | ||||
WHERE sl.' . $object->IDField . ' IN (' . implode(',', $ids) . ')'; | WHERE sl.' . $object->IDField . ' IN (' . implode(',', $ids) . ')'; | ||||
$reply_emails = $this->Conn->GetCol($sql, $object->IDField); | $reply_emails = $this->Conn->GetCol($sql, $object->IDField); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Validates email recipients | * Validates email recipients | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function _validateRecipients($event) | function _validateRecipients($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
/** @var kEmailSendingHelper $esender */ | |||||
$esender = $this->Application->recallObject('EmailSender'); | $esender = $this->Application->recallObject('EmailSender'); | ||||
/* @var $esender kEmailSendingHelper */ | |||||
$cc = $object->GetDBField('Cc'); | $cc = $object->GetDBField('Cc'); | ||||
if ($cc && ($esender->GetRecipients($cc) === false)) { | if ($cc && ($esender->GetRecipients($cc) === false)) { | ||||
$object->SetError('Cc', 'invalid_format'); | $object->SetError('Cc', 'invalid_format'); | ||||
} | } | ||||
$bcc = $object->GetDBField('Bcc'); | $bcc = $object->GetDBField('Bcc'); | ||||
Show All 31 Lines | |||||
if ($this->Application->GetVar('client_mode')) { | if ($this->Application->GetVar('client_mode')) { | ||||
return ; | return ; | ||||
} | } | ||||
if (!$object->GetDBField('VerifyCode')) { | if (!$object->GetDBField('VerifyCode')) { | ||||
$this->_generateVerificationCode($object); | $this->_generateVerificationCode($object); | ||||
} | } | ||||
/** @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_submission = $form_submission_helper->getSubmissionFromLog($object); | $form_submission = $form_submission_helper->getSubmissionFromLog($object); | ||||
$form =& $form_submission_helper->getForm($form_submission); | $form =& $form_submission_helper->getForm($form_submission); | ||||
$send_params = Array ( | $send_params = Array ( | ||||
'from_name' => $form->GetDBField('ReplyFromName'), | 'from_name' => $form->GetDBField('ReplyFromName'), | ||||
'from_email' => $object->GetDBField('FromEmail'), | 'from_email' => $object->GetDBField('FromEmail'), | ||||
'to_email' => $object->GetDBField('ToEmail'), | 'to_email' => $object->GetDBField('ToEmail'), | ||||
'subject' => $object->GetDBField('Subject'), | 'subject' => $object->GetDBField('Subject'), | ||||
'message' => $object->GetDBField('Message'), | 'message' => $object->GetDBField('Message'), | ||||
); | ); | ||||
$to_name = $form_submission_helper->getFieldByRole($form_submission, SubmissionFormField::COMMUNICATION_ROLE_NAME); | $to_name = $form_submission_helper->getFieldByRole($form_submission, SubmissionFormField::COMMUNICATION_ROLE_NAME); | ||||
if ($to_name) { | if ($to_name) { | ||||
$send_params['to_name'] = $to_name; | $send_params['to_name'] = $to_name; | ||||
} | } | ||||
/** @var kEmailSendingHelper $esender */ | |||||
$esender = $this->Application->recallObject('EmailSender'); | $esender = $this->Application->recallObject('EmailSender'); | ||||
/* @var $esender kEmailSendingHelper */ | |||||
$esender->SetReturnPath( $form->GetDBField('BounceEmail') ); | $esender->SetReturnPath( $form->GetDBField('BounceEmail') ); | ||||
if ($object->GetDBField('Cc')) { | if ($object->GetDBField('Cc')) { | ||||
$recipients = $esender->GetRecipients( $object->GetDBField('Cc') ); | $recipients = $esender->GetRecipients( $object->GetDBField('Cc') ); | ||||
foreach ($recipients as $recipient_info) { | foreach ($recipients as $recipient_info) { | ||||
$esender->AddCc($recipient_info['Email'], $recipient_info['Name']); | $esender->AddCc($recipient_info['Email'], $recipient_info['Name']); | ||||
Show All 21 Lines | |||||
// mark as sent after sending is finished | // mark as sent after sending is finished | ||||
$object->SetDBField('SentStatus', SUBMISSION_LOG_SENT); | $object->SetDBField('SentStatus', SUBMISSION_LOG_SENT); | ||||
// reset bounce status before (re-)sending | // reset bounce status before (re-)sending | ||||
$object->SetDBField('BounceInfo', NULL); | $object->SetDBField('BounceInfo', NULL); | ||||
$object->SetDBField('BounceDate_date', NULL); | $object->SetDBField('BounceDate_date', NULL); | ||||
$object->SetDBField('BounceDate_time', NULL); | $object->SetDBField('BounceDate_time', NULL); | ||||
if ($object->GetDBField('DraftId')) { | if ($object->GetDBField('DraftId')) { | ||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject('draft_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject('draft_TempHandler', 'kTempTablesHandler'); | ||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems('draft', '', Array ($object->GetDBField('DraftId'))); | $temp_handler->DeleteItems('draft', '', Array ($object->GetDBField('DraftId'))); | ||||
$object->SetDBField('DraftId', 0); | $object->SetDBField('DraftId', 0); | ||||
} | } | ||||
$object->Update(); | $object->Update(); | ||||
} | } | ||||
/** | /** | ||||
* Sends new email after log record was created | * Sends new email after log record was created | ||||
* Updates last update time for submission | * Updates last update time for submission | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemCreate(kEvent $event) | protected function OnAfterItemCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemCreate($event); | parent::OnAfterItemCreate($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->_sendEmail($object); // send email | $this->_sendEmail($object); // send email | ||||
$this->_updateSubmission($event); | $this->_updateSubmission($event); | ||||
$reply_to = $object->GetDBField('ReplyTo'); | $reply_to = $object->GetDBField('ReplyTo'); | ||||
if ( !$reply_to ) { | if ( !$reply_to ) { | ||||
$reply_to = $this->_getLastMessageId($event, !$this->Application->GetVar('client_mode')); | $reply_to = $this->_getLastMessageId($event, !$this->Application->GetVar('client_mode')); | ||||
} | } | ||||
if ( $reply_to ) { | if ( $reply_to ) { | ||||
// this is reply to other message -> mark it as replied | // this is reply to other message -> mark it as replied | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/** @var kDBItem $org_message */ | |||||
$org_message = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); | $org_message = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); | ||||
Line exceeds 120 characters; contains 130 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 130 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 | |||||
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" | |||||
/* @var $org_message kDBItem */ | |||||
$org_message->Load($reply_to); | $org_message->Load($reply_to); | ||||
$org_message->SetDBField('ReplyStatus', SUBMISSION_LOG_REPLIED); | $org_message->SetDBField('ReplyStatus', SUBMISSION_LOG_REPLIED); | ||||
$org_message->Update(); | $org_message->Update(); | ||||
} | } | ||||
if ( $this->Application->GetVar('client_mode') ) { | if ( $this->Application->GetVar('client_mode') ) { | ||||
// new reply from client received -> send notification about it | // new reply from client received -> send notification about it | ||||
$this->Application->emailAdmin('FORM.SUBMISSION.REPLY.FROM.USER'); | $this->Application->emailAdmin('FORM.SUBMISSION.REPLY.FROM.USER'); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns last message id (client OR admin) | * Returns last message id (client OR admin) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param bool $from_client | * @param bool $from_client | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
function _getLastMessageId($event, $from_client = false) | function _getLastMessageId($event, $from_client = false) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
/** @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_submission = $form_submission_helper->getSubmissionFromLog($object); | $form_submission = $form_submission_helper->getSubmissionFromLog($object); | ||||
$form =& $form_submission_helper->getForm($form_submission); | $form =& $form_submission_helper->getForm($form_submission); | ||||
$reply_email = $form->GetDBField('ReplyFromEmail'); | $reply_email = $form->GetDBField('ReplyFromEmail'); | ||||
$sql = 'SELECT MAX(' . $object->IDField . ') | $sql = 'SELECT MAX(' . $object->IDField . ') | ||||
FROM ' . $object->TableName . ' | FROM ' . $object->TableName . ' | ||||
Show All 9 Lines | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemUpdate(kEvent $event) | protected function OnAfterItemUpdate(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemUpdate($event); | parent::OnAfterItemUpdate($event); | ||||
$this->_updateSubmission($event); | $this->_updateSubmission($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
// send out email event to admin for bouncing | // send out email event to admin for bouncing | ||||
$sent_status = $object->GetDBField('SentStatus'); | $sent_status = $object->GetDBField('SentStatus'); | ||||
if ( $object->GetOriginalField('SentStatus') != $sent_status && $sent_status == SUBMISSION_LOG_BOUNCE ) { | if ( $object->GetOriginalField('SentStatus') != $sent_status && $sent_status == SUBMISSION_LOG_BOUNCE ) { | ||||
$this->Application->emailAdmin('FORM.SUBMISSION.REPLY.FROM.USER.BOUNCED'); | $this->Application->emailAdmin('FORM.SUBMISSION.REPLY.FROM.USER.BOUNCED'); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Sets last sent/reply dates based on field changes in log record | * Sets last sent/reply dates based on field changes in log record | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function _updateStatusDates($event) | function _updateStatusDates($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$now = adodb_mktime(); | $now = adodb_mktime(); | ||||
$sent_status = $object->GetDBField('SentStatus'); | $sent_status = $object->GetDBField('SentStatus'); | ||||
if (($event->Special != 'merge') && ($sent_status == SUBMISSION_LOG_SENT) && ($sent_status != $object->GetOriginalField('SentStatus'))) { | if (($event->Special != 'merge') && ($sent_status == SUBMISSION_LOG_SENT) && ($sent_status != $object->GetOriginalField('SentStatus'))) { | ||||
// sent status was set | // sent status was set | ||||
$object->SetDBField('SentOn_date', $now); | $object->SetDBField('SentOn_date', $now); | ||||
$object->SetDBField('SentOn_time', $now); | $object->SetDBField('SentOn_time', $now); | ||||
Show All 9 Lines | |||||
/** | /** | ||||
* Sets last updated field for form submission | * Sets last updated field for form submission | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function _updateSubmission($event) | function _updateSubmission($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
/** @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_submission = $form_submission_helper->getSubmissionFromLog($object); | $form_submission = $form_submission_helper->getSubmissionFromLog($object); | ||||
// 1. set last updated | // 1. set last updated | ||||
$last_updated = max ($object->GetDBField('SentOn'), $object->GetDBField('RepliedOn')); | $last_updated = max ($object->GetDBField('SentOn'), $object->GetDBField('RepliedOn')); | ||||
if ($form_submission->GetDBField('LastUpdatedOn') < $last_updated) { | if ($form_submission->GetDBField('LastUpdatedOn') < $last_updated) { | ||||
// don't set smaller last update, that currenly set | // don't set smaller last update, that currenly set | ||||
Show All 25 Lines | |||||
/** | /** | ||||
* Saves current unsent message as draft | * Saves current unsent message as draft | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnSaveDraft($event) | function OnSaveDraft($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject( Array('skip_autoload' => true) ); | $object = $event->getObject( 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" | |||||
Expected 0 spaces before closing bracket; 1 found Lint: CodingStandard.Functions.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
/* @var $object kDBItem */ | |||||
/** @var kDBItem $draft */ | |||||
$draft = $this->Application->recallObject('draft', null, Array('skip_autoload' => true)); | $draft = $this->Application->recallObject('draft', 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" | |||||
/* @var $draft kDBItem */ | |||||
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | ||||
if ($items_info) { | if ($items_info) { | ||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->setID($id); | $object->setID($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
Show All 23 Lines | |||||
/** | /** | ||||
* Uses found draft instead of submission reply body | * Uses found draft instead of submission reply body | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnUseDraft($event) | function OnUseDraft($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject( Array('skip_autoload' => true) ); | $object = $event->getObject( Array('skip_autoload' => true) ); | ||||
Expected 0 spaces before closing bracket; 1 found Lint: CodingStandard.Functions.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
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" | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
/* @var $object kDBItem */ | |||||
/** @var kDBItem $draft */ | |||||
$draft = $this->Application->recallObject('draft', null, Array('skip_autoload' => true)); | $draft = $this->Application->recallObject('draft', 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" | |||||
/* @var $draft kDBItem */ | |||||
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | ||||
if ($items_info) { | if ($items_info) { | ||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->setID($id); | $object->setID($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
Show All 17 Lines | |||||
/** | /** | ||||
* Deletes draft, that matches given user and form submission | * Deletes draft, that matches given user and form submission | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnDeleteDraft($event) | function OnDeleteDraft($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject( Array('skip_autoload' => true) ); | $object = $event->getObject( Array('skip_autoload' => true) ); | ||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
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" | |||||
Expected 0 spaces before closing bracket; 1 found Lint: CodingStandard.Functions.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
/* @var $object kDBItem */ | |||||
/** @var kDBItem $draft */ | |||||
$draft = $this->Application->recallObject('draft', null, Array('skip_autoload' => true)); | $draft = $this->Application->recallObject('draft', 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" | |||||
/* @var $draft kDBItem */ | |||||
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | ||||
if ($items_info) { | if ($items_info) { | ||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->setID($id); | $object->setID($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$object->SetDBField('DraftId', 0); | $object->SetDBField('DraftId', 0); | ||||
$load_keys = Array ( | $load_keys = Array ( | ||||
'FormSubmissionId' => $object->GetDBField('FormSubmissionId'), | 'FormSubmissionId' => $object->GetDBField('FormSubmissionId'), | ||||
'CreatedById' => $this->Application->RecallVar('user_id'), | 'CreatedById' => $this->Application->RecallVar('user_id'), | ||||
); | ); | ||||
// get existing draft for given submission and user | // get existing draft for given submission and user | ||||
$draft->Load($load_keys); | $draft->Load($load_keys); | ||||
if ($draft->isLoaded()) { | if ($draft->isLoaded()) { | ||||
No blank line found before "if" control structure Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject('draft_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject('draft_TempHandler', 'kTempTablesHandler'); | ||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems('draft', '', Array ($draft->GetID())); | $temp_handler->DeleteItems('draft', '', Array ($draft->GetID())); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); | $this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); | ||||
$event->redirect = false; | $event->redirect = false; | ||||
} | } | ||||
} | } |
No blank line found before "if" control structure