Exemplo n.º 1
1
 * 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;
 }
 public function testblowfishDecode()
 {
     //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 = blowfishDecode('test', '');
     $this->assertSame($expected, $actual);
     //valid key and valid data
     $expected = 'Data';
     $actual = blowfishDecode('test', 'HI1/88NJJss=');
     $this->assertSame($expected, $actual);
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
 /**
  * [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);
     // ---------------------------------------------------------
 }
Exemplo n.º 7
0
 /**
  * Populates this instance
  * @param string $id
  * @return object $this
  */
 function retrieve($id)
 {
     require_once 'include/utils/encryption_utils.php';
     $q = "SELECT * FROM outbound_email WHERE id = '{$id}'";
     $r = $this->db->query($q);
     $a = $this->db->fetchByAssoc($r);
     if (!empty($a)) {
         foreach ($a as $k => $v) {
             if ($k == 'mail_smtppass' && !empty($v)) {
                 $this->{$k} = blowfishDecode(blowfishGetKey('OutBoundEmail'), $v);
             } else {
                 $this->{$k} = $v;
             }
             // else
         }
         if (!empty($a['mail_smtptype'])) {
             $this->mail_smtpdisplay = $this->_getOutboundServerDisplay($a['mail_smtptype'], $a['mail_smtpserver']);
         } else {
             $this->mail_smtpdisplay = $a['mail_smtpserver'];
         }
     }
     return $this;
 }
Exemplo n.º 8
0
 /**
  * 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)
 {
     if (empty($value)) {
         return $value;
     }
     // no need to decrypt empty
     require_once "include/utils/encryption_utils.php";
     return blowfishDecode($this->getEncryptKey(), $value);
 }
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
 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;
 }
 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;
 }
Exemplo n.º 12
0
 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;
         }
     }
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
0
 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.");
 }