function setNeutralizedField($fieldname, $fieldlabel = false)
 {
     $fieldlabel = str_replace(" ", "_", $fieldlabel);
     if (Webforms_Model::isCustomField($fieldname)) {
         $this->data["neutralizedfield"] = 'label:' . $fieldlabel;
     } else {
         $this->data["neutralizedfield"] = $fieldname;
     }
 }
Example #2
0
 function captureNow($request)
 {
     $returnURL = false;
     try {
         foreach ($request as $key => $value) {
             $request[utf8_decode($key)] = $value;
         }
         if (!vtlib_isModuleActive('Webforms')) {
             throw new Exception('webforms is not active');
         }
         $webform = Webforms_Model::retrieveWithPublicId(vtlib_purify($request['publicid']));
         if (empty($webform)) {
             throw new Exception("Webform not found.");
         }
         $returnURL = $webform->getReturnUrl();
         // Retrieve user information
         $user = CRMEntity::getInstance('Users');
         $user->id = $user->getActiveAdminId();
         $user->retrieve_entity_info($user->id, 'Users');
         // Prepare the parametets
         $parameters = array();
         $webformFields = $webform->getFields();
         foreach ($webformFields as $webformField) {
             if ($webformField->getDefaultValue() != null) {
                 $parameters[$webformField->getFieldName()] = decode_html($webformField->getDefaultValue());
             } else {
                 $webformNeutralizedField = html_entity_decode($webformField->getNeutralizedField());
                 if (is_array(vtlib_purify($request[$webformNeutralizedField]))) {
                     $fieldData = implode(" |##| ", vtlib_purify($request[$webformNeutralizedField]));
                 } else {
                     $fieldData = vtlib_purify($request[$webformNeutralizedField]);
                     $fieldData = decode_html($fieldData);
                 }
                 $parameters[$webformField->getFieldName()] = stripslashes($fieldData);
             }
             if ($webformField->getRequired()) {
                 if (empty($parameters[$webformField->getFieldName()])) {
                     throw new Exception("Required fields not filled");
                 }
             }
         }
         $parameters['assigned_user_id'] = vtws_getWebserviceEntityId('Users', $webform->getOwnerId());
         // Create the record
         $record = vtws_create($webform->getTargetModule(), $parameters, $user);
         $this->sendResponse($returnURL, 'ok');
         return;
     } catch (Exception $e) {
         $this->sendResponse($returnURL, false, $e->getMessage());
         return;
     }
 }
<?php

/*+********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
require_once 'modules/Webforms/Webforms.php';
require_once 'modules/Webforms/model/WebformsModel.php';
require_once 'Smarty_setup.php';
require_once 'config.inc.php';
Webforms::checkAdminAccess($current_user);
$webformModel = Webforms_Model::retrieveWithId($_REQUEST['id']);
$webformFields = $webformModel->getFields();
$smarty = new vtigerCRM_Smarty();
$smarty->assign('ACTIONPATH', $site_URL);
$smarty->assign('WEBFORM', new Webforms());
$smarty->assign('WEBFORMMODEL', $webformModel);
$smarty->assign('WEBFORMFIELDS', $webformFields);
$smarty->assign('LANGUAGE', $current_language);
$smarty->display(vtlib_getModuleTemplate($currentModule, 'HTMLView.tpl'));
 static function retrieveWithId($data)
 {
     global $adb, $log;
     $id = $data;
     $model = false;
     // Retrieve model and populate information
     $result = $adb->pquery("SELECT * FROM vtiger_webforms WHERE id=?", array($id));
     if ($adb->num_rows($result)) {
         $model = new Webforms_Model($adb->fetch_array($result));
         $model->retrieveFields();
     }
     return $model;
 }
<?php

/*+********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme, $current_user, $adb, $log;
require_once 'Smarty_setup.php';
require 'user_privileges/user_privileges_' . $current_user->id . '.php';
require_once 'modules/Webforms/Webforms.php';
require_once 'modules/Webforms/model/WebformsModel.php';
Webforms::checkAdminAccess($current_user);
$webforms = Webforms_Model::listAll();
$smarty = new vtigerCRM_Smarty();
$category = getParentTab();
$smarty->assign('WEBFORMS', $webforms);
$smarty->assign('ENABLED', $enabled);
$smarty->assign('ACTION', 'list');
$smarty->assign("THEME", $theme);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('APP', $app_strings);
$smarty->assign('MODULE', $currentModule);
$smarty->assign('CATEGORY', $category);
$smarty->assign('IMAGE_PATH', "themes/{$theme}/images/");
$smarty->assign('LANGUAGE', $current_language);
$smarty->display(vtlib_getModuleTemplate($currentModule, 'ListView.tpl'));
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
global $app_strings, $mod_strings, $current_language, $currentModule, $theme, $current_user, $adb, $log;
require_once 'Smarty_setup.php';
require_once 'modules/Webforms/Webforms.php';
require_once 'include/utils/UserInfoUtil.php';
require_once 'config.inc.php';
Webforms::checkAdminAccess($current_user);
$isCreate = !isset($_REQUEST['id']);
$webform = false;
if ($isCreate) {
    $webform = new Webforms_Model();
} else {
    $webform = Webforms_Model::retrieveWithId(vtlib_purify($_REQUEST['id']));
}
$smarty = new vtigerCRM_Smarty();
$category = getParentTab();
$targetModules = array('Leads');
$usersList = get_user_array(false);
$smarty->assign('WEBFORM', $webform);
$smarty->assign('USERS', $usersList);
$smarty->assign('WEBFORMMODULES', $targetModules);
$smarty->assign('THEME', $theme);
$smarty->assign('MOD', $mod_strings);
$smarty->assign('APP', $app_strings);
$smarty->assign('MODULE', $currentModule);
$smarty->assign('CATEGORY', $category);
$smarty->assign('IMAGE_PATH', "themes/{$theme}/images/");
$smarty->assign('CALENDAR_LANG', 'en');
Example #7
0
<?php

/*+********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
require_once 'modules/Webforms/Webforms.php';
require_once 'modules/Webforms/model/WebformsModel.php';
include_once 'include/Zend/Json.php';
global $current_user, $theme;
if ($_REQUEST['ajax'] == 'true') {
    if (Webforms_Model::existWebformWithName(vtlib_purify($_REQUEST['name']))) {
        print_r(Zend_Json::encode(array('success' => false, 'result' => false)));
    } else {
        print_r(Zend_Json::encode(array('success' => true, 'result' => true)));
    }
} else {
    Webforms::checkAdminAccess($current_user);
    $webform = new Webforms_Model($_REQUEST);
    try {
        $webform->save();
        $URL = 'index.php?module=Webforms&action=WebformsDetailView&parenttab=Settings&id=' . $webform->getId();
    } catch (Exception $e) {
        $URL = 'index.php?module=Webforms&action=Error&parenttab=Settings&errormsg=' . $e->getMessage();
    }
    header(sprintf("Location: %s", $URL));
}
Example #8
-9
 function captureNow($request)
 {
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage);
     vglobal('app_strings', $moduleLanguageStrings['languageStrings']);
     $returnURL = false;
     try {
         if (!vtlib_isModuleActive('Webforms')) {
             throw new Exception('webforms is not active');
         }
         $webform = Webforms_Model::retrieveWithPublicId(vtlib_purify($request['publicid']));
         if (empty($webform)) {
             throw new Exception("Webform not found.");
         }
         $returnURL = $webform->getReturnUrl();
         $roundrobin = $webform->getRoundrobin();
         // Retrieve user information
         $user = CRMEntity::getInstance('Users');
         $user->id = $user->getActiveAdminId();
         $user->retrieve_entity_info($user->id, 'Users');
         // Prepare the parametets
         $parameters = array();
         $webformFields = $webform->getFields();
         foreach ($webformFields as $webformField) {
             if ($webformField->getDefaultValue() != null) {
                 $parameters[$webformField->getFieldName()] = decode_html($webformField->getDefaultValue());
             } else {
                 $webformNeutralizedField = html_entity_decode($webformField->getNeutralizedField(), ENT_COMPAT, "UTF-8");
                 if (is_array(vtlib_purify($request[$webformNeutralizedField]))) {
                     $fieldData = implode(" |##| ", vtlib_purify($request[$webformNeutralizedField]));
                 } else {
                     $fieldData = vtlib_purify($request[$webformNeutralizedField]);
                     $fieldData = decode_html($fieldData);
                 }
                 $parameters[$webformField->getFieldName()] = stripslashes($fieldData);
             }
             if ($webformField->getRequired()) {
                 if (!isset($parameters[$webformField->getFieldName()])) {
                     throw new Exception("Required fields not filled");
                 }
             }
         }
         if ($roundrobin) {
             $ownerId = $webform->getRoundrobinOwnerId();
             $ownerType = vtws_getOwnerType($ownerId);
             $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId);
         } else {
             $ownerId = $webform->getOwnerId();
             $ownerType = vtws_getOwnerType($ownerId);
             $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId);
         }
         // Create the record
         $record = vtws_create($webform->getTargetModule(), $parameters, $user);
         $this->sendResponse($returnURL, 'ok');
         return;
     } catch (Exception $e) {
         $this->sendResponse($returnURL, false, $e->getMessage());
         return;
     }
 }