protected function renderFormLayout($form = null)
 {
     $baseUrl = Yii::app()->createAbsoluteUrl('sendGrid/external/writeLog');
     $text = SendGridUtil::renderEventWebHookUrlOnForm($this->model, 'username', '30%');
     SendGridUtil::registerEventWebhookUrlScript('SendGridWebApiConfigurationForm_username', $baseUrl);
     return $text . parent::renderFormLayout($form);
 }
 /**
  * Assumes before calling this, the sendgrid settings have been validated in the form.
  */
 protected function processSendTestMessageForSendGrid()
 {
     $configurationForm = SendGridWebApiConfigurationFormAdapter::makeFormFromGlobalConfiguration();
     if (isset($_POST['UserSendGridConfigurationForm'])) {
         $configurationForm->username = $_POST['UserSendGridConfigurationForm']['apiUsername'];
         $configurationForm->password = $_POST['UserSendGridConfigurationForm']['apiPassword'];
         $configurationForm->aTestToAddress = $_POST['UserSendGridConfigurationForm']['aTestToAddress'];
         $fromNameToSendMessagesFrom = $_POST['UserEmailConfigurationForm']['fromName'];
         $fromAddressToSendMessagesFrom = $_POST['UserEmailConfigurationForm']['fromAddress'];
         $messageContent = SendGridUtil::sendTestMessage($configurationForm, $fromNameToSendMessagesFrom, $fromAddressToSendMessagesFrom);
         Yii::app()->getClientScript()->setToAjaxMode();
         $messageView = new TestConnectionView($messageContent);
         $view = new ModalView($this, $messageView);
         echo $view->render();
         Yii::app()->end();
     } else {
         throw new NotSupportedException();
     }
 }
 /**
  * Assumes before calling this, the sendgrid settings have been validated in the form.
  */
 public function actionSendTestMessage()
 {
     $configurationForm = SendGridWebApiConfigurationFormAdapter::makeFormFromGlobalConfiguration();
     $postVariableName = get_class($configurationForm);
     if (isset($_POST[$postVariableName])) {
         if (isset($_POST[$postVariableName])) {
             $configurationForm->setAttributes($_POST[$postVariableName]);
         }
         $messageContent = SendGridUtil::sendTestMessage($configurationForm);
         Yii::app()->getClientScript()->setToAjaxMode();
         $messageView = new TestConnectionView($messageContent);
         $view = new ModalView($this, $messageView);
         echo $view->render();
     } else {
         throw new NotSupportedException();
     }
 }
 /**
  * Render event webhook url.
  * @param CModel $model
  * @return string
  */
 protected function renderEventWebhookUrl($model)
 {
     $baseUrl = Yii::app()->createAbsoluteUrl('sendGrid/external/writeLog');
     $text = SendGridUtil::renderEventWebHookUrlOnForm($model, 'apiUsername');
     SendGridUtil::registerEventWebhookUrlScript('UserSendGridConfigurationForm_apiUsername', $baseUrl);
     return $text;
 }