addColumn('no', 'no') ->addColumn('text', 'name', array('orderBy' => 'name')) ->addColumn('email', 'email', array('orderBy' => 'email')) ->addColumn('options', 'options'); return $this; } protected function _getNewForm() { $form = parent::_getNewForm(); $form->password->setRequired(); $form->confirmPassword->setRequired(); return $form; } /** * @param Qs_Form $form * * @return $this|App_Application_User_AdminView */ protected function _bindPasswordFields($form) { parent::_bindPasswordFields($form); $form->addElement( 'checkbox', 'sendReviewerNotification', array( 'label' => 'Send Reviewer Email Notification', 'decoration' => 'simple', ) ); $form->getElement('sendReviewerNotification')->addValidator( 'Callback', true, array( array($this, 'validateNotificationCheckbox') ) ); /** @var Zend_Validate_Callback $callback */ $callback = $form->getElement('sendReviewerNotification')->getValidator('Callback'); $callback->setMessage( 'Password must be filled out', Zend_Validate_Callback::INVALID_VALUE ); return $this; } public static function validateNotificationCheckbox($value, $context) { return ('y' == $value && empty($context['password'])) ? false : true; } protected function _postInsert() { $this->_sendReviewerNotification(); return parent::_postInsert(); } protected function _postUpdate() { $this->_sendReviewerNotification(); return parent::_postUpdate(); } protected function _sendReviewerNotification() { $data = $this->_getDataObj()->getData(); if ('y' != Qs_Array::get($data, 'sendReviewerNotification', 'n')) { return $this; } $from = App_Settings_Obj::getEmailForm('applicationReviewerRegistrationEmailFrom'); $to = $data['email']; $subject = App_Settings_Obj::get('applicationReviewerRegistrationEmailSubject'); $body = App_Settings_Obj::get('applicationReviewerRegistrationEmailBody'); $emailData = array(); foreach ($data as $key => $val) { $key = '{' . $key . '}'; $emailData[$key] = htmlspecialchars($val); } $emailData['{link}'] = Qs_SiteMap::findFirst(array(), array('type' => 'Application_Reviewer_Login_'), array(), 'url'); $emailData['{password}'] = $emailData['{confirmPassword}']; $body = str_replace(array_keys($emailData), $emailData, $body); $this->_sendMail(compact('from', 'to', 'subject', 'body')); return $this; } }