public function save($check_notify = false)
 {
     if (!$this->mail_smtppass && $this->id) {
         $bean = new OutboundEmailAccounts();
         $bean->retrieve($this->id);
         $this->mail_smtppass = $bean->mail_smtppass;
     }
     $this->mail_smtppass = $this->mail_smtppass ? blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->mail_smtppass) : null;
     $results = parent::save($check_notify);
     return $results;
 }
 public function testblowfishEncode()
 {
     //execute the method and test if it returns expected values
     //it won't work with blank key, will throw an error
     //valid key and blank data
     $expected = '';
     $actual = blowfishEncode('test', '');
     $this->assertSame($expected, $actual);
     //valid key and valid data
     $expected = 'HI1/88NJJss=';
     $actual = blowfishEncode('test', 'Data');
     $this->assertSame($expected, $actual);
 }
 /**
  * wraps SugarBean->save()
  * @param string ID of saved bean
  */
 function save($check_notify = false)
 {
     // generate cache table for email 2.0
     $multiDImArray = $this->generateMultiDimArrayFromFlatArray(explode(",", $this->mailbox), $this->retrieveDelimiter());
     $raw = $this->generateFlatArrayFromMultiDimArray($multiDImArray, $this->retrieveDelimiter());
     sort($raw);
     //_pp(explode(",", $this->mailbox));
     //_ppd($raw);
     $raw = $this->filterMailBoxFromRaw(explode(",", $this->mailbox), $raw);
     $this->mailbox = implode(",", $raw);
     if (!empty($this->email_password)) {
         $this->email_password = blowfishEncode(blowfishGetKey('InboundEmail'), $this->email_password);
     }
     $ret = parent::save($check_notify);
     return $ret;
 }
示例#4
0
 /**
  * Encrpyt and base64 encode an 'encrypt' field type in the bean using Blowfish. The default system key is stored in cache/Blowfish/{keytype}
  * @param STRING value -plain text value of the bean field.
  * @return string
  */
 function encrpyt_before_save($value)
 {
     require_once "include/utils/encryption_utils.php";
     return blowfishEncode(blowfishGetKey('encrypt_field'), $value);
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $app_list_strings;
     require_once "modules/Configurator/metadata/SugarpdfSettingsdefs.php";
     if (file_exists('custom/modules/Configurator/metadata/SugarpdfSettingsdefs.php')) {
         require_once 'custom/modules/Configurator/metadata/SugarpdfSettingsdefs.php';
     }
     if (!empty($_POST['save'])) {
         // Save the logos
         $error = $this->checkUploadImage();
         if (empty($error)) {
             $focus = new Administration();
             foreach ($SugarpdfSettings as $k => $v) {
                 if ($v['type'] == 'password') {
                     if (isset($_POST[$k])) {
                         $_POST[$k] = blowfishEncode(blowfishGetKey($k), $_POST[$k]);
                     }
                 }
             }
             if (!empty($_POST["sugarpdf_pdf_class"]) && $_POST["sugarpdf_pdf_class"] != PDF_CLASS) {
                 // clear the cache for quotes detailview in order to switch the pdf class.
                 if (is_file($cachedfile = sugar_cached('modules/Quotes/DetailView.tpl'))) {
                     unlink($cachedfile);
                 }
             }
             $focus->saveConfig();
             header('Location: index.php?module=Administration&action=index');
         }
     }
     if (!empty($_POST['restore'])) {
         $focus = new Administration();
         foreach ($_POST as $key => $val) {
             $prefix = $focus->get_config_prefix($key);
             if (in_array($prefix[0], $focus->config_categories)) {
                 $result = $focus->db->query("SELECT count(*) AS the_count FROM config WHERE category = '{$prefix[0]}' AND name = '{$prefix[1]}'");
                 $row = $focus->db->fetchByAssoc($result);
                 if ($row['the_count'] != 0) {
                     $focus->db->query("DELETE FROM config WHERE category = '{$prefix[0]}' AND name = '{$prefix[1]}'");
                 }
             }
         }
         header('Location: index.php?module=Configurator&action=SugarpdfSettings');
     }
     echo getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>" . translate('LBL_MODULE_NAME', 'Administration') . "</a>", $mod_strings['LBL_PDFMODULE_NAME']), false);
     $pdf_class = array("TCPDF" => "TCPDF", "EZPDF" => "EZPDF");
     $this->ss->assign('APP_LIST', $app_list_strings);
     $this->ss->assign("JAVASCRIPT", get_set_focus_js());
     $this->ss->assign("SugarpdfSettings", $SugarpdfSettings);
     $this->ss->assign("pdf_enable_ezpdf", PDF_ENABLE_EZPDF);
     if (PDF_ENABLE_EZPDF == "0" && PDF_CLASS == "EZPDF") {
         $error = "ERR_EZPDF_DISABLE";
         $this->ss->assign("selected_pdf_class", "TCPDF");
     } else {
         $this->ss->assign("selected_pdf_class", PDF_CLASS);
     }
     $this->ss->assign("pdf_class", $pdf_class);
     if (!empty($error)) {
         $this->ss->assign("error", $mod_strings[$error]);
     }
     if (!function_exists('imagecreatefrompng')) {
         $this->ss->assign("GD_WARNING", 1);
     } else {
         $this->ss->assign("GD_WARNING", 0);
     }
     $this->ss->display('modules/Configurator/tpls/SugarpdfSettings.tpl');
     require_once "include/javascript/javascript.php";
     $javascript = new javascript();
     $javascript->setFormName("ConfigureSugarpdfSettings");
     foreach ($SugarpdfSettings as $k => $v) {
         if (isset($v["required"]) && $v["required"] == true) {
             $javascript->addFieldGeneric($k, "varchar", $v['label'], TRUE, "");
         }
     }
     echo $javascript->getScript();
 }
示例#6
0
 /**
  * Generate values for saving into outbound_emails table
  * @param array $keys
  * @return array
  */
 protected function getValues(&$keys)
 {
     $values = array();
     $validKeys = array();
     foreach ($keys as $def) {
         if ($def == 'mail_smtppass' && !empty($this->{$def})) {
             $this->{$def} = blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->{$def});
         }
         // if
         if ($def == 'mail_smtpauth_req' || $def == 'mail_smtpssl' || $def == 'mail_smtpport') {
             if (empty($this->{$def})) {
                 $this->{$def} = 0;
             }
             $values[] = intval($this->{$def});
             $validKeys[] = $def;
         } else {
             if (isset($this->{$def})) {
                 $values[] = $this->db->quoted($this->{$def});
                 $validKeys[] = $def;
             }
         }
     }
     $keys = $validKeys;
     return $values;
 }
示例#7
0
 /**
  * Encrpyt and base64 encode an 'encrypt' field type in the bean using Blowfish. The default system key is stored in cache/Blowfish/{keytype}
  * @param STRING value -plain text value of the bean field.
  * @return string
  */
 function encrpyt_before_save($value)
 {
     require_once "include/utils/encryption_utils.php";
     return blowfishEncode($this->getEncryptKey(), $value);
 }
示例#8
0
 /**
  * Save source's config to custom directory
  */
 public function saveConfig()
 {
     $config_str = "<?php\n/***CONNECTOR SOURCE***/\n";
     // Handle encryption
     if (!empty($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && !empty($this->_config['properties'])) {
         require_once 'include/utils/encryption_utils.php';
         foreach ($this->_config['encrypt_properties'] as $name) {
             if (!empty($this->_config['properties'][$name])) {
                 $this->_config['properties'][$name] = blowfishEncode(blowfishGetKey('encrypt_field'), $this->_config['properties'][$name]);
             }
         }
     }
     foreach ($this->_config as $key => $val) {
         if (!empty($val)) {
             $config_str .= override_value_to_string_recursive2('config', $key, $val, false);
         }
     }
     $dir = str_replace('_', '/', get_class($this));
     if (!file_exists("custom/modules/Connectors/connectors/sources/{$dir}")) {
         mkdir_recursive("custom/modules/Connectors/connectors/sources/{$dir}");
     }
     file_put_contents("custom/modules/Connectors/connectors/sources/{$dir}/config.php", $config_str);
 }
 function queryFilterNot_Equals_Str(&$layout_def)
 {
     require_once "include/utils/encryption_utils.php";
     $search_value = blowfishEncode(blowfishGetKey('encrypt_field'), $layout_def['input_name0']);
     return $this->_get_column_select($layout_def) . "!='" . $GLOBALS['db']->quote($search_value) . "'\n";
 }
示例#10
0
 /**
  * saves an instance
  */
 function save()
 {
     require_once 'include/utils/encryption_utils.php';
     if (empty($this->id) || $this->new_with_id) {
         if (empty($this->id)) {
             $this->id = create_guid();
         }
         $cols = '';
         $values = '';
         foreach ($this->field_defs as $def) {
             if (!empty($cols)) {
                 $cols .= ", ";
             }
             if (!empty($values)) {
                 $values .= ", ";
             }
             $cols .= $def;
             $pattern = '\\';
             if ($def == 'mail_smtppass' && !empty($this->{$def})) {
                 $this->{$def} = blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->{$def});
             }
             // if
             if ($def == 'mail_smtpauth_req' || $def == 'mail_smtpssl') {
                 if (empty($this->{$def})) {
                     $this->{$def} = 0;
                 }
                 $values .= $this->{$def};
             } elseif ($def == 'mail_smtpuser' && strpos($this->{$def}, '\\')) {
                 //bug 41766: taking care of '\' in username
                 $temp = explode('\\', $this->{$def});
                 $this->{$def} = $temp[0] . '\\\\' . $temp[1];
                 $values .= "{$def} = '{$this->{$def}}'";
             } else {
                 $values .= "'{$this->{$def}}'";
             }
         }
         $q = "INSERT INTO outbound_email ({$cols}) VALUES ({$values})";
     } else {
         $values = array();
         foreach ($this->field_defs as $def) {
             switch ($def) {
                 case 'mail_smtpport':
                 case 'mail_smtpauth_req':
                 case 'mail_smtpssl':
                     if (empty($this->{$def})) {
                         $this->{$def} = 0;
                     }
                     $values[] = "{$def} = {$this->{$def}}";
                     break;
                 case 'mail_smtppass':
                     if (!empty($this->mail_smtppass)) {
                         $this->mail_smtppass = blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->mail_smtppass);
                     } else {
                         // ignore empty password unless username is empty too
                         if (!empty($this->mail_smtpuser)) {
                             continue;
                         }
                     }
                     $values[] = "{$def} = '{$this->{$def}}'";
                     break;
                 case 'mail_smtpuser':
                     if (strpos($this->{$def}, '\\')) {
                         //bug 41766: taking care of '\' in username
                         $temp = explode('\\', $this->{$def});
                         $this->{$def} = $temp[0] . '\\\\' . $temp[1];
                     }
                 default:
                     $values[] = "{$def} = '{$this->{$def}}'";
             }
         }
         $q = "UPDATE outbound_email SET " . implode(', ', $values) . " WHERE id = '{$this->id}'";
     }
     $this->db->query($q, true);
     return $this;
 }
示例#11
0
 /**
  * saves an instance
  */
 function save()
 {
     require_once 'include/utils/encryption_utils.php';
     if (empty($this->id) || $this->new_with_id) {
         if (empty($this->id)) {
             $this->id = create_guid();
         }
         $cols = '';
         $values = '';
         foreach ($this->field_defs as $def) {
             if (!empty($cols)) {
                 $cols .= ", ";
             }
             if (!empty($values)) {
                 $values .= ", ";
             }
             $cols .= $def;
             if ($def == 'mail_smtppass' && !empty($this->mail_smtppass)) {
                 $this->mail_smtppass = blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->mail_smtppass);
             }
             // if
             if ($def == 'mail_smtpauth_req' || $def == 'mail_smtpssl') {
                 if (empty($this->{$def})) {
                     $this->{$def} = 0;
                 }
                 $values .= "{$this->{$def}}";
             } else {
                 $values .= "'{$this->{$def}}'";
             }
         }
         $q = "INSERT INTO outbound_email ({$cols}) VALUES ({$values})";
     } else {
         $values = "";
         foreach ($this->field_defs as $def) {
             if (!empty($values)) {
                 $values .= ", ";
             }
             if ($def == 'mail_smtppass' && !empty($this->{$def})) {
                 $this->{$def} = blowfishEncode(blowfishGetKey('OutBoundEmail'), $this->{$def});
             }
             // if
             if ($def == 'mail_smtpauth_req' || $def == 'mail_smtpssl') {
                 if (empty($this->{$def})) {
                     $this->{$def} = 0;
                 }
                 $values .= "{$def} = {$this->{$def}}";
             } else {
                 $values .= "{$def} = '{$this->{$def}}'";
             }
         }
         $q = "UPDATE outbound_email SET {$values} WHERE id = '{$this->id}'";
     }
     $this->db->query($q, true);
     return $this;
 }
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
if (!is_admin($current_user)) {
    sugar_die('Admin Only');
}
require_once 'include/Sugarpdf/sugarpdf_config.php';
$SugarpdfSettings = array("sugarpdf_pdf_author" => array("label" => $mod_strings["PDF_AUTHOR"], "info_label" => $mod_strings["PDF_AUTHOR_INFO"], "value" => PDF_AUTHOR, "class" => "basic", "type" => "text", "required" => "true"), "sugarpdf_pdf_header_logo" => array("label" => $mod_strings["PDF_HEADER_LOGO"], "info_label" => $mod_strings["PDF_HEADER_LOGO_INFO"], "value" => PDF_HEADER_LOGO, "path" => K_PATH_IMAGES . PDF_HEADER_LOGO, "class" => "basic", "type" => "image"), "new_header_logo" => array("label" => $mod_strings["PDF_NEW_HEADER_LOGO"], "info_label" => $mod_strings["PDF_NEW_HEADER_LOGO_INFO"], "value" => "", "class" => "basic", "type" => "file"), "sugarpdf_pdf_header_logo_width" => array("label" => $mod_strings["PDF_HEADER_LOGO_WIDTH"], "info_label" => $mod_strings["PDF_HEADER_LOGO_WIDTH_INFO"], "value" => PDF_HEADER_LOGO_WIDTH, "class" => "basic", "type" => "number", "required" => "true"), "sugarpdf_pdf_header_string" => array("label" => $mod_strings["PDF_HEADER_STRING"], "info_label" => $mod_strings["PDF_HEADER_STRING_INFO"], "value" => PDF_HEADER_STRING, "class" => "basic", "type" => "text"), "sugarpdf_pdf_header_title" => array("label" => $mod_strings["PDF_HEADER_TITLE"], "info_label" => $mod_strings["PDF_HEADER_TITLE_INFO"], "value" => PDF_HEADER_TITLE, "class" => "basic", "type" => "text"), "sugarpdf_pdf_filename" => array("label" => $mod_strings["PDF_FILENAME"], "info_label" => $mod_strings["PDF_FILENAME_INFO"], "value" => PDF_FILENAME, "class" => "basic", "type" => "text", "required" => "true"), "sugarpdf_pdf_title" => array("label" => $mod_strings["PDF_TITLE"], "info_label" => $mod_strings["PDF_TITLE_INFO"], "value" => PDF_TITLE, "class" => "basic", "type" => "text"), "sugarpdf_pdf_subject" => array("label" => $mod_strings["PDF_SUBJECT"], "info_label" => $mod_strings["PDF_SUBJECT_INFO"], "value" => PDF_SUBJECT, "class" => "basic", "type" => "text"), "sugarpdf_pdf_keywords" => array("label" => $mod_strings["PDF_KEYWORDS"], "info_label" => $mod_strings["PDF_KEYWORDS_INFO"], "value" => PDF_KEYWORDS, "class" => "basic", "type" => "text"));
if (!empty($_POST['save'])) {
    $error = checkUploadImage();
    if (empty($error)) {
        $focus = new Administration();
        foreach ($SugarpdfSettings as $k => $v) {
            if ($v['type'] == 'password') {
                if (isset($_POST[$k])) {
                    $_POST[$k] = blowfishEncode(blowfishGetKey($k), $_POST[$k]);
                }
            }
        }
        $focus->saveConfig();
        header('Location: index.php?module=Administration&action=index');
    }
}
if (!empty($_POST['restore'])) {
    $focus = new Administration();
    foreach ($_POST as $key => $val) {
        $prefix = $focus->get_config_prefix($key);
        if (in_array($prefix[0], $focus->config_categories)) {
            $result = $focus->db->query("SELECT count(*) AS the_count FROM config WHERE category = '{$prefix[0]}' AND name = '{$prefix[1]}'");
            $row = $focus->db->fetchByAssoc($result, -1, true);
            if ($row['the_count'] != 0) {
 public function _providerEmailTemplateFormat()
 {
     require_once "include/utils/encryption_utils.php";
     return array(array(blowfishEncode(blowfishGetKey('encrypt_field'), 'Test value'), 'Test value'));
 }
示例#14
0
 /**
  * Process The license Permissions based on the active license data,
  * if this data doesn't exists a default configuration is used instead, this one doesn't have any permissions
  * @return array
  */
 public function getLicensePermissions()
 {
     $this->licensePermissions = new stdClass();
     if (!isset($_SESSION['PMSE'])) {
         $this->licenseData = $this->licenseManager->getActiveLicenseData();
         $this->licenseActivationData = $this->getLicenseActivationData();
         $this->licenseData->lic_max_cases = isset($this->licenseData->lic_max_cases) ? $this->licenseData->lic_max_cases : 0;
         $this->licenseData->lic_max_users = isset($this->licenseData->lic_max_users) ? $this->licenseData->lic_max_users : 0;
         $this->licenseData->lic_max_admins = isset($this->licenseData->lic_max_admins) ? $this->licenseData->lic_max_admins : 0;
         $this->licenseData->lic_product_expiration_date = isset($this->licenseData->lic_product_expiration_date) ? $this->licenseData->lic_product_expiration_date : '1900-01-01';
         $this->licenseData->lic_enabled_br = isset($this->licenseData->lic_enabled_br) ? $this->licenseData->lic_enabled_br : false;
         $this->licensePermissions->canExecuteCases = false;
         $this->licensePermissions->canStartCases = false;
         $this->licensePermissions->canAssignUserDashlets = false;
         $this->licensePermissions->canAssignAdminDashlets = false;
         $this->licensePermissions->canExecuteBusinessRules = false;
         if ($this->licenseData->lic_max_cases > $this->licenseActivationData->casesNumber) {
             $this->licensePermissions->canStartCases = true;
         }
         if ($this->licenseData->lic_max_users > $this->licenseActivationData->assignedUserDashlets) {
             $this->licensePermissions->canAssignUserDashlets = true;
         }
         if ($this->licenseData->lic_max_admins > $this->licenseActivationData->assignedAdminDashlets) {
             $this->licensePermissions->canAssignAdminDashlets = true;
         }
         $expirationDate = new DateTime($this->licenseData->lic_product_expiration_date);
         if ($expirationDate > $this->licenseActivationData->actualDate) {
             $this->licensePermissions->canExecuteCases = true;
         }
         $this->licensePermissions->canExecuteBusinessRules = $this->licenseData->lic_enabled_br;
         $_SESSION['PMSE'] = blowfishEncode(blowfishGetKey('ProcessMaker'), base64_encode(serialize($this->licensePermissions)));
     } else {
         $this->licensePermissions = unserialize(base64_decode(blowfishDecode(blowfishGetKey('ProcessMaker'), $_SESSION['PMSE'])));
     }
     return $this->licensePermissions;
 }
 /**
  * wraps SugarBean->save()
  * @param string ID of saved bean
  */
 function save($check_notify = false)
 {
     $this->email_password = blowfishEncode(blowfishGetKey('InboundEmail'), $this->email_password);
     return parent::save($check_notify);
 }