* details. * * You should have received a copy of the GNU Affero General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". ********************************************************************************/ require_once 'include/Sugarpdf/sugarpdf_config.php'; $SugarpdfSettings = array("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_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_keywords" => array("label" => $mod_strings["PDF_KEYWORDS"], "info_label" => $mod_strings["PDF_KEYWORDS_INFO"], "value" => PDF_KEYWORDS, "class" => "basic", "type" => "text"), "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_CUSTOM_IMAGES . PDF_HEADER_LOGO, "class" => "logo", "type" => "image"), "new_header_logo" => array("label" => $mod_strings["PDF_NEW_HEADER_LOGO"], "info_label" => $mod_strings["PDF_NEW_HEADER_LOGO_INFO"], "value" => "", "class" => "logo", "type" => "file"), "sugarpdf_pdf_small_header_logo" => array("label" => $mod_strings["PDF_SMALL_HEADER_LOGO"], "info_label" => $mod_strings["PDF_SMALL_HEADER_LOGO_INFO"], "value" => PDF_SMALL_HEADER_LOGO, "path" => K_PATH_CUSTOM_IMAGES . PDF_SMALL_HEADER_LOGO, "class" => "logo", "type" => "image"), "new_small_header_logo" => array("label" => $mod_strings["PDF_NEW_SMALL_HEADER_LOGO"], "info_label" => $mod_strings["PDF_NEW_SMALL_HEADER_LOGO_INFO"], "value" => "", "class" => "logo", "type" => "file"), "sugarpdf_pdf_filename" => array("label" => $mod_strings["PDF_FILENAME"], "info_label" => $mod_strings["PDF_FILENAME_INFO"], "value" => PDF_FILENAME, "class" => "advanced", "type" => "text", "required" => "true"), "sugarpdf_pdf_compression" => array("label" => $mod_strings["PDF_COMPRESSION"], "info_label" => $mod_strings["PDF_COMPRESSION_INFO"], "value" => PDF_COMPRESSION, "class" => "advanced", "type" => "bool"), "sugarpdf_pdf_jpeg_quality" => array("label" => $mod_strings["PDF_JPEG_QUALITY"], "info_label" => $mod_strings["PDF_JPEG_QUALITY_INFO"], "value" => PDF_JPEG_QUALITY, "class" => "advanced", "type" => "percent", "required" => "true"), "sugarpdf_pdf_pdf_version" => array("label" => $mod_strings["PDF_PDF_VERSION"], "info_label" => $mod_strings["PDF_PDF_VERSION_INFO"], "value" => PDF_PDF_VERSION, "class" => "advanced", "type" => "number", "required" => "true"), "sugarpdf_pdf_protection" => array("label" => $mod_strings["PDF_PROTECTION"], "info_label" => $mod_strings["PDF_PROTECTION_INFO"], "value" => explode(",", PDF_PROTECTION), "class" => "advanced", "type" => "multiselect", "selectList" => array("print" => "Print", "modify" => "Modify", "copy" => "Copy", "annot-forms" => "Annotations and forms")), "sugarpdf_pdf_user_password" => array("label" => $mod_strings["PDF_USER_PASSWORD"], "info_label" => $mod_strings["PDF_USER_PASSWORD_INFO"], "value" => blowfishDecode(blowfishGetKey('sugarpdf_pdf_user_password'), PDF_USER_PASSWORD), "class" => "advanced", "type" => "password"), "sugarpdf_pdf_owner_password" => array("label" => $mod_strings["PDF_OWNER_PASSWORD"], "info_label" => $mod_strings["PDF_OWNER_PASSWORD_INFO"], "value" => blowfishDecode(blowfishGetKey('sugarpdf_pdf_owner_password'), PDF_OWNER_PASSWORD), "class" => "advanced", "type" => "password"), "sugarpdf_pdf_acl_access" => array("label" => $mod_strings["PDF_ACL_ACCESS"], "info_label" => $mod_strings["PDF_ACL_ACCESS_INFO"], "value" => PDF_ACL_ACCESS, "class" => "advanced", "type" => "select", "selectList" => array("edit" => "Edition", "list" => "List", "detail" => "Detail", "export" => "Export"), "required" => "true"), "sugarpdf_k_small_ratio" => array("label" => $mod_strings["K_SMALL_RATIO"], "info_label" => $mod_strings["K_SMALL_RATIO_INFO"], "value" => K_SMALL_RATIO, "class" => "advanced", "type" => "number", "required" => "true"), "sugarpdf_k_cell_height_ratio" => array("label" => $mod_strings["K_CELL_HEIGHT_RATIO"], "info_label" => $mod_strings["K_CELL_HEIGHT_RATIO_INFO"], "value" => K_CELL_HEIGHT_RATIO, "class" => "advanced", "type" => "number", "required" => "true"), "sugarpdf_pdf_image_scale_ratio" => array("label" => $mod_strings["PDF_IMAGE_SCALE_RATIO"], "info_label" => $mod_strings["PDF_IMAGE_SCALE_RATIO_INFO"], "value" => PDF_IMAGE_SCALE_RATIO, "class" => "advanced", "type" => "number", "required" => "true"), "sugarpdf_pdf_unit" => array("label" => $mod_strings["PDF_UNIT"], "info_label" => $mod_strings["PDF_UNIT_INFO"], "value" => PDF_UNIT, "class" => "advanced", "type" => "select", "selectList" => array("mm" => "Millimeter", "pt" => "Point", "cm" => "Centimeter", "in" => "Inch"), "required" => "true")); // Use the OOB directory for images if there is no image in the custom directory $small_logo = $SugarpdfSettings['sugarpdf_pdf_small_header_logo']['path']; $logo = $SugarpdfSettings['sugarpdf_pdf_header_logo']['path']; if (@getimagesize($logo) === FALSE) { $SugarpdfSettings['sugarpdf_pdf_header_logo']['path'] = K_PATH_IMAGES . $SugarpdfSettings['sugarpdf_pdf_header_logo']['value']; } if (@getimagesize($small_logo) === FALSE) { $SugarpdfSettings['sugarpdf_pdf_small_header_logo']['path'] = K_PATH_IMAGES . $SugarpdfSettings['sugarpdf_pdf_small_header_logo']['value']; }
function displayListPlain($layout_def) { $value = $this->_get_list_value($layout_def); require_once "include/utils/encryption_utils.php"; $value = blowfishDecode(blowfishGetKey('encrypt_field'), $value); return $value; }
static function getLoginInfo($application, $includeInactive = false) { global $current_user; $eapmBean = new EAPM(); if (isset($_SESSION['EAPM'][$application]) && !$includeInactive) { if (is_array($_SESSION['EAPM'][$application])) { $eapmBean->fromArray($_SESSION['EAPM'][$application]); } else { return null; } } else { $queryArray = array('assigned_user_id' => $current_user->id, 'application' => $application, 'deleted' => 0); if (!$includeInactive) { $queryArray['validated'] = 1; } $eapmBean = $eapmBean->retrieve_by_string_fields($queryArray); // Don't cache the include inactive results if (!$includeInactive) { if ($eapmBean != null) { $_SESSION['EAPM'][$application] = $eapmBean->toArray(); } else { $_SESSION['EAPM'][$application] = ''; return null; } } } if (isset($eapmBean->password)) { require_once "include/utils/encryption_utils.php"; $eapmBean->password = blowfishDecode(blowfishGetKey('encrypt_field'), $eapmBean->password); } return $eapmBean; }
/** * Get the already stored license data. * @param string $uid * @return \stdClass */ public function getLicenseData($uid) { $result = new stdClass(); $result->success = false; $key = blowfishGetKey('ProcessMaker'); //TODO DELETE THIS LINE //$result->success = true; //return $result; //Verify if activationCode exist in DB $rs = $this->amBean->retrieve_by_string_fields(array("acm_uid" => $uid)); if (empty($rs)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_IDFIELDMISSING', $this->moduleName); return $result; } try { $license = json_decode($this->crypt->openLicense($key, $rs->acm_data)); } catch (Exception $e) { $result->message = $e->getMessage(); return $result; } if (empty($license)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_NOTVALID', $this->moduleName); return $result; } else { if (!isset($license->lic_max_admins)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_ADMINISTRATORMISSING', $this->moduleName); return $result; } else { $result->lic_max_admins = $license->lic_max_admins; } if (!isset($license->lic_max_users)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_USERSMISSING', $this->moduleName); return $result; } else { $result->lic_max_users = $license->lic_max_users; } if (!isset($license->lic_max_cases)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_CASESMISSING', $this->moduleName); return $result; } else { $result->lic_max_cases = $license->lic_max_cases; } if (!isset($license->lic_product_expiration_date)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_PRODUCTDATEMISSING', $this->moduleName); return $result; } else { $result->lic_product_expiration_date = $license->lic_product_expiration_date; } if (!isset($license->lic_support_expiration_date)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_SUPPORTDATEMISSING', $this->moduleName); return $result; } else { $result->lic_support_expiration_date = $license->lic_support_expiration_date; } if (!isset($license->lic_enabled_br)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_BUSSINESRULESMISSING', $this->moduleName); return $result; } else { $result->lic_enabled_br = (bool) $license->lic_enabled_br; } $result->success = true; } return $result; }
/** * 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; }
public function retrieve($id = -1, $encode = true, $deleted = true) { $results = parent::retrieve($id, $encode, $deleted); $this->mail_smtppass = $this->mail_smtppass ? blowfishDecode(blowfishGetKey('OutBoundEmail'), $this->mail_smtppass) : null; return $results; }
/** * 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; }
protected function getEncryptKey() { if (empty(self::$field_key[$this->module_key])) { self::$field_key[$this->module_key] = blowfishGetKey($this->module_key); } return self::$field_key[$this->module_key]; }
public function loadConfig() { $config = array(); $dir = str_replace('_', '/', get_class($this)); if (file_exists("modules/Connectors/connectors/sources/{$dir}/config.php")) { require "modules/Connectors/connectors/sources/{$dir}/config.php"; } if (file_exists("custom/modules/Connectors/connectors/sources/{$dir}/config.php")) { require "custom/modules/Connectors/connectors/sources/{$dir}/config.php"; } $this->_config = $config; // Handle decryption if (isset($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && isset($this->_config['properties'])) { require_once 'include/utils/encryption_utils.php'; foreach ($this->_config['encrypt_properties'] as $name) { if (isset($this->_config['properties'][$name])) { $this->_config['properties'][$name] = blowfishDecode(blowfishGetKey('encrypt_field'), $this->_config['properties'][$name]); } } } //If there are no required config fields specified, we will default them to all be required if (empty($this->_required_config_fields)) { foreach ($this->_config['properties'] as $id => $value) { $this->_required_config_fields[] = $id; } } }
/** * 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')); }
/** * Initialize config - decrypt encrypted fields */ public function initConfig() { if ($this->config_decrypted) { return; } // Handle decryption require_once 'include/utils/encryption_utils.php'; if (!empty($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && !empty($this->_config['properties'])) { foreach ($this->_config['encrypt_properties'] as $name) { if (!empty($this->_config['properties'][$name])) { $this->_config['properties'][$name] = blowfishDecode(blowfishGetKey('encrypt_field'), $this->_config['properties'][$name]); } } } $this->config_decrypted = true; }
/** * repairs the encrypted password for a given I-E account * @return bool True on success */ function repairAccount() { for ($i = 0; $i < 3; $i++) { if ($i != 0) { // decode is performed on retrieve already $this->email_password = blowfishDecode(blowfishGetKey('InboundEmail'), $this->email_password); } if ($this->connectMailserver() == 'true') { $this->save(); // save decoded password (is encoded on save()) return true; } } return false; }
/** * Decode and decrypt a base 64 encoded string with field type 'encrypt' in this bean using Blowfish. * @param STRING value - an encrypted and base 64 encoded string. * @return string */ function decrypt_after_retrieve($value) { require_once "include/utils/encryption_utils.php"; return blowfishDecode(blowfishGetKey('encrypt_field'), $value); }
function testSystemAccountMailSettingsChangedUserAccessToUsername() { //User not alloweed to access system email username/password $GLOBALS['db']->query("DELETE FROM config where name='allow_default_outbound' AND category='notify'"); $GLOBALS['db']->query("INSERT INTO config (category,name,value) VALUES ('notify','allow_default_outbound','2')"); $newSystemPort = 864; $newSystemServer = "system.imap.com"; $newSystemUsername = "******"; $newSystemPassword = "******"; $userID = create_guid(); $ob = new OutboundEmail(); $ob->id = $userID; $ob->new_with_id = TRUE; $ob->name = 'Sugar Test 1'; $ob->type = 'system-override'; $ob->user_id = $this->_user->id; $ob->mail_sendtype = "SMTP"; $ob->mail_smtpuser = "******"; $ob->mail_smtppass = "******"; $ob->save(); $this->ob = $ob; $system = $ob->getSystemMailerSettings(); $system->new_with_id = FALSE; $system->mail_smtpport = $newSystemPort; $system->mail_smtpserver = $newSystemServer; $system->mail_smtpuser = $newSystemUsername; $system->mail_smtppass = $newSystemPassword; $system->saveSystem(); $obRetrieved = new OutboundEmail(); $obRetrieved->retrieve($userID); $this->assertEquals($newSystemPort, $obRetrieved->mail_smtpport, "Could not update users port system-override accounts after system save."); $this->assertEquals($newSystemServer, $obRetrieved->mail_smtpserver, "Could not update users server system-override accounts after system save."); $this->assertEquals($newSystemUsername, $obRetrieved->mail_smtpuser, "Could not update users username system-override accounts after system save."); $this->assertEquals($newSystemPassword, blowfishDecode(blowfishGetKey('OutBoundEmail'), $obRetrieved->mail_smtppass), "Could not update users password system-override accounts after system save."); }
/** * [OVERRIDE] - This method is meant to overidden in a subclass. The purpose of this method is * to allow a view to do some preprocessing before the display method is called. This becomes * useful when you have a view defined at the application level and then within a module * have a sub-view that extends from this application level view. The application level * view can do the setup in preDisplay() that is common to itself and any subviews * and then the subview can just override display(). If it so desires, can also override * preDisplay(). */ function preDisplay() { // set document information $this->SetCreator(PDF_CREATOR); $this->SetAuthor(PDF_AUTHOR); $this->SetTitle(PDF_TITLE); $this->SetSubject(PDF_SUBJECT); $this->SetKeywords(PDF_KEYWORDS); // set other properties $compression = false; if (PDF_COMPRESSION == "on") { $compression = true; } $this->SetCompression($compression); $protection = array(); if (PDF_PROTECTION != "") { $protection = explode(",", PDF_PROTECTION); } $this->SetProtection($protection, blowfishDecode(blowfishGetKey('sugarpdf_pdf_user_password'), PDF_USER_PASSWORD), blowfishDecode(blowfishGetKey('sugarpdf_pdf_owner_password'), PDF_OWNER_PASSWORD)); $this->setCellHeightRatio(K_CELL_HEIGHT_RATIO); $this->setJPEGQuality(intval(PDF_JPEG_QUALITY)); $this->setPDFVersion(PDF_PDF_VERSION); // set default header data $this->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $this->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $this->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); //set margins $this->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $this->setHeaderMargin(PDF_MARGIN_HEADER); $this->setFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $this->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $this->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings //$this->setLanguageArray($l); // --------------------------------------------------------- }
/** * @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(); }
/** * 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; }
protected function getEncryptKey() { if (empty(self::$field_key)) { self::$field_key = blowfishGetKey('encrypt_field'); } return self::$field_key; }
public function testblowfishGetKey() { //execute the method and test if it returns expected length string //test key $actual = blowfishGetKey('test'); $this->assertGreaterThanOrEqual(36, strlen($actual)); //var_dump($actual); //default key $actual = blowfishGetKey('rapelcg_svryq'); $this->assertGreaterThanOrEqual(36, strlen($actual)); }