add *.inc files to project
This commit is contained in:
119
include/ECM/EcmDropdownEditor/EcmDropdownEditor.inc
Normal file
119
include/ECM/EcmDropdownEditor/EcmDropdownEditor.inc
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*
|
||||
* important:
|
||||
* add to return_app_list_strings_language in include/utils.php:
|
||||
* //add mz 2015-01-07
|
||||
* //include EcmDropdownEditor custom doms
|
||||
* $path = 'include/language/'.$language.'.EcmDropdownEditor.php';
|
||||
* if (file_exists($path)) {
|
||||
* include $path;
|
||||
* foreach ($customDoms as $key => $val)
|
||||
* $app_list_strings[$key] = $val;
|
||||
* }
|
||||
* //end mz
|
||||
*/
|
||||
class EcmDropdownEditor {
|
||||
const MY_PATH = "include/ECM/EcmDropdownEditor/";
|
||||
private $module;
|
||||
private $fieldName;
|
||||
private $dom; // name of edited list
|
||||
private $dropdowns; // values of edited list
|
||||
private $languages; // Sugar languages list
|
||||
private $container; //name of div with edit form
|
||||
public function EcmDropdownEditor($module, $container) {
|
||||
$this->module = $module;
|
||||
$this->languages = get_languages ();
|
||||
$this->container = $container;
|
||||
$tmp = explode ( "___", $container );
|
||||
$this->fieldName = $tmp [0];
|
||||
}
|
||||
|
||||
// Get all dropdowns from module vardefs (including all Sugar languages)
|
||||
private function getDropdowns() {
|
||||
// get list values
|
||||
global $sugar_config; // just to get current language
|
||||
$l = array ();
|
||||
foreach ( $this->languages as $id => $lang ) {
|
||||
$l [$id] = return_app_list_strings_language ( $id );
|
||||
}
|
||||
// get dom name
|
||||
include_once ('modules/' . $this->module . '/vardefs.php');
|
||||
//evolpe begin
|
||||
if(file_exists('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php')){
|
||||
include('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php');
|
||||
}
|
||||
//evolpe end
|
||||
$this->dom = $dictionary [substr ( $this->module, 0, - 1 )] ['fields'] [$this->fieldName] ['options'];
|
||||
$tmp = array ();
|
||||
foreach ( $l [$sugar_config ['default_language']] [$this->dom] as $key => $value ) {
|
||||
$tmp [$key] = array ();
|
||||
foreach ( $this->languages as $id => $lang )
|
||||
$tmp [$key] [$id] = $l [$id] [$this->dom] [$key];
|
||||
}
|
||||
$this->dropdowns[$this->dom] = $tmp;
|
||||
unset ( $tmp );
|
||||
return true;
|
||||
}
|
||||
public function DrawEditView() {
|
||||
$this->getDropdowns ();
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'DROPDOWNS', $this->dropdowns );
|
||||
$smarty->assign ( 'LANGUAGES', $this->languages );
|
||||
$smarty->assign ( 'CONTAINER', $this->container );
|
||||
return $smarty->fetch ( self::MY_PATH . 'EditView.tpl' );
|
||||
}
|
||||
public static function getOptionTemplate() {
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'KEY', create_guid () );
|
||||
$smarty->assign ( 'LANGUAGES', get_languages () );
|
||||
return $smarty->fetch ( self::MY_PATH . 'addOption.tpl' );
|
||||
}
|
||||
public static function saveDom($name, $normal) {
|
||||
require_once 'include/utils/file_utils.php';
|
||||
// save normal
|
||||
foreach ( $normal as $lang => $options ) {
|
||||
$customDoms = null;
|
||||
$path = 'include/language/' . $lang . '.EcmDropdownEditor.php';
|
||||
if (file_exists ( $path ))
|
||||
require ($path);
|
||||
else
|
||||
$customDoms = array ();
|
||||
$customDoms [$name] = array ();
|
||||
foreach ( $options as $key => $val )
|
||||
$customDoms [$name] [$key] = $val;
|
||||
write_array_to_file ( 'customDoms', $customDoms, $path );
|
||||
}
|
||||
// clear sugar cache
|
||||
include_once ('modules/Administration/QuickRepairAndRebuild.php');
|
||||
$repair = new RepairAndClear ();
|
||||
$modules = array (
|
||||
'All Modules'
|
||||
);
|
||||
$selected_actions = array (
|
||||
'clearTpls',
|
||||
'clearJsLangFiles',
|
||||
'clearLangFiles'
|
||||
);
|
||||
$repair->repairAndClearAll ( $selected_actions, $modules, false, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getOptionsHTML() {
|
||||
// get dom names
|
||||
include_once ('modules/' . $this->module . '/vardefs.php');
|
||||
//evolpe begin
|
||||
if(file_exists('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php')){
|
||||
include('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php');
|
||||
}
|
||||
//evolpe end
|
||||
$dom = $dictionary [substr ( $this->module, 0, - 1 )] ['fields'] [$this->fieldName] ['options'];
|
||||
//current language
|
||||
global $current_language;
|
||||
$options = return_app_list_strings_language($current_language);
|
||||
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'OPTIONS', $options[$dom] );
|
||||
return $smarty->fetch ( self::MY_PATH . 'createOptions.tpl' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
11
include/ECM/EcmJsTable/EcmJsTable.inc
Normal file
11
include/ECM/EcmJsTable/EcmJsTable.inc
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
class EcmJsTable {
|
||||
const MY_PATH = "include/ECM/EcmJsTable/";
|
||||
static function getHeaders($metadata, $type) {
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'METADATA', $metadata );
|
||||
$smarty->assign ( 'TYPE', $type );
|
||||
return $smarty->fetch ( self::MY_PATH . 'header.tpl' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
76
include/ECM/EcmMultiPdf/EcmMultiPdf.inc
Normal file
76
include/ECM/EcmMultiPdf/EcmMultiPdf.inc
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* add mz 2014-12-30
|
||||
* Class to create one pdf file from many documents
|
||||
*/
|
||||
class EcmMultiPdf {
|
||||
const TEMP_DIR = "temp/EcmMultiPdf/";
|
||||
const MY_PATH = "include/ECM/EcmMultiPdf/";
|
||||
private $outputfile;
|
||||
private $documents; // is two-dimensions array, $documents[i] = array('module'=>'moduleName', 'record'=>'record_id')
|
||||
private $status;
|
||||
private $count;
|
||||
private $temp_files; // array with temponary file names
|
||||
private $s; // class strings
|
||||
function __construct($documents, $outputfile = 'multi.pdf') {
|
||||
$this->documents = $documents;
|
||||
$this->outputfile = strtolower ( substr ( $outputfile, - 4 ) ) == '.pdf' ? strtolower ( substr ( $outputfile, 0, - 4 ) ) .'_'. create_guid () . '.pdf' : $outputfile .'_'. create_guid () . '.pdf';
|
||||
$this->count = sizeof ( $this->documents );
|
||||
$this->temp_files = array ();
|
||||
// create temp dir if not exists
|
||||
if (! is_dir ( self::TEMP_DIR ))
|
||||
mkdir ( self::TEMP_DIR );
|
||||
}
|
||||
/*
|
||||
* Function creates pdf
|
||||
* return:
|
||||
* file path on succes
|
||||
* -1: prepareDosc error
|
||||
* -2: mergeFiles error
|
||||
*/
|
||||
public function process() {
|
||||
if (! $this->prepareDocs ())
|
||||
return - 1;
|
||||
if (! $this->mergeFiles ())
|
||||
return - 2;
|
||||
$this->deleteTempFiles ();
|
||||
return self::TEMP_DIR . $this->outputfile;
|
||||
}
|
||||
private function prepareDocs() {
|
||||
if (! is_array ( $this->documents ) || $this->count == 0)
|
||||
return false;
|
||||
|
||||
for($i = 0; $i < $this->count; $i ++) {
|
||||
$doc = ( array ) $this->documents [$i]; // cast from object to array when it's axaj call
|
||||
if (! is_array ( $doc ) || sizeof ( $doc ) != 2 || ! $doc ['module'] || ! $doc ['record'])
|
||||
return false;
|
||||
if (! file_exists ( 'modules/' . $doc ['module'] . '/createPDF.php' ))
|
||||
return false;
|
||||
include_once 'modules/' . $doc ['module'] . '/createPDF.php';
|
||||
$generator = 'create' . substr ( $doc ['module'], 0, - 1 ) . 'Pdf';
|
||||
$filename = basename ( $generator ( $doc ['record'], 'MULTIPDF' ) );
|
||||
$this->temp_files [$i] = $filename;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private function mergeFiles() {
|
||||
include_once self::MY_PATH . 'PDFMerger.php';
|
||||
$merger = new PDFMerger ();
|
||||
$errors = array ();
|
||||
for($i = 0; $i < $this->count; $i ++)
|
||||
if (file_exists ( self::TEMP_DIR . $this->temp_files [$i] ))
|
||||
$merger->addPDF ( self::TEMP_DIR . $this->temp_files [$i], 'all' );
|
||||
else
|
||||
return -2;
|
||||
if (!file_put_contents ( self::TEMP_DIR . $this->outputfile, $merger->merge ( 'string', $this->outputfile ) ));
|
||||
return -2;
|
||||
return true; // file is ready
|
||||
}
|
||||
private function deleteTempFiles() {
|
||||
if (sizeof ( $this->temp_files ) == 0)
|
||||
return;
|
||||
foreach ( $this->temp_files as $f )
|
||||
unlink ( self::TEMP_DIR . $f );
|
||||
}
|
||||
}
|
||||
?>
|
||||
181
include/ECM/EcmSendMail/EcmSendMail.inc
Normal file
181
include/ECM/EcmSendMail/EcmSendMail.inc
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/*
|
||||
* add mz 2014-12-29
|
||||
* Class can send email from any module using system mail service
|
||||
* getStatus() returns 1 if message was sended, or error message if sth goes wrong
|
||||
*/
|
||||
class EcmSendMail {
|
||||
const TEMP_DIR = "upload/EcmSendMailTemp/";
|
||||
|
||||
private $to_addresses = NULL; // array with recipients addresses
|
||||
private $cc_addresses = NULL; // array with CC addresses
|
||||
private $bcc_addresses = NULL; // array with BCC addresses
|
||||
private $attachments = NULL; // array with attachments filenames
|
||||
private $from = NULL;
|
||||
private $fromName = NULL;
|
||||
private $replyTo = NULL;
|
||||
private $replyToName = NULL;
|
||||
private $subject = NULL;
|
||||
private $message = NULL;
|
||||
private $status;
|
||||
private $OBCharset;
|
||||
private $clearTemp = false;
|
||||
private $s; // class strings
|
||||
function __construct() {
|
||||
global $locale, $current_language;
|
||||
$this->OBCharset = $locale->getPrecedentPreference ( 'default_email_charset' );
|
||||
// get labels if exists
|
||||
if (file_exists ( 'include/ECM/EcmSendMail/' . $current_language . '.php' ))
|
||||
include_once ('include/ECM/EcmSendMail/' . $current_language . '.php');
|
||||
else
|
||||
// othervise load en_us
|
||||
include_once ('include/ECM/EcmSendMail/en_us.php');
|
||||
$this->s = $strings;
|
||||
|
||||
//create temp dir if not exists
|
||||
if (!is_dir(self::TEMP_DIR))
|
||||
mkdir(self::TEMP_DIR);
|
||||
}
|
||||
public function sendMail() {
|
||||
include_once ('include/SugarPHPMailer.php');
|
||||
include_once ('include/utils/db_utils.php'); // for from_html function
|
||||
|
||||
$mail = new SugarPHPMailer ();
|
||||
$mail->prepForOutbound ();
|
||||
$mail->setMailerForSystem ();
|
||||
|
||||
// clear addresses
|
||||
$mail->ClearAllRecipients ();
|
||||
$mail->ClearReplyTos ();
|
||||
$mail->ClearCCs ();
|
||||
$mail->ClearBCCs ();
|
||||
|
||||
// Add recipients
|
||||
if (! is_array ( $this->to_addresses ) || sizeof ( $this->to_addresses ) == 0) {
|
||||
$this->status = $this->s ['LBL_NO_TO_ADDRESS'];
|
||||
return;
|
||||
}
|
||||
foreach ( $this->to_addresses as $k => $v )
|
||||
$mail->AddAddress ( $k, $this->t ( $v ) ); // function t() is explained below
|
||||
|
||||
// Add CC
|
||||
if (is_array ( $this->cc_addresses ) || sizeof ( $this->cc_addresses ) > 0) {
|
||||
foreach ( $this->cc_addresses as $k => $v )
|
||||
$mail->AddCC ( $k, $this->t ( $v ) );
|
||||
}
|
||||
|
||||
// Add BCC
|
||||
if (is_array ( $this->bcc_addresses ) || sizeof ( $this->bcc_addresses ) > 0) {
|
||||
foreach ( $this->bcc_addresses as $k => $v )
|
||||
$mail->AddBCC ( $k, $this->t ( $v ) );
|
||||
}
|
||||
|
||||
// if sender is not defined by setSender(), get values from user settings
|
||||
if (! $this->from || ! $this->fromName) {
|
||||
global $current_user;
|
||||
$u = new User ();
|
||||
$u->retrieve ( $current_user->id );
|
||||
}
|
||||
if (! $this->from)
|
||||
$this->from = $u->emailAddress->getPrimaryAddress ( $u );
|
||||
if (! $this->fromName)
|
||||
$this->fromName = (! empty ( $replyToName )) ? $current_user->getPreference ( 'mail_fromname' ) : $current_user->full_name;
|
||||
if ($u)
|
||||
unset ( $u );
|
||||
|
||||
$mail->From = $this->from;
|
||||
$mail->FromName = $this->fromName;
|
||||
|
||||
// Add reply to informations if they're setted
|
||||
if ($this->replyToName && $this->replyTo)
|
||||
$mail->AddReplyTo ( $this->replyTo, $this->replyToName );
|
||||
|
||||
$mail->Sender = $mail->From; /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
|
||||
|
||||
// Add subject
|
||||
$mail->Subject = $this->subject;
|
||||
// Prepare and add message
|
||||
// Using code from handleBodyInHTMLformat(), /modules/Email/Email.php
|
||||
$mail->IsHTML ( true );
|
||||
$mail->Body = from_html ( wordwrap ( $this->message, 996 ) );
|
||||
$plainText = from_html ( $this->description_html );
|
||||
$plainText = strip_tags ( br2nl ( $plainText ) );
|
||||
$mail->AltBody = $plainText;
|
||||
|
||||
// add attachments
|
||||
if (is_array ( $this->attachments ) && sizeof ( $this->attachments ) > 0) {
|
||||
foreach ( $this->attachments as $f ) {
|
||||
$filename = $f;
|
||||
$location = self::TEMP_DIR.$filename;
|
||||
if (! file_exists ( $location ) || is_dir ( $location )) {
|
||||
$this->status = $this->s ['LBL_NO_ATTACHMENT'] . $filename;
|
||||
return;
|
||||
}
|
||||
// get file mime type
|
||||
$finfo = finfo_open ( FILEINFO_MIME_TYPE );
|
||||
$mime_type = finfo_file ( $finfo, $location );
|
||||
finfo_close ( $finfo );
|
||||
// add attachment
|
||||
$mail->AddAttachment ( $location, $this->t ( $filename ), 'base64', $mime_type );
|
||||
}
|
||||
}
|
||||
|
||||
// Send mail, log if there is error
|
||||
echo "?";
|
||||
if (! $mail->Send ()) {
|
||||
echo ' tu?';
|
||||
var_dump( $mail->ErrorInfo);
|
||||
$this->status = $this->s ['LBL_SEND_ERROR'];
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->clearTemp)
|
||||
$this->deleteTempFiles ();
|
||||
|
||||
$this->status = 1;
|
||||
}
|
||||
private function deleteTempFiles() {
|
||||
foreach ( $this->attachments as $f )
|
||||
unlink ( self::TEMP_DIR.$f );
|
||||
}
|
||||
// helper function to translate charset
|
||||
private function t($s) {
|
||||
global $locale;
|
||||
return $locale->translateCharsetMIME ( trim ( $s ), 'UTF-8', $this->OBCharset );
|
||||
}
|
||||
// swetery ;)
|
||||
public function setSubject($subject) {
|
||||
$this->subject = $this->t ( $subject );
|
||||
}
|
||||
public function setMessage($message) {
|
||||
$this->message = $message;
|
||||
}
|
||||
public function setAddresses($to_addresses) {
|
||||
$this->to_addresses = $to_addresses;
|
||||
}
|
||||
public function setCCAddresses($cc_addresses) {
|
||||
$this->cc_addresses = $cc_addresses;
|
||||
}
|
||||
public function setBCCAddresses($bcc_addresses) {
|
||||
$this->bcc_addresses = $bcc_addresses;
|
||||
}
|
||||
public function setAttachments($attachments) {
|
||||
$this->attachments = $attachments;
|
||||
}
|
||||
public function setSender($from, $fromName) {
|
||||
$this->from = $from;
|
||||
$this->fromName = $this->t ( $fromName );
|
||||
}
|
||||
public function setReplyTo($replyTo, $replyToName) {
|
||||
$this->replyTo = $replyTo;
|
||||
$this->replyToName = $this->t ( $replyToName );
|
||||
}
|
||||
public function setClearTemp($clearTemp) {
|
||||
$this->clearTemp = $clearTemp;
|
||||
}
|
||||
// getery ;)
|
||||
public function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<h2>OFC Test Suite - PERL</h2>
|
||||
<ul>Available Tests:
|
||||
<li><a href="test_bar.asp">BAR</a>, </li>
|
||||
<li><a href="test_line.asp">LINE</a>, </li>
|
||||
<li><a href="test_stackbar.asp">STACK BAR</a>, </li>
|
||||
<li><a href="test_pie.asp">PIE</a>, </li>
|
||||
<li><a href="test_scatter.asp">Scatter</a>, </li>
|
||||
<li><a href="test_area.asp">Area</a>, </li>
|
||||
<li><a href="test_cgi.pl">CGI Test</a></li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user