Example #1
0
 function savepost()
 {
     $post = new WebForm($this->gbform);
     if (!$post->isValid()) {
         // Form is invalid, post it back to the user to allow correction
     } else {
         $db = new DatabaseConnection();
         $db->insertRow("INSERT INTO guestbook (name,email,website,message) VALUES (%s,%s,%s,%s)", $post->name, $post->email, $post->website, $post->message);
     }
 }
Example #2
0
 private function manageProfessional()
 {
     /* Bail out if the user doesn't have SA permissions. */
     if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
     }
     if (ModuleUtility::moduleExists('asp') && (!defined('CATS_TEST_MODE') || !CATS_TEST_MODE)) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
     }
     $wf = new WebForm();
     $wf->addField('licenseKey', 'License Key', WFT_TEXT, true, 60, 30, 190, '', '/[A-Za-z0-9 ]+/', 'That is not a valid license key!');
     $message = '';
     $license = new License();
     $upgradeStatus = false;
     if (isset($_GET['webFormPostBack'])) {
         list($fields, $errors) = $wf->getValidatedFields();
         if (count($errors) > 0) {
             $message = 'Please enter a license key in order to continue.';
         }
         $key = trim($fields['licenseKey']);
         $configWritten = false;
         if ($license->setKey($key) === false) {
             $message = 'That is not a valid license key<br /><span style="font-size: 16px; color: #000000;">Please verify that you have the correct key and try again.</span>';
         } else {
             if ($license->isProfessional()) {
                 if (!CATSUtility::isSOAPEnabled()) {
                     $message = 'CATS Professional requires the PHP SOAP library which isn\'t currently installed.<br /><br />' . 'Installation Instructions:<br /><br />' . 'WAMP/Windows Users:<dl>' . '<li>Left click on the wamp icon.</li>' . '<li>Select "PHP Settings" from the drop-down list.</li>' . '<li>Select "PHP Extensions" from the drop-down list.</li>' . '<li>Check the "php_soap" option.</li>' . '<li>Restart WAMP.</li></dl>' . 'Linux Users:<br /><br />' . 'Re-install PHP with the --enable-soap configuration option.<br /><br />' . 'Please visit http://www.catsone.com for more support options.';
                 }
                 if (!LicenseUtility::validateProfessionalKey($key)) {
                     $message = 'That is not a valid Professional membership key<br /><span style="font-size: 16px; color: #000000;">Please verify that you have the correct key and try again.</span>';
                 } else {
                     if (!CATSUtility::changeConfigSetting('LICENSE_KEY', "'" . $key . "'")) {
                         $message = 'Internal Permissions Error<br /><span style="font-size: 12px; color: #000000;">CATS is unable ' . 'to write changes to your <b>config.php</b> file. Please change the file permissions or contact us ' . 'for support. Our support e-mail is <a href="mailto:support@catsone.com">support@catsone.com</a> ' . 'and our office number if (952) 417-0067.</span>';
                     } else {
                         $upgradeStatus = true;
                     }
                 }
             } else {
                 $message = 'That is not a valid Professional membership key<br /><span style="font-size: 16px; color: #000000;">Please verify that you have the correct key and try again.</span>';
             }
         }
     }
     $this->_template->assign('active', $this);
     $this->_template->assign('subActive', 'Professional Membership');
     $this->_template->assign('message', $message);
     $this->_template->assign('upgradeStatus', $upgradeStatus);
     $this->_template->assign('webForm', $wf);
     $this->_template->assign('license', $license);
     $this->_template->display('./modules/settings/Professional.tpl');
 }
Example #3
0
 /**
  * Create a web lead form with a custom style
  *
  * Currently web forms have all options passed as GET parameters. Saved web forms
  * are saved to the table x2_web_forms. Saving, retrieving, and updating a web form
  * all happens in this function. Someday this should be updated to be it's own module.
  *
  * 
  * This get request is for weblead/service type only, marketing/weblist/view supplies 
  * the form that posts for weblist type 
  *  
  */
 public function run()
 {
     AuxLib::debugLogR($_POST);
     $modelClass = $this->controller->modelClass;
     if ($modelClass === 'Campaign') {
         $modelClass = 'Contacts';
     }
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         // save a web form
         if (empty($_POST['name'])) {
             if ($modelClass === 'Contacts') {
                 echo json_encode(array('errors' => array('name' => Yii::t('marketing', 'Name cannot be blank.'))));
             } elseif ($modelClass === 'Services') {
                 echo json_encode(array('errors' => array('name' => Yii::t('marketing', 'Name cannot be blank.'))));
             }
             return;
         }
         if ($modelClass === 'Contacts') {
             $type = !empty($_POST['type']) ? $_POST['type'] : 'weblead';
         } elseif ($modelClass === 'Services') {
             $type = 'serviceCase';
         }
         $model = WebForm::model()->findByAttributes(array('name' => $_POST['name'], 'type' => $type));
         // check if we are updating an existing web form
         if (!isset($model)) {
             $model = new WebForm();
             $model->name = $_POST['name'];
             $model->type = $type;
             $model->modelName = $modelClass;
             $model->visibility = 1;
             $model->assignedTo = Yii::app()->user->getName();
             $model->createdBy = Yii::app()->user->getName();
             $model->createDate = time();
         }
         //grab web lead configuration and stash in 'params'
         $whitelist = array('fg', 'bgc', 'font', 'bs', 'bc', 'tags');
         $config = array_filter(array_intersect_key($_POST, array_flip($whitelist)));
         //restrict param values, alphanumeric, # for color vals, comma for tag list
         $config = preg_replace('/[^a-zA-Z0-9#,]/', '', $config);
         if (!empty($config)) {
             $model->params = $config;
         } else {
             $model->params = null;
         }
         if (isset($_POST['generateLead']) && isset($_POST['leadSource'])) {
             $model->leadSource = $_POST['leadSource'];
             $model->generateLead = 1;
         } else {
             $model->generateLead = 0;
         }
         if (isset($_POST['generateAccount'])) {
             $model->generateAccount = 1;
         } else {
             $model->generateAccount = 0;
         }
         $model->updatedBy = Yii::app()->user->getName();
         $model->lastUpdated = time();
         if ($model->save()) {
             echo json_encode($model->attributes);
         } else {
             echo json_encode(array('errors' => $model->getErrors()));
         }
     } else {
         if ($modelClass === 'Contacts') {
             $criteria = X2Model::model('Marketing')->getAccessCriteria();
             $condition = $criteria->condition;
             $forms = WebForm::model()->findAll('type="weblead" AND ' . $condition, $criteria->params);
             $this->controller->render('application.modules.marketing.views.marketing.webleadForm', array('forms' => $forms));
         } else {
             if ($modelClass === 'Services') {
                 $criteria = X2Model::model('Services')->getAccessCriteria();
                 $condition = $criteria->condition;
                 // get service web forms (other option is 'weblead' used by marketing module)
                 $forms = WebForm::model()->findAll('type="serviceCase" AND ' . $condition, $criteria->params);
                 $this->controller->render('application.modules.services.views.services.createWebFormView', array('forms' => $forms));
             }
         }
     }
 }
Example #4
0
 public function actionSaveWebLeadFormCustomHtml()
 {
     if (!empty($_POST) && !empty($_POST['id']) && !empty($_POST['html'])) {
         $model = WebForm::model()->findByPk($_POST['id']);
         if ($model) {
             $model->header = $_POST['html'];
             if ($model->save()) {
                 echo CJSON::encode(array('success', $model->attributes));
                 return;
             }
         }
     }
     echo CJSON::encode(array('error', Yii::t('marketing', 'Custom HTML could not be saved.')));
 }
Example #5
0
 /**
  * Create a web lead form with a custom style
  *
  * There are currently two methods of specifying web form options. 
  *  Method 1 (legacy):
  *      Web form options are sent in the GET parameters (limited options: css, web form
  *      id for retrieving custom header)
  *  Method 2 (new):
  *      CSS options are passed in the GET parameters and all other options (custom fields, 
  *      custom html, and email templates) are stored in the database and accessed via a
  *      web form id sent in the GET parameters.
  *
  * This get request is for weblead/service type only, marketing/weblist/view supplies
  * the form that posts for weblist type
  *
  */
 public function run()
 {
     $modelClass = $this->controller->modelClass;
     if ($modelClass === 'Campaign') {
         $modelClass = 'Contacts';
     }
     if ($modelClass === 'Contacts') {
         $model = new Contacts('webForm');
     } elseif ($modelClass === 'Services') {
         $model = new Services('webForm');
     }
     $extractedParams = array();
     if (isset($_GET['webFormId'])) {
         $webForm = WebForm::model()->findByPk($_GET['webFormId']);
     }
     $extractedParams['leadSource'] = null;
     $extractedParams['generateLead'] = false;
     $extractedParams['generateAccount'] = false;
     if (isset($webForm)) {
         // new method
         if (!empty($webForm->leadSource)) {
             $extractedParams['leadSource'] = $webForm->leadSource;
         }
         if (!empty($webForm->generateLead)) {
             $extractedParams['generateLead'] = $webForm->generateLead;
         }
         if (!empty($webForm->generateAccount)) {
             $extractedParams['generateAccount'] = $webForm->generateAccount;
         }
     }
     if ($modelClass === 'Contacts') {
         $this->handleWebleadFormSubmission($model, $extractedParams);
     } else {
         if ($modelClass === 'Services') {
             $this->handleServiceFormSubmission($model, $extractedParams);
         }
     }
 }