Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

218
modules/Audit/Audit.php Executable file
View File

@@ -0,0 +1,218 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* 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. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('modules/Audit/field_assoc.php');
class Audit extends SugarBean {
var $module_dir = "Audit";
var $object_name = "Audit";
// This is used to retrieve related fields from form posts.
var $additional_column_fields = Array();
function Audit() {
parent::SugarBean();
}
var $new_schema = true;
function get_summary_text()
{
return $this->name;
}
function create_export_query(&$order_by, &$where)
{
}
function fill_in_additional_list_fields()
{
}
function fill_in_additional_detail_fields()
{
}
function fill_in_additional_parent_fields()
{
}
function get_list_view_data()
{
}
function get_audit_link()
{
}
function get_audit_list()
{
global $focus, $genericAssocFieldsArray, $moduleAssocFieldsArray, $current_user, $timedate, $app_strings;
$audit_list = array();
if(!empty($_REQUEST['record'])) {
$result = $focus->retrieve($_REQUEST['record']);
if($result == null || !$focus->ACLAccess('', $focus->isOwner($current_user->id)))
{
sugar_die($app_strings['ERROR_NO_RECORD']);
}
}
if($focus->is_AuditEnabled()){
$order= ' order by '.$focus->get_audit_table_name().'.date_created desc' ;//order by contacts_audit.date_created desc
$query = "SELECT ".$focus->get_audit_table_name().".*, users.user_name FROM ".$focus->get_audit_table_name().", users WHERE ".$focus->get_audit_table_name().".created_by = users.id AND ".$focus->get_audit_table_name().".parent_id = '$focus->id'".$order;
$result = $focus->db->query($query);
// We have some data.
require('metadata/audit_templateMetaData.php');
$fieldDefs = $dictionary['audit']['fields'];
while (($row = $focus->db->fetchByAssoc($result))!= null) {
$temp_list = array();
foreach($fieldDefs as $field){
if(isset($row[$field['name']])) {
if(($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') &&
(array_key_exists($row['field_name'], $genericAssocFieldsArray) || (!empty($moduleAssocFieldsArray[$focus->object_name]) && array_key_exists($row['field_name'], $moduleAssocFieldsArray[$focus->object_name])) )
) {
$temp_list[$field['name']] = Audit::getAssociatedFieldName($row['field_name'], $row[$field['name']]);
} else{
$temp_list[$field['name']] = $row[$field['name']];
}
if ($field['name'] == 'date_created') {
$temp_list[$field['name']]=$timedate->to_display_date_time($temp_list[$field['name']]);
}
if(($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && ($row['data_type'] == "enum" || $row['data_type'] == "multienum"))
{
global $app_list_strings;
$enum_keys = unencodeMultienum($temp_list[$field['name']]);
$enum_values = array();
foreach($enum_keys as $enum_key) {
if(isset($focus->field_defs[$row['field_name']]['options'])) {
$domain = $focus->field_defs[$row['field_name']]['options'];
if(isset($app_list_strings[$domain][$enum_key]))
$enum_values[] = $app_list_strings[$domain][$enum_key];
}
}
if(!empty($enum_values)){
$temp_list[$field['name']] = implode(', ', $enum_values);
}
if($temp_list['data_type']==='date'){
$temp_list[$field['name']]=$timedate->to_display_date($temp_list[$field['name']], false);
}
}
elseif($field['name'] == 'field_name')
{
global $mod_strings;
if(isset($focus->field_defs[$row['field_name']]['vname'])) {
$label = $focus->field_defs[$row['field_name']]['vname'];
$temp_list[$field['name']] = translate($label, $focus->module_dir);
}
}
}
}
$temp_list['created_by'] = $row['user_name'];
$audit_list[] = $temp_list;
}
}
return $audit_list;
}
function getAssociatedFieldName($fieldName, $fieldValue){
global $focus, $genericAssocFieldsArray, $moduleAssocFieldsArray;
if(!empty($moduleAssocFieldsArray[$focus->object_name]) && array_key_exists($fieldName, $moduleAssocFieldsArray[$focus->object_name])){
$assocFieldsArray = $moduleAssocFieldsArray[$focus->object_name];
}
else if(array_key_exists($fieldName, $genericAssocFieldsArray)){
$assocFieldsArray = $genericAssocFieldsArray;
}
else{
return $fieldValue;
}
$query = "";
$field_arr = $assocFieldsArray[$fieldName];
$query = "SELECT ";
if(is_array($field_arr['select_field_name'])){
$count = count($field_arr['select_field_name']);
$index = 1;
foreach($field_arr['select_field_name'] as $col){
$query .= $col;
if($index < $count){
$query .= ", ";
}
$index++;
}
}
else{
$query .= $field_arr['select_field_name'];
}
$query .= " FROM ".$field_arr['table_name']." WHERE ".$field_arr['select_field_join']." = '".$fieldValue."'";
$result = $focus->db->query($query);
if(!empty($result)){
if($row = $focus->db->fetchByAssoc($result)){
if(is_array($field_arr['select_field_name'])){
$returnVal = "";
foreach($field_arr['select_field_name'] as $col){
$returnVal .= $row[$col]." ";
}
return $returnVal;
}
else{
return $row[$field_arr['select_field_name']];
}
}
}
}
}
?>

197
modules/Audit/Popup_picker.php Executable file
View File

@@ -0,0 +1,197 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* 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. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once("include/upload_file.php");
require_once('include/utils/db_utils.php');
require_once('modules/Audit/Audit.php');
global $beanList, $beanFiles, $currentModule, $focus, $action, $app_strings, $app_list_strings, $current_language, $timedate, $mod_strings;
//we don't want the parent module's string file, but rather the string file specifc to this subpanel
$bean = $beanList[$_REQUEST['module_name']];
require_once($beanFiles[$bean]);
$focus = new $bean;
class Popup_Picker
{
/*
*
*/
function Popup_Picker()
{
}
/**
*
*/
function process_page()
{
global $theme;
global $focus;
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $currentModule;
global $odd_bg;
global $even_bg;
global $audit;
global $current_language;
$audit_list = Audit::get_audit_list();
$xtpl=new XTemplate ('modules/Audit/Popup_picker.html');
$xtpl->assign('MOD', $mod_strings);
$xtpl->assign('APP', $app_strings);
insert_popup_header($theme);
//output header
echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
$mod_strings = return_module_language($current_language, $focus->module_dir);
$printImageURL = SugarThemeRegistry::current()->getImageURL('print.gif');
$titleExtra = <<<EOHTML
<a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
<img src="{$printImageURL}" alt="{$GLOBALS['app_strings']['LNK_PRINT']}"></a>
<a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
{$GLOBALS['app_strings']['LNK_PRINT']}
</a>
EOHTML;
$params = array();
$params[] = translate('LBL_MODULE_NAME', $focus->module_dir);
$params[] = $focus->get_summary_text();
$params[] = translate('LBL_CHANGE_LOG', 'Audit');
echo str_replace('</div>',"<span class='utils'>$titleExtra</span></div>",getClassicModuleTitle($focus->module_dir, $params, false));
$oddRow = true;
$audited_fields = $focus->getAuditEnabledFieldDefinitions();
asort($audited_fields);
$fields = '';
$field_count = count($audited_fields);
$start_tag = "<table><tr><td >";
$end_tag = "</td></tr></table>";
if($field_count > 0)
{
$index = 0;
foreach($audited_fields as $key=>$value)
{
$index++;
$vname = '';
if(isset($value['vname']))
$vname = $value['vname'];
else if(isset($value['label']))
$vname = $value['label'];
$fields .= str_replace(':', '', translate($vname, $focus->module_dir));
if($index < $field_count)
{
$fields .= ", ";
}
}
echo $start_tag.translate('LBL_AUDITED_FIELDS', 'Audit').$fields.$end_tag;
}
else
{
echo $start_tag.translate('LBL_AUDITED_FIELDS', 'Audit').$end_tag;
}
foreach($audit_list as $audit)
{
if(empty($audit['before_value_string']) && empty($audit['after_value_string']))
{
$before_value = $audit['before_value_text'];
$after_value = $audit['after_value_text'];
}
else {
$before_value = $audit['before_value_string'];
$after_value = $audit['after_value_string'];
}
// Let's run the audit data through the sugar field system
if(isset($audit['data_type'])){
require_once('include/SugarFields/SugarFieldHandler.php');
$vardef = array('name'=>'audit_field','type'=>$audit['data_type']);
$field = SugarFieldHandler::getSugarField($audit['data_type']);
$before_value = $field->getChangeLogSmarty(array($vardef['name']=>$before_value), $vardef, array(), $vardef['name']);
$after_value = $field->getChangeLogSmarty(array($vardef['name']=>$after_value), $vardef, array(), $vardef['name']);
}
$activity_fields = array(
'ID' => $audit['id'],
'NAME' => $audit['field_name'],
'BEFORE_VALUE' => $before_value,
'AFTER_VALUE' => $after_value,
'CREATED_BY' => $audit['created_by'],
'DATE_CREATED' => $audit['date_created'],
);
$xtpl->assign("ACTIVITY", $activity_fields);
if($oddRow)
{
//todo move to themes
$xtpl->assign("ROW_COLOR", 'oddListRow');
$xtpl->assign("BG_COLOR", $odd_bg);
}
else
{
//todo move to themes
$xtpl->assign("ROW_COLOR", 'evenListRow');
$xtpl->assign("BG_COLOR", $even_bg);
}
$oddRow = !$oddRow;
$xtpl->parse("audit.row");
// Put the rows in.
}//end foreach
$xtpl->parse("audit");
$xtpl->out("audit");
insert_popup_footer();
}
} // end of class Popup_Picker
?>

85
modules/Audit/field_assoc.php Executable file
View File

@@ -0,0 +1,85 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* 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. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
global $genericAssocFieldsArray;
global $moduleAssocFieldsArray;
$genericAssocFieldsArray = array('assigned_user_id' =>
array('table_name' => 'users',
'select_field_name' => 'user_name',
'select_field_join' => 'id',
),
'account_id' =>
array('table_name' => 'accounts',
'select_field_name' => 'name',
'select_field_join' => 'id',
),
'contact_id' =>
array('table_name' => 'contacts',
'select_field_name' =>
array('first_name',
'last_name',
),
'select_field_join' => 'id',
),
'fixed_in_release' =>
array('table_name' => 'releases',
'select_field_name' => 'name',
'select_field_join' => 'id',
),
'found_in_release' =>
array('table_name' => 'releases',
'select_field_name' => 'name',
'select_field_join' => 'id',
),
);
$moduleAssocFieldsArray = array('Account' =>
array('parent_id' =>
array('table_name' => 'accounts',
'select_field_name' => 'name',
'select_field_join' => 'id',
)
),
);
?>

View File

@@ -0,0 +1,49 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* 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. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$mod_strings = array (
'LBL_FIELD_NAME' => 'Field',
'LBL_OLD_NAME' => 'Old Value',
'LBL_NEW_VALUE' => 'New Value',
'LBL_CREATED_BY' => 'Changed By',
'LBL_LIST_DATE' => 'Change Date',
'LBL_AUDITED_FIELDS' => 'Fields audited in this module: ',
'LBL_NO_AUDITED_FIELDS_TEXT' => 'There are no fields audited in this module',
'LBL_CHANGE_LOG' => 'Change Log',
);

View File

@@ -0,0 +1,47 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version
* 1.1.3 ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* All copies of the Covered Code must include on each user interface screen:
* (i) the "Powered by SugarCRM" logo and
* (ii) the SugarCRM copyright notice
* in the same form as they appear in the distribution. See full license for
* requirements.
*
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) 2004-2005 SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* pl_pl.lang.ext.php,v for SugarCRM 4.5.1->>
* Translator: Krzysztof Morawski
* All Rights Reserved.
* Any bugs report welcome: krzysiek<at>kmmgroup<dot>pl
* Contributor(s): ______________________________________..
********************************************************************************/
$mod_strings = array (
'LBL_FIELD_NAME' => 'Pole',
'LBL_OLD_NAME' => 'Poprzednia wartość',
'LBL_NEW_VALUE' => 'Nowa wartość',
'LBL_CREATED_BY' => 'Zmienione przez',
'LBL_LIST_DATE' => 'Data zmiany',
'LBL_AUDITED_FIELDS' => 'Pola kontrolne w tym module: ',
'LBL_NO_AUDITED_FIELDS_TEXT' => 'Nie ma żadnych pól kontrolonych w tym module.',
//add 26.09.2011
'LBL_CHANGE_LOG'=> 'Dziennik zmian',
);
?>

38
modules/Audit/vardefs.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* 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. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$dictionary['Audit'] = array();
?>