Add php files
This commit is contained in:
115
include/SugarFields/Fields/Address/SugarFieldAddress.php
Executable file
115
include/SugarFields/Fields/Address/SugarFieldAddress.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* SugarFieldAddress.php
|
||||
* SugarFieldAddress translates and displays fields from a vardef definition into different formats
|
||||
* for EditViews and DetailViews. A sample invocation from a Meta-Data file is as follows:
|
||||
*
|
||||
* array (
|
||||
* 'name' => 'primary_address_street',
|
||||
* 'type' => 'address',
|
||||
* 'displayParams'=>array('key'=>'primary'),
|
||||
* ),
|
||||
*
|
||||
* Where name is set to the field for ACL verification, type is set to 'address'
|
||||
* to override the default field type and the displayParams array includes the key
|
||||
* for the address field. Assumptions are made that the vardefs.php contains address
|
||||
* elements with the corresponding names. There is the optional displayParam index
|
||||
* 'copy' that accepts as value the key of the other address fields. In our
|
||||
* example we may enable copying from the primary address fields with:
|
||||
*
|
||||
* array (
|
||||
* 'name' => 'altaddress_street',
|
||||
* 'type' => 'address',
|
||||
* 'displayParams'=>array('key'=>'alt', 'copy'=>'primary'),
|
||||
* ),
|
||||
*
|
||||
*/
|
||||
require_once('include/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
class SugarFieldAddress extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
global $app_strings;
|
||||
if(!isset($displayParams['key'])) {
|
||||
$GLOBALS['log']->debug($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);
|
||||
$this->ss->trigger_error($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);
|
||||
return;
|
||||
}
|
||||
|
||||
//Allow for overrides. You can specify a Smarty template file location in the language file.
|
||||
if(isset($app_strings['SMARTY_ADDRESS_DETAILVIEW'])) {
|
||||
$tplCode = $app_strings['SMARTY_ADDRESS_DETAILVIEW'];
|
||||
return $this->fetch($tplCode);
|
||||
}
|
||||
|
||||
global $current_language;
|
||||
if(isset($current_language) && file_exists('include/SugarFields/Fields/Address/' . $current_language . '.DetailView.tpl')) {
|
||||
return $this->fetch('include/SugarFields/Fields/Address/' . $current_language . '.DetailView.tpl');
|
||||
} else {
|
||||
return $this->fetch('include/SugarFields/Fields/Address/DetailView.tpl');
|
||||
} //if-else
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
global $app_strings;
|
||||
if(!isset($displayParams['key'])) {
|
||||
$GLOBALS['log']->debug($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);
|
||||
$this->ss->trigger_error($app_strings['ERR_ADDRESS_KEY_NOT_SPECIFIED']);
|
||||
return;
|
||||
}
|
||||
|
||||
//Allow for overrides. You can specify a Smarty template file location in the language file.
|
||||
if(isset($app_strings['SMARTY_ADDRESS_EDITVIEW'])) {
|
||||
$tplCode = $app_strings['SMARTY_ADDRESS_EDITVIEW'];
|
||||
return $this->fetch($tplCode);
|
||||
}
|
||||
|
||||
global $current_language;
|
||||
if(isset($current_language) && file_exists('include/SugarFields/Fields/Address/' . $current_language . '.EditView.tpl')) {
|
||||
return $this->fetch('include/SugarFields/Fields/Address/' . $current_language . '.EditView.tpl');
|
||||
} else {
|
||||
return $this->fetch('include/SugarFields/Fields/Address/EditView.tpl');
|
||||
} //if-else
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
342
include/SugarFields/Fields/Base/SugarFieldBase.php
Executable file
342
include/SugarFields/Fields/Base/SugarFieldBase.php
Executable file
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
/**
|
||||
* SugarFieldBase translates and displays fields from a vardef definition into different formats
|
||||
* including DetailView, ListView, EditView. It also provides Search Inputs and database queries
|
||||
* to handle searching
|
||||
*
|
||||
*/
|
||||
class SugarFieldBase {
|
||||
var $ss; // Sugar Smarty Object
|
||||
var $hasButton = false;
|
||||
function SugarFieldBase($type) {
|
||||
$this->type = $type;
|
||||
$this->ss = new Sugar_Smarty();
|
||||
}
|
||||
function fetch($path){
|
||||
$additional = '';
|
||||
if(!$this->hasButton && !empty($this->button)){
|
||||
$additional .= '<input type="button" class="button" ' . $this->button . '>';
|
||||
}
|
||||
if(!empty($this->buttons)){
|
||||
foreach($this->buttons as $v){
|
||||
$additional .= ' <input type="button" class="button" ' . $v . '>';
|
||||
}
|
||||
|
||||
}
|
||||
if(!empty($this->image)){
|
||||
$additional .= ' <img ' . $this->image . '>';
|
||||
}
|
||||
return $this->ss->fetch($path) . $additional;
|
||||
}
|
||||
|
||||
function findTemplate($view){
|
||||
static $tplCache = array();
|
||||
|
||||
if ( isset($tplCache[$this->type][$view]) ) {
|
||||
return $tplCache[$this->type][$view];
|
||||
}
|
||||
|
||||
$lastClass = get_class($this);
|
||||
$classList = array($this->type,str_replace('SugarField','',$lastClass));
|
||||
while ( $lastClass = get_parent_class($lastClass) ) {
|
||||
$classList[] = str_replace('SugarField','',$lastClass);
|
||||
}
|
||||
|
||||
$tplName = '';
|
||||
foreach ( $classList as $className ) {
|
||||
$tplName = 'include/SugarFields/Fields/'. $className .'/'. $view .'.tpl';
|
||||
if ( file_exists('custom/'.$tplName) ) {
|
||||
$tplName = 'custom/'.$tplName;
|
||||
break;
|
||||
}
|
||||
if ( file_exists($tplName) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tplCache[$this->type][$view] = $tplName;
|
||||
|
||||
return $tplName;
|
||||
}
|
||||
|
||||
public function formatField($rawField, $vardef){
|
||||
// The base field doesn't do any formatting, so override it in subclasses for more specific actions
|
||||
return $rawField;
|
||||
}
|
||||
|
||||
|
||||
public function unformatField($formattedField, $vardef){
|
||||
// The base field doesn't do any formatting, so override it in subclasses for more specific actions
|
||||
return $formattedField;
|
||||
}
|
||||
|
||||
function getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex = -1, $view){
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
|
||||
|
||||
return $this->fetch($this->findTemplate($view));
|
||||
}
|
||||
|
||||
function getListViewSmarty($parentFieldArray, $vardef, $displayParams, $col) {
|
||||
// FIXME: Rework the listview to use two-pass rendering like the DetailView
|
||||
|
||||
$tabindex = 1;
|
||||
$isArray = is_array($parentFieldArray);
|
||||
$fieldName = $vardef['name'];
|
||||
|
||||
if ( $isArray ) {
|
||||
$fieldNameUpper = strtoupper($fieldName);
|
||||
if ( isset($parentFieldArray[$fieldNameUpper])) {
|
||||
$parentFieldArray[$fieldName] = $this->formatField($parentFieldArray[$fieldNameUpper],$vardef);
|
||||
} else {
|
||||
$parentFieldArray[$fieldName] = '';
|
||||
}
|
||||
} else {
|
||||
if ( isset($parentFieldArray->$fieldName) ) {
|
||||
$parentFieldArray->$fieldName = $this->formatField($parentFieldArray->$fieldName,$vardef);
|
||||
} else {
|
||||
$parentFieldArray->$fieldName = '';
|
||||
}
|
||||
}
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex, false);
|
||||
|
||||
$this->ss->left_delimiter = '{';
|
||||
$this->ss->right_delimiter = '}';
|
||||
$this->ss->assign('col',$vardef['name']);
|
||||
|
||||
return $this->fetch($this->findTemplate('ListView'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a smarty template for the DetailViews
|
||||
*
|
||||
* @param parentFieldArray string name of the variable in the parent template for the bean's data
|
||||
* @param vardef vardef field defintion
|
||||
* @param displayParam parameters for display
|
||||
* available paramters are:
|
||||
* * labelSpan - column span for the label
|
||||
* * fieldSpan - column span for the field
|
||||
*/
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
return"<span id='{$vardef['name']}'>" . $this->getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex, 'DetailView') . '</span>';
|
||||
}
|
||||
|
||||
// 99% of all fields will just format like a listview, but just in case, it's here to override
|
||||
function getChangeLogSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
return $this->formatField($parentFieldArray[$vardef['name']],$vardef);
|
||||
}
|
||||
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
if(!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html'){
|
||||
$type = $this->type;
|
||||
$this->type = 'Base';
|
||||
$result= $this->getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
$this->type = $type;
|
||||
return $result;
|
||||
}
|
||||
return $this->getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex, 'EditView');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
if(!empty($vardef['auto_increment']))$vardef['len']=255;
|
||||
return $this->getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex, 'EditView');
|
||||
}
|
||||
|
||||
function getPopupViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){
|
||||
if (is_array($displayParams) && !isset($displayParams['formName']))
|
||||
$displayParams['formName'] = 'popup_query_form';
|
||||
else if (empty($displayParams))
|
||||
$displayParams = array('formName' => 'popup_query_form');
|
||||
return $this->getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
public function getEmailTemplateValue($inputField, $vardef, $displayParams = array(), $tabindex = 0){
|
||||
// This does not return a smarty section, instead it returns a direct value
|
||||
return $this->formatField($inputField,$vardef);
|
||||
}
|
||||
|
||||
function displayFromFunc( $displayType, $parentFieldArray, $vardef, $displayParams, $tabindex ) {
|
||||
|
||||
if ( ! is_array($vardef['function']) ) {
|
||||
$funcName = $vardef['function'];
|
||||
$includeFile = '';
|
||||
$onListView = false;
|
||||
$returnsHtml = false;
|
||||
} else {
|
||||
$funcName = $vardef['function']['name'];
|
||||
$includeFile = '';
|
||||
if ( isset($vardef['function']['include']) ) {
|
||||
$includeFile = $vardef['function']['include'];
|
||||
}
|
||||
if ( isset($vardef['function']['onListView']) && $vardef['function']['onListView'] == true ) {
|
||||
$onListView = true;
|
||||
} else {
|
||||
$onListView = false;
|
||||
}
|
||||
if ( isset($vardef['function']['returns']) && $vardef['function']['returns'] == 'html' ) {
|
||||
$returnsHtml = true;
|
||||
} else {
|
||||
$returnsHtml = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $displayType == 'ListView'
|
||||
|| $displayType == 'popupView'
|
||||
|| $displayType == 'searchView'
|
||||
|| $displayType == 'wirelessEditView'
|
||||
|| $displayType == 'wirelessDetailView'
|
||||
|| $displayType == 'wirelessListView'
|
||||
) {
|
||||
// Traditionally, before 6.0, additional functions were never called, so this code doesn't get called unless the vardef forces it
|
||||
if ( $onListView ) {
|
||||
if ( !empty($includeFile) ) {
|
||||
require_once($includeFile);
|
||||
}
|
||||
|
||||
return $funcName($parentFieldArray, $vardef['name'], $parentFieldArray[$vardef['name']], $displayType);
|
||||
} else {
|
||||
$displayTypeFunc = 'get'.$displayType.'Smarty';
|
||||
return $this->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
} else {
|
||||
if ( !empty($displayParams['idName']) ) {
|
||||
$fieldName = $displayParams['idName'];
|
||||
} else {
|
||||
$fieldName = $vardef['name'];
|
||||
}
|
||||
if ( $returnsHtml ) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
$tpl = $this->findTemplate($displayType.'Function');
|
||||
if ( $tpl == '' ) {
|
||||
// Can't find a function template, just use the base
|
||||
$tpl = $this->findTemplate('DetailViewFunction');
|
||||
}
|
||||
return "<span id='{$vardef['name']}'>" . $this->fetch($tpl) . '</span>';
|
||||
} else {
|
||||
return '{sugar_run_helper include="'.$includeFile.'" func="'.$funcName.'" bean=$bean field="'.$fieldName.'" value=$fields.'.$fieldName.'.value displayType="'.$displayType.'"}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getEditView() {
|
||||
}
|
||||
|
||||
function getSearchInput() {
|
||||
}
|
||||
|
||||
function getQueryLike() {
|
||||
}
|
||||
|
||||
function getQueryIn() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup function to assign values to the smarty template, should be called before every display function
|
||||
*/
|
||||
function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass=true) {
|
||||
$this->button = '';
|
||||
$this->buttons = '';
|
||||
$this->image = '';
|
||||
if ($twopass){
|
||||
$this->ss->left_delimiter = '{{';
|
||||
$this->ss->right_delimiter = '}}';
|
||||
}
|
||||
$this->ss->assign('parentFieldArray', $parentFieldArray);
|
||||
$this->ss->assign('vardef', $vardef);
|
||||
$this->ss->assign('tabindex', $tabindex);
|
||||
|
||||
//for adding attributes to the field
|
||||
|
||||
if(!empty($displayParams['field'])){
|
||||
$plusField = '';
|
||||
foreach($displayParams['field'] as $key=>$value){
|
||||
$plusField .= ' ' . $key . '="' . $value . '"';//bug 27381
|
||||
}
|
||||
$displayParams['field'] = $plusField;
|
||||
}
|
||||
//for adding attributes to the button
|
||||
if(!empty($displayParams['button'])){
|
||||
$plusField = '';
|
||||
foreach($displayParams['button'] as $key=>$value){
|
||||
$plusField .= ' ' . $key . '="' . $value . '"';
|
||||
}
|
||||
$displayParams['button'] = $plusField;
|
||||
$this->button = $displayParams['button'];
|
||||
}
|
||||
if(!empty($displayParams['buttons'])){
|
||||
$plusField = '';
|
||||
foreach($displayParams['buttons'] as $keys=>$values){
|
||||
foreach($values as $key=>$value){
|
||||
$plusField[$keys] .= ' ' . $key . '="' . $value . '"';
|
||||
}
|
||||
}
|
||||
$displayParams['buttons'] = $plusField;
|
||||
$this->buttons = $displayParams['buttons'];
|
||||
}
|
||||
if(!empty($displayParams['image'])){
|
||||
$plusField = '';
|
||||
foreach($displayParams['image'] as $key=>$value){
|
||||
$plusField .= ' ' . $key . '="' . $value . '"';
|
||||
}
|
||||
$displayParams['image'] = $plusField;
|
||||
$this->image = $displayParams['image'];
|
||||
}
|
||||
$this->ss->assign('displayParams', $displayParams);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be called when the bean is saved. The bean itself will be passed by reference
|
||||
* @param SugarBean bean - the bean performing the save
|
||||
* @param array params - an array of paramester relevant to the save, most likely will be $_REQUEST
|
||||
*/
|
||||
public function save(&$bean, $params, $field, $properties, $prefix = ''){
|
||||
if ( isset($params[$prefix.$field]) ) {
|
||||
if(isset($properties['len']) && isset($properties['type']) && 'varchar' == $properties['type']){
|
||||
$bean->$field = trim($this->unformatField($params[$prefix.$field],$properties));
|
||||
}
|
||||
else {
|
||||
$bean->$field = $this->unformatField($params[$prefix.$field],$properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
89
include/SugarFields/Fields/Bool/SugarFieldBool.php
Executable file
89
include/SugarFields/Fields/Bool/SugarFieldBool.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldBool extends SugarFieldBase {
|
||||
/**
|
||||
*
|
||||
* @return The html for a drop down if the search field is not 'my_items_only' or a dropdown for all other fields.
|
||||
* This strange behavior arises from the special needs of PM. They want the my items to be checkboxes and all other boolean fields to be dropdowns.
|
||||
* @author Navjeet Singh
|
||||
* @param $parentFieldArray -
|
||||
**/
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
if( preg_match("/current_user_only.*/", $vardef['name']) || preg_match("/empty.*/", $vardef['name'])){
|
||||
return $this->fetch('include/SugarFields/Fields/Bool/EditView.tpl');
|
||||
}else{
|
||||
if( preg_match("/isHidden.*/", $vardef['name']) || preg_match("/empty.*/", $vardef['name'])){
|
||||
return $this->fetch('include/SugarFields/Fields/Bool/EditView.tpl');
|
||||
}else{
|
||||
return $this->fetch('include/SugarFields/Fields/Bool/SearchView.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getEmailTemplateValue($inputField, $vardef, $displayParams = array(), $tabindex = 0){
|
||||
global $app_list_strings;
|
||||
// This does not return a smarty section, instead it returns a direct value
|
||||
if ( $inputField == 'bool_true' || $inputField == true ) {
|
||||
return $app_list_strings['checkbox_dom']['1'];
|
||||
} else {
|
||||
return $app_list_strings['checkbox_dom']['2'];
|
||||
}
|
||||
}
|
||||
|
||||
public function unformatField($formattedField, $vardef){
|
||||
if ( empty($formattedField) ) {
|
||||
$unformattedField = false;
|
||||
return $unformattedField;
|
||||
}
|
||||
if ( $formattedField == '0' || $formattedField == 'off' || $formattedField == 'false' || $formattedField == 'no' ) {
|
||||
$unformattedField = false;
|
||||
} else {
|
||||
$unformattedField = true;
|
||||
}
|
||||
|
||||
return $unformattedField;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
221
include/SugarFields/Fields/Collection/SugarFieldCollection.php
Executable file
221
include/SugarFields/Fields/Collection/SugarFieldCollection.php
Executable file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
class SugarFieldCollection extends SugarFieldBase {
|
||||
var $tpl_path;
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$nolink = array('Users');
|
||||
if(in_array($vardef['module'], $nolink)){
|
||||
$displayParams['nolink']=true;
|
||||
}else{
|
||||
$displayParams['nolink']=false;
|
||||
}
|
||||
$json = getJSONobj();
|
||||
$displayParamsJSON = $json->encode($displayParams);
|
||||
$vardefJSON = $json->encode($vardef);
|
||||
$this->ss->assign('displayParamsJSON', '{literal}'.$displayParamsJSON.'{/literal}');
|
||||
$this->ss->assign('vardefJSON', '{literal}'.$vardefJSON.'{/literal}');
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
if(empty($this->tpl_path)){
|
||||
$this->tpl_path = 'include/SugarFields/Fields/Collection/DetailView.tpl';
|
||||
}
|
||||
return $this->fetch($this->tpl_path);
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex, $searchView = false) {
|
||||
if($searchView){
|
||||
$form_name = 'search_form';
|
||||
}else{
|
||||
$form_name = 'EditView';
|
||||
}
|
||||
$json = getJSONobj();
|
||||
$displayParamsJSON = $json->encode($displayParams);
|
||||
$vardefJSON = $json->encode($vardef);
|
||||
$this->ss->assign('required', !empty($vardef['required']));
|
||||
$this->ss->assign('displayParamsJSON', '{literal}'.$displayParamsJSON.'{/literal}');
|
||||
$this->ss->assign('vardefJSON', '{literal}'.$vardefJSON.'{/literal}');
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
if(!$searchView) {
|
||||
if(empty($this->tpl_path)){
|
||||
$this->tpl_path = 'include/SugarFields/Fields/Collection/EditView.tpl';
|
||||
}
|
||||
return $this->fetch($this->tpl_path);
|
||||
}
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex, true);
|
||||
}
|
||||
/**
|
||||
* This should be called when the bean is saved. The bean itself will be passed by reference
|
||||
* @param SugarBean bean - the bean performing the save
|
||||
* @param array params - an array of paramester relevant to the save, most likely will be $_REQUEST
|
||||
*/
|
||||
public function save(&$bean, $params, $field, $properties, $prefix = ''){
|
||||
if(isset($_POST["primary_" . $field . "_collection"])){
|
||||
$save = false;
|
||||
$value_name = $field . "_values";
|
||||
$link_field = array();
|
||||
// populate $link_field from POST
|
||||
foreach($_POST as $name=>$value){
|
||||
if(strpos($name, $field . "_collection_") !== false){
|
||||
$num = substr($name, -1);
|
||||
if(is_numeric($num)){
|
||||
settype($num, 'int');
|
||||
if(strpos($name, $field . "_collection_extra_") !== false){
|
||||
$extra_field = substr($name, $field . "_collection_extra_" . $num);
|
||||
$link_field[$num]['extra_field'][$extra_field]=$value;
|
||||
}else if ($name == $field . "_collection_" . $num){
|
||||
$link_field[$num]['name']=$value;
|
||||
}else if ($name == "id_" . $field . "_collection_" . $num){
|
||||
$link_field[$num]['id']=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set Primary
|
||||
if(isset($_POST["primary_" . $field . "_collection"])){
|
||||
$primary = $_POST["primary_" . $field . "_collection"];
|
||||
settype($primary, 'int');
|
||||
$link_field[$primary]['primary']=true;
|
||||
}
|
||||
// Create or update record and take care of the extra_field
|
||||
require('include/modules.php');
|
||||
require_once('data/Link.php');
|
||||
$class = load_link_class($bean->field_defs[$field]);
|
||||
|
||||
$link_obj = new $class($bean->field_defs[$field]['relationship'], $bean, $bean->field_defs[$field]);
|
||||
$module = $link_obj->getRelatedModuleName();
|
||||
$beanName = $beanList[$module];
|
||||
require_once($beanFiles[$beanName]);
|
||||
foreach($link_field as $k=>$v){
|
||||
$save = false;
|
||||
$update_fields = array();
|
||||
$obj = new $beanName();
|
||||
if(!isset($link_field[$k]['name']) || empty($link_field[$k]['name'])){
|
||||
// There is no name so it is an empty record -> ignore it!
|
||||
unset($link_field[$k]);
|
||||
break;
|
||||
}
|
||||
if(!isset($link_field[$k]['id']) || empty($link_field[$k]['id']) || (isset($_POST[$field . "_new_on_update"]) && $_POST[$field . "_new_on_update"] === 'true')){
|
||||
// Create a new record
|
||||
if(isset($_POST[$field . "_allow_new"]) && ($_POST[$field . "_allow_new"] === 'false' || $_POST[$field . "_allow_new"] === false)){
|
||||
// Not allow to create a new record so remove from $link_field
|
||||
unset($link_field[$k]);
|
||||
break;
|
||||
}
|
||||
if(!isset($link_field[$k]['id']) || empty($link_field[$k]['id'])){
|
||||
// There is no ID so it is a new record
|
||||
$save = true;
|
||||
$obj->name=$link_field[$k]['name'];
|
||||
}else{
|
||||
// We duplicate an existing record because new_on_update is set
|
||||
$obj->retrieve($link_field[$k]['id']);
|
||||
$obj->id='';
|
||||
$obj->name = $obj->name . '_DUP';
|
||||
}
|
||||
}else{
|
||||
// id exist so retrieve the data
|
||||
$obj->retrieve($link_field[$k]['id']);
|
||||
}
|
||||
// Update the extra field for the new or the existing record
|
||||
if(isset($v['extra_field']) && is_array($v['extra_field'])){
|
||||
// Retrieve the changed fields
|
||||
if(isset($_POST["update_fields_{$field}_collection"]) && !empty($_POST["update_fields_{$field}_collection"])){
|
||||
$JSON = getJSONobj();
|
||||
$update_fields = $JSON->decode(html_entity_decode($_POST["update_fields_{$field}_collection"]));
|
||||
}
|
||||
// Update the changed fields
|
||||
foreach($update_fields as $kk=>$vv){
|
||||
if(!isset($_POST[$field . "_allow_update"]) || ($_POST[$field . "_allow_update"] !== 'false' && $_POST[$field . "_allow_update"] !== false)){
|
||||
//allow to update the extra_field in the record
|
||||
if(isset($v['extra_field'][$kk]) && $vv == true){
|
||||
$extra_field_name = str_replace("_".$field."_collection_extra_".$k,"",$kk);
|
||||
if($obj->$extra_field_name != $v['extra_field'][$kk]){
|
||||
$save = true;
|
||||
$obj->$extra_field_name=$v['extra_field'][$kk];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Save the new or updated record
|
||||
if($save){
|
||||
if(!$obj->ACLAccess('save')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
$obj->save();
|
||||
$link_field[$k]['id']=$obj->id;
|
||||
}
|
||||
}
|
||||
// Save new relationship or delete deleted relationship
|
||||
if(!empty($link_field)){
|
||||
if($bean->load_relationship($field)){
|
||||
$oldvalues = $bean->$field->get(true);
|
||||
$role_field = $bean->$field->_get_link_table_role_field($bean->$field->_relationship_name);
|
||||
foreach($link_field as $new_v){
|
||||
if(!empty($new_v['id'])){
|
||||
if(!empty($role_field)){
|
||||
if(isset($new_v['primary']) && $new_v['primary']){
|
||||
$bean->$field->add($new_v['id'], array($role_field=>'primary'));
|
||||
}else{
|
||||
$bean->$field->add($new_v['id'], array($role_field=>'NULL'));
|
||||
}
|
||||
}else{
|
||||
$bean->$field->add($new_v['id'], array());
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($oldvalues as $old_v){
|
||||
$match = false;
|
||||
foreach($link_field as $new_v){
|
||||
if($new_v['id'] == $old_v['id']){
|
||||
$match = true;
|
||||
}
|
||||
}
|
||||
if(!$match){
|
||||
$bean->$field->delete($bean->id, $old_v['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
499
include/SugarFields/Fields/Collection/ViewSugarFieldCollection.php
Executable file
499
include/SugarFields/Fields/Collection/ViewSugarFieldCollection.php
Executable file
@@ -0,0 +1,499 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Collection/SugarFieldCollection.php');
|
||||
|
||||
|
||||
class ViewSugarFieldCollection{
|
||||
var $ss; // Sugar Smarty Object
|
||||
var $bean;
|
||||
var $bean_id;
|
||||
var $name;
|
||||
var $value_name;
|
||||
var $displayParams; // DisplayParams for the collection field (defined in the metadata)
|
||||
var $vardef; // vardef of the collection field.
|
||||
var $related_module; // module name of the related module
|
||||
var $module_dir; // name of the module where the collection field is.
|
||||
var $numFields;
|
||||
var $json;
|
||||
var $tpl_path;
|
||||
var $extra_var;
|
||||
var $skipModuleQuickSearch = false;
|
||||
var $field_to_name_array; //mapping of fields for the return of the select popup
|
||||
var $showSelectButton = true;
|
||||
var $hideShowHideButton = false;
|
||||
var $action_type;
|
||||
var $form_name;
|
||||
|
||||
function ViewSugarFieldCollection($fill_data = true){
|
||||
$this->json = getJSONobj();
|
||||
if($fill_data){
|
||||
$this->displayParams = $this->json->decode(html_entity_decode($_REQUEST['displayParams']));
|
||||
$this->vardef = $this->json->decode(html_entity_decode($_REQUEST['vardef']));
|
||||
$this->module_dir = $_REQUEST['module_dir'];
|
||||
$this->action_type = $_REQUEST['action_type'];
|
||||
$this->name = $this->vardef['name'];
|
||||
$this->value_name = $this->name . '_values';
|
||||
$this->numFields = 1;
|
||||
$this->ss = new Sugar_Smarty();
|
||||
$this->edit_tpl_path = 'include/SugarFields/Fields/Collection/CollectionEditView.tpl';
|
||||
$this->detail_tpl_path = 'include/SugarFields/Fields/Collection/CollectionDetailView.tpl';
|
||||
$this->extra_var = array();
|
||||
$this->field_to_name_array = array();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Retrieve the related module and load the bean and the relationship
|
||||
* call retrieve values()
|
||||
*/
|
||||
function setup(){
|
||||
if(!class_exists('Relationship')){
|
||||
|
||||
}
|
||||
$rel = new Relationship();
|
||||
if(!empty($this->vardef['relationship'])){
|
||||
$rel->retrieve_by_name($this->vardef['relationship']);
|
||||
}
|
||||
if($rel->relationship_type == 'many-to-many'){
|
||||
if($rel->lhs_module == $this->module_dir){
|
||||
$this->related_module = $rel->rhs_module;
|
||||
$module_dir = $rel->lhs_module;
|
||||
}else if($rel->rhs_module == $this->module_dir){
|
||||
$this->related_module = $rel->lhs_module;
|
||||
$module_dir = $rel->rhs_module;
|
||||
}else{
|
||||
die("this field has no relationships mapped with this module");
|
||||
}
|
||||
if($module_dir != $this->module_dir){
|
||||
die('These modules do not match : '. $this->module_dir . ' and ' . $module_dir);
|
||||
}
|
||||
if(isset($GLOBALS['beanList'][$this->module_dir])){
|
||||
$class = $GLOBALS['beanList'][$this->module_dir];
|
||||
if(file_exists($GLOBALS['beanFiles'][$class])){
|
||||
$this->bean = loadBean($this->module_dir);
|
||||
$this->bean->retrieve($_REQUEST['bean_id']);
|
||||
if($this->bean->load_relationship($this->vardef['name'])){
|
||||
$this->retrieve_values();
|
||||
}else{
|
||||
die('failed to load the relationship');
|
||||
}
|
||||
}else{
|
||||
die('class file do not exist');
|
||||
}
|
||||
}else{
|
||||
die($this->module_dir . ' is not in the beanList.');
|
||||
}
|
||||
}
|
||||
else{
|
||||
die("the relationship is not a many-to-many");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Retrieve the values from the DB using the get method of the link class
|
||||
* Organize and save the value into the bean
|
||||
*/
|
||||
function retrieve_values(){
|
||||
if(empty($this->bean->{$this->value_name}) && isset($this->bean->{$this->name})){
|
||||
$values = array();
|
||||
$values = $this->bean->{$this->name}->get(true);
|
||||
$role_field = $this->bean->{$this->name}->_get_link_table_role_field($this->bean->{$this->name}->_relationship_name);
|
||||
foreach($values as $v){
|
||||
$role = '';
|
||||
foreach($v as $kk=>$vv){
|
||||
if($kk == $role_field){
|
||||
$role=$vv;
|
||||
}
|
||||
}
|
||||
if($role == 'primary'){
|
||||
$primary_id = $v['id'];
|
||||
}else{
|
||||
$secondary_ids[] = array('id'=>$v['id'], 'role'=>$role);
|
||||
}
|
||||
}
|
||||
$this->bean->{$this->value_name} = array('role_field'=>$role_field);
|
||||
if(isset($primary_id) || isset($secondary_ids)){
|
||||
if(!isset($primary_id)){
|
||||
$primary_id = $secondary_ids[0]['id'];
|
||||
unset($secondary_ids[0]);
|
||||
}
|
||||
if(isset($GLOBALS['beanList'][ $this->related_module])){
|
||||
$class = $GLOBALS['beanList'][$this->related_module];
|
||||
if(file_exists($GLOBALS['beanFiles'][$class])){
|
||||
$mod = loadBean($this->module_dir);
|
||||
$mod->relDepth = $this->bean->relDepth + 1;
|
||||
$mod->retrieve($primary_id);
|
||||
if (isset($mod->name)) {
|
||||
$this->bean->{$this->value_name}=array_merge($this->bean->{$this->value_name}, array('primary'=>array('id'=>$primary_id, 'name'=>$mod->name)));
|
||||
}
|
||||
$secondaries = array();
|
||||
if(isset($secondary_ids)){
|
||||
foreach($secondary_ids as $v){
|
||||
if($mod->retrieve($v['id'])){
|
||||
if (isset($mod->name)){
|
||||
$secondaries['secondaries'][]=array('id'=>$v['id'], 'name'=>$mod->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->bean->{$this->value_name}=array_merge($this->bean->{$this->value_name}, $secondaries);
|
||||
if(isset($field['additionalFields'])){
|
||||
foreach($field['additionalFields'] as $field=>$to){
|
||||
if(isset($mod->$field)){
|
||||
$this->bean->$to = $mod->$field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* redirect to the good process method.
|
||||
*/
|
||||
function process(){
|
||||
if($this->action_type == 'editview'){
|
||||
$this->process_editview();
|
||||
}else if($this->action_type == 'detailview'){
|
||||
$this->process_detailview();
|
||||
}
|
||||
}
|
||||
function process_detailview(){
|
||||
|
||||
}
|
||||
/*
|
||||
* Build the DisplayParams array
|
||||
*/
|
||||
function process_editview(){
|
||||
if(isset($this->bean->{$this->value_name}['secondaries'])){
|
||||
$this->numFields=count($this->bean->{$this->value_name}['secondaries'])+1;
|
||||
}
|
||||
if(!isset($this->displayParams['readOnly'])) {
|
||||
$this->displayParams['readOnly'] = '';
|
||||
} else {
|
||||
$this->displayParams['readOnly'] = $this->displayParams['readOnly'] == false ? '' : 'READONLY';
|
||||
}
|
||||
// If there is extra field to show.
|
||||
if(isset($this->displayParams['collection_field_list'])){
|
||||
|
||||
require_once('include/SugarFields/SugarFieldHandler.php');
|
||||
$sfh = new SugarFieldHandler();
|
||||
vardefmanager::loadVardef($this->related_module, $GLOBALS['beanList'][$this->related_module]);
|
||||
foreach($this->displayParams['collection_field_list'] as $k=>$v){
|
||||
$javascript='';
|
||||
$collection_field_vardef = $GLOBALS['dictionary'][$GLOBALS['beanList'][$this->related_module]]['fields'][$v['name']];
|
||||
|
||||
// For each extra field the params which are not displayParams will be consider as params to override the vardefs values.
|
||||
foreach($v as $k_override=>$v_override){
|
||||
if($k_override != 'displayParams'){
|
||||
$collection_field_vardef[$k_override] = $v_override;
|
||||
}
|
||||
}
|
||||
|
||||
// If relate field : enable quick search by creating the sqs_object array.
|
||||
if($collection_field_vardef['type'] == 'relate'){
|
||||
require_once('include/TemplateHandler/TemplateHandler.php');
|
||||
$tph = new TemplateHandler();
|
||||
$javascript = $tph->createQuickSearchCode(array($collection_field_vardef['name']=>$collection_field_vardef), array($v), $this->form_name);
|
||||
$javascript = str_replace('<script language="javascript">'."if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}']=","",$javascript);
|
||||
$javascript = substr($javascript, 0, -10);//remove ";</script>"
|
||||
$javascriptPHP = $this->json->decode($javascript);
|
||||
foreach($javascriptPHP['populate_list'] as $kk=>$vv){
|
||||
$javascriptPHP['populate_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
|
||||
}
|
||||
foreach($javascriptPHP['required_list'] as $kk=>$vv){
|
||||
$javascriptPHP['required_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
|
||||
}
|
||||
foreach($javascriptPHP['field_list'] as $kk=>$vv){
|
||||
if($vv == 'id'){
|
||||
$javascriptPHP['populate_list'][$kk];
|
||||
}
|
||||
}
|
||||
$javascript = $this->json->encode($javascriptPHP);
|
||||
$javascript = "<script language='javascript'>if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}_" . $this->vardef['name'] . "_collection_extra_0']=".$javascript.';</script>';
|
||||
}
|
||||
|
||||
$collection_field_vardef['name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
|
||||
if(isset($collection_field_vardef['id_name'])){
|
||||
$collection_field_vardef['id_name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
|
||||
}
|
||||
if(isset($this->displayParams['allow_update']) && ($this->displayParams['allow_update'] === false || $this->displayParams['allow_update'] === 'false')){
|
||||
$this->displayParams['allow_update']='false';
|
||||
$v['displayParams']['field']['disabled']='';
|
||||
}else{
|
||||
$this->displayParams['allow_update']='true';
|
||||
if(!isset($v['displayParams'])){
|
||||
$v['displayParams']=array();
|
||||
}
|
||||
}
|
||||
$viewtype='EditView';
|
||||
$name = $collection_field_vardef['name'];
|
||||
// Rearranging the array with name as key instaead of number. This is required for displaySmarty() to assign the good variable.
|
||||
$this->displayParams['collection_field_list'][$name]['vardefName'] = $this->displayParams['collection_field_list'][$k]['name'];
|
||||
$this->displayParams['collection_field_list'][$name]['name'] = $name;
|
||||
if($collection_field_vardef['type'] == 'relate'){
|
||||
$this->displayParams['collection_field_list'][$name]['id_name'] = $collection_field_vardef['id_name'];
|
||||
$this->displayParams['collection_field_list'][$name]['module'] = $collection_field_vardef['module'];
|
||||
}
|
||||
$this->displayParams['collection_field_list'][$name]['label'] = "{sugar_translate label='{$collection_field_vardef['vname']}' module='{$this->related_module}'}";//translate($collection_field_vardef['vname'], $this->related_module);
|
||||
$this->displayParams['collection_field_list'][$name]['field'] = $sfh->displaySmarty('displayParams.collection_field_list', $collection_field_vardef, $viewtype, $v['displayParams'], 1);
|
||||
$this->displayParams['collection_field_list'][$name]['field'] .= '{literal}'.$javascript;
|
||||
// Handle update_field array ONCHANGE
|
||||
$this->displayParams['collection_field_list'][$name]['field'] .= <<<FRA
|
||||
<script language='javascript'>
|
||||
var oldonchange = '';
|
||||
if(typeof(document.getElementById('{$collection_field_vardef['name']}').attributes.onchange) != 'undefined')
|
||||
{
|
||||
oldonchange=document.getElementById('{$collection_field_vardef['name']}').attributes.onchange.value;
|
||||
}
|
||||
FRA;
|
||||
$this->displayParams['collection_field_list'][$name]['field'] .= "eval(\"document.getElementById('{$collection_field_vardef['name']}').onchange = function onchange(event){collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['name']}=true;";
|
||||
if($collection_field_vardef['type'] == 'relate'){
|
||||
// If relate add the ID field to the array
|
||||
$this->displayParams['collection_field_list'][$name]['field'] .= "collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['id_name']}=true;";
|
||||
}
|
||||
$this->displayParams['collection_field_list'][$name]['field'] .= "document.getElementById('update_fields_{$this->vardef['name']}_collection').value = JSON.stringifyNoSecurity(collection['{$this->vardef['name']}'].update_fields);\" + oldonchange + \"};\");</script>{/literal}";
|
||||
//we need to get rid of the old value;
|
||||
unset($this->displayParams['collection_field_list'][$k]);
|
||||
}
|
||||
}
|
||||
if(!isset($this->displayParams['class'])) $this->displayParams['class']='';
|
||||
if(isset($this->displayParams['allow_new']) && ($this->displayParams['allow_new'] === false || $this->displayParams['allow_new'] === 'false')){
|
||||
$this->displayParams['allow_new']='false';
|
||||
$this->displayParams['class']=str_replace('sqsNoAutofill','',$this->displayParams['class']);
|
||||
}else{
|
||||
$this->displayParams['allow_new']='true';
|
||||
$this->displayParams['class'].=' sqsNoAutofill';
|
||||
}
|
||||
if(isset($this->displayParams['new_on_update']) && ($this->displayParams['new_on_update'] !== false || $this->displayParams['new_on_update'] !== 'false' || $this->displayParams['new_on_update'] !== 'FALSE' || $this->displayParams['new_on_update'] !== '0')){
|
||||
$this->displayParams['new_on_update']='true';
|
||||
}else{
|
||||
$this->displayParams['new_on_update']='false';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Init the template with the variables
|
||||
*/
|
||||
function init_tpl(){
|
||||
foreach($this->extra_var as $k=>$v){
|
||||
$this->ss->assign($k,$v);
|
||||
}
|
||||
if($this->action_type == 'editview'){
|
||||
$this->ss->assign('quickSearchCode',$this->createQuickSearchCode());
|
||||
$this->createPopupCode();// this code populate $this->displayParams with popupdata.
|
||||
$this->tpl_path = $this->edit_tpl_path;
|
||||
}else if($this->action_type == 'detailview'){
|
||||
$this->tpl_path = $this->detail_tpl_path;
|
||||
}
|
||||
|
||||
$this->ss->assign('displayParams',$this->displayParams);
|
||||
$this->ss->assign('vardef',$this->vardef);
|
||||
$this->ss->assign('module',$this->related_module);
|
||||
$this->ss->assign('values',$this->bean->{$this->value_name});
|
||||
$this->ss->assign('showSelectButton',$this->showSelectButton);
|
||||
$this->ss->assign('hideShowHideButton',$this->hideShowHideButton);
|
||||
$this->ss->assign('APP',$GLOBALS['app_strings']);
|
||||
}
|
||||
/*
|
||||
* Display the collection field after retrieving the cached row.
|
||||
*/
|
||||
function display(){
|
||||
$cacheRowFile = $GLOBALS['sugar_config']['cache_dir'] . 'modules/'. $this->module_dir . '/collections/'. $this->name . '.tpl';
|
||||
if(!$this->checkTemplate($cacheRowFile)){
|
||||
$dir = dirname($cacheRowFile);
|
||||
if(!file_exists($dir)) {
|
||||
|
||||
mkdir_recursive($dir, null, true);
|
||||
}
|
||||
$cacheRow = $this->ss->fetch('include/SugarFields/Fields/Collection/CollectionEditViewRow.tpl');
|
||||
file_put_contents($cacheRowFile, $cacheRow);
|
||||
}
|
||||
$this->ss->assign('cacheRowFile', $cacheRowFile);
|
||||
return $this->ss->fetch($this->tpl_path);
|
||||
}
|
||||
/*
|
||||
* Check if the template is cached
|
||||
* return a bool
|
||||
*/
|
||||
function checkTemplate($cacheRowFile){
|
||||
if(!empty($GLOBALS['sugar_config']['developerMode']) || !empty($_SESSION['developerMode'])){
|
||||
return false;
|
||||
}
|
||||
return file_exists($cacheRowFile);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create the quickSearch code for the collection field.
|
||||
* return the javascript code which define sqs_objects.
|
||||
*/
|
||||
function createQuickSearchCode($returnAsJavascript = true){
|
||||
$sqs_objects = array();
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
$qsd->setFormName($this->form_name);
|
||||
for($i=0; $i<$this->numFields; $i++){
|
||||
$name1 = "{$this->form_name}_{$this->name}_collection_{$i}";
|
||||
if(!$this->skipModuleQuickSearch && preg_match('/(Campaigns|Teams|Users|Contacts|Accounts)/si', $this->related_module, $matches)) {
|
||||
if($matches[0] == 'Users'){
|
||||
$sqs_objects[$name1] = $qsd->getQSUser();
|
||||
} else if($matches[0] == 'Campaigns') {
|
||||
$sqs_objects[$name1] = $qsd->getQSCampaigns();
|
||||
|
||||
} else if($matches[0] == 'Users'){
|
||||
$sqs_objects[$name1] = $qsd->getQSUser();
|
||||
|
||||
} else if($matches[0] == 'Accounts') {
|
||||
$nameKey = "{$this->name}_collection_{$i}";
|
||||
$idKey = "id_{$this->name}_collection_{$i}";
|
||||
|
||||
//There are billingKey, registerKey and additionalFields entries you can define in editviewdefs.php
|
||||
//entry to allow quick search to autocomplete fields with a suffix value of the
|
||||
//billing/registerKey value (i.e. 'billingKey' => 'primary' in Contacts will populate
|
||||
//primary_XXX fields with the Account's billing address values).
|
||||
//addtionalFields are key/value pair of fields to fill from Accounts(key) to Contacts(value)
|
||||
$billingKey = isset($this->displayParams['billingKey']) ? $this->displayParams['billingKey'] : null;
|
||||
$registerKey = isset($this->displayParams['registerKey']) ? $this->displayParams['registerKey'] : null;
|
||||
$additionalFields = isset($this->displayParams['additionalFields']) ? $this->displayParams['additionalFields'] : null;
|
||||
$sqs_objects[$name1] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $registerKey, $additionalFields);
|
||||
} else if($matches[0] == 'Contacts'){
|
||||
$sqs_objects[$name1] = $qsd->getQSContact($name1, "id_".$name1);
|
||||
}
|
||||
$temp_array = array('field_list'=>array(),'populate_list'=>array());
|
||||
foreach($sqs_objects[$name1]['field_list'] as $k=>$v){
|
||||
if(!in_array($v, array('name','id'))){
|
||||
$sqs_objects[$name1]['primary_field_list'][]=$v;
|
||||
$sqs_objects[$name1]['primary_populate_list'][]=$sqs_objects[$name1]['populate_list'][$k];
|
||||
}else{
|
||||
$temp_array['field_list'][]=$v;
|
||||
$temp_array['populate_list'][]=$sqs_objects[$name1]['populate_list'][$k];
|
||||
}
|
||||
}
|
||||
$sqs_objects[$name1]['field_list'] = $temp_array['field_list'];
|
||||
$sqs_objects[$name1]['populate_list'] = $temp_array['populate_list'];
|
||||
if(isset($this->displayParams['collection_field_list'])){
|
||||
foreach($this->displayParams['collection_field_list'] as $v){
|
||||
$sqs_objects[$name1]['populate_list'][]= $v['vardefName']."_".$this->name."_collection_extra_".$i;
|
||||
$sqs_objects[$name1]['field_list'][] = $v['vardefName'];
|
||||
}
|
||||
}
|
||||
}else {
|
||||
$sqs_objects[$name1] = $qsd->getQSParent($this->related_module);
|
||||
$sqs_objects[$name1]['populate_list'] = array("{$this->vardef['name']}_collection_{$i}", "id_{$this->vardef['name']}_collection_{$i}");
|
||||
$sqs_objects[$name1]['field_list'] = array('name', 'id');
|
||||
if(isset($this->displayParams['collection_field_list'])){
|
||||
foreach($this->displayParams['collection_field_list'] as $v){
|
||||
$sqs_objects[$name1]['populate_list'][] = $v['vardefName']."_".$this->name."_collection_extra_".$i;
|
||||
$sqs_objects[$name1]['field_list'][] = $v['vardefName'];
|
||||
}
|
||||
}
|
||||
if(isset($this->displayParams['field_to_name_array'])){
|
||||
foreach($this->displayParams['field_to_name_array'] as $k=>$v){
|
||||
/*
|
||||
* "primary_populate_list" and "primary_field_list" are used when the field is selected as a primary.
|
||||
* At this time the JS function changePrimary() will copy "primary_populate_list" and "primary_field_list"
|
||||
* into "populate_list" and "field_list" and remove the values from all the others which are secondaries.
|
||||
* "primary_populate_list" and "primary_field_list" contain the fields which has to be populated outside of
|
||||
* the collection field. For example the "Address Information" are populated with the "billing address" of the
|
||||
* selected account in a contact editview.
|
||||
*/
|
||||
$sqs_objects[$name1]['primary_populate_list'][] = $v;
|
||||
$sqs_objects[$name1]['primary_field_list'][] = $k;
|
||||
}
|
||||
}else if(isset($field['field_list']) && isset($field['populate_list'])){
|
||||
$sqs_objects[$name1]['primary_populate_list'] = array_merge($sqs_objects[$name1]['populate_list'], $field['field_list']);
|
||||
$sqs_objects[$name1]['primary_field_list'] = array_merge($sqs_objects[$name1]['field_list'], $field['populate_list']);
|
||||
}else{
|
||||
$sqs_objects[$name1]['primary_populate_list'] = array();
|
||||
$sqs_objects[$name1]['primary_field_list'] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id = "{$this->form_name}_{$this->name}_collection_0";
|
||||
|
||||
if(!empty($sqs_objects) && count($sqs_objects) > 0) {
|
||||
foreach($sqs_objects[$id]['field_list'] as $k=>$v){
|
||||
$this->field_to_name_array[$v] = $sqs_objects[$id]['populate_list'][$k];
|
||||
}
|
||||
if($returnAsJavascript){
|
||||
$quicksearch_js = '<script language="javascript">';
|
||||
$quicksearch_js.= "if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}";
|
||||
|
||||
foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
|
||||
$quicksearch_js .= "sqs_objects['$sqsfield']={$this->json->encode($sqsfieldArray)};";
|
||||
}
|
||||
|
||||
return $quicksearch_js .= '</script>';
|
||||
}else{
|
||||
return $sqs_objects;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
/*
|
||||
* Always call createQuickSearchCode() before createPopupCode() to define field_to_name_array
|
||||
*/
|
||||
function createPopupCode(){
|
||||
// TODO the 'select' button is not fully working. We should use the sqs_objects in open_popup instead of the parameter.
|
||||
if(isset($this->field_to_name_array) && !empty($this->field_to_name_array)){
|
||||
$call_back_function = 'set_return';
|
||||
|
||||
if(isset($this->displayParams['formName'])) {
|
||||
$form = $this->displayParams['formName'];
|
||||
} else if($this->action_type == 'editview'){
|
||||
$form = 'EditView';
|
||||
} else if($this->action_type == 'quickcreate'){
|
||||
$form = "QuickCreate_{$this->module_dir}";
|
||||
}
|
||||
|
||||
if(isset($this->displayParams['call_back_function'])) {
|
||||
$call_back_function = $this->displayParams['call_back_function'];
|
||||
}
|
||||
|
||||
$popup_request_data= array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form,
|
||||
'field_to_name_array' => $this->field_to_name_array,
|
||||
);
|
||||
|
||||
//Make sure to replace {{ and }} with spacing in between because Smarty template parsing will treat {{ or }} specially
|
||||
$this->displayParams['popupData'] = '{literal}'. str_replace(array('{{', '}}'), array('{ {', '} }'), $this->json->encode($popup_request_data)) . '{/literal}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
42
include/SugarFields/Fields/Collection/view.sugarfieldcollection.php
Executable file
42
include/SugarFields/Fields/Collection/view.sugarfieldcollection.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Collection/ViewSugarFieldCollection.php');
|
||||
$view = new ViewSugarFieldCollection();
|
||||
$view->setup();
|
||||
$view->process();
|
||||
$view->init_tpl();
|
||||
echo $view->display();
|
||||
?>
|
||||
59
include/SugarFields/Fields/Currency/SugarFieldCurrency.php
Executable file
59
include/SugarFields/Fields/Currency/SugarFieldCurrency.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Float/SugarFieldFloat.php');
|
||||
|
||||
class SugarFieldCurrency extends SugarFieldFloat {
|
||||
function getListViewSmarty($parentFieldArray, $vardef, $displayParams, $col) {
|
||||
$tabindex = 1;
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex, false);
|
||||
|
||||
$this->ss->left_delimiter = '{';
|
||||
$this->ss->right_delimiter = '}';
|
||||
$this->ss->assign('col',strtoupper($vardef['name']));
|
||||
if(is_object($parentFieldArray) ){
|
||||
if(!empty($parentFieldArray->currency_id)) {
|
||||
$this->ss->assign('currency_id',$parentFieldArray->currency_id);
|
||||
}
|
||||
} else if (!empty($parentFieldArray['CURRENCY_ID'])) {
|
||||
$this->ss->assign('currency_id',$parentFieldArray['CURRENCY_ID']);
|
||||
} else if (!empty($parentFieldArray['currency_id'])) {
|
||||
$this->ss->assign('currency_id',$parentFieldArray['currency_id']);
|
||||
}
|
||||
return $this->fetch($this->findTemplate('ListView'));
|
||||
}
|
||||
}
|
||||
115
include/SugarFields/Fields/Datetime/SugarFieldDatetime.php
Executable file
115
include/SugarFields/Fields/Datetime/SugarFieldDatetime.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldDatetime extends SugarFieldBase {
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['hiddeCalendar'])) {
|
||||
$displayParams['hiddeCalendar'] = false;
|
||||
}
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
//jchi , bug #24557 , 10/31/2008
|
||||
if(isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')){
|
||||
return $this->fetch('include/SugarFields/Fields/Base/DetailView.tpl');
|
||||
}
|
||||
//end
|
||||
return $this->fetch('include/SugarFields/Fields/Datetime/SearchView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['hiddeCalendar'])) {
|
||||
$displayParams['hiddeCalendar'] = false;
|
||||
}
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
//jchi , bug #24557 , 10/31/2008
|
||||
if(isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')){
|
||||
return $this->fetch('include/SugarFields/Fields/Base/DetailView.tpl');
|
||||
}
|
||||
//end
|
||||
return $this->fetch('include/SugarFields/Fields/Datetime/EditView.tpl');
|
||||
}
|
||||
|
||||
|
||||
public function save(&$bean, &$inputData, &$field, &$def, $prefix = '') {
|
||||
global $timedate;
|
||||
if ( !isset($inputData[$prefix.$field]) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$offset = strlen(trim($inputData[$prefix.$field])) < 11 ? false : true;
|
||||
$bean->$field = $timedate->to_db_date($inputData[$prefix.$field], $offset);
|
||||
}
|
||||
}
|
||||
?>
|
||||
109
include/SugarFields/Fields/Datetimecombo/SugarFieldDatetimecombo.php
Executable file
109
include/SugarFields/Fields/Datetimecombo/SugarFieldDatetimecombo.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldDatetimecombo extends SugarFieldBase {
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
global $timedate;
|
||||
$displayParams['dateFormat'] = $timedate->get_cal_date_format();
|
||||
|
||||
$displayParams['timeFormat'] = $timedate->get_user_time_format();
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Datetimecombo/EditView.tpl');
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
global $timedate;
|
||||
$displayParams['dateFormat'] = $timedate->get_cal_date_format();
|
||||
|
||||
$displayParams['timeFormat'] = $timedate->get_user_time_format();
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Datetimecombo/SearchView.tpl');
|
||||
}
|
||||
|
||||
|
||||
public function save(&$bean, &$inputData, &$field, &$def, $prefix = '') {
|
||||
global $timedate;
|
||||
if ( !isset($inputData[$prefix.$field]) ) {
|
||||
//$bean->$field = '';
|
||||
return;
|
||||
}
|
||||
|
||||
if(strpos($inputData[$prefix.$field], ' ') > 0) {
|
||||
$bean->$field = $timedate->to_db($inputData[$prefix.$field]);
|
||||
} else {
|
||||
$GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $inputData[$prefix.$field]);
|
||||
//Default to assume date format value
|
||||
$bean->$field = $timedate->to_db_date($inputData[$prefix.$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
54
include/SugarFields/Fields/Download/SugarFieldDownload.php
Executable file
54
include/SugarFields/Fields/Download/SugarFieldDownload.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldDownload extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
$vardef['value'] = urlencode(basename($vardef['value']));
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Download/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
$vardef['value'] = urlencode(basename($vardef['value']));
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Download/EditView.tpl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
106
include/SugarFields/Fields/Enum/SugarFieldEnum.php
Executable file
106
include/SugarFields/Fields/Enum/SugarFieldEnum.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldEnum extends SugarFieldBase {
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return "<span id='{$vardef['name']}'>" . $this->fetch('include/SugarFields/Fields/Enum/DetailViewFunction.tpl') . '</span>';
|
||||
}else{
|
||||
return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
if(empty($displayParams['size'])) {
|
||||
$displayParams['size'] = 6;
|
||||
}
|
||||
|
||||
if(isset($vardef['function']) && !empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Enum/EditViewFunction.tpl');
|
||||
}else{
|
||||
return parent::getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
|
||||
if(empty($displayParams['size'])) {
|
||||
$displayParams['size'] = 6;
|
||||
}
|
||||
|
||||
if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Enum/EditViewFunction.tpl');
|
||||
}else{
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Enum/SearchView.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function displayFromFunc( $displayType, $parentFieldArray, $vardef, $displayParams, $tabindex ) {
|
||||
if ( isset($vardef['function']['returns']) && $vardef['function']['returns'] == 'html' ) {
|
||||
return parent::displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
$displayTypeFunc = 'get'.$displayType.'Smarty';
|
||||
return $this->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
public function formatField($rawField, $vardef){
|
||||
global $app_list_strings;
|
||||
|
||||
if(!empty($vardef['options'])){
|
||||
$option_array_name = $vardef['options'];
|
||||
|
||||
if(!empty($app_list_strings[$option_array_name][$rawField])){
|
||||
return $app_list_strings[$option_array_name][$rawField];
|
||||
}else {
|
||||
return $rawField;
|
||||
}
|
||||
} else {
|
||||
return $rawField;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
103
include/SugarFields/Fields/File/SugarFieldFile.php
Executable file
103
include/SugarFields/Fields/File/SugarFieldFile.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldFile extends SugarFieldBase
|
||||
{
|
||||
|
||||
function getDataForDetaiLView ()
|
||||
{}
|
||||
|
||||
function getDetailViewSmarty ($parentFieldArray, $vardef, $displayParams,
|
||||
$tabindex)
|
||||
{
|
||||
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/File/DetailView.tpl');
|
||||
}
|
||||
|
||||
public function save (&$bean, $params, $field, $properties, $prefix = '')
|
||||
{
|
||||
global $sugar_config;
|
||||
// only save relation here
|
||||
// file save on ajax request crm/uploadAjaxFile.php
|
||||
if ($_POST[$field . '_newname'] != '') {
|
||||
|
||||
var_dump($_POST[$field . '_newname']);
|
||||
|
||||
if($bean->id==''){
|
||||
$bean->id = create_guid();
|
||||
$bean->new_with_id = true;
|
||||
}
|
||||
$bean->$field='';
|
||||
|
||||
foreach ($_POST[$field . '_newname'] as $key => $value) {
|
||||
$target_file = $sugar_config['upload_dir'] . basename($value);
|
||||
if (file_exists($target_file)) {
|
||||
$Revision = new DocumentRevision();
|
||||
$Revision->retrieve($value);
|
||||
if($Revision->id==''){
|
||||
$Revision = new DocumentRevision();
|
||||
$Revision->change_log = 'test';
|
||||
$Revision->revision = 1;
|
||||
$Revision->document_id = $bean->id;
|
||||
$Revision->filename = $_POST[$field . '_orginal'][$key];
|
||||
$Revision->file_ext = pathinfo(
|
||||
$_POST[$field . '_orginal'][$key],
|
||||
PATHINFO_EXTENSION);
|
||||
$Revision->file_mime_type = $_POST[$field . '_type'][$key];
|
||||
$Revision->save();
|
||||
|
||||
// change id bc $Revision->id=$value; bug
|
||||
$GLOBALS['db']->query(
|
||||
"update document_revisions set id='" . $value .
|
||||
"' where id='" . $Revision->id . "'");
|
||||
$success = true;
|
||||
$bean->$field.=$_POST[$field . '_orginal'][$key].':'.$_POST[$field . '_newname'][$key].':'.$_POST[$field . '_type'][$key].';';
|
||||
|
||||
} else {
|
||||
$bean->$field.=$_POST[$field . '_orginal'][$key].':'.$_POST[$field . '_newname'][$key].':'.$_POST[$field . '_type'][$key].';';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
echo 'nowe: '.$bean->$field;
|
||||
// die();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
67
include/SugarFields/Fields/Float/SugarFieldFloat.php
Executable file
67
include/SugarFields/Fields/Float/SugarFieldFloat.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Int/SugarFieldInt.php');
|
||||
|
||||
class SugarFieldFloat extends SugarFieldInt {
|
||||
public function formatField($rawField, $vardef){
|
||||
// A null precision uses the user prefs / system prefs by default
|
||||
$precision = null;
|
||||
if ( isset($vardef['precision']) ) {
|
||||
$precision = $vardef['precision'];
|
||||
}
|
||||
|
||||
if ( $rawField === '' || $rawField === NULL ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if($vardef['name']=='QUANTITY' || 'STATE'==$vardef['name']){
|
||||
return $rawField;
|
||||
} else {
|
||||
return format_number($rawField,$precision,$precision);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function unformatField($formattedField, $vardef){
|
||||
if ( $formattedField === '' || $formattedField === NULL ) {
|
||||
return '';
|
||||
}
|
||||
return (float)unformat_number($formattedField);
|
||||
}
|
||||
|
||||
}
|
||||
45
include/SugarFields/Fields/Fullname/SugarFieldFullname.php
Executable file
45
include/SugarFields/Fields/Fullname/SugarFieldFullname.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldFullname extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Fullname/DetailView.tpl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
72
include/SugarFields/Fields/Html/SugarFieldHtml.php
Executable file
72
include/SugarFields/Fields/Html/SugarFieldHtml.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldHtml extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){
|
||||
$vardef['value'] = $this->getVardefValue($vardef);
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Html/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){
|
||||
$vardef['value'] = $this->getVardefValue($vardef);
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Html/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$vardef['value'] = $this->getVardefValue($vardef);
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Html/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getVardefValue($vardef){
|
||||
if(empty($vardef['value'])){
|
||||
if(!empty($vardef['default']))
|
||||
return from_html($vardef['default']);
|
||||
elseif(!empty($vardef['default_value']))
|
||||
return from_html($vardef['default_value']);
|
||||
} else {
|
||||
return from_html($vardef['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
71
include/SugarFields/Fields/Int/SugarFieldInt.php
Executable file
71
include/SugarFields/Fields/Int/SugarFieldInt.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
|
||||
class SugarFieldInt extends SugarFieldBase {
|
||||
public function formatField($rawField, $vardef){
|
||||
if ( !empty($vardef['disable_num_format']) ) {
|
||||
return $rawField;
|
||||
}
|
||||
if ( $rawField === '' || $rawField === NULL ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return format_number($rawField,0,0);
|
||||
}
|
||||
|
||||
public function unformatField($formattedField, $vardef){
|
||||
if ( $formattedField === '' || $formattedField === NULL ) {
|
||||
return '';
|
||||
}
|
||||
return (int)unformat_number($formattedField);
|
||||
}
|
||||
|
||||
public function unformatSearchRequest(&$inputData, &$field) {
|
||||
$field['value'] = $this->unformatField($field['value'],$field);
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
// Use the basic field type for searches, no need to format/unformat everything... for now
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
|
||||
|
||||
return $this->fetch('include/SugarFields/Fields/Int/SearchForm.tpl');
|
||||
}
|
||||
}
|
||||
66
include/SugarFields/Fields/Multienum/SugarFieldMultienum.php
Executable file
66
include/SugarFields/Fields/Multienum/SugarFieldMultienum.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldMultienum extends SugarFieldBase {
|
||||
|
||||
function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass=true) {
|
||||
if ( !isset($vardef['options_list']) && isset($vardef['options']) && !is_array($vardef['options'])) {
|
||||
$vardef['options_list'] = $GLOBALS['app_list_strings'][$vardef['options']];
|
||||
}
|
||||
return parent::setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass);
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Multienum/EditViewFunction.tpl');
|
||||
}else{
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Multienum/SearchView.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function save(&$bean, $params, $field, $properties, $prefix = ''){
|
||||
if ( isset($params[$prefix.$field]) ) {
|
||||
if($params[$prefix.$field][0] === '' && !empty($params[$prefix.$field][1]) ) {
|
||||
unset($params[$prefix.$field][0]);
|
||||
}
|
||||
|
||||
$bean->$field = encodeMultienumValue($params[$prefix.$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
128
include/SugarFields/Fields/New_phone/SugarFieldNew_phone.php
Executable file
128
include/SugarFields/Fields/New_phone/SugarFieldNew_phone.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
require_once('include/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldNew_phone extends SugarFieldBase
|
||||
{
|
||||
|
||||
public function formatField($rawField, $vardef)
|
||||
{
|
||||
if (empty($rawField)) return $rawField;
|
||||
|
||||
$fields = explode('^|^', $rawField);
|
||||
$params = array('',0,0,'');
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$params = explode('^,^', $field);
|
||||
if (intval($params[1]) == 1) return $params[0];
|
||||
}
|
||||
return $params[0];
|
||||
}
|
||||
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex)
|
||||
{
|
||||
global $app_strings;
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
|
||||
return $this->fetch('include/SugarFields/Fields/New_phone/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex)
|
||||
{
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/New_phone/EditView.tpl');
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex)
|
||||
{
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/New_phone/SearchView.tpl');
|
||||
}
|
||||
|
||||
public function save(&$bean, $params, $field, $properties, $prefix = '')
|
||||
{
|
||||
global $module;
|
||||
|
||||
$prefix = $module . 'phoneFlag';
|
||||
$phones = array();
|
||||
|
||||
//сохраняем номер телефона
|
||||
foreach ($params as $key => $val)
|
||||
{
|
||||
if (strpos($key, $prefix . '0_') === 0)
|
||||
{
|
||||
$new_key = intval(str_replace($prefix . '0_', '', $key));
|
||||
if (empty($val)) continue; //Это пустая запись не будем сохранять ее
|
||||
if (!isset($first_key)) $first_key = $new_key;
|
||||
|
||||
$phones[$new_key] = array(
|
||||
0 => $val,
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => '',
|
||||
4 => $this->only_digit($val),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//сохраняем селект атрибуты
|
||||
foreach ($params as $key => $val)
|
||||
{
|
||||
if (strpos($key, $prefix . '3_') === 0)
|
||||
{
|
||||
$new_key = intval(str_replace($prefix . '3_', '', $key));
|
||||
|
||||
if (empty($val)) continue; //Это пустая запись не будем сохранять ее
|
||||
if (isset($phones[$new_key]) AND !empty($phones[$new_key])) $phones[$new_key][3] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($phones))
|
||||
{
|
||||
//Основной
|
||||
if (isset($params[$prefix . '1']))
|
||||
{
|
||||
$key = intval($params[$prefix . '1']);
|
||||
if (isset($phones[$key])) $phones[$key][1] = 1;
|
||||
else $phones[$first_key][1] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$phones[$first_key][1] = 1;
|
||||
}
|
||||
|
||||
// Все чекбокс атрибуты
|
||||
for ($i = 2; $i <= 2; $i++) // он у нас только один (не звонить), но вообще сделано универсально, можно добавить атрибуты
|
||||
{
|
||||
if (isset($params[$prefix . $i]) and is_array($params[$prefix . $i]))
|
||||
{
|
||||
foreach ($params[$prefix . $i] as $value)
|
||||
{
|
||||
$intval = intval($value);
|
||||
if (isset($phones[$intval])) $phones[$intval][$i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ext_phone = array();
|
||||
foreach ($phones as $key => $val)
|
||||
{
|
||||
$ext_phone[] = join('^,^', $val);
|
||||
}
|
||||
$bean->$field = join('^|^', $ext_phone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bean->$field = '';
|
||||
}
|
||||
}
|
||||
|
||||
private function only_digit($phone)
|
||||
{
|
||||
$pattern = '/[^0-9]*/';
|
||||
return preg_replace($pattern, '', $phone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
121
include/SugarFields/Fields/Parent/SugarFieldParent.php
Executable file
121
include/SugarFields/Fields/Parent/SugarFieldParent.php
Executable file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldParent extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$nolink = array('Users', 'Teams');
|
||||
if(in_array($vardef['module'], $nolink)){
|
||||
$this->ss->assign('nolink', true);
|
||||
}else{
|
||||
$this->ss->assign('nolink', false);
|
||||
}
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Parent/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$form_name = 'EditView';
|
||||
if(isset($displayParams['formName'])) {
|
||||
$form_name = $displayParams['formName'];
|
||||
}
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => array(
|
||||
'id' => $vardef['id_name'],
|
||||
'name' => $vardef['name'],
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
global $app_list_strings;
|
||||
$parent_types = $app_list_strings['record_type_display'];
|
||||
|
||||
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
|
||||
foreach($disabled_parent_types as $disabled_parent_type){
|
||||
if($disabled_parent_type != $focus->parent_type){
|
||||
unset($parent_types[$disabled_parent_type]);
|
||||
}
|
||||
}
|
||||
asort($parent_types);
|
||||
$json = getJSONobj();
|
||||
$displayParams['popupData'] = '{literal}'.$json->encode($popup_request_data).'{/literal}';
|
||||
$displayParams['disabled_parent_types'] = '<script>var disabledModules='. $json->encode($disabled_parent_types).';</script>';
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Parent/EditView.tpl');
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$form_name = 'search_form';
|
||||
|
||||
if(isset($displayParams['formName'])) {
|
||||
$form_name = $displayParams['formName'];
|
||||
}
|
||||
|
||||
$this->ss->assign('form_name', $form_name);
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => array(
|
||||
'id' => $vardef['id_name'],
|
||||
'name' => $vardef['name'],
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
global $app_list_strings;
|
||||
$parent_types = $app_list_strings['record_type_display'];
|
||||
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
|
||||
foreach($disabled_parent_types as $disabled_parent_type){
|
||||
if($disabled_parent_type != $focus->parent_type){
|
||||
unset($parent_types[$disabled_parent_type]);
|
||||
}
|
||||
}
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$displayParams['popupData'] = '{literal}'.$json->encode($popup_request_data).'{/literal}';
|
||||
$displayParams['disabled_parent_types'] = '<script>var disabledModules='. $json->encode($disabled_parent_types).';</script>';
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
|
||||
return $this->fetch('include/SugarFields/Fields/Parent/SearchView.tpl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
44
include/SugarFields/Fields/Readonly/SugarFieldReadonly.php
Executable file
44
include/SugarFields/Fields/Readonly/SugarFieldReadonly.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldReadonly extends SugarFieldBase {
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
return $this->getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
256
include/SugarFields/Fields/Relate/SugarFieldRelate.php
Executable file
256
include/SugarFields/Fields/Relate/SugarFieldRelate.php
Executable file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldRelate extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$nolink = array('Users', 'Teams');
|
||||
if(in_array($vardef['module'], $nolink)){
|
||||
$this->ss->assign('nolink', true);
|
||||
}else{
|
||||
$this->ss->assign('nolink', false);
|
||||
}
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Relate/DetailView.tpl');
|
||||
}
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
if(!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html'){
|
||||
return parent::getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
$call_back_function = 'set_return';
|
||||
if(isset($displayParams['call_back_function'])) {
|
||||
$call_back_function = $displayParams['call_back_function'];
|
||||
}
|
||||
$form_name = 'EditView';
|
||||
if(isset($displayParams['formName'])) {
|
||||
$form_name = $displayParams['formName'];
|
||||
}
|
||||
|
||||
//Special Case for accounts; use the displayParams array and retrieve
|
||||
//the key and copy indexes. 'key' is the suffix of the field we are searching
|
||||
//the Account's address with. 'copy' is the suffix we are copying the addresses
|
||||
//form fields into.
|
||||
if(isset($vardef['module']) && preg_match('/Accounts/si',$vardef['module'])
|
||||
&& isset($displayParams['key']) && isset($displayParams['copy'])) {
|
||||
|
||||
if(isset($displayParams['key']) && is_array($displayParams['key'])) {
|
||||
$database_key = $displayParams['key'];
|
||||
} else {
|
||||
$database_key[] = $displayParams['key'];
|
||||
}
|
||||
|
||||
if(isset($displayParams['copy']) && is_array($displayParams['copy'])) {
|
||||
$form = $displayParams['copy'];
|
||||
} else {
|
||||
$form[] = $displayParams['copy'];
|
||||
}
|
||||
|
||||
if(count($database_key) != count($form)) {
|
||||
global $app_list_strings;
|
||||
$this->ss->trigger_error($app_list_strings['ERR_SMARTY_UNEQUAL_RELATED_FIELD_PARAMETERS']);
|
||||
} //if
|
||||
|
||||
$copy_phone = isset($displayParams['copyPhone']) ? $displayParams['copyPhone'] : true;
|
||||
|
||||
$field_to_name = array();
|
||||
$field_to_name['id'] = $vardef['id_name'];
|
||||
$field_to_name['name'] = $vardef['name'];
|
||||
$address_fields = array('_address_street', '_address_city', '_address_state', '_address_postalcode', '_address_country');
|
||||
$count = 0;
|
||||
foreach($form as $f) {
|
||||
foreach($address_fields as $afield) {
|
||||
$field_to_name[$database_key[$count] . $afield] = $f . $afield;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => $field_to_name,
|
||||
);
|
||||
|
||||
if($copy_phone) {
|
||||
$popup_request_data['field_to_name_array']['phone_office'] = 'phone_work';
|
||||
}
|
||||
} elseif(isset($displayParams['field_to_name_array'])) {
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => $displayParams['field_to_name_array'],
|
||||
);
|
||||
} else {
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => array(
|
||||
'id' => (empty($displayParams['idName']) ? $vardef['id_name'] : ($displayParams['idName'] . '_' . $vardef['id_name'])) ,
|
||||
((empty($vardef['rname'])) ? 'name' : $vardef['rname']) => (empty($displayParams['idName']) ? $vardef['name'] : $displayParams['idName']),
|
||||
),
|
||||
);
|
||||
}
|
||||
$json = getJSONobj();
|
||||
$displayParams['popupData'] = '{literal}'.$json->encode($popup_request_data). '{/literal}';
|
||||
if(!isset($displayParams['readOnly'])) {
|
||||
$displayParams['readOnly'] = '';
|
||||
} else {
|
||||
$displayParams['readOnly'] = $displayParams['readOnly'] == false ? '' : 'READONLY';
|
||||
}
|
||||
|
||||
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Relate/EditView.tpl');
|
||||
}
|
||||
|
||||
function getPopupViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){
|
||||
$displayParams['clearOnly'] = true;
|
||||
return $this->getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$call_back_function = 'set_return';
|
||||
if(isset($displayParams['call_back_function'])) {
|
||||
$call_back_function = $displayParams['call_back_function'];
|
||||
}
|
||||
$form_name = 'search_form';
|
||||
if(isset($displayParams['formName'])) {
|
||||
$form_name = $displayParams['formName'];
|
||||
}
|
||||
if(!empty($vardef['rname']) && $vardef['rname'] == 'user_name'){
|
||||
$displayParams['useIdSearch'] = true;
|
||||
}
|
||||
//Special Case for accounts; use the displayParams array and retrieve
|
||||
//the key and copy indexes. 'key' is the suffix of the field we are searching
|
||||
//the Account's address with. 'copy' is the suffix we are copying the addresses
|
||||
//form fields into.
|
||||
if(isset($vardef['module']) && preg_match('/Accounts/si',$vardef['module'])
|
||||
&& isset($displayParams['key']) && isset($displayParams['copy'])) {
|
||||
|
||||
if(isset($displayParams['key']) && is_array($displayParams['key'])) {
|
||||
$database_key = $displayParams['key'];
|
||||
} else {
|
||||
$database_key[] = $displayParams['key'];
|
||||
}
|
||||
|
||||
if(isset($displayParams['copy']) && is_array($displayParams['copy'])) {
|
||||
$form = $displayParams['copy'];
|
||||
} else {
|
||||
$form[] = $displayParams['copy'];
|
||||
}
|
||||
|
||||
if(count($database_key) != count($form)) {
|
||||
global $app_list_strings;
|
||||
$this->ss->trigger_error($app_list_strings['ERR_SMARTY_UNEQUAL_RELATED_FIELD_PARAMETERS']);
|
||||
} //if
|
||||
|
||||
$copy_phone = isset($displayParams['copyPhone']) ? $displayParams['copyPhone'] : true;
|
||||
|
||||
$field_to_name = array();
|
||||
$field_to_name['id'] = $vardef['id_name'];
|
||||
$field_to_name['name'] = $vardef['name'];
|
||||
$address_fields = array('_address_street', '_address_city', '_address_state', '_address_postalcode', '_address_country');
|
||||
$count = 0;
|
||||
foreach($form as $f) {
|
||||
foreach($address_fields as $afield) {
|
||||
$field_to_name[$database_key[$count] . $afield] = $f . $afield;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => $field_to_name,
|
||||
);
|
||||
|
||||
if($copy_phone) {
|
||||
$popup_request_data['field_to_name_array']['phone_office'] = 'phone_work';
|
||||
}
|
||||
} elseif(isset($displayParams['field_to_name_array'])) {
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => $displayParams['field_to_name_array'],
|
||||
);
|
||||
} else {
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => $call_back_function,
|
||||
'form_name' => $form_name,
|
||||
'field_to_name_array' => array(
|
||||
'id' => $vardef['id_name'],
|
||||
((empty($vardef['rname'])) ? 'name' : $vardef['rname']) => $vardef['name'],
|
||||
),
|
||||
);
|
||||
}
|
||||
$json = getJSONobj();
|
||||
$displayParams['popupData'] = '{literal}'.$json->encode($popup_request_data). '{/literal}';
|
||||
if(!isset($displayParams['readOnly'])) {
|
||||
$displayParams['readOnly'] = '';
|
||||
} else {
|
||||
$displayParams['readOnly'] = $displayParams['readOnly'] == false ? '' : 'READONLY';
|
||||
}
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Relate/SearchView.tpl');
|
||||
}
|
||||
|
||||
function formatField($rawField, $vardef) {
|
||||
if ('contact_name' == $vardef['name']){
|
||||
$default_locale_name_format = $GLOBALS['current_user']->getPreference('default_locale_name_format');
|
||||
$default_locale_name_format = trim(preg_replace('/s/i', '', $default_locale_name_format));
|
||||
$new_field = '';
|
||||
$names = array();
|
||||
$temp = explode(' ', $rawField);
|
||||
if ( !isset($temp[1]) ) {
|
||||
$names['f'] = '';
|
||||
$names['l'] = $temp[0];
|
||||
}
|
||||
elseif ( !empty($temp) ) {
|
||||
$names['f'] = $temp[0];
|
||||
$names['l'] = $temp[1];
|
||||
}
|
||||
for($i=0;$i<strlen($default_locale_name_format);$i++){
|
||||
$new_field .= array_key_exists($default_locale_name_format{$i}, $names) ? $names[$default_locale_name_format{$i}] : $default_locale_name_format{$i};
|
||||
}
|
||||
}
|
||||
else $new_field = $rawField;
|
||||
|
||||
return $new_field;
|
||||
}
|
||||
}
|
||||
?>
|
||||
80
include/SugarFields/Fields/Text/SugarFieldText.php
Executable file
80
include/SugarFields/Fields/Text/SugarFieldText.php
Executable file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldText extends SugarFieldBase {
|
||||
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$displayParams['nl2br'] = true;
|
||||
$displayParams['htmlescape'] = true;
|
||||
$displayParams['url2html'] = true;
|
||||
return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
}
|
||||
function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) {
|
||||
|
||||
$this->ss->assign('prefix', $prefix);
|
||||
$this->ss->assign('field_id', $field_id);
|
||||
$this->ss->assign('value', $value);
|
||||
$this->ss->assign('tabindex', $tabindex);
|
||||
|
||||
$displayParams = array();
|
||||
$displayParams['textonly'] = $rich_text ? false : true;
|
||||
$displayParams['maxlength'] = $maxlength;
|
||||
$displayParams['rows'] = $rows;
|
||||
$displayParams['cols'] = $cols;
|
||||
|
||||
|
||||
$this->ss->assign('displayParams', $displayParams);
|
||||
if(isset($GLOBALS['current_user'])) {
|
||||
$height = $GLOBALS['current_user']->getPreference('text_editor_height');
|
||||
$width = $GLOBALS['current_user']->getPreference('text_editor_width');
|
||||
$height = isset($height) ? $height : '300px';
|
||||
$width = isset($width) ? $width : '95%';
|
||||
$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
|
||||
$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
|
||||
} else {
|
||||
$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
|
||||
$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
|
||||
}
|
||||
|
||||
if(file_exists('custom/include/SugarFields/Fields/Text/ClassicEditView.tpl')) {
|
||||
return $this->ss->fetch('custom/include/SugarFields/Fields/Text/ClassicEditView.tpl');
|
||||
} else {
|
||||
return $this->ss->fetch('include/SugarFields/Fields/Text/ClassicEditView.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
include/SugarFields/Fields/Username/SugarFieldUsername.php
Executable file
50
include/SugarFields/Fields/Username/SugarFieldUsername.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* 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/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldUsername extends SugarFieldBase {
|
||||
function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
|
||||
global $current_language;
|
||||
if(isset($current_language) && file_exists('include/SugarFields/Fields/Username/' . $current_language . '.DetailView.tpl')) {
|
||||
return $this->fetch('include/SugarFields/Fields/Username/' . $current_language . '.DetailView.tpl');
|
||||
} else {
|
||||
return $this->fetch('include/SugarFields/Fields/Username/DetailView.tpl');
|
||||
} //if-else
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user