'Application_Document_Admin'), array(), 'url'); $list->addColumn('no', 'no') ->addColumn('text', 'schoolName', array('orderBy' => 'schoolName')) ->addColumn('text', 'name', array('orderBy' => 'name')) ->addColumn('email', 'email', array('orderBy' => 'email')) ->addColumn('documents', 'documents', array('orderBy' => 'documentsCount', 'documentsUrl' => $documentsUrl)) ->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', 'sendUserNotification', array( 'label' => 'Send Applicant Email Notification', 'decoration' => 'simple', ) ); $form->getElement('sendUserNotification')->addValidator( 'Callback', true, array( array($this, 'validateNotificationCheckbox') ) ); /** @var Zend_Validate_Callback $callback */ $callback = $form->getElement('sendUserNotification')->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->_sendApplicantNotification(); return parent::_postInsert(); } protected function _postUpdate() { $this->_sendApplicantNotification(); return parent::_postUpdate(); } protected function _sendApplicantNotification() { $data = $this->_getDataObj()->getData(); if ('y' != Qs_Array::get($data, 'sendUserNotification', 'n')) { return $this; } $from = App_Settings_Obj::getEmailForm('applicationUserRegistrationEmailFrom'); $to = $data['email']; $subject = App_Settings_Obj::get('applicationUserRegistrationEmailSubject'); $body = App_Settings_Obj::get('applicationUserRegistrationEmailBody'); $emailData = array(); foreach ($data as $key => $val) { $key = '{' . $key . '}'; $emailData[$key] = htmlspecialchars($val); } $emailData['{link}'] = Qs_SiteMap::findFirst(array(), array('type' => 'Application_User_Login_'), array(), 'url'); $emailData['{password}'] = $emailData['{confirmPassword}']; $body = str_replace(array_keys($emailData), $emailData, $body); $this->_sendMail(compact('from', 'to', 'subject', 'body')); return $this; } }