This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

374
include/SubPanel/SubPanel.php Executable file
View File

@@ -0,0 +1,374 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/SubPanel/registered_layout_defs.php');
//AG todo remove subpanedata and subpanel id from this class...
class SubPanel
{
var $hideNewButton = false;
var $subpanel_id;
var $parent_record_id;
var $parent_module; // the name of the parent module
var $parent_bean; // the instantiated bean of the parent
var $template_file;
var $linked_fields;
var $action = 'DetailView';
var $show_select_button = true;
var $subpanel_define = null; // contains the layout_def.php
var $subpanel_defs;
var $subpanel_query=null;
var $layout_def_key='';
function SubPanel($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='')
{
global $theme, $beanList, $beanFiles, $focus, $app_strings;
$this->subpanel_defs=$subpanelDef;
$this->subpanel_id = $subpanel_id;
$this->parent_record_id = $record_id;
$this->parent_module = $module;
$this->layout_def_key = $layout_def_key;
$this->parent_bean = $focus;
$result = $focus;
if(empty($result))
{
$parent_bean_name = $beanList[$module];
$parent_bean_file = $beanFiles[$parent_bean_name];
require_once($parent_bean_file);
$this->parent_bean = new $parent_bean_name();
$this->parent_bean->retrieve($this->parent_record_id);
$result = $this->parent_bean;
}
if($record_id!='fab4' && $result == null)
{
sugar_die($app_strings['ERROR_NO_RECORD']);
}
if (empty($subpanelDef)) {
//load the subpanel by name.
if (!class_exists('MyClass')) {
require_once 'include/SubPanel/SubPanelDefinitions.php' ;
}
$panelsdef=new SubPanelDefinitions($result,$layout_def_key);
$subpanelDef=$panelsdef->load_subpanel($subpanel_id);
$this->subpanel_defs=$subpanelDef;
}
}
function setTemplateFile($template_file)
{
$this->template_file = $template_file;
}
function setBeanList(&$value){
$this->bean_list =$value;
}
function setHideNewButton($value){
$this->hideNewButton = $value;
}
function getHeaderText( $currentModule){
}
function get_buttons( $panel_query=null)
{
$thisPanel =& $this->subpanel_defs;
$subpanel_def = $thisPanel->get_buttons();
if(!isset($this->listview)){
$this->listview = new ListView();
}
$layout_manager = $this->listview->getLayoutManager();
$widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>';
foreach($subpanel_def as $widget_data)
{
$widget_data['query']=urlencode($panel_query);
$widget_data['action'] = $_REQUEST['action'];
$widget_data['module'] = $thisPanel->get_inst_prop_value('module');
$widget_data['focus'] = $this->parent_bean;
$widget_data['subpanel_definition'] = $thisPanel;
$widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n";
if(empty($widget_data['widget_class']))
{
$widget_contents .= "widget_class not defined for top subpanel buttons";
}
else
{
$widget_contents .= $layout_manager->widgetDisplay($widget_data);
}
$widget_contents .= '</td>';
}
$widget_contents .= '</tr></table></div>';
return $widget_contents;
}
function ProcessSubPanelListView($xTemplatePath, &$mod_strings)
{
global $app_strings;
global $current_user;
global $sugar_config;
if(isset($this->listview)){
$ListView =& $this->listview;
}else{
$ListView = new ListView();
}
$ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings);
$ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id);
$ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions?
$ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id);
$ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle" alt="'.$app_strings['LNK_EDIT'].'" border="0"'));
$ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" alt="'.$app_strings['LNK_DELETE'].'" border="0"'));
$ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" alt="'.$app_strings['LNK_REMOVE'].'" border="0"'));
$header_text= '';
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
{
$exploded = explode('/', $xTemplatePath);
$file_name = $exploded[sizeof($exploded) - 1];
$mod_name = $exploded[sizeof($exploded) - 2];
$header_text= "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang="
.$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>";
}
$ListView->setHeaderTitle('');
$ListView->setHeaderText('');
ob_start();
$ListView->is_dynamic = true;
$ListView->records_per_page = $sugar_config['list_max_entries_per_subpanel'] + 0;
$ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','";
$ListView->subpanel_id = $this->subpanel_id;
$ListView->end_link_wrapper = "',true);";
if ( !empty($this->layout_def_key) ) {
$ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper;
}
$where = '';
$ListView->setQuery($where, '', '', '');
$ListView->show_export_button = false;
//function returns the query that was used to populate sub-panel data.
$query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs);
$this->subpanel_query=$query;
$ob_contents = ob_get_contents();
ob_end_clean();
return $ob_contents;
}
function display()
{
global $timedate;
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $beanList;
global $beanFiles;
global $current_language;
$result_array = array();
$return_string = $this->ProcessSubPanelListView($this->template_file,$result_array);
print $return_string;
}
function getModulesWithSubpanels()
{
global $beanList;
$dir = dir('modules');
$modules = array();
while($entry = $dir->read())
{
if(file_exists('modules/' . $entry . '/layout_defs.php'))
{
$modules[$entry] = $entry;
}
}
return $modules;
}
function getModuleSubpanels($module){
require_once('include/SubPanel/SubPanelDefinitions.php');
global $beanList, $beanFiles;
if(!isset($beanList[$module])){
return array();
}
$class = $beanList[$module];
require_once($beanFiles[$class]);
$mod = new $class();
$spd = new SubPanelDefinitions($mod);
$tabs = $spd->get_available_tabs(true);
$ret_tabs = array();
$reject_tabs = array('history'=>1, 'activities'=>1);
foreach($tabs as $key=>$tab){
foreach($tab as $k=>$v){
if (! isset ( $reject_tabs [$k] )) {
$ret_tabs [$k] = $v;
}
}
}
return $ret_tabs;
}
//saves overrides for defs
function saveSubPanelDefOverride( $panel, $subsection, $override){
global $layout_defs, $beanList;
//save the new subpanel
$name = "subpanel_layout['list_fields']";
//bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels
$path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels';
$filename = $panel->parent_bean->object_name . $panel->_instance_properties['subpanel_name'] ;
$extname = '_override'.$panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ;
mkdir_recursive($path, true);
write_array_to_file( $name, $override,$path.'/' . $filename .'.php');
//save the override for the layoutdef
$name = "layout_defs['". $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']"; // tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files - gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs
// $GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name);
$newValue = override_value_to_string($name, 'override_subpanel_name', $filename);
mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true);
$fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w');
fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>");
fclose($fp);
require_once('ModuleInstall/ModuleInstaller.php');
$moduleInstaller = new ModuleInstaller();
$moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs
$moduleInstaller->rebuild_layoutdefs();
if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'))
include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php');
if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'))
include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
}
function get_subpanel_setup($module)
{
$subpanel_setup = '';
$layout_defs = get_layout_defs();
if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup']))
{
$subpanel_setup = $layout_defs[$module]['subpanel_setup'];
}
return $subpanel_setup;
}
/**
* Retrieve the subpanel definition from the registered layout_defs arrays.
*/
function getSubPanelDefine($module, $subpanel_id)
{
$default_subpanel_define = SubPanel::_get_default_subpanel_define($module, $subpanel_id);
$custom_subpanel_define = SubPanel::_get_custom_subpanel_define($module, $subpanel_id);
$subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define);
if(empty($subpanel_define))
{
print('Could not load subpanel definition for: ' . $subpanel_id);
}
return $subpanel_define;
}
function _get_custom_subpanel_define($module, $subpanel_id)
{
$ret_val = array();
if($subpanel_id != '')
{
$layout_defs = get_layout_defs();
if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]))
{
$ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id];
}
}
return $ret_val;
}
function _get_default_subpanel_define($module, $subpanel_id)
{
$ret_val = array();
if($subpanel_id != '')
{
$layout_defs = get_layout_defs();
if(!empty($layout_defs[$subpanel_id]['default_subpanel_define']))
{
$ret_val = $layout_defs[$subpanel_id]['default_subpanel_define'];
}
}
return $ret_val;
}
}
?>

View File

@@ -0,0 +1,659 @@
<?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".
********************************************************************************/
//input
// module directory
//constructor
// open the layout_definitions file.
//
class aSubPanel
{
var $name ;
var $_instance_properties ;
var $mod_strings ;
var $panel_definition ;
var $sub_subpanels ;
var $parent_bean ;
//module's table name and column fields.
var $table_name ;
var $db_fields ;
var $bean_name ;
var $template_instance ;
function aSubPanel ( $name , $instance_properties , $parent_bean , $reload = false , $original_only = false )
{
$this->_instance_properties = $instance_properties ;
$this->name = $name ;
$this->parent_bean = $parent_bean ;
//set language
global $current_language ;
if (! isset ( $parent_bean->mbvardefs ))
{
$mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ;
}
$this->mod_strings = $mod_strings ;
if ($this->isCollection ())
{
$this->load_sub_subpanels () ; //load sub-panel definition.
} else
{
if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){
_pstack_trace();
}
$def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ;
$orig_exists = is_file($def_path);
$loaded = false;
if (is_file($def_path))
{
require ($def_path);
$loaded = true;
}
if (is_file("custom/$def_path") && (!$original_only || !$orig_exists))
{
require ("custom/$def_path");
$loaded = true;
}
if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ))
{
$cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ;
require ($cust_def_path) ;
$loaded = true;
}
if (!$loaded)
{
$GLOBALS['log']->fatal("Failed to load original or custom subpanel data for $name in $def_path");
}
// check that the loaded subpanel definition includes a $subpanel_layout section - some, such as projecttasks/default do not...
$this->panel_definition = array () ;
if (isset($subpanel_layout))
{
$this->panel_definition = $subpanel_layout ;
}
$this->load_module_info () ; //load module info from the module's bean file.
}
}
function distinct_query ()
{
if (isset ( $this->_instance_properties [ 'get_distinct_data' ] ))
{
if (! empty ( $this->_instance_properties [ 'get_distinct_data' ] ))
return true ; else
return false ;
}
return false ;
}
//return the translated header value.
function get_title ()
{
if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ))
{
return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ;
}
return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ;
}
//return the definition of buttons. looks for buttons in 2 locations.
function get_buttons ()
{
$buttons = array ( ) ;
if (isset ( $this->_instance_properties [ 'top_buttons' ] ))
{
//this will happen only in the case of sub-panels with multiple sources(activities).
$buttons = $this->_instance_properties [ 'top_buttons' ] ;
} else
{
$buttons = $this->panel_definition [ 'top_buttons' ] ;
}
// permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled.
//only email is being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled.
//as of today these are the only 2 sub-panels that use the union clause.
$mod_name = $this->get_module_name () ;
if ($mod_name == 'Activities' or $mod_name = 'History')
{
global $modListHeader ;
global $modules_exempt_from_availability_check ;
if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check ))))
{
foreach ( $buttons as $key => $button )
{
foreach ( $button as $property => $value )
{
if ($value == 'SubPanelTopComposeEmailButton' or $value == 'SubPanelTopArchiveEmailButton')
{
//remove this button from the array.
unset ( $buttons [ $key ] ) ;
}
}
}
}
}
return $buttons ;
}
//call this function for sub-panels that have unions.
function load_sub_subpanels ()
{
global $modListHeader ;
// added a check for security of tabs to see if an user has access to them
// this prevents passing an "unseen" tab to the query string and pulling up its contents
if (! isset ( $modListHeader ))
{
global $current_user ;
if (isset ( $current_user ))
{
$modListHeader = query_module_access_list ( $current_user ) ;
}
}
global $modules_exempt_from_availability_check ;
if (empty ( $this->sub_subpanels ))
{
$panels = $this->get_inst_prop_value ( 'collection_list' ) ;
foreach ( $panels as $panel => $properties )
{
if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check ))
{
$this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean ) ;
}
}
}
}
function isDatasourceFunction ()
{
if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false)
{
return false ;
}
return true ;
}
function isCollection ()
{
if ($this->get_inst_prop_value ( 'type' ) == 'collection')
return true ; else
return false ;
}
//get value of a property defined at the panel instance level.
function get_inst_prop_value ( $name )
{
if (isset ( $this->_instance_properties [ $name ] ))
return $this->_instance_properties [ $name ] ; else
return null ;
}
//get value of a property defined at the panel definition level.
function get_def_prop_value ( $name )
{
if (isset ( $this->panel_definition [ $name ] ))
{
return $this->panel_definition [ $name ] ;
} else
{
return null ;
}
}
//if datasource is of the type function then return the function name
//else return the value as is.
function get_function_parameters ()
{
$parameters = array ( ) ;
if ($this->isDatasourceFunction ())
{
$parameters = $this->get_inst_prop_value ( 'function_parameters' ) ;
}
return $parameters ;
}
function get_data_source_name ( $check_set_subpanel_data = false )
{
$prop_value = null ;
if ($check_set_subpanel_data)
{
$prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ;
}
if (! empty ( $prop_value ))
{
return $prop_value ;
} else
{
//fall back to default behavior.
}
if ($this->isDatasourceFunction ())
{
return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ;
} else
{
return $this->get_inst_prop_value ( 'get_subpanel_data' ) ;
}
}
//returns the where clause for the query.
function get_where ()
{
return $this->get_def_prop_value ( 'where' ) ;
}
function is_fill_in_additional_fields ()
{
// do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php
$temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ;
return $temp ;
}
function get_list_fields ()
{
if (isset ( $this->panel_definition [ 'list_fields' ] ))
{
return $this->panel_definition [ 'list_fields' ] ;
} else
{
return array ( ) ;
}
}
function get_module_name ()
{
return $this->get_inst_prop_value ( 'module' ) ;
}
function get_name ()
{
return $this->name ;
}
//load subpanel mdoule's table name and column fields.
function load_module_info ()
{
global $beanList ;
global $beanFiles ;
$module_name = $this->get_module_name () ;
if (! empty ( $module_name ))
{
$bean_name = $beanList [ $this->get_module_name () ] ;
$this->bean_name = $bean_name ;
include_once ($beanFiles [ $bean_name ]) ;
$this->template_instance = new $bean_name ( ) ;
$this->template_instance->force_load_details = true ;
$this->table_name = $this->template_instance->table_name ;
//$this->db_fields=$this->template_instance->column_fields;
}
}
//this function is to be used only with sub-panels that are based
//on collections.
function get_header_panel_def ()
{
if (! empty ( $this->sub_subpanels ))
{
if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ))
{
return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ;
} else
{
reset ( $this->sub_subpanels ) ;
return current ( $this->sub_subpanels ) ;
}
}
return null ;
}
/**
* Returns an array of current properties of the class.
* It will simply give the class name for instances of classes.
*/
function _to_array ()
{
return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ;
}
}
;
class SubPanelDefinitions
{
var $_focus ;
var $_visible_tabs_array ;
var $panels ;
var $layout_defs ;
/**
* Enter description here...
*
* @param BEAN $focus - this is the bean you want to get the data from
* @param STRING $layout_def_key - if you wish to use a layout_def defined in the default metadata/subpaneldefs.php that is not keyed off of $bean->module_dir pass in the key here
* @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here.
* @return SubPanelDefinitions
*/
function SubPanelDefinitions ( $focus , $layout_def_key = '' , $layout_def_override = '' )
{
$this->_focus = $focus ;
if (! empty ( $layout_def_override ))
{
$this->layout_defs = $layout_def_override ;
} else
{
$this->open_layout_defs ( false, $layout_def_key ) ;
}
}
/**
* This function returns an ordered list of all "tabs", actually subpanels, for this module
* The source list is obtained from the subpanel layout contained in the layout_defs for this module,
* found either in the modules metadata/subpaneldefs.php file, or in the modules custom/.../Ext/Layoutdefs/layoutdefs.ext.php file
* and filtered through an ACL check.
* Note that the keys for the resulting array of tabs are in practice the name of the underlying source relationship for the subpanel
* So for example, the key for a custom module's subpanel with Accounts might be 'one_one_accounts', as generated by the Studio Relationship Editor
* Although OOB module subpanels have keys such as 'accounts', which might on the face of it appear to be a reference to the related module, in fact 'accounts' is still the relationship name
* @param boolean Optional - include the subpanel title label in the return array (false)
* @return array All tabs that pass an ACL check
*/
function get_available_tabs ($FromGetModuleSubpanels=false)
{
global $modListHeader ;
global $modules_exempt_from_availability_check ;
if (isset ( $this->_visible_tabs_array ))
return $this->_visible_tabs_array ;
if (empty($modListHeader))
$modListHeader = query_module_access_list($GLOBALS['current_user']);
$this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort
if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first
{
//retrieve list of hidden subpanels
$hidden_panels = $this->get_hidden_subpanels();
//activities is a special use case in that if it is hidden,
//then the history tab should be hidden too.
if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){
//add history to list hidden_panels
$hidden_panels['history'] = 'history';
}
foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array )
{
//exclude if this subpanel is hidden from admin screens
$module = $key;
if ( isset($values_array['module']) )
$module = strtolower($values_array['module']);
if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){
//this panel is hidden, skip it
continue;
}
// make sure the module attribute is set, else none of this works...
if ( !isset($values_array [ 'module' ])) {
$GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ;
continue;
}
//check permissions.
$exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ;
$ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ;
$GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ;
if ( $ok )
{
while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) )
{
$values_array [ 'order' ] ++ ;
}
$this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ;
}
}
}
ksort ( $this->_visible_tabs_array ) ;
return $this->_visible_tabs_array ;
}
/**
* Load the definition of the a sub-panel.
* Also the sub-panel is added to an array of sub-panels.
* use of reload has been deprecated, since the subpanel is initialized every time.
*/
function load_subpanel ( $name , $reload = false , $original_only = false )
{
if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ]))
return false;
return new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only ) ;
}
/**
* Load the layout def file and associate the definition with a variable in the file.
*/
function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false )
{
$layout_defs [ $this->_focus->module_dir ] = array ( ) ;
$layout_defs [ $layout_def_key ] = array ( ) ;
if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] )))
{
if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' ))
require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' ))
require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
if (! empty ( $layout_def_key ))
$this->layout_defs = $layout_defs [ $layout_def_key ] ;
else
$this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
}
}
/**
* Removes a tab from the list of loaded tabs.
* Returns true if successful, false otherwise.
* Hint: Used by Campaign's DetailView.
*/
function exclude_tab ( $tab_name )
{
$result = false ;
//unset layout definition
if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ))
{
unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ;
}
//unset instance from _visible_tab_array
if (! empty ( $this->_visible_tabs_array ))
{
$key = array_search ( $tab_name, $this->_visible_tabs_array ) ;
if ($key !== false)
{
unset ( $this->_visible_tabs_array [ $key ] ) ;
}
}
return $result ;
}
/**
* return all available subpanels that belong to the list of tab modules. You can optionally return all
* available subpanels, and also optionally group by module (prepends the key with the bean class name).
*/
function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false )
{
global $moduleList, $beanFiles, $beanList, $module;
//use tab controller function to get module list with named keys
require_once("modules/MySettings/TabController.php");
$modules_to_check = TabController::get_key_array($moduleList);
//change case to match subpanel processing later on
$modules_to_check = array_change_key_case($modules_to_check);
// Append on the CampaignLog module, because that is where the subpanels point, not directly to Campaigns
$modules_to_check['campaignlog'] = "CampaignLog";
$spd = '';
$spd_arr = array();
//iterate through modules and build subpanel array
foreach($modules_to_check as $mod_name){
//skip if module name is not in bean list, otherwise get the bean class name
if(!isset($beanList[$mod_name])) continue;
$class = $beanList[$mod_name];
//skip if class name is not in file list, otherwise require the bean file and create new class
if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
//retrieve subpanels for this bean
require_once($beanFiles[$class]);
$bean_class = new $class();
//create new subpanel definition instance and get list of tabs
$spd = new SubPanelDefinitions($bean_class) ;
$sub_tabs = $spd->get_available_tabs();
//add each subpanel to array of total subpanles
foreach( $sub_tabs as $panel_key){
$panel_key = strtolower($panel_key);
$panel_module = $panel_key;
if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) )
$panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']);
//if module_only flag is set, only if it is also in module array
if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
$panel_key_name = $panel_module;
//group_by_key_name is set to true, then array will hold an entry for each
//subpanel, with the module name prepended in the key
if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
//add panel name to subpanel array
$spd_arr[$panel_key_name] = $panel_module;
}
}
return $spd_arr;
}
/*
* save array of hidden panels to mysettings category in config table
*/
function set_hidden_subpanels($panels){
$administration = new Administration();
$serialized = base64_encode(serialize($panels));
$administration->saveSetting('MySettings', 'hide_subpanels', $serialized);
}
/*
* retrieve hidden subpanels
*/
function get_hidden_subpanels(){
global $moduleList;
//create variable as static to minimize queries
static $hidden_subpanels = null;
// if the static value is not already cached, then retrieve it.
if(empty($hidden_subpanels))
{
//create Administration object and retrieve any settings for panels
$administration = new Administration();
$administration->retrieveSettings('MySettings');
if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){
$hidden_subpanels = $administration->settings['MySettings_hide_subpanels'];
$hidden_subpanels = trim($hidden_subpanels);
//make sure serialized string is not empty
if (!empty($hidden_subpanels)){
//decode and unserialize to retrieve the array
$hidden_subpanels = base64_decode($hidden_subpanels);
$hidden_subpanels = unserialize($hidden_subpanels);
//Ensure modules saved in the preferences exist.
//get user preference
//unserialize and add to array if not empty
$pref_hidden = array();
foreach($pref_hidden as $id => $pref_hidden_panel) {
$hidden_subpanels[] = $pref_hidden_panel;
}
}else{
//no settings found, return empty
return $hidden_subpanels;
}
}
else
{ //no settings found, return empty
return $hidden_subpanels;
}
}
return $hidden_subpanels;
}
}
?>

View File

@@ -0,0 +1,65 @@
<!--
/*********************************************************************************
* 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".
********************************************************************************/
-->
<!-- BEGIN: dyn_list_view -->
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view">
<tbody>
<!-- BEGIN: list_nav_row -->
{PAGINATION}
<!-- END: list_nav_row -->
<tr height="20">
<!-- BEGIN: header_cell -->
<th scope="col" width="{CELL_WIDTH}" nowrap="nowrap"><span sugar='slot{CELL_COUNT}'>{HEADER_CELL}</span sugar='slot'></th>
<!-- END: header_cell -->
</tr>
<!-- BEGIN: row -->
<tr height="20" class="{ROW_COLOR}S1" >
<!-- BEGIN: cell -->
<td scope="row" valign="top" nowrap="nowrap"><span sugar='slot{CELL_COUNT}b'>{CELL}</span sugar='slot'></td>
<!-- END: cell -->
</tr>
<!-- END: row -->
<!-- BEGIN: nodata -->
<tr height='20' class='{ROW_COLOR}S1'>
<td colspan='{COL_COUNT}'>
<em>{APP.LBL_NO_DATA}</em>
</td>
</tr>
<!-- END: nodata -->
</tbody>
</table>
<!-- END: dyn_list_view -->

View File

@@ -0,0 +1,121 @@
/*********************************************************************************
* 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".
********************************************************************************/
var request_id=0;var current_child_field='';var current_subpanel_url='';var child_field_loaded=new Object();var request_map=new Object();function get_module_name()
{if(typeof(window.document.forms['DetailView'])=='undefined'){return'';}else{if(typeof(window.document.forms['DetailView'].elements['subpanel_parent_module'])!='undefined'&&window.document.forms['DetailView'].elements['subpanel_parent_module'].value!=''){return window.document.forms['DetailView'].elements['subpanel_parent_module'].value;}
return window.document.forms['DetailView'].elements['module'].value;}}
function subp_nav(m,i,a,t,r){if(t.href.search(/#/)<0){return;}
if(a=='d'){a='DetailView';}else{a='EditView';}
url="index.php?module="+m+"&action="+a+"&record="+i+"&parent_module="+get_module_name()+"&parent_id="+get_record_id()+"&return_module="+get_module_name()+"&return_id="+get_record_id()+"&return_action=DetailView";if(r)
{url+="&return_relationship="+r;}
t.href=url;}
function sub_p_rem(sp,lf,li,rp){return_url="index.php?module="+get_module_name()+"&action=SubPanelViewer&subpanel="+sp+"&record="+get_record_id()+"&sugar_body_only=1&inline=1";remove_url="index.php?module="+get_module_name()
+"&action=DeleteRelationship"
+"&record="+get_record_id()
+"&linked_field="+lf
+"&linked_id="+li
+"&return_url="+escape(escape(return_url))
+"&refresh_page="+rp;showSubPanel(sp,remove_url,true);}
function sp_rem_conf(){return confirm(SUGAR.language.get('app_strings','NTC_REMOVE_CONFIRMATION'))}
function get_record_id()
{return window.document.forms['DetailView'].elements['record'].value;}
function get_layout_def_key()
{if(typeof(window.document.forms['DetailView'].elements['layout_def_key'])=='undefined')return'';return window.document.forms['DetailView'].elements['layout_def_key'].value;}
function save_finished(args)
{var child_field=request_map[args.request_id];delete(child_field_loaded[child_field]);showSubPanel(child_field);}
function set_return_and_save_background(popup_reply_data)
{var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;var passthru_data=popup_reply_data.passthru_data;var query_array=new Array();if(name_to_value_array!='undefined'){for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{query_array.push(the_key+"="+name_to_value_array[the_key]);}}}
var selection_list=popup_reply_data.selection_list;if(selection_list!='undefined'){for(var the_key in selection_list)
{query_array.push('subpanel_id[]='+selection_list[the_key])}}
var module=get_module_name();var id=get_record_id();query_array.push('value=DetailView');query_array.push('module='+module);query_array.push('http_method=get');query_array.push('return_module='+module);query_array.push('return_id='+id);query_array.push('record='+id);query_array.push('isDuplicate=false');query_array.push('action=Save2');query_array.push('inline=1');var refresh_page=escape(passthru_data['refresh_page']);for(prop in passthru_data){if(prop=='link_field_name'){query_array.push('subpanel_field_name='+escape(passthru_data[prop]));}else{if(prop=='module_name'){query_array.push('subpanel_module_name='+escape(passthru_data[prop]));}else{query_array.push(prop+'='+escape(passthru_data[prop]));}}}
var query_string=query_array.join('&');request_map[request_id]=passthru_data['child_field'];var returnstuff=http_fetch_sync('index.php',query_string);request_id++;got_data(returnstuff,true);if(refresh_page==1){document.location.reload(true);}}
function got_data(args,inline)
{var list_subpanel=document.getElementById('list_subpanel_'+request_map[args.request_id].toLowerCase());if(list_subpanel!=null){var subpanel=document.getElementById('subpanel_'+request_map[args.request_id].toLowerCase());var child_field=request_map[args.request_id].toLowerCase();if(inline){buttonHTML='';trEls=list_subpanel.getElementsByTagName('tr');if(trEls&&trEls.length>0){for(x in trEls){if(trEls[x]&&trEls[x].className=='pagination'){tableEls=trEls[x].getElementsByTagName('table');tdEls=tableEls[0].getElementsByTagName('td');span=tdEls[0].getElementsByTagName('span');if(span){buttonHTML=span[0].innerHTML;}
break;}}}
child_field_loaded[child_field]=2;list_subpanel.innerHTML='';list_subpanel.innerHTML=args.responseText;if(buttonHTML!=''){list_subpanel=document.getElementById('list_subpanel_'+request_map[args.request_id].toLowerCase());trEls=list_subpanel.getElementsByTagName('tr');for(x in trEls){if(trEls[x]&&trEls[x].className=='pagination'){tableEls=trEls[x].getElementsByTagName('table');tdEls=tableEls[0].getElementsByTagName('td');span=tdEls[0].getElementsByTagName('span');span[0].innerHTML=buttonHTML;break;}}}}else{child_field_loaded[child_field]=1;subpanel.innerHTML='';subpanel.innerHTML=args.responseText;var inlineTable=subpanel.getElementsByTagName('table');inlineTable=inlineTable[1];inlineTable=subpanel.removeChild(inlineTable);var listDiv=document.createElement('div');listDiv.id='list_subpanel_'+request_map[args.request_id].toLowerCase();subpanel.appendChild(listDiv);listDiv.appendChild(inlineTable);}
subpanel.style.display='';set_div_cookie(subpanel.cookie_name,'');if(current_child_field!=''&&child_field!=current_child_field)
{}
current_child_field=child_field;}}
function showSubPanel(child_field,url,force_load,layout_def_key)
{var inline=1;if(typeof(force_load)=='undefined'||force_load==null)
{force_load=false;}
if(force_load||typeof(child_field_loaded[child_field])=='undefined')
{request_map[request_id]=child_field;if(typeof(url)=='undefined'||url==null)
{var module=get_module_name();var id=get_record_id();if(typeof(layout_def_key)=='undefined'||layout_def_key==null){layout_def_key=get_layout_def_key();}
url='index.php?sugar_body_only=1&module='+module+'&subpanel='+child_field+'&action=SubPanelViewer&inline='+inline+'&record='+id+'&layout_def_key='+layout_def_key;}
if(url.indexOf('http://')!=0&&url.indexOf('https://')!=0)
{url=''+url;}
current_subpanel_url=url;var returnstuff=http_fetch_sync(url+'&inline='+inline+'&ajaxSubpanel=true');request_id++;got_data(returnstuff,inline);}
else
{var subpanel=document.getElementById('subpanel_'+child_field);subpanel.style.display='';set_div_cookie(subpanel.cookie_name,'');if(current_child_field!=''&&child_field!=current_child_field)
{hideSubPanel(current_child_field);}
current_child_field=child_field;}
if(typeof(url)!='undefined'&&url!=null&&url.indexOf('refresh_page=1')>0){document.location.reload();}}
function markSubPanelLoaded(child_field){child_field_loaded[child_field]=2;}
function hideSubPanel(child_field)
{var subpanel=document.getElementById('subpanel_'+child_field);subpanel.style.display='none';set_div_cookie(subpanel.cookie_name,'none');}
var sub_cookie_name=get_module_name()+'_divs';var temp=Get_Cookie(sub_cookie_name);var div_cookies=new Array();if(temp&&typeof(temp)!='undefined'){div_cookies=get_sub_cookies(temp);}
function set_div_cookie(name,display){div_cookies[name]=display;Set_Cookie(sub_cookie_name,subs_to_cookie(div_cookies),3000,false,false,false);}
function local_open_popup(name,width,height,arg1,arg2,arg3,params)
{return open_popup(name,width,height,arg1,arg2,arg3,params);}
SUGAR.subpanelUtils=function(){var originalLayout=null;var subpanelContents={};var subpanelLocked={};return{getLayout:function(asString,ignoreHidden){subpanels=document.getElementById('subpanel_list');subpanelIds=new Array();for(wp=0;wp<subpanels.childNodes.length;wp++){if(typeof subpanels.childNodes[wp].id!='undefined'&&subpanels.childNodes[wp].id.match(/whole_subpanel_[\w-]*/)&&(typeof ignoreHidden=='undefined'||subpanels.childNodes[wp].style.display!='none')){subpanelIds.push(subpanels.childNodes[wp].id.replace(/whole_subpanel_/,''));}}
if(asString)return subpanelIds.join(',');else return subpanelIds;},onDrag:function(e,id){originalLayout=SUGAR.subpanelUtils.getLayout(true,true);},onDrop:function(e,id){newLayout=SUGAR.subpanelUtils.getLayout(true,true);if(originalLayout!=newLayout){SUGAR.subpanelUtils.saveLayout(newLayout);}},saveLayout:function(order){ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING_LAYOUT'));if(typeof SUGAR.subpanelUtils.currentSubpanelGroup!='undefined'){var orderList=SUGAR.subpanelUtils.getLayout(false,true);var currentGroup=SUGAR.subpanelUtils.currentSubpanelGroup;}
var success=function(data){ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVED_LAYOUT'));window.setTimeout('ajaxStatus.hideStatus()',2000);if(typeof SUGAR.subpanelUtils.currentSubpanelGroup!='undefined'){SUGAR.subpanelUtils.reorderSubpanelSubtabs(currentGroup,orderList);}}
url='index.php?module=Home&action=SaveSubpanelLayout&layout='+order+'&layoutModule='+currentModule;if(typeof SUGAR.subpanelUtils.currentSubpanelGroup!='undefined'){url=url+'&layoutGroup='+encodeURI(SUGAR.subpanelUtils.currentSubpanelGroup);}
var cObj=YAHOO.util.Connect.asyncRequest('GET',url,{success:success,failure:success});},inlineSave:function(theForm,buttonName){ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING'));var success=function(data){var element=document.getElementById(buttonName);do{element=element.parentNode;}while(element.className!='quickcreate'&&element.parentNode);if(element.className=='quickcreate'){var subpanel=element.id.slice(9,-7);SUGAR.subpanelUtils.cancelCreate(buttonName);var module=get_module_name();var id=get_record_id();var layout_def_key=get_layout_def_key();try{eval('result = '+data.responseText);}catch(err){}
if(typeof(result)!='undefined'&&result!=null&&typeof(result['status'])!='undefined'&&result['status']!=null&&result['status']=='dupe'){document.location.href="index.php?"+result['get'].replace(/&amp;/gi,'&').replace(/&lt;/gi,'<').replace(/&gt;/gi,'>').replace(/&#039;/gi,'\'').replace(/&quot;/gi,'"').replace(/\r\n/gi,'\n');return;}else{showSubPanel(subpanel,null,true);ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVED'));window.setTimeout('ajaxStatus.hideStatus()',1000);if(reloadpage)window.location.reload(false);}}}
var reloadpage=false;if((buttonName=='Meetings_subpanel_save_button'||buttonName=='Calls_subpanel_save_button')&&document.getElementById(theForm).status[document.getElementById(theForm).status.selectedIndex].value=='Held'){reloadpage=true;}
YAHOO.util.Connect.setForm(theForm,true,true);var cObj=YAHOO.util.Connect.asyncRequest('POST','index.php',{success:success,failure:success,upload:success});return false;},sendAndRetrieve:function(theForm,theDiv,loadingStr){function success(data){theDivObj=document.getElementById(theDiv);subpanelContents[theDiv]=new Array();subpanelContents[theDiv]['list']=theDivObj;subpanelContents[theDiv]['newDiv']=document.createElement('div');dataToDOMAvail=false;subpanelContents[theDiv]['newDiv'].innerHTML='<script type="text/javascript">dataToDOMAvail=true;</script>'+data.responseText;subpanelContents[theDiv]['newDiv'].id=theDiv+'_newDiv';subpanelContents[theDiv]['newDiv'].className='quickcreate';theDivObj.style.display='none';theDivObj.parentNode.insertBefore(subpanelContents[theDiv]['newDiv'],theDivObj);if(!dataToDOMAvail){SUGAR.util.evalScript(data.responseText);}
subpanelLocked[theDiv]=false;setTimeout("enableQS(false)",500);ajaxStatus.hideStatus();}
if(typeof subpanelLocked[theDiv]!='undefined'&&subpanelLocked[theDiv])return false;subpanelLocked[theDiv]=true;if(typeof loadingStr=='undefined')loadingStr=SUGAR.language.get('app_strings','LBL_LOADING');ajaxStatus.showStatus(loadingStr);YAHOO.util.Connect.setForm(theForm);var cObj=YAHOO.util.Connect.asyncRequest('POST','index.php',{success:success,failure:success});return false;},cancelCreate:function(buttonName){var element=document.getElementById(buttonName);do{element=element.parentNode;}while(element.className!='quickcreate'&&element.parentNode);var theDiv=element.id.substr(0,element.id.length-7);if(typeof(subpanelContents[theDiv])=='undefined')
return false;subpanelContents[theDiv]['newDiv'].parentNode.removeChild(subpanelContents[theDiv]['newDiv']);subpanelContents[theDiv]['list'].style.display='';return false;},loadSubpanelGroupFromMore:function(group){SUGAR.subpanelUtils.updateSubpanelMoreTab(group);SUGAR.subpanelUtils.loadSubpanelGroup(group);},updateSubpanelMoreTab:function(group){var moreTab=document.getElementById(SUGAR.subpanelUtils.subpanelMoreTab+'_sp_tab');moreTab.id=group+'_sp_tab';moreTab.getElementsByTagName('a')[0].innerHTML=group;moreTab.getElementsByTagName('a')[0].href="javascript:SUGAR.subpanelUtils.loadSubpanelGroup('"+group+"');";var menuLink=document.getElementById(group+'_sp_mm');menuLink.id=SUGAR.subpanelUtils.subpanelMoreTab+'_sp_mm';menuLink.href="javascript:SUGAR.subpanelUtils.loadSubpanelGroupFromMore('"+SUGAR.subpanelUtils.subpanelMoreTab+"');";menuLink.innerHTML=SUGAR.subpanelUtils.subpanelMoreTab;SUGAR.subpanelUtils.subpanelMoreTab=group;},loadSubpanelGroup:function(group){if(group==SUGAR.subpanelUtils.currentSubpanelGroup)return;if(SUGAR.subpanelUtils.loadedGroups[group]){SUGAR.subpanelUtils.updateSubpanel(group);}else{SUGAR.subpanelUtils.loadedGroups.push(group);var needed=Array();for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){if(typeof(SUGAR.subpanelUtils.subpanelGroups[group][group_sp])=='string'&&!document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp])){needed.push(SUGAR.subpanelUtils.subpanelGroups[group][group_sp]);}}
var success=function(){SUGAR.subpanelUtils.updateSubpanelEventHandlers(needed);SUGAR.subpanelUtils.updateSubpanels(group);};if(needed.length){ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_LOADING'));SUGAR.util.retrieveAndFill(SUGAR.subpanelUtils.requestUrl+needed.join(','),'subpanel_list',null,success,null,true);}else{SUGAR.subpanelUtils.updateSubpanels(group);}}
SUGAR.subpanelUtils.setGroupCookie(group);},updateSubpanels:function(group){var sp_list=document.getElementById('subpanel_list');for(sp in sp_list.childNodes){if(sp_list.childNodes[sp].id){sp_list.childNodes[sp].style.display='none';}}
for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){if(typeof(SUGAR.subpanelUtils.subpanelGroups[group][group_sp])!='string')continue;var cur=document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp]);cur.style.display='block';try{YAHOO.util.DDM.swapNode(cur,sp_list.getElementsByTagName('LI')[group_sp]);}catch(e){}}
SUGAR.subpanelUtils.updateSubpanelTabs(group);},updateSubpanelTabs:function(group){if(SUGAR.subpanelUtils.showLinks){SUGAR.subpanelUtils.updateSubpanelSubtabs(group);document.getElementById('subpanelSubTabs').innerHTML=SUGAR.subpanelUtils.subpanelSubTabs[group];}
oldTab=document.getElementById(SUGAR.subpanelUtils.currentSubpanelGroup+'_sp_tab');if(oldTab){oldTab.className='';oldTab.getElementsByTagName('a')[0].className='';}
mainTab=document.getElementById(group+'_sp_tab');mainTab.className='active';mainTab.getElementsByTagName('a')[0].className='current';SUGAR.subpanelUtils.currentSubpanelGroup=group;ajaxStatus.hideStatus();},updateSubpanelEventHandlers:function(){if(SubpanelInitTabNames){SubpanelInitTabNames(SUGAR.subpanelUtils.getLayout(false));}},reorderSubpanelSubtabs:function(group,order){SUGAR.subpanelUtils.subpanelGroups[group]=order;if(SUGAR.subpanelUtils.showLinks==1){SUGAR.subpanelUtils.updateSubpanelSubtabs(group);if(SUGAR.subpanelUtils.currentSubpanelGroup==group){document.getElementById('subpanelSubTabs').innerHTML=SUGAR.subpanelUtils.subpanelSubTabs[group];}}},updateSubpanelSubtabs:function(group){var notFirst=0;var preMore=SUGAR.subpanelUtils.subpanelGroups[group].slice(0,SUGAR.subpanelUtils.subpanelMaxSubtabs);SUGAR.subpanelUtils.subpanelSubTabs[group]='<table border="0" cellpadding="0" cellspacing="0" height="20" width="100%" class="subTabs"><tr>';for(var sp_key=0;sp_key<preMore.length;sp_key++){if(notFirst!=0){SUGAR.subpanelUtils.subpanelSubTabs[group]+='<td width="1"> | </td>';}else{notFirst=1;}
SUGAR.subpanelUtils.subpanelSubTabs[group]+='<td nowrap="nowrap"><a href="#'+preMore[sp_key]+'" class="subTabLink">'+SUGAR.subpanelUtils.subpanelTitles[preMore[sp_key]]+'</a></td>';}
if(document.getElementById('MoreSub'+group+'PanelMenu')){SUGAR.subpanelUtils.subpanelSubTabs[group]+='<td nowrap="nowrap"> | &nbsp;<span class="subTabMore" id="MoreSub'+group+'PanelHandle" style="margin-left:2px; cursor: pointer; cursor: hand;" align="absmiddle" onmouseover="SUGAR.subpanelUtils.menu.tbspButtonMouseOver(this.id,\'\',\'\',0);">&gt;&gt;</span></td>';}
SUGAR.subpanelUtils.subpanelSubTabs[group]+='<td width="100%">&nbsp;</td></tr></table>';var postMore=SUGAR.subpanelUtils.subpanelGroups[group].slice(SUGAR.subpanelUtils.subpanelMaxSubtabs);var subpanelMenu=document.getElementById('MoreSub'+group+'PanelMenu');if(postMore&&subpanelMenu){subpanelMenu.innerHTML='';for(var sp_key=0;sp_key<postMore.length;sp_key++){subpanelMenu.innerHTML+='<a href="#'+postMore[sp_key]+'" class="menuItem" parentid="MoreSub'+group+'PanelMenu" onmouseover="hiliteItem(this,\'yes\'); closeSubMenus(this);" onmouseout="unhiliteItem(this);">'+SUGAR.subpanelUtils.subpanelTitles[postMore[sp_key]]+'</a>';}
subpanelMenu+='</div>';}},setGroupCookie:function(group){Set_Cookie(SUGAR.subpanelUtils.tabCookieName,group,3000,false,false,false);}};}();SUGAR.subpanelUtils.menu=function(){return{tbspButtonMouseOver:function(id,top,left,leftOffset){closeMenusDelay=eraseTimeout(closeMenusDelay);if(openMenusDelay==null){openMenusDelay=window.setTimeout("SUGAR.subpanelUtils.menu.spShowMenu('"+id+"','"+top+"','"+left+"','"+leftOffset+"')",delayTime);}},spShowMenu:function(id,top,left,leftOffset){openMenusDelay=eraseTimeout(openMenusDelay);var menuName=id.replace(/Handle/i,'Menu');var menu=getLayer(menuName);if(currentMenu){closeAllMenus();}
SUGAR.subpanelUtils.menu.spPopupMenu(id,menu,top,left,leftOffset);},spPopupMenu:function(handleID,menu,top,left,leftOffset){var bw=checkBrowserWidth();var menuName=handleID.replace(/Handle/i,'Menu');var menuWidth=120;var imgWidth=document.getElementById(handleID).width;if(menu){var menuHandle=getLayer(handleID);var p=menuHandle;if(left==""){var left=0;while(p&&p.tagName.toUpperCase()!='BODY'){left+=p.offsetLeft;p=p.offsetParent;}
left+=parseInt(leftOffset);}
if(top==""){var top=0;p=menuHandle;top+=p.offsetHeight;while(p&&p.tagName.toUpperCase()!='BODY'){top+=p.offsetTop;p=p.offsetParent;}}
if(left+menuWidth>bw){left=left-menuWidth+imgWidth;}
setMenuVisible(menu,left,top,false);}}};}();

View File

@@ -0,0 +1,449 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/SubPanel/SubPanel.php');
require_once('include/SubPanel/SubPanelTilesTabs.php');
require_once('include/SubPanel/SubPanelDefinitions.php');
class SubPanelTiles
{
var $id;
var $module;
var $focus;
var $start_on_field;
var $layout_manager;
var $layout_def_key;
var $show_tabs = false;
var $subpanel_definitions;
var $hidden_tabs=array(); //consumer of this class can array of tabs that should be hidden. the tab name
//should be the array.
function SubPanelTiles(&$focus, $layout_def_key='', $layout_def_override = '')
{
$this->focus = $focus;
$this->id = $focus->id;
$this->module = $focus->module_dir;
$this->layout_def_key = $layout_def_key;
$this->subpanel_definitions=new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override);
}
/*
* Return the current selected or requested subpanel tab
* @return string The identifier for the selected subpanel tab (e.g., 'Other')
*/
function getSelectedGroup()
{
global $current_user;
if(isset($_REQUEST['subpanelTabs']))
$_SESSION['subpanelTabs'] = $_REQUEST['subpanelTabs'];
require_once 'include/tabConfig.php' ; // include/tabConfig.php in turn includes the customized file at custom/include/tabConfig.php...
$subpanelTabsPref = $current_user->getPreference('subpanel_tabs');
if(!isset($subpanelTabsPref)) $subpanelTabsPref = $GLOBALS['sugar_config']['default_subpanel_tabs'];
if(!empty($GLOBALS['tabStructure']) && (!empty($_SESSION['subpanelTabs']) || !empty($sugar_config['subpanelTabs']) || !empty($subpanelTabsPref)))
{
// Determine selected group
if(!empty($_REQUEST['subpanel']))
{
$selected_group = $_REQUEST['subpanel'];
}
elseif(!empty($_COOKIE[$this->module.'_sp_tab']))
{
$selected_group = $_COOKIE[$this->module.'_sp_tab'];
}
elseif(!empty($_SESSION['parentTab']) && !empty($GLOBALS['tabStructure'][$_SESSION['parentTab']]) && in_array($this->module, $GLOBALS['tabStructure'][$_SESSION['parentTab']]['modules']))
{
$selected_group = $_SESSION['parentTab'];
}
else
{
$selected_group = '';
foreach($GLOBALS['tabStructure'] as $mainTab => $group)
{
if(in_array($this->module, $group['modules']))
{
$selected_group = $mainTab;
break;
}
}
if(!$selected_group)
{
$selected_group = 'All';
}
}
}
else
{
$selected_group = '';
}
return $selected_group;
}
/*
* Determine which subpanels should be shown within the selected tab group (e.g., 'Other');
* @param boolean $showTabs True if we should call the code to render each visible tab
* @param string $selectedGroup The requested tab group
* @return array Visible tabs
*/
function getTabs($showTabs = true, $selectedGroup='')
{
global $current_user;
//get all the "tabs" - this actually means all the subpanels available for display within a tab
$tabs = $this->subpanel_definitions->get_available_tabs();
if(!empty($selectedGroup))
{
return SubPanelTilesTabs::getTabs($tabs, $showTabs, $selectedGroup);
}
else
{
// see if user current user has custom subpanel layout
$tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs);
/* Check if the preference is set now,
* because there's no point in executing this code if
* we aren't going to render anything.
*/
$subpanelLinksPref = $current_user->getPreference('subpanel_links');
if(!isset($subpanelLinksPref)) $subpanelLinksPref = $GLOBALS['sugar_config']['default_subpanel_links'];
if($showTabs && $subpanelLinksPref){
require_once('include/SubPanel/SugarTab.php');
$sugarTab = new SugarTab();
$displayTabs = array();
foreach($tabs as $tab){
$displayTabs []= array('key'=>$tab, 'label'=>translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']));
//echo '<td nowrap="nowrap"><a class="subTabLink" href="#' . $tab . '">' . translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']) . '</a></td><td> | </td>';
}
$sugarTab->setup(array(),array(),$displayTabs);
$sugarTab->display();
}
//echo '<td width="100%">&nbsp;</td></tr></table>';
}
return $tabs;
}
function display($showContainer = true, $forceTabless = false)
{
global $layout_edit_mode, $sugar_version, $sugar_config, $current_user, $app_strings;
if(isset($layout_edit_mode) && $layout_edit_mode){
return;
}
global $modListHeader;
ob_start();
echo '<script type="text/javascript" src="'. getJSPath('include/SubPanel/SubPanelTiles.js') . '"></script>';
?>
<script>
if(document.DetailView != null &&
document.DetailView.elements != null &&
document.DetailView.elements.layout_def_key != null &&
typeof document.DetailView.elements['layout_def_key'] != 'undefined'){
document.DetailView.elements['layout_def_key'].value = '<?php echo $this->layout_def_key; ?>';
}
</script>
<?php
$tabs = array();
$default_div_display = 'inline';
if(!empty($sugar_config['hide_subpanels_on_login'])){
if(!isset($_SESSION['visited_details'][$this->focus->module_dir])){
setcookie($this->focus->module_dir . '_divs', '');
unset($_COOKIE[$this->focus->module_dir . '_divs']);
$_SESSION['visited_details'][$this->focus->module_dir] = true;
}
$default_div_display = 'none';
}
$div_cookies = get_sub_cookies($this->focus->module_dir . '_divs');
//Display the group header. this section is executed only if the tabbed interface is being used.
$current_key = '';
if (! empty($this->show_tabs))
{
require_once('include/tabs.php');
$tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showSubPanel');
echo get_form_header('Related', '', false);
echo "<br />" . $tab_panel->display();
}
if(empty($_REQUEST['subpanels']))
{
$selected_group = $forceTabless?'':$this->getSelectedGroup();
$usersLayout = $current_user->getPreference('subpanelLayout', $this->focus->module_dir);
// we need to use some intelligence here when restoring the user's layout, as new modules with new subpanels might have been installed since the user's layout was recorded
// this means that we can't just restore the old layout verbatim as the new subpanels would then go walkabout
// so we need to do a merge while attempting as best we can to preserve the sense of the specified order
// this is complicated by the different ordering schemes used in the two sources for the panels: the user's layout uses an ordinal layout, the panels from getTabs have an explicit ordering driven by the 'order' parameter
// it's not clear how to best reconcile these two schemes; so we punt on it, and add all new panels to the end of the user's layout. At least this will give them a clue that something has changed...
// we also now check for tabs that have been removed since the user saved his or her preferences.
$tabs = $this->getTabs($showContainer, $selected_group) ;
if(!empty($usersLayout))
{
$availableTabs = $tabs ;
$tabs = array_intersect ( $usersLayout , $availableTabs ) ; // remove any tabs that have been removed since the user's layout was saved
foreach (array_diff ( $availableTabs , $usersLayout ) as $tab)
$tabs [] = $tab ;
}
}
else
{
$tabs = explode(',', $_REQUEST['subpanels']);
}
$tab_names = array();
if($showContainer)
{
echo '<ul class="noBullet" id="subpanel_list">';
}
//echo "<li id='hidden_0' style='height: 5px' class='noBullet'>&nbsp;&nbsp;&nbsp;</li>";
if (empty($GLOBALS['relationships'])) {
if (!class_exists('Relationship')) {
require('modules/Relationships/Relationship.php');
}
$rel= new Relationship();
$rel->load_relationship_meta();
foreach ($tabs as $tab)
{
//load meta definition of the sub-panel.
$thisPanel=$this->subpanel_definitions->load_subpanel($tab);
if ($thisPanel === false)
continue;
//this if-block will try to skip over ophaned subpanels. Studio/MB are being delete unloaded modules completely.
//this check will ignore subpanels that are collections (activities, history, etc)
if (!isset($thisPanel->_instance_properties['collection_list']) and isset($thisPanel->_instance_properties['get_subpanel_data']) ) {
//ignore when data source is a function
if (!isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']])) {
if (stripos($thisPanel->_instance_properties['get_subpanel_data'],'function:') === false) {
$GLOBALS['log']->fatal("Bad subpanel definition, it has incorrect value for get_subpanel_data property " .$tab);
continue;
}
} else {
$rel_name='';
if (isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'])) {
$rel_name=$this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'];
}
if (empty($rel_name) or !isset($GLOBALS['relationships'][$rel_name])) {
$GLOBALS['log']->fatal("Missing relationship definition " .$rel_name. ". skipping " .$tab ." subpanel");
continue;
}
}
}
echo '<li class="noBullet" id="whole_subpanel_' . $tab . '">';
$display= 'none';
$div_display = $default_div_display;
$cookie_name = $tab . '_v';
if(isset($div_cookies[$cookie_name])){
$div_display = $div_cookies[$cookie_name];
}
if(!empty($sugar_config['hide_subpanels'])){
$div_display = 'none';
}
if($div_display == 'none'){
$opp_display = 'inline';
}else{
$opp_display = 'none';
}
if (!empty($this->layout_def_key) ) {
$layout_def_key = $this->layout_def_key;
} else {
$layout_def_key = '';
}
if (empty($this->show_tabs))
{
$show_icon_html = SugarThemeRegistry::current()->getImage( 'advanced_search', 'alt="' . translate('LBL_SHOW') . '" border="0 align="absmiddle""');
$hide_icon_html = SugarThemeRegistry::current()->getImage( 'basic_search', 'alt="' . translate('LBL_HIDE') . '" border="0" align="absmiddle"');
$max_min = "<a name=\"$tab\"> </a><span id=\"show_link_".$tab."\" style=\"display: $opp_display\"><a href='#' class='utilsLink' onclick=\"current_child_field = '".$tab."';showSubPanel('".$tab."',null,null,'".$layout_def_key."');document.getElementById('show_link_".$tab."').style.display='none';document.getElementById('hide_link_".$tab."').style.display='';return false;\">"
. "" . $show_icon_html . "</a></span>";
$max_min .= "<span id=\"hide_link_".$tab."\" style=\"display: $div_display\"><a href='#' class='utilsLink' onclick=\"hideSubPanel('".$tab."');document.getElementById('hide_link_".$tab."').style.display='none';document.getElementById('show_link_".$tab."').style.display='';return false;\">"
. "" . $hide_icon_html . "</a></span>";
echo '<div id="subpanel_title_' . $tab . '"';
if(empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) echo ' onmouseover="this.style.cursor = \'move\';"';
echo '>' . get_form_header( $thisPanel->get_title(), $max_min, false) . '</div>';
}
echo <<<EOQ
<div cookie_name="$cookie_name" id="subpanel_$tab" style="display:$div_display">
<script>document.getElementById("subpanel_$tab" ).cookie_name="$cookie_name";</script>
EOQ;
$display_spd = '';
if($div_display != 'none'){
echo "<script>markSubPanelLoaded('$tab');</script>";
$old_contents = ob_get_contents();
@ob_end_clean();
ob_start();
include_once('include/SubPanel/SubPanel.php');
$subpanel_object = new SubPanel($this->module, $_REQUEST['record'], $tab,$thisPanel,$layout_def_key);
$subpanel_object->setTemplateFile('include/SubPanel/SubPanelDynamic.html');
$subpanel_object->display();
$subpanel_data = ob_get_contents();
@ob_end_clean();
ob_start();
echo $this->get_buttons($thisPanel,$subpanel_object->subpanel_query);
$buttons = ob_get_contents();
@ob_end_clean();
ob_start();
echo $old_contents;
//echo $buttons;
$display_spd = $subpanel_data;
}
echo <<<EOQ
<div id="list_subpanel_$tab">$display_spd</div>
</div>
EOQ;
array_push($tab_names, $tab);
echo '</li>';
} // end $tabs foreach
if($showContainer)
{
echo '</ul>';
if(!empty($selected_group))
{
// closing table from tpls/singletabmenu.tpl
echo '</td></tr></table>';
}
}
// drag/drop code
$tab_names = '["' . join($tab_names, '","') . '"]';
global $sugar_config;
if(empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) {
echo <<<EOQ
<script>
var SubpanelInit = function() {
SubpanelInitTabNames({$tab_names});
}
var SubpanelInitTabNames = function(tabNames) {
subpanel_dd = new Array();
j = 0;
for(i in tabNames) {
subpanel_dd[j] = new ygDDList('whole_subpanel_' + tabNames[i]);
subpanel_dd[j].setHandleElId('subpanel_title_' + tabNames[i]);
subpanel_dd[j].onMouseDown = SUGAR.subpanelUtils.onDrag;
subpanel_dd[j].afterEndDrag = SUGAR.subpanelUtils.onDrop;
j++;
}
YAHOO.util.DDM.mode = 1;
}
currentModule = '{$this->module}';
YAHOO.util.Event.addListener(window, 'load', SubpanelInit);
</script>
EOQ;
}
$ob_contents = ob_get_contents();
ob_end_clean();
return $ob_contents;
}
}
function getLayoutManager()
{
require_once('include/generic/LayoutManager.php');
if ( $this->layout_manager == null) {
$this->layout_manager = new LayoutManager();
}
return $this->layout_manager;
}
function get_buttons($thisPanel,$panel_query=null)
{
$subpanel_def = $thisPanel->get_buttons();
$layout_manager = $this->getLayoutManager();
$widget_contents = '<span><table cellpadding="0" cellspacing="0"><tr>';
foreach($subpanel_def as $widget_data)
{
$widget_data['query']=urlencode($panel_query);
$widget_data['action'] = $_REQUEST['action'];
$widget_data['module'] = $thisPanel->get_inst_prop_value('module');
$widget_data['focus'] = $this->focus;
$widget_data['subpanel_definition'] = $thisPanel;
$widget_contents .= '<td class="buttons">' . "\n";
if(empty($widget_data['widget_class']))
{
$widget_contents .= "widget_class not defined for top subpanel buttons";
}
else
{
$widget_contents .= $layout_manager->widgetDisplay($widget_data);
}
$widget_contents .= '</td>';
}
$widget_contents .= '</tr></table></span>';
return $widget_contents;
}
}

View File

@@ -0,0 +1,266 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/SubPanel/SubPanel.php');
require_once('include/SubPanel/SubPanelDefinitions.php');
require_once('include/SubPanel/SubPanelTiles.php');
class SubPanelTilesTabs extends SubPanelTiles
{
function SubPanelTiles(&$focus, $layout_def_key='', $layout_def_override = '')
{
$this->focus = $focus;
$this->id = $focus->id;
$this->module = $focus->module_dir;
$this->layout_def_key = $layout_def_key;
$this->subpanel_definitions = new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override);
}
function getSubpanelGroupLayout($selectedGroup)
{
global $current_user;
$layoutParams = $this->module;
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
if($selectedGroup != translate('LBL_TABGROUP_ALL'))
{
$layoutParams .= ':'.$selectedGroup;
}
// see if user current user has custom subpanel layout
return $current_user->getPreference('subpanelLayout', $layoutParams);
}
function applyUserCustomLayoutToTabs($tabs, $key='All')
{
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
if($key=='All')
{
$key=translate('LBL_TABGROUP_ALL');
}
$usersCustomLayout = SubPanelTilesTabs::getSubpanelGroupLayout($key);
if(!empty($usersCustomLayout))
{
/* Return elements of the custom layout
* which occur in $tabs in unchanged order.
* Then append elements of $tabs which are
* not included in the layout. */
$diff = array_diff($tabs, $usersCustomLayout);
$tabs = array_intersect($usersCustomLayout, $tabs);
foreach($diff as $subpanel)
{
$tabs []= $subpanel;
}
}
return $tabs;
}
/*
* Place subpanels into tabs for display on a DetailView
* @param array $tabs Array containing the ids of all subpanels to be placed into tabs
* @param boolean $showTabs Call the view code to display the generated tabs
* @param string $selectedGroup (Optional) Name of any selected tab (defaults to 'All')
*/
function getTabs($tabs, $showTabs = true, $selectedGroup='All')
{
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
if($selectedGroup=='All')
$selectedGroup=translate('LBL_TABGROUP_ALL');
require_once 'include/SubPanel/SubPanelDefinitions.php' ;
$spd = new SubPanelDefinitions ( $this->focus ) ;
// Set up a mapping from subpanelID, found in the $tabs list, to the source module name
// As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two
// when constructing the subpanel tabs
// Note that we can't use the very similar GroupedTabStructure class as it lacks this mapping, and logically, it is designed
// for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent
// subpanels, and use unique subpanel IDs instead.
$moduleNames = array () ;
foreach ( $tabs as $subpanelID )
{
$subpanel = $spd->load_subpanel( $subpanelID );
if ($subpanel !== false)
$moduleNames [ $subpanelID ] = $subpanel->get_module_name() ;
}
$groups = array () ;
$found = array () ;
foreach( $GLOBALS['tabStructure'] as $mainTab => $subModules)
{
foreach( $subModules['modules'] as $key => $subModule )
{
foreach ( $tabs as $subpanelID )
if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0)
{
$groups [ translate ( $mainTab ) ] [ 'modules' ] [ $key ] = $subpanelID ;
$found [ $subpanelID ] = true ;
break;
}
}
}
// Put all the remaining subpanels into the 'Other' tab.
foreach( $tabs as $subpanelID )
{
if ( ! isset ( $found [ $subpanelID ] ) )
$groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ;
}
/* Move history to same tab as activities */
if(in_array('history', $tabs) && in_array('activities', $tabs))
{
foreach($groups as $mainTab => $group)
{
if(in_array('activities', array_map('strtolower', $group['modules'])))
{
if(!in_array('history', array_map('strtolower', $group['modules'])))
{
/* Move hist from there to here */
$groups[$mainTab]['modules'] []= 'history';
}
}
else if(false !== ($i = array_search('history', array_map('strtolower', $group['modules']))))
{
unset($groups[$mainTab]['modules'][$i]);
if(empty($groups[$mainTab]['modules']))
{
unset($groups[$mainTab]);
}
}
}
}
/* Add the 'All' group.
* Note that if a tab group already exists with the name 'All',
* it will be overwritten in this union operation.
*/
if(count($groups) <= 1)
$groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs));
else
$groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups;
/* Note - all $display checking and array_intersects with $tabs
* are now redundant (thanks to GroupedTabStructure), and could
* be removed for performance, but for now can stay to help ensure
* that the tabs get renedered correctly.
*/
$retTabs = array();
if($showTabs)
{
require_once('include/SubPanel/SugarTab.php');
$sugarTab = new SugarTab();
$displayTabs = array();
$otherTabs = array();
foreach ($groups as $key=>$tab)
{
$display = false;
foreach($tab['modules'] as $subkey=>$subtab)
{
if(in_array(strtolower($subtab), $tabs))
{
$display = true;
break;
}
}
$selected = '';
if($selectedGroup == $key)
{
$selected = 'current';
}
if($display)
{
$relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key);
$sugarTabs[$key] = array(//'url'=>'index.php?module=' . $_REQUEST['module'] . '&record=' . $_REQUEST['record'] . '&action=' . $_REQUEST['action']. '&subpanel=' . $key.'#tabs',
//'url'=>"javascript:SUGAR.util.retrieveAndFill('index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$_REQUEST['module']}&record={$_REQUEST['record']}&subpanel=$key','subpanel_list',null,null,null);",
'label'=>( !empty($tab['label']) ? $tab['label']: $key ),
'type'=>$selected);
$otherTabs[$key] = array('key'=>$key, 'tabs'=>array());
$orderedTabs = array_intersect($relevantTabs, array_map('strtolower', $groups[$key]['modules']));
foreach($orderedTabs as $subkey => $subtab)
{
$otherTabs[$key]['tabs'][$subkey] = array('key'=>$subtab, 'label'=>translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$subtab]['title_key']));
}
if($selectedGroup == $key)
{
$displayTabs = $otherTabs[$key]['tabs'];
$retTabs = $orderedTabs;
}
}
}
if(empty($displayTabs) && !empty($otherTabs))
{
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
$selectedGroup = translate('LBL_TABGROUP_ALL');
$displayTabs = $otherTabs[$selectedGroup]['tabs'];
$sugarTabs[$selectedGroup]['type'] = 'current';
$retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
}
if (!empty($sugarTabs) || !empty($otherTabs) ) {
$sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup);
$sugarTab->display();
}
}
else
{
$tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $selectedGroup);
$retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
}
return $retTabs;
}
}
?>

View File

@@ -0,0 +1,91 @@
<?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".
********************************************************************************/
global $beanList;
global $beanFiles;
if(empty($_REQUEST['module']))
{
die("'module' was not defined");
}
if(empty($_REQUEST['record']))
{
die("'record' was not defined");
}
if(!isset($beanList[$_REQUEST['module']]))
{
die("'".$_REQUEST['module']."' is not defined in \$beanList");
}
$subpanel = $_REQUEST['subpanel'];
$record = $_REQUEST['record'];
$module = $_REQUEST['module'];
if(empty($_REQUEST['inline']))
{
insert_popup_header($theme);
}
//require_once('include/SubPanel/SubPanelDefinitions.php');
//require_once($beanFiles[$beanList[$_REQUEST['module']]]);
//$focus=new $beanList[$_REQUEST['module']];
//$focus->retrieve($record);
include('include/SubPanel/SubPanel.php');
$layout_def_key = '';
if(!empty($_REQUEST['layout_def_key'])){
$layout_def_key = $_REQUEST['layout_def_key'];
}
$subpanel_object = new SubPanel($module, $record, $subpanel,null, $layout_def_key);
$subpanel_object->setTemplateFile('include/SubPanel/SubPanelDynamic.html');
echo (empty($_REQUEST['inline']))?$subpanel_object->get_buttons():'' ;
$subpanel_object->display();
if(empty($_REQUEST['inline']))
{
insert_popup_footer($theme);
}
?>

88
include/SubPanel/SugarTab.php Executable file
View File

@@ -0,0 +1,88 @@
<?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".
********************************************************************************/
if(empty($GLOBALS['sugar_smarty']))$GLOBALS['sugar_smarty'] = new Sugar_Smarty();
class SugarTab{
function SugarTab($type='singletabmenu'){
$this->type = $type;
}
function setup($mainTabs, $otherTabs=array(), $subTabs=array(), $selected_group='All'){
global $sugar_version, $sugar_config, $current_user;
$max_tabs = $current_user->getPreference('max_tabs');
if(!isset($max_tabs) || $max_tabs <= 0) $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
$moreTabs = array_slice($mainTabs,$max_tabs);
/* If the current tab is in the 'More' menu, move it into the visible menu. */
if(!empty($moreTabs[$selected_group]))
{
$temp = array($selected_group => $mainTabs[$selected_group]);
unset($mainTabs[$selected_group]);
array_splice($mainTabs, $max_tabs-1, 0, $temp);
}
$GLOBALS['sugar_smarty']->assign('showLinks', 'false');
$GLOBALS['sugar_smarty']->assign('sugartabs', array_slice($mainTabs, 0, $max_tabs));
$GLOBALS['sugar_smarty']->assign('moreMenu', array_slice($mainTabs, $max_tabs));
$GLOBALS['sugar_smarty']->assign('othertabs', $otherTabs);
$GLOBALS['sugar_smarty']->assign('startSubPanel', $selected_group);
$GLOBALS['sugar_smarty']->assign('sugarVersionJsStr', "?s=$sugar_version&c={$sugar_config['js_custom_version']}");
if(!empty($mainTabs))
{
$mtak = array_keys($mainTabs);
$GLOBALS['sugar_smarty']->assign('moreTab', $mainTabs[$mtak[min(count($mtak)-1, $max_tabs-1)]]['label']);
}
}
function fetch(){
return $GLOBALS['sugar_smarty']->fetch('include/SubPanel/tpls/' . $this->type . '.tpl');
}
function display(){
$GLOBALS['sugar_smarty']->display('include/SubPanel/tpls/' . $this->type . '.tpl');
}
}
?>

View File

@@ -0,0 +1,52 @@
<?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".
********************************************************************************/
/**
* Retrieves an array of all the layout_defs defined in the app.
*/
function get_layout_defs()
{
//TODO add global memory cache support here. If there is an in memory cache, leverage it.
global $layout_defs;
return $layout_defs;
}
?>

View File

@@ -0,0 +1,141 @@
{*
/*********************************************************************************
* 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".
********************************************************************************/
*}
<script>
SUGAR.subpanelUtils.currentSubpanelGroup = '{$startSubPanel}';
SUGAR.subpanelUtils.subpanelMoreTab = '{$moreTab}';
SUGAR.subpanelUtils.subpanelMaxSubtabs = '{$maxSubtabs}';
SUGAR.subpanelUtils.subpanelHtml = new Array();
SUGAR.subpanelUtils.loadedGroups = Array();
SUGAR.subpanelUtils.loadedGroups.push('{$startSubPanel}');
SUGAR.subpanelUtils.subpanelSubTabs = new Array();
SUGAR.subpanelUtils.subpanelGroups = new Array();
{foreach from=$othertabs item=tab}
{assign var='notFirst' value='0'}
SUGAR.subpanelUtils.subpanelGroups['{$tab.key}'] = [{foreach from=$tab.tabs item=subtab}{if $notFirst != 0}, {else}{assign var='notFirst' value='1'}{/if}'{$subtab.key}'{/foreach}{foreach from=$otherMoreSubMenu[$tab.key].tabs item=subtab}, '{$subtab.key}'{/foreach}];
{/foreach}
{assign var='notFirst' value='0'}
SUGAR.subpanelUtils.subpanelTitles = {ldelim}{foreach from=$othertabs.All.tabs item=subtab}{if $notFirst != 0}, {else}{assign var='notFirst' value='1'}{/if}'{$subtab.key}':'{$subtab.label}'{/foreach}{foreach from=$otherMoreSubMenu.All.tabs item=subtab}, '{$subtab.key}':'{$subtab.label}'{/foreach}{rdelim};
SUGAR.subpanelUtils.tabCookieName = get_module_name() + '_sp_tab';
SUGAR.subpanelUtils.showLinks = {$showLinks};
SUGAR.subpanelUtils.requestUrl = 'index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$smarty.request.module}&record={$smarty.request.record}&subpanels=';
</script>
{if !empty($sugartabs)}
<ul id="groupTabs" class="subpanelTablist">
{foreach from=$sugartabs item=tab}
<li id="{$tab.label}_sp_tab">
<a class="{$tab.type}" href="javascript:SUGAR.subpanelUtils.loadSubpanelGroup('{$tab.label}');">{$tab.label}</a>
</li>
{/foreach}
{if !empty($moreMenu)}
<li>
<div id='MorePanelHandle' onmouseover='SUGAR.subpanelUtils.menu.tbspButtonMouseOver(this.id,"","",0);'>
<img src="{sugar_getimagepath file='blank.gif'}" alt="more" border="0" height="16" width="16" />
</div>
</li>
{/if}
</ul>
{* Table closed in SubPanelTiles.php, line 295 *}
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="subpanelTabForm">
<tr>
<td>
{/if}
{if $showLinks == 'true'}
<table cellpadding="0" cellspacing="0" width='100%'>
<tr height="20">
<td class="subpanelSubTabBar" colspan="100" id="subpanelSubTabs">
<table border="0" cellpadding="0" cellspacing="0" height="20" width="100%" class="subTabs">
<tbody>
<tr>
{foreach from=$subtabs item=tab}
{if !empty($notFirst) && ($notFirst != 0) && ($notFirst != 1)}
<td width='1'> | </td>
{else}
{assign var='notFirst' value='2'}
{/if}
<td nowrap="nowrap">
<a href='#{$tab.key}' class='subTabLink'>{$tab.label}</a>
</td>
{/foreach}
{if !empty($otherMoreSubMenu[$moreSubMenuName].tabs)}
<td nowrap="nowrap"> | &nbsp;<span class="subTabMore" id="MoreSub{$moreSubMenuName}PanelHandle" style="margin-left:2px; cursor: pointer; cursor: hand;" align="absmiddle" onmouseover="SUGAR.subpanelUtils.menu.tbspButtonMouseOver(this.id,'','',0);">&gt;&gt;</span></td>
{/if}
<td width='100%'>&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
{/if}
{if !empty($moreMenu)}
<div id="MorePanelMenu" class="menu">
{foreach from=$moreMenu item=tab}
<a href="javascript:SUGAR.subpanelUtils.loadSubpanelGroupFromMore('{$tab.label}');" class="menuItem" id="{$tab.label}_sp_mm" parentid="MorePanelMenu" onmouseover="hiliteItem(this,'yes'); closeSubMenus(this);" onmouseout="unhiliteItem(this);">{$tab.label}</a>
{/foreach}
</div>
{/if}
{foreach from=$otherMoreSubMenu item=group}
{if !empty($group.tabs)}
<div id="MoreSub{$group.key}PanelMenu" class="menu">
{foreach from=$group.tabs item=subtab}
<a href="#{$subtab.key}" class="menuItem" parentid="MoreSub{$group.key}PanelMenu" onmouseover="hiliteItem(this,'yes'); closeSubMenus(this);" onmouseout="unhiliteItem(this);">{$subtab.label}</a>
{/foreach}
</div>
{/if}
{/foreach}