'doNew',
'insert' => 'doInsert',
'cancel' => 'doBack',
'thank' => 'doThank',
);
function doInsert()
{
$form = $this->_getNewForm();
if ($form->validate()) {
$this->DBObj->initFromForm($form);
$id = $this->DBObj->insert();
$this->_sendMail($id);
$this->doBack();
} else {
$form->exec();
}
return true;
}
function doBack()
{
skHTTP::redirect(BASE_URL . '/' . CURR_PAGE_FULL . '?action=thank');
}
function doThank()
{
$this->Doc->addContent(array('tpl' => 'SponsorApplication/thank.tpl'));
}
protected function _sendMail($id)
{
$data = $this->DBObj->getFromDB($id);
if (is_array($data) && !empty($data)) {
$form = $this->_getEditForm();
$body = "New Sponsor Application has been submitted at MNCAR.org\n
\n
";
//$body .= "Received: " . date('d M, Y', mktime($data['added'])) . "\n";
unset($data['added'], $data['changed'], $data['id']);
foreach ($data as $key => $value) {
$el = $form->getElement($key);
$body .= $el->getLabel() . ": {$value}\n
";
}
$body .= "\n
\n
View Application";
$admin_email = Settings::getAdminEmails('admin_email');
$headers = "From: " . Settings::get('admin_email_from') . "\n";
$headers .= "Content-type: text/html\n";
foreach ($admin_email as $email) {
mail($email, 'MNCAR Sponsor Application', $body, $headers);
}
}
return true;
}
}