2011-06-10 21:55:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
|
|
* http://www.mysqldumper.net
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Forms_Config
|
|
|
|
* @version SVN: $Rev$
|
|
|
|
* @author $Author$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create form to input e-mail data in configuration
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Forms_Config
|
|
|
|
*/
|
|
|
|
class Application_Form_Config_Email extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Language translator
|
|
|
|
* @var Msd_Language
|
|
|
|
*/
|
|
|
|
protected $_lang;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration
|
2012-08-21 20:22:56 +00:00
|
|
|
* @var Msd_Config
|
2011-06-10 21:55:32 +00:00
|
|
|
*/
|
|
|
|
protected $_config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add elements to form.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
2012-08-04 17:09:48 +00:00
|
|
|
$this->_config = Msd_Registry::getConfig();
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->_lang = Msd_Language::getInstance();
|
|
|
|
$this->setDisableLoadDefaultDecorators(true);
|
|
|
|
$this->setDecorators(array('SubForm'));
|
|
|
|
$this->addDisplayGroupPrefixPath(
|
|
|
|
'Msd_Form_Decorator',
|
|
|
|
'Msd/Form/Decorator/'
|
|
|
|
);
|
2011-09-08 15:27:02 +00:00
|
|
|
|
|
|
|
if (isset($_POST['sendEmail']) && $_POST['sendEmail'] == 'y') {
|
|
|
|
$activateValidator = true;
|
|
|
|
} else {
|
|
|
|
$activateValidator = false;
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->_addActivateButton();
|
2011-09-08 15:27:02 +00:00
|
|
|
$this->_addSender($activateValidator);
|
|
|
|
$this->_addRecipient($activateValidator);
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->_addButtonAddRecipientCc();
|
2011-09-04 10:45:52 +00:00
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
// add Recipients CC
|
|
|
|
$ccElements = $this->_setRecipientCc(
|
2012-08-04 17:09:48 +00:00
|
|
|
$this->_config->getParam('email.RecipientCc'),
|
2011-09-08 15:27:02 +00:00
|
|
|
$activateValidator
|
2011-06-10 21:55:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->_addAttachement();
|
|
|
|
$this->_addEmailProgram();
|
2011-09-04 10:45:52 +00:00
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
// create and add display group
|
|
|
|
$elements = array(
|
|
|
|
'sendEmail',
|
|
|
|
'SenderAddress',
|
|
|
|
'SenderName',
|
|
|
|
'RecipientAddress',
|
|
|
|
'RecipientName',
|
2011-09-03 16:29:27 +00:00
|
|
|
'AddCc'
|
|
|
|
);
|
2011-06-10 21:55:32 +00:00
|
|
|
// add cc-recipients
|
|
|
|
if (count($ccElements)>0) {
|
|
|
|
$elements = array_merge(
|
|
|
|
$elements,
|
|
|
|
$ccElements
|
|
|
|
);
|
|
|
|
}
|
2011-09-03 16:29:27 +00:00
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
$elements = array_merge(
|
|
|
|
$elements,
|
|
|
|
array(
|
|
|
|
'attachBackup',
|
|
|
|
'Maxsize',
|
|
|
|
'MaxsizeUnit',
|
|
|
|
'Program'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addDisplayGroup(
|
|
|
|
$elements,
|
|
|
|
'email',
|
|
|
|
array(
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('DisplayGroup'),
|
|
|
|
'legend' => $this->_lang->getTranslator()->_('L_CONFIG_EMAIL')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$elements = array(
|
|
|
|
'SendmailCall'
|
|
|
|
);
|
|
|
|
$this->addDisplayGroup(
|
|
|
|
$elements,
|
|
|
|
'sendmailConfig',
|
|
|
|
array(
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('DisplayGroup'),
|
|
|
|
'legend' => $this->_lang->getTranslator()->_('L_SENDMAIL'),
|
|
|
|
'class' => 'sendmailConfig',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$elements = array(
|
|
|
|
'SMTPHost',
|
|
|
|
'SMTPPort',
|
|
|
|
'SMTPUserAuth',
|
|
|
|
'SMTPUser',
|
|
|
|
'SMTPPassword',
|
|
|
|
'SMTPUseSSL',
|
|
|
|
);
|
|
|
|
$this->addDisplayGroup(
|
|
|
|
$elements,
|
|
|
|
'smtpConfig',
|
|
|
|
array(
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('DisplayGroup'),
|
|
|
|
'legend' => $this->_lang->getTranslator()->_('L_SMTP'),
|
|
|
|
'class' => 'smtpConfig',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add e-mail activate button to form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _addActivateButton()
|
|
|
|
{
|
|
|
|
//Button send email
|
|
|
|
$this->addElement(
|
|
|
|
'radio',
|
|
|
|
'sendEmail',
|
|
|
|
array(
|
|
|
|
'class' => 'radio toggler',
|
|
|
|
'label' => 'L_SEND_MAIL_FORM',
|
|
|
|
'onclick' => "myToggle(this, 'y', 'emailToggle');",
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'multiOptions' => array(
|
|
|
|
'y' => 'L_YES',
|
|
|
|
'n' => 'L_NO',
|
|
|
|
),
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2011-09-03 16:29:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds line with sender inputs
|
|
|
|
*
|
2011-09-08 15:27:02 +00:00
|
|
|
* @param bool $activateValidator
|
|
|
|
*
|
2011-09-03 16:29:27 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2011-09-08 15:27:02 +00:00
|
|
|
private function _addSender($activateValidator)
|
2011-09-03 16:29:27 +00:00
|
|
|
{
|
|
|
|
//Sender email
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SenderAddress',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_EMAIL_SENDER',
|
|
|
|
'size' => 30,
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-09-03 16:29:27 +00:00
|
|
|
'decorators' => array('LineStart'),
|
|
|
|
'validators' => array('EmailAddress'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//Sender name
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SenderName',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_NAME',
|
|
|
|
'size' => 30,
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-09-03 16:29:27 +00:00
|
|
|
'decorators' => array('LineEnd'),
|
|
|
|
'validators' => array('NotEmpty'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
/**
|
2011-09-03 16:29:27 +00:00
|
|
|
* Add line with recipient name and e-mail
|
|
|
|
*
|
2011-09-08 15:27:02 +00:00
|
|
|
* @param bool $activateValidator
|
|
|
|
*
|
2011-09-03 16:29:27 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2011-09-08 15:27:02 +00:00
|
|
|
private function _addRecipient($activateValidator)
|
2011-09-03 16:29:27 +00:00
|
|
|
{
|
|
|
|
//Recipient email
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'RecipientAddress',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_EMAIL_RECIPIENT',
|
|
|
|
'size' => 30,
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-09-03 16:29:27 +00:00
|
|
|
'decorators' => array('LineStart'),
|
|
|
|
'validators' => array('EmailAddress'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//Recipient name
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'RecipientName',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_NAME',
|
|
|
|
'size' => 30,
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-09-03 16:29:27 +00:00
|
|
|
'decorators' => array('LineEnd'),
|
|
|
|
'validators' => array('NotEmpty'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add button to add a cc-recipient
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _addButtonAddRecipientCc()
|
|
|
|
{
|
|
|
|
$this->addElement(
|
|
|
|
'button',
|
|
|
|
'AddCc',
|
|
|
|
array(
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'content' =>
|
|
|
|
$this->getView()->getIcon('plus') . ' ' .
|
|
|
|
$this->_lang->getTranslator()->_('L_ADD_RECIPIENT'),
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
'escape' => false,
|
|
|
|
'label' => '',
|
|
|
|
'class' => 'Formbutton emailToggle',
|
|
|
|
'onclick' => "addEmailRecipientCc();",
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-08 15:27:02 +00:00
|
|
|
/**
|
2011-06-10 21:55:32 +00:00
|
|
|
* Add Cc-Recipients
|
|
|
|
*
|
2011-09-03 16:29:27 +00:00
|
|
|
* @param $recipientsCc
|
2011-09-08 15:27:02 +00:00
|
|
|
* @param bool $activateValidator
|
2011-09-03 16:29:27 +00:00
|
|
|
*
|
|
|
|
* @internal param array $configRecipientCc All Cc-Recipients
|
2011-06-10 21:55:32 +00:00
|
|
|
*
|
|
|
|
* @return array Element names to add to display group
|
|
|
|
*/
|
2011-09-08 15:27:02 +00:00
|
|
|
private function _setRecipientCc($recipientsCc, $activateValidator)
|
2011-06-10 21:55:32 +00:00
|
|
|
{
|
|
|
|
if ($recipientsCc === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($recipientsCc) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$elements = array();
|
|
|
|
foreach ($recipientsCc as $i => $recipient) {
|
|
|
|
//Recipient CC email
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'RecipientCc_'.$i.'_Address',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_EMAIL_CC',
|
|
|
|
'listsep' => ' ',
|
|
|
|
'size' => 30,
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-06-10 21:55:32 +00:00
|
|
|
'decorators' => array('LineStart'),
|
|
|
|
'validators' => array('EmailAddress'),
|
|
|
|
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//CC name
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'RecipientCc_'.$i.'_Name',
|
|
|
|
array(
|
|
|
|
'class' => 'text emailToggle',
|
|
|
|
'label' => 'L_NAME',
|
|
|
|
'listsep' => ' ',
|
|
|
|
'size' => 30,
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
2011-09-08 15:27:02 +00:00
|
|
|
'required' => $activateValidator,
|
2011-06-10 21:55:32 +00:00
|
|
|
'decorators' => array('LineMiddle'),
|
2011-09-03 16:29:27 +00:00
|
|
|
'validators' => array('NotEmpty'),
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//button delete recipient
|
|
|
|
$confirmDelete = sprintf(
|
|
|
|
$this->_lang->getTranslator()->_('L_CONFIRM_RECIPIENT_DELETE'),
|
|
|
|
$recipient['Name']
|
|
|
|
);
|
|
|
|
$confirmDelete = Msd_Html::getJsQuote($confirmDelete, true);
|
|
|
|
$this->addElement(
|
|
|
|
'button',
|
|
|
|
'DeleteCc_'.$i,
|
|
|
|
array(
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'content' =>
|
|
|
|
$this->getView()->getIcon('delete') . ' ' .
|
|
|
|
$this->_lang->getTranslator()->_('L_DELETE'),
|
|
|
|
'decorators' => array('LineEnd'),
|
|
|
|
'escape' => false,
|
|
|
|
'label' => '',
|
|
|
|
'class' => 'Formbutton emailToggle',
|
|
|
|
'onclick' =>
|
2011-09-04 10:45:52 +00:00
|
|
|
'if (!confirm("' . $confirmDelete . '")) return false;'
|
|
|
|
.' deleteEmailRecipientCc(' . $i .');',
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$elements = array_merge(
|
|
|
|
$elements,
|
|
|
|
array(
|
|
|
|
'RecipientCc_'.$i.'_Address',
|
|
|
|
'RecipientCc_'.$i.'_Name',
|
|
|
|
'DeleteCc_'.$i,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add line attachement and -size to form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _addAttachement()
|
|
|
|
{
|
|
|
|
|
|
|
|
//Attach backup
|
|
|
|
$this->addElement(
|
|
|
|
'radio',
|
|
|
|
'attachBackup',
|
|
|
|
array(
|
|
|
|
'class' => 'radio emailToggle toggler',
|
|
|
|
'label' => 'L_ATTACH_BACKUP',
|
|
|
|
'onclick' => "myToggle(this, 'y', 'attachToggle');",
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'multiOptions' => array(
|
|
|
|
'y' => 'L_YES',
|
|
|
|
'n' => 'L_NO',
|
|
|
|
),
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//Max filesize
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'Maxsize',
|
|
|
|
array(
|
|
|
|
'class' => 'text right emailToggle attachToggle',
|
|
|
|
'size' => 6,
|
|
|
|
'maxlength' => 6,
|
|
|
|
'label' => 'L_EMAIL_MAXSIZE',
|
|
|
|
'listsep' => ' ',
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('LineStart'),
|
|
|
|
'validators' => array('Digits'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
//Max filesize unit
|
|
|
|
$this->addElement(
|
|
|
|
'select',
|
|
|
|
'MaxsizeUnit',
|
|
|
|
array(
|
|
|
|
'class' => 'select emailToggle attachToggle',
|
|
|
|
'listsep' => ' ',
|
|
|
|
'multiOptions' => array(
|
|
|
|
'kb' => 'L_UNIT_KB',
|
|
|
|
'mb' => 'L_UNIT_MB',
|
|
|
|
),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('LineEnd'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add select for e-mail program
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _addEmailProgram()
|
|
|
|
{
|
|
|
|
//Mail program
|
|
|
|
$this->addElement(
|
|
|
|
'select',
|
|
|
|
'Program',
|
|
|
|
array(
|
|
|
|
'class' => 'select emailToggle',
|
|
|
|
'label' => 'L_MAILPROGRAM',
|
|
|
|
'id' => 'toggleEmailSettings',
|
|
|
|
'listsep' => ' ',
|
|
|
|
'multiOptions' => array(
|
|
|
|
'php' => 'L_PHPMAIL',
|
|
|
|
'sendmail' => 'L_SENDMAIL',
|
|
|
|
'smtp' => 'L_SMTP'
|
|
|
|
),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
'onchange' => 'toggleEmailProgram();',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SendmailCall',
|
|
|
|
array(
|
|
|
|
'class' => 'text',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_CALL'),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SMTPHost',
|
|
|
|
array(
|
|
|
|
'class' => 'text',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_SMTP_HOST'),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
2011-09-03 16:29:27 +00:00
|
|
|
'validators' => array('NotEmpty'),
|
2011-06-10 21:55:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SMTPPort',
|
|
|
|
array(
|
|
|
|
'class' => 'text',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_SMTP_PORT'),
|
|
|
|
'validators' => array('Digits'),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'radio',
|
|
|
|
'SMTPUserAuth',
|
|
|
|
array(
|
|
|
|
'class' => 'radio toggler',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_AUTHORIZE'),
|
|
|
|
'listsep' => ' ',
|
|
|
|
'multiOptions' => array(
|
|
|
|
'y' => 'L_YES',
|
|
|
|
'n' => 'L_NO',
|
|
|
|
),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
'onclick' => "myToggle(this, 'y', 'SMTPAuthToggle');",
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SMTPUser',
|
|
|
|
array(
|
|
|
|
'class' => 'text SMTPAuthToggle',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_USERNAME'),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
'rowclass' => 'SMTPAuth',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'SMTPPassword',
|
|
|
|
array(
|
|
|
|
'class' => 'text SMTPAuthToggle',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_PASSWORD'),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
'rowclass' => 'SMTPAuth',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->addElement(
|
|
|
|
'radio',
|
|
|
|
'SMTPUseSSL',
|
|
|
|
array(
|
|
|
|
'class' => 'radio',
|
|
|
|
'label' => $this->_lang->getTranslator()->_('L_USE_SSL'),
|
|
|
|
'listsep' => ' ',
|
|
|
|
'multiOptions' => array(
|
|
|
|
'y' => 'L_YES',
|
|
|
|
'n' => 'L_NO',
|
|
|
|
),
|
|
|
|
'disableLoadDefaultDecorators' => true,
|
|
|
|
'decorators' => array('Default'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts an multi array from flat element names and values
|
|
|
|
*
|
|
|
|
* @param array $data The values to extract index and values from
|
2012-10-27 13:56:04 +00:00
|
|
|
* @param bool $suppressArrayNotation
|
2011-06-10 21:55:32 +00:00
|
|
|
*
|
|
|
|
* @return array The converted array
|
|
|
|
*/
|
2012-10-27 13:56:04 +00:00
|
|
|
public function getValidValues($data, $suppressArrayNotation = false)
|
2011-06-10 21:55:32 +00:00
|
|
|
{
|
|
|
|
$values = parent::getValidValues($data, true);
|
|
|
|
$newArray = array();
|
|
|
|
while (false !== (list($key, $value) = each($values))) {
|
2011-09-03 16:29:27 +00:00
|
|
|
if (substr($key, 0, 12) != 'RecipientCc_') {
|
2011-06-10 21:55:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
list($prefix, $index, $fieldKey) = explode('_', $key);
|
2011-09-03 16:29:27 +00:00
|
|
|
if (!isset($values['RecipientCc'])) {
|
2011-06-10 21:55:32 +00:00
|
|
|
$values[$prefix] = array();
|
|
|
|
}
|
2011-09-03 16:29:27 +00:00
|
|
|
if (!isset($values[$key])) {
|
|
|
|
$values[$key] = array();
|
2011-06-10 21:55:32 +00:00
|
|
|
}
|
|
|
|
$newArray[$index][$fieldKey] = $value;
|
|
|
|
unset($values[$key]);
|
|
|
|
}
|
|
|
|
|
2011-09-03 16:29:27 +00:00
|
|
|
$values['RecipientCc'] = array_values($newArray);
|
2011-09-04 10:45:52 +00:00
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
return $values;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set default values
|
|
|
|
*
|
2012-10-27 13:56:04 +00:00
|
|
|
* @param array $defaults
|
2011-06-10 21:55:32 +00:00
|
|
|
*
|
|
|
|
* @return Zend_Form
|
|
|
|
*/
|
2012-10-27 13:56:04 +00:00
|
|
|
public function setDefaults(array $defaults)
|
2011-06-10 21:55:32 +00:00
|
|
|
{
|
|
|
|
if (isset($defaults['email']['RecipientCc'])) {
|
|
|
|
$recipientCc = array();
|
|
|
|
while (false !== (list($recipientCcId, $recipientCcData) =
|
|
|
|
each($defaults['email']['RecipientCc']))) {
|
|
|
|
foreach ($recipientCcData as $key => $value) {
|
|
|
|
$recipientCc['RecipientCc_' .
|
|
|
|
$recipientCcId . '_' . $key] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($defaults['email']['RecipientCc']);
|
|
|
|
$defaults['email'] = array_merge(
|
|
|
|
$defaults['email'],
|
|
|
|
$recipientCc
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return parent::setDefaults($defaults);
|
|
|
|
}
|
2011-09-03 16:29:27 +00:00
|
|
|
|
2011-06-10 21:55:32 +00:00
|
|
|
/**
|
|
|
|
* Set input default value
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param string $value
|
|
|
|
*
|
2012-08-21 20:22:56 +00:00
|
|
|
* @return Zend_Form
|
2011-06-10 21:55:32 +00:00
|
|
|
*/
|
|
|
|
public function setDefault($name, $value)
|
|
|
|
{
|
|
|
|
$name = str_replace('.', '_', $name);
|
|
|
|
parent::setDefault($name, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|