Add php files
This commit is contained in:
37
modules/ModuleBuilder/Forms.php
Executable file
37
modules/ModuleBuilder/Forms.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
?>
|
||||
102
modules/ModuleBuilder/MB/AjaxCompose.php
Executable file
102
modules/ModuleBuilder/MB/AjaxCompose.php
Executable file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
class AjaxCompose{
|
||||
var $sections = array();
|
||||
var $crumbs = array('Home'=>'ModuleBuilder.main("Home")',/* 'Assistant'=>'Assistant.mbAssistant.xy=Array("650, 40"); Assistant.mbAssistant.show();'*/);
|
||||
function addSection($name, $title, $content, $action='activate'){
|
||||
$crumb = '';
|
||||
if($name == 'center'){
|
||||
$crumb = $this->getBreadCrumb();
|
||||
}
|
||||
$this->sections[$name] = array('title'=>$title,'crumb'=>$crumb, 'content'=>$content, 'action'=>$action);
|
||||
}
|
||||
|
||||
function getJavascript(){
|
||||
if(!empty($this->sections['center'])){
|
||||
if(empty($this->sections['east']))$this->addSection('east', '', '', 'deactivate');
|
||||
if(empty($this->sections['east2']))$this->addSection('east2', '', '', 'deactivate');
|
||||
}
|
||||
|
||||
$json = getJSONobj();
|
||||
return $json->encode($this->sections);
|
||||
}
|
||||
|
||||
function addCrumb($name, $action){
|
||||
$this->crumbs[$name] = $action;
|
||||
}
|
||||
|
||||
function getBreadCrumb(){
|
||||
$crumbs = '';
|
||||
$actions = array();
|
||||
$count = 0;
|
||||
foreach($this->crumbs as $name=>$action){
|
||||
if($name == 'Home'){
|
||||
$crumbs .= "<a onclick='$action' href='javascript:void(0)'>". getStudioIcon('home', 'home', 16, 16) . '</a>';
|
||||
}else if($name=='Assistant'){
|
||||
$crumbs .= "<a id='showassist' onclick='$action' href='javascript:void(0)'>". getStudioIcon('assistant', 'assistant', 16, 16) . '</a>';
|
||||
}else{
|
||||
if($count > 0){
|
||||
$crumbs .= ' > ';
|
||||
}else{
|
||||
$crumbs .= ' | ';
|
||||
}
|
||||
if(empty($action)){
|
||||
$crumbs .="<span class='crumbLink'>$name</span>";
|
||||
$actions[] = "";
|
||||
}else {
|
||||
$crumbs .="<a href='javascript:void(0);' onclick='$action' class='crumbLink'>$name</a>";
|
||||
$actions[] = $action;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
}
|
||||
if($count > 1 && $actions[$count-2] != ""){
|
||||
$crumbs = "<a onclick='{$actions[$count-2]}' href='javascript:void(0)'>". getStudioIcon('back', 'back', 16, 16) . '</a> '. $crumbs;
|
||||
}
|
||||
return $crumbs . '<br><br>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
function echoErrorStatus($labelName=''){
|
||||
$sections = array('failure'=>true,'failMsg'=>$labelName);
|
||||
$json = getJSONobj();
|
||||
echo $json->encode($sections);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
100
modules/ModuleBuilder/MB/MBField.php
Executable file
100
modules/ModuleBuilder/MB/MBField.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
class MBField{
|
||||
var $type = 'varchar';
|
||||
var $name = false;
|
||||
var $label = false;
|
||||
var $vname = false;
|
||||
var $options = false;
|
||||
var $length = false;
|
||||
var $error = '';
|
||||
var $required = false;
|
||||
var $reportable = true;
|
||||
var $default = 'MSI1';
|
||||
var $comment = '';
|
||||
|
||||
|
||||
|
||||
function getFieldVardef(){
|
||||
if(empty($this->name)){
|
||||
$this->error = 'A name is required to create a field';
|
||||
return false;
|
||||
}
|
||||
if(empty($this->label))$this->label = $this->name;
|
||||
$this->name = strtolower($this->getDBName($this->name));
|
||||
$vardef = array();
|
||||
$vardef['name']=$this->name;
|
||||
if(empty($this->vname))$this->vname = 'LBL_' . strtoupper($this->name);
|
||||
$vardef['vname'] = $this->addLabel();
|
||||
if(!empty($this->required))$vardef['required'] = $this->required;
|
||||
if(empty($this->reportable))$vardef['reportable'] = false;
|
||||
if(!empty($this->comment))$vardef['comment'] = $this->comment;
|
||||
if($this->default !== 'MSI1')$vardef['default'] = $this->default;
|
||||
switch($this->type){
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
case 'float':
|
||||
case 'int':
|
||||
$vardef['type']=$this->type;
|
||||
return $vardef;
|
||||
case 'bool':
|
||||
$vardef['type'] = 'bool';
|
||||
$vardef['default'] = (empty($vardef['default']))?0:1;
|
||||
return $vardef;
|
||||
case 'enum':
|
||||
$vardef['type']='enum';
|
||||
if(empty($this->options)){
|
||||
$this->options = $this->name . '_list';
|
||||
}
|
||||
$vardef['options'] = $this->addDropdown();
|
||||
return $vardef;
|
||||
default:
|
||||
$vardef['type']='varchar';
|
||||
return $vardef;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function addDropDown(){
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
function addLabel(){
|
||||
return $this->vname;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
252
modules/ModuleBuilder/MB/MBLanguage.php
Executable file
252
modules/ModuleBuilder/MB/MBLanguage.php
Executable file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
class MBLanguage{
|
||||
var $iTemplates = array();
|
||||
var $templates = array();
|
||||
function MBLanguage( $name, $path, $label, $key_name){
|
||||
$this->path = $path;
|
||||
$this->name = $name;
|
||||
$this->key_name = $key_name;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
function load(){
|
||||
$this->generateModStrings();
|
||||
$this->generateAppStrings();
|
||||
}
|
||||
|
||||
function loadStrings($file){
|
||||
$module = strtoupper($this->name);
|
||||
$object_name = strtoupper($this->key_name);
|
||||
$_object_name = strtolower($this->name);
|
||||
if(!file_exists($file))return;
|
||||
|
||||
$d = dir($file);
|
||||
while($e = $d->read()){
|
||||
if(substr($e, 0, 1) != '.' && is_file($file . '/' . $e)){
|
||||
include($file.'/'. $e);
|
||||
if(empty($this->strings[$e])){
|
||||
|
||||
$this->strings[$e] = $mod_strings;
|
||||
}else{
|
||||
$this->strings[$e] = array_merge($this->strings[$e], $mod_strings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadAppListStrings($file){
|
||||
|
||||
if(!file_exists($file))return;
|
||||
//we may not need this when loading in the app strings, but there is no harm
|
||||
//in setting it.
|
||||
$object_name = strtolower($this->key_name);
|
||||
|
||||
$d = dir($file);
|
||||
while($e = $d->read()){
|
||||
if(substr($e, 0, 1) != '.' && is_file($file . '/' . $e)){
|
||||
include($file.'/'. $e);
|
||||
if(empty($this->appListStrings[$e])){
|
||||
|
||||
$this->appListStrings[$e] = $app_list_strings;
|
||||
}else{
|
||||
$this->appListStrings[$e] = array_merge($this->appListStrings[$e], $app_list_strings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateModStrings(){
|
||||
$this->strings = array();
|
||||
$this->loadTemplates();
|
||||
|
||||
foreach($this->iTemplates as $template=>$val){
|
||||
$file = MB_IMPLEMENTS . '/' . $template . '/language';
|
||||
$this->loadStrings($file);
|
||||
}
|
||||
foreach($this->templates as $template=>$val){
|
||||
$file = MB_TEMPLATES . '/' . $template . '/language';
|
||||
$this->loadStrings($file);
|
||||
}
|
||||
$this->loadStrings($this->path . '/language');
|
||||
}
|
||||
|
||||
function getModStrings($language='en_us'){
|
||||
$language .= '.lang.php';
|
||||
if(!empty($this->strings[$language]) && $language != 'en_us.lang.php'){
|
||||
return sugarArrayMerge($this->strings['en_us.lang.php'], $this->strings[$language]);
|
||||
}
|
||||
if(!empty($this->strings['en_us.lang.php']))return $this->strings['en_us.lang.php'];
|
||||
$empty = array();
|
||||
return $empty;
|
||||
}
|
||||
function getAppListStrings($language='en_us'){
|
||||
$language .= '.lang.php';
|
||||
if(!empty($this->appListStrings[$language]) && $language != 'en_us.lang.php'){
|
||||
return sugarArrayMerge($this->appListStrings['en_us.lang.php'], $this->appListStrings[$language]);
|
||||
}
|
||||
if(!empty($this->appListStrings['en_us.lang.php']))return $this->appListStrings['en_us.lang.php'];
|
||||
$empty = array();
|
||||
return $empty;
|
||||
}
|
||||
|
||||
function generateAppStrings($buildFromTemplate = true){
|
||||
$this->appListStrings = array('en_us.lang.php'=>array());
|
||||
//By default, generate app strings for the current language as well.
|
||||
$this->appListStrings[$GLOBALS [ 'current_language' ] . ".lang.php"] = array();
|
||||
$this->loadAppListStrings($this->path . '/../../language/application');
|
||||
|
||||
if($buildFromTemplate){
|
||||
//go through the templates application strings and load anything that is needed
|
||||
foreach($this->iTemplates as $template=>$val){
|
||||
$file = MB_IMPLEMENTS . '/' . $template . '/language/application';
|
||||
$this->loadAppListStrings($file);
|
||||
}
|
||||
foreach($this->templates as $template=>$val){
|
||||
$file = MB_TEMPLATES . '/' . $template . '/language/application';
|
||||
$this->loadAppListStrings($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
function save($key_name, $duplicate=false, $rename=false){
|
||||
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
|
||||
$save_path = $this->path . '/language';
|
||||
mkdir_recursive($save_path);
|
||||
foreach($this->strings as $lang=>$values){
|
||||
//Check if the module Label has changed.
|
||||
$renameLang = $rename || empty($values) || $this->label != $values['LBL_MODULE_NAME'];
|
||||
$mod_strings = return_module_language(str_replace('.lang.php','',$lang), 'ModuleBuilder');
|
||||
$required = array(
|
||||
'LBL_LIST_FORM_TITLE'=>$this->label . " " . $mod_strings['LBL_LIST'],
|
||||
'LBL_MODULE_NAME'=>$this->label,
|
||||
'LBL_MODULE_TITLE'=>$this->label,
|
||||
'LBL_HOMEPAGE_TITLE'=>$mod_strings['LBL_HOMEPAGE_PREFIX'] . " " . $this->label,
|
||||
//FOR GENERIC MENU
|
||||
'LNK_NEW_RECORD'=>$mod_strings['LBL_CREATE'] ." ". $this->label,
|
||||
'LNK_LIST'=>$mod_strings['LBL_VIEW'] ." ". $this->label,
|
||||
'LNK_IMPORT_'.strtoupper($this->key_name)=>translate('LBL_IMPORT') ." ". $this->label,
|
||||
'LBL_SEARCH_FORM_TITLE'=>$mod_strings['LBL_SEARCH'] ." ". $this->label,
|
||||
'LBL_HISTORY_SUBPANEL_TITLE'=>$mod_strings['LBL_HISTORY'],
|
||||
'LBL_ACTIVITIES_SUBPANEL_TITLE'=>$mod_strings['LBL_ACTIVITIES'],
|
||||
'LBL_'.strtoupper($this->key_name).'_SUBPANEL_TITLE'=>$this->label,
|
||||
'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] ." ". $this->label,
|
||||
);
|
||||
foreach($required as $k=>$v){
|
||||
if(empty($values[$k]) || $renameLang){
|
||||
$values[$k] = $v;
|
||||
}
|
||||
}
|
||||
write_array_to_file('mod_strings', $values, $save_path .'/'.$lang,'w', $header);
|
||||
}
|
||||
$app_save_path = $this->path . '/../../language/application';
|
||||
mkdir_recursive($app_save_path);
|
||||
$key_changed = ($this->key_name != $key_name);
|
||||
|
||||
foreach($this->appListStrings as $lang=>$values){
|
||||
if(!$duplicate){
|
||||
unset($values['moduleList'][$this->key_name]);
|
||||
}
|
||||
$values['moduleList'][$key_name]= $this->label;
|
||||
$appFile = $header. "\n";
|
||||
require_once('include/utils/array_utils.php');
|
||||
$this->getGlobalAppListStringsForMB($values);
|
||||
foreach($values as $key=>$array){
|
||||
if($duplicate){
|
||||
//keep the original when duplicating
|
||||
$appFile .= override_value_to_string_recursive2 ('app_list_strings', $key, $array);
|
||||
}
|
||||
$okey = $key;
|
||||
if($key_changed)$key = str_replace($this->key_name, $key_name, $key);
|
||||
if($key_changed)$key = str_replace(strtolower($this->key_name), strtolower($key_name), $key);
|
||||
// if we aren't duplicating or the key has changed let's add it
|
||||
if(!$duplicate || $okey != $key){
|
||||
$appFile .= override_value_to_string_recursive2 ('app_list_strings', $key, $array);
|
||||
}
|
||||
}
|
||||
|
||||
$fp = sugar_fopen($app_save_path . '/'. $lang, 'w');
|
||||
fwrite($fp, $appFile);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is no this dropdown list in custom\modulebuilder\packages\$package\language\application\$lang.lang.php ,
|
||||
* we will include it from global app_list_string array into custom\modulebuilder\packages\$package\language\application\$lang.lang.php
|
||||
* when we create a dropdown filed and the value is created in MB.(#20728 )
|
||||
**/
|
||||
function getGlobalAppListStringsForMB(&$values){
|
||||
//Ensure it comes from MB
|
||||
if(!empty($_REQUEST['view_package']) && !empty($_REQUEST['type']) && $_REQUEST['type']='enum' && !empty($_REQUEST['options'])){
|
||||
if(!isset($values[$_REQUEST['options']])){
|
||||
global $app_list_strings;
|
||||
if(!empty($app_list_strings[$_REQUEST['options']])){
|
||||
$values[$_REQUEST['options']] = $app_list_strings[$_REQUEST['options']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function build($path){
|
||||
if(file_exists($this->path.'/language/'))
|
||||
copy_recursive($this->path.'/language/', $path . '/language/');
|
||||
}
|
||||
|
||||
function loadTemplates() {
|
||||
if(empty($this->templates)){
|
||||
if (file_exists("$this->path/config.php")) {
|
||||
include "$this->path/config.php";
|
||||
$this->templates = $config['templates'];
|
||||
$this->iTemplates = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the templates and load the language files again. This is called from
|
||||
* MBModule->save() once the config file has been written.
|
||||
*/
|
||||
function reload(){
|
||||
$this->templates = null;
|
||||
$this->load();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
800
modules/ModuleBuilder/MB/MBModule.php
Executable file
800
modules/ModuleBuilder/MB/MBModule.php
Executable file
@@ -0,0 +1,800 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
define ( 'MB_TEMPLATES', 'include/SugarObjects/templates' ) ;
|
||||
define ( 'MB_IMPLEMENTS', 'include/SugarObjects/implements' ) ;
|
||||
require_once ('modules/ModuleBuilder/MB/MBVardefs.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/MBRelationship.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/MBLanguage.php') ;
|
||||
|
||||
class MBModule
|
||||
{
|
||||
public $name = '' ;
|
||||
public $config = array (
|
||||
'assignable' => 1 , 'acl' => 1 , 'has_tab' => 1 , 'studio' => 1 , 'audit' => 1 ) ;
|
||||
public $mbpublicdefs ;
|
||||
public $errors = array ( ) ;
|
||||
public $path = '' ;
|
||||
public $implementable = array (
|
||||
'has_tab' => 'Navigation Tab' ) ;
|
||||
public $always_implement = array ( 'assignable' => 'Assignable' , 'acl' => 'Access Controls' , 'studio' => 'Studio Support' , 'audit' => 'Audit Table' ) ;
|
||||
public $iTemplate = array (
|
||||
'assignable' ) ;
|
||||
|
||||
public $config_md5 = null ;
|
||||
|
||||
function __construct ($name , $path , $package , $package_key)
|
||||
{
|
||||
global $mod_strings;
|
||||
$this->config [ 'templates' ] = array ( 'basic' => 1 ) ;
|
||||
|
||||
$this->name = MBModule::getDBName ( $name ) ;
|
||||
$this->key_name = $package_key . '_' . $name ;
|
||||
$this->package = $package ;
|
||||
$this->package_key = $package_key ;
|
||||
$this->package_path = $path ;
|
||||
|
||||
$this->implementable = array (
|
||||
'has_tab' => !empty($mod_strings[ 'LBL_NAV_TAB' ]) ? $mod_strings[ 'LBL_NAV_TAB' ] : false) ;
|
||||
$this->path = $this->getModuleDir () ;
|
||||
// $this->mbrelationship = new MBRelationship($this->name, $this->path, $this->key_name);
|
||||
$this->relationships = new UndeployedRelationships ( $this->path ) ;
|
||||
$this->mbvardefs = new MBVardefs ( $this->name, $this->path, $this->key_name ) ;
|
||||
|
||||
$this->load () ;
|
||||
}
|
||||
|
||||
function getDBName ($name)
|
||||
{
|
||||
return preg_replace ( "/[^\w]+/", "_", $name ) ;
|
||||
}
|
||||
|
||||
function getModuleName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function getPackageName()
|
||||
{
|
||||
return $this->package;
|
||||
}
|
||||
|
||||
function getRelationships()
|
||||
{
|
||||
return $this->relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the module based on the module name
|
||||
*
|
||||
*/
|
||||
function load ()
|
||||
{
|
||||
if (file_exists ( $this->path . '/config.php' ))
|
||||
{
|
||||
include ($this->path . '/config.php') ;
|
||||
$this->config = $config ;
|
||||
}
|
||||
$label = (! empty ( $this->config [ 'label' ] )) ? $this->config [ 'label' ] : $this->name ;
|
||||
$this->mblanguage = new MBLanguage ( $this->name, $this->path, $label, $this->key_name ) ;
|
||||
foreach ( $this->iTemplate as $temp )
|
||||
{
|
||||
if (! empty ( $this->config [ $temp ] ))
|
||||
{
|
||||
$this->mbvardefs->iTemplates [ $temp ] = 1 ;
|
||||
$this->mblanguage->iTemplates [ $temp ] = $temp ;
|
||||
}
|
||||
}
|
||||
$this->mbvardefs->templates = $this->config [ 'templates' ] ;
|
||||
$this->mblanguage->templates = $this->config [ 'templates' ] ;
|
||||
$this->mbvardefs->load () ;
|
||||
$this->mblanguage->load () ;
|
||||
|
||||
}
|
||||
|
||||
function addTemplate ($template)
|
||||
{
|
||||
$this->config [ 'templates' ] [ $template ] = 1 ;
|
||||
}
|
||||
|
||||
function getModuleDir ()
|
||||
{
|
||||
return $this->package_path . '/modules/' . $this->name ;
|
||||
}
|
||||
|
||||
function removeTemplate ($template)
|
||||
{
|
||||
unset ( $this->config [ 'templates' ] [ $template ] ) ;
|
||||
}
|
||||
|
||||
function getVardefs ($by_group = false)
|
||||
{
|
||||
$this->mbvardefs->updateVardefs ( $by_group ) ;
|
||||
return $this->mbvardefs->getVardefs () ;
|
||||
}
|
||||
|
||||
function addField ($vardef)
|
||||
{
|
||||
$this->mbvardefs->addFieldVardef ( $vardef ) ;
|
||||
}
|
||||
|
||||
function addFieldObject ($field)
|
||||
{
|
||||
$vardef = $field->get_field_def () ;
|
||||
$this->mbvardefs->mergeVardefs();
|
||||
$existingVardefs = $this->mbvardefs->getVardefs () ;
|
||||
//Merge with the existing vardef if it already exists
|
||||
if(!empty($existingVardefs['fields'][$vardef['name']])){
|
||||
$vardef = array_merge( $existingVardefs['fields'][$vardef['name']], $vardef);
|
||||
}
|
||||
if (! empty ( $vardef [ 'source' ] ) && $vardef [ 'source' ] == 'custom_fields')
|
||||
unset ( $vardef [ 'source' ] ) ;
|
||||
|
||||
$this->mbvardefs->load();
|
||||
$this->addField ( $vardef ) ;
|
||||
$this->mbvardefs->save();
|
||||
}
|
||||
|
||||
function deleteField ($name)
|
||||
{
|
||||
$this->mbvardefs->deleteField ( $name ) ;
|
||||
}
|
||||
|
||||
function fieldExists ($name = '' , $type = '')
|
||||
{
|
||||
$vardefs = $this->mbvardefs->getVardef () ;
|
||||
if (! empty ( $vardefs ))
|
||||
{
|
||||
if (empty ( $type ) && empty ( $name ))
|
||||
return false ; else if (empty ( $type ))
|
||||
return ! empty ( $vardefs [ 'fields' ] [ $name ] ) ; else if (empty ( $name ))
|
||||
{
|
||||
foreach ( $vardefs [ 'fields' ] as $def )
|
||||
{
|
||||
if ($def [ 'type' ] == $type)
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
} else
|
||||
return (! empty ( $vardefs [ 'fields' ] [ $name ] ) && ($vardefs [ 'fields' ] [ $name ] [ 'type' ] == $type)) ;
|
||||
} else
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
function getModStrings ($language = 'en_us')
|
||||
{
|
||||
return $this->mblanguage->getModStrings ( $language ) ;
|
||||
}
|
||||
|
||||
function setModStrings ($language = 'en_us' , $mod_strings)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
$this->mblanguage->strings [ $language ] = $mod_strings ;
|
||||
}
|
||||
|
||||
function setLabel ($language = 'en_us' , $key , $value)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
$this->mblanguage->strings [ $language ] [ $key ] = $value ;
|
||||
//Ensure this key exists in all languages
|
||||
foreach ($this->mblanguage->strings as $lang => $values) {
|
||||
if (empty($values[$key])) {
|
||||
$this->mblanguage->strings[$lang][$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteLabel ($language = 'en_us' , $key)
|
||||
{
|
||||
foreach ($this->mblanguage->strings as $lang => $values) {
|
||||
if (!empty($values[$key])) {
|
||||
unset($this->mblanguage->strings[$lang][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Required for an MB module to work with Dynamic fields
|
||||
*/
|
||||
function addLabel ( $displayLabel)
|
||||
{
|
||||
$this->setLabel('en_us', $this->getDBName($displayLabel, false), translate($displayLabel));
|
||||
$this->save();
|
||||
}
|
||||
|
||||
function getLabel ($language = 'en_us' , $key)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
if (empty ( $this->mblanguage->strings [ $language ] [ $key ] ))
|
||||
{
|
||||
|
||||
return '' ;
|
||||
}
|
||||
return $this->mblanguage->strings [ $language ] [ $key ] ;
|
||||
|
||||
}
|
||||
|
||||
function getAppListStrings ($language = 'en_us')
|
||||
{
|
||||
return $this->mblanguage->getAppListStrings ( $language ) ;
|
||||
}
|
||||
|
||||
function setAppListStrings ($language = 'en_us' , $app_list_strings)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
$this->mblanguage->appListStrings [ $language ] = $app_list_strings ;
|
||||
}
|
||||
|
||||
function setDropDown ($language = 'en_us' , $key , $value)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
$this->mblanguage->appListStrings [ $language ] [ $key ] = $value ;
|
||||
}
|
||||
|
||||
function deleteDropDown ($language = 'en_us' , $key)
|
||||
{
|
||||
$language .= '.lang.php' ;
|
||||
unset ( $this->mblanguage->appListStrings [ $language ] [ $key ] ) ;
|
||||
}
|
||||
|
||||
function save ()
|
||||
{
|
||||
$this->path = $this->getModuleDir () ;
|
||||
if (mkdir_recursive ( $this->path ))
|
||||
{
|
||||
|
||||
$this->setConfigMD5 () ;
|
||||
$old_config_md5 = $this->config_md5 ;
|
||||
$this->saveConfig () ;
|
||||
$this->getVardefs () ;
|
||||
$this->mbvardefs->save ( $this->key_name ) ;
|
||||
// $this->mbrelationship->save ( $this->key_name ) ;
|
||||
$this->relationships->save () ;
|
||||
$this->copyMetaData () ;
|
||||
$this->copyDashlet () ;
|
||||
$this->copyViews() ;
|
||||
if (0 != strcmp ( $old_config_md5, $this->config_md5 ))
|
||||
{
|
||||
$this->mblanguage->reload () ;
|
||||
}
|
||||
$this->mblanguage->label = $this->config [ 'label' ] ;
|
||||
//pass in the key_name incase it has changed mblanguage will check if it is different and handle it accordingly
|
||||
$this->mblanguage->save ( $this->key_name ) ;
|
||||
|
||||
if (! file_exists ( $this->package_path . "/icons/icon_" . ucfirst ( $this->key_name ) . ".gif" ))
|
||||
{
|
||||
$this->createIcon () ;
|
||||
}
|
||||
$this->errors = array_merge ( $this->errors, $this->mbvardefs->errors ) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function copyDashlet() {
|
||||
$templates = array_reverse ( $this->config [ 'templates' ], true ) ;
|
||||
foreach ( $templates as $template => $a )
|
||||
{
|
||||
if (file_exists ( MB_TEMPLATES . '/' . $template . '/Dashlets/Dashlet' ))
|
||||
{
|
||||
|
||||
$this->copyMetaRecursive ( MB_TEMPLATES . '/' . $template . '/Dashlets/Dashlet', $this->path . '/Dashlets/' . $this->key_name . 'Dashlet/' ) ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyViews() {
|
||||
$templates = array_reverse ( $this->config [ 'templates' ], true ) ;
|
||||
foreach ( $templates as $template => $a )
|
||||
{
|
||||
if (file_exists ( MB_TEMPLATES . '/' . $template . '/views' ))
|
||||
{
|
||||
$this->copyMetaRecursive ( MB_TEMPLATES . '/' . $template . '/views', $this->path . '/views/' ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyCustomFiles ( $from , $to )
|
||||
{
|
||||
$d = dir ( $from ) ;
|
||||
while ( $filename = $d->read () )
|
||||
{
|
||||
if (substr ( $filename, 0, 1 ) == '.')
|
||||
continue ;
|
||||
if ( $filename != 'metadata' && $filename != 'Dashlets' && $filename != 'relationships' && $filename != 'language' && $filename != 'config.php' && $filename != 'relationships.php' && $filename != 'vardefs.php' )
|
||||
copy_recursive ( "$from/$filename" , "$to/$filename" ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function copyMetaData ()
|
||||
{
|
||||
$templates = array_reverse ( $this->config [ 'templates' ], true ) ;
|
||||
foreach ( $templates as $template => $a )
|
||||
{
|
||||
if (file_exists ( MB_TEMPLATES . '/' . $template . '/metadata' ))
|
||||
{
|
||||
$this->copyMetaRecursive ( MB_TEMPLATES . '/' . $template . '/metadata', $this->path . '/metadata/' ) ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyMetaRecursive ($from , $to , $overwrite = false)
|
||||
{
|
||||
if (! file_exists ( $from ))
|
||||
return ;
|
||||
if (is_dir ( $from ))
|
||||
{
|
||||
$findArray = array ( '<module_name>' , '<_module_name>' , '<MODULE_NAME>' , '<object_name>' , '<_object_name>' , '<OBJECT_NAME>' );
|
||||
$replaceArray = array ( $this->key_name , strtolower ( $this->key_name ) , strtoupper ( $this->key_name ) ,
|
||||
$this->key_name , strtolower ( $this->key_name ) , strtoupper ( $this->key_name ) );
|
||||
mkdir_recursive ( $to ) ;
|
||||
$d = dir ( $from ) ;
|
||||
while ( $e = $d->read () )
|
||||
{
|
||||
if (substr ( $e, 0, 1 ) == '.')
|
||||
continue ;
|
||||
$nfrom = $from . '/' . $e ;
|
||||
$nto = $to . '/' . str_replace ( 'm-n-', $this->key_name, $e ) ;
|
||||
if (is_dir ( $nfrom ))
|
||||
{
|
||||
$this->copyMetaRecursive ( $nfrom, $nto, $overwrite ) ;
|
||||
} else
|
||||
{
|
||||
if ($overwrite || ! file_exists ( $nto ))
|
||||
{
|
||||
$contents = file_get_contents ( $nfrom ) ;
|
||||
$contents = str_replace ( $findArray, $replaceArray, $contents ) ;
|
||||
$fw = sugar_fopen ( $nto, 'w' ) ;
|
||||
fwrite ( $fw, $contents ) ;
|
||||
fclose ( $fw ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function saveConfig ()
|
||||
{
|
||||
$header = file_get_contents ( 'modules/ModuleBuilder/MB/header.php' ) ;
|
||||
if (! write_array_to_file ( 'config', $this->config, $this->path . '/config.php', 'w', $header ))
|
||||
{
|
||||
$this->errors [] = 'Could not save config to ' . $this->path . '/config.php' ;
|
||||
}
|
||||
$this->setConfigMD5 () ;
|
||||
}
|
||||
|
||||
function setConfigMD5 ()
|
||||
{
|
||||
if (file_exists ( $this->path . '/config.php' ))
|
||||
$this->config_md5 = md5 ( base64_encode ( serialize ( $this->config ) ) ) ;
|
||||
}
|
||||
|
||||
function build ($basepath)
|
||||
{
|
||||
$path = $basepath . '/modules/' . $this->key_name ;
|
||||
if (mkdir_recursive ( $path ))
|
||||
{
|
||||
$this->createClasses ( $path ) ;
|
||||
if( $this->config['importable'] || in_array ( 'person', array_keys($this->config[ 'templates' ]) ) )
|
||||
$this->createMenu ( $path ) ;
|
||||
$this->copyCustomFiles ( $this->path , $path ) ;
|
||||
$this->copyMetaRecursive ( $this->path . '/metadata/', $path . '/metadata/', true ) ;
|
||||
$this->copyMetaRecursive ( $this->path . '/Dashlets/' . $this->key_name . 'Dashlet/',
|
||||
$path . '/Dashlets/' . $this->key_name . 'Dashlet/', true ) ;
|
||||
$this->relationships->build ( $basepath ) ;
|
||||
$this->mblanguage->build ( $path ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function createClasses ($path)
|
||||
{
|
||||
$class = array ( ) ;
|
||||
$class [ 'name' ] = $this->key_name ;
|
||||
$class [ 'table_name' ] = strtolower ( $class [ 'name' ] ) ;
|
||||
$class [ 'extends' ] = 'Basic' ;
|
||||
$class [ 'requires' ] [] = MB_TEMPLATES . '/basic/Basic.php' ;
|
||||
$class [ 'requires' ] = array ( ) ;
|
||||
$class [ 'audited' ] = (! empty ( $this->config [ 'audit' ] )) ? 'true' : 'false' ;
|
||||
$class [ 'acl' ] = ! empty ( $this->config [ 'acl' ] ) ;
|
||||
$class [ 'templates' ] = "'basic'" ;
|
||||
foreach ( $this->iTemplate as $template )
|
||||
{
|
||||
if (! empty ( $this->config [ $template ] ))
|
||||
{
|
||||
$class [ 'templates' ] .= ",'$template'" ;
|
||||
}
|
||||
}
|
||||
foreach ( $this->config [ 'templates' ] as $template => $a )
|
||||
{
|
||||
if ($template == 'basic')
|
||||
continue ;
|
||||
$class [ 'templates' ] .= ",'$template'" ;
|
||||
$class [ 'extends' ] = ucFirst ( $template ) ;
|
||||
$class [ 'requires' ] [] = MB_TEMPLATES . '/' . $template . '/' . ucfirst ( $template ) . '.php' ;
|
||||
}
|
||||
$class [ 'importable' ] = $this->config [ 'importable' ] ;
|
||||
$this->mbvardefs->updateVardefs () ;
|
||||
$class [ 'fields' ] = $this->mbvardefs->vardefs [ 'fields' ] ;
|
||||
$class [ 'fields_string' ] = var_export_helper ( $this->mbvardefs->vardef [ 'fields' ] ) ;
|
||||
$relationship = array ( ) ;
|
||||
$class [ 'relationships' ] = var_export_helper ( $this->mbvardefs->vardef [ 'relationships' ] ) ;
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->left_delimiter = '{{' ;
|
||||
$smarty->right_delimiter = '}}' ;
|
||||
$smarty->assign ( 'class', $class ) ;
|
||||
//write sugar generated class
|
||||
$fp = sugar_fopen ( $path . '/' . $class [ 'name' ] . '_sugar.php', 'w' ) ;
|
||||
fwrite ( $fp, $smarty->fetch ( 'modules/ModuleBuilder/tpls/MBModule/Class.tpl' ) ) ;
|
||||
fclose ( $fp ) ;
|
||||
//write vardefs
|
||||
$fp = sugar_fopen ( $path . '/vardefs.php', 'w' ) ;
|
||||
fwrite ( $fp, $smarty->fetch ( 'modules/ModuleBuilder/tpls/MBModule/vardef.tpl' ) ) ;
|
||||
fclose ( $fp ) ;
|
||||
|
||||
if (! file_exists ( $path . '/' . $class [ 'name' ] . '.php' ))
|
||||
{
|
||||
$fp = sugar_fopen ( $path . '/' . $class [ 'name' ] . '.php', 'w' ) ;
|
||||
fwrite ( $fp, $smarty->fetch ( 'modules/ModuleBuilder/tpls/MBModule/DeveloperClass.tpl' ) ) ;
|
||||
fclose ( $fp ) ;
|
||||
}
|
||||
if (! file_exists ( $path . '/metadata' ))
|
||||
mkdir_recursive ( $path . '/metadata' ) ;
|
||||
if (! empty ( $this->config [ 'studio' ] ))
|
||||
{
|
||||
$fp = sugar_fopen ( $path . '/metadata/studio.php', 'w' ) ;
|
||||
fwrite ( $fp, $smarty->fetch ( 'modules/ModuleBuilder/tpls/MBModule/Studio.tpl' ) ) ;
|
||||
fclose ( $fp ) ;
|
||||
} else
|
||||
{
|
||||
if (file_exists ( $path . '/metadata/studio.php' ))
|
||||
unlink ( $path . '/metadata/studio.php' ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function createMenu ($path)
|
||||
{
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->assign ( 'moduleName', $this->key_name ) ;
|
||||
$smarty->assign ( 'showvCard', in_array ( 'person', array_keys($this->config[ 'templates' ]) ) ) ;
|
||||
$smarty->assign ( 'showimport', $this->config['importable'] );
|
||||
//write sugar generated class
|
||||
$fp = sugar_fopen ( $path . '/' . 'Menu.php', 'w' ) ;
|
||||
fwrite ( $fp, $smarty->fetch ( 'modules/ModuleBuilder/tpls/MBModule/Menu.tpl' ) ) ;
|
||||
fclose ( $fp ) ;
|
||||
}
|
||||
|
||||
function addInstallDefs (&$installDefs)
|
||||
{
|
||||
$name = $this->key_name ;
|
||||
$installDefs [ 'copy' ] [] = array ( 'from' => '<basepath>/SugarModules/modules/' . $name , 'to' => 'modules/' . $name ) ;
|
||||
$installDefs [ 'beans' ] [] = array ( 'module' => $name , 'class' => $name , 'path' => 'modules/' . $name . '/' . $name . '.php' , 'tab' => $this->config [ 'has_tab' ] ) ;
|
||||
$this->relationships->addInstallDefs ( $installDefs ) ;
|
||||
}
|
||||
|
||||
function getNodes ()
|
||||
{
|
||||
|
||||
$lSubs = array ( ) ;
|
||||
$psubs = $this->getProvidedSubpanels () ;
|
||||
foreach ( $psubs as $sub )
|
||||
{
|
||||
$subLabel = $sub ;
|
||||
if ($subLabel == 'default')
|
||||
{
|
||||
$subLabel = $GLOBALS [ 'mod_strings' ] [ 'LBL_DEFAULT' ] ;
|
||||
}
|
||||
$lSubs [] = array ( 'name' => $subLabel , 'type' => 'list' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view=ListView&view_module=' . $this->name . '&view_package=' . $this->package . '&subpanel=' . $sub . '&subpanelLabel=' . $subLabel . '&local=1' ) ;
|
||||
}
|
||||
|
||||
$searchSubs = array ( ) ;
|
||||
$searchSubs [] = array ( 'name' => translate('LBL_BASIC_SEARCH') , 'type' => 'list' , 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=basic_search&view_module={$this->name}&view_package={$this->package}" ) ;
|
||||
$searchSubs [] = array ( 'name' => translate('LBL_ADVANCED_SEARCH') , 'type' => 'list' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view=advanced_search&view_module=' . $this->name . '&view_package=' . $this->package ) ;
|
||||
$dashlets = array( );
|
||||
$dashlets [] = array('name' => translate('LBL_DASHLETLISTVIEW') , 'type' => 'dashlet' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view=dashlet&view_module=' . $this->name . '&view_package=' . $this->package );
|
||||
$dashlets [] = array('name' => translate('LBL_DASHLETSEARCHVIEW') , 'type' => 'dashletsearch' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view=dashletsearch&view_module=' . $this->name . '&view_package=' . $this->package );
|
||||
|
||||
$popups = array( );
|
||||
$popups [] = array('name' => translate('LBL_POPUPLISTVIEW') , 'type' => 'popuplistview' , 'action' => 'module=ModuleBuilder&action=editLayout&view=popuplist&view_module=' . $this->name . '&view_package=' . $this->package );
|
||||
$popups [] = array('name' => translate('LBL_POPUPSEARCH') , 'type' => 'popupsearch' , 'action' => 'module=ModuleBuilder&action=editLayout&view=popupsearch&view_module=' . $this->name . '&view_package=' . $this->package );
|
||||
|
||||
$layouts = array (
|
||||
array ( 'name' => translate('LBL_EDITVIEW') , 'type' => 'edit' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view='.MB_EDITVIEW.'&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_DETAILVIEW') , 'type' => 'detail' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view='.MB_DETAILVIEW.'&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_LISTVIEW') , 'type' => 'list' , 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view='.MB_LISTVIEW.'&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_QUICKCREATE') , 'type' => MB_QUICKCREATE, 'action' => 'module=ModuleBuilder&MB=true&action=editLayout&view='.MB_QUICKCREATE.'&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_DASHLET') , 'type' => 'Folder', 'children' => $dashlets, 'action' => 'module=ModuleBuilder&MB=true&action=wizard&view=dashlet&view_module=' . $this->name . '&view_package=' . $this->package ),
|
||||
array ( 'name' => translate('LBL_POPUP') , 'type' => 'Folder', 'children' => $popups, 'action' => 'module=ModuleBuilder&MB=true&action=wizard&view=popup&view_module=' . $this->name . '&view_package=' . $this->package ),
|
||||
array ( 'name' => translate('LBL_SEARCH_FORMS') , 'action' => 'module=ModuleBuilder&MB=true&action=wizard&view=search&view_module=' . $this->name . '&view_package=' . $this->package , 'type' => 'folder' , 'children' => $searchSubs )
|
||||
) ;
|
||||
|
||||
$children = array (
|
||||
array ( 'name' => translate('LBL_FIELDS') , 'action' => 'module=ModuleBuilder&action=modulefields&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_LABELS') , 'action' => 'module=ModuleBuilder&action=modulelabels&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_RELATIONSHIPS') , 'action' => 'module=ModuleBuilder&action=relationships&view_module=' . $this->name . '&view_package=' . $this->package ) ,
|
||||
array ( 'name' => translate('LBL_LAYOUTS') , 'type' => 'Folder' , 'action' => "module=ModuleBuilder&action=wizard&view_module={$this->name}&view_package={$this->package}&MB=1" , 'children' => $layouts ) ,
|
||||
) ;
|
||||
|
||||
if (count ( $lSubs ) > 0)
|
||||
{
|
||||
$children [] = array ( 'name' => translate('LBL_AVAILABLE_SUBPANELS') , 'type' => 'folder' , 'children' => $lSubs ) ;
|
||||
}
|
||||
|
||||
$nodes = array ( 'name' => $this->name , 'children' => $children , 'action' => 'module=ModuleBuilder&action=module&view_module=' . $this->name . '&view_package=' . $this->package ) ;
|
||||
|
||||
return $nodes ;
|
||||
}
|
||||
|
||||
|
||||
function getProvidedSubpanels ()
|
||||
{
|
||||
$this->providedSubpanels = array () ;
|
||||
|
||||
$subpanelDir = $this->getModuleDir () . '/metadata/subpanels/' ;
|
||||
if (file_exists ( $subpanelDir ))
|
||||
{
|
||||
$f = dir ( $subpanelDir ) ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
|
||||
while ( $g = $f->read () )
|
||||
{
|
||||
// sanity check to confirm that this is a usable subpanel...
|
||||
if (substr ( $g, 0, 1 ) != '.' && AbstractRelationships::validSubpanel ( $subpanelDir . $g ))
|
||||
{
|
||||
$subname = str_replace ( '.php', '', $g ) ;
|
||||
$this->providedSubpanels [ $subname ] = $subname ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->providedSubpanels;
|
||||
}
|
||||
|
||||
function getTypes ()
|
||||
{
|
||||
$types = array ( ) ;
|
||||
$d = dir ( MB_TEMPLATES ) ;
|
||||
while ( $e = $d->read () )
|
||||
{
|
||||
if (substr ( $e, 0, 1 ) != '.')
|
||||
{
|
||||
$types [ $e ] = $e ;
|
||||
}
|
||||
}
|
||||
|
||||
return $types ;
|
||||
}
|
||||
|
||||
function rename ($new_name)
|
||||
{
|
||||
$old = $this->getModuleDir () ;
|
||||
$old_name = $this->key_name;
|
||||
$this->name = $new_name ;
|
||||
$this->key_name = $this->package_key . '_' . $this->name ;
|
||||
$new = $this->getModuleDir () ;
|
||||
if (file_exists ( $new ))
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
$renamed = rename ( $old, $new ) ;
|
||||
if ($renamed)
|
||||
{
|
||||
$this->renameMetaData ( $new , $old_name) ;
|
||||
$this->renameLanguageFiles ( $new ) ;
|
||||
|
||||
}
|
||||
return $renamed ;
|
||||
}
|
||||
|
||||
function renameLanguageFiles ($new_dir , $duplicate = false)
|
||||
{
|
||||
|
||||
$this->mblanguage->name = $this->name ;
|
||||
$this->mblanguage->path = $new_dir ;
|
||||
$this->mblanguage->generateAppStrings () ;
|
||||
$this->mblanguage->save ( $this->key_name, $duplicate, true) ;
|
||||
}
|
||||
|
||||
function renameMetaData ($new_dir, $old_name)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( 'MBModule.php->renameMetaData: new_dir=' . $new_dir ) ;
|
||||
if (! file_exists ( $new_dir ))
|
||||
return ;
|
||||
$dir = dir ( $new_dir ) ;
|
||||
while ( $e = $dir->read () )
|
||||
{
|
||||
if (substr ( $e, 0, 1 ) != '.')
|
||||
{
|
||||
if (is_dir ( $new_dir . '/' . $e ))
|
||||
{
|
||||
$this->renameMetaData ( $new_dir . '/' . $e, $old_name) ;
|
||||
}
|
||||
if (is_file ( $new_dir . '/' . $e ))
|
||||
{
|
||||
$contents = file_get_contents ( $new_dir . '/' . $e ) ;
|
||||
$contents = preg_replace ( '/(\$module_name[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . $this->key_name . '$3', $contents ) ;
|
||||
$contents = preg_replace ( '/(\$_module_name[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . strtolower ( $this->key_name ) . '$3', $contents ) ;
|
||||
$contents = preg_replace ( '/(\$MODULE_NAME[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . strtoupper ( $this->key_name ) . '$3', $contents ) ;
|
||||
$contents = preg_replace ( '/(\$object_name[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . $this->key_name . '$3', $contents ) ;
|
||||
$contents = preg_replace ( '/(\$_object_name[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . strtolower ( $this->key_name ) . '$3', $contents ) ;
|
||||
$contents = preg_replace ( '/(\$OBJECT_NAME[ ]*=[ ]*\')(.*)(\'[ ]*;)/', '$1' . strtoupper ( $this->key_name ) . '$3', $contents ) ;
|
||||
$contents = str_replace ( "{$old_name}_", $this->key_name . "_", $contents ) ;
|
||||
$fp = sugar_fopen ( $new_dir . '/' . $e, 'w' ) ;
|
||||
fwrite ( $fp, $contents ) ;
|
||||
fclose ( $fp ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function copy ($new_name)
|
||||
{
|
||||
$old = $this->getModuleDir () ;
|
||||
|
||||
$count = 0 ;
|
||||
$old_name = $this->key_name;
|
||||
$this->name = $new_name ;
|
||||
$this->key_name = $this->package_key . '_' . $this->name ;
|
||||
$new = $this->getModuleDir () ;
|
||||
while ( file_exists ( $new ) )
|
||||
{
|
||||
$count ++ ;
|
||||
$this->name = $new_name . $count ;
|
||||
$this->key_name = $this->package_key . '_' . $this->name ;
|
||||
$new = $this->getModuleDir () ;
|
||||
}
|
||||
|
||||
$new = $this->getModuleDir () ;
|
||||
$copied = copy_recursive ( $old, $new ) ;
|
||||
|
||||
if ($copied)
|
||||
{
|
||||
$this->renameMetaData ( $new , $old_name) ;
|
||||
$this->renameLanguageFiles ( $new, true ) ;
|
||||
}
|
||||
return $copied ;
|
||||
|
||||
}
|
||||
|
||||
function delete ()
|
||||
{
|
||||
return rmdir_recursive ( $this->getModuleDir () ) ;
|
||||
}
|
||||
|
||||
function populateFromPost ()
|
||||
{
|
||||
foreach ( $this->implementable as $key => $value )
|
||||
{
|
||||
$this->config [ $key ] = ! empty ( $_REQUEST [ $key ] ) ;
|
||||
}
|
||||
foreach ( $this->always_implement as $key => $value )
|
||||
{
|
||||
$this->config [ $key ] = true ;
|
||||
}
|
||||
if (! empty ( $_REQUEST [ 'type' ] ))
|
||||
{
|
||||
$this->addTemplate ( $_REQUEST [ 'type' ] ) ;
|
||||
}
|
||||
|
||||
if (! empty ( $_REQUEST [ 'label' ] ))
|
||||
{
|
||||
$this->config [ 'label' ] = $_REQUEST [ 'label' ] ;
|
||||
}
|
||||
|
||||
$this->config [ 'importable' ] = ! empty( $_REQUEST[ 'importable' ] ) ;
|
||||
|
||||
}
|
||||
|
||||
function getAvailibleSubpanelDef ($panelName)
|
||||
{
|
||||
$filepath = $this->getModuleDir () . "/metadata/subpanels/{$panelName}.php" ;
|
||||
if (file_exists ( $filepath ))
|
||||
{
|
||||
include ($filepath) ;
|
||||
return $subpanel_layout ;
|
||||
}
|
||||
return array ( ) ;
|
||||
|
||||
}
|
||||
|
||||
function saveAvailibleSubpanelDef ($panelName , $layout)
|
||||
{
|
||||
$dir = $this->getModuleDir () . "/metadata/subpanels" ;
|
||||
$filepath = "$dir/{$panelName}.php" ;
|
||||
if (mkdir_recursive ( $dir ))
|
||||
{
|
||||
// preserve any $module_name entry if one exists
|
||||
if (file_exists ( $filepath ))
|
||||
{
|
||||
include ($filepath) ;
|
||||
}
|
||||
$module_name = (isset ( $module_name )) ? $module_name : $this->key_name ;
|
||||
$layout = "<?php\n" . '$module_name=\'' . $module_name . "';\n" . '$subpanel_layout = ' . var_export_helper ( $layout ) . ";" ;
|
||||
$GLOBALS [ 'log' ]->debug ( "About to save this file to $filepath" ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( $layout ) ;
|
||||
$fw = sugar_fopen ( $filepath, 'w' ) ;
|
||||
fwrite ( $fw, $layout ) ;
|
||||
fclose ( $fw ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function getLocalSubpanelDef ($panelName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function createIcon ()
|
||||
{
|
||||
$icondir = $this->package_path . "/icons" ;
|
||||
mkdir_recursive ( $icondir ) ;
|
||||
$template = "" ;
|
||||
foreach ( $this->config [ 'templates' ] as $temp => $val )
|
||||
$template = $temp ;
|
||||
copy ( "themes/default/images/icon_$template.gif", "$icondir/icon_" . ucfirst ( $this->key_name ) . ".gif" ) ;
|
||||
copy ( "include/SugarObjects/templates/$template/icons/$template.gif", "$icondir/" . $this->key_name . ".gif" ) ;
|
||||
if (file_exists("include/SugarObjects/templates/$template/icons/Create$template.gif"))
|
||||
copy ( "include/SugarObjects/templates/$template/icons/Create$template.gif", "$icondir/Create" . $this->key_name . ".gif" ) ;
|
||||
if (file_exists("include/SugarObjects/templates/$template/icons/{$template}_32.gif"))
|
||||
copy ( "include/SugarObjects/templates/$template/icons/{$template}_32.gif", "$icondir/icon_" . $this->key_name . "_32.gif" ) ;
|
||||
}
|
||||
|
||||
function removeFieldFromLayouts ( $fieldName )
|
||||
{
|
||||
// hardcoded list of types for now, as also hardcoded in a different form in getNodes
|
||||
// TODO: replace by similar mechanism to StudioModule to determine the list of available views for this module
|
||||
$views = array ( 'editview' , 'detailview' , 'listview' , 'basic_search' , 'advanced_search' , 'dashlet' , 'popuplist');
|
||||
|
||||
foreach ($views as $type )
|
||||
{
|
||||
$parser = ParserFactory::getParser( $type , $this->name , $this->package ) ;
|
||||
if ($parser->removeField ( $fieldName ) )
|
||||
$parser->handleSave(false) ; // don't populate from $_REQUEST, just save as is...
|
||||
}
|
||||
//Remove the fields in subpanel
|
||||
$psubs = $this->getProvidedSubpanels() ;
|
||||
foreach ( $psubs as $sub )
|
||||
{
|
||||
$parser = ParserFactory::getParser( MB_LISTVIEW , $this->name, $this->package , $sub) ;
|
||||
if ($parser->removeField ( $fieldName ) )
|
||||
$parser->handleSave(false) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
786
modules/ModuleBuilder/MB/MBPackage.php
Executable file
786
modules/ModuleBuilder/MB/MBPackage.php
Executable file
@@ -0,0 +1,786 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/MBModule.php');
|
||||
|
||||
class MBPackage{
|
||||
var $name;
|
||||
var $is_uninstallable = true;
|
||||
var $description = '';
|
||||
var $has_images = true;
|
||||
var $modules = array();
|
||||
var $date_modified = '';
|
||||
var $author = '';
|
||||
var $key = '';
|
||||
var $readme='';
|
||||
function MBPackage($name){
|
||||
$this->name = $name;
|
||||
$this->load();
|
||||
|
||||
}
|
||||
function loadModules($force=false){
|
||||
if(!file_exists(MB_PACKAGE_PATH . '/' . $this->name .'/modules'))return;
|
||||
$d = dir(MB_PACKAGE_PATH . '/' . $this->name .'/modules');
|
||||
while($e = $d->read()){
|
||||
if(substr($e, 0, 1) != '.' && is_dir(MB_PACKAGE_PATH . '/'. $this->name. '/modules/' . $e)){
|
||||
$this->getModule($e, $force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the translated module titles from the selected language into.
|
||||
* Will override currently loaded string to reflect undeployed label changes.
|
||||
* $app_list_strings
|
||||
* @return
|
||||
* @param $languge String language identifyer
|
||||
*/
|
||||
function loadModuleTitles($languge = '')
|
||||
{
|
||||
if (empty($language))
|
||||
{
|
||||
$language = $GLOBALS['current_language'];
|
||||
}
|
||||
global $app_list_strings;
|
||||
$packLangFilePath = $this->getPackageDir() . "/language/application/" . $language . ".lang.php";
|
||||
if (file_exists($packLangFilePath))
|
||||
{
|
||||
|
||||
require($packLangFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
function getModule($name, $force=true){
|
||||
if(!$force && !empty($this->modules[$name]))return;
|
||||
$path = $this->getPackageDir();
|
||||
|
||||
$this->modules[$name] = new MBModule($name, $path, $this->name, $this->key);
|
||||
}
|
||||
|
||||
function deleteModule($name){
|
||||
$this->modules[$name]->delete();
|
||||
unset($this->modules[$name]);
|
||||
}
|
||||
|
||||
function getManifest($version_specific = false, $for_export = false){
|
||||
//If we are exporting the package, we must ensure a different install key
|
||||
$pre = $for_export ? MB_EXPORTPREPEND : "";
|
||||
$date = gmdate($GLOBALS['timedate']->get_db_date_time_format());
|
||||
$time = time();
|
||||
$this->description = to_html($this->description);
|
||||
$is_uninstallable = ($this->is_uninstallable ? 'true' : 'false');
|
||||
$flavor = "'" . $GLOBALS['sugar_flavor'] . "'";
|
||||
if($GLOBALS['sugar_flavor'] == 'CE')$flavor = "'CE', 'PRO','ENT'";
|
||||
$version = (!empty($version_specific))?"'" . $GLOBALS['sugar_version'] . "'" : '';
|
||||
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
|
||||
return <<<EOQ
|
||||
$header
|
||||
\$manifest = array (
|
||||
'acceptable_sugar_versions' =>
|
||||
array (
|
||||
$version
|
||||
),
|
||||
'acceptable_sugar_flavors' =>
|
||||
array(
|
||||
$flavor
|
||||
),
|
||||
'readme'=>'$this->readme',
|
||||
'key'=>'$this->key',
|
||||
'author' => '$this->author',
|
||||
'description' => '$this->description',
|
||||
'icon' => '',
|
||||
'is_uninstallable' => $is_uninstallable,
|
||||
'name' => '$pre$this->name',
|
||||
'published_date' => '$date',
|
||||
'type' => 'module',
|
||||
'version' => '$time',
|
||||
'remove_tables' => 'prompt',
|
||||
);
|
||||
EOQ;
|
||||
}
|
||||
|
||||
function buildInstall($path){
|
||||
$installdefs = array ('id' => $this->name,
|
||||
'beans'=>array(),
|
||||
'layoutdefs'=>array(),
|
||||
'relationships'=>array(),
|
||||
);
|
||||
if($this->has_images){
|
||||
$installdefs['image_dir'] = '<basepath>/icons';
|
||||
}
|
||||
foreach(array_keys($this->modules) as $module){
|
||||
$this->modules[$module]->build($path);
|
||||
$this->modules[$module]->addInstallDefs($installdefs);
|
||||
}
|
||||
$this->path = $this->getPackageDir();
|
||||
if(file_exists($this->path . '/language')){
|
||||
$d= dir($this->path . '/language');
|
||||
while($e = $d->read()){
|
||||
$lang_path = $this->path .'/language/' . $e;
|
||||
if(substr($e, 0, 1) != '.' && is_dir($lang_path)){
|
||||
$f = dir($lang_path);
|
||||
while($g = $f->read()){
|
||||
if(substr($g, 0, 1) != '.' && is_file($lang_path.'/'. $g)){
|
||||
$lang = substr($g, 0, strpos($g, '.'));
|
||||
$installdefs['language'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/language/'.$e . '/'. $g,
|
||||
'to_module'=> $e,
|
||||
'language'=> $lang
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copy_recursive( $this->path . '/language/', $path . '/language/');
|
||||
$icon_path = $path . '/../icons/default/images/';
|
||||
mkdir_recursive($icon_path);
|
||||
copy_recursive($this->path . '/icons/', $icon_path);
|
||||
}
|
||||
return "\n".'$installdefs = ' . var_export_helper($installdefs). ';';
|
||||
|
||||
}
|
||||
|
||||
function getPackageDir(){
|
||||
return MB_PACKAGE_PATH . '/' . $this->name;
|
||||
}
|
||||
|
||||
function getBuildDir(){
|
||||
return MB_PACKAGE_BUILD . '/' . $this->name;
|
||||
}
|
||||
|
||||
function getZipDir(){
|
||||
return $this->getPackageDir() . '/zips';
|
||||
}
|
||||
|
||||
|
||||
function load(){
|
||||
$path = $this->getPackageDir();
|
||||
if(file_exists($path .'/manifest.php')){
|
||||
require($path . '/manifest.php');
|
||||
if(!empty($manifest)){
|
||||
$this->date_modified = $manifest['published_date'];
|
||||
$this->is_uninstallable = $manifest['is_uninstallable'];
|
||||
$this->author = $manifest['author'];
|
||||
$this->key = $manifest['key'];
|
||||
$this->description = $manifest['description'];
|
||||
if(!empty($manifest['readme']))
|
||||
$this->readme = $manifest['readme'];
|
||||
}
|
||||
}
|
||||
$this->loadModules(true);
|
||||
}
|
||||
|
||||
function save(){
|
||||
$path = $this->getPackageDir();
|
||||
if(mkdir_recursive($path)){
|
||||
$fp = sugar_fopen($path .'/manifest.php', 'w');
|
||||
|
||||
|
||||
//Save all the modules when we save a package
|
||||
$this->updateModulesMetaData(true);
|
||||
fwrite($fp, $this->getManifest() );
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function build($export=true, $clean = false){
|
||||
$this->loadModules();
|
||||
require_once('include/utils/zip_utils.php');
|
||||
$package_path = $this->getPackageDir();
|
||||
$path = $this->getBuildDir() . '/SugarModules';
|
||||
if($clean && file_exists($path))rmdir_recursive($path);
|
||||
if(mkdir_recursive($path)){
|
||||
|
||||
$manifest = $this->getManifest().$this->buildInstall($path);
|
||||
$fp = sugar_fopen($this->getBuildDir() .'/manifest.php', 'w');
|
||||
fwrite($fp, $manifest);
|
||||
fclose($fp);
|
||||
|
||||
}
|
||||
if(file_exists('modules/ModuleBuilder/MB/LICENSE.txt')){
|
||||
copy('modules/ModuleBuilder/MB/LICENSE.txt', $this->getBuildDir() . '/LICENSE.txt');
|
||||
}else if(file_exists('LICENSE.txt')){
|
||||
copy('LICENSE.txt', $this->getBuildDir() . '/LICENSE.txt');
|
||||
}
|
||||
$package_dir = $this->getPackageDir();
|
||||
$date = date('Y_m_d_His');
|
||||
$zipDir = $this->getZipDir();
|
||||
if(!file_exists($zipDir))mkdir_recursive($zipDir);
|
||||
$cwd = getcwd();
|
||||
chdir($this->getBuildDir());
|
||||
zip_dir('.',$cwd . '/'. $zipDir. '/'. $this->name. $date. '.zip');
|
||||
chdir($cwd);
|
||||
if($export){
|
||||
header('Location:' . $zipDir. '/'. $this->name. $date. '.zip');
|
||||
}
|
||||
return array(
|
||||
'zip'=>$zipDir. '/'. $this->name. $date. '.zip',
|
||||
'manifest'=>$this->getBuildDir(). '/manifest.php',
|
||||
'name'=>$this->name. $date,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function getNodes(){
|
||||
$this->loadModules();
|
||||
$node = array('name'=>$this->name, 'action'=>'module=ModuleBuilder&action=package&package=' . $this->name, 'children'=>array());
|
||||
foreach(array_keys($this->modules) as $module){
|
||||
$node['children'][] = $this->modules[$module]->getNodes();
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
function populateFromPost(){
|
||||
$this->description = $_REQUEST['description'];
|
||||
$this->author = $_REQUEST['author'];
|
||||
$this->key = $_REQUEST['key'];
|
||||
$this->readme = $_REQUEST['readme'];
|
||||
}
|
||||
|
||||
function rename($new_name){
|
||||
$old= $this->getPackageDir();
|
||||
$this->name = $new_name;
|
||||
$new = $this->getPackageDir();
|
||||
if(file_exists($new)){
|
||||
return false;
|
||||
}
|
||||
if(rename($old, $new)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateModulesMetaData($save=false){
|
||||
foreach(array_keys($this->modules) as $module){
|
||||
$old_name = $this->modules[$module]->key_name;
|
||||
$this->modules[$module]->key_name = $this->key . '_' . $this->modules[$module]->name;
|
||||
$this->modules[$module]->renameMetaData($this->modules[$module]->getModuleDir(), $old_name);
|
||||
$this->modules[$module]->renameLanguageFiles($this->modules[$module]->getModuleDir());
|
||||
if($save)$this->modules[$module]->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function copy($new_name){
|
||||
$old= $this->getPackageDir();
|
||||
|
||||
$count = 0;
|
||||
$this->name = $new_name;
|
||||
$new= $this->getPackageDir();
|
||||
while(file_exists($new)){
|
||||
$count++;
|
||||
$this->name = $new_name . $count;
|
||||
$new= $this->getPackageDir();
|
||||
}
|
||||
|
||||
$new = $this->getPackageDir();
|
||||
if(copy_recursive($old, $new)){
|
||||
$this->updateModulesMetaData();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function delete(){
|
||||
return rmdir_recursive($this->getPackageDir());
|
||||
}
|
||||
|
||||
|
||||
//creation of the installdefs[] array for the manifest when exporting customizations
|
||||
function customBuildInstall($modules, $path, $extensions = array()){
|
||||
$columns=$this->getColumnsName();
|
||||
$installdefs = array ('id' => $this->name);
|
||||
$include_path="$path/SugarModules/include/language";
|
||||
if(file_exists($include_path) && is_dir($include_path)){
|
||||
$dd= dir($include_path);
|
||||
while($gg = $dd->read()){
|
||||
if(substr($gg, 0, 1) != '.' && is_file($include_path . '/' . $gg)){
|
||||
$lang = substr($gg, 0, strpos($gg, '.'));
|
||||
$installdefs['language'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/include/language/'. $gg,
|
||||
'to_module'=> 'application',
|
||||
'language'=>$lang
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($modules as $value){
|
||||
$custom_module = $this->getCustomModules($value);
|
||||
foreach($custom_module as $va){
|
||||
if ($va == 'language'){
|
||||
$this->getLanguageManifestForModule($value, $installdefs);
|
||||
$this->getCustomFieldsManifestForModule($value, $installdefs);
|
||||
}//fi
|
||||
if($va == 'metadata'){
|
||||
$this->getCustomMetadataManifestForModule($value, $installdefs);
|
||||
}//fi
|
||||
}//foreach
|
||||
}//foreach
|
||||
if (is_dir("$path/Extension"))
|
||||
{
|
||||
$this->getExtensionsManifestForPackage($path, $installdefs);
|
||||
}
|
||||
return "\n".'$installdefs = ' . var_export_helper($installdefs). ';';
|
||||
}
|
||||
|
||||
private function getLanguageManifestForModule($module, &$installdefs)
|
||||
{
|
||||
$lang_path = 'custom/modules/' . $module . '/language';
|
||||
foreach(scandir($lang_path) as $langFile)
|
||||
{
|
||||
if(substr($langFile, 0, 1) != '.' && is_file($lang_path . '/' . $langFile)){
|
||||
$lang = substr($langFile, 0, strpos($langFile, '.'));
|
||||
$installdefs['language'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/modules/' . $module . '/language/'. $langFile,
|
||||
'to_module'=> $module,
|
||||
'language'=>$lang
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getCustomFieldsManifestForModule($module, &$installdefs)
|
||||
{
|
||||
$db = DBManagerFactory::getInstance();
|
||||
$result=$db->query("SELECT * FROM fields_meta_data where custom_module='$module'");
|
||||
while($row = $db->fetchByAssoc($result)){
|
||||
$name = $row['id'];
|
||||
foreach($row as $col=>$res){
|
||||
switch ($col) {
|
||||
case 'custom_module':
|
||||
$installdefs['custom_fields'][$name]['module'] = $res;
|
||||
break;
|
||||
case 'required':
|
||||
$installdefs['custom_fields'][$name]['require_option'] = $res;
|
||||
break;
|
||||
case 'vname':
|
||||
$installdefs['custom_fields'][$name]['label'] = $res;
|
||||
break;
|
||||
case 'required':
|
||||
$installdefs['custom_fields'][$name]['require_option'] = $res;
|
||||
break;
|
||||
case 'massupdate':
|
||||
$installdefs['custom_fields'][$name]['mass_update'] = $res;
|
||||
break;
|
||||
case 'comments':
|
||||
$installdefs['custom_fields'][$name]['comments'] = $res;
|
||||
break;
|
||||
case 'help':
|
||||
$installdefs['custom_fields'][$name]['help'] = $res;
|
||||
break;
|
||||
case 'len':
|
||||
$installdefs['custom_fields'][$name]['max_size'] = $res;
|
||||
break;
|
||||
default:
|
||||
$installdefs['custom_fields'][$name][$col] = $res;
|
||||
}//switch
|
||||
}//foreach
|
||||
}//while
|
||||
}
|
||||
|
||||
private function getCustomMetadataManifestForModule($module, &$installdefs)
|
||||
{
|
||||
$meta_path = 'custom/modules/' . $module . '/metadata';
|
||||
foreach(scandir($meta_path) as $meta_file)
|
||||
{
|
||||
if(substr($meta_file, 0, 1) != '.' && is_file($meta_path . '/' . $meta_file)){
|
||||
if($meta_file == 'listviewdefs.php'){
|
||||
$installdefs['copy'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/modules/'. $module . '/metadata/'. $meta_file,
|
||||
'to'=> 'custom/modules/'. $module . '/metadata/' . $meta_file,
|
||||
);
|
||||
}
|
||||
else{
|
||||
$installdefs['copy'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/modules/'. $module . '/metadata/'. $meta_file,
|
||||
'to'=> 'custom/modules/'. $module . '/metadata/' . $meta_file,
|
||||
);
|
||||
$installdefs['copy'][] = array(
|
||||
'from'=> '<basepath>/SugarModules/modules/'. $module . '/metadata/'. $meta_file,
|
||||
'to'=> 'custom/working/modules/'. $module . '/metadata/' . $meta_file,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getExtensionsManifestForPackage($path, &$installdefs)
|
||||
{
|
||||
$extPath = "$path/Extension/modules";
|
||||
foreach(scandir($extPath) as $moduleDir)
|
||||
{
|
||||
if(substr($moduleDir, 0, 1) != '.' && is_dir("$extPath/$moduleDir/Ext")){
|
||||
foreach(scandir("$extPath/$moduleDir/Ext") as $type)
|
||||
{
|
||||
if(substr($type, 0, 1) != '.' && is_dir("$extPath/$moduleDir/Ext/$type")){
|
||||
foreach(scandir("$extPath/$moduleDir/Ext/$type") as $file)
|
||||
{
|
||||
if(substr($file, 0, 1) != '.' && strtolower(substr($file, -4)) == ".php")
|
||||
{
|
||||
$installdefs['copy'][] = array(
|
||||
'from'=> "<basepath>/Extension/modules/$moduleDir/Ext/$type/$file",
|
||||
'to'=> "custom/Extension/modules/$moduleDir/Ext/$type/$file",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//return an array which contain the name of fields_meta_data table's columns
|
||||
function getColumnsName(){
|
||||
|
||||
$meta = new FieldsMetaData();
|
||||
$arr = array();
|
||||
foreach($meta->getFieldDefinitions() as $key=>$value) {
|
||||
$arr[] = $key;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
//creation of the custom fields ZIP file (use getmanifest() and customBuildInstall() )
|
||||
function exportCustom($modules, $export=true, $clean = true){
|
||||
$path=$this->getBuildDir();
|
||||
if($clean && file_exists($path))rmdir_recursive($path);
|
||||
//Copy the custom files to the build dir
|
||||
foreach($modules as $mod){
|
||||
$extensions = $this->getExtensionsList($mod);
|
||||
$pathmod="$path/SugarModules/modules/$mod";
|
||||
if(mkdir_recursive($pathmod)){
|
||||
if(file_exists("custom/modules/$mod")){
|
||||
copy_recursive("custom/modules/$mod", "$pathmod");
|
||||
//Don't include cached extension files
|
||||
if (is_dir("$pathmod/Ext"))
|
||||
rmdir_recursive("$pathmod/Ext");
|
||||
}
|
||||
//Convert modstring files to extension compatible arrays
|
||||
$this->convertLangFilesToExtensions("$pathmod/language");
|
||||
}
|
||||
$pathext="$path/Extension/modules/$mod/Ext";
|
||||
if (!empty($extensions) && mkdir_recursive($pathext))
|
||||
{
|
||||
foreach($extensions as $type => $files)
|
||||
{
|
||||
sugar_mkdir("$pathext/$type");
|
||||
foreach($files as $file => $filePath)
|
||||
{
|
||||
copy ($filePath, "$pathext/$type/$file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->copyCustomDropdownValuesForModules($modules,$path);
|
||||
if(file_exists($path)){
|
||||
$manifest = $this->getManifest(true).$this->customBuildInstall($modules,$path);
|
||||
sugar_file_put_contents($path .'/manifest.php', $manifest);;
|
||||
}
|
||||
if(file_exists('modules/ModuleBuilder/MB/LICENSE.txt')){
|
||||
copy('modules/ModuleBuilder/MB/LICENSE.txt', $path . '/LICENSE.txt');
|
||||
}
|
||||
else if(file_exists('LICENSE.txt')){
|
||||
copy('LICENSE.txt', $path . '/LICENSE.txt');
|
||||
}
|
||||
require_once('include/utils/zip_utils.php');
|
||||
$date = date('Y_m_d_His');
|
||||
$zipDir = $this->getZipDir();
|
||||
if(!file_exists($zipDir))mkdir_recursive($zipDir);
|
||||
$cwd = getcwd();
|
||||
chdir($this->getBuildDir());
|
||||
zip_dir('.',$cwd . '/'. $zipDir. '/'. $this->name. $date. '.zip');
|
||||
chdir($cwd);
|
||||
if($clean && file_exists($this->getBuildDir()))rmdir_recursive($this->getBuildDir());
|
||||
if($export){
|
||||
header('Location:' . $zipDir. '/'. $this->name. $date. '.zip');
|
||||
}
|
||||
return $zipDir. '/'. $this->name. $date. '.zip';
|
||||
}
|
||||
|
||||
private function convertLangFilesToExtensions($langDir)
|
||||
{
|
||||
if (is_dir($langDir))
|
||||
{
|
||||
foreach(scandir($langDir) as $langFile)
|
||||
{
|
||||
$mod_strings = array();
|
||||
if (strcasecmp(substr($langFile, -4), ".php") != 0)
|
||||
continue;
|
||||
include("$langDir/$langFile");
|
||||
$out = "<?php \n // created: " . date('Y-m-d H:i:s') . "\n";
|
||||
foreach($mod_strings as $lbl_key => $lbl_val )
|
||||
{
|
||||
$out .= override_value_to_string("mod_strings", $lbl_key, $lbl_val) . "\n";
|
||||
}
|
||||
$out .= "\n?>\n";
|
||||
sugar_file_put_contents("$langDir/$langFile", $out);
|
||||
}
|
||||
}
|
||||
}
|
||||
private function copyCustomDropdownValuesForModules($modules, $path)
|
||||
{
|
||||
if(file_exists("custom/include/language")){
|
||||
if(mkdir_recursive("$path/SugarModules/include")){
|
||||
global $app_list_strings;
|
||||
$backStrings = $app_list_strings;
|
||||
foreach(scandir("custom/include/language") as $langFile)
|
||||
{
|
||||
$app_list_strings = array();
|
||||
if (strcasecmp(substr($langFile, -4), ".php") != 0)
|
||||
continue;
|
||||
include("custom/include/language/$langFile");
|
||||
$out = "<?php \n";
|
||||
$lang = substr($langFile, 0, -9);
|
||||
$options = $this->getCustomDropDownStringsForModules($modules, $app_list_strings);
|
||||
foreach($options as $name => $arr) {
|
||||
$out .= override_value_to_string('app_list_strings', $name, $arr);
|
||||
}
|
||||
mkdir_recursive("$path/SugarModules/include/language/");
|
||||
sugar_file_put_contents("$path/SugarModules/include/language/$lang.$this->name.php", $out);
|
||||
}
|
||||
$app_list_strings = $backStrings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCustomDropDownStringsForModules($modules, $list_strings) {
|
||||
global $beanList, $beanFiles;
|
||||
$options = array();
|
||||
foreach($modules as $module)
|
||||
{
|
||||
if (!empty($beanList[$module]))
|
||||
{
|
||||
require_once($beanFiles[$beanList[$module]]);
|
||||
$bean = new $beanList[$module]();
|
||||
foreach($bean->field_defs as $field => $def)
|
||||
{
|
||||
if (isset($def['options']) && isset($list_strings[$def['options']]))
|
||||
{
|
||||
$options[$def['options']] = $list_strings[$def['options']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if $module=false : return an array with custom module and there customizations.
|
||||
//if $module=!false : return an array with the directories of custom/module/$module.
|
||||
function getCustomModules($module=false){
|
||||
global $mod_strings;
|
||||
$path='custom/modules/';
|
||||
$extPath = 'custom/Extension/modules/';
|
||||
if(!file_exists($path) || !is_dir($path)){
|
||||
return array($mod_strings['LBL_EC_NOCUSTOM'] => "");
|
||||
}
|
||||
else{
|
||||
if ($module != false ){
|
||||
$path=$path . $module . '/';
|
||||
}
|
||||
$scanlisting = scandir($path);
|
||||
$dirlisting = array();
|
||||
foreach ($scanlisting as $value){
|
||||
if(is_dir($path . $value) == true && $value != '.' && $value != '..') {
|
||||
$dirlisting[] = $value;
|
||||
}
|
||||
}
|
||||
if(empty($dirlisting)){
|
||||
return array($mod_strings['LBL_EC_NOCUSTOM'] => "");
|
||||
}
|
||||
if ($module == false ){
|
||||
foreach ($dirlisting as $value){
|
||||
if(!file_exists('modules/' . $value . '/metadata/studio.php'))
|
||||
continue;
|
||||
$custommodules[$value]=$this->getCustomModules($value);
|
||||
foreach ($custommodules[$value] as $va){
|
||||
switch ($va) {
|
||||
case 'language':
|
||||
$return[$value][$va] = $mod_strings['LBL_EC_CUSTOMFIELD'];
|
||||
break;
|
||||
case 'metadata':
|
||||
$return[$value][$va] = $mod_strings['LBL_EC_CUSTOMLAYOUT'];
|
||||
break;
|
||||
case 'Ext':
|
||||
|
||||
$return[$value][$va] = $mod_strings['LBL_EC_CUSTOMFIELD'];
|
||||
break;
|
||||
case '':
|
||||
$return[$value . " " . $mod_strings['LBL_EC_EMPTYCUSTOM']] = "";
|
||||
break;
|
||||
default:
|
||||
$return[$value][$va] = $mod_strings['LBL_UNDEFINED'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
else{
|
||||
return $dirlisting;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getExtensionsList($module, $excludeRelationships = true)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
$extPath = 'custom/Extension/modules/';
|
||||
$modExtPath = $extPath . $module . '/Ext';
|
||||
$rels = new DeployedRelationships($module);
|
||||
$relList = $rels->getRelationshipList ();
|
||||
|
||||
$ret = array();
|
||||
if (is_dir($modExtPath))
|
||||
{
|
||||
$extFolders = scandir($modExtPath);
|
||||
foreach($extFolders as $extFolder)
|
||||
{
|
||||
if (!is_dir("$modExtPath/$extFolder") || substr($extFolder, 0, 1) == ".")
|
||||
continue;
|
||||
|
||||
foreach( scandir("$modExtPath/$extFolder") as $extFile)
|
||||
{
|
||||
|
||||
if (substr($extFile, 0, 1) == "." || strtolower(substr($extFile, -4)) != ".php")
|
||||
continue;
|
||||
//Exclude relattionship extension files
|
||||
if ($excludeRelationships && (
|
||||
(substr($extFile, 0, 6) == "custom" && isset($relList[substr($extFile, 6, strlen($extFile) - 10)])) ||
|
||||
(substr($extFile, 6, 6) == "custom" && isset($relList[substr($extFile, 12, strlen($extFile) - 16)]))
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($ret[$extFolder]))
|
||||
$ret[$extFolder] = array();
|
||||
|
||||
$ret[$extFolder][$extFile ] = "$modExtPath/$extFolder/$extFile";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of field defs for fields that will exist when this package is deployed
|
||||
* based on the relationships in all of its modules.
|
||||
*
|
||||
* @param $moduleName (module must be from whithin this package)
|
||||
* @return array Field defs
|
||||
*/
|
||||
function getRelationshipsForModule($moduleName) {
|
||||
$ret = array();
|
||||
if (isset($this->modules[$moduleName])) {
|
||||
$keyName = $this->modules[$moduleName]->key_name;
|
||||
foreach($this->modules as $mName => $module) {
|
||||
$rels = $module->getRelationships();
|
||||
$relList = $rels->getRelationshipList();
|
||||
foreach($relList as $rName ) {
|
||||
$rel = $rels->get ( $rName ) ;
|
||||
if ($rel->lhs_module == $keyName || $rel->rhs_module == $keyName) {
|
||||
$ret[$rName] = $rel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function exportProjectInstall($package, $for_export){
|
||||
$pre = $for_export ? MB_EXPORTPREPEND : "";
|
||||
$installdefs = array ('id' => $pre . $this->name);
|
||||
$installdefs['copy'][] = array(
|
||||
'from'=> '<basepath>/' . $this->name,
|
||||
'to'=> 'custom/modulebuilder/packages/'. $this->name,
|
||||
);
|
||||
return "\n".'$installdefs = ' . var_export_helper($installdefs). ';';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function exportProject($package, $export=true, $clean = true){
|
||||
$tmppath="custom/modulebuilder/projectTMP/";
|
||||
if(file_exists($this->getPackageDir())){
|
||||
if(mkdir_recursive($tmppath)){
|
||||
copy_recursive($this->getPackageDir(), $tmppath ."/". $this->name);
|
||||
$manifest = $this->getManifest(true, $export).$this->exportProjectInstall($package, $export);
|
||||
$fp = sugar_fopen($tmppath .'/manifest.php', 'w');
|
||||
fwrite($fp, $manifest);
|
||||
fclose($fp);
|
||||
if(file_exists('modules/ModuleBuilder/MB/LICENSE.txt')){
|
||||
copy('modules/ModuleBuilder/MB/LICENSE.txt', $tmppath . '/LICENSE.txt');
|
||||
}
|
||||
else if(file_exists('LICENSE.txt')){
|
||||
copy('LICENSE.txt', $tmppath . '/LICENSE.txt');
|
||||
}
|
||||
$readme_contents = $this->readme;
|
||||
$readmefp = sugar_fopen($tmppath.'/README.txt','w');
|
||||
fwrite($readmefp, $readme_contents);
|
||||
fclose($readmefp);
|
||||
}
|
||||
}
|
||||
require_once('include/utils/zip_utils.php');
|
||||
$date = date('Y_m_d_His');
|
||||
$zipDir = "custom/modulebuilder/packages/ExportProjectZips";
|
||||
if(!file_exists($zipDir))mkdir_recursive($zipDir);
|
||||
$cwd = getcwd();
|
||||
chdir($tmppath);
|
||||
zip_dir('.',$cwd . '/'. $zipDir. '/project_'. $this->name. $date. '.zip');
|
||||
chdir($cwd);
|
||||
if($clean && file_exists($tmppath))rmdir_recursive($tmppath);
|
||||
if($export){
|
||||
header('Location:' . $zipDir. '/project_'. $this->name. $date. '.zip');
|
||||
}
|
||||
return $zipDir. '/project_'. $this->name. $date. '.zip';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
78
modules/ModuleBuilder/MB/MBPackageTree.php
Executable file
78
modules/ModuleBuilder/MB/MBPackageTree.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('include/ytree/Tree.php');
|
||||
require_once('include/ytree/Node.php');
|
||||
class MBPackageTree{
|
||||
|
||||
function MBPackageTree(){
|
||||
$this->tree = new Tree('package_tree');
|
||||
$this->tree->id = 'package_tree';
|
||||
$this->mb = new ModuleBuilder();
|
||||
$this->populateTree($this->mb->getNodes(), $this->tree);
|
||||
}
|
||||
|
||||
function getName(){
|
||||
return 'Packages';
|
||||
}
|
||||
|
||||
function populateTree($nodes, &$parent){
|
||||
foreach($nodes as $node){
|
||||
if(empty($node['label']))$node['label'] = $node['name'];
|
||||
$yn = new Node($parent->id . '/' . $node['name'],$node['label']);
|
||||
if(!empty($node['action']))
|
||||
$yn->set_property('action', $node['action']);
|
||||
$yn->set_property('href', 'javascript:void(0);');
|
||||
$yn->id = $parent->id . '/' . $node['name'];
|
||||
if(!empty($node['children']))$this->populateTree($node['children'], $yn);
|
||||
$parent->add_node($yn);
|
||||
}
|
||||
}
|
||||
|
||||
function fetch(){
|
||||
//return $this->tree->generate_header() . $this->tree->generate_nodes_array();
|
||||
return $this->tree->generate_nodes_array();
|
||||
}
|
||||
|
||||
function fetchNodes(){
|
||||
return $this->tree->generateNodesRaw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
175
modules/ModuleBuilder/MB/MBRelationship.php
Executable file
175
modules/ModuleBuilder/MB/MBRelationship.php
Executable file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php' ;
|
||||
|
||||
/*
|
||||
* This is an Adapter for the new UndeployedRelationships Class to allow ModuleBuilder to use the new class without change
|
||||
* As ModuleBuilder is updated, references to this MBRelationship class should be replaced by direct references to UndeployedRelationships
|
||||
*/
|
||||
|
||||
class MBRelationship
|
||||
{
|
||||
|
||||
public $relatableModules = array ( ) ; // required by MBModule
|
||||
public $relationships = array ( ) ; // required by view.relationships.php; must be kept in sync with the implementation
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string $name The name of this module (not used)
|
||||
* @param string $path The base path of the module directory within the ModuleBuilder package directory
|
||||
* @param string $key_name The Fully Qualified Name for this module - that is, $packageName_$name
|
||||
*/
|
||||
function MBRelationship ($name , $path , $key_name)
|
||||
{
|
||||
$this->implementation = new UndeployedRelationships ( $path ) ;
|
||||
$this->moduleName = $key_name ;
|
||||
$this->path = $path ;
|
||||
$this->updateRelationshipVariable();
|
||||
}
|
||||
|
||||
function findRelatableModules ()
|
||||
{
|
||||
// do not call findRelatableModules in the constructor as it leads to an infinite loop if the implementation calls getPackage() which loads the packages which loads the module which findsRelatableModules which...
|
||||
$this->relatableModules = $this->implementation->findRelatableModules () ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Originally in 5.0 this method expected $_POST variables keyed in the "old" format - lhs_module, relate, msub, rsub etc
|
||||
* At 5.1 this has been changed to the "new" format of lhs_module, rhs_module, lhs_subpanel, rhs_subpanel, label
|
||||
* @return AbstractRelationship
|
||||
*/
|
||||
function addFromPost ()
|
||||
{
|
||||
return $this->implementation->addFromPost () ;
|
||||
}
|
||||
|
||||
/*
|
||||
* New function to replace the old MBModule subpanel property - now we obtain the 'subpanels' (actually related modules) from the relationships object
|
||||
*/
|
||||
function getRelationshipList ()
|
||||
{
|
||||
return $this->implementation->getRelationshipList () ;
|
||||
}
|
||||
|
||||
function get ($relationshipName)
|
||||
{
|
||||
return $this->implementation->get ( $relationshipName ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deprecated
|
||||
* Add a relationship to this set
|
||||
* Original MBRelationships could only support one relationship between this module and any other
|
||||
*/
|
||||
/*
|
||||
function addRelationship ($name , $relatedTo , $relatedSubpanel = 'default' , $mysubpanel = 'default' , $type)
|
||||
{
|
||||
$this->implementation->add ( new ManyToManyRelationship ( $name, $this->moduleName, $relatedTo, $mysubpanel, $relatedSubpanel ) ) ;
|
||||
$this->updateRelationshipVariable () ;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Add a relationship to this set
|
||||
* Original MBRelationships could only support one relationship between this module and any other
|
||||
* @param array $rel Relationship definition in the old format (defined by self::oldFormatKeys)
|
||||
*/
|
||||
function add ($rel)
|
||||
{
|
||||
// convert old format definition to new format
|
||||
if (! isset ( $rel [ 'lhs_module' ] ))
|
||||
$rel [ 'lhs_module' ] = $this->moduleName ;
|
||||
$definition = AbstractRelationships::convertFromOldFormat ( $rel ) ;
|
||||
if (! isset ( $definition ['relationship_type']))
|
||||
$definition ['relationship_type'] = 'many-to-many';
|
||||
// get relationship object from RelationshipFactory
|
||||
$relationship = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
// add relationship to the set of relationships
|
||||
$this->implementation->add ( $relationship ) ;
|
||||
$this->updateRelationshipVariable () ;
|
||||
return $relationship;
|
||||
}
|
||||
|
||||
function delete ($name)
|
||||
{
|
||||
$this->implementation->delete ( $name ) ;
|
||||
$this->updateRelationshipVariable () ;
|
||||
}
|
||||
|
||||
function save ()
|
||||
{
|
||||
$this->implementation->save () ;
|
||||
}
|
||||
|
||||
function build ($path)
|
||||
{
|
||||
$this->implementation->build () ;
|
||||
}
|
||||
|
||||
function addInstallDefs (&$installDef)
|
||||
{
|
||||
$this->implementation->addInstallDefs ( $installDef ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
function load ()
|
||||
{
|
||||
$this->implementation->load () ;
|
||||
$this->updateRelationshipVariable () ;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Transitional function to keep the public relationship variable in sync with the implementation master copy
|
||||
* We have to do this as various things refer directly to MBRelationship->relationships...
|
||||
*/
|
||||
|
||||
private function updateRelationshipVariable ()
|
||||
{
|
||||
foreach ( $this->implementation->getRelationshipList () as $relationshipName )
|
||||
{
|
||||
$rel = $this->implementation->getOldFormat ( $relationshipName ) ;
|
||||
$this->relationships [ $relationshipName ] = $rel ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
145
modules/ModuleBuilder/MB/MBVardefs.php
Executable file
145
modules/ModuleBuilder/MB/MBVardefs.php
Executable file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
class MBVardefs{
|
||||
var $templates = array();
|
||||
var $iTemplates = array();
|
||||
var $vardefs = array();
|
||||
var $vardef = array();
|
||||
var $path = '';
|
||||
var $name = '';
|
||||
var $errors = array();
|
||||
|
||||
function MBVardefs($name, $path, $key_name){
|
||||
$this->path = $path;
|
||||
$this->name = $name;
|
||||
$this->key_name = $key_name;
|
||||
$this->load();
|
||||
}
|
||||
|
||||
function loadTemplate($by_group, $template, $file){
|
||||
$module = $this->name;
|
||||
$table_name = $this->name;
|
||||
$object_name = $this->key_name;
|
||||
$_object_name = strtolower($this->key_name);
|
||||
|
||||
// required by the vardef template for team security in SugarObjects
|
||||
$table_name = strtolower($module);
|
||||
|
||||
if(file_exists($file)){
|
||||
include($file);
|
||||
if($by_group){
|
||||
$this->vardefs['fields'] [$template]= $vardefs['fields'];
|
||||
}else{
|
||||
$this->vardefs['fields']= array_merge($this->vardefs['fields'], $vardefs['fields']);
|
||||
if(!empty($vardefs['relationships'])){
|
||||
$this->vardefs['relationships']= array_merge($this->vardefs['relationships'], $vardefs['relationships']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mergeVardefs($by_group=false){
|
||||
$this->vardefs = array(
|
||||
'fields'=>array(),
|
||||
'relationships'=>array(),
|
||||
);
|
||||
// $object_name = $this->key_name;
|
||||
// $_object_name = strtolower($this->name);
|
||||
$module_name = $this->name;
|
||||
$this->loadTemplate($by_group,'basic', MB_TEMPLATES . '/basic/vardefs.php');
|
||||
foreach($this->iTemplates as $template=>$val){
|
||||
$file = MB_IMPLEMENTS . '/' . $template . '/vardefs.php';
|
||||
$this->loadTemplate($by_group,$template, $file);
|
||||
}
|
||||
foreach($this->templates as $template=>$val){
|
||||
if($template == 'basic')continue;
|
||||
$file = MB_TEMPLATES . '/' . $template . '/vardefs.php';
|
||||
$this->loadTemplate($by_group,$template, $file);
|
||||
}
|
||||
|
||||
if($by_group){
|
||||
$this->vardefs['fields'][$this->name] = $this->vardef['fields'];
|
||||
}else{
|
||||
$this->vardefs['fields'] = array_merge($this->vardefs['fields'], $this->vardef['fields']);
|
||||
}
|
||||
}
|
||||
|
||||
function updateVardefs($by_group=false){
|
||||
$this->mergeVardefs($by_group);
|
||||
}
|
||||
|
||||
|
||||
function getVardefs(){
|
||||
return $this->vardefs;
|
||||
}
|
||||
|
||||
function getVardef(){
|
||||
return $this->vardef;
|
||||
}
|
||||
|
||||
function addFieldVardef($vardef){
|
||||
if(empty($vardef['default']))unset($vardef['default']);
|
||||
$this->vardef['fields'][$vardef['name']] = $vardef;
|
||||
}
|
||||
|
||||
function deleteField($field){
|
||||
unset($this->vardef['fields'][$field->name]);
|
||||
}
|
||||
|
||||
function save(){
|
||||
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
|
||||
write_array_to_file('vardefs', $this->vardef, $this->path . '/vardefs.php','w', $header);
|
||||
}
|
||||
|
||||
function build($path){
|
||||
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
|
||||
write_array_to_file('dictionary["' . $this->name . '"]', $this->getVardefs(), $path . '/vardefs.php', 'w', $header);
|
||||
}
|
||||
function load(){
|
||||
$this->vardef = array('fields'=>array(), 'relationships'=>array());
|
||||
if(file_exists($this->path . '/vardefs.php')){
|
||||
include($this->path. '/vardefs.php');
|
||||
$this->vardef = $vardefs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
147
modules/ModuleBuilder/MB/ModuleBuilder.php
Executable file
147
modules/ModuleBuilder/MB/ModuleBuilder.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
define ( 'MB_PACKAGE_PATH', 'custom/modulebuilder/packages' ) ;
|
||||
define ( 'MB_PACKAGE_BUILD', 'custom/modulebuilder/builds' ) ;
|
||||
require_once ('modules/ModuleBuilder/MB/MBPackage.php') ;
|
||||
|
||||
class ModuleBuilder
|
||||
{
|
||||
var $packages = array ( ) ;
|
||||
|
||||
function getPackageList ()
|
||||
{
|
||||
static $list = array ( ) ;
|
||||
if (! empty ( $list ) || ! file_exists ( MB_PACKAGE_PATH ))
|
||||
return $list ;
|
||||
$d = dir ( MB_PACKAGE_PATH ) ;
|
||||
while ( $e = $d->read () )
|
||||
{
|
||||
if (file_exists ( MB_PACKAGE_PATH . '/' . $e . '/manifest.php' ))
|
||||
{
|
||||
$list [] = $e ;
|
||||
}
|
||||
}
|
||||
sort ( $list ) ; // order important as generate_nodes_array in Tree.php later loops over this by foreach to generate the package list
|
||||
return $list ;
|
||||
|
||||
}
|
||||
|
||||
function getPackage ($name)
|
||||
{
|
||||
if (! empty ( $this->packages [ $name ] ))
|
||||
return $this->packages [ $name ] ;
|
||||
$this->packages [ $name ] = new MBPackage ( $name ) ;
|
||||
}
|
||||
|
||||
function getPackageKey ($name)
|
||||
{
|
||||
$manifestPath = MB_PACKAGE_PATH . '/' . $name . '/manifest.php' ;
|
||||
if (file_exists ( $manifestPath ))
|
||||
{
|
||||
require( $manifestPath ) ;
|
||||
if(!empty($manifest))
|
||||
return $manifest['key'];
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
function &getPackageModule ($package , $module)
|
||||
{
|
||||
$this->getPackage ( $package ) ;
|
||||
$this->packages [ $package ]->getModule ( $module ) ;
|
||||
return $this->packages [ $package ]->modules [ $module ] ;
|
||||
}
|
||||
|
||||
function save ()
|
||||
{
|
||||
$packages = array_keys ( $this->packages ) ;
|
||||
foreach ( $packages as $package )
|
||||
{
|
||||
$this->packages [ $package ]->save () ;
|
||||
}
|
||||
}
|
||||
|
||||
function build ()
|
||||
{
|
||||
$packages = array_keys ( $this->packages ) ;
|
||||
foreach ( $packages as $package )
|
||||
{
|
||||
if (count ( $packages ) == 1)
|
||||
{
|
||||
$this->packages [ $package ]->build ( true ) ;
|
||||
} else
|
||||
{
|
||||
$this->packages [ $package ]->build ( false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPackages ()
|
||||
{
|
||||
if (empty ( $this->packages ))
|
||||
{
|
||||
$list = $this->getPackageList () ;
|
||||
foreach ( $list as $package )
|
||||
{
|
||||
if (! empty ( $this->packages [ $package ] ))
|
||||
continue ;
|
||||
$this->packages [ $package ] = new MBPackage ( $package ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNodes ()
|
||||
{
|
||||
$this->getPackages () ;
|
||||
$nodes = array ( ) ;
|
||||
foreach ( array_keys ( $this->packages ) as $name )
|
||||
{
|
||||
$nodes [] = $this->packages [ $name ]->getNodes () ;
|
||||
}
|
||||
return $nodes ;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
35
modules/ModuleBuilder/MB/header.php
Executable file
35
modules/ModuleBuilder/MB/header.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
63
modules/ModuleBuilder/Module/DropDownBrowser.php
Executable file
63
modules/ModuleBuilder/Module/DropDownBrowser.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
class DropDownBrowser
|
||||
{
|
||||
|
||||
function getNodes()
|
||||
{
|
||||
global $mod_strings, $app_list_strings;
|
||||
$nodes = array();
|
||||
// $nodes[$mod_strings['LBL_EDIT_DROPDOWNS']] = array( 'name'=>$mod_strings['LBL_EDIT_DROPDOWNS'], 'action' =>'module=ModuleBuilder&action=globaldropdown&view_package=studio', 'imageTitle' => 'SPUploadCSS', 'help' => 'editDropDownBtn');
|
||||
// $nodes[$mod_strings['LBL_ADD_DROPDOWN']] = array( 'name'=>$mod_strings['LBL_ADD_DROPDOWN'], 'action'=>'module=ModuleBuilder&action=globaldropdown&view_package=studio','imageTitle' => 'SPSync', 'help' => 'addDropDownBtn');
|
||||
|
||||
$my_list_strings = $app_list_strings;
|
||||
foreach($my_list_strings as $key=>$value){
|
||||
if(!is_array($value)){
|
||||
unset($my_list_strings[$key]);
|
||||
}
|
||||
}
|
||||
$dropdowns = array_keys($my_list_strings);
|
||||
asort($dropdowns);
|
||||
foreach($dropdowns as $dd)
|
||||
{
|
||||
$nodes[$dd] = array( 'name'=>$dd, 'action'=>"module=ModuleBuilder&action=dropdown&view_package=studio&dropdown_name=$dd",'imageTitle' => 'SPSync', 'help' => 'editDropDownBtn');
|
||||
}
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
52
modules/ModuleBuilder/Module/DropDownTree.php
Executable file
52
modules/ModuleBuilder/Module/DropDownTree.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/ModuleBuilder/MB/MBPackageTree.php');
|
||||
require_once('modules/ModuleBuilder/Module/DropDownBrowser.php');
|
||||
|
||||
class DropDownTree extends MBPackageTree{
|
||||
function DropDownTree(){
|
||||
$this->tree = new Tree('package_tree');
|
||||
$this->tree->id = 'package_tree';
|
||||
$this->mb = new DropDownBrowser();
|
||||
$this->populateTree($this->mb->getNodes(), $this->tree);
|
||||
}
|
||||
|
||||
function getName(){
|
||||
return translate('LBL_SECTION_PACKAGES');
|
||||
}
|
||||
}
|
||||
?>
|
||||
47
modules/ModuleBuilder/Module/MainTree.php
Executable file
47
modules/ModuleBuilder/Module/MainTree.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/MBPackageTree.php');
|
||||
require_once('modules/ModuleBuilder/Module/StudioBrowser.php');
|
||||
class MainTree extends MBPackageTree{
|
||||
function MainTree(){
|
||||
$this->tree = new Tree('package_tree');
|
||||
$this->tree->id = 'package_tree';
|
||||
$this->mb = new StudioBrowser();
|
||||
$this->populateTree(array(), $this->tree);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
85
modules/ModuleBuilder/Module/StudioBrowser.php
Executable file
85
modules/ModuleBuilder/Module/StudioBrowser.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
|
||||
|
||||
function cmp($a,$b)
|
||||
{
|
||||
return strcasecmp($a,$b);
|
||||
}
|
||||
|
||||
class StudioBrowser{
|
||||
var $modules = array();
|
||||
|
||||
function loadModules(){
|
||||
global $current_user;
|
||||
$access = get_admin_modules_for_user($current_user);
|
||||
$d = dir('modules');
|
||||
while($e = $d->read()){
|
||||
if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
|
||||
if(file_exists('modules/' . $e . '/metadata/studio.php') && isset($GLOBALS [ 'beanList' ][$e]) && (in_array($e, $access) || is_admin($current_user))) // installed modules must also exist in the beanList
|
||||
{
|
||||
$this->modules[$e] = StudioModuleFactory::getStudioModule( $e ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadRelatableModules(){
|
||||
$d = dir('modules');
|
||||
while($e = $d->read()){
|
||||
if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
|
||||
if(file_exists('modules/' . $e . '/metadata/studio.php') && isset($GLOBALS [ 'beanList' ][$e])) // installed modules must also exist in the beanList
|
||||
{
|
||||
$this->modules[$e] = StudioModuleFactory::getStudioModule( $e ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNodes(){
|
||||
$this->loadModules();
|
||||
$nodes = array();
|
||||
foreach($this->modules as $module){
|
||||
$nodes[$module->name] = $module->getNodes();
|
||||
}
|
||||
uksort($nodes,'cmp'); // bug 15103 - order is important - this array is later looped over by foreach to generate the module list
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
415
modules/ModuleBuilder/Module/StudioModule.php
Executable file
415
modules/ModuleBuilder/Module/StudioModule.php
Executable file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class StudioModule
|
||||
{
|
||||
public $name ;
|
||||
private $popups = array ( ) ;
|
||||
public $module ;
|
||||
public $fields ;
|
||||
public $seed;
|
||||
|
||||
function __construct ($module)
|
||||
{
|
||||
$this->sources = array ( 'editviewdefs.php' => array ( 'name' => translate ('LBL_EDITVIEW') , 'type' => MB_EDITVIEW , 'image' => 'EditView' ) ,
|
||||
'detailviewdefs.php' => array ( 'name' => translate('LBL_DETAILVIEW') , 'type' => MB_DETAILVIEW , 'image' => 'DetailView' ) ,
|
||||
'listviewdefs.php' => array ( 'name' => translate('LBL_LISTVIEW') , 'type' => MB_LISTVIEW , 'image' => 'ListView' ) ) ;
|
||||
|
||||
$moduleNames = array_change_key_case ( $GLOBALS [ 'app_list_strings' ] [ 'moduleList' ] ) ;
|
||||
$this->name = isset ( $moduleNames [ strtolower ( $module ) ] ) ? $moduleNames [ strtolower ( $module ) ] : strtolower ( $module ) ;
|
||||
$this->module = $module ;
|
||||
$class = $GLOBALS [ 'beanList' ] [ $this->module ] ;
|
||||
require_once $GLOBALS [ 'beanFiles' ] [ $class ] ;
|
||||
$this->seed = new $class ( ) ;
|
||||
$this->fields = $this->seed->field_defs ;
|
||||
//$GLOBALS['log']->debug ( get_class($this)."->__construct($module): ".print_r($this->fields,true) ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the name of this module. Some modules have naming inconsistencies such as Bug Tracker and Bugs which causes warnings in Relationships
|
||||
* Added to resolve bug #20257
|
||||
*/
|
||||
function getModuleName()
|
||||
{
|
||||
$modules_with_odd_names = array(
|
||||
'Bug Tracker'=>'Bugs'
|
||||
);
|
||||
if ( isset ( $modules_with_odd_names [ $this->name ] ) )
|
||||
return ( $modules_with_odd_names [ $this->name ] ) ;
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to determine the type of a module, for example 'basic' or 'company'
|
||||
* These types are defined by the SugarObject Templates in /include/SugarObjects/templates
|
||||
* Custom modules extend one of these standard SugarObject types, so the type can be determined from their parent
|
||||
* Standard module types can be determined simply from the module name - 'bugs' for example is of type 'issue'
|
||||
* If all else fails, fall back on type 'basic'...
|
||||
* @return string Module's type
|
||||
*/
|
||||
function getType ()
|
||||
{
|
||||
// first, get a list of a possible parent types
|
||||
$templates = array () ;
|
||||
$d = dir ( 'include/SugarObjects/templates' ) ;
|
||||
while ( $filename = $d->read() )
|
||||
{
|
||||
if ( substr($filename,0,1) != '.' )
|
||||
$templates [ strtolower ( $filename) ] = strtolower ( $filename ) ;
|
||||
}
|
||||
|
||||
// If a custom module, then its type is determined by the parent SugarObject that it extends
|
||||
$type = $GLOBALS [ 'beanList' ] [ $this->module ] ;
|
||||
require_once $GLOBALS [ 'beanFiles' ] [ $type ] ;
|
||||
|
||||
do
|
||||
{
|
||||
$seed = new $type () ;
|
||||
$type = get_parent_class ($seed) ;
|
||||
} while ( ! in_array ( strtolower ( $type ) , $templates ) && $type != 'SugarBean' ) ;
|
||||
|
||||
if ( $type != 'SugarBean' )
|
||||
{
|
||||
return strtolower ( $type ) ;
|
||||
}
|
||||
|
||||
// If a standard module then just look up its type - type is implicit for standard modules. Perhaps one day we will make it explicit, just as we have done for custom modules...
|
||||
$types = array (
|
||||
'Accounts' => 'company' ,
|
||||
'Bugs' => 'issue' ,
|
||||
'Cases' => 'issue' ,
|
||||
'Contacts' => 'person' ,
|
||||
'Documents' => 'file' ,
|
||||
'Leads' => 'person' ,
|
||||
'Opportunities' => 'sale'
|
||||
) ;
|
||||
if ( isset ( $types [ $this->module ] ) )
|
||||
return $types [ $this->module ] ;
|
||||
|
||||
return "basic" ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the fields for this module as sourced from the SugarBean
|
||||
* @return Array of fields
|
||||
*/
|
||||
|
||||
function getFields ()
|
||||
{
|
||||
return $this->fields ;
|
||||
}
|
||||
|
||||
function getNodes ()
|
||||
{
|
||||
return array ( 'name' => $this->name , 'module' => $this->module , 'type' => 'StudioModule' , 'action' => "module=ModuleBuilder&action=wizard&view_module={$this->module}" , 'children' => $this->getModule() ) ;
|
||||
}
|
||||
|
||||
function getModule ()
|
||||
{
|
||||
$sources = array ( translate('LBL_LABELS') => array ( 'action' => "module=ModuleBuilder&action=editLabels&view_module={$this->module}" , 'imageTitle' => 'Labels' , 'help' => 'labelsBtn' ) ,
|
||||
translate('LBL_FIELDS') => array ( 'action' => "module=ModuleBuilder&action=modulefields&view_package=studio&view_module={$this->module}" , 'imageTitle' => 'Fields' , 'help' => 'fieldsBtn' ) ,
|
||||
translate('LBL_RELATIONSHIPS') => array ( 'action' => "get_tpl=true&module=ModuleBuilder&action=relationships&view_module={$this->module}" , 'imageTitle' => 'Relationships' , 'help' => 'relationshipsBtn' ) ,
|
||||
translate('LBL_LAYOUTS') => array ( 'children' => 'getLayouts' , 'action' => "module=ModuleBuilder&action=wizard&view=layouts&view_module={$this->module}" , 'imageTitle' => 'Layouts' , 'help' => 'layoutsBtn' ) ,
|
||||
translate('LBL_SUBPANELS') => array ( 'children' => 'getSubpanels' , 'action' => "module=ModuleBuilder&action=wizard&view=subpanels&view_module={$this->module}" , 'imageTitle' => 'Subpanels' , 'help' => 'subpanelsBtn' ) ) ;
|
||||
|
||||
$nodes = array () ;
|
||||
foreach ( $sources as $source => $def )
|
||||
{
|
||||
$nodes [ $source ] = $def ;
|
||||
$nodes [ $source ] [ 'name' ] = translate ( $source ) ;
|
||||
if ( isset ( $def [ 'children' ] ) )
|
||||
{
|
||||
$childNodes = $this->$def [ 'children' ] () ;
|
||||
if ( !empty ( $childNodes ) )
|
||||
{
|
||||
$nodes [ $source ] [ 'type' ] = 'Folder' ;
|
||||
$nodes [ $source ] [ 'children' ] = $childNodes ;
|
||||
}
|
||||
else
|
||||
unset ( $nodes [ $source ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return $nodes ;
|
||||
}
|
||||
|
||||
function getViews() {
|
||||
$views = array () ;
|
||||
foreach ( $this->sources as $file => $def )
|
||||
{
|
||||
if (file_exists ( "modules/{$this->module}/metadata/$file" ))
|
||||
{
|
||||
$views [ str_replace ( '.php', '' , $file) ] = $def ;
|
||||
}
|
||||
}
|
||||
return $views;
|
||||
}
|
||||
|
||||
function getLayouts()
|
||||
{
|
||||
$views = $this->getViews();
|
||||
|
||||
// Now add in the QuickCreates - quickcreatedefs can be created by Studio from editviewdefs if they are absent, so just add them in regardless of whether the quickcreatedefs file exists
|
||||
|
||||
$hideQuickCreateForModules = array ( 'kbdocuments' , 'projecttask' ,
|
||||
'campaigns'
|
||||
) ;
|
||||
// Some modules should not have a QuickCreate form at all, so do not add them to the list
|
||||
if (! in_array ( strtolower ( $this->module ), $hideQuickCreateForModules ))
|
||||
$views [ 'quickcreatedefs' ] = array ( 'name' => translate('LBL_QUICKCREATE') , 'type' => MB_QUICKCREATE , 'image' => 'QuickCreate' ) ;
|
||||
|
||||
$layouts = array ( ) ;
|
||||
foreach ( $views as $def )
|
||||
{
|
||||
$layouts [ $def['name'] ] = array ( 'name' => $def['name'] , 'action' => "module=ModuleBuilder&action=editLayout&view={$def['type']}&view_module={$this->module}" , 'imageTitle' => $def['image'] , 'help' => "viewBtn{$def['type']}" , 'size' => '48' ) ;
|
||||
}
|
||||
|
||||
if($this->isValidDashletModule($this->module)){
|
||||
$dashlets = array( );
|
||||
$dashlets [] = array('name' => translate('LBL_DASHLETLISTVIEW') , 'type' => 'dashlet' , 'action' => 'module=ModuleBuilder&action=editLayout&view=dashlet&view_module=' . $this->module );
|
||||
$dashlets [] = array('name' => translate('LBL_DASHLETSEARCHVIEW') , 'type' => 'dashletsearch' , 'action' => 'module=ModuleBuilder&action=editLayout&view=dashletsearch&view_module=' . $this->module );
|
||||
$layouts [ translate('LBL_DASHLET') ] = array ( 'name' => translate('LBL_DASHLET') , 'type' => 'Folder', 'children' => $dashlets, 'imageTitle' => 'Dashlet', 'action' => 'module=ModuleBuilder&action=wizard&view=dashlet&view_module=' . $this->module);
|
||||
}
|
||||
|
||||
//For popup tree node
|
||||
$popups = array( );
|
||||
$popups [] = array('name' => translate('LBL_POPUPLISTVIEW') , 'type' => 'popuplistview' , 'action' => 'module=ModuleBuilder&action=editLayout&view=popuplist&view_module=' . $this->module );
|
||||
$popups [] = array('name' => translate('LBL_POPUPSEARCH') , 'type' => 'popupsearch' , 'action' => 'module=ModuleBuilder&action=editLayout&view=popupsearch&view_module=' . $this->module );
|
||||
$layouts [ translate('LBL_POPUP') ] = array ( 'name' => translate('LBL_POPUP') , 'type' => 'Folder', 'children' => $popups, 'imageTitle' => 'Popup', 'imageName' => 'icon_Popup.gif', 'action' => 'module=ModuleBuilder&action=wizard&view=popup&view_module=' . $this->module);
|
||||
|
||||
$nodes = $this->getSearch () ;
|
||||
if ( !empty ( $nodes ) )
|
||||
{
|
||||
$layouts [ translate('LBL_SEARCH') ] = array ( 'name' => translate('LBL_SEARCH') , 'type' => 'Folder' , 'children' => $nodes , 'action' => "module=ModuleBuilder&action=wizard&view=search&view_module={$this->module}" , 'imageTitle' => 'SearchForm' , 'help' => 'searchBtn' , 'size' => '48') ;
|
||||
}
|
||||
|
||||
return $layouts ;
|
||||
|
||||
}
|
||||
|
||||
function isValidDashletModule($moduleName){
|
||||
$fileName = "My{$moduleName}Dashlet";
|
||||
$customFileName = "{$moduleName}Dashlet";
|
||||
if (file_exists ( "modules/{$moduleName}/Dashlets/{$fileName}/{$fileName}.php" )
|
||||
|| file_exists ( "custom/modules/{$moduleName}/Dashlets/{$fileName}/{$fileName}.php" )
|
||||
|| file_exists ( "modules/{$moduleName}/Dashlets/{$customFileName}/{$customFileName}.php" )
|
||||
|| file_exists ( "custom/modules/{$moduleName}/Dashlets/{$customFileName}/{$customFileName}.php" ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getSearch ()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php') ;
|
||||
|
||||
$nodes = array () ;
|
||||
foreach ( array ( MB_BASICSEARCH => 'LBL_BASIC_SEARCH' , MB_ADVANCEDSEARCH => 'LBL_ADVANCED_SEARCH' ) as $view => $label )
|
||||
{
|
||||
try
|
||||
{
|
||||
$parser = new SearchViewMetaDataParser ( $view , $this->module ) ;
|
||||
$title = translate ( $label ) ;
|
||||
if($label == 'LBL_BASIC_SEARCH'){
|
||||
$name = 'BasicSearch';
|
||||
}elseif($label == 'LBL_ADVANCED_SEARCH'){
|
||||
$name = 'AdvancedSearch';
|
||||
}else{
|
||||
$name = str_replace ( ' ', '', $title ) ;
|
||||
}
|
||||
$nodes [ $title ] = array ( 'name' => $title , 'action' => "module=ModuleBuilder&action=editLayout&view={$view}&view_module={$this->module}" , 'imageTitle' => $title , 'imageName' => $name , 'help' => "{$name}Btn" , 'size' => '48' ) ;
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info( 'No search layout : '. $e->getMessage() ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return $nodes ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return an object containing all the relationships participated in by this module
|
||||
* @return AbstractRelationships Set of relationships
|
||||
*/
|
||||
function getRelationships ()
|
||||
{
|
||||
return new DeployedRelationships ( $this->module ) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a list of subpanels used by the current module
|
||||
*/
|
||||
function getSubpanels ()
|
||||
{
|
||||
if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
|
||||
$GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
|
||||
|
||||
require_once ('include/SubPanel/SubPanel.php') ;
|
||||
|
||||
$nodes = array ( ) ;
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( "StudioModule->getSubpanels(): getting subpanels for " . $this->module ) ;
|
||||
|
||||
foreach ( SubPanel::getModuleSubpanels ( $this->module ) as $name => $label )
|
||||
{
|
||||
if ($name == 'users')
|
||||
continue ;
|
||||
$subname = sugar_ucfirst ( (! empty ( $label )) ? translate ( $label, $this->module ) : $name ) ;
|
||||
$nodes [ $subname ] = array ( 'name' => $name , 'label' => $subname , 'action' => "module=ModuleBuilder&action=editLayout&view=ListView&view_module={$this->module}&subpanel={$name}&subpanelLabel={$subname}" , 'imageTitle' => $subname , 'imageName' => $name, 'altImageName' => 'Subpanels', 'size' => '48' ) ;
|
||||
}
|
||||
|
||||
return $nodes ;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a list of subpanels provided to other modules
|
||||
*
|
||||
*
|
||||
*/
|
||||
function getProvidedSubpanels ()
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
$this->providedSubpanels = array () ;
|
||||
$subpanelDir = 'modules/' . $this->module . '/metadata/subpanels/' ;
|
||||
foreach(array($subpanelDir, "custom/$subpanelDir") as $dir)
|
||||
{
|
||||
if (is_dir ( $dir ))
|
||||
{
|
||||
foreach(scandir($dir) as $fileName)
|
||||
{
|
||||
// sanity check to confirm that this is a usable subpanel...
|
||||
if (substr ( $fileName, 0, 1 ) != '.' && substr ( strtolower($fileName), -4 ) == ".php"
|
||||
&& AbstractRelationships::validSubpanel ( "$dir/$fileName" ))
|
||||
{
|
||||
$subname = str_replace ( '.php', '', $fileName ) ;
|
||||
$this->providedSubpanels [ $subname ] = $subname ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->providedSubpanels;
|
||||
}
|
||||
|
||||
|
||||
function getParentModulesOfSubpanel($subpanel){
|
||||
global $moduleList, $beanFiles, $beanList, $module;
|
||||
|
||||
//use tab controller function to get module list with named keys
|
||||
require_once("modules/MySettings/TabController.php");
|
||||
require_once("include/SubPanel/SubPanelDefinitions.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);
|
||||
|
||||
$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) ;
|
||||
if ( isset($spd->layout_defs['subpanel_setup'][strtolower($subpanel)]['module']) ){
|
||||
$spd_arr[] = $mod_name;
|
||||
}
|
||||
}
|
||||
return $spd_arr;
|
||||
}
|
||||
|
||||
function removeFieldFromLayouts ( $fieldName )
|
||||
{
|
||||
require_once("modules/ModuleBuilder/parsers/ParserFactory.php");
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->removeFieldFromLayouts($fieldName)" ) ;
|
||||
$sources = $this->getViewMetadataSources();
|
||||
$sources[] = array('type' => MB_BASICSEARCH);
|
||||
$sources[] = array('type' => MB_ADVANCEDSEARCH);
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( print_r( $sources,true) ) ;
|
||||
foreach ( $sources as $name => $defs )
|
||||
{
|
||||
$parser = ParserFactory::getParser( $defs [ 'type' ] , $this->module ) ;
|
||||
if ($parser->removeField ( $fieldName ) )
|
||||
$parser->handleSave(false) ; // don't populate from $_REQUEST, just save as is...
|
||||
}
|
||||
|
||||
//Remove the fields in subpanel
|
||||
$data = $this->getParentModulesOfSubpanel($this->module);
|
||||
foreach($data as $parentModule){
|
||||
$parser = ParserFactory::getParser( MB_LISTVIEW , $parentModule, null , $this->module) ;
|
||||
if ($parser->removeField ( $fieldName ) )
|
||||
$parser->handleSave(false) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getViewMetadataSources() {
|
||||
$sources = $this->getViews();
|
||||
$sources[] = array('type' => MB_BASICSEARCH);
|
||||
$sources[] = array('type' => MB_ADVANCEDSEARCH);
|
||||
$sources[] = array('type' => MB_DASHLET);
|
||||
$sources[] = array('type' => MB_DASHLETSEARCH);
|
||||
$sources[] = array('type' => MB_POPUPLIST);
|
||||
$sources[] = array('type' => MB_QUICKCREATE);
|
||||
|
||||
return $sources;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
54
modules/ModuleBuilder/Module/StudioModuleFactory.php
Executable file
54
modules/ModuleBuilder/Module/StudioModuleFactory.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once 'modules/ModuleBuilder/Module/StudioModule.php' ;
|
||||
|
||||
class StudioModuleFactory
|
||||
{
|
||||
function getStudioModule($module)
|
||||
{
|
||||
$studioModClass = "{$module}StudioModule";
|
||||
if (file_exists("modules/{$module}/{$studioModClass}.php"))
|
||||
{
|
||||
require_once "modules/{$module}/{$studioModClass}.php";
|
||||
return new $studioModClass($module);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StudioModule($module);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
51
modules/ModuleBuilder/Module/StudioTree.php
Executable file
51
modules/ModuleBuilder/Module/StudioTree.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/MBPackageTree.php');
|
||||
require_once('modules/ModuleBuilder/Module/StudioBrowser.php');
|
||||
class StudioTree extends MBPackageTree{
|
||||
function StudioTree(){
|
||||
$this->tree = new Tree('package_tree');
|
||||
$this->tree->id = 'package_tree';
|
||||
$this->mb = new StudioBrowser();
|
||||
$this->populateTree($this->mb->getNodes(), $this->tree);
|
||||
}
|
||||
|
||||
function getName(){
|
||||
return translate('LBL_SECTION_MODULES');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
74
modules/ModuleBuilder/action_view_map.php
Executable file
74
modules/ModuleBuilder/action_view_map.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on May 14, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
//format '<action_name>' => '<view_name>',
|
||||
$action_view_map = array(
|
||||
'index' => 'main',
|
||||
'module'=>'module',
|
||||
'modulefields'=>'modulefields',
|
||||
'modulelabels'=>'modulelabels',
|
||||
'relationships'=>'relationships',
|
||||
'relationship'=>'relationship',
|
||||
'resetmodule'=>'resetmodule',
|
||||
'modulefield'=>'modulefield',
|
||||
'displaydeploy'=>'displaydeploy',
|
||||
'package'=>'package',
|
||||
'dropdown'=>'dropdown',
|
||||
'dropdowns'=>'dropdowns',
|
||||
'detailview' => 'detail',
|
||||
'editview' => 'edit',
|
||||
'popup' => 'popup',
|
||||
'home'=>'home',
|
||||
'visibilityeditor' => 'visibilityeditor',
|
||||
'exportcustomizations'=>'exportcustomizations',
|
||||
|
||||
);
|
||||
// add those we need from the global action_view_map
|
||||
$action_view_map['dc'] = 'dc';
|
||||
$action_view_map['dcajax'] = 'dcajax';
|
||||
$action_view_map['quick'] = 'quick';
|
||||
$action_view_map['quickcreate'] = 'quickcreate';
|
||||
$action_view_map['spot'] = 'spot';
|
||||
$action_view_map['inlinefield'] = 'inlinefield';
|
||||
$action_view_map['inlinefieldsave'] = 'inlinefieldsave';
|
||||
$action_view_map['pluginlist'] = 'plugins';
|
||||
$action_view_map['downloadplugin'] = 'downloadplugin';
|
||||
?>
|
||||
717
modules/ModuleBuilder/controller.php
Executable file
717
modules/ModuleBuilder/controller.php
Executable file
@@ -0,0 +1,717 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class ModuleBuilderController extends SugarController
|
||||
{
|
||||
var $action_remap = array ( ) ;
|
||||
|
||||
function fromModuleBuilder ()
|
||||
{
|
||||
return (isset ( $_REQUEST [ 'MB' ] ) && ($_REQUEST [ 'MB' ] == '1')) ;
|
||||
}
|
||||
|
||||
function process(){
|
||||
$GLOBALS [ 'log' ]->info ( get_class($this).":" ) ;
|
||||
global $current_user;
|
||||
$access = get_admin_modules_for_user($current_user);
|
||||
if(is_admin($current_user) || (is_admin_for_any_module($current_user) && !isset($_REQUEST['view_module']) && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'package'))||
|
||||
(isset($_REQUEST['view_module']) && (in_array($_REQUEST['view_module'], $access)|| empty($_REQUEST['view_module']))) ||
|
||||
(isset($_REQUEST['type']) && (($_REQUEST['type']=='dropdowns' && is_admin_for_any_module($current_user))||
|
||||
($_REQUEST['type']=='studio' && displayStudioForCurrentUser() == true))))
|
||||
{
|
||||
$this->hasAccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hasAccess = false;
|
||||
}
|
||||
parent::process();
|
||||
}
|
||||
|
||||
|
||||
function action_editLayout ()
|
||||
{
|
||||
switch ( strtolower ( $_REQUEST [ 'view' ] ))
|
||||
{
|
||||
case MB_EDITVIEW :
|
||||
case MB_DETAILVIEW :
|
||||
case MB_QUICKCREATE :
|
||||
$this->view = 'layoutView' ;
|
||||
break ;
|
||||
case MB_LISTVIEW :
|
||||
$this->view = 'listView' ;
|
||||
break ;
|
||||
case MB_BASICSEARCH :
|
||||
case MB_ADVANCEDSEARCH :
|
||||
$this->view = 'searchView' ;
|
||||
break ;
|
||||
case MB_DASHLET :
|
||||
case MB_DASHLETSEARCH :
|
||||
$this->view = 'dashlet' ;
|
||||
break ;
|
||||
case MB_POPUPLIST :
|
||||
case MB_POPUPSEARCH :
|
||||
$this->view = 'popupview' ;
|
||||
break ;
|
||||
default :
|
||||
$GLOBALS [ 'log' ]->fatal ( 'Action = editLayout with unknown view=' . $_REQUEST [ 'view' ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function action_ViewTree ()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
switch ( $_REQUEST [ 'tree' ])
|
||||
{
|
||||
case 'ModuleBuilder' :
|
||||
require_once ('modules/ModuleBuilder/MB/MBPackageTree.php') ;
|
||||
$mbt = new MBPackageTree ( ) ;
|
||||
break ;
|
||||
case 'Studio' :
|
||||
require_once ('modules/ModuleBuilder/Module/StudioTree.php') ;
|
||||
$mbt = new StudioTree ( ) ;
|
||||
}
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
$ajax->addSection ( 'west', $mbt->getName (), $mbt->fetchNodes () ) ;
|
||||
echo $ajax->getJavascript () ;
|
||||
|
||||
sugar_cleanup ( true ) ;
|
||||
|
||||
}
|
||||
|
||||
function action_SavePackage ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
|
||||
if (! empty ( $load ))
|
||||
{
|
||||
$mb->getPackage ( $load ) ;
|
||||
|
||||
if (! empty ( $_REQUEST [ 'duplicate' ] ))
|
||||
{
|
||||
$result = $mb->packages [ $load ]->copy ( $_REQUEST [ 'name' ] ) ;
|
||||
$load = $mb->packages [ $load ]->name ;
|
||||
$mb->getPackage ( $load ) ;
|
||||
}
|
||||
$mb->packages [ $load ]->populateFromPost () ;
|
||||
$mb->packages [ $load ]->loadModules () ;
|
||||
$mb->save () ;
|
||||
if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
|
||||
{
|
||||
if (! $mb->packages [ $load ]->rename ( $_REQUEST [ 'name' ] ))
|
||||
{
|
||||
$mb->packages [ $load ]->name = $_REQUEST [ 'original_name' ] ;
|
||||
$_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
|
||||
}
|
||||
}
|
||||
$_REQUEST [ 'package' ] = $_REQUEST [ 'name' ] ;
|
||||
$this->view = 'package' ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_BuildPackage ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$load = $_REQUEST [ 'name' ] ;
|
||||
if (! empty ( $load ))
|
||||
{
|
||||
$mb->getPackage ( $load ) ;
|
||||
$mb->packages [ $load ]->build () ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_DeployPackage ()
|
||||
{
|
||||
if(defined('TEMPLATE_URL')){
|
||||
sugar_cache_reset();
|
||||
SugarTemplateUtilities::disableCache();
|
||||
}
|
||||
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$load = $_REQUEST [ 'package' ] ;
|
||||
$message = $GLOBALS [ 'mod_strings' ] [ 'LBL_MODULE_DEPLOYED' ] ;
|
||||
if (! empty ( $load ))
|
||||
{
|
||||
$zip = $mb->getPackage ( $load ) ;
|
||||
require_once ('ModuleInstall/PackageManager/PackageManager.php') ;
|
||||
$pm = new PackageManager ( ) ;
|
||||
$info = $mb->packages [ $load ]->build ( false ) ;
|
||||
mkdir_recursive ( $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/upload/upgrades/module/') ;
|
||||
rename ( $info [ 'zip' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ) ;
|
||||
copy ( $info [ 'manifest' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '-manifest.php' ) ;
|
||||
$_REQUEST [ 'install_file' ] = $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ;
|
||||
$GLOBALS [ 'mi_remove_tables' ] = false ;
|
||||
$pm->performUninstall ( $load ) ;
|
||||
//#23177 , js cache clear
|
||||
clearAllJsAndJsLangFilesWithoutOutput();
|
||||
//#30747, clear the cache in memoy
|
||||
$cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
|
||||
sugar_cache_clear($cache_key );
|
||||
sugar_cache_reset();
|
||||
//clear end
|
||||
$pm->performInstall ( $_REQUEST [ 'install_file' ] , true) ;
|
||||
}
|
||||
echo 'complete' ;
|
||||
|
||||
}
|
||||
|
||||
function action_ExportPackage ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$load = $_REQUEST [ 'name' ] ;
|
||||
$author = $_REQUEST [ 'author' ] ;
|
||||
$description = $_REQUEST [ 'description' ] ;
|
||||
$readme = $_REQUEST [ 'readme' ] ;
|
||||
if (! empty ( $load ))
|
||||
{
|
||||
$mb->getPackage ( $load ) ;
|
||||
$mb->packages [ $load ]->author = $author ;
|
||||
$mb->packages [ $load ]->description = $description ;
|
||||
$mb->packages [ $load ]->exportProject () ;
|
||||
$mb->packages [ $load ]->readme = $readme ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_DeletePackage ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$mb->getPackage ( $_REQUEST [ 'package' ] ) ;
|
||||
$mb->packages [ $_REQUEST [ 'package' ] ]->delete () ;
|
||||
$this->view = 'deletepackage' ;
|
||||
}
|
||||
|
||||
function action_SaveModule ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
|
||||
if (! empty ( $load ))
|
||||
{
|
||||
$mb->getPackage ( $_REQUEST [ 'package' ] ) ;
|
||||
$mb->packages [ $_REQUEST [ 'package' ] ]->getModule ( $load ) ;
|
||||
$module = & $mb->packages [ $_REQUEST [ 'package' ] ]->modules [ $load ] ;
|
||||
$module->populateFromPost () ;
|
||||
$mb->save () ;
|
||||
if (! empty ( $_REQUEST [ 'duplicate' ] ))
|
||||
{
|
||||
$module->copy ( $_REQUEST [ 'name' ] ) ;
|
||||
} else if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
|
||||
{
|
||||
if (! $module->rename ( $_REQUEST [ 'name' ] ))
|
||||
{
|
||||
$module->name = $_REQUEST [ 'original_name' ] ;
|
||||
$_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
|
||||
}
|
||||
}
|
||||
|
||||
$_REQUEST [ 'view_package' ] = $_REQUEST [ 'package' ] ;
|
||||
$_REQUEST [ 'view_module' ] = $module->name ;
|
||||
$this->view = 'module' ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_DeleteModule ()
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$module->delete () ;
|
||||
$this->view = 'package' ;
|
||||
}
|
||||
|
||||
function action_saveLabels ()
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
$parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
$parser->handleSave ( $_REQUEST, $_REQUEST [ 'selected_lang' ] ) ;
|
||||
if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
|
||||
{
|
||||
$this->view = 'modulelabels' ;
|
||||
} else //STUDIO
|
||||
{
|
||||
$this->view = isset ( $_REQUEST [ 'view' ] ) ? 'edit' : 'labels' ; // detect if we are being called by the LayoutEditor rather than the LabelEditor (set in view.layoutlabel.php)
|
||||
}
|
||||
}
|
||||
|
||||
function action_SaveLabel ()
|
||||
{
|
||||
if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
|
||||
{
|
||||
$_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
$parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
$parser->handleSave ( $_REQUEST, $GLOBALS [ 'current_language' ] ) ;
|
||||
|
||||
}
|
||||
$this->view = 'modulefields' ;
|
||||
}
|
||||
|
||||
function action_ExportCustom ()
|
||||
{
|
||||
$modules = $_REQUEST [ 'modules' ] ;
|
||||
$name = $_REQUEST [ 'name' ] ;
|
||||
$author = $_REQUEST [ 'author' ] ;
|
||||
$description = $_REQUEST [ 'description' ] ;
|
||||
ob_clean () ;
|
||||
if (! empty ( $modules ) && ! empty ( $name ))
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
$mb = new MBPackage ( $name ) ;
|
||||
$mb->author = $author ;
|
||||
$mb->description = $description ;
|
||||
$mb->exportCustom ( $modules, true, true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_SaveField ()
|
||||
{
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$field = get_widget ( $_REQUEST [ 'type' ] ) ;
|
||||
$_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
|
||||
|
||||
$field->populateFromPost () ;
|
||||
|
||||
if (!isset ( $_REQUEST [ 'view_package' ] ))
|
||||
{
|
||||
require_once ('modules/DynamicFields/DynamicField.php') ;
|
||||
if (! empty ( $_REQUEST [ 'view_module' ] ))
|
||||
{
|
||||
$module = $_REQUEST [ 'view_module' ] ;
|
||||
$df = new DynamicField ( $module ) ;
|
||||
$class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
|
||||
require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
|
||||
$mod = new $class_name ( ) ;
|
||||
$df->setup ( $mod ) ;
|
||||
|
||||
$field->save ( $df ) ;
|
||||
$this->action_SaveLabel () ;
|
||||
include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
global $mod_strings;
|
||||
$mod_strings['LBL_ALL_MODULES'] = 'all_modules';
|
||||
$repair = new RepairAndClear();
|
||||
$repair->show_output = false;
|
||||
$repair->module_list = array($class_name);
|
||||
$repair->repairDatabase();
|
||||
$repair->clearVardefs();
|
||||
$repair->clearTpls();
|
||||
//#28707 ,clear all the js files in cache
|
||||
$repair->module_list = array();
|
||||
$repair->clearJsFiles();
|
||||
}
|
||||
} else
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$field->save ( $module ) ;
|
||||
$module->mbvardefs->save () ;
|
||||
// get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
|
||||
$module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
|
||||
$module->save();
|
||||
}
|
||||
$this->view = 'modulefields' ;
|
||||
}
|
||||
|
||||
function action_saveSugarField ()
|
||||
{
|
||||
global $mod_strings;
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$field = get_widget ( $_REQUEST [ 'type' ] ) ;
|
||||
$_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
|
||||
|
||||
$field->populateFromPost () ;
|
||||
require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
|
||||
$module = $_REQUEST [ 'view_module' ] ;
|
||||
$df = new StandardField ( $module ) ;
|
||||
$class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
|
||||
require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
|
||||
$mod = new $class_name ( ) ;
|
||||
$df->setup ( $mod ) ;
|
||||
|
||||
$field->module = $mod;
|
||||
$field->save ( $df ) ;
|
||||
$this->action_SaveLabel () ;
|
||||
|
||||
$MBmodStrings = $mod_strings;
|
||||
$GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
|
||||
|
||||
include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
$GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
|
||||
$_REQUEST['execute_sql'] = true;
|
||||
|
||||
$repair = new RepairAndClear();
|
||||
$repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
|
||||
//#28707 ,clear all the js files in cache
|
||||
$repair->module_list = array();
|
||||
$repair->clearJsFiles();
|
||||
|
||||
|
||||
// now clear the cache so that the results are immediately visible
|
||||
include_once ('include/TemplateHandler/TemplateHandler.php') ;
|
||||
TemplateHandler::clearCache ( $module ) ;
|
||||
|
||||
$GLOBALS [ 'mod_strings' ] = $MBmodStrings;
|
||||
}
|
||||
|
||||
function action_RefreshField ()
|
||||
{
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$field = get_widget ( $_POST [ 'type' ] ) ;
|
||||
$field->populateFromPost () ;
|
||||
$this->view = 'modulefield' ;
|
||||
}
|
||||
|
||||
function action_saveVisibility ()
|
||||
{
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( MB_VISIBILITY, $_REQUEST [ 'view_module' ], $packageName ) ;
|
||||
|
||||
$json = getJSONobj();
|
||||
$visibility_grid = $json->decode(html_entity_decode(rawurldecode($_REQUEST [ 'visibility_grid' ]), ENT_QUOTES) );
|
||||
$parser->saveVisibility ( $_REQUEST [ 'fieldname' ] , $_REQUEST [ 'trigger' ] , $visibility_grid ) ;
|
||||
|
||||
echo $json->encode(array( "visibility_editor_{$_REQUEST['fieldname']}" => array("action" => "deactivate")));
|
||||
}
|
||||
|
||||
function action_SaveRelationshipLabel (){
|
||||
$selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
|
||||
if (empty($_REQUEST [ 'view_package' ])){
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
$relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
|
||||
if (! empty ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
if ($relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] )){
|
||||
$metadata = $relationship->buildLabels(true);
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
$parser = new ParserLabel ( $_REQUEST['view_module'] ) ;
|
||||
$parser->handleSaveRelationshipLabels ( $metadata, $selected_lang ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//TODO FOR MB
|
||||
}
|
||||
$this->view = 'relationships' ;
|
||||
}
|
||||
|
||||
function action_SaveRelationship ()
|
||||
{
|
||||
if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
|
||||
{
|
||||
$GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
|
||||
}
|
||||
|
||||
if (empty($_REQUEST [ 'view_package' ]))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
$relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
|
||||
} else
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
|
||||
$relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
|
||||
}
|
||||
|
||||
$relationships->addFromPost () ;
|
||||
$relationships->save () ;
|
||||
$GLOBALS['log']->debug("\n\nSTART BUILD");
|
||||
if (empty($_REQUEST [ 'view_package' ])) {
|
||||
$relationships->build () ;
|
||||
|
||||
LanguageManager::clearLanguageCache($_REQUEST [ 'view_module' ]);
|
||||
}
|
||||
$GLOBALS['log']->debug("\n\nEND BUILD");
|
||||
|
||||
$this->view = 'relationships' ;
|
||||
}
|
||||
|
||||
function action_DeleteRelationship ()
|
||||
{
|
||||
if (isset ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
if (empty($_REQUEST [ 'view_package' ] ))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
if (!empty($_REQUEST['remove_tables']))
|
||||
$GLOBALS['mi_remove_tables'] = $_REQUEST['remove_tables'];
|
||||
$relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
|
||||
} else
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
|
||||
$relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
|
||||
}
|
||||
$relationships->delete ( $_REQUEST [ 'relationship_name' ] ) ;
|
||||
$relationships->save () ;
|
||||
}
|
||||
$this->view = 'relationships' ;
|
||||
}
|
||||
|
||||
function action_SaveDropDown ()
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php' ;
|
||||
$parser = new ParserDropDown ( ) ;
|
||||
$parser->saveDropDown ( $_REQUEST ) ;
|
||||
$this->view = 'dropdowns' ;
|
||||
}
|
||||
|
||||
function action_DeleteField ()
|
||||
{
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$field = get_widget ( $_POST [ 'type' ] ) ;
|
||||
$field->name = $_REQUEST [ 'name' ] ;
|
||||
if (!isset ( $_REQUEST [ 'view_package' ] ))
|
||||
{
|
||||
if (! empty ( $_REQUEST [ 'name' ] ) && ! empty ( $_REQUEST [ 'view_module' ] ))
|
||||
{
|
||||
require_once ('modules/DynamicFields/DynamicField.php') ;
|
||||
$moduleName = $_REQUEST [ 'view_module' ] ;
|
||||
$class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
|
||||
require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
|
||||
$seed = new $class_name ( ) ;
|
||||
$df = new DynamicField ( $moduleName ) ;
|
||||
$df->setup ( $seed ) ;
|
||||
//Need to load the entire field_meta_data for some field types
|
||||
$field = $df->getFieldWidget($moduleName, $field->name);
|
||||
$field->delete ( $df ) ;
|
||||
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
|
||||
$module = StudioModuleFactory::getStudioModule( $moduleName ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$field->delete ( $module ) ;
|
||||
$mb->save () ;
|
||||
}
|
||||
$module->removeFieldFromLayouts( $field->name );
|
||||
$this->view = 'modulefields' ;
|
||||
}
|
||||
|
||||
function action_CloneField ()
|
||||
{
|
||||
$this->view_object_map [ 'field_name' ] = $_REQUEST [ 'name' ] ;
|
||||
$this->view_object_map [ 'is_clone' ] = true ;
|
||||
$this->view = 'modulefield' ;
|
||||
}
|
||||
|
||||
function action_SaveAssistantPref ()
|
||||
{
|
||||
global $current_user ;
|
||||
if (isset ( $_REQUEST [ 'pref_value' ] ))
|
||||
{
|
||||
if ($_REQUEST [ 'pref_value' ] == 'ignore')
|
||||
{
|
||||
$current_user->setPreference ( 'mb_assist', 'DISABLED', 0, 'Assistant' ) ;
|
||||
} else
|
||||
{
|
||||
$current_user->setPreference ( 'mb_assist', 'ENABLED', 0, 'Assistant' ) ;
|
||||
}
|
||||
$current_pref = $current_user->getPreference ( 'mb_assist', 'Assistant' ) ;
|
||||
echo "Assistant.processUserPref('$current_pref')" ;
|
||||
sugar_cleanup ( true ) ; //push preferences to DB.
|
||||
}
|
||||
}
|
||||
|
||||
// Studio2 Actions
|
||||
|
||||
|
||||
function action_EditProperty ()
|
||||
{
|
||||
$this->view = 'property' ;
|
||||
}
|
||||
|
||||
function action_saveProperty ()
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
$modules = $_REQUEST['view_module'];
|
||||
if(!empty($_REQUEST['subpanel'])){
|
||||
$modules = $_REQUEST['subpanel'];
|
||||
}
|
||||
$parser = new ParserLabel ( $modules , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
// if no language provided, then use the user's current language which is most likely what they intended
|
||||
$language = (isset($_REQUEST [ 'selected_lang' ])) ? $_REQUEST [ 'selected_lang' ] : $GLOBALS['current_language'] ;
|
||||
$parser->handleSave ( $_REQUEST, $language ) ;
|
||||
$json = getJSONobj();
|
||||
echo $json->encode(array("east" => array("action" => "deactivate")));
|
||||
}
|
||||
|
||||
function action_editModule ()
|
||||
{
|
||||
$this->view = 'module' ;
|
||||
}
|
||||
|
||||
function action_wizard ()
|
||||
{
|
||||
$this->view = 'wizard' ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive a layout through $_REQUEST and save it out to the working files directory
|
||||
* Expects a series of $_REQUEST parameters all in the format $_REQUEST['slot-panel#-slot#-property']=value
|
||||
*/
|
||||
|
||||
function action_saveLayout ()
|
||||
{
|
||||
$parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
$this->view = 'layoutview' ;
|
||||
$parser->writeWorkingFile () ;
|
||||
}
|
||||
|
||||
function action_saveAndPublishLayout ()
|
||||
{
|
||||
$parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
$this->view = 'layoutview' ;
|
||||
$parser->handleSave () ;
|
||||
}
|
||||
|
||||
function action_manageBackups ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function action_listViewSave ()
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( "action_listViewSave" ) ;
|
||||
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
$subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName, $subpanelName ) ;
|
||||
$this->view = 'listView' ;
|
||||
$parser->handleSave () ;
|
||||
|
||||
}
|
||||
|
||||
function action_dashletSave () {
|
||||
$this->view = 'dashlet' ;
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
|
||||
$parser->handleSave () ;
|
||||
}
|
||||
|
||||
function action_popupSave(){
|
||||
$this->view = 'popupview' ;
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
|
||||
$parser->handleSave () ;
|
||||
if(empty($packageName)){
|
||||
include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
global $mod_strings;
|
||||
$mod_strings['LBL_ALL_MODULES'] = 'all_modules';
|
||||
$repair = new RepairAndClear();
|
||||
$repair->show_output = false;
|
||||
$class_name = $GLOBALS [ 'beanList' ] [ $_REQUEST [ 'view_module' ] ] ;
|
||||
$repair->module_list = array($class_name);
|
||||
$repair->clearTpls();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function action_searchViewSave ()
|
||||
{
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
|
||||
$parser = new SearchViewMetaDataParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
|
||||
$parser->handleSave () ;
|
||||
$this->view = 'searchView' ;
|
||||
}
|
||||
|
||||
function action_editLabels ()
|
||||
{
|
||||
if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
|
||||
{
|
||||
$this->view = 'modulelabels';
|
||||
}else{ //STUDIO
|
||||
$this->view = 'labels';
|
||||
}
|
||||
}
|
||||
|
||||
function action_get_app_list_string ()
|
||||
{
|
||||
require_once ('include/JSON.php') ;
|
||||
$json = new JSON ( ) ;
|
||||
if (isset ( $_REQUEST [ 'key' ] ) && ! empty ( $_REQUEST [ 'key' ] ))
|
||||
{
|
||||
$key = $_REQUEST [ 'key' ] ;
|
||||
$value = array ( ) ;
|
||||
if (! empty ( $GLOBALS [ 'app_list_strings' ] [ $key ] ))
|
||||
{
|
||||
$value = $GLOBALS [ 'app_list_strings' ] [ $key ] ;
|
||||
} else
|
||||
{
|
||||
$package_strings = array ( ) ;
|
||||
if (! empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio' && ! empty ( $_REQUEST [ 'view_module' ] ))
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$lang = $GLOBALS [ 'current_language' ] ;
|
||||
$module->mblanguage->generateAppStrings ( false ) ;
|
||||
$package_strings = $module->mblanguage->appListStrings [ $lang . '.lang.php' ] ;
|
||||
if (isset ( $package_strings [ $key ] ) && is_array ( $package_strings [ $key ] ))
|
||||
{
|
||||
$value = $package_strings [ $key ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $json->encode ( $value ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function action_history ()
|
||||
{
|
||||
$this->view = 'history' ;
|
||||
}
|
||||
|
||||
function resetmodule()
|
||||
{
|
||||
$this->view = 'resetmodule';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
685
modules/ModuleBuilder/language/en_us.lang.php
Executable file
685
modules/ModuleBuilder/language/en_us.lang.php
Executable file
@@ -0,0 +1,685 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array(
|
||||
'help'=>array(
|
||||
'package'=>array(
|
||||
'create'=>'Provide a <b>Name</b> for the package. The name you enter must be alphanumeric and contain no spaces. (Example: HR_Management)<br/><br/> You can provide <b>Author</b> and <b>Description</b> information for package. <br/><br/>Click <b>Save</b> to create the package.',
|
||||
'modify'=>'The properties and possible actions for the <b>Package</b> appear here.<br><br>You can modify the <b>Name</b>, <b>Author</b> and <b>Description</b> of the package, as well as view and customize all of the modules contained within the package.<br><br>Click <b>New Module</b> to create a module for the package.<br><br>If the package contains at least one module, you can <b>Publish</b> and <b>Deploy</b> the package, as well as <b>Export</b> the customizations made in the package.',
|
||||
'name'=>'This is the <b>Name</b> of the current package. <br/><br/>The name you enter must be alphanumeric, start with a letter and contain no spaces. (Example: HR_Management)',
|
||||
'author'=>'This is the <b>Author</b> that is displayed during installation as the name of the entity that created the package.<br><br>The Author could be either an individual or a company.',
|
||||
'description'=>'This is the <b>Description</b> of the package that is displayed during installation.',
|
||||
'publishbtn'=>'Click <b>Publish</b> to save all entered data and to create a .zip file that is an installable version of the package.<br><br>Use <b>Module Loader</b> to upload the .zip file and install the package.',
|
||||
'deploybtn'=>'Click <b>Deploy</b> to save all entered data and to install the package, including all modules, in the current instance.',
|
||||
'duplicatebtn'=>'Click <b>Duplicate</b> to copy the contents of the package into a new package and to display the new package. <br/><br/>For the new package, a new name will be generated automatically by appending a number to the end of the name of the package used to create the new one. You can rename the new package by entering a new <b>Name</b> and clicking <b>Save</b>.',
|
||||
'exportbtn'=>'Click <b>Export</b> to create a .zip file containing the customizations made in the package.<br><br> The generated file is not an installable version of the package.<br><br>Use <b>Module Loader</b> to import the .zip file and to have the package, including customizations, appear in Module Builder.',
|
||||
'deletebtn'=>'Click <b>Delete</b> to delete this package and all files related to this package.',
|
||||
'savebtn'=>'Click <b>Save</b> to save all entered data related to the package.',
|
||||
'existing_module'=>'Click the <b>Module</b> icon to edit the properties and customize the fields, relationships and layouts associated with the module.',
|
||||
'new_module'=>'Click <b>New Module</b> to create a new module for this package.',
|
||||
'key'=>'This 5-letter, alphanumeric <b>Key</b> will be used to prefix all directories, class names and database tables for all of the modules in the current package.<br><br>The key is used in an effort to achieve table name uniqueness.',
|
||||
'readme'=>'Click to add <b>Readme</b> text for this package.<br><br>The Readme will be available at the time of installation.',
|
||||
),
|
||||
'main'=>array(
|
||||
|
||||
),
|
||||
'module'=>array(
|
||||
'create'=>'Provide a <b>Name</b> for the module. The <b>Label</b> that you provide will appear in the navigation tab. <br/><br/>Choose to display a navigation tab for the module by checking the <b>Navigation Tab</b> checkbox.<br/><br/>Then choose the type of module you would like to create. <br/><br/>Select a template type. Each template contains a specific set of fields, as well as pre-defined layouts, to use as a basis for your module. <br/><br/>Click <b>Save</b> to create the module.',
|
||||
'modify'=>'You can change the module properties or customize the <b>Fields</b>, <b>Relationships</b> and <b>Layouts</b> related to the module.',
|
||||
'importable'=>'Checking the <b>Importable</b> checkbox will enable importing for this module.<br><br>A link to the Import Wizard will appear in the Shortcuts panel in the module. The Import Wizard facilitates importing of data from external sources into the custom module.',
|
||||
'team_security'=>'Checking the <b>Team Security</b> checkbox will enable team security for this module. <br/><br/>If team security is enabled, the Team selection field will appear within the records in the module ',
|
||||
'reportable'=>'Checking this box will allow this module to have reports run against it.',
|
||||
'assignable'=>'Checking this box will allow a record in this module to be assigned to a selected user.',
|
||||
'has_tab'=>'Checking <b>Navigation Tab</b> will provide a navigation tab for the module.',
|
||||
'acl'=>'Checking this box will enable Access Controls on this module, including Field Level Security.',
|
||||
'studio'=>'Checking this box will allow administrators to customize this module within Studio.',
|
||||
'audit'=>'Checking this box will enable Auditing for this module. Changes to certain fields will be recorded so that administrators can review the change history.',
|
||||
'viewfieldsbtn'=>'Click <b>View Fields</b> to view the fields associated with the module and to create and edit custom fields.',
|
||||
'viewrelsbtn'=>'Click <b>View Relationships</b> to view the relationships associated with this module and to create new relationships.',
|
||||
'viewlayoutsbtn'=>'Click <b>View Layouts</b> to view the layouts for the module and to customize the field arrangement within the layouts.',
|
||||
'duplicatebtn'=>'Click <b>Duplicate</b> to copy the properties of the module into a new module and to display the new module. <br/><br/>For the new module, a new name will be generated automatically by appending a number to the end of the name of the module used to create the new one.',
|
||||
'deletebtn'=>'Click <b>Delete</b> to delete this module.',
|
||||
'name'=>'This is the <b>Name</b> of the current module.<br/><br/>The name must be alphanumeric and must start with a letter and contain no spaces. (Example: HR_Management)',
|
||||
'label'=>'This is the <b>Label</b> that will appear in the navigation tab for the module. ',
|
||||
'savebtn'=>'Click <b>Save</b> to save all entered data related to the module.',
|
||||
'type_basic'=>'The <b>Basic</b> template type provides basic fields, such as the Name, Assigned to, Team, Date Created and Description fields.',
|
||||
'type_company'=>'The <b>Company</b> template type provides organization-specific fields, such as Company Name, Industry and Billing Address.<br/><br/>Use this template to create modules that are similar to the standard Accounts module.',
|
||||
'type_issue'=>'The <b>Issue</b> template type provides case- and bug-specific fields, such as Number, Status, Priority and Description.<br/><br/>Use this template to create modules that are similar to the standard Cases and Bug Tracker modules.',
|
||||
'type_person'=>'The <b>Person</b> template type provides individual-specific fields, such as Salutation, Title, Name, Address and Phone Number.<br/><br/>Use this template to create modules that are similar to the standard Contacts and Leads modules.',
|
||||
'type_sale'=>'The <b>Sale</b> template type provides opportunity specific fields, such as Lead Source, Stage, Amount and Probability. <br/><br/>Use this template to create modules that are similar to the standard Opportunities module.',
|
||||
'type_file'=>'The <b>File</b> template provides Document specific fields, such as File Name, Document type, and Publish Date.<br><br>Use this template to create modules that are similar to the standard Documents module.',
|
||||
|
||||
),
|
||||
'dropdowns'=>array(
|
||||
'default' => 'All of the <b>Dropdowns</b> for the application are listed here.<br><br>The dropdowns can be used for dropdown fields in any module.<br><br>To make changes to an existing dropdown, click on the dropdown name.<br><br>Click <b>Add Dropdown</b> to create a new dropdown.',
|
||||
'editdropdown'=>'Dropdown lists can be used for standard or custom dropdown fields in any module.<br><br>Provide a <b>Name</b> for the dropdown list.<br><br>If any language packs are installed in the application, you can select the <b>Language</b> to use for the list items.<br><br>In the <b>Item Name</b> field, provide a name for the option in the dropdown list. This name will not appear in the dropdown list that is visible to users.<br><br>In the <b>Display Label</b> field, provide a label that will be visible to users.<br><br>After providing the item name and display label, click <b>Add</b> to add the item to the dropdown list.<br><br>To reorder the items in the list, drag and drop items into the desired positions.<br><br>To edit the display label of an item, click the <b>Edit icon</b>, and enter a new label. To delete an item from the dropdown list, click the <b>Delete icon</b>.<br><br>To undo a change made to a display label, click <b>Undo</b>. To redo a change that was undone, click <b>Redo</b>.<br><br>Click <b>Save</b> to save the dropdown list.',
|
||||
|
||||
),
|
||||
'subPanelEditor'=>array(
|
||||
'modify' => 'All of the fields that can be displayed in the <b>Subpanel</b> appear here.<br><br>The <b>Default</b> column contains the fields that are displayed in the Subpanel.<br/><br/>The <b>Hidden</b> column contains fields that can be added to the Default column.',
|
||||
'savebtn' => 'Click <b>Save & Deploy</b> to save changes you made and to make them active within the module.',
|
||||
'historyBtn'=> 'Click <b>View History</b> to view and restore a previously saved layout from the history.',
|
||||
'historyDefault'=> 'Click <b>Restore Default</b> to restore a view to its original layout.',
|
||||
'Hidden' => '<b>Hidden</b> fields do not appear in the subpanel.',
|
||||
'Default' => '<b>Default</b> fields appear in the subpanel.',
|
||||
|
||||
),
|
||||
'listViewEditor'=>array(
|
||||
'modify' => 'All of the fields that can be displayed in the <b>ListView</b> appear here.<br><br>The <b>Default</b> column contains the fields that are displayed in the ListView by default.<br/><br/>The <b>Available</b> column contains fields that a user can select in the Search to create a custom ListView. <br/><br/>The <b>Hidden</b> column contains fields that can be added to the Default or Available column.',
|
||||
'savebtn' => 'Click <b>Save & Deploy</b> to save changes you made and to make them active within the module.',
|
||||
'historyBtn'=> 'Click <b>View History</b> to view and restore a previously saved layout from the history.',
|
||||
'historyDefault'=> 'Click <b>Restore Default</b> to restore a view to its original layout.',
|
||||
'Hidden' => '<b>Hidden</b> fields not currently available for users to see in ListViews.',
|
||||
'Available' => '<b>Available</b> fields are not shown by default, but can be added to ListViews by users.',
|
||||
'Default' => '<b>Default</b> fields appear in ListViews that are not customized by users.'
|
||||
),
|
||||
'popupListViewEditor'=>array(
|
||||
'modify' => 'All of the fields that can be displayed in the <b>ListView</b> appear here.<br><br>The <b>Default</b> column contains the fields that are displayed in the ListView by default.<br/><br/>The <b>Hidden</b> column contains fields that can be added to the Default or Available column.',
|
||||
'savebtn' => 'Click <b>Save & Deploy</b> to save changes you made and to make them active within the module.',
|
||||
'historyBtn'=> 'Click <b>View History</b> to view and restore a previously saved layout from the history.',
|
||||
'historyDefault'=> 'Click <b>Restore Default</b> to restore a view to its original layout.',
|
||||
'Hidden' => '<b>Hidden</b> fields not currently available for users to see in ListViews.',
|
||||
'Default' => '<b>Default</b> fields appear in ListViews that are not customized by users.'
|
||||
),
|
||||
'searchViewEditor'=>array(
|
||||
'modify' => 'All of the fields that can be displayed in the <b>Search</b> form appear here.<br><br>The <b>Default</b> column contains the fields that will be displayed in the Search form.<br/><br/>The <b>Hidden</b> column contains fields available for you as an admin to add to the Search form.',
|
||||
'savebtn' => 'Clicking <b>Save & Deploy</b> will save all changes and make them active',
|
||||
'Hidden' => '<b>Hidden</b> fields do not appear in the Search.',
|
||||
'historyBtn'=> 'Click <b>View History</b> to view and restore a previously saved layout from the history.',
|
||||
'historyDefault'=> 'Click <b>Restore Default</b> to restore a view to its original layout.',
|
||||
'Default' => '<b>Default</b> fields appear in the Search.'
|
||||
),
|
||||
'layoutEditor'=>array(
|
||||
'defaultdetailview'=>'The <b>Layout</b> area contains the fields that are currently displayed within the <b>DetailView</b>.<br/><br/>The <b>Toolbox</b> contains the <b>Recycle Bin</b> and the fields and layout elements that can be added to the layout.<br><br>Make changes to the layout by dragging and dropping elements and fields between the <b>Toolbox</b> and the <b>Layout</b> and within the layout itself.<br><br>To remove a field from the layout, drag the field to the <b>Recycle Bin</b>. The field will then be available in the Toolbox to add to the layout.',
|
||||
'defaultquickcreate'=>'The <b>Layout</b> area contains the fields that are currently displayed within the <b>QuickCreate</b> form.<br><br>The QuickCreate form appears in the subpanels for the module when the Create button is clicked.<br/><br/>The <b>Toolbox</b> contains the <b>Recycle Bin</b> and the fields and layout elements that can be added to the layout.<br><br>Make changes to the layout by dragging and dropping elements and fields between the <b>Toolbox</b> and the <b>Layout</b> and within the layout itself.<br><br>To remove a field from the layout, drag the field to the <b>Recycle Bin</b>. The field will then be available in the Toolbox to add to the layout.',
|
||||
//this defualt will be used for edit view
|
||||
'default' => 'The <b>Layout</b> area contains the fields that are currently displayed within the <b>EditView</b>.<br/><br/>The <b>Toolbox</b> contains the <b>Recycle Bin</b> and the fields and layout elements that can be added to the layout.<br><br>Make changes to the layout by dragging and dropping elements and fields between the <b>Toolbox</b> and the <b>Layout</b> and within the layout itself.<br><br>To remove a field from the layout, drag the field to the <b>Recycle Bin</b>. The field will then be available in the Toolbox to add to the layout.',
|
||||
'saveBtn' => 'Click <b>Save</b> to preserve the changes you made to the layout since the last time you saved it.<br><br>The changes will not be displayed in the module until you Deploy the saved changes.',
|
||||
'historyBtn'=> 'Click <b>View History</b> to view and restore a previously saved layout from the history.',
|
||||
'historyDefault'=> 'Click <b>Restore Default</b> to restore a view to its original layout.',
|
||||
'publishBtn'=> 'Click <b>Save & Deploy</b> to save all changes you made to the layout since the last time you saved it, and to make the changes active in the module.<br><br>The layout will immediately be displayed in the module.',
|
||||
'toolbox' => 'The <b>Toolbox</b> contains the <b>Recycle Bin</b>, additional layout elements and the set of available fields to add to the layout.<br/><br/>The layout elements and fields in the Toolbox can be dragged and dropped into the layout, and the layout elements and fields can be dragged and dropped from the layout into the Toolbox.<br><br>The layout elements are <b>Panels</b> and <b>Rows</b>. Adding a new row or a new panel to the layout provides additional locations in the layout for fields.<br/><br/>Drag and drop any of the fields in the Toolbox or layout onto a occupied field position to swap the locations of the two fields.<br/><br/>The <b>Filler</b> field creates blank space in the layout where it is placed.',
|
||||
'panels' => 'The <b>Layout</b> area provides a view of how the layout will appear within the module when the changes made to the layout are deployed.<br/><br/>You can reposition fields, rows and panels by dragging and dropping them in the desired location.<br/><br/>Remove elements by dragging and dropping them in the <b>Recycle Bin</b> in the Toolbox, or add new elements and fields by dragging them from the <b>Toolbox</b>s and dropping them in the desired location in the layout.',
|
||||
'delete' => 'Drag and drop any element here to remove it from the layout',
|
||||
'property' => 'Edit The label displayed for this field. <br/><b>Tab Order</b> controls in what order the tab key switches between fields.',
|
||||
),
|
||||
'fieldsEditor'=>array(
|
||||
'default' => 'The <b>Fields</b> that are available for the module are listed here by Field Name.<br><br>Custom fields created for the module appear above the fields that are available for the module by default.<br><br>To edit a field, click the <b>Field Name</b>.<br/><br/>To create a new field, click <b>Add Field</b>.',
|
||||
'mbDefault'=>'The <b>Fields</b> that are available for the module are listed here by Field Name.<br><br>To configure the properties for a field, click the Field Name.<br><br>To create a new field, click <b>Add Field</b>. The label along with the other properties of the new field can be edited after creation by clicking the Field Name.<br><br>After the module is deployed, the new fields created in Module Builder are regarded as standard fields in the deployed module in Studio.',
|
||||
'addField' => 'Select a <b>Data Type</b> for the new field. The type you select determines what kind of characters can be entered for the field. For example, only numbers that are integers may be entered into fields that are of the Integer data type.<br><br> Provide a <b>Name</b> for the field. The name must be alphanumeric and must not contain any spaces. Underscores are valid.<br><br> The <b>Display Label</b> is the label that will appear for the fields in the module layouts. The <b>System Label</b> is used to refer to the field in the code.<br><br> Depending on the data type selected for the field, some or all of the following properties can be set for the field:<br><br> <b>Help Text</b> appears temporarily while a user hovers over the field and can be used to prompt the user for the type of input desired.<br><br> <b>Comment Text</b> is only seen within Studio &/or Module Builder, and can be used to describe the field for administrators.<br><br> <b>Default Value</b> will appear in the field. Users can enter a new value in the field or use the default value.<br><br> Select the <b>Mass Update</b> checkbox in order to be able to use the Mass Update feature for the field.<br><br>The <b>Max Size</b> value determines the maximum number of characters that can be entered in the field.<br><br> Select the <b>Required Field</b> checkbox in order to make the field required. A value must be provided for the field in order to be able to save a record containing the field.<br><br> Select the <b>Reportable</b> checkbox in order to allow the field to be used for filters and for displaying data in Reports.<br><br> Select the <b>Audit</b> checkbox in order to be able to track changes to the field in the Change Log.<br><br>Select an option in the <b>Importable</b> field to allow, disallow or require the field to be imported into in the Import Wizard.<br><br>Select an option in the <b>Duplicate Merge</b> field to enable or disable the Merge Duplicates and Find Duplicates features.<br><br>Additional properties can be set for certain data types.',
|
||||
'editField' => 'The properties of this field can be customized.<br><br>Click <b>Clone</b> to create a new field with the same properties.',
|
||||
'mbeditField' => 'The <b>Display Label</b> of a template field can be customized. The other properties of the field can not be customized.<br><br>Click <b>Clone</b> to create a new field with the same properties.<br><br>To remove a template field so that it does not display in the module, remove the field from the appropriate <b>Layouts</b>.'
|
||||
|
||||
),
|
||||
'exportcustom'=>array(
|
||||
'exportHelp'=>'Export customizations made in Studio by creating packages that can be uploaded into another Sugar instance through the <b>Module Loader</b>.<br><br> First, provide a <b>Package Name</b>. You can provide <b>Author</b> and <b>Description</b> information for package as well.<br><br>Select the module(s) that contain the customizations you wish to export. Only modules containing customizations will appear for you to select.<br><br>Then click <b>Export</b> to create a .zip file for the package containing the customizations.',
|
||||
'exportCustomBtn'=>'Click <b>Export</b> to create a .zip file for the package containing the customizations that you wish to export.',
|
||||
'name'=>'This is the <b>Name</b> of the package. This name will be displayed during installation.',
|
||||
'author'=>'This is the <b>Author</b> that is displayed during installation as the name of the entity that created the package. The Author can be either an individual or a company.',
|
||||
'description'=>'This is the <b>Description</b> of the package that is displayed during installation.',
|
||||
),
|
||||
'studioWizard'=>array(
|
||||
'mainHelp' => 'Welcome to the <b>Developer Tools</b> area. <br/><br/>Use the tools within this area to create and manage standard and custom modules and fields.',
|
||||
'studioBtn' => 'Use <b>Studio</b> to customize deployed modules.',
|
||||
'mbBtn' => 'Use <b>Module Builder</b> to create new modules.',
|
||||
'sugarPortalBtn' => 'Use <b>Sugar Portal Editor</b> to manage and customize the Sugar Portal.',
|
||||
'dropDownEditorBtn' => 'Use <b>Dropdown Editor</b> to add and edit global dropdowns for dropdown fields.',
|
||||
'appBtn' => 'Application mode is where you can customize various properties of the program, such as how many TPS reports are displayed on the homepage',
|
||||
'backBtn' => 'Return to the previous step.',
|
||||
'studioHelp'=> 'Use <b>Studio</b> to determine what and how information is displayed in the modules.',
|
||||
'moduleBtn' => 'Click to edit this module.',
|
||||
'moduleHelp'=> 'The components that you can customize for the module appear here.<br><br>Click an icon to select the component to edit.',
|
||||
'fieldsBtn' => 'Create and customize <b>Fields</b> to store information in the module.',
|
||||
'labelsBtn' => 'Edit the <b>Labels</b> that display for the fields and other titles in the module.' ,
|
||||
'relationshipsBtn' => 'Add new or view existing <b>Relationships</b> for the module.' ,
|
||||
'layoutsBtn'=> 'Customize the module <b>Layouts</b>. The layouts are the different views of the module contaning fields.<br><br>You can determine which fields appear and how they are organized in each layout.',
|
||||
'subpanelBtn'=> 'Determine which fields appear in the <b>Subpanels</b> in the module.',
|
||||
'portalBtn' =>'Customize the module <b>Layouts</b> that appear in the <b>Sugar Portal</b>.',
|
||||
'layoutsHelp'=> 'The module <b>Layouts</b> that can be customized appear here.<br><br>The layouts display fields and field data.<br><br>Click an icon to select the layout to edit.',
|
||||
'subpanelHelp'=> 'The <b>Subpanels</b> in the module that can be customized appear here.<br><br>Click an icon to select the module to edit.',
|
||||
'newPackage'=>'Click <b>New Package</b> to create a new package.',
|
||||
'exportBtn' => 'Click <b>Export Customizations</b> to create and download a package containing customizations made in Studio for specific modules.',
|
||||
'mbHelp' => 'Use <b>Module Builder</b> to create packages containing custom modules based on standard or custom objects.',
|
||||
'viewBtnEditView' => 'Customize the module\'s <b>EditView</b> layout.<br><br>The EditView is the form containing input fields for capturing user-entered data.',
|
||||
'viewBtnDetailView' => 'Customize the module\'s <b>DetailView</b> layout.<br><br>The DetailView displays user-entered field data.',
|
||||
'viewBtnDashlet' => 'Customize the module\'s <b>Sugar Dashlet</b>, including the Sugar Dashlet\'s ListView and Search.<br><br>The Sugar Dashlet will be available to add to the pages in the Home module.',
|
||||
'viewBtnListView' => 'Customize the module\'s <b>ListView</b> layout.<br><br>The Search results appear in the ListView.',
|
||||
'searchBtn' => 'Customize the module\'s <b>Search</b> layouts.<br><br>Determine what fields can be used to filter records that appear in the ListView.',
|
||||
'viewBtnQuickCreate' => 'Customize the module\'s <b>QuickCreate</b> layout.<br><br>The QuickCreate form appears in subpanels and in the Emails module.',
|
||||
|
||||
'searchHelp'=> 'The <b>Search</b> forms that can be customized appear here.<br><br>Search forms contain fields for filtering records.<br><br>Click an icon to select the search layout to edit.',
|
||||
'dashletHelp' =>'The <b>Sugar Dashlet</b> layouts that can be customized appear here.<br><br>The Sugar Dashlet will be available to add to the pages in the Home module.',
|
||||
'DashletListViewBtn' =>'The <b>Sugar Dashlet ListView</b> displays records based on the Sugar Dashlet search filters.',
|
||||
'DashletSearchViewBtn' =>'The <b>Sugar Dashlet Search</b> filters records for the Sugar Dashlet listview.',
|
||||
'popupHelp' =>'The <b>Popup</b> layouts that can be customized appear here.<br>',
|
||||
'PopupListViewBtn' =>'The <b>Popup ListView</b> displays records based on the Popup search views.',
|
||||
'PopupSearchViewBtn' =>'The <b>Popup Search</b> views records for the Popup listview.',
|
||||
'BasicSearchBtn' => 'Customize the <b>Basic Search</b> form that appears in the Basic Search tab in the Search area for the module.',
|
||||
'AdvancedSearchBtn' => 'Customize the <b>Advanced Search</b> form that appears in the Advanced Search tab in the Search area for the module.',
|
||||
'portalHelp' => 'Manage and customize the <b>Sugar Portal</b>.',
|
||||
'SPUploadCSS' => 'Upload a <b>Style Sheet</b> for the Sugar Portal.',
|
||||
'SPSync' => '<b>Sync</b> customizations to the Sugar Portal instance.',
|
||||
'Layouts' => 'Customize the <b>Layouts</b> of the Sugar Portal modules.',
|
||||
'portalLayoutHelp' => 'The modules within the Sugar Portal appear in this area.<br><br>Select a module to edit the <b>Layouts</b>.',
|
||||
'relationshipsHelp' => 'All of the <b>Relationships</b> that exist between the module and other deployed modules appear here.<br><br>The relationship <b>Name</b> is the system-generated name for the relationship.<br><br>The <b>Primary Module</b> is the module that owns the relationships. For example, all of the properties of the relationships for which the Accounts module is the primary module are stored in the Accounts database tables.<br><br>The <b>Type</b> is the type of relationship exists between the Primary module and the <b>Related Module</b>.<br><br>Click a column title to sort by the column.<br><br>Click a row in the relationship table to view the properties associated with the relationship.<br><br>Click <b>Add Relationship</b> to create a new relationship.<br><br>Relationships can be created between any two deployed modules.',
|
||||
'relationshipHelp'=>'<b>Relationships</b> can be created between the module and another deployed module.<br><br> Relationships are visually expressed through subpanels and relate fields in the module records.<br><br>Select one of the following relationship <b>Types</b> for the module:<br><br> <b>One-to-One</b> - Both modules\' records will contain relate fields.<br><br> <b>One-to-Many</b> - The Primary Module\'s record will contain a subpanel, and the Related Module\'s record will contain a relate field.<br><br> <b>Many-to-Many</b> - Both modules\' records will display subpanels.<br><br> Select the <b>Related Module</b> for the relationship. <br><br>If the relationship type involves subpanels, select the subpanel view for the appropriate modules.<br><br> Click <b>Save</b> to create the relationship.',
|
||||
'convertLeadHelp' => "Here you can add modules to the convert layout screen and modify the layouts of existing ones.<br/>
|
||||
You can re-order the modules by dragging their rows in the table.<br/><br/>
|
||||
|
||||
<b>Module:</b> The name of the module.<br/><br/>
|
||||
<b>Required:</b> Required modules must be created or selected before the lead can be converted.<br/><br/>
|
||||
<b>Copy Data:</b> If checked, fields from the lead will be copied to fields with the same name in the newly created records.<br/><br/>
|
||||
<b>Allow Selection:</b> Modules with a relate field in Contacts can be selected rather than created during the convert lead process.<br/><br/>
|
||||
<b>Edit:</b> Modify the convert layout for this module.<br/><br/>
|
||||
<b>Delete:</b> Remove this module from the convert layout.<br/><br/>
|
||||
",
|
||||
'editDropDownBtn' => 'Edit a global Dropdown',
|
||||
'addDropDownBtn' => 'Add a new global Dropdown',
|
||||
),
|
||||
'fieldsHelp'=>array(
|
||||
'default'=>'The <b>Fields</b> in the module are listed here by Field Name.<br><br>The module template includes a pre-determined set of fields.<br><br>To create a new field, click <b>Add Field</b>.<br><br>To edit a field, click the <b>Field Name</b>.<br/><br/>After the module is deployed, the new fields created in Module Builder, along with the template fields, are regarded as standard fields in Studio.',
|
||||
),
|
||||
'relationshipsHelp'=>array(
|
||||
'default'=>'The <b>Relationships</b> that have been created between the module and other modules appear here.<br><br>The relationship <b>Name</b> is the system-generated name for the relationship.<br><br>The <b>Primary Module</b> is the module that owns the relationships. The relationship properties are stored in the database tables belonging to the primary module.<br><br>The <b>Type</b> is the type of relationship exists between the Primary module and the <b>Related Module</b>.<br><br>Click a column title to sort by the column.<br><br>Click a row in the relationship table to view and edit the properties associated with the relationship.<br><br>Click <b>Add Relationship</b> to create a new relationship.',
|
||||
'addrelbtn'=>'mouse over help for add relationship..',
|
||||
'addRelationship'=>'<b>Relationships</b> can be created between the module and another custom module or a deployed module.<br><br> Relationships are visually expressed through subpanels and relate fields in the module records.<br><br>Select one of the following relationship <b>Types</b> for the module:<br><br> <b>One-to-One</b> - Both modules\' records will contain relate fields.<br><br> <b>One-to-Many</b> - The Primary Module\'s record will contain a subpanel, and the Related Module\'s record will contain a relate field.<br><br> <b>Many-to-Many</b> - Both modules\' records will display subpanels.<br><br> Select the <b>Related Module</b> for the relationship. <br><br>If the relationship type involves subpanels, select the subpanel view for the appropriate modules.<br><br> Click <b>Save</b> to create the relationship.',
|
||||
),
|
||||
'labelsHelp'=>array(
|
||||
'default'=> 'The <b>Labels</b> for the fields and other titles in the module can be changed.<br><br>Edit the label by clicking within the field, entering a new label and clicking <b>Save</b>.<br><br>If any language packs are installed in the application, you can select the <b>Language</b> to use for the labels.',
|
||||
'saveBtn'=>'Click <b>Save</b> to save all changes.',
|
||||
'publishBtn'=>'Click <b>Save & Deploy</b> to save all changes and make them active.',
|
||||
),
|
||||
'portalSync'=>array(
|
||||
'default' => 'Enter the <b>Sugar Portal URL</b> of the portal instance to update, and click <b>Go</b>.<br><br>Then enter a valid Sugar user name and password, and then click <b>Begin Sync</b>.<br><br>The customizations made to the Sugar Portal <b>Layouts</b>, along with the <b>Style Sheet</b> if one was uploaded, will be transferred to specified the portal instance.',
|
||||
),
|
||||
'portalStyle'=>array(
|
||||
'default' => 'You can customize the look of the Sugar Portal by using a style sheet.<br><br>Select a <b>Style Sheet</b> to upload.<br><br>The style sheet will be implemented in the Sugar Portal the next time a sync is performed.',
|
||||
),
|
||||
),
|
||||
|
||||
'assistantHelp'=>array(
|
||||
'package'=>array(
|
||||
//custom begin
|
||||
'nopackages'=>'To get started on a project, click <b>New Package</b> to create a new package to house your custom module(s). <br/><br/>Each package can contain one or more modules.<br/><br/>For instance, you might want to create a package containing one custom module that is related to the standard Accounts module. Or, you might want to create a package containing several new modules that work together as a project and that are related to each other and to other modules already in the application.',
|
||||
'somepackages'=>'A <b>package</b> acts as a container for custom modules, all of which are part of one project. The package can contain one or more custom <b>modules</b> that can be related to each other or to other modules in the application.<br/><br/>After creating a package for your project, you can create modules for the package right away, or you can return to the Module Builder at a later time to complete the project.<br><br>When the project is complete, you can <b>Deploy</b> the package to install the custom modules within the application.',
|
||||
'afterSave'=>'Your new package should contain at least one module. You can create one or more custom modules for the package.<br/><br/>Click <b>New Module</b> to create a custom module for this package.<br/><br/> After creating at least one module, you can publish or deploy the package to make it available for your instance and/or other users\' instances.<br/><br/> To deploy the package in one step within your Sugar instance, click <b>Deploy</b>.<br><br>Click <b>Publish</b> to save the package as a .zip file. After the .zip file is saved to your system, use the <b>Module Loader</b> to upload and install the package within your Sugar instance. <br/><br/>You can distribute the file to other users to upload and install within their own Sugar instances.',
|
||||
'create'=>'A <b>package</b> acts as a container for custom modules, all of which are part of one project. The package can contain one or more custom <b>modules</b> that can be related to each other or to other modules in the application.<br/><br/>After creating a package for your project, you can create modules for the package right away, or you can return to the Module Builder at a later time to complete the project.',
|
||||
),
|
||||
'main'=>array(
|
||||
'welcome'=>'Use the <b>Developer Tools</b> to create and manage standard and custom modules and fields. <br/><br/>To manage modules in the application, click <b>Studio</b>. <br/><br/>To create custom modules, click <b>Module Builder</b>.',
|
||||
'studioWelcome'=>'All of the currently installed modules, including standard and module-loaded objects, are customizable within Studio.'
|
||||
),
|
||||
'module'=>array(
|
||||
'somemodules'=>"Since the current package contains at least one module, you can <b>Deploy</b> the modules in the package within your Sugar instance or <b>Publish</b> the package to be installed in the current Sugar instance or another instance using the <b>Module Loader</b>.<br/><br/>To install the package directly within your Sugar instance, click <b>Deploy</b>.<br><br>To create a .zip file for the package that can be loaded and installed within the current Sugar instance and other instances using the <b>Module Loader</b>, click <b>Publish</b>.<br/><br/> You can build the modules for this package in stages, and publish or deploy when you are ready to do so. <br/><br/>After publishing or deploying a package, you can make changes to the package properties and customize the modules further. Then re-publish or re-deploy the package to apply the changes." ,
|
||||
'editView'=> 'Here you can edit the existing fields. You can remove any of the existing fields or add available fields in the left panel.',
|
||||
'create'=>'When choosing the type of <b>Type</b> of module that you wish to create, keep in mind the types of fields you would like to have within the module. <br/><br/>Each module template contains a set of fields pertaining to the type of module described by the title.<br/><br/><b>Basic</b> - Provides basic fields that appear in standard modules, such as the Name, Assigned to, Team, Date Created and Description fields.<br/><br/> <b>Company</b> - Provides organization-specific fields, such as Company Name, Industry and Billing Address. Use this template to create modules that are similar to the standard Accounts module.<br/><br/> <b>Person</b> - Provides individual-specific fields, such as Salutation, Title, Name, Address and Phone Number. Use this template to create modules that are similar to the standard Contacts and Leads modules.<br/><br/><b>Issue</b> - Provides case- and bug-specific fields, such as Number, Status, Priority and Description. Use this template to create modules that are similar to the standard Cases and Bug Tracker modules.<br/><br/>Note: After you create the module, you can edit the labels of the fields provided by the template, as well as create custom fields to add to the module layouts.',
|
||||
'afterSave'=>'Customize the module to suit your needs by editing and creating fields, establishing relationships with other modules and arranging the fields within the layouts.<br/><br/>To view the template fields and manage custom fields within the module, click <b>View Fields</b>.<br/><br/>To create and manage relationships between the module and other modules, whether modules already in the application or other custom modules within the same package, click <b>View Relationships</b>.<br/><br/>To edit the module layouts, click <b>View Layouts</b>. You can change the Detail View, Edit View and List View layouts for the module just as you would for modules already in the application within Studio.<br/><br/> To create a module with the same properties as the current module, click <b>Duplicate</b>. You can further customize the new module.',
|
||||
'viewfields'=>'The fields in the module can be customized to suit your needs.<br/><br/>You can not delete standard fields, but you can remove them from the appropriate layouts within the Layouts pages. <br/><br/>You can quickly create new fields that have similar properties to existing fields by clicking <b>Clone</b> in the <b>Properties</b> form. Enter any new properties, and then click <b>Save</b>.<br/><br/>It is recommended that you set all of the properties for the standard fields and custom fields before you publish and install the package containing the custom module.',
|
||||
'viewrelationships'=>'You can create many-to-many relationships between the current module and other modules in the package, and/or between the current module and modules already installed in the application.<br><br> To create one-to-many and one-to-one relationships, create <b>Relate</b> and <b>Flex Relate</b> fields for the modules.',
|
||||
'viewlayouts'=>'You can control what fields are available for capturing data within the <b>Edit View</b>. You can also control what data displays within the <b>Detail View</b>. The views do not have to match. <br/><br/>The Quick Create form is displayed when the <b>Create</b> is clicked in a module subpanel. By default, the <b>Quick Create</b> form layout is the same as the default <b>Edit View</b> layout. You can customize the Quick Create form so that it contains less and/or different fields than the Edit View layout. <br><br>You can determine the module security using Layout customization along with <b>Role Management</b>.<br><br>',
|
||||
'existingModule' =>'After creating and customizing this module, you can create additional modules or return to the package to <b>Publish</b> or <b>Deploy</b> the package.<br><br>To create additional modules, click <b>Duplicate</b> to create a module with the same properties as the current module, or navigate back to the package, and click <b>New Module</b>.<br><br> If you are ready to <b>Publish</b> or <b>Deploy</b> the package containing this module, navigate back to the package to perform these functions. You can publish and deploy packages containing at least one module.',
|
||||
'labels'=> 'The labels of the standard fields as well as custom fields can be changed. Changing field labels will not affect the data stored in the fields.',
|
||||
),
|
||||
'listViewEditor'=>array(
|
||||
'modify' => 'There are three columns displayed to the left. The "Default" column contains the fields that are displayed in a list view by default, the "Available" column contains fields that a user can choose to use for creating a custom list view, and the "Hidden" column contains fields available for you as an admin to either add to the default or Available columns for use by users but are currently disabled.',
|
||||
'savebtn' => 'Clicking <b>Save</b> will save all changes and make them active.',
|
||||
'Hidden' => 'Hidden fields are fields that are not currently available to users for use in list views.',
|
||||
'Available' => 'Available fields are fields that are not shown by default, but can be enabled by users.',
|
||||
'Default' => 'Default fields are displayed to users who have not created custom list view settings.'
|
||||
),
|
||||
|
||||
'searchViewEditor'=>array(
|
||||
'modify' => 'There are two columns displayed to the left. The "Default" column contains the fields that will be displayed in the search view, and the "Hidden" column contains fields available for you as an admin to add to the view.',
|
||||
'savebtn' => 'Clicking <b>Save & Deploy</b> will save all changes and make them active.',
|
||||
'Hidden' => 'Hidden fields are fields that will not be shown in the search view.',
|
||||
'Default' => 'Default fields will be shown in the search view.'
|
||||
),
|
||||
'layoutEditor'=>array(
|
||||
'default' => 'There are two columns displayed to the left. The right-hand column, labeled Current Layout or Layout Preview, is where you change the module layout. The left-hand column, entitled Toolbox, contains useful elements and tools for use when editing the layout. <br/><br/>If the layout area is titled Current Layout then you are working on a copy of the layout currently used by the module for display.<br/><br/>If it is titled Layout Preview then you are working on a copy created earlier by a click on the Save button, that might have already been changed from the version seen by users of this module.',
|
||||
'saveBtn' => 'Clicking this button saves the layout so that you can preserve your changes. When you return to this module you will start from this changed layout. Your layout however will not be seen by users of the module until you click the Save and Publish button.',
|
||||
'publishBtn'=> 'Click this button to deploy the layout. This means that this layout will immediately be seen by users of this module.',
|
||||
'toolbox' => 'The toolbox contains a variety of useful features for editing layouts, including a trash area, a set of additional elements and a set of available fields. Any of these can be dragged and dropped onto the layout.',
|
||||
'panels' => 'This area shows how your layout will look to users of this module when it is depolyed.<br/><br/>You can reposition elements such as fields, rows and panels by dragging and dropping them; delete elements by dragging and dropping them on the trash area in the toolbox, or add new elements by dragging them from the toolbox and dropping them on to the layout in the desired position.'
|
||||
),
|
||||
'dropdownEditor'=>array(
|
||||
'default' => 'There are two columns displayed to the left. The right-hand column, labeled Current Layout or Layout Preview, is where you change the module layout. The left-hand column, entitled Toolbox, contains useful elements and tools for use when editing the layout. <br/><br/>If the layout area is titled Current Layout then you are working on a copy of the layout currently used by the module for display.<br/><br/>If it is titled Layout Preview then you are working on a copy created earlier by a click on the Save button, that might have already been changed from the version seen by users of this module.',
|
||||
'dropdownaddbtn'=> 'Clicking this button adds a new item to the dropdown.',
|
||||
|
||||
),
|
||||
'exportcustom'=>array(
|
||||
'exportHelp'=>'Customizations made in Studio within this instance can be packaged and deployed in another instance. <br><br>Provide a <b>Package Name</b>. You can provide <b>Author</b> and <b>Description</b> information for package.<br><br>Select the module(s) that contain the customizations to export. (Only modules containing customizations will appear for you to select.)<br><br>Click <b>Export</b> to create a .zip file for the package containing the customizations. The .zip file can be uploaded in another instance through <b>Module Loader</b>.',
|
||||
'exportCustomBtn'=>'Click <b>Export</b> to create a .zip file for the package containing the customizations that you wish to export.
|
||||
',
|
||||
'name'=>'The <b>Name</b> of the package will be displayed in Module Loader after the package is uploaded for installation in Studio.',
|
||||
'author'=>'The <b>Author</b> is the name of the entity that created the package. The Author can be either an individual or a company.<br><br>The Author will be displayed in Module Loader after the package is uploaded for installation in Studio.
|
||||
',
|
||||
'description'=>'The <b>Description</b> of the package will be displayed in Module Loader after the package is uploaded for installation in Studio.',
|
||||
),
|
||||
'studioWizard'=>array(
|
||||
'mainHelp' => 'Welcome to the <b>Developer Tools</b1> area. <br/><br/>Use the tools within this area to create and manage standard and custom modules and fields.',
|
||||
'studioBtn' => 'Use <b>Studio</b> to customize installed modules by changing the field arrangement, selecting what fields are available and creating custom data fields.',
|
||||
'mbBtn' => 'Use <b>Module Builder</b> to create new modules.',
|
||||
'appBtn' => 'Use Application mode to customize various properties of the program, such as how many TPS reports are displayed on the homepage',
|
||||
'backBtn' => 'Return to the previous step.',
|
||||
'studioHelp'=> 'Use <b>Studio</b> to customize installed modules.',
|
||||
'moduleBtn' => 'Click to edit this module.',
|
||||
'moduleHelp'=> 'Select the module component that you would like to edit',
|
||||
'fieldsBtn' => 'Edit what information is stored in the module by controlling the <b>Fields</b> in the module.<br/><br/>You can edit and create custom fields here.',
|
||||
'labelsBtn' => 'Click <b>Save</b> to save your custom labels.' ,
|
||||
'layoutsBtn'=> 'Customize the <b>Layouts</b> of the Edit, Detail, List and search views.',
|
||||
'subpanelBtn'=> 'Edit what information is shown in this modules subpanels.',
|
||||
'layoutsHelp'=> 'Select a <b>Layout to edit</b>.<br/<br/>To change the layout that contains data fields for entering data, click <b>Edit View</b>.<br/><br/>To change the layout that displays the data entered into the fields in the Edit View, click <b>Detail View</b>.<br/><br/>To change the columns which appear in the default list, click <b>List View</b>.<br/><br/>To change the Basic and Advanced search form layouts, click <b>Search</b>.',
|
||||
'subpanelHelp'=> 'Select a <b>Subpanel</b> to edit.',
|
||||
'searchHelp' => 'Select a <b>Search</b> layout to edit.',
|
||||
'labelsBtn' => 'Edit the <b>Labels</b> to display for values in this module.',
|
||||
'newPackage'=>'Click <b>New Package</b> to create a new package.',
|
||||
'mbHelp' => '<b>Welcome to Module Builder.</b><br/><br/>Use <b>Module Builder</b> to create packages containing custom modules based on standard or custom objects. <br/><br/>To begin, click <b>New Package</b> to create a new package, or select a package to edit.<br/><br/> A <b>package</b> acts as a container for custom modules, all of which are part of one project. The package can contain one or more custom modules that can be related to each other or to modules in the application. <br/><br/>Examples: You might want to create a package containing one custom module that is related to the standard Accounts module. Or, you might want to create a package containing several new modules that work together as a project and that are related to each other and to modules in the application.',
|
||||
'exportBtn' => 'Click <b>Export Customizations</b> to create a package containing customizations made in Studio for specific modules.',
|
||||
),
|
||||
|
||||
|
||||
),
|
||||
//HOME
|
||||
'LBL_HOME_EDIT_DROPDOWNS'=>'Dropdown Editor',
|
||||
|
||||
//ASSISTANT
|
||||
'LBL_AS_SHOW' => 'Show Assistant in future.',
|
||||
'LBL_AS_IGNORE' => 'Ignore Assistant in future.',
|
||||
'LBL_AS_SAYS' => 'Assistant Says:',
|
||||
|
||||
|
||||
//STUDIO2
|
||||
'LBL_MODULEBUILDER'=>'Module Builder',
|
||||
'LBL_STUDIO' => 'Studio',
|
||||
'LBL_DROPDOWNEDITOR' => 'Dropdown Editor',
|
||||
'LBL_EDIT_DROPDOWN'=>'Edit Dropdown',
|
||||
'LBL_DEVELOPER_TOOLS' => 'Developer Tools',
|
||||
'LBL_SUGARPORTAL' => 'Sugar Portal Editor',
|
||||
'LBL_SYNCPORTAL' => 'Sync Portal',
|
||||
'LBL_PACKAGE_LIST' => 'Package List',
|
||||
'LBL_HOME' => 'Home',
|
||||
'LBL_NONE'=>'-None-',
|
||||
'LBL_DEPLOYE_COMPLETE'=>'Deploy complete',
|
||||
'LBL_DEPLOY_FAILED' =>'An error has occured during deploy process, your package may not have installed correctly',
|
||||
'LBL_ADD_FIELDS'=>'Add Custom Fields',
|
||||
'LBL_AVAILABLE_SUBPANELS'=>'Available Subpanels',
|
||||
'LBL_ADVANCED'=>'Advanced',
|
||||
'LBL_ADVANCED_SEARCH'=>'Advanced Search',
|
||||
'LBL_BASIC'=>'Basic',
|
||||
'LBL_BASIC_SEARCH'=>'Basic Search',
|
||||
'LBL_CURRENT_LAYOUT'=>'Layout',
|
||||
'LBL_CURRENCY' => 'Currency',
|
||||
'LBL_DASHLET'=>'Sugar Dashlet',
|
||||
'LBL_DASHLETLISTVIEW'=>'Sugar Dashlet ListView',
|
||||
'LBL_DASHLETSEARCH'=>'Sugar Dashlet Search',
|
||||
'LBL_POPUP'=>'PopupView',
|
||||
'LBL_POPUPLIST'=>'Popup ListView',
|
||||
'LBL_POPUPLISTVIEW'=>'Popup ListView',
|
||||
'LBL_POPUPSEARCH'=>'Popup Search',
|
||||
'LBL_DASHLETSEARCHVIEW'=>'Sugar Dashlet Search',
|
||||
'LBL_DISPLAY_HTML'=>'Display HTML Code',
|
||||
'LBL_DETAILVIEW'=>'DetailView',
|
||||
'LBL_DROP_HERE' => '[Drop Here]',
|
||||
'LBL_EDIT'=>'Edit',
|
||||
'LBL_EDIT_LAYOUT'=>'Edit Layout',
|
||||
'LBL_EDIT_ROWS'=>'Edit Rows',
|
||||
'LBL_EDIT_COLUMNS'=>'Edit Columns',
|
||||
'LBL_EDIT_LABELS'=>'Edit Labels',
|
||||
'LBL_EDIT_FIELDS'=>'Edit Custom Fields',
|
||||
'LBL_EDIT_PORTAL'=>'Edit Portal for ',
|
||||
'LBL_EDIT_FIELDS'=>'Edit Fields',
|
||||
'LBL_EDITVIEW'=>'EditView',
|
||||
'LBL_CONVERTLEAD' => 'Convert Lead',
|
||||
'LBL_FILLER'=>'(filler)',
|
||||
'LBL_FIELDS'=>'Fields',
|
||||
'LBL_FAILED_TO_SAVE' => 'Failed To Save',
|
||||
'LBL_FAILED_PUBLISHED' => 'Failed to Publish',
|
||||
'LBL_HOMEPAGE_PREFIX' => 'My',
|
||||
'LBL_LAYOUT_PREVIEW'=>'Layout Preview',
|
||||
'LBL_LAYOUTS'=>'Layouts',
|
||||
'LBL_LISTVIEW'=>'ListView',
|
||||
'LBL_MODULES'=>'Modules',
|
||||
'LBL_MODULE_TITLE' => 'Studio',
|
||||
'LBL_NEW_PACKAGE' => 'New Package',
|
||||
'LBL_NEW_PANEL'=>'New Panel',
|
||||
'LBL_NEW_ROW'=>'New Row',
|
||||
'LBL_PACKAGE_DELETED'=>'Package Deleted',
|
||||
'LBL_PUBLISHING' => 'Publishing ...',
|
||||
'LBL_PUBLISHED' => 'Published',
|
||||
'LBL_SELECT_FILE'=> 'Select File',
|
||||
'LBL_SAVE_LAYOUT'=> 'Save Layout',
|
||||
'LBL_SELECT_A_SUBPANEL' => 'Select a Subpanel',
|
||||
'LBL_SELECT_SUBPANEL' => 'Select Subpanel',
|
||||
'LBL_SUBPANELS' => 'Subpanels',
|
||||
'LBL_SUBPANEL' => 'Subpanel',
|
||||
'LBL_SUBPANEL_TITLE' => 'Title:',
|
||||
'LBL_SEARCH_FORMS' => 'Search',
|
||||
'LBL_SEARCH'=>'Search',
|
||||
'LBL_STAGING_AREA' => 'Staging Area (drag and drop items here)',
|
||||
'LBL_SUGAR_FIELDS_STAGE' => 'Sugar Fields (click items to add to staging area)',
|
||||
'LBL_SUGAR_BIN_STAGE' => 'Sugar Bin (click items to add to staging area)',
|
||||
'LBL_TOOLBOX' => 'Toolbox',
|
||||
'LBL_VIEW_SUGAR_FIELDS' => 'View Sugar Fields',
|
||||
'LBL_VIEW_SUGAR_BIN' => 'View Sugar Bin',
|
||||
'LBL_QUICKCREATE' => 'QuickCreate',
|
||||
'LBL_EDIT_DROPDOWNS' => 'Edit a Global Dropdown',
|
||||
'LBL_ADD_DROPDOWN' => 'Add a new Global Dropdown',
|
||||
'LBL_BLANK' => '-blank-',
|
||||
'LBL_TAB_ORDER' => 'Tab Order',
|
||||
'LBL_TAB_PANELS' => 'Display panels as tabs',
|
||||
'LBL_TAB_PANELS_HELP' => 'Display each panel as its own tab instead of having them all appear on one screen',
|
||||
'LBL_DROPDOWN_TITLE_NAME' => 'Name',
|
||||
'LBL_DROPDOWN_LANGUAGE' => 'Language',
|
||||
'LBL_DROPDOWN_ITEMS' => 'List Items',
|
||||
'LBL_DROPDOWN_ITEM_NAME' => 'Item Name',
|
||||
'LBL_DROPDOWN_ITEM_LABEL' => 'Display Label',
|
||||
|
||||
|
||||
|
||||
//RELATIONSHIPS
|
||||
'LBL_MODULE' => 'Module',
|
||||
'LBL_LHS_MODULE'=>'Primary Module',
|
||||
'LBL_CUSTOM_RELATIONSHIPS' => '* relationship created in Studio',
|
||||
'LBL_RELATIONSHIPS'=>'Relationships',
|
||||
'LBL_RELATIONSHIP_EDIT' => 'Edit Relationship',
|
||||
'LBL_REL_NAME' => 'Name',
|
||||
'LBL_REL_LABEL' => 'Label',
|
||||
'LBL_REL_TYPE' => 'Type',
|
||||
'LBL_RHS_MODULE'=>'Related Module',
|
||||
'LBL_NO_RELS' => 'No Relationships',
|
||||
'LBL_RELATIONSHIP_ROLE_ENTRIES'=>'Optional Condition' ,
|
||||
'LBL_RELATIONSHIP_ROLE_COLUMN'=>'Column',
|
||||
'LBL_RELATIONSHIP_ROLE_VALUE'=>'Value',
|
||||
'LBL_SUBPANEL_FROM'=>'Subpanel from',
|
||||
'LBL_RELATIONSHIP_ONLY'=>'No visible elements will be created for this relationship as there is a pre-existing visible relationship between these two modules.',
|
||||
'LBL_ONETOONE' => 'One to One',
|
||||
'LBL_ONETOMANY' => 'One to Many',
|
||||
'LBL_MANYTOONE' => 'Many to One',
|
||||
'LBL_MANYTOMANY' => 'Many to Many',
|
||||
|
||||
|
||||
//STUDIO QUESTIONS
|
||||
'LBL_QUESTION_FUNCTION' => 'Select a function or component.',
|
||||
'LBL_QUESTION_MODULE1' => 'Select a module.',
|
||||
'LBL_QUESTION_EDIT' => 'Select a module to edit.',
|
||||
'LBL_QUESTION_LAYOUT' => 'Select a layout to edit.',
|
||||
'LBL_QUESTION_SUBPANEL' => 'Select a subpanel to edit.',
|
||||
'LBL_QUESTION_SEARCH' => 'Select a search layout to edit.',
|
||||
'LBL_QUESTION_MODULE' => 'Select a module component to edit.',
|
||||
'LBL_QUESTION_PACKAGE' => 'Select a package to edit, or create a new package.',
|
||||
'LBL_QUESTION_EDITOR' => 'Select a tool.',
|
||||
'LBL_QUESTION_DROPDOWN' => 'Select a dropdown to edit, or create a new dropdown.',
|
||||
'LBL_QUESTION_DASHLET' => 'Select a dashlet layout to edit.',
|
||||
'LBL_QUESTION_POPUP' => 'Select a popup layout to edit.',
|
||||
//CUSTOM FIELDS
|
||||
'LBL_RELATE_TO'=>'Relate To',
|
||||
'LBL_NAME'=>'Name',
|
||||
'LBL_LABELS'=>'Labels',
|
||||
'LBL_MASS_UPDATE'=>'Mass Update',
|
||||
'LBL_AUDITED'=>'Audit',
|
||||
'LBL_CUSTOM_MODULE'=>'Module',
|
||||
'LBL_DEFAULT_VALUE'=>'Default Value',
|
||||
'LBL_REQUIRED'=>'Required',
|
||||
'LBL_DATA_TYPE'=>'Type',
|
||||
'LBL_HCUSTOM'=>'CUSTOM',
|
||||
'LBL_HDEFAULT'=>'DEFAULT',
|
||||
'LBL_LANGUAGE'=>'Language:',
|
||||
|
||||
|
||||
//SECTION
|
||||
'LBL_SECTION_EDLABELS' => 'Edit Labels',
|
||||
'LBL_SECTION_PACKAGES' => 'Packages',
|
||||
'LBL_SECTION_PACKAGE' => 'Package',
|
||||
'LBL_SECTION_MODULES' => 'Modules',
|
||||
'LBL_SECTION_PORTAL' => 'Portal',
|
||||
'LBL_SECTION_DROPDOWNS' => 'Dropdowns',
|
||||
'LBL_SECTION_PROPERTIES' => 'Properties',
|
||||
'LBL_SECTION_DROPDOWNED' => 'Edit Dropdown',
|
||||
'LBL_SECTION_HELP' => 'Help',
|
||||
'LBL_SECTION_ACTION' => 'Action',
|
||||
'LBL_SECTION_MAIN' => 'Main',
|
||||
'LBL_SECTION_EDPANELLABEL' => 'Edit Panel Label',
|
||||
'LBL_SECTION_FIELDEDITOR' => 'Edit Field',
|
||||
'LBL_SECTION_DEPLOY' => 'Deploy',
|
||||
'LBL_SECTION_MODULE' => 'Module',
|
||||
'LBL_SECTION_VISIBILITY_EDITOR'=>'Edit Visibility',
|
||||
//WIZARDS
|
||||
|
||||
//LIST VIEW EDITOR
|
||||
'LBL_DEFAULT'=>'Default',
|
||||
'LBL_HIDDEN'=>'Hidden',
|
||||
'LBL_AVAILABLE'=>'Available',
|
||||
'LBL_LISTVIEW_DESCRIPTION'=>'There are three columns displayed below. The <b>Default</b> column contains fields that are displayed in a list view by default. The <b>Additional</b> column contains fields that a user can choose to use for creating a custom view. The <b>Available</b> column displays fields availabe for you as an admin to add to the Default or Additional columns for use by users.',
|
||||
'LBL_LISTVIEW_EDIT'=>'List View Editor',
|
||||
|
||||
//Manager Backups History
|
||||
'LBL_MB_PREVIEW'=>'Preview',
|
||||
'LBL_MB_RESTORE'=>'Restore',
|
||||
'LBL_MB_DELETE'=>'Delete',
|
||||
'LBL_MB_COMPARE'=>'Compare',
|
||||
'LBL_MB_DEFAULT_LAYOUT'=>'Default Layout',
|
||||
|
||||
//END WIZARDS
|
||||
|
||||
//BUTTONS
|
||||
'LBL_BTN_ADD'=>'Add',
|
||||
'LBL_BTN_SAVE'=>'Save',
|
||||
'LBL_BTN_SAVE_CHANGES'=>'Save Changes',
|
||||
'LBL_BTN_DONT_SAVE'=>'Discard Changes',
|
||||
'LBL_BTN_CANCEL'=>'Cancel',
|
||||
'LBL_BTN_CLOSE'=>'Close',
|
||||
'LBL_BTN_SAVEPUBLISH'=>'Save & Deploy',
|
||||
'LBL_BTN_NEXT'=>'Next',
|
||||
'LBL_BTN_BACK'=>'Back',
|
||||
'LBL_BTN_CLONE'=>'Clone',
|
||||
'LBL_BTN_ADDCOLS'=>'Add Columns',
|
||||
'LBL_BTN_ADDROWS'=>'Add Rows',
|
||||
'LBL_BTN_ADDFIELD'=>'Add Field',
|
||||
'LBL_BTN_ADDDROPDOWN'=>'Add Dropdown',
|
||||
'LBL_BTN_SORT_ASCENDING'=>'Sort Ascending',
|
||||
'LBL_BTN_SORT_DESCENDING'=>'Sort Descending',
|
||||
'LBL_BTN_EDLABELS'=>'Edit Labels',
|
||||
'LBL_BTN_UNDO'=>'Undo',
|
||||
'LBL_BTN_REDO'=>'Redo',
|
||||
'LBL_BTN_ADDCUSTOMFIELD'=>'Add Custom Field',
|
||||
'LBL_BTN_EXPORT'=>'Export Customizations',
|
||||
'LBL_BTN_DUPLICATE'=>'Duplicate',
|
||||
'LBL_BTN_PUBLISH'=>'Publish',
|
||||
'LBL_BTN_DEPLOY'=>'Deploy',
|
||||
'LBL_BTN_EXP'=>'Export',
|
||||
'LBL_BTN_DELETE'=>'Delete',
|
||||
'LBL_BTN_VIEW_LAYOUTS'=>'View Layouts',
|
||||
'LBL_BTN_VIEW_FIELDS'=>'View Fields',
|
||||
'LBL_BTN_VIEW_RELATIONSHIPS'=>'View Relationships',
|
||||
'LBL_BTN_ADD_RELATIONSHIP'=>'Add Relationship',
|
||||
//TABS
|
||||
|
||||
|
||||
//ERRORS
|
||||
'ERROR_ALREADY_EXISTS'=> 'Error: Field Already Exists',
|
||||
'ERROR_INVALID_KEY_VALUE'=> "Error: Invalid Key Value: [']",
|
||||
'ERROR_NO_HISTORY' => 'No history files found',
|
||||
'ERROR_MINIMUM_FIELDS' => 'The layout must contain at least one field',
|
||||
'ERROR_GENERIC_TITLE' => 'An error has occured',
|
||||
'ERROR_REQUIRED_FIELDS' => 'Are you sure you wish to continue? The following required fields are missing from the layout: ',
|
||||
|
||||
|
||||
|
||||
|
||||
//PACKAGE AND MODULE BUILDER
|
||||
'LBL_PACKAGE_NAME'=>'Package Name:',
|
||||
'LBL_MODULE_NAME'=>'Module Name:',
|
||||
'LBL_AUTHOR'=>'Author:',
|
||||
'LBL_DESCRIPTION'=>'Description:',
|
||||
'LBL_KEY'=>'Key:',
|
||||
'LBL_ADD_README'=>' Readme',
|
||||
'LBL_MODULES'=>'Modules:',
|
||||
'LBL_LAST_MODIFIED'=>'Last Modified:',
|
||||
'LBL_NEW_MODULE'=>'New Module',
|
||||
'LBL_LABEL'=>'Label:',
|
||||
'LBL_LABEL_TITLE'=>'Label',
|
||||
'LBL_WIDTH'=>'Width',
|
||||
'LBL_PACKAGE'=>'Package:',
|
||||
'LBL_TYPE'=>'Type:',
|
||||
'LBL_TEAM_SECURITY'=>'Team Security',
|
||||
'LBL_ASSIGNABLE'=>'Assignable',
|
||||
'LBL_PERSON'=>'Person',
|
||||
'LBL_COMPANY'=>'Company',
|
||||
'LBL_ISSUE'=>'Issue',
|
||||
'LBL_SALE'=>'Sale',
|
||||
'LBL_FILE'=>'File',
|
||||
'LBL_NAV_TAB'=>'Navigation Tab',
|
||||
'LBL_CREATE'=>'Create',
|
||||
'LBL_LIST'=>'List',
|
||||
'LBL_VIEW'=>'View',
|
||||
'LBL_LIST_VIEW'=>'List View',
|
||||
'LBL_HISTORY'=>'View History',
|
||||
'LBL_RESTORE_DEFAULT'=>'Restore Default',
|
||||
'LBL_ACTIVITIES'=>'Activities',
|
||||
'LBL_SEARCH'=>'Search',
|
||||
'LBL_NEW'=>'New',
|
||||
'LBL_TYPE_BASIC'=>'basic',
|
||||
'LBL_TYPE_COMPANY'=>'company',
|
||||
'LBL_TYPE_PERSON'=>'person',
|
||||
'LBL_TYPE_ISSUE'=>'issue',
|
||||
'LBL_TYPE_SALE'=>'sale',
|
||||
'LBL_TYPE_FILE'=>'file',
|
||||
'LBL_RSUB'=>'This is the subpanel that will be displayed in your module',
|
||||
'LBL_MSUB'=>'This is the subpanel that your module provides to the related module for display',
|
||||
'LBL_MB_IMPORTABLE'=>'Importing',
|
||||
|
||||
// VISIBILITY EDITOR
|
||||
'LBL_VE_VISIBLE'=>'visible',
|
||||
'LBL_VE_HIDDEN'=>'hidden',
|
||||
'LBL_PACKAGE_WAS_DELETED'=>'[[package]] was deleted',
|
||||
|
||||
//EXPORT CUSTOMS
|
||||
'LBL_EC_TITLE'=>'Export Customizations',
|
||||
'LBL_EC_NAME'=>'Package Name:',
|
||||
'LBL_EC_AUTHOR'=>'Author:',
|
||||
'LBL_EC_DESCRIPTION'=>'Description:',
|
||||
'LBL_EC_KEY'=>'Key:',
|
||||
'LBL_EC_CHECKERROR'=>'Please select a module.',
|
||||
'LBL_EC_CUSTOMFIELD'=>'customized field(s)',
|
||||
'LBL_EC_CUSTOMLAYOUT'=>'customized layout(s)',
|
||||
'LBL_EC_NOCUSTOM'=>'No modules have been customized.',
|
||||
'LBL_EC_EMPTYCUSTOM'=>'has empty customizations.',
|
||||
'LBL_EC_EXPORTBTN'=>'Export',
|
||||
'LBL_MODULE_DEPLOYED' => 'Module has been deployed.',
|
||||
'LBL_UNDEFINED' => 'undefined',
|
||||
|
||||
//AJAX STATUS
|
||||
'LBL_AJAX_FAILED_DATA' => 'Failed to retrieve data',
|
||||
'LBL_AJAX_TIME_DEPENDENT' => 'A time dependent action is in progress. Please wait and try again in a few seconds.',
|
||||
'LBL_AJAX_LOADING' => 'Loading...',
|
||||
'LBL_AJAX_DELETING' => 'Deleting...',
|
||||
'LBL_AJAX_BUILDPROGRESS' => 'Build In Progress...',
|
||||
'LBL_AJAX_DEPLOYPROGRESS' => 'Deploy In Progress...',
|
||||
'LBL_AJAX_FIELD_EXISTS' =>'The field name you entered already exists. Please enter a new field name.',
|
||||
//JS
|
||||
'LBL_JS_REMOVE_PACKAGE' => 'Are you sure you wish to remove this package? This will permanently delete all files associated with this package.',
|
||||
'LBL_JS_REMOVE_MODULE' => 'Are you sure you wish to remove this module? This will permanently delete all files associated with this module.',
|
||||
'LBL_JS_DEPLOY_PACKAGE' => 'Any customizations that you made in Studio will be overwritten when this module is re-deployed. Are you sure you want to proceed?',
|
||||
|
||||
'LBL_DEPLOY_IN_PROGRESS' => 'Deploying Package',
|
||||
'LBL_JS_VALIDATE_NAME'=>'Name - Must be alphanumeric with no spaces and starting with a letter',
|
||||
'LBL_JS_VALIDATE_KEY'=>'Key - Must be alphanumeric',
|
||||
'LBL_JS_VALIDATE_LABEL'=>'Please enter a label that will be used as the Display Name for this module',
|
||||
'LBL_JS_VALIDATE_TYPE'=>'Please select the type of module you wish to build from the list above',
|
||||
'LBL_JS_VALIDATE_REL_NAME'=>'Name - Must be alphanumeric with no spaces',
|
||||
'LBL_JS_VALIDATE_REL_LABEL'=>'Label - please add a label that will be displayed above the subpanel',
|
||||
|
||||
//CONFIRM
|
||||
'LBL_CONFIRM_FIELD_DELETE'=>'Deleting this custom field will delete both the custom field and all the data related to the custom field from the database. The field will be no longer appear in any module layouts. Do you wish to continue?',
|
||||
'LBL_CONFIRM_RELATIONSHIP_DELETE'=>'Are you sure you wish to delete this relationship?',
|
||||
'LBL_CONFIRM_RELATIONSHIP_DEPLOY'=>'This will make this relationship permanent. Are you sure you wish to deploy this relationship?',
|
||||
'LBL_CONFIRM_DONT_SAVE' => 'Changes have been made since you last saved, would you like to save?',
|
||||
'LBL_CONFIRM_DONT_SAVE_TITLE' => 'Save Changes?',
|
||||
'LBL_CONFIRM_LOWER_LENGTH' => 'Data may be truncated and this cannot be undone, are you sure you wish to continue?',
|
||||
|
||||
//POPUP HELP
|
||||
'LBL_POPHELP_FIELD_DATA_TYPE'=>'Select the appropriate data type based on the type of data that will be entered into the field.',
|
||||
'LBL_POPHELP_IMPORTABLE'=>'<b>Yes</b>: The field will be included in an import operation.<br><b>No</b>: The field will not be included in an import.<br><b>Required</b>: A value for the field must be provided in any import.',
|
||||
'LBL_POPHELP_IMAGE_WIDTH'=>'Enter a number for Width, as measured in pixels.<br> The uploaded image will be scaled to this Width.',
|
||||
'LBL_POPHELP_IMAGE_HEIGHT'=>'Enter a number for the Height, as measured in pixels.<br> The uploaded image will be scaled to this Height.',
|
||||
'LBL_POPHELP_DUPLICATE_MERGE'=>'<b>Enabled</b>: The field will appear in the Merge Duplicates feature, but will not be available to use for the filter conditions in the Find Duplicates feature.<br><b>Disabled</b>: The field will not appear in the Merge Duplicates feature, and will not be available to use for the filter conditions in the Find Duplicates feature.'
|
||||
,
|
||||
|
||||
//Revert Module labels
|
||||
'LBL_RESET' => 'Reset',
|
||||
'LBL_RESET_MODULE' => 'Reset Module',
|
||||
'LBL_REMOVE_CUSTOM' => 'Remove Customizations',
|
||||
'LBL_CLEAR_RELATIONSHIPS' => 'Clear Relationships',
|
||||
'LBL_RESET_LABELS' => 'Reset Labels',
|
||||
'LBL_RESET_LAYOUTS' => 'Reset Layouts"',
|
||||
'LBL_REMOVE_FIELDS' => 'Remove Custom Fields',
|
||||
'LBL_CLEAR_EXTENSIONS' => 'Clear Extensions',
|
||||
'LBL_CLEAR_EXTENSIONS' => 'Clear Extensions',
|
||||
|
||||
|
||||
|
||||
'LBL_HISTORY_TIMESTAMP' => 'TimeStamp',
|
||||
'LBL_HISTORY_TITLE' => ' history',
|
||||
|
||||
'fieldTypes' => array(
|
||||
'varchar'=>'TextField',
|
||||
'int'=>'Integer',
|
||||
'float'=>'Float',
|
||||
'bool'=>'Checkbox',
|
||||
'enum'=>'DropDown',
|
||||
'multienum' => 'MultiSelect',
|
||||
'date'=>'Date',
|
||||
'phone' => 'Phone',
|
||||
'currency' => 'Currency',
|
||||
'html' => 'HTML',
|
||||
'radioenum' => 'Radio',
|
||||
'relate' => 'Relate',
|
||||
'address' => 'Address',
|
||||
'text' => 'TextArea',
|
||||
'url' => 'URL',
|
||||
'iframe' => 'IFrame',
|
||||
'encrypt'=>'Encrypt',
|
||||
'datetimecombo' =>'Datetime',
|
||||
'decimal'=>'Decimal',
|
||||
),
|
||||
|
||||
'parent' => 'Flex Relate',
|
||||
|
||||
'LBL_ILLEGAL_FIELD_VALUE' =>"Drop down key cannot contain quotes.",
|
||||
'LBL_CONFIRM_SAVE_DROPDOWN' =>"You are selecting this item for removal from the dropdown list. Any dropdown fields using this list with this item as a value will no longer display the value, and the value will no longer be able to be selected from the dropdown fields. Are you sure you want to continue?",
|
||||
);
|
||||
|
||||
657
modules/ModuleBuilder/language/pl_pl.lang.php
Executable file
657
modules/ModuleBuilder/language/pl_pl.lang.php
Executable file
@@ -0,0 +1,657 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Professional Subscription
|
||||
* Agreement ("License") which can be viewed at
|
||||
* http://www.sugarcrm.com/crm/products/sugar-professional-eula.html
|
||||
* By installing or using this file, You have unconditionally agreed to the
|
||||
* terms and conditions of the License, and You may not use this file except in
|
||||
* compliance with the License. Under the terms of the license, You shall not,
|
||||
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign
|
||||
* or otherwise transfer Your rights to the Software, and 2) use the Software
|
||||
* for timesharing or service bureau purposes such as hosting the Software for
|
||||
* commercial gain and/or for the benefit of a third party. Use of the Software
|
||||
* may be subject to applicable fees and any use of the Software without first
|
||||
* paying applicable fees is strictly prohibited. You do not have the right to
|
||||
* remove SugarCRM copyrights from the source code or user interface.
|
||||
*
|
||||
* All copies of the Covered Code must include on each user interface screen:
|
||||
* (i) the "Powered by SugarCRM" logo and
|
||||
* (ii) the SugarCRM copyright notice
|
||||
* in the same form as they appear in the distribution. See full license for
|
||||
* requirements.
|
||||
*
|
||||
* Your Warranty, Limitations of liability and Indemnity are expressly stated
|
||||
* in the License. Please refer to the License for the specific language
|
||||
* governing these rights and limitations under the License. Portions created
|
||||
* by SugarCRM are Copyright (C) 2004-2007 SugarCRM, Inc.; All Rights Reserved.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* pl_pl.lang.php,v for SugarCRM 4.5.1b
|
||||
* Translator: Krzysztof Morawski
|
||||
* All Rights Reserved.
|
||||
* Any bugs report welcome: krzysiek<at>kmmgroup<dot>pl
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$mod_strings = array(
|
||||
'help'=>array(
|
||||
'package'=>array(
|
||||
'create'=>'Wprowadź <b>Nazwę</b> dla pakietu. Musi ona składać się ze znaków alfanumerycznych i nie zawierać spacji. (Przykład: HR_Zarządzanie)<br/><br/> Możesz podać <b>Autora</b> i <b>Opis</b>, jako informację o pakiecie. <br/><br/>Kliknij <b>Zapisz</b> aby utworzyć pakiet.',
|
||||
'modify'=>'Właściwości i możliwe działania na <b>pakiecie</b> pojawiają się <b>tutaj</b>. Możesz zmodyfikować <b>Nazwisko</b>, <b>Autora</b> oraz <b>Opis</b> pakietu, tak jak widok pakietu, jak również wszystkie jego moduły.<br><br>Możesz również <b>Publikować</b> i <b>Zamieszczać</b> pakiet, jak również <b>Eksportować</b> presonalizacje w pakiecie.',
|
||||
'name'=>'To jest <b>Nazwa</b> bieżącego modułu. <br/><br/>Nazwa, którą wprowadzasz musi być złożona ze znaków alfanumerycznych, rozpoczynać się od litery i nie zawierać spacji. (Przykład: HR_Management)',
|
||||
'author'=>'To jest określenie <b>Autora</b>, które jest wyświetlane podczas instalacji, jako podmiotu tworzącego pakiet. Autor może być zarówno osobą, jak i organizacją.',
|
||||
'description'=>'To jest <b>Opis</b> pakietu wyświetlany podczas instalacji.',
|
||||
'publishbtn'=>'Kliknij <b>Publikuj</b>, aby zapisać wszystkie zmiany i utworzyć plik .zip, który jest instalacyjną wersją pakietu.<br><br>Użyj <b>Ładowacza Modułów</b> aby załadować plik .zip i zainstalować pakiet.',
|
||||
'deploybtn'=>'Kliknij <b>Zamieść</b> aby zapisać wprowadzone dane i zainstalować pakiet, zawierający wszystkie moduły.',
|
||||
'duplicatebtn'=>'Kliknij <b>Duplikuj</b>, aby skopiować zawartość pakietu do nowego i aby wyświetlić nowy pakiet. <br/><br/>Nazwa dla nowego pakietu zostanie wygenerowana automatycznie, poprzez dodanie numeru do nazwy pakietu, z którego został utworzony. Możesz zmienić nazwę nowego pakietu przez wprowadzenie nowej <b>Nazwy</b> i kliknięcie <b>Zachowaj</b>.',
|
||||
'exportbtn'=>'Kliknij <b>Eksport</b> aby utworzyć plik .zip, zawierający personalizacje użyte przy tworzeniu pakietu.<br><br> Wygenerowany plik zawiera kod personalizacji dla pakietu i nie jest plikiem instalacyjnym pakietu.<br><br>Użyj <b>Ładowacza Modułów</b> aby zaimportować plik zip, i umożliwić użycie personalizacji w nowych pakietach.',
|
||||
'deletebtn'=>'Kliknij <b>Usuń</b> aby usunać pakiet i wszystkie pliki powiązane z nim.',
|
||||
'savebtn'=>'Kliknij <b>Zapisz</b> aby zapisać wszystkie wprowadzone dane powiązane z pakietem.',
|
||||
'existing_module'=>'Kliknij <b>ikonę modułu</b>,aby edytować wartości i dostosować pola, zależności i wyglądy, należące do tego modułu.',
|
||||
'new_module'=>'Kliknij <b>Nowy moduł</b>, aby utworzyć nowy moduł dla tego pakietu.',
|
||||
'key'=>'Ten 5-cio literowy, alfanumeryczny <b>Klucz</b> będzie używany jako przedrostek w każdym katalogu, nazwie klasy i tabeli, dla każdego modułu tego pakietu.<br><br>Klucz jest używany w celu osiągnięcia unikalnych nazw dla tabel.',
|
||||
'readme'=>'Możesz dodać tekst <b>Readme</b> do tego pakietu.<br><br>Będzie on dostępny podczas instalacji.',
|
||||
),
|
||||
'main'=>array(
|
||||
|
||||
),
|
||||
'module'=>array(
|
||||
'create'=>'Podaj <b>Nazwę</b> nowego modułu. <b>Etykieta</b>, którą wprowadzisz pojawi się w Zakładce Nawigacyjnej. <br/><br/>Wyświetlanie Zakładki Nawigacyjnej uzyskasz przez zaznaczenie pola <b>Zakładka Nawigacyjna</b>.<br/><br/>Zaznacz pole <b>Bezpieczeństwo Zespołu</b> by uzyskać możliwość dostępu do wybranych rekordów w obrębie Zespołu. <br/><br/>Następnie wybierz typu modułu, który chcesz utworzyć. <br/><br/>Wybierz Szkic. Każdy z wzorów zawiera określony zestaw pól, takich jak predefiniowane wyglądy, używane jako wyjściowe dla modułu. <br/><br/>Kliknij <b>Zachowaj</b> aby utworzyć moduł.',
|
||||
'modify'=>'Możesz zmienić właściwości modułu lub dostosować <b>Pola</b>, <b>Zależności</b> i <b>Wyglądy</b>, powiązane z tym modułem.',
|
||||
'importable'=>'Zaznaczenie pola <b>Importowalny</b> właczy możliwość imoportu dla tego modułu.<br><br>Link do kreatora importu pojawi się w panelu skrótów w module. Właściwości kreatora importu pozwalają wprowadzać dane z zewnętrzynch źrodeł do własnego modułu.',
|
||||
'team_security'=>'Zaznaczenie pola <b>Bezpieczeństwo zespołu</b> włączy funkcję bezpieczeństwa zespołu dla tego modułu. <br/><br/>Jeśli funkcja bezpieczeństwa zespołów jest włączona dla tego modułu, pola wyborów dla zespołów pojawią się w widokach tego modułu.',
|
||||
'reportable'=>'Zaznaczenie tego pola umożliwi wykonanie raportów z udziałem tego modułu.',
|
||||
'assignable'=>'Zaznaczenie tego pola umożliwi przydzielanie rekordów w tym module do poszczególnych użytkowników.',
|
||||
'has_tab'=>'Zaznaczenie pola <b>Zakładka nawigacyjna</b> wyświetli zakładkę nawigacyjną w module.',
|
||||
'acl'=>'Zaznaczenie tego pola włączy funkcję kontroli dostępu w tym module, również bezpieczeństwa dla pól.',
|
||||
'studio'=>'Zaznaczenie tego pola zezwoli administratorom dostosowywać ten moduł w Studio.',
|
||||
'audit'=>'Zaznaczenie tego pola włączy logowanie zmian w tym module. Zmiany w poszczególnych polach będą rejestrowane i administratorzy będą mogli zobaczyć tę historię.',
|
||||
'viewfieldsbtn'=>'Kliknij <b>Zobacz pola</b> aby zobaczyć pola powiązane z tym modułem i w celu tworzenia lub edycji własnych pól.',
|
||||
'viewrelsbtn'=>'Kliknij <b>Zależności</b> aby zobaczyć zależności powiązane z tym modułem w celu tworzenia lub edycji zależności.',
|
||||
'viewlayoutsbtn'=>'Kliknij <b>Zobacz widoki</b> aby zobaczyć widoki modułu i ustawić własny układ pól w widokach modułu.',
|
||||
'duplicatebtn'=>'Kliknij <b>Duplikuj</b> aby skopiować właściwości modułu do nowo tworzonego modułu i wyświetlić go. <br/><br/> Nazwa dla nowego modułu jest generowana automatycznie, poprzez dodanie numeru na końcu nazwy modułu pierwotnego.<br><br>Możesz zmienić nazwę nowego modułu, wprowadzając nową <b>Nazwę</b> i klikając <b>Zachowaj</b>.',
|
||||
'deletebtn'=>'Kliknij <b>Usuń</b>, aby usunąć ten moduł.',
|
||||
'name'=>'To jest <b>Nazwa</b> edytowanego modułu. <br/><br/>Nazwa, którą wprowadzasz musi skladać się ze znaków alfanumerycznych, zaczynać od litery i nie zawierać spacji. (Przykład: HR_Management)',
|
||||
'label'=>'To jest <b>Etykieta</b>, która pojawiać się będzie na zakładce nawigacyjnej modułu. ',
|
||||
'savebtn'=>'Kliknij <b>Zachowaj</b>, aby zachować dane powiązane z modułem.',
|
||||
'type_basic'=>'<b>Podstawowy</b> wzorzec, ma zdefiniowane domyślnie takie nazwy pól jak nazwa, przydzielone do, zespół, data utworzenia i opis.',
|
||||
'type_company'=>'Wzorzec <b>Firma</b> zawiera pola specyfinczne dla określenia organizacji, jak np. Nazwa firmy, typ działalności, adres fakturowania.<br/><br/>Używaj tego wzorca do tworzenia modułów podobnych do modułu Klienci.',
|
||||
'type_issue'=>'Wzorzec <b>Cecha</b> zawiera pola typowe dla modułów spraw i śledzenia błędów, takie jak numer, status, priorytet, opis.<br/><br/>Używaj tego wzorca do tworzenia modułów podobnych do modułu Sprawy, lub Śledzenie błędów.',
|
||||
'type_person'=>'Wzorzec <b>Osoba</b> zawiera pola typowe dla określenia osoby, takie jak pozdrowienie, tytuł, nazwisko, adres i numer telefonu.<br/><br/>Używaj tego wzorca do tworzenia modułów podobnych do modułu kontakty, czy adresy.',
|
||||
'type_sale'=>'Wzorzec <b>Sprzedaż</b> zawiera pola typowe dla modułu określającego okazję - szansę sprzedaży, takie jak pochodzenie adresu/kontaktu, poziom zaawansowania, kwotę transakcji i prawdopodobieństwo. <br/><br/>Używaj tego wzorca do tworzenia modułów podobnych do standardowego modułu Okazji.',
|
||||
'type_file'=>'Wzorzec <b>Plik</b> zawiera pola typowe dla modułu określającego pracę na dokumentach, takie jak nazwa pliku, typ dokument lub data publikacji.<br><br>Używaj tego wzorca do tworzenia modułów podobnych do modułu zarządzania dokumenty.',
|
||||
|
||||
),
|
||||
'dropdowns'=>array(
|
||||
'default' => 'Wszystkie <b>listy rozwijalne</b> występujące w aplikacj są tutaj wymienione.<br><br>Listy te mogą zostać użyte do tworzenia rozwijalnych list w dowolnym module.<br><br>Aby wprowadzić zmiany w istniejącej liście, kliknij na jej nazwę.<br><br>Kliknij <b>Dodaj listę rozwijalną</b> aby utworzyć nową.',
|
||||
'editdropdown'=>'Listy rozwijalne mogą być używane dla standardowych i utworzonych własnych pól w dowolnym module.<br><br>Wprowadź <b>Nazwę</b> dla listy rozwijalnej.<br><br>Jeżeli w aplikacji są zainstalowane pakiety językowe, możesz określić <b>Język</b> elementów listy.<br><br>W polu <b>Nazwa Elementu</b> wprowadź nazwę dla opcji w liscie rozwijalnej. Nazwa ta nie będzie widoczna na liście rozwijalnej widocznej dla użytkowników.<br><br>W polu <b>Wyświetl etykietę</b> wprowadź etykietę, która pojawi się na liście rozwijalnej.<br><br>Po wprowadzeniu nazwy elementu i etykiety, kliknij <b>Dodaj</b>, aby dodać nowy elemnet do listy.<br><br>W celu zmiany kolejności elementów listy, przeciągnij i upuść elementy w porządanym miejscu.<br><br>Aby edytować etykietę elementu, kliknij na ikonę<b>Edytuj</b>, i wprowadź nową etykietę. Aby usunąć element z listy rozwijalnej, kliknij na ikonie <b>Usuń</b>.<br><br>Aby cofnąć zmiany wprowadzone w etykietach, kliknij <b>Cofnij</b>. Aby przywrócić usunięte uprzednio zmiany, kliknij <b>Przywróć</b>.<br><br>Kliknij <b>Zachowaj</b> aby zatwierdzić aktualny wygląd list rozwijalnych.',
|
||||
|
||||
),
|
||||
'subPanelEditor'=>array(
|
||||
'modify' => 'Wszystkie pola, które mogą zostać wyświetlone w <b>Subpanelach</b> pojawią się tutaj.<br><br><b>Domyślna</b> kolumna zawiera pola, które są wyświetlone w Subpanelu.<br/><br/><b>Ukryta</b> kolumna zawiera pola, które mogą zostać dodane do kolumny Domyślnej.',
|
||||
'savebtn' => 'Kliknij <b>Zachowaj i zamieść</b>, aby zachować zmiany wykonane przez Ciebie i uczynić je aktywnymi.',
|
||||
'historyBtn'=> 'Kliknij <b>Zobacz historię</b> jeśli chcesz przejrzeć i przywrócić poprzednio zapisany wygląd z historii.',
|
||||
'historyDefault'=> 'Kliknij przycisk<b>Przywróć domyślne</b> aby przywrócić do orginalny wygląd.',
|
||||
'Hidden' => 'Pola <b>Ukryte</b> nie pojawią się w subpanelu.',
|
||||
'Default' => '<b>Domyślne</b> pojawią się w subpanelu.',
|
||||
|
||||
),
|
||||
'listViewEditor'=>array(
|
||||
'modify' => 'Wszystkie pola, które mogą zostać wyświetlone w <b>Widoku listy</b> pojawią się tutaj.<br><br>Kolumna <b>Domyślne</b> zawiera te pola, które są wyświetlone w Widoku listy domyślnie.<br/><br/>Kolumna <b>Dostępne</b> zawiera pola, które mogą zostać wybrane przez użytkownika w celu utworzenia własnego widoku listy. <br/><br/>Kolumna <b>Ukryte</b> zawiera pola, które mogą zostać dodane do kolumn Domyślne lub Dostępne.',
|
||||
'savebtn' => 'Kliknij <b>Zachowaj i zamieść</b> aby zapisać zmiany i uaktywnić je w module.',
|
||||
'historyBtn'=> 'Kliknij <b>Zobacz historię</b>, aby zobaczyć historię zmian, lub przywrócić porzednio zachowany widok.',
|
||||
'historyDefault'=> 'Kliknij przycisk<b>Przywróć domyślne</b> aby przywrócić do orginalny wygląd.',
|
||||
'Hidden' => 'Pola <b>Ukryte</b> nie są obecnie dostępne dla użytkowników w widoku listy.',
|
||||
'Available' => 'Pola <b>Dostępne</b> nie są widoczne domyślnie, ale mogą zostać dodane do widoku listy przez użytkowników.',
|
||||
'Default' => 'Pola <b>Domyślne</b>, widoczne w widoku listy nie są edytowalne przez użytkowników.'
|
||||
),
|
||||
'searchViewEditor'=>array(
|
||||
'modify' => 'Wszystkie pola, które mogą zostać wyświetlone w formularzu <b>Wyszukaj</b> pojawią się tutaj.<br><br>Kolumna <b>Domyślne</b> zawiera pola, które będą wyświetlone w formularzu Wyszukaj.<br/><br/>Kolumna <b>Ukryte</b> zawiera pola dostępne dla Ciebie, jako administratora do dodania do formularza Wyszukaj.',
|
||||
'savebtn' => 'Kliknięcie <b>Zachowaj i zamieść</b> zapisze wszystkie zmiany i uaktywni je',
|
||||
'Hidden' => 'Pola <b>Ukryte</b> nie pojawią się w "Wyszukaj".',
|
||||
'historyBtn'=> 'Kliknij <b>Zobacz historię</b>, aby zobaczyć lub przywrócić poprzednio zachowany wygląd.',
|
||||
'historyDefault'=> 'Kliknij przycisk<b>Przywróć domyślne</b> aby przywrócić orginalny wygląd.',
|
||||
'Default' => 'Pola <b>Domyślne</b> pojawią się w "Wyszukaj".',
|
||||
),
|
||||
'layoutEditor'=>array(
|
||||
'defaultdetailview'=>'Obszar <b>Widoku</b> zawiera pola, które są obecnie wyświetlone w <b>Widoku szczegółowym</b>.<br/><br/><b>Skrzynka narzędziowa</b> zawiera <b>Kosz</b>, oraz elementy widoku, które mogą zostać dodane do widoku.<br><br>Zmian w widoku dokonuje się przeciągając i upuszczając elementy i pola pomiędzy <b>Skrzynkką</b> a <b>Widokiem</b> i samym widokiem.<br><br>Aby usunąć pola z widoku, przeciągnij pola do <b>Kosza</b>. Pola będą wtedy dostępne w Skrzynce narzędziowej i możliwe do dodania do widoku.',
|
||||
'defaultquickcreate'=>'Obszar <b>Widoku</b> zawiera pola, które są obecnie wyświetlone w formularzu <b>Szybkie tworzenie</b>.<br><br>Formularz ten pojawia się w subpanelach dla modułu, gdy przycisk Utwórz jest klilknięty.<br/><br/><b>Skrzynka narzędziowa</b> zawiera <b>Kosz</b>, pola i elementy widoku, które mogą zostać dodane do widoku.<br><br>Zmian w widoku dokonuje się przeciągając i upuszczając elementy i pola pomiędzy <b>Skrzynkką</b> a <b>Widokiem</b> i samym widokiem.<br><br>Aby usunąć pola z widoku, przeciągnij pola do <b>Kosza</b>. Pola będą wtedy dostępne w Skrzynce narzędziowej i możliwe do dodania do widoku.',
|
||||
//this defualt will be used for edit view
|
||||
'default' => 'Obszar <b>Widoku</b> zawiera pola, które są obecnie wyświetlone w <b>Widoku szczegółowym</b>.<br/><br/><b>Skrzynka narzędziowa</b> zawiera <b>Kosz</b>, oraz elementy widoku, które mogą zostać dodane do widoku.<br><br>Zmian w widoku dokonuje się przeciągając i upuszczając elementy i pola pomiędzy <b>Skrzynkką</b> a <b>Widokiem</b> i samym widokiem.<br><br>Aby usunąć pola z widoku, przeciągnij pola do <b>Kosza</b>. Pola będą wtedy dostępne w Skrzynce narzędziowej i możliwe do dodania do widoku.',
|
||||
'saveBtn' => 'Kliknij <b>Zachowaj</b>, aby zabezpieczyć zmiany dokonane w wyglądzie widoku od ostatniego zapisu.<br><br>Zmiany nie będą wyświetlone w module, dopóki nie zostaną zamieszczone.',
|
||||
'historyBtn'=> 'Kliknij <b>Zobacz historię</b>, aby zobaczyć lub przywrócić poprzednio zachowany widok.',
|
||||
'historyDefault'=> 'Kliknij przycisk<b>Przywróć domyślne</b> aby przywrócić orginalny wygląd.',
|
||||
'publishBtn'=> 'Kliknięcie <b>Zachowaj i zamieść</b> zapisze wszystkie zmiany od ostatniego zapisu i uaktywni je w module. Widok będzię niezwłocznie wyświetlony w module.',
|
||||
'toolbox' => '<b>Skrzynka narzędziowa</b> zawiera <b>Kosz</b>, dodatkowe elementy widoku i zestaw dostępnych pól do dodania do widoku.<br/><br/>Elementy widoku i pola w Skrzynce mogą być przeciągane i upuszcznane na widoku i vice versa.<br><br>Elementami widoku są <b>Panele</b> i <b>Wiersze</b>. Dodanie nowego wiersza lub panelu do widoku wprowadza dodatkowe miejsce dla pól do widoku.<br/><br/>Przeciągnięcie i upuszczenie pól w obrębie Skrzynki lub widoku na miejscu, zajmowanym już przez inne pole, spowoduje zamianę pozycji obu pól.<br/><br/>Pole <b>Wypełniacz</b> tworzy pustą przestrzeń w widoku, tam, gdzie zostanie umieszczone.',
|
||||
'panels' => 'Obszar <b>Widoku</b> przedstawia podgląd tego, jak będzie wyglądał w module, gdy zmiany zostaną zapisane i zamieszczone.<br/><br/>Możesz zmienić pozycję pól, wierszy i paneli, przez przeciągnięcie ich w porządane miejsce.<br/><br/>Usuwanie elementów następuje przez przeciągnięcie i upuszczenie ich do <b>Kosza</b> w Skrzynce narzędziowej. Dodawanie elementów do widoku odbywa się w odwrotnej kolejności.',
|
||||
'delete' => 'Przeciągnij i upuść dowolny element, aby usunąć go z widoku',
|
||||
'property' => 'Edytuj etykietę, dla tego pola. <br/><b>Tab Order</b> controls in what order the tab key switches between fields.',
|
||||
),
|
||||
'fieldsEditor'=>array(
|
||||
'default' => 'Nazwy <b>Pól</b>, dostępnych w tym module są wymienione tutaj.<br><br>Własne pola utworzone w module są wymienione poniżej pól dostępnych domyślnie.<br><br>W celu edycji pola, kliknij <b>Nazwę pola</b>.<br/><br/>Aby utworzyć pole, kliknij <b>Dodaj pole</b>.',
|
||||
'mbDefault'=>'Nazwy <b>Pól</b>, dostępnych w tym module są wymienione tutaj.<br><br>Aby utworzyć własne pole z wzorca, kliknij na jego nazwie.<br><br>Aby utworzyć nowe, kliknij <b>Dodaj pole</b>. Etykieta inne właściwości utworzonego pola mogą być edytowane później przez kliknięcie na nazwy pola.<br><br>Gdy moduł jest już zamieszczony, pola utworzone za pomocą Budowniczego Modułów wyglądają jak pola standardowe w Studio.',
|
||||
'addField' => 'Wybierz <b>Typ danych</b> dla nowego pola. Typ, który wybierzesz, określa rodzaj znaków wprowadzanych do pola. Na przykład tylko liczby całkowite mogą zostać wprowadzone do pola typu integer.<br><br> Określ <b>Nazwę</b> dla pola. Nazwa musi składać się ze znaków alfanumerycznych i nie zawierać żadnych spacji. Podkreślenia są dozwolone.<br><br> <b>Etykieta wyświetlana</b> to etykieta widoczna w widokach modułu. <b>Etykieta systemowa</b> jest używana do określenia pola w kodzie.<br><br> Zależenie od wybranego dla pola typu danych, niektóre lub wszystkie z wymienionych właściwości mogą być określone dla pola:<br><br> <b>Tekst pomocy</b> pojawia się okresowo, gdy użytkownik przeciągnie wskaźnik nad polem.<br><br> <b>Tekst komentarza</b> jest widziany tylko w Studio &/lub w Budowniczym Modułów i może opisywać przeznaczenie pola, przydatne dla administratorów<br><br> <b>Wartość domyślna</b> jest widoczna w polu. Użytkownicy mogą wprowadzić nową wartość, lub użyć domyślnej.<br><br> Zaznacz opcję <b>Masowa aktualizacja</b>, by móc skorzystać z funkcji masowej aktualizacji dla danego pola.<br><br>Wartość <b>Maksymalny rozmiar</b> determinuje największą ilość znaków, które mogą zostać wprowadzone do pola.<br><br> Zaznacz opcję <b>Pole wymagane</b>, aby dane pole było konieczne do wypełnienia. Wtedy trzeba będzie zawsze wprowadzić jakąś wartość dla pola, aby móc zapisać rekord zawierający to pole.<br><br> Wybierz opcję <b>Raportowalne</b> aby pole mogło być użyte w filtrach, oraz aby dane były wyświetlane w Raportach.<br><br> Wybierz opcję <b>Audytu</b>, aby móc śledzić zmiany danych pola Dzienniku zmian.<br><br>Dodatkowe właściwości mogą być określane dla poszczególnych typów danych.',
|
||||
'editField' => '<b>Etykieta wyświetlana</b> pola może być zmieniana. Inne właściwości pola - nie.<br><br>Kliknij <b>Klonuj</b>, aby utworzyć nowe pole z takimi samymi właściwościami.',
|
||||
'mbeditField' => '<b>Etykieta wyświetlana</b> pola wzorca pola może być zmieniana. Inne właściwości pola - nie.<br><br>Kliknij <b>Klonuj</b>, aby utworzyć nowe pole z takimi samymi właściwościami.<br><br>Aby usunąć pole wzorca, tak aby nie było widoczne w module, usuń je z odpowiedniego <b>Widoku</b>.'
|
||||
|
||||
),
|
||||
'exportcustom'=>array(
|
||||
'exportHelp'=>'Zmiany własne dokonane za pomocą modułu Studio w tej instancji mogą zostać spakowane i zamieszczone w innej. <br><br>Wprować <b>Nazwę pakietu</b>. W pakiecie możesz zamieścić informacje o <b>Autorze</b> i <b>Opis</b>.<br><br>Wybierz moduł(y),przeznaczone do eksportu,zawierające zmiany własne. Możesz wybrać tylko moduły zawierające te zmiany.)<br><br>Kliknij <b>Eksport</b>, aby stworzyć plik .zip pakietu zawierającego zmiany własne. Plik .zip może zostać załadowany do innej instancji za pomocą <b>Ładowacza modułów</b>.',
|
||||
'exportCustomBtn'=>'Kliknij <b>Eksport</b>, aby utworzyć plik .zip pakietu zawierającego dostosowania, które chcesz wyeksportować.',
|
||||
'name'=>'<b>Nazwa</b> pakietu zostanie wyświetlona w Ładowaczu modułów, po tym jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
'author'=>'Określenie <b>Autor</b> to nazwa podmiotu tworzącego pakiet. Autorem może być zarówno osoba jak i firma.<br><br>Autor zostanie wyświetlony w Ładowaczu Modułów, po tym, jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
'description'=>'<b>Opis</b> pakietu zostanie wyświetlony w Ładowaczu Modułów, po tym, jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
),
|
||||
'studioWizard'=>array(
|
||||
'mainHelp' => 'Witamy w strefie <b>Narzędzia Programisty</b1>. <br/><br/>W tej strefie możesz używać narzędzi, aby tworzyć i zarządzać standardowymi i dostosowywanymi modułami i polami.',
|
||||
'studioBtn' => 'Użyj <b>Studio</b> aby dostosować zainstalowane moduły, poprzez zmianę aranżacji pól, wybór, które z nich mają być dostępne i aby tworzyć własne pola danych.',
|
||||
'mbBtn' => 'Użyj <b>Budowniczego Modułów</b> aby tworzyć moduły.',
|
||||
'sugarPortalBtn' => 'Użyj <b>Edytora portalu Sugar</b> do zarządznia i zmieniania portalu Sugar.',
|
||||
'dropDownEditorBtn' => 'Użyj <b>Edytora list rozwijalnytch</b> aby dodać i edytować globalne listy rozwijalne.',
|
||||
'appBtn' => 'Tryb aplikacji działa, gdy chcesz dostosować różne właściwości programu, takie jak np. jak dużo TPS raportów jest wyświetlanych na stronie głównej.',
|
||||
'backBtn' => 'Powrót do poprzedniego kroku.',
|
||||
'studioHelp'=> 'Użyj <b>Studio</b> aby określić co i jak informacje zostaną wyświetlone w modułach.',
|
||||
'moduleBtn' => 'Kliknij, aby edytować ten moduł.',
|
||||
'moduleHelp'=> 'Wybierz element modułu, który chcesz edytować.',
|
||||
'fieldsBtn' => 'Zdecyduj, które informacje są zapisywane w module, poprzez sterowanie <b>Polami</b> w module.<br/><br/>Tutaj możesz także edytować i tworzyć własne pola.',
|
||||
'labelsBtn' => 'Edytuj <b>Etykiety</b>, które są wyświetlane dla pól i innych tytułów w module.' ,
|
||||
'relationshipsBtn' => 'Dodaj nową, lub obejrzyj istniejące <b>Zależności</b> dla modułu.' ,
|
||||
'layoutsBtn'=> 'Dostosuj <b>Wyglądy</b> modułu. Wyglądy są innymi widokami modułu, zawierającego pola.<br><br>Możesz ustalić, które pola bedą widoczne i jak zostaną uszeregowane w każdym z wyglądów.',
|
||||
'subpanelBtn'=> 'Ustal, które pola pojawią się w <b>Subpanelach</b> modułu.',
|
||||
'portalBtn' =>'Dostosuj <b>Wyglądy</b> modułu, które pojawią sie w <b>Portalu Sugar</b>.',
|
||||
'layoutsHelp'=> '<b>Wyglądy</b> modułu, które mogą być dostosowywane są pokazane tutaj<br><br>Wyglądy wyświetlają pola i ich zawartość<br><br>Kliknij na ikonie, aby wybrać wygląd do edycji.',
|
||||
'subpanelHelp'=> '<b>Subpanele</b> w module, które mogą być dostosowywane są widoczne tutaj.<br><br>Kliknij na ikonie, aby wybrać moduł do edycji.',
|
||||
'newPackage'=>'Kliknij <b>Nowy Pakiet</b> by utworzyć nowy pakiet.',
|
||||
'exportBtn' => 'Kliknij <b>Wyeksportuj dostosowania</b>, aby zbudować pakiet zawierający własne modyfikacje, stworzone w Studio, dla określonego modułu.',
|
||||
'mbHelp' => '<b>Witamy w Budowniczym Modułów.</b><br/><br/><b>Budowniczy Modułów</b> jest używany do tworzenia pakietów zawierających dostosowane przez Ciebie moduły, bazujące na standardowych, lub własnych modułach. <br/><br/>Aby rozpocząć, kliknij <b>Nowy Pakiet</b> w celu utworzenia nowego pakietu, lub wybierz pakiet do edycji.<br/><br/> <b>Pakiet</b> może być zbiorem własnych modułów, które są częścią jednego projektu. Pakiet może więc zawierać więcej niż jeden moduł własny, który może być połączony z dowolnym innym modułem w aplikacji. <br/><br/>Przykład: Możesz stworzyć pakiet, zawierający jeden moduł własny, który jest połączony ze standardowym modułem <b>Klienci</b>. lub stworzyć kilka modułów, współpracujących ze sobą, jako projekt i będących zależnymi od modułów alikacji.',
|
||||
'viewBtnEditView' => 'Dostosuj <b>Widok edycji</b> modułu.<br><br>Ten widok to formularz zawierający pola zbierające dane wprowadzanie przez użytkownika.',
|
||||
'viewBtnDetailView' => 'Dostosuj <b>Widok szczegółowy</b> modułu.<br><br>Ten widok to formularz zawierający pola zbierające dane wprowadzanie przez użytkownika.',
|
||||
'viewBtnDashlet' => 'Dostosuj <b>Belki</b> modułu, zawierające belki widoku listy i wyszukiwania.<br><br> Belka będzie mogła być również dodana do strony głównej.',
|
||||
'viewBtnListView' => 'Dostosuj <b>Widok listy</b> modułu.<br><br>Wynik wyszukiwania pojawi się w widoku listy.',
|
||||
'searchBtn' => 'Dostosuj widok <b>Szukaj</b>.<br><br>Określ jakie pola mogą zostać użyte do filtrowania rekordów, które pojawią się w widoku listy.',
|
||||
'viewBtnQuickCreate' => 'Dostosuj widok <b>Szybkie tworzenie</b>.<br><br>Formularz szybkiego tworzenia pojawia się w subpanelach i w module poczty.',
|
||||
'searchHelp'=> 'Formularz <b>Szukaj</b>, który może zostać dostosowany pojawi się tutaj.<br><br>Formularz zawiera pola, służące do filtrowania rekordów.<br><br>Kliknij na ikonie, aby wybrać wygląd do edycji.',
|
||||
'dashletHelp' =>'Wygląd <b>Belek</b>, który może zostać dostosowany pojawi się tutaj.<br><br>Belki są dostępne do dodawania na stronach modułu startowego.',
|
||||
'DashletListViewBtn' =>'<b>Widok listy belek</b> wyświetla rekordy bazujące na filtrach wyszukiwania belek.',
|
||||
'DashletSearchViewBtn' =>'Rekordy Filtrów widoku <b>Wyszukiwania Belek</b>.',
|
||||
'BasicSearchBtn' => 'Dostosuj formularz <b>Proste wyszukiwanie</b>, który pojawi się w zakładce "Proste wyszukiwanie" w obszarze wyszukiwania dla modułu.',
|
||||
'AdvancedSearchBtn' => 'Dostosuj formularz <b>Wyszukiwanie zaawansowane</b>, który pojawi się w zakładce "Wyszukiwanie zaawansowane" w obszarze wyszukiwania dla modułu.',
|
||||
'portalHelp' => 'Zarządzaj i dostosuj <b>Portal Sugar</b>.',
|
||||
'SPUploadCSS' => 'Załaduj <b>Arkusz stylów</b> dla Portalu Sugar.',
|
||||
'SPSync' => '<b>Synchronizuj</b> dostosowywane elementy z instancją Portalu Sugar.',
|
||||
'Layouts' => 'Dostosuj <b>Wygląd</b> modułów portalu Sugar.',
|
||||
'portalLayoutHelp' => 'Moduły w Portalu pojawiają się w tym obszarze.<br><br>Wybierz moduł, aby móc edytować <b>Wygląd</b>.',
|
||||
'relationshipsHelp' => 'Wszystkie <b>Zależności</b>, które istnieją pomiędzy modułami nadrzędnymi i podległymi pojawiają sie tutaj.<br><br><b>Nazwa</b> zależności jest generowana automatycznie przez system.<br><br><b>Moduł Nadrzędny</b> to moduł, do którego należa wszystkie zależności. Na przykład, wszystkie właściwości zależności, dla których moduł Klienci jest modułem nadrzędnym, są przechowywane w tabelach bazy danych dla modułu Klienci.<br><br>Kliknin wiersz w tabeli zależności, aby zobaczyć właściwości powiązane z nią.<br><br>Kliknij <b>Dodaj zależność</b> w celu utworzenia nowej zależności.<br><br>Zależności mogą być tworzone pomiędzy dowolnymi zamieszczonymi już modułami.',
|
||||
'relationshipHelp'=>'<b>Zależności</b> tworzą się pomiędzy modułem nadrzędnym i innym zamieszczonym modułem.<br><br> Zależności są przedstawione wizualnie jako subpanele i połączone pola w rekordach modułu.<br><br> Jeśli zależność już istnieje pomiędzy dwoma modułami, każda nowa zależność stworzona pomiędzy nimi nie będzie dodatkowo uwidoczniona.<br><br> Wybierz jedną z następujących zależności <b>Typ</b> dla modułu:<br><br> <b>Jeden-do-jednego</b> - oba rekordy w modułach będą zawierać połączone pola.<br><br> <b>Jeden-do-wielu</b> - Rekord modułu nadrzędnego będzie zawierał subpanel, a rekord modułu podrzędnego - połączone pole.<br><br> <b>Wielu-do-Wielu</b> - W rekordach obu modułów wyświetlą się subpanele.<br><br> Wybierz <b>Moduły połączone </b> dla zależności. <br><br> Jeżeli typ zależności jest wyrażony za pomocą subpaneli, wybierz widok subpaneli dla właściwego modułu.<br><br> Kliknij <b>Zachowaj</b>, aby utworzyć zależność. Raz utworzonej zależności nie można ani edytować ani usunąć.',
|
||||
'editDropDownBtn' => 'Edytuj globalną listę rozwijalną',
|
||||
'addDropDownBtn' => 'Dodaj nową globalną listę rozwijalną',
|
||||
),
|
||||
'fieldsHelp'=>array(
|
||||
'default'=>'<b>Pola</b> są w tym module wymienione po nazwie.<br><br>Wzorzec modułu zawiera predefiniowany zestaw pól.<br><br>Aby stworzyć nowe pole, kliknij <b>Dodaj pole</b>.<br><br>Aby edytować - kliknij <b>Nazwę pola</b>.<br/><br/>Po zamieszczeniu modułu, nowe pola utworzone w Budowniczym modułów, oraz pola wzorcowe są traktowane jako zwykłe pola w module Studio.',
|
||||
),
|
||||
'relationshipsHelp'=>array(
|
||||
'default'=>'<b>Zależności</b> stworzone pomiędzy modułami pojawią się tutaj.<br><br><b>Name</b> zależności jest generowana przez system.<br><br><b>Moduł nadrzędny </b> to moduł, do którego należą zależności. Ich właściwości są przechowywane w tabelach bazy danych, należących do modułu nadrzędnego.<br><br>Klikając na wiersz w tabeli zależności można oglądać i edytować właściwości przynależne do zależności.<br><br>Kliknij <b>Dodaj zależność</b>, aby utworzyć nową',
|
||||
'addrelbtn'=>'myszkę nad pomocą aby dodać zależność.',
|
||||
'addRelationship'=>'<b>Zależności</b> mogą być tworzone pomiędzy modułem i innym modułe dostosowywanym, lub już zamieszczonym.<br><br> Zależności są wyrażone wizualnie pomiędzy subpanelami i połączonymi polami w rekordach modułu.<br><br>Wybierz jedną z następujących <b>Typów</b> zależności dla modułu:<br><br> <b>Jeden-do-jednego</b> - Rekordy obu modułów zawierają połączone pola.<br><br> <b>Jeden-do-wielu</b> - Rekord modułu nadrzędnego będzie zawierał subpanel, a rekordy modułów połączonych - połączone pola.<br><br> <b>Wiele-do-wielu</b> - Rekordy obu modułów będą zawierały subpanele.<br><br> Wybierz <b>Połączone moduły</b> dla zależności. <br><br>Jeśli zależność jest skonstruowana z użyciem subpaneli, wybierz widok subpaneli dla właściwych modułów.<br><br> Kliknij <b>Zachowaj</b> aby utworzyć zależność.',
|
||||
),
|
||||
'labelsHelp'=>array(
|
||||
'default'=> '<b>Etykiety</b> dla pól i inne tytuły mogą być zmieniane.<br><br>Edytuj etykiety klikając na pole. Wprowadź nową etykietę i kliknij <b>Zachowaj</b>.<br><br>Jeśli w aplikacji są zainstalowane pakiety językowe, możesz wybrać <b>Język</b> dla etykiet.',
|
||||
'saveBtn'=>'Kliknij <b>Zachowaj</b>, aby zapisać wszyskie zmiany',
|
||||
'publishBtn'=>'Kliknij <b>Zachowaj i zamieść</b>, aby zapisać wszyskie zmiany i uaktywnić je',
|
||||
),
|
||||
'portalSync'=>array(
|
||||
'default' => 'Wprowadź <b>Adres URL Portalu Sugar</b> i kliknij <b>Dalej</b>.<br><br>Nastepnie wprowadź prawidłową nazwę użytkownika Sugar, oraz hasło i kliknij <b>Rozpocznij synchronizację</b>.<br><br>Dostosowania wprowadzone dla portalu Sugar, zawierające <b>Wyglądy</b>, wraz z <b>Arkuszami stylów</b>, jeśli zostały uprzednio załadowane, zostaną wprowadzone w określonej powyżej instancji portalu.',
|
||||
),
|
||||
'portalStyle'=>array(
|
||||
'default' => 'Możesz dostosować wygląd portalu Sugar, korzystając z arkusza stylów.<br><br>Wybierz <b>Arkusz stylów</b> do załadowania.<br><br>Arkusz stylów zostanie zaimplementowany do Portalu Sugar, podczas następnej synchronizacji.',
|
||||
),
|
||||
),
|
||||
|
||||
'assistantHelp'=>array(
|
||||
'package'=>array(
|
||||
//custom begin
|
||||
'nopackages'=>'Aby rozpocząć nowy projekt, kliknij <b>Nową paczkę</b>, aby stworzyć miejsce na pliki Twojego modułu. <br/><br/>Każda paczka może zawierać jeden lub więcej modułów.<br/>Dla instancji, możesz stworzyć własną paczkę, zawierającą nowy moduł połączony ze standardowym modułem Klienci. Możesz również stworzyć paczkę zawierającą kilka modułów, pracujących razem jako projekt i połączonych z modułami istniejącymi standardowo w aplikacji.',
|
||||
'somepackages'=>'<b>Paczka</b> przechowuje stworzone przez użytkownika moduły, które wszystkie są składnikami jednego projektu. Paczka może zawierać jeden lub więcej stworzonych <b>modułów</b>, które mogą być połączone razem, lub z innymi modułami aplikacji.<br/><br/>Po utworzeniu paczki, możesz tworzyć moduły od razu, lub pozostawić ją do późniejszej edycji.<br><br>Gdy projekt jest skończony, możesz <b>Zamieścić</b> paczkę, tworząc własny moduł do zainstalowania w aplikacji.',
|
||||
'afterSave'=>'Paczka powinna zawierać przynajmniej jeden moduł. Możesz stworzyć jeden lub więcej własnych modułów w obrębie jednej paczki.<br/><br/>Kliknij na <b>Nowy moduł</b>, aby utworzyć własny moduł dla tej paczki.<br/><br/> Po utworzeniu ostaniego modułu, możesz opublikować, lub zamieścić paczkę, co udostępni ją dla Twojej instancji i/lub użytkowników.<br/><br/> Aby zamieścić paczkę jednym ruchem w Twojej instancji, kliknij <b>Zamieść</b>.<br><br>Kliknij <b>Publikuj</b>, aby zapisać projekt w pliku .zip. Gdy zostanie on zachowany w Twoim systemie, użyj <b>Ładowacza modułów</b>, aby załadować i zainstalować paczkę w Twoim systemie. <br/><br/>Możesz ją dowolnie dystrybuować pomiędzy różnymi instalacjami Sugar.',
|
||||
'create'=>'<b>Paczka</b> przechowuje stworzone przez użytkownika moduły, które wszystkie są składnikami jednego projektu. Paczka może zawierać jeden lub więcej stworzonych <b>modułów</b>, które mogą być połączone razem, lub z innymi modułami aplikacji.<br/><br/>Po utworzeniu paczki, możesz tworzyć moduły od razu, lub pozostawić ją do późniejszej edycji.',
|
||||
),
|
||||
'main'=>array(
|
||||
'welcome'=>'Użyj <b>Narzędzi developera</b> do tworzenia i zarządzania standardowymi i własnymi modułami i polami. <br/><br/>Do zarządzania modułami w aplikacji służy stiudio <b>Studio</b>. <br/><br/>Do tworzenia własnych modułów - <b>Budowniczy modułów</b>.',
|
||||
'studioWelcome'=>'Wszystkie zainstalowane obecnie moduły, zarówno standardowe, jak i obiekty ładowane, są edytowalne w Studio.'
|
||||
),
|
||||
'module'=>array(
|
||||
'somemodules'=>'Gdy tworzona paczka zawiera już co najmniej jeden moduł, możesz <b>Zamieścić</b> go, jako paczkę w instancji Sugar, lub <b>Publikować</b> ją jako pakiet do zainstalowania w tej, lub innej instacji, używając <b>Ładowacza modułów</b>.<br/><br/>Aby zainstalować paczkę bezpośrednio w Twojej instancji Sugar, kliknij <b>Zamieść</b>.<br><br>Aby utworzyć paczkę, możliwą do zainstalowania w różnych instancjach, za pomocą <b>Ładowacza modułów</b>, musisz stworzyć plik .zip, klikając <b>Publikuj</b>.<br/><br/> Możesz budować moduły w paczce etapami i publikować, lub zamieszczać gdy tylko zechcesz. <br/><br/>Po publikacji, lub zamieszczeniu paczki, możesz dalej dokonywać zmian i zmieniać właściwości modułów. Potem ponownie dokonaj publikacji, lub zamieszczenia, aby zaaprobować zmiany.' ,
|
||||
'editView'=> 'Tutaj możesz edytować istniejące pola, lb w lewym panelu dodawać nowe.',
|
||||
'create'=>'Gdy wybierasz <b>Typ</b> modułu, który chcesz stworzyć, jednocześnie wybierasz typ pól, które znajdą się w module. <br/><br/>Każdy wzorzec modułu zawiera zestaw pól właściwy dla konkretnego typu modułu, określony przejego nazwę.<br/><br/><b>Podstawowy</b> - zawiera podstawowe pola, które pojawiają się w standardowych modułach. Te pola to np. Nazwa, Przydzielone do,Zespół, Data utworzenia lub Opis.<br/><br/> <b>Firma</b> - Zawiera pola typowe dla określenia organizacji, takie jak Nazwa firmy, jej adres i dane do fakturowania. Używaj tego wzorca, do tworzenia modułów podobnych do standardowego modułu Klienci.<br/><br/> <b>Osoba</b> - Zawiera pola służące do określenia osób, takie jak Pozdrowienie, Tytuł, Imię, Adres i numer telefonu. Używaj tego wzorca, do tworzenia modułów podobnych do standardowych modułów Kontakty i Adresy.<br/><br/><b>Cecha</b> - Zawiera pola specyficzne dla modułów Spraw lub do określenia błędów, takie jak numer, status, priorytet lub opis. Używaj tego wzorca, do tworzenia modułów podobnych do standardowych modułów Spraw lub Śledzenia błędów.<br/><br/>Uwaga: Po utworzeniu modułu, możesz edytować etykiety pól wzorca, podobnie jak własnych pól, dodanych do wyglądu modułu.',
|
||||
'afterSave'=>'Tworząc moduł dostosowany do Twoich potrzeb, możesz edytować i tworzyć pola, ustalać zależności pomiędzy innymi modułami i aranżować rozkład pól w wyglądach.<br/><br/>Aby zobaczyć pola wzorcowe w module i aranżować własne, kliknij <b>Zobacz pola</b>.<br/><br/>Aby utworzyć lub zarządzać zależnościami pomiędzy modułami, zarówno tymi, które znajdują się w aplikacji, jak i tymi, które utworzono w tej samej paczce, kliknij <b>Zobacz zależności</b>.<br/><br/>Aby edytować wyglądy, kliknij <b>Zobacz wyglądy</b>. Możesz zmieniać widok szczegółowy, widok edycji oraz widok listy dokładnie tak samo, jak edytuje się standardowe moduły w Studio.<br/><br/> Aby utworzyć moduł o takich samych właściwościach, kliknij <b>Duplikuj</b>. Możesz dalej dostosowywać powstały w wyniku duplikacji moduł.',
|
||||
'viewfields'=>'Pola w module mogą być dowlnie edytowane.<br/><br/>Nie możesz usunąć standardowych pól, ale możesz wyłączyć je w widokach na stronie wyglądu. <br/><br/>Możesz natomiast edytować etykiety pól standardowych. Inne ich właściwości nie mogą być edytowane. Możesz poza tym szybko tworzyć nowe pola, o podobnych właściwościach poprzez kliknięcie na nazwie pola, a następnie na przycisku <b>Klonuj</b> w formularzu <b>Właświwości</b>. Wprowadź nowe właściwości i kliknij <b>Zachowaj</b>.<br/><br/>Jeśli dostosowujesz nowy moduł, a został on już zainstalowany, nie wszystkie z właściwości pól mogą być edytowane. Należy określić zatem wszystkie właściwości dla pól standardowych i własnych, zanim paczka zawierająca moduł zostanie opublikowana lub zainstalowana.',
|
||||
'viewrelationships'=>'Możesz towrzyć zależności wiele-do-wielu pomiędzy bieżącym modułem, a innymi modułami w paczce i/lub pomiędzy bieżącym modułem, a modułami zainstalowanymi w aplikacji.<br><br> Aby utworzyć zależność jeden-do-wielu i jeden-do-jednego, kliknij <b>Połączenie</b> i <b>Stwórz połaczenie</b> pomiędzy polami w module.',
|
||||
'viewlayouts'=>'Możesz kontrolować, które z pól są dostępne do gromadzenia danych w <b>Widoku edycji</b>. Możesz także kontrolować jakie dane są wyświetlane w <b>Widoku szczegółowym</b>. Widoki nie muszą zawierać takich samych danych. <br/><br/>TFormulasz szybkiego tworzenia jest wyświetlony, gdy kalwisz <b>Utwórz</b> jest kliknięty w subapnelu modułu. Momyślnie wygląd formularza <b>Szybkiego tworzenia</b> jest taki sam, jak wygląd <b>Widoku edycji</b>. Możesz dostosowywać formularz szybkiego tworzenia tak, aby zawierał mniej lub więcej pól niż wygląd widoku edycji. <br><br>Możesz dostosować również poziom bezpieczeństwa dla wyglądu, korzystając z <b>Zarządzania rolami</b>.<br><br>',
|
||||
'existingModule' =>'Po utworzeniu i dostosowaniu modułu, możesz tworzyć następne moduły, lub <b>Publikować</b> lub <b>Zamieścić</b> paczkę.<br><br>Aby utworzyć dodatkowe moduły, kliknij <b>Duplikuj</b>, w celu stworzenia modułu o takich samych właściwościach, jak bieżący, lub cofnij się i kliknij <b>Nowy moduł</b>.<br><br> Jeśli jesteś gotowy do <b>Publikacji</b> lub <b>Zamieszczenia</b> paczki zawierającej ten moduł, cofnij się do poziomu zarządzania paczką Możesz zamieścić, lub opublikować paczkę, zawierającą co najmniej jeden moduł.',
|
||||
'labels'=> 'Etykiety pol standardowych i własnych mogą być zmieniane. Zmiana etykiet nie będzie miała wpływu na wprowadzone do nich dane.',
|
||||
),
|
||||
'listViewEditor'=>array(
|
||||
'modify' => 'Po lewej stronie są wyświetlone trzy kolumny. Kolumna <b>Domyślne</b> zawiera pola, które wyświetlają się domyślnie w <b>Widoku listy</b>, kolumna <b>Dostępne</b>, zawiera pola, które użytkownik może wykorzystać w trzorzeniu własnego widoku listy, a kolumna <b>Ukryte</b> - pola dostępne dla Ciebie, jako administratora, możliwe do dodania do jednej z dwóch poprzednich kolumn. Pola te stają się wtedy widoczne i dostępne dla użytkownika.',
|
||||
'savebtn' => 'Kliknięcie <b>Zachowaj</b> zachowa wszystkie zmiany i uaktywni je.',
|
||||
'Hidden' => 'Pola ukryte to pola, które nie są obecnie dostępne dla użytkowników w widoku listy.',
|
||||
'Available' => 'Pola dostępne to pola, które nie są widoczne domyślnie, ale mogą zostać włączone przez użytkowników.',
|
||||
'Default' => 'Pola domyślne są wyświetlane użytkownikom, którzy nie modyifkowali widoków listy.'
|
||||
),
|
||||
|
||||
'searchViewEditor'=>array(
|
||||
'modify' => 'Po lewej stronie są wyświetlone dwie kolumny. Kolumna <b>Domyślne</b> zawiera pola, które zostaną wyśwwietlone w widoku wyszukiwania, a kolumna <b>Ukryte</b> zawiera pola dostępne dla Ciebie, jako administratora do dodania do widoku edycji.',
|
||||
'savebtn' => 'Kliknięcie <b>Zachowaj i opublikuj</b> zachowa wszystkie zmiany i uaktywni je.',
|
||||
'Hidden' => 'Pola ukryte nie będą wyświetlane w widoku wyszukiwania.',
|
||||
'Default' => 'Pola domyślne będą wyświetlane w widoku wyszukiwania.',
|
||||
),
|
||||
'layoutEditor'=>array(
|
||||
'default' => 'Po lewej stronie są wyświetlone dwie kolumny. Prawa, oznaczona jako <b>Widok bieżący</b> lub <b>Podgląd widoku</b>, to miejsce, którym możesz zmieniać wygląd modułu. Lewa - <b>Szkynka narzędziowa</b>, zawiera użyteczne elementy i narzędzia, przydatne w edycji wyglądu. <br/><br/>Jeśli obszar edycji jest oznaczony jako <b>Bieżący wygląd</b>, pracujesz wtedy na kopii wyświetlanego wyglądu.<br/><br/>Jeśli jest to <b>Podgląd Widoku</b>, to pracujesz na wyglądze utworzonym, za pomocą klawisza <b>Zachowaj</b>. Może to być wersja inna od tego, co widzielu użytkownicy.',
|
||||
'saveBtn' => 'Kliknięcie na klawisz zachowa wygląd, możesz temu zapobiec. Gdy cofniesz się, rozpoczniesz od tego zmienionego wyglądu. Twój utworzony widok, nie będzie widziany przez użytkowników modułu dopuki nie klikniesz klawisz <b>Zachowaj</b> i <b>Publikuj</b>.',
|
||||
'publishBtn'=> 'Kliknij klawisz, aby zamieścić wygląd. Oznacza to, że zostanie on niezwłocznie wyświetlony użytkoniwkom tego modułu.',
|
||||
'toolbox' => '<b>Skrzynka narzędziowa</b> zawiera przeróżne użyteczne funkcje, służące do edycji wyglądu, takie jak obszar kosza, zestaw dodatkowych elementów i zestaw dostępnych pól. Każdy z nich może być przeciągnięty i upuszczony na wygląd.',
|
||||
'panels' => 'Ten obszar pokazuje jak będzie wyglądał Twój wygląd, dla użytkowników modułu, gdy zostanie zamieszczony.<br/><br/>Możesz przemieszczać elementy, takie jak pola, wiersze i panele,używając techniki <b>przeciągnij i upuść</b>. W ten sam sposób usuwasz elementy przesuwająć je nad obszar kosza w skrzynce narzędziowej, lub dodajesz nowe, wyciągając je ze skrzynki i przesuwając na pożądaną pozycję w obszasze edycji widoku.'
|
||||
),
|
||||
'dropdownEditor'=>array(
|
||||
'default' => 'Po lewej stronie są wyświetlone dwie kolumny. Prawa z nich, oznaczona jako Bieżący widok, lub podgląd widoku, to ta, w której zmieniasz widok modułu. Lewa zawiera skrzynkę narzędziową, z użytecznymi elementami i narzędziami, których można użyć do edycji wyglądu. <br/><br/>Jeśli obszar wyglądu jest oznaczony jako bieżący, pracujesz na kopii bieżącego wyglądu modułu.<br/><br/>Jeśli obszar jest oznaczony jako Podgląd widoku, pracujesz na stworzonym wcześniej -po naciśnięciu klawisza Zachowaj - zatem może on być już zmieniony w stosunku do tego, co widzą Użytkownicy.',
|
||||
'dropdownaddbtn'=> 'Kliknięcie tego przycisku spowoduje dodanie nowej pozycji do listy rozwijalnej.',
|
||||
),
|
||||
'exportcustom'=>array(
|
||||
'exportHelp'=>'Zmiany własne dokonane za pomocą modułu Studio w tej instancji mogą zostać spakowane i zamieszczone w innej. <br><br>Wprować <b>Nazwę pakietu</b>. W pakiecie możesz zamieścić informacje o <b>Autorze</b> i <b>Opis</b>.<br><br>Wybierz moduł(y),przeznaczone do eksportu,zawierające zmiany własne. Możesz wybrać tylko moduły zawierające te zmiany.)<br><br>Kliknij <b>Eksport</b>, aby stworzyć plik .zip pakietu zawierającego zmiany własne. Plik .zip może zostać załadowany do innej instancji za pomocą <b>Ładowacza modułów</b>.',
|
||||
'exportCustomBtn'=>'Kliknij <b>Eksport</b>, aby utworzyć plik .zip pakietu zawierającego zmiany własne, które chcesz wyeksportować.',
|
||||
'name'=>'<b>Nazwa</b> pakietu zostanie wyświetlona w Ładowaczu modułów, po tym jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
'author'=>'Określenie <b>Autor</b> to nazwa podmiotu tworzącego pakiet. Autorem może być zarówno osoba jak i firma.<br><br>Autor zostanie wyświetlony w Ładowaczu Modułów, po tym, jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
'description'=>'<b>Opis</b> pakietu zostanie wyświetlony w Ładowaczu Modułów, po tym, jak pakiet zostanie przygotowany do instalacji w Studio.',
|
||||
),
|
||||
|
||||
|
||||
'studioWizard'=>array(
|
||||
'mainHelp' => 'Witamy w strefie <b>Narzędzia Programisty</b1>. <br/><br/>W tej strefie możesz używać narzędzi,aby tworzyć i zarządzać standardowymi i dostosowanymi modułami i polami.',
|
||||
'studioBtn' => 'Użyj <b>Studio</b> aby dostosować zainstalowane moduły, poprzez zmianę aranżacji pól, wybór, które z nich mają być dostępne i aby tworzyć własne pola danych.',
|
||||
'mbBtn' => 'Użyj <b>Budowniczego Modułów</b> aby tworzyć moduły.',
|
||||
'appBtn' => 'Użyj trybu aplikacji aby dostosować różne cechy programu, takie jak np. jak dużo raportów TPS ma się pojawiać na stronie głównej',
|
||||
'backBtn' => 'Powrót do poprzedniego kroku.',
|
||||
'studioHelp'=> 'Użyj <b>Studio</b> aby dostosować zainstalowane moduły.',
|
||||
'moduleBtn' => 'Kliknij, aby edytować ten moduł.',
|
||||
'moduleHelp'=> 'Wybierz element modułu, który chcesz edytować.',
|
||||
'fieldsBtn' => 'Zdecyduj, które informacje są zapisywane w module, poprzez sterowanie <b>Polami</b> w module.<br/><br/>Tutaj możesz także edytować i tworzyć własne pola.',
|
||||
'labelsBtn' => 'Kliknij <b>Zachowaj</b> aby zapisać swoje własne oznaczenia etykiet.' ,
|
||||
'layoutsBtn'=> 'Dostosuj <b>Wyglądy</b> Widoków edycji, szczegółów, listy i wyszukiwania.',
|
||||
'subpanelBtn'=> 'Zdecyduj, jakie informacje mają pojawiać się w subpanelach w tym module.',
|
||||
'layoutsHelp'=> ' Wybierz <b>Wygląd do edycji</b>.<br/<br/>Aby zmienić wygląd, który zawiera pola do wprowadzania danych, kliknij <b>Edytuj widok</b>.<br/><br/>Aby zmienić wygląd, który wyświetla dane wprowadzone do pól, w Edycji Widoku, kliknij <b>Szczegóły Widoku</b>.<br/><br/>Aby zmienić kolumny, które pojawiają się domyślnie, kliknij <b>Widok listy</b>.<br/><br/>Aby zmienić Podstawowy i Zaawansowany widok formularza, kliknij <b>Szukaj</b>.',
|
||||
'subpanelHelp'=> 'Wybierz <b>Subpanel</b> to edit.',
|
||||
'searchHelp' => 'Wybierz widok do edycji klikając <b>Szukaj</b>.',
|
||||
'labelsBtn' => 'Edytuj <b>Etykiety</b> aby wyświetlić wartości dla tego modułu.',
|
||||
'newPackage'=>'Kliknij <b>Nowy Pakiet</b> by utworzyć nowy pakiet.',
|
||||
'mbHelp' => '<b>Witamy w Budowniczym Modułów.</b><br/><br/><b>Budowniczy Modułów</b> jest używany do tworzenia pakietów zawierających dostosowywane moduły, bazujące na standardowych, lub własnych modułach. <br/><br/>Aby rozpocząć, kliknij <b>Nowy Pakiet</b> w celu utworzenia nowego pakietu, lub wybierz pakiet do edycji.<br/><br/> <b>Pakiet</b> może być zbiorem własnych modułów, które są częścią jednego projektu. Pakiet może więc zawierać więcej niż jeden moduł własny, który może być połączony z dowolnym innym modułem w aplikacji. <br/><br/>Przykład: Możesz stworzyć pakiet, zawierający jeden moduł własny, który jest połączony ze standardowym modułem <b>Klienci</b>. lub stworzyć kilka modułów, współpracujących ze sobą, jako projekt i będących zależnymi od modułów aplikacji.',
|
||||
'exportBtn' => 'Kliknij <b>Wyeksportuj dostosowania</b>, aby zbudować pakiet zawierający elementy stworzone przez Ciebie w Studio, dla określonego modułu.',
|
||||
),
|
||||
|
||||
|
||||
),
|
||||
//HOME
|
||||
'LBL_HOME_EDIT_DROPDOWNS'=>'Edytuj listy rozwijalne',
|
||||
|
||||
//ASSISTANT
|
||||
'LBL_AS_SHOW' => 'Pokaż Asystenta w przyszłości.',
|
||||
'LBL_AS_IGNORE' => 'Nie pokazuj Asystenta w przyszłości.',
|
||||
'LBL_AS_SAYS' => 'Asystent sugeruje:',
|
||||
|
||||
|
||||
//STUDIO2
|
||||
'LBL_MODULEBUILDER'=>'Budowniczy Modułów',
|
||||
'LBL_STUDIO' => 'Studio',
|
||||
'LBL_DROPDOWNEDITOR' => 'Edytor list rozwijalnych',
|
||||
'LBL_EDIT_DROPDOWN'=>'Edytuj listy rozwijalne',
|
||||
'LBL_DEVELOPER_TOOLS' => 'Narzędzia programisty',
|
||||
'LBL_SUGARPORTAL' => 'Edytor portalu Sugar',
|
||||
'LBL_SYNCPORTAL' => 'Synchronizuj portal',
|
||||
'LBL_PACKAGE_LIST' => 'Lista pakietów',
|
||||
'LBL_HOME' => 'Powrót do strony głównej',
|
||||
'LBL_NONE'=>'-Nic-',
|
||||
|
||||
'LBL_ADD_FIELDS'=>'Dodaj własne pola',
|
||||
'LBL_AVAILABLE_SUBPANELS'=>'Dostępne subpanele',
|
||||
'LBL_ADVANCED'=>'Zaawansowane',
|
||||
'LBL_ADVANCED_SEARCH'=>'Wyszukiwanie zaawansowane',
|
||||
'LBL_BASIC'=>'Podstawowe',
|
||||
'LBL_BASIC_SEARCH'=>'Wyszukiwanie podstawowe',
|
||||
'LBL_CURRENT_LAYOUT'=>'Obecny wygląd',
|
||||
'LBL_CURRENCY' => 'Waluta',
|
||||
'LBL_DASHLET'=>'Belki',
|
||||
'LBL_DASHLETLISTVIEW'=>'Widok listy belek Sugar',
|
||||
'LBL_DASHLETSEARCH'=>'Sukaj belek Sugar',
|
||||
'LBL_DASHLETSEARCHVIEW'=>'Wyszukiwanie belek Sugar',
|
||||
'LBL_DISPLAY_HTML'=>'Wyświetl kod HTML',
|
||||
'LBL_DETAILVIEW'=>'Widok szczegółowy',
|
||||
'LBL_DROP_HERE' => '[Upuść tutaj]',
|
||||
'LBL_EDIT'=>'Edytuj',
|
||||
'LBL_EDIT_LAYOUT'=>'Widok edycji',
|
||||
'LBL_EDIT_ROWS'=>'Edytuj wiersze',
|
||||
'LBL_EDIT_COLUMNS'=>'Edytuj kolumny',
|
||||
'LBL_EDIT_LABELS'=>'Edytuj etykiety',
|
||||
'LBL_EDIT_FIELDS'=>'Edytuj własne pola',
|
||||
'LBL_EDIT_PORTAL'=>'Edytuj portal dla ',
|
||||
'LBL_EDIT_FIELDS'=>'Edytuj pola',
|
||||
'LBL_EDITVIEW'=>'Widok edycji',
|
||||
'LBL_FILLER'=>'(wypełniacz)',
|
||||
'LBL_FIELDS'=>'Pola',
|
||||
'LBL_FAILED_TO_SAVE' => 'Nie można zapisać',
|
||||
'LBL_FAILED_PUBLISHED' => 'Nie można opublikować',
|
||||
'LBL_HOMEPAGE_PREFIX' => 'Moja',
|
||||
'LBL_LAYOUT_PREVIEW'=>'Podgląd wyglądu',
|
||||
'LBL_LAYOUTS'=>'Wyglądy',
|
||||
'LBL_LISTVIEW'=>'Widok listy',
|
||||
'LBL_MODULES'=>'Moduły',
|
||||
'LBL_MODULE_TITLE' => 'Studio',
|
||||
'LBL_NEW_PACKAGE' => 'Nowy pakiet',
|
||||
'LBL_NEW_PANEL'=>'Nowy panel',
|
||||
'LBL_NEW_ROW'=>'Nowy wiersz',
|
||||
'LBL_PACKAGE_DELETED'=>'Pakiet usunięty',
|
||||
'LBL_PUBLISHING' => 'Publikowanie ...',
|
||||
'LBL_PUBLISHED' => 'Opublikowany',
|
||||
'LBL_SELECT_FILE'=> 'Wybierz plik',
|
||||
'LBL_SAVE_LAYOUT'=> 'Zapisz wygląd',
|
||||
'LBL_SELECT_A_SUBPANEL' => 'Wybierz subpanel',
|
||||
'LBL_SELECT_SUBPANEL' => 'Wybierz subpanel',
|
||||
'LBL_SUBPANELS' => 'Subanele',
|
||||
'LBL_SUBPANEL' => 'Subanele',
|
||||
'LBL_SUBPANEL_TITLE' => 'Tytuł:',
|
||||
'LBL_SEARCH_FORMS' => 'Szukaj',
|
||||
'LBL_SEARCH'=>'Wyszukiwanie',
|
||||
'LBL_STAGING_AREA' => 'Platforma konstrukcyjna (tutaj przeciągnij i upuść elementy)',
|
||||
'LBL_SUGAR_FIELDS_STAGE' => 'Pola Sugar (kliknij element, aby dodać do platformy konstrukcyjnej).',
|
||||
'LBL_SUGAR_BIN_STAGE' => 'Kosz Sugar (kliknij element, aby dodać do platformy konstrukcyjnej).',
|
||||
'LBL_TOOLBOX' => 'Skrzynka narzędziowa',
|
||||
'LBL_VIEW_SUGAR_FIELDS' => 'Oberzyj pola Sugar',
|
||||
'LBL_VIEW_SUGAR_BIN' => 'Obejrzyj kosz Sugar',
|
||||
'LBL_QUICKCREATE' => 'Szybkie tworzenie',
|
||||
'LBL_EDIT_DROPDOWNS' => 'Edytuj globalną listę rozwijalną',
|
||||
'LBL_ADD_DROPDOWN' => 'Dodaj nową globalną listę rozwijalną',
|
||||
'LBL_BLANK' => '-czysto-',
|
||||
'LBL_TAB_ORDER' => 'Kolejność zakładek',
|
||||
|
||||
'LBL_DROPDOWN_TITLE_NAME' => 'Nazwa',
|
||||
'LBL_DROPDOWN_LANGUAGE' => 'Język',
|
||||
'LBL_DROPDOWN_ITEMS' => 'Lista elementów',
|
||||
'LBL_DROPDOWN_ITEM_NAME' => 'Nazwa elementu',
|
||||
'LBL_DROPDOWN_ITEM_LABEL' => 'Pokaż etykietę',
|
||||
|
||||
//RELATIONSHIPS
|
||||
'LBL_MODULE' => 'Moduł',
|
||||
'LBL_LHS_MODULE'=>'Moduł nadrzędny',
|
||||
'LBL_CUSTOM_RELATIONSHIPS' => '* zależności tworzone w Studio lub Budowniczym Modułów',
|
||||
'LBL_RELATIONSHIPS'=>'Zależności',
|
||||
'LBL_RELATIONSHIPS_EDIT'=>'Edytuj zależności',
|
||||
'LBL_REL_NAME' => 'Nazwa',
|
||||
'LBL_REL_LABEL' => 'Etykieta',
|
||||
'LBL_REL_TYPE' => 'Typ',
|
||||
'LBL_RHS_MODULE'=>'Połączone moduły',
|
||||
'LBL_NO_RELS' => 'Brak zależności',
|
||||
'LBL_RELATIONSHIP_ROLE_ENTRIES'=>'Warunki optymalne' ,
|
||||
'LBL_RELATIONSHIP_ROLE_COLUMN'=>'Kolumna',
|
||||
'LBL_RELATIONSHIP_ROLE_VALUE'=>'Wartość',
|
||||
'LBL_SUBPANEL_FROM'=>'Subpanel z',
|
||||
'LBL_RELATIONSHIP_ONLY'=>'Nie zostaną utworzone żadne widoczne elementy dla tej zależności jeśli są już istniejące widoczne zależności dla tych dwóch modułów.',
|
||||
'LBL_ONETOONE' => 'Jeden do jednego',
|
||||
'LBL_ONETOMANY' => 'Jeden do wielu',
|
||||
'LBL_MANYTOONE' => 'Wielu do jednego',
|
||||
'LBL_MANYTOMANY' => 'Wielu do wielu',
|
||||
|
||||
|
||||
//STUDIO QUESTIONS
|
||||
'LBL_QUESTION_FUNCTION' => 'Wybierz funkcję, lub komponent.',
|
||||
'LBL_QUESTION_MODULE1' => 'Wybierz moduł.',
|
||||
'LBL_QUESTION_EDIT' => 'Wybierz moduł do edycji.',
|
||||
'LBL_QUESTION_LAYOUT' => 'Wybierz wygląd do edycji.',
|
||||
'LBL_QUESTION_SUBPANEL' => 'Wybierz subpanelpanel do edycji.',
|
||||
'LBL_QUESTION_SEARCH' => 'Wybierz wygląd wyszukiwania do edycji.',
|
||||
'LBL_QUESTION_MODULE' => 'Wybierz element modułu do edycji.',
|
||||
'LBL_QUESTION_PACKAGE' => 'Wybierz pakiet do edycji, lub utwórz nowy.',
|
||||
'LBL_QUESTION_EDITOR' => 'Wybierz narzędzie.',
|
||||
'LBL_QUESTION_DROPDOWN' => 'Wybierz listę rozwijalną, aby edytować, lub utworzyć nową listę.',
|
||||
'LBL_QUESTION_DASHLET' => 'Wybierz wygląd belki do edycji.',
|
||||
//CUSTOM FIELDS
|
||||
'LBL_RELATE_TO'=>'Połączony z',
|
||||
'LBL_NAME'=>'Nazwa',
|
||||
'LBL_LABELS'=>'Etykiety',
|
||||
'LBL_MASS_UPDATE'=>'Pełna aktualizacja',
|
||||
'LBL_AUDITED'=>'Sprawdzenie',
|
||||
'LBL_CUSTOM_MODULE'=>'Moduł',
|
||||
'LBL_DEFAULT_VALUE'=>'Wartość domyślna',
|
||||
'LBL_REQUIRED'=>'Wymagane',
|
||||
'LBL_DATA_TYPE'=>'Typ',
|
||||
'LBL_HCUSTOM'=>'WŁASNY',
|
||||
'LBL_HDEFAULT'=>'DOMYŚLNY',
|
||||
'LBL_LANGUAGE'=>'Język:',
|
||||
|
||||
|
||||
//SECTION
|
||||
'LBL_SECTION_EDLABELS' => 'Edytuj panele',
|
||||
'LBL_SECTION_PACKAGES' => 'Pakiety',
|
||||
'LBL_SECTION_PACKAGE' => 'Pakiet',
|
||||
'LBL_SECTION_MODULES' => 'Moduły',
|
||||
'LBL_SECTION_PORTAL' => 'Portal',
|
||||
'LBL_SECTION_DROPDOWNS' => 'Listy rozwijalne',
|
||||
'LBL_SECTION_PROPERTIES' => 'Właściwości',
|
||||
'LBL_SECTION_DROPDOWNED' => 'Edytor list rozwijalnych',
|
||||
'LBL_SECTION_HELP' => 'Pomoc',
|
||||
'LBL_SECTION_ACTION' => 'Akcja',
|
||||
'LBL_SECTION_MAIN' => 'Główny',
|
||||
'LBL_SECTION_EDPANELLABEL' => 'Edytuj etykiety paneli',
|
||||
'LBL_SECTION_FIELDEDITOR' => 'Edytor pól',
|
||||
'LBL_SECTION_DEPLOY' => 'Zamieszczanie',
|
||||
'LBL_SECTION_MODULE' => 'Moduł',
|
||||
'LBL_SECTION_VISIBILITY_EDITOR'=>'Edytuj widzialność',
|
||||
//WIZARDS
|
||||
|
||||
//LIST VIEW EDITOR
|
||||
'LBL_DEFAULT'=>'Domyślne',
|
||||
'LBL_HIDDEN'=>'Ukryte',
|
||||
'LBL_AVAILABLE'=>'Dostępne',
|
||||
'LBL_LISTVIEW_DESCRIPTION'=>'Poniżej są wyświetlone trzy kolumy; Kolumna <b>Domyślne</b> zawierają pola, które są wyświetlone poniżej. Kolumna <b>Dodatkowe</b> zawiera pola, których Użytkownik może użyć podczas tworzenia własnego wyglądu. Kolumna <b>Dostępne</b> wyświetla pola, które są dostępne dla Ciebie, jako administratora, a które możesz dodać do dostępnych dla Użytkowników.',
|
||||
'LBL_LISTVIEW_EDIT'=>'Edytor wyglądu listy',
|
||||
|
||||
//Manager Backups History
|
||||
'LBL_MB_PREVIEW'=>'Podgląd',
|
||||
'LBL_MB_RESTORE'=>'Przywróć',
|
||||
'LBL_MB_DELETE'=>'Usuń',
|
||||
'LBL_MB_COMPARE'=>'Porównaj',
|
||||
'LBL_MB_DEFAULT_LAYOUT'=>'Układ domyślny',
|
||||
|
||||
//END WIZARDS
|
||||
|
||||
//BUTTONS
|
||||
'LBL_BTN_ADD'=>'Dodaj',
|
||||
'LBL_BTN_SAVE'=>'Zachowaj',
|
||||
'LBL_BTN_SAVE_CHANGES'=>'Zachowaj zmiany',
|
||||
'LBL_BTN_DONT_SAVE'=>'Pomiń zmiany',
|
||||
'LBL_BTN_CANCEL'=>'Skasuj',
|
||||
'LBL_BTN_CLOSE'=>'Zamknij',
|
||||
'LBL_BTN_UPLOAD'=>'Załaduj',
|
||||
'LBL_BTN_SAVEPUBLISH'=>'Zapisz i zamieść',
|
||||
'LBL_BTN_NEXT'=>'Następny',
|
||||
'LBL_BTN_CLONE'=>'Klonuj',
|
||||
'LBL_BTN_BACK'=>'Cofnij',
|
||||
'LBL_BTN_ADDCOLS'=>'Dodaj kolumnę',
|
||||
'LBL_BTN_ADDROWS'=>'Dodaj wiersz',
|
||||
'LBL_BTN_ADDFIELD'=>'Dodaj pole',
|
||||
'LBL_BTN_ADDDROPDOWN'=>'Dodaj listę rozwijalną',
|
||||
'LBL_BTN_SORT_ASCENDING'=>'Sortuj rosnąco',
|
||||
'LBL_BTN_SORT_DESCENDING'=>'Sortuj malejąco',
|
||||
'LBL_BTN_EDLABELS'=>'Edytuj etykiety',
|
||||
'LBL_BTN_UNDO'=>'Skasuj',
|
||||
'LBL_BTN_REDO'=>'Przywróć',
|
||||
'LBL_BTN_ADDCUSTOMFIELD'=>'Dodaj własne pole',
|
||||
'LBL_BTN_EXPORT'=>'Wyeksportuj własne dostosowania',
|
||||
'LBL_BTN_DUPLICATE'=>'Duplikuj',
|
||||
'LBL_BTN_PUBLISH'=>'Publikuj',
|
||||
'LBL_BTN_DEPLOY'=>'Zamieść',
|
||||
'LBL_BTN_EXP'=>'Eksport',
|
||||
'LBL_BTN_DELETE'=>'Usuń',
|
||||
'LBL_BTN_VIEW_LAYOUTS'=>'Zobacz wyglądy',
|
||||
'LBL_BTN_VIEW_FIELDS'=>'Zobacz pola',
|
||||
'LBL_BTN_VIEW_RELATIONSHIPS'=>'Zobacz zależności',
|
||||
'LBL_BTN_ADD_RELATIONSHIP'=>'Dodaj zależności',
|
||||
//TABS
|
||||
|
||||
|
||||
//ERRORS
|
||||
'ERROR_ALREADY_EXISTS'=> 'Błąd: Pole juz istnieje',
|
||||
'ERROR_INVALID_KEY_VALUE'=> "Błąd: Nieprawidłowa wartość klucza: [']",
|
||||
'ERROR_NO_HISTORY' => 'Nie odnaleziono plików historii',
|
||||
'ERROR_MINIMUM_FIELDS' => 'Układ ten musi zawierać przynajmniej jedno pole',
|
||||
|
||||
|
||||
|
||||
//SUGAR PORTAL
|
||||
'LBL_PORTAL'=>'Portal',
|
||||
'LBL_SYNCP_WELCOME'=>'Wprowadź adres URL do instalacji Portalu, którą chcesz poprawić.',
|
||||
'LBL_SP_UPLOADSTYLE'=>'Wybierz arkusz stylów do załadowania z Twojego komputera.<br> Akrkusz stylów będzie zaimplementowany w Portalu Sugar, przy następnej synchronizacji.',
|
||||
'LBL_SP_UPLOADED'=> 'Załadowano',
|
||||
'ERROR_SP_UPLOADED'=>'Upewnij się, że załadowałeś akrusz stylów css.',
|
||||
'LBL_SP_PREVIEW'=>'Tutaj jest podgląd, jak będzie wyglądał Twoj Portal Sugar, gdy użyjesz tego arkusza stylów.',
|
||||
'LBL_PORTALSITE'=>'Adres URL Portalu Sugar: ',
|
||||
'LBL_PORTAL_GO'=>'Naprzór',
|
||||
'LBL_UP_STYLE_SHEET'=>'Załaduj arkusz stylów',
|
||||
'LBL_QUESTION_SUGAR_PORTAL' => 'Wybierz wyglad Portalu do edycji.',
|
||||
'LBL_QUESTION_PORTAL' => 'Wybierz wyglad Portalu do edycji.',
|
||||
'LBL_SUGAR_PORTAL'=>'Portal Sugar',
|
||||
|
||||
//PORTAL PREVIEW
|
||||
'LBL_CASES'=>'Sprawy',
|
||||
'LBL_NEWSLETTERS'=>'Newsletters',
|
||||
'LBL_BUG_TRACKER'=>'Śledzenie błędów',
|
||||
'LBL_MY_ACCOUNT'=>'Moje konto',
|
||||
'LBL_LOGOUT'=>'Wyloguj',
|
||||
'LBL_CREATE_NEW'=>'Utwórz nowe',
|
||||
'LBL_LIST'=>'Lista',
|
||||
'LBL_LOW'=>'Niski',
|
||||
'LBL_MEDIUM'=>'Średni',
|
||||
'LBL_HIGH'=>'Wysoki',
|
||||
'LBL_NUMBER'=>'Numer:',
|
||||
'LBL_PRIORITY'=>'Priorytet:',
|
||||
'LBL_SUBJECT'=>'Temat',
|
||||
'LBL_DESCRIPTION'=>'Opis:',
|
||||
|
||||
|
||||
|
||||
|
||||
//PACKAGE AND MODULE BUILDER
|
||||
'LBL_PACKAGE_NAME'=>'Nazwa pakietu:',
|
||||
'LBL_MODULE_NAME'=>'Nazwa modułu:',
|
||||
'LBL_AUTHOR'=>'Autor:',
|
||||
'LBL_DESCRIPTION'=>'Opis:',
|
||||
'LBL_KEY'=>'Klucz:',
|
||||
'LBL_ADD_README'=>' Readme',
|
||||
'LBL_MODULES'=>'Moduły:',
|
||||
'LBL_LAST_MODIFIED'=>'Ostatnio modyfikowany:',
|
||||
'LBL_NEW_MODULE'=>'Nowy moduł',
|
||||
'LBL_LABEL'=>'Etykieta:',
|
||||
'LBL_LABEL_TITLE'=>'Etykieta',
|
||||
'LBL_WIDTH'=>'Szerokość',
|
||||
'LBL_PACKAGE'=>'Paczka:',
|
||||
'LBL_TYPE'=>'Typ:',
|
||||
'LBL_TEAM_SECURITY'=>'Zabezpieczenia zespołu',
|
||||
'LBL_ASSIGNABLE'=>'Możliwy do przydzielenia',
|
||||
'LBL_PERSON'=>'Osoba',
|
||||
'LBL_COMPANY'=>'Firma',
|
||||
'LBL_ISSUE'=>'Wydanie',
|
||||
'LBL_SALE'=>'Sprzedaż',
|
||||
'LBL_FILE'=>'Plik',
|
||||
'LBL_NAV_TAB'=>'Zakładka nawigacyjna',
|
||||
'LBL_CREATE'=>'Utwórz',
|
||||
'LBL_LIST'=>'Lista',
|
||||
'LBL_LIST_VIEW'=>'Widok listy',
|
||||
'LBL_HISTORY'=>'Zobacz historię',
|
||||
'LBL_ACTIVITIES'=>'Działania',
|
||||
'LBL_SEARCH'=>'Szukaj',
|
||||
'LBL_NEW'=>'Nowy',
|
||||
'LBL_TYPE_BASIC'=>'podstawowy',
|
||||
'LBL_TYPE_COMPANY'=>'firma',
|
||||
'LBL_TYPE_PERSON'=>'osoba',
|
||||
'LBL_TYPE_ISSUE'=>'wydanie',
|
||||
'LBL_TYPE_SALE'=>'sprzedaż',
|
||||
'LBL_TYPE_FILE'=>'plik',
|
||||
'LBL_RSUB'=>'To jest subpanel, który będzie wyświetlany w Twoim module',
|
||||
'LBL_MSUB'=>'To jest subpanel, który jest połączony z modułem do wyświetlenia.',
|
||||
'LBL_MB_IMPORTABLE'=>'Importowanie',
|
||||
|
||||
//EXPORT CUSTOMS
|
||||
'LBL_EC_TITLE'=>'Wyeksportuj dostosowania',
|
||||
'LBL_EC_NAME'=>'Nazwa pakietu:',
|
||||
'LBL_EC_AUTHOR'=>'Autor:',
|
||||
'LBL_EC_DESCRIPTION'=>'Opis:',
|
||||
'LBL_EC_KEY'=>'Klucz:',
|
||||
'LBL_EC_CHECKERROR'=>'Wybierz moduł.',
|
||||
'LBL_EC_CUSTOMFIELD'=>'pole dostosowane',
|
||||
'LBL_EC_CUSTOMLAYOUT'=>'wygląd dostosowany',
|
||||
'LBL_EC_NOCUSTOM'=>'Żaden moduł nie został dostosowany.',
|
||||
'LBL_EC_EMPTYCUSTOM'=>'nie posiada własnych dostosowań.',
|
||||
'LBL_EC_EXPORTBTN'=>'Eksport',
|
||||
'LBL_MODULE_DEPLOYED' => 'Moduł został zamieszczony.',
|
||||
'LBL_UNDEFINED' => 'niezidentyfikowany',
|
||||
|
||||
//AJAX STATUS
|
||||
'LBL_AJAX_FAILED_DATA' => 'Nie można przywrócić danych',
|
||||
'LBL_AJAX_TIME_DEPENDENT' => 'Operacja, której wykonanie może zająć nieco czasu własnie trwa. Poczekaj i spróbuj za chwilę',
|
||||
'LBL_AJAX_LOADING' => 'Ładuję...',
|
||||
'LBL_AJAX_DELETING' => 'Usuwam...',
|
||||
'LBL_AJAX_BUILDPROGRESS' => 'Budowanie trwa...',
|
||||
'LBL_AJAX_DEPLOYPROGRESS' => 'Zamieszczanie trwa...',
|
||||
|
||||
//JS
|
||||
'LBL_JS_REMOVE_PACKAGE' => 'Czy na pewno chcesz usunąć ten pakiet? Spowoduje to trwałe usunięcie wszystkich plików skojarzonych z tym pakietem.',
|
||||
|
||||
'LBL_DEPLOY_IN_PROGRESS' => 'Zamieszczanie pakietu',
|
||||
'LBL_JS_VALIDATE_NAME'=>'Nazwa - musi składać się ze znaków alfanumerycznych, bez spacji i rozpoczynać się od litery',
|
||||
'LBL_JS_VALIDATE_KEY'=>'Klucz - musi składać się ze znaków alfanumerycznych, bez spacji i rozpoczynać się od litery',
|
||||
'LBL_JS_VALIDATE_LABEL'=>'Wprowadź etykiete, która będzie użyta jako nazwa tego modułu',
|
||||
'LBL_JS_VALIDATE_TYPE'=>'Wybierz z listy rozwijalnej typ modułu, który chcesz zbudować',
|
||||
'LBL_JS_VALIDATE_REL_NAME'=>'Nazwa - musi składać się ze znaków alfanumerycznych, bez spacji',
|
||||
'LBL_JS_VALIDATE_REL_LABEL'=>'Etykieta - wpisz etykietę, która będzie wyświetlana ponad subpanelem',
|
||||
|
||||
//CONFIRM
|
||||
'LBL_CONFIRM_FIELD_DELETE'=>'Usunięcie własnego pola, usunie wszystkie dane połączone z własnym polem. Powinieneś wtedy również usunąć te pola ze wszystkich wygladów, w krórych zostały dodane',
|
||||
'LBL_CONFIRM_RELATIONSHIP_DELETE'=>'Czy na pewno chcesz usunąć tę zależność?',
|
||||
'LBL_CONFIRM_RELATIONSHIP_DEPLOY'=>'To ustawi na stałe tę zależność. Czy na pewno chcesz zamieścić tę zależność?',
|
||||
'LBL_CONFIRM_DONT_SAVE' => 'Zmiany, które zostały wprowadzone od ostatniego zapisywania. Czy chcesz zapisać teraz?',
|
||||
'LBL_CONFIRM_DONT_SAVE_TITLE' => 'Zachować zmiany?',
|
||||
|
||||
//POPUP HELP
|
||||
'LBL_POPHELP_FIELD_DATA_TYPE'=>'Wybierz właściwy typ danych na podstawie tych, które zostaną wprowadzone do pól.',
|
||||
'LBL_POPHELP_DUPLICATE_MERGE'=>'<b>Włączone</b>: Pola pojawią się w funkcji Scal duplikaty, ale nie będzie możliwe ich użycie dla filtra warunków w funkcji odszukiwania duplikatów.<br><b>Wyłączone</b>: Pola nie pojawią się w funkcji Scal duplikaty, ale nie będzie możliwe ich użycie dla filtra warunków w funkcji odszukiwania duplikatów.'
|
||||
|
||||
. '<br><b>W Filtrze</b>: Pola nie pojawią się w funkcji Scal duplikaty, ale będzie możliwe ich użycie dla filtra warunków w funkcji odszukiwania duplikatów.<br><b>Tylko filtr</b>: Pola pojawią się w funkcji Scal duplikaty, ale nie będzie możliwe ich użycie dla filtra warunków w funkcji odszukiwania duplikatów.<br><b>Domyślnie wybrany filtr</b>: Pola zostaną użyte w warunkach filtrowania w funkcji znajdź duplikaty, i będą również dostępne w funkcji Scal duplikaty.'
|
||||
|
||||
,
|
||||
|
||||
'fieldTypes' => array(
|
||||
'varchar'=>'Ciąg znaków',
|
||||
'int'=>'Liczba',
|
||||
'float'=>'Dziesiętne',
|
||||
'bool'=>'Pole checkbox',
|
||||
'enum'=>'Lista rozwijalna',
|
||||
'multienum' => 'Wielokrotny wybór',
|
||||
'date'=>'Data',
|
||||
'phone' => 'Telefon',
|
||||
'currency' => 'Waluta',
|
||||
'html' => 'HTML',
|
||||
'radioenum' => 'Radio',
|
||||
'relate' => 'Zależne',
|
||||
'address' => 'Adres',
|
||||
'text' => 'Pole tekstowe',
|
||||
'url' => 'Link',
|
||||
'iframe' => 'IFrame',
|
||||
'encrypt'=>'Kodowane'
|
||||
),
|
||||
|
||||
'parent' => 'Wybór zależności',
|
||||
//add 14.09.2011
|
||||
'LBL_POPUP'=>'PopupView',
|
||||
'LBL_POPUPLIST'=>'Popup ListView',
|
||||
'LBL_POPUPLISTVIEW'=>'Popup ListView',
|
||||
'LBL_POPUPSEARCH'=>'Popup Search',
|
||||
'LBL_RESTORE_DEFAULT'=>'Przywróć domyślne',
|
||||
'LBL_TAB_PANELS' => 'Zakładki',
|
||||
);
|
||||
|
||||
173
modules/ModuleBuilder/parsers/ModuleBuilderParser.php
Executable file
173
modules/ModuleBuilder/parsers/ModuleBuilderParser.php
Executable file
@@ -0,0 +1,173 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
class ModuleBuilderParser
|
||||
{
|
||||
|
||||
var $_defMap; // private - mapping from view to variable name inside the viewdef file
|
||||
var $_variables = array(); // private - set of additional variables (other than the viewdefs) found in the viewdef file that need to be added to the file again when it is saved - used by ModuleBuilder
|
||||
|
||||
function ModuleBuilderParser()
|
||||
{
|
||||
$this->_defMap = array('listview'=>'listViewDefs','searchview'=>'searchdefs','editview'=>'viewdefs','detailview'=>'viewdefs','quickcreate'=>'viewdefs');
|
||||
}
|
||||
/*
|
||||
* Initialize this parser
|
||||
*/
|
||||
function init ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Dummy function used to ease the transition to the new parser structure
|
||||
*/
|
||||
function populateFromPost()
|
||||
{
|
||||
}
|
||||
|
||||
function _loadFromFile($view,$file,$moduleName)
|
||||
{
|
||||
|
||||
$variables = array();
|
||||
if (! file_exists($file))
|
||||
{
|
||||
$this->_fatalError("ModuleBuilderParser: required viewdef file {$file} does not exist");
|
||||
}
|
||||
$GLOBALS['log']->info('ModuleBuilderParser->_loadFromFile(): file='.$file);
|
||||
require ($file); // loads in a $viewdefs
|
||||
|
||||
// Check to see if we have the module name set as a variable rather than embedded in the $viewdef array
|
||||
// If we do, then we have to preserve the module variable when we write the file back out
|
||||
// This is a format used by ModuleBuilder templated modules to speed the renaming of modules
|
||||
// Traditional Sugar modules don't use this format
|
||||
// We must do this in ParserModifyLayout (rather than just in ParserBuildLayout) because we might be editing the layout of a MB created module in Studio after it has been deployed
|
||||
$moduleVariables = array('module_name','_module_name', 'OBJECT_NAME', '_object_name');
|
||||
foreach ($moduleVariables as $name)
|
||||
{
|
||||
if (isset($$name)) {
|
||||
$variables[$name] = $$name;
|
||||
}
|
||||
}
|
||||
$viewVariable = $this->_defMap[strtolower($view)];
|
||||
// Now tidy up the module name in the viewdef array
|
||||
// MB created definitions store the defs under packagename_modulename and later methods that expect to find them under modulename will fail
|
||||
$defs = $$viewVariable;
|
||||
|
||||
if (isset($variables['module_name']))
|
||||
{
|
||||
$mbName = $variables['module_name'];
|
||||
if ($mbName != $moduleName)
|
||||
{
|
||||
$GLOBALS['log']->debug('ModuleBuilderParser->_loadFromFile(): tidying module names from '.$mbName.' to '.$moduleName);
|
||||
$defs[$moduleName] = $defs[$mbName];
|
||||
unset($defs[$mbName]);
|
||||
}
|
||||
}
|
||||
// $GLOBALS['log']->debug('ModuleBuilderParser->_loadFromFile(): '.print_r($defs,true));
|
||||
return (array('viewdefs' => $defs, 'variables' => $variables));
|
||||
}
|
||||
|
||||
function handleSave ($file,$view,$moduleName,$defs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save the new layout
|
||||
*/
|
||||
function _writeToFile ($file,$view,$moduleName,$defs,$variables)
|
||||
{
|
||||
mkdir_recursive(dirname($file));
|
||||
$GLOBALS['log']->debug("ModuleBuilderParser->_writeFile(): file=".$file);
|
||||
$useVariables = (count($variables)>0);
|
||||
if( $fh = @sugar_fopen( $file, 'w' ) )
|
||||
{
|
||||
$out = "<?php\n";
|
||||
if ($useVariables)
|
||||
{
|
||||
// write out the $<variable>=<modulename> lines
|
||||
foreach($variables as $key=>$value)
|
||||
{
|
||||
$out .= "\$$key = '".$value."';\n";
|
||||
}
|
||||
}
|
||||
|
||||
// write out the defs array itself
|
||||
switch (strtolower($view))
|
||||
{
|
||||
case 'editview':
|
||||
case 'detailview':
|
||||
case 'quickcreate':
|
||||
$defs = array($view => $defs);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$viewVariable = $this->_defMap[strtolower($view)];
|
||||
$out .= "\$$viewVariable = ";
|
||||
$out .= ($useVariables) ? "array (\n\$module_name =>\n".var_export_helper($defs) : var_export_helper( array($moduleName => $defs) );
|
||||
|
||||
// tidy up the parenthesis
|
||||
if ($useVariables)
|
||||
{
|
||||
$out .= "\n)";
|
||||
}
|
||||
$out .= ";\n?>\n";
|
||||
|
||||
// $GLOBALS['log']->debug("parser.modifylayout.php->_writeFile(): out=".print_r($out,true));
|
||||
fputs( $fh, $out);
|
||||
fclose( $fh );
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['log']->fatal("ModuleBuilderParser->_writeFile() Could not write new viewdef file ".$file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _fatalError ($msg)
|
||||
{
|
||||
$GLOBALS ['log']->fatal($msg);
|
||||
echo $msg;
|
||||
sugar_cleanup();
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
122
modules/ModuleBuilder/parsers/ParserFactory.php
Executable file
122
modules/ModuleBuilder/parsers/ParserFactory.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class ParserFactory
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new parser
|
||||
*
|
||||
* @param string $view The view, for example EditView or ListView. For search views, use advanced_search or basic_search
|
||||
* @param string $moduleName Module name
|
||||
* @param string $packageName Package name. If present implies that we are being called from ModuleBuilder
|
||||
* @return AbstractMetaDataParser
|
||||
*/
|
||||
|
||||
function getParser ( $view , $moduleName , $packageName = null , $subpanelName = null )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( "ParserFactory->getParser($view,$moduleName,$packageName,$subpanelName )" ) ;
|
||||
if ( empty ( $packageName ) || ( $packageName == 'studio' ) )
|
||||
$packageName = null ;
|
||||
switch ( strtolower ( $view ))
|
||||
{
|
||||
case MB_EDITVIEW :
|
||||
case MB_DETAILVIEW :
|
||||
case MB_QUICKCREATE :
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
return new GridLayoutMetaDataParser ( $view, $moduleName, $packageName ) ;
|
||||
case MB_CONVERTLEAD :
|
||||
require_once 'modules/Leads/ConvertLayoutMetadataParser.php';
|
||||
return new ConvertLayoutMetadataParser( $moduleName );
|
||||
case MB_BASICSEARCH :
|
||||
case MB_ADVANCEDSEARCH :
|
||||
require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
|
||||
return new SearchViewMetaDataParser ( $view, $moduleName, $packageName ) ;
|
||||
case MB_LISTVIEW :
|
||||
if ($subpanelName == null)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
|
||||
return new ListLayoutMetaDataParser ( MB_LISTVIEW, $moduleName, $packageName ) ;
|
||||
} else
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php' ;
|
||||
return new SubpanelMetaDataParser ( $subpanelName, $moduleName, $packageName ) ;
|
||||
}
|
||||
case MB_DASHLET :
|
||||
case MB_DASHLETSEARCH :
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php' ;
|
||||
return new DashletMetaDataParser($view, $moduleName, $packageName );
|
||||
case MB_POPUPLIST :
|
||||
case MB_POPUPSEARCH :
|
||||
require_once 'modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php' ;
|
||||
return new PopupMetaDataParser($view, $moduleName, $packageName );
|
||||
case MB_LABEL :
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
return new ParserLabel ( $moduleName, $packageName ) ;
|
||||
case MB_VISIBILITY :
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.visibility.php' ;
|
||||
return new ParserVisibility ( $moduleName, $packageName ) ;
|
||||
default :
|
||||
$prefix = '';
|
||||
if(!is_null ( $packageName )){
|
||||
$prefix = empty($packageName) ? 'build' :'modify';
|
||||
}
|
||||
$fileName = "modules/ModuleBuilder/parsers/parser." . strtolower ( $prefix . $view ) . ".php" ;
|
||||
if (file_exists ( $fileName ))
|
||||
{
|
||||
require_once $fileName ;
|
||||
$class = 'Parser' . $prefix . ucfirst ( $view ) ;
|
||||
if (class_exists ( $class ))
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( 'Using ModuleBuilder Parser ' . $fileName ) ;
|
||||
$parser = new $class ( ) ;
|
||||
return $parser ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$GLOBALS [ 'log' ]->fatal ( get_class ( $this ) . ": cannot create ModuleBuilder Parser $fileName" ) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
158
modules/ModuleBuilder/parsers/StandardField.php
Executable file
158
modules/ModuleBuilder/parsers/StandardField.php
Executable file
@@ -0,0 +1,158 @@
|
||||
<?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 ('modules/DynamicFields/DynamicField.php') ;
|
||||
|
||||
class StandardField extends DynamicField
|
||||
{
|
||||
var $custom_def = array();
|
||||
var $base_path = "";
|
||||
var $baseField;
|
||||
|
||||
|
||||
function __construct($module = '') {
|
||||
$this->module = (! empty ( $module )) ? $module :( (isset($_REQUEST['module']) && ! empty($_REQUEST['module'])) ? $_REQUEST ['module'] : '');
|
||||
$this->base_path = "custom/Extension/modules/{$this->module}/Ext/Vardefs";
|
||||
}
|
||||
|
||||
protected function loadCustomDef($field){
|
||||
global $beanList;
|
||||
if (!empty($beanList[$this->module]) && is_file("custom/Extension/modules/{$this->module}/Ext/Vardefs/sugarfield_$field.php"))
|
||||
{
|
||||
$dictionary = array($beanList[$this->module] => array("fields" => array($field => array())));
|
||||
include("$this->base_path/sugarfield_$field.php");
|
||||
if (!empty($dictionary[$beanList[$this->module]]) && isset($dictionary[$beanList[$this->module]]["fields"][$field]))
|
||||
$this->custom_def = $dictionary[$beanList[$this->module]]["fields"][$field];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom field using a field object
|
||||
*
|
||||
* @param Field Object $field
|
||||
* @return boolean
|
||||
*/
|
||||
function addFieldObject(&$field){
|
||||
global $dictionary, $beanList;
|
||||
if (empty($beanList[$this->module]))
|
||||
return false;
|
||||
|
||||
$bean_name = $beanList[$this->module];
|
||||
if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name]))
|
||||
return false;
|
||||
|
||||
$currdef = $dictionary[$bean_name]["fields"][$field->name];
|
||||
$this->loadCustomDef($field->name);
|
||||
$newDef = $field->get_field_def();
|
||||
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$this->baseField = get_widget ( $field->type) ;
|
||||
foreach ($field->vardef_map as $property => $fmd_col){
|
||||
if ($property == "action" || $property == "label_value" || $property == "label"
|
||||
|| ((substr($property, 0,3) == 'ext' && strlen($property) == 4))
|
||||
)
|
||||
continue;
|
||||
|
||||
// Bug 37043 - Avoid writing out vardef defintions that are the default value.
|
||||
if (isset($newDef[$property]) &&
|
||||
((!isset($currdef[$property]) && !$this->isDefaultValue($property,$newDef[$property], $this->baseField))
|
||||
|| (isset($currdef[$property]) && $currdef[$property] != $newDef[$property])
|
||||
)
|
||||
){
|
||||
|
||||
$this->custom_def[$property] =
|
||||
is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"]))
|
||||
unset($this->custom_def["duplicate_merge_dom_value"]);
|
||||
|
||||
$file_loc = "$this->base_path/sugarfield_{$field->name}.php";
|
||||
|
||||
$out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n";
|
||||
foreach ($this->custom_def as $property => $val)
|
||||
{
|
||||
$out .= override_value_to_string_recursive(array($bean_name, "fields", $field->name, $property), "dictionary", $val) . "\n";
|
||||
}
|
||||
|
||||
$out .= "\n ?>";
|
||||
|
||||
if (!file_exists($this->base_path))
|
||||
mkdir_recursive($this->base_path);
|
||||
|
||||
if( $fh = @sugar_fopen( $file_loc, 'w' ) )
|
||||
{
|
||||
fputs( $fh, $out);
|
||||
fclose( $fh );
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
protected function isDefaultValue($property, $value, $baseField)
|
||||
{
|
||||
switch ($property) {
|
||||
case "importable":
|
||||
return ( $value === 'true' || $value === '1' || $value === true || $value === 1 ); break;
|
||||
case "required":
|
||||
case "audited":
|
||||
case "massupdate":
|
||||
return ( $value === 'false' || $value === '0' || $value === false || $value === 0); break;
|
||||
case "default_value":
|
||||
case "default":
|
||||
case "help":
|
||||
case "comments":
|
||||
return ($value == "");
|
||||
case "duplicate_merge":
|
||||
return ( $value === 'false' || $value === '0' || $value === false || $value === 0 || $value === "disabled"); break;
|
||||
}
|
||||
|
||||
if (isset($baseField->$property))
|
||||
{
|
||||
return $baseField->$property == $value;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
69
modules/ModuleBuilder/parsers/constants.php
Executable file
69
modules/ModuleBuilder/parsers/constants.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
define('MB_BASEMETADATALOCATION','base');
|
||||
define('MB_CUSTOMMETADATALOCATION','custom');
|
||||
define('MB_WORKINGMETADATALOCATION','working');
|
||||
define('MB_HISTORYMETADATALOCATION','history');
|
||||
define('MB_GRIDLAYOUTMETADATA','gridLayoutMetaData');
|
||||
define('MB_LISTLAYOUTMETADATA','listLayoutMetaData');
|
||||
define('MB_LISTVIEW','listview');
|
||||
define('MB_SEARCHVIEW','searchview');
|
||||
define('MB_BASICSEARCH','basic_search' );
|
||||
define('MB_ADVANCEDSEARCH','advanced_search' );
|
||||
define('MB_DASHLET','dashlet');
|
||||
define('MB_DASHLETSEARCH','dashletsearch');
|
||||
define('MB_EDITVIEW','editview');
|
||||
define('MB_DETAILVIEW','detailview');
|
||||
define('MB_CONVERTLEAD','convertlead');
|
||||
define('MB_QUICKCREATE','quickcreate');
|
||||
define('MB_POPUPLIST','popuplist');
|
||||
define('MB_POPUPSEARCH','popupsearch');
|
||||
define('MB_LABEL','label');
|
||||
define('MB_ONETOONE', 'one-to-one');
|
||||
define('MB_ONETOMANY', 'one-to-many');
|
||||
define('MB_MANYTOONE', 'many-to-one');
|
||||
define('MB_MANYTOMANY', 'many-to-many');
|
||||
define('MB_MAXDBIDENTIFIERLENGTH',30); // maximum length of any identifier in our supported databases
|
||||
define('MB_EXPORTPREPEND','project_');
|
||||
define('MB_VISIBILITY','visibility');
|
||||
|
||||
class MBConstants
|
||||
{
|
||||
static $EMPTY = array ( 'name' => '(empty)' , 'label' => '(empty)' ) ;
|
||||
static $FILLER = array ( 'name' => '(filler)' , 'label' => 'LBL_FILLER' ) ; // would prefer to have label => translate('LBL_FILLER') but can't be done in a static, and don't want to require instantiating a new object to get these constants
|
||||
}
|
||||
210
modules/ModuleBuilder/parsers/parser.dropdown.php
Executable file
210
modules/ModuleBuilder/parsers/parser.dropdown.php
Executable file
@@ -0,0 +1,210 @@
|
||||
<?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('modules/ModuleBuilder/parsers/ModuleBuilderParser.php');
|
||||
|
||||
class ParserDropDown extends ModuleBuilderParser {
|
||||
|
||||
/**
|
||||
* Takes in the request params from a save request and processes
|
||||
* them for the save.
|
||||
*
|
||||
* @param REQUEST params $params
|
||||
*/
|
||||
function saveDropDown($params){
|
||||
require_once('modules/Administration/Common.php');
|
||||
$emptyMarker = translate('LBL_BLANK');
|
||||
$selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);
|
||||
$type = $_REQUEST['view_package'];
|
||||
$dir = '';
|
||||
$dropdown_name = $params['dropdown_name'];
|
||||
$json = getJSONobj();
|
||||
|
||||
$list_value = str_replace('"":""', '"__empty__":""', $params['list_value']);
|
||||
//Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes.
|
||||
$temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES) );
|
||||
$dropdown = array () ;
|
||||
// dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order
|
||||
// we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered
|
||||
foreach ( $temp as $item )
|
||||
{
|
||||
$dropdown[ $item [0] ] = $item [ 1 ] ;
|
||||
}
|
||||
|
||||
if(array_key_exists($emptyMarker, $dropdown)){
|
||||
$output=array();
|
||||
foreach($dropdown as $key => $value){
|
||||
if($emptyMarker===$key)
|
||||
$output['']='';
|
||||
else
|
||||
$output[$key]=$value;
|
||||
}
|
||||
$dropdown=$output;
|
||||
}
|
||||
|
||||
if($type != 'studio'){
|
||||
$mb = new ModuleBuilder();
|
||||
$module =& $mb->getPackageModule($params['view_package'], $params['view_module']);
|
||||
$this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module);
|
||||
//Can't use synch on selected lang as we want to overwrite values, not just keys
|
||||
$module->mblanguage->appListStrings[$selected_lang.'.lang.php'][$dropdown_name] = $dropdown;
|
||||
$module->mblanguage->save($module->key_name); // tyoung - key is required parameter as of
|
||||
}else{
|
||||
$contents = return_custom_app_list_strings_file_contents($selected_lang);
|
||||
$my_list_strings = return_app_list_strings_language($selected_lang);
|
||||
if($selected_lang == $GLOBALS['current_language']){
|
||||
$GLOBALS['app_list_strings'][$dropdown_name] = $dropdown;
|
||||
}
|
||||
//write to contents
|
||||
$contents = str_replace("?>", '', $contents);
|
||||
if(empty($contents))$contents = "<?php";
|
||||
//add new drop down to the bottom
|
||||
if(!empty($params['use_push'])){
|
||||
//this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed
|
||||
foreach($dropdown as $key=>$value){
|
||||
//only if the value has changed or does not exist do we want to add it this way
|
||||
if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){
|
||||
//clear out the old value
|
||||
$pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism';
|
||||
$contents = preg_replace($pattern_match, "\n", $contents);
|
||||
//add the new ones
|
||||
$contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']['$key']=" . var_export_helper($value) . ";";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//Now synch up the keys in other langauges to ensure that removed/added Drop down values work properly under all langs.
|
||||
$this->synchDropDown($dropdown_name, $dropdown, $selected_lang, $dir);
|
||||
$contents = $this->getNewCustomContents($dropdown_name, $dropdown, $selected_lang);
|
||||
}
|
||||
if(!empty($dir) && !is_dir($dir))
|
||||
{
|
||||
$continue = mkdir_recursive($dir);
|
||||
}
|
||||
save_custom_app_list_strings_contents($contents, $selected_lang, $dir);
|
||||
}
|
||||
sugar_cache_reset();
|
||||
clearAllJsAndJsLangFilesWithoutOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* function synchDropDown
|
||||
* Ensures that the set of dropdown keys is consistant accross all languages.
|
||||
*
|
||||
* @param $dropdown_name The name of the dropdown to be synched
|
||||
* @param $dropdown array The dropdown currently being saved
|
||||
* @param $selected_lang String the language currently selected in Studio/MB
|
||||
* @param $saveLov String the path to the directory to save the new lang file in.
|
||||
*/
|
||||
function synchDropDown($dropdown_name, $dropdown, $selected_lang, $saveLoc) {
|
||||
$allLanguages = get_languages();
|
||||
foreach ($allLanguages as $lang => $langName) {
|
||||
if ($lang != $selected_lang) {
|
||||
$listStrings = return_app_list_strings_language($lang);
|
||||
$langDropDown = array();
|
||||
if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name]))
|
||||
{
|
||||
$langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]);
|
||||
} else
|
||||
{
|
||||
//if the dropdown does not exist in the language, justt use what we have.
|
||||
$langDropDown = $dropdown;
|
||||
}
|
||||
$contents = $this->getNewCustomContents($dropdown_name, $langDropDown, $lang);
|
||||
save_custom_app_list_strings_contents($contents, $lang, $saveLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function synchMBDropDown
|
||||
* Ensures that the set of dropdown keys is consistant accross all languages in a ModuleBuilder Module
|
||||
*
|
||||
* @param $dropdown_name The name of the dropdown to be synched
|
||||
* @param $dropdown array The dropdown currently being saved
|
||||
* @param $selected_lang String the language currently selected in Studio/MB
|
||||
* @param $module MBModule the module to update the languages in
|
||||
*/
|
||||
function synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module) {
|
||||
$selected_lang = $selected_lang . '.lang.php';
|
||||
foreach($module->mblanguage->appListStrings as $lang => $listStrings) {
|
||||
if ($lang != $selected_lang)
|
||||
{
|
||||
$langDropDown = array();
|
||||
if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name]))
|
||||
{
|
||||
$langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]);
|
||||
} else
|
||||
{
|
||||
$langDropDown = $dropdown;
|
||||
}
|
||||
$module->mblanguage->appListStrings[$lang][$dropdown_name] = $langDropDown;
|
||||
$module->mblanguage->save($module->key_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function synchDDKeys($dom, $sub) {
|
||||
//check for extra keys
|
||||
foreach($sub as $key=>$value) {
|
||||
if (!isset($dom[$key])) {
|
||||
unset ($sub[$key]);
|
||||
}
|
||||
}
|
||||
//check for missing keys
|
||||
foreach($dom as $key=>$value) {
|
||||
if (!isset($sub[$key])) {
|
||||
$sub[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $sub;
|
||||
}
|
||||
|
||||
function getPatternMatch($dropdown_name) {
|
||||
return '/\s*\$GLOBALS\s*\[\s*\'app_list_strings\s*\'\s*\]\[\s*\''
|
||||
. $dropdown_name.'\'\s*\]\s*=\s*array\s*\([^\)]*\)\s*;\s*/ism';
|
||||
}
|
||||
|
||||
function getNewCustomContents($dropdown_name, $dropdown, $lang) {
|
||||
$contents = return_custom_app_list_strings_file_contents($lang);
|
||||
$contents = str_replace("?>", '', $contents);
|
||||
if(empty($contents))$contents = "<?php";
|
||||
$contents = preg_replace($this->getPatternMatch($dropdown_name), "\n", $contents);
|
||||
$contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']=" . var_export_helper($dropdown) . ";";
|
||||
return $contents;
|
||||
}
|
||||
}
|
||||
?>
|
||||
189
modules/ModuleBuilder/parsers/parser.label.php
Executable file
189
modules/ModuleBuilder/parsers/parser.label.php
Executable file
@@ -0,0 +1,189 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ;
|
||||
|
||||
class ParserLabel extends ModuleBuilderParser
|
||||
{
|
||||
|
||||
function ParserLabel ($moduleName, $packageName = '' )
|
||||
{
|
||||
$this->moduleName = $moduleName;
|
||||
if (!empty($packageName))
|
||||
$this->packageName = $packageName ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes in the request params from a save request and processes
|
||||
* them for the save.
|
||||
* @param REQUEST $params Labels as "label_".System label => Display label pairs
|
||||
* @param string $language Language key, for example 'en_us'
|
||||
*/
|
||||
function handleSave ($params , $language)
|
||||
{
|
||||
$labels = array ( ) ;
|
||||
foreach ( $params as $key => $value )
|
||||
{
|
||||
if (preg_match ( '/^label_/', $key ) && strcmp ( $value, 'no_change' ) != 0)
|
||||
{
|
||||
$labels [ strtoupper(substr ( $key, 6 )) ] = $value ;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->packageName)) //we are in Module builder
|
||||
{
|
||||
return self::addLabels ( $language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language" ) ;
|
||||
} else
|
||||
{
|
||||
return self::addLabels ( $language, $labels, $this->moduleName ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a set of labels to the language pack for a module, deployed or undeployed
|
||||
* @param string $language Language key, for example 'en_us'
|
||||
* @param array $labels The labels to add in the form of an array of System label => Display label pairs
|
||||
* @param string $moduleName Name of the module to which to add these labels
|
||||
* @param string $packageName If module is undeployed, name of the package to which it belongs
|
||||
*/
|
||||
static function addLabels ($language , $labels , $moduleName , $basepath = null, $forRelationshipLabel = false)
|
||||
{
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );" ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( "\$labels:" . print_r ( $labels, true ) ) ;
|
||||
|
||||
$deployedModule = false ;
|
||||
if (is_null ( $basepath ))
|
||||
{
|
||||
$deployedModule = true ;
|
||||
$basepath = "custom/modules/$moduleName/language" ;
|
||||
if($forRelationshipLabel){
|
||||
$basepath = "custom/modules/$moduleName/Ext/Language" ;
|
||||
}
|
||||
if (! is_dir ( $basepath ))
|
||||
{
|
||||
mkdir_recursive($basepath);
|
||||
}
|
||||
}
|
||||
|
||||
$filename = "$basepath/$language.lang.php" ;
|
||||
if($forRelationshipLabel){
|
||||
$filename = "$basepath/$language.lang.ext.php" ;
|
||||
}
|
||||
$dir_exists = is_dir ( $basepath ) ;
|
||||
|
||||
$mod_strings = array ( ) ;
|
||||
|
||||
if ($dir_exists)
|
||||
{
|
||||
if (file_exists ( $filename ))
|
||||
{
|
||||
// obtain $mod_strings
|
||||
include ($filename) ;
|
||||
}else if($forRelationshipLabel){
|
||||
$fh = fopen ($filename, 'a');
|
||||
fclose($fh);
|
||||
}
|
||||
} else
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
$changed = false ;
|
||||
|
||||
//$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
|
||||
|
||||
foreach ( $labels as $key => $value )
|
||||
{
|
||||
if (! isset ( $mod_strings [ $key ] ) || strcmp ( $value, $mod_strings [ $key ] ) != 0)
|
||||
{
|
||||
$mod_strings [$key] = html_entity_decode_utf8($value, ENT_QUOTES ); // must match encoding used in view.labels.php
|
||||
$changed = true ;
|
||||
}
|
||||
}
|
||||
|
||||
if ($changed)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: writing new mod_strings to $filename" ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ;
|
||||
if (! write_array_to_file ( "mod_strings", $mod_strings, $filename ))
|
||||
{
|
||||
$GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ;
|
||||
} else
|
||||
{
|
||||
// if we have a cache to worry about, then clear it now
|
||||
if ($deployedModule)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ;
|
||||
$cache_key = "module_language." . $language . $moduleName ;
|
||||
sugar_cache_clear ( $cache_key ) ;
|
||||
LanguageManager::clearLanguageCache ( $moduleName, $language ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes in the request params from a save request and processes
|
||||
* them for the save.
|
||||
* @param $metadata
|
||||
* @param string $language Language key, for example 'en_us'
|
||||
*/
|
||||
function handleSaveRelationshipLabels ($metadata , $language)
|
||||
{
|
||||
foreach ( $metadata as $definition )
|
||||
{
|
||||
$labels = array();
|
||||
$labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
|
||||
self::addLabels ( $language, $labels, $definition [ 'module' ],null,true );
|
||||
}
|
||||
}
|
||||
|
||||
function addLabelsToAllLanguages($labels)
|
||||
{
|
||||
$langs = get_languages();
|
||||
foreach($langs as $lang_key => $lang_display)
|
||||
{
|
||||
$this->addLabels($lang_key, $labels, $this->moduleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
524
modules/ModuleBuilder/parsers/parser.modifylayoutview.php
Executable file
524
modules/ModuleBuilder/parsers/parser.modifylayoutview.php
Executable file
@@ -0,0 +1,524 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php');
|
||||
|
||||
class ParserModifyLayoutView extends ModuleBuilderParser
|
||||
{
|
||||
|
||||
var $maxColumns; // number of columns in this layout
|
||||
var $usingWorkingFile = false; // if a working file exists (used by view.edit.php among others to determine the title for the layout edit panel)
|
||||
var $language_module; // set to module name for studio, passed to the smarty template and used by sugar_translate
|
||||
var $_sourceFile; // private - the source of the layout defn
|
||||
var $_customFile; // private
|
||||
var $_workingFile; // private
|
||||
var $_originalFile; //private
|
||||
var $_moduleVariable; // private - if set, contains the name of the variable containing the module name in the $viewdef file
|
||||
var $_module; // private
|
||||
var $_view; // private
|
||||
var $_viewdefs; // private
|
||||
var $_fieldDefs; // private
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function init ($module, $view, $submittedLayout = false)
|
||||
{
|
||||
$this->_view = ucfirst($view);
|
||||
$this->_module = $module;
|
||||
$this->language_module = $module;
|
||||
|
||||
$this->_baseDirectory = "modules/{$module}/metadata/";
|
||||
$file = $this->_baseDirectory . strtolower($view) . "defs.php";
|
||||
$this->_customFile = "custom/" . $file;
|
||||
$this->_workingFile = "custom/working/" . $file;
|
||||
|
||||
$this->_sourceView = $this->_view;
|
||||
$this->_originalFile = $file ;
|
||||
$this->_sourceFile = $file;
|
||||
if (is_file($this->_workingFile))
|
||||
{
|
||||
$this->_sourceFile = $this->_workingFile;
|
||||
$this->usingWorkingFile = true;
|
||||
}
|
||||
else if (is_file($this->_customFile))
|
||||
{
|
||||
$this->_sourceFile = $this->_customFile;
|
||||
}
|
||||
else if (! is_file($this->_sourceFile))
|
||||
{
|
||||
// if we don't have ANY defined metadata then improvise as best we can
|
||||
if (strtolower($this->_view) == 'quickcreate')
|
||||
{
|
||||
// special handling for quickcreates - base the quickcreate on the editview if no quickcreatedef exists
|
||||
$this->_sourceFile = $this->_baseDirectory."editviewdefs.php";
|
||||
if (is_file("custom/" . $this->_sourceFile))
|
||||
{
|
||||
$this->_sourceFile = "custom/" . $this->_sourceFile;
|
||||
}
|
||||
$this->_sourceView = 'EditView';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_fatalError('parser.modifylayout.php->init(): no metadata for '.$this->_module.' '.$this->_view);
|
||||
}
|
||||
}
|
||||
|
||||
// get the fieldDefs from the bean
|
||||
$class = $GLOBALS ['beanList'] [$module];
|
||||
require_once ($GLOBALS ['beanFiles'] [$class]);
|
||||
$bean = new $class();
|
||||
$this->_fieldDefs = & $bean->field_defs;
|
||||
|
||||
$this->loadModule($this->_module, $this->_sourceView);
|
||||
$this->_viewdefs ['panels'] = $this->_parseData($this->_viewdefs['panels']); // put into a canonical format
|
||||
$this->maxColumns = $this->_viewdefs ['templateMeta'] ['maxColumns'];
|
||||
|
||||
if ($submittedLayout)
|
||||
{
|
||||
// replace the definitions with the new submitted layout
|
||||
$this->_loadLayoutFromRequest();
|
||||
} else
|
||||
{
|
||||
$this->_padFields(); // destined for a View, so we want to add in (empty) fields
|
||||
}
|
||||
// $GLOBALS['log']->debug($this->_viewdefs['panels']);
|
||||
|
||||
}
|
||||
|
||||
function getAvailableFields ()
|
||||
{
|
||||
// Available fields are those that are in the Model and the original layout definition, but not already shown in the View
|
||||
// So, because the formats of the two are different we brute force loop through View and unset the fields we find in a copy of Model
|
||||
$availableFields = $this->_getModelFields();
|
||||
$GLOBALS['log']->debug( get_class($this)."->getAvailableFields(): _getModelFields returns: ".implode(",",array_keys($availableFields)));
|
||||
if (! empty($this->_viewdefs))
|
||||
{
|
||||
foreach ($this->_viewdefs ['panels'] as $panel)
|
||||
{
|
||||
foreach ($panel as $row)
|
||||
{
|
||||
foreach ($row as $fieldArray)
|
||||
{ // fieldArray is an array('name'=>name,'label'=>label)
|
||||
if (isset($fieldArray ['name']))
|
||||
{
|
||||
unset($availableFields [$fieldArray ['name']]);
|
||||
$GLOBALS['log']->debug( get_class($this)."->getAvailableFields(): removing ".$fieldArray ['name'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $availableFields;
|
||||
}
|
||||
|
||||
function getLayout ()
|
||||
{
|
||||
return $this->_viewdefs ['panels'];
|
||||
}
|
||||
|
||||
function writeWorkingFile ()
|
||||
{
|
||||
$this->_writeToFile($this->_workingFile,$this->_view,$this->_module,$this->_viewdefs,$this->_variables);
|
||||
}
|
||||
|
||||
function handleSave ()
|
||||
{
|
||||
$this->_writeToFile($this->_customFile,$this->_view,$this->_module,$this->_viewdefs,$this->_variables);
|
||||
// now clear the cache so that the results are immediately visible
|
||||
include_once('include/TemplateHandler/TemplateHandler.php');
|
||||
if (strtolower($this->_view) == 'quickcreate')
|
||||
{
|
||||
TemplateHandler::clearCache($this->_module,"form_SubPanelQuickCreate_{$this->_module}.tpl");
|
||||
TemplateHandler::clearCache($this->_module,"form_DCQuickCreate_{$this->_module}.tpl");
|
||||
}
|
||||
else
|
||||
{
|
||||
TemplateHandler::clearCache($this->_module,"{$this->_view}.tpl");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function loadModule ($module, $view)
|
||||
{
|
||||
$this->_viewdefs = array();
|
||||
$viewdefs = null;
|
||||
|
||||
$loaded = $this->_loadFromFile($view,$this->_sourceFile,$module);
|
||||
$this->_viewdefs = $loaded['viewdefs'][$module][$view];
|
||||
$this->_variables = $loaded['variables'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the canonical panel layout from the submitted form
|
||||
*
|
||||
*/
|
||||
function _loadLayoutFromRequest ()
|
||||
{
|
||||
|
||||
$i = 1;
|
||||
// set up the map of panel# (as provided in the _REQUEST) to panel ID (as used in $this->_viewdefs['panels'])
|
||||
foreach ($this->_viewdefs ['panels'] as $panelID => $panel)
|
||||
{
|
||||
$panelMap [$i ++] = $panelID;
|
||||
}
|
||||
// replace any old values with new panel labels from the request
|
||||
foreach ($_REQUEST as $key => $value)
|
||||
{
|
||||
$components = explode('-', $key);
|
||||
if ($components [0] == 'panel')
|
||||
{
|
||||
$panelMap [$components ['1']] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$olddefs = $this->_viewdefs ['panels'];
|
||||
$origFieldDefs = $this->_getOrigFieldViewDefs();
|
||||
// $GLOBALS['log']->debug('origFieldDefs');
|
||||
// $GLOBALS['log']->debug($origFieldDefs);
|
||||
$this->_viewdefs ['panels'] = null; // because the new field properties should replace the old fields, not be merged
|
||||
|
||||
if ($this->maxColumns < 1)
|
||||
{
|
||||
$this->_fatalError("EditDetailViewParser:invalid maxColumns=" . $this->maxColumns);
|
||||
}
|
||||
|
||||
foreach ($_REQUEST as $slot => $value)
|
||||
{
|
||||
$slotComponents = explode('-', $slot); // [0] = 'slot', [1] = panel #, [2] = slot #, [3] = property name
|
||||
if ($slotComponents [0] == 'slot')
|
||||
{
|
||||
$slotNumber = $slotComponents ['2'];
|
||||
$panelID = $panelMap [$slotComponents ['1']];
|
||||
$rowID = floor($slotNumber / $this->maxColumns);
|
||||
$colID = $slotNumber - ($rowID * $this->maxColumns);
|
||||
//If the original editview defined this field, copy that over.
|
||||
if ($slotComponents ['3'] == 'name' && isset($origFieldDefs [$value]) && is_array($origFieldDefs [$value]))
|
||||
{
|
||||
$this->_viewdefs ['panels'] [$panelID] [$rowID] [$colID] = $origFieldDefs [$value];
|
||||
}
|
||||
else
|
||||
{
|
||||
$property = $slotComponents ['3'];
|
||||
if ($value == '(filler)')
|
||||
{
|
||||
$this->_viewdefs ['panels'] [$panelID] [$rowID] [$colID] = NULL;
|
||||
} else
|
||||
{
|
||||
$this->_viewdefs ['panels'] [$panelID] [$rowID] [$colID] [$property] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now handle the (empty) fields - first non-(empty) field goes in at column 0; all other (empty)'s removed
|
||||
// Do this AFTER reading in all the $_REQUEST parameters as can't guarantee the order of those, and we need to operate on complete rows
|
||||
foreach ($this->_viewdefs ['panels'] as $panelID => $panel)
|
||||
{
|
||||
// remove all (empty)s
|
||||
foreach ($panel as $rowID => $row)
|
||||
{
|
||||
$startOfRow = true;
|
||||
$offset = 0;
|
||||
foreach ($row as $colID => $col)
|
||||
{
|
||||
if ($col ['name'] == '(empty)')
|
||||
{
|
||||
// if a leading (empty) then remove (by noting that remaining fields need to be shuffled along)
|
||||
if ($startOfRow)
|
||||
{
|
||||
$offset ++;
|
||||
}
|
||||
unset($row [$colID]);
|
||||
} else
|
||||
{
|
||||
$startOfRow = false;
|
||||
}
|
||||
}
|
||||
// reindex to remove leading (empty)s
|
||||
$newRow = array();
|
||||
foreach ($row as $colID => $col)
|
||||
{
|
||||
$newRow [$colID - $offset] = $col;
|
||||
}
|
||||
$this->_viewdefs ['panels'] [$panelID] [$rowID] = $newRow;
|
||||
}
|
||||
}
|
||||
// _pp($this->_viewdefs);
|
||||
}
|
||||
|
||||
function _padFields ()
|
||||
{
|
||||
if (! empty($this->_viewdefs))
|
||||
{
|
||||
foreach ($this->_viewdefs ['panels'] as $panelID => $panel)
|
||||
{
|
||||
$column = 0;
|
||||
foreach ($panel as $rowID => $row)
|
||||
{
|
||||
// pad between fields on a row
|
||||
foreach ($row as $colID => $col)
|
||||
{
|
||||
for ($i = $column + 1 ; $i < $colID ; $i ++ )
|
||||
{
|
||||
$row [$i] = array('name' => '(empty)', 'label' => '(empty)');
|
||||
}
|
||||
$column = $colID;
|
||||
}
|
||||
// now pad out to the end of the row
|
||||
if (($column + 1) < $this->maxColumns)
|
||||
{ // last column is maxColumns-1
|
||||
for ($i = $column + 1 ; $i < $this->maxColumns ; $i ++ )
|
||||
{
|
||||
$row [$i] = array('name' => '(empty)', 'label' => '(empty)');
|
||||
}
|
||||
}
|
||||
ksort($row);
|
||||
$this->_viewdefs ['panels'] [$panelID] [$rowID] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add a new field to the end of a panel
|
||||
// don't write out (caller should call handleSave() when ready)
|
||||
function _addField ($properties, $panelID = FALSE)
|
||||
{
|
||||
|
||||
// if a panelID was not passed, use the first available panel in the list
|
||||
if (!$panelID) {
|
||||
$panels = array_keys($this->_viewdefs['panels']);
|
||||
$panelID = $panels[0];
|
||||
}
|
||||
|
||||
if (isset($this->_viewdefs ['panels'] [$panelID]))
|
||||
{
|
||||
|
||||
// need to clean up the viewdefs before writing them -- Smarty will fail if any fillers/empties are present
|
||||
foreach ($this->_viewdefs['panels'] as $loop_panelID => $panel_contents) {
|
||||
foreach ($panel_contents as $row_id => $row) {
|
||||
foreach ($row as $col_id => $col) {
|
||||
if ($col['name'] == '(filler)') {
|
||||
$this->_viewdefs['panels'][$loop_panelID][$row_id][$col_id] = NULL;
|
||||
}
|
||||
elseif ($col['name'] == '(empty)') {
|
||||
unset($this->_viewdefs['panels'][$loop_panelID][$row_id][$col_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$panel = $this->_viewdefs ['panels'] [$panelID];
|
||||
$lastrow = count($panel) - 1; // index starts at 0
|
||||
$lastcol = count($panel [$lastrow]);
|
||||
|
||||
// if we're on the last column of the last row, start a new row
|
||||
// print "lastrow=$lastrow lastcol=$lastcol";
|
||||
if ($lastcol >= $this->maxColumns)
|
||||
{
|
||||
$lastrow ++;
|
||||
$this->_viewdefs ['panels'] [$panelID] [$lastrow] = array();
|
||||
$lastcol = 0;
|
||||
}
|
||||
|
||||
$this->_viewdefs ['panels'] [$panelID] [$lastrow] [$lastcol] = $properties;
|
||||
}
|
||||
}
|
||||
|
||||
/* getModelFields returns an array of all fields stored in the database for this module plus those fields in the original layout definition (so we get fields such as Team ID)*/
|
||||
function _getModelFields ()
|
||||
{
|
||||
$modelFields = array();
|
||||
$origViewDefs = $this->_getOrigFieldViewDefs();
|
||||
// $GLOBALS['log']->debug("Original viewdefs = ".print_r($origViewDefs,true));
|
||||
foreach ($origViewDefs as $field => $def)
|
||||
{
|
||||
if (!empty($field))
|
||||
{
|
||||
if (! is_array($def)) {
|
||||
$def = array('name' => $field);
|
||||
}
|
||||
// get this field's label - if it has not been explicitly provided, see if the fieldDefs has a label for this field, and if not fallback to the field name
|
||||
if (! isset($def ['label']))
|
||||
{
|
||||
if (! empty($this->_fieldDefs [$field] ['vname']))
|
||||
{
|
||||
$def ['label'] = $this->_fieldDefs [$field] ['vname'];
|
||||
} else
|
||||
{
|
||||
$def ['label'] = $field;
|
||||
}
|
||||
}
|
||||
$modelFields[$field] = array('name' => $field, 'label' => $def ['label']);
|
||||
}
|
||||
}
|
||||
$GLOBALS['log']->debug(print_r($modelFields,true));
|
||||
foreach ($this->_fieldDefs as $field => $def)
|
||||
{
|
||||
if ((!empty($def['studio']) && $def['studio'] == 'visible')
|
||||
|| (empty($def['studio']) && (empty($def ['source']) || $def ['source'] == 'db' || $def ['source'] == 'custom_fields') && $def ['type'] != 'id' && strcmp($field, 'deleted') != 0 && (empty($def ['dbType']) || $def ['dbType'] != 'id') && (empty($def ['dbtype']) || $def ['dbtype'] != 'id')))
|
||||
{
|
||||
$label = isset($def['vname']) ? $def['vname'] : $def['name'];
|
||||
$modelFields [$field] = array('name' => $field, 'label' => $label);
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['log']->debug( get_class($this)."->_getModelFields(): skipping $field from modelFields as it fails the test for inclusion");
|
||||
if ($field == 'assigned_user_name')
|
||||
{
|
||||
$GLOBALS['log']->debug( print_r($def,true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$GLOBALS['log']->debug( get_class($this)."->_getModelFields(): remaining entries in modelFields are: ".implode(",",array_keys($modelFields)));
|
||||
return $modelFields;
|
||||
}
|
||||
|
||||
function _parseData ($panels)
|
||||
{
|
||||
$fields = array();
|
||||
if (empty($panels))
|
||||
return;
|
||||
|
||||
// Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined, it goes straight into rows
|
||||
// See EditView2 for similar treatment
|
||||
if (! empty($panels) && count($panels) > 0)
|
||||
{
|
||||
$keys = array_keys($panels);
|
||||
if (is_numeric($keys [0]))
|
||||
{
|
||||
$defaultPanel = $panels;
|
||||
unset($panels); //blow away current value
|
||||
$panels [''] = $defaultPanel;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($panels as $panelID => $panel)
|
||||
{
|
||||
foreach ($panel as $rowID => $row)
|
||||
{
|
||||
foreach ($row as $colID => $col)
|
||||
{
|
||||
$properties = array();
|
||||
|
||||
if (! empty($col))
|
||||
{
|
||||
if (is_string($col))
|
||||
{
|
||||
$properties ['name'] = $col;
|
||||
} else if (! empty($col ['name']))
|
||||
{
|
||||
$properties = $col;
|
||||
}
|
||||
} else
|
||||
{
|
||||
$properties ['name'] = translate('LBL_FILLER');
|
||||
}
|
||||
|
||||
if (! empty($properties ['name']))
|
||||
{
|
||||
|
||||
// get this field's label - if it has not been explicity provided, see if the fieldDefs has a label for this field, and if not fallback to the field name
|
||||
if (! isset($properties ['label']))
|
||||
{
|
||||
if (! empty($this->_fieldDefs [$properties ['name']] ['vname']))
|
||||
{
|
||||
$properties ['label'] = $this->_fieldDefs [$properties ['name']] ['vname'];
|
||||
} else
|
||||
{
|
||||
$properties ['label'] = $properties ['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$displayData[strtoupper($panelID)] [$rowID] [$colID] = $properties;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $displayData;
|
||||
}
|
||||
|
||||
function _getOrigFieldViewDefs ()
|
||||
{
|
||||
$origFieldDefs = array();
|
||||
$GLOBALS['log']->debug("Original File = ".$this->_originalFile);
|
||||
if (file_exists($this->_originalFile))
|
||||
{
|
||||
include ($this->_originalFile);
|
||||
$origdefs = $viewdefs [$this->_module] [$this->_sourceView] ['panels'];
|
||||
// $GLOBALS['log']->debug($origdefs);
|
||||
// Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined, it goes straight into rows
|
||||
// See EditView2 for similar treatment
|
||||
if (! empty($origdefs) && count($origdefs) > 0)
|
||||
{
|
||||
$keys = array_keys($origdefs);
|
||||
if (is_numeric($keys [0]))
|
||||
{
|
||||
$defaultPanel = $origdefs;
|
||||
unset($origdefs); //blow away current value
|
||||
$origdefs [''] = $defaultPanel;
|
||||
}
|
||||
}
|
||||
foreach ($origdefs as $pname => $paneldef)
|
||||
{
|
||||
foreach ($paneldef as $row)
|
||||
{
|
||||
foreach ($row as $fieldDef)
|
||||
{
|
||||
if (is_array($fieldDef))
|
||||
{
|
||||
$fieldName = $fieldDef ['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$fieldName = $fieldDef;
|
||||
}
|
||||
$origFieldDefs [$fieldName] = $fieldDef;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $origFieldDefs;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
324
modules/ModuleBuilder/parsers/parser.modifylistview.php
Executable file
324
modules/ModuleBuilder/parsers/parser.modifylistview.php
Executable file
@@ -0,0 +1,324 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ;
|
||||
class ParserModifyListView extends ModuleBuilderParser
|
||||
{
|
||||
var $listViewDefs = false ;
|
||||
var $defaults = array ( ) ;
|
||||
var $additional = array ( ) ;
|
||||
var $available = array ( ) ;
|
||||
var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved
|
||||
// var $language_module = '';
|
||||
var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
function init ( $module_name , $submodule = '' )
|
||||
{
|
||||
global $app_list_strings ;
|
||||
$this->module_name = $module_name ;
|
||||
$mod_strings = return_module_language ( $GLOBALS [ 'current_language' ], $this->module_name ) ; // needed solely so that listviewdefs that reference this can be included without error
|
||||
$class = $GLOBALS [ 'beanList' ] [ $this->module_name ] ;
|
||||
require_once ($GLOBALS [ 'beanFiles' ] [ $class ]) ;
|
||||
$this->module = new $class ( ) ;
|
||||
|
||||
$loaded = $this->_loadFromFile('ListView','modules/' . $this->module_name . '/metadata/listviewdefs.php',$this->module_name);
|
||||
$this->originalListViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
|
||||
$this->_variables = $loaded['variables'];
|
||||
// _pp($loaded);
|
||||
$this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ;
|
||||
if (file_exists ( $this->customFile ))
|
||||
{
|
||||
$loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name);
|
||||
$this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
|
||||
$this->_variables = $loaded['variables'];
|
||||
} else
|
||||
{
|
||||
$this->listViewDefs = & $this->originalListViewDefs ;
|
||||
}
|
||||
|
||||
$this->fixKeys ( $this->originalListViewDefs ) ;
|
||||
$this->fixKeys ( $this->listViewDefs ) ;
|
||||
$this->language_module = $this->module_name ;
|
||||
}
|
||||
|
||||
function getLanguage()
|
||||
{
|
||||
return $this->language_module;
|
||||
}
|
||||
// re-key array so that every entry has a key=name and all keys are lowercase - makes it easier in handleSave() later...
|
||||
function fixKeys ( &$defs )
|
||||
{
|
||||
$temp = array ( ) ;
|
||||
foreach ( $defs as $key => $value )
|
||||
{
|
||||
if (! is_array ( $value ))
|
||||
{
|
||||
$key = $value ;
|
||||
$def = array ( ) ;
|
||||
$def [ 'name' ] = (isset ( $this->module->field_defs [ $key ] )) ? $this->module->field_defs [ $key ] [ 'name' ] : $key ;
|
||||
$value = $def ;
|
||||
}
|
||||
if (isset ( $value [ 'name' ] ))
|
||||
{
|
||||
$key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key
|
||||
}
|
||||
$temp [ strtolower ( $key ) ] = $value ;
|
||||
}
|
||||
$defs = $temp ;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the default fields for a listview
|
||||
* Called only when displaying the listview for editing; not called when saving
|
||||
*/
|
||||
function getDefaultFields ()
|
||||
{
|
||||
$this->defaults = array ( ) ;
|
||||
foreach ( $this->listViewDefs as $key => $def )
|
||||
{
|
||||
// add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true
|
||||
// Important: the 'studio' fields must be added back into the layout on save, as they're not editable rather than hidden
|
||||
if (! empty ( $def [ 'default' ] ))
|
||||
{
|
||||
if (! isset($def['studio']) || $def['studio'] === true)
|
||||
{
|
||||
$this->defaults [ $key ] = $def ;
|
||||
}
|
||||
else
|
||||
// anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything
|
||||
{
|
||||
$this->reserved [ $key ] = $def;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->defaults ;
|
||||
}
|
||||
/**
|
||||
* returns additional fields available for users to create fields
|
||||
*/
|
||||
function getAdditionalFields ()
|
||||
{
|
||||
$this->additional = array ( ) ;
|
||||
foreach ( $this->listViewDefs as $key => $def )
|
||||
{
|
||||
if (empty ( $def [ 'default' ] ))
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
$this->additional [ $key ] = $def ;
|
||||
}
|
||||
}
|
||||
return $this->additional ;
|
||||
}
|
||||
/**
|
||||
* returns unused fields that are available for using in either default or additional list views
|
||||
*/
|
||||
function getAvailableFields ()
|
||||
{
|
||||
$this->availableFields = array ( ) ;
|
||||
$lowerFieldList = array_change_key_case ( $this->listViewDefs ) ;
|
||||
foreach ( $this->originalListViewDefs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if (! isset ( $lowerFieldList [ $key ] ))
|
||||
{
|
||||
$this->availableFields [ $key ] = $def ;
|
||||
}
|
||||
}
|
||||
$GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true));
|
||||
$modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs;
|
||||
foreach ( $modFields as $key => $def )
|
||||
{
|
||||
$fieldName = strtolower ( $key ) ;
|
||||
if ($fieldName == 'currency_id')
|
||||
continue;
|
||||
if (!isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
|
||||
{
|
||||
// bug 19656: this test changed after 5.0.0b - we now remove all ID type fields - whether set as type, or dbtype, from the fielddefs
|
||||
if ($this->isValidField($key, $def)){
|
||||
$label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ;
|
||||
$this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->availableFields ;
|
||||
}
|
||||
|
||||
function isValidField($key, $def) {
|
||||
//Allow fields that are studio visible
|
||||
if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible')
|
||||
return true;
|
||||
|
||||
//No ID fields
|
||||
if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id'))
|
||||
return false;
|
||||
|
||||
//only allow DB and custom fields (if a source is specified)
|
||||
if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields')
|
||||
return false;
|
||||
|
||||
//Dont ever show the "deleted" fields or "_name" fields
|
||||
if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false))
|
||||
return false;
|
||||
|
||||
_pp($def);
|
||||
//If none of the "ifs" are true, the field is valid
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getField ( $fieldName )
|
||||
{
|
||||
$fieldName = strtolower ( $fieldName ) ;
|
||||
foreach ( $this->listViewDefs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if ($key == $fieldName)
|
||||
{
|
||||
return $def ;
|
||||
}
|
||||
}
|
||||
foreach ( $this->module->field_defs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if ($key == $fieldName)
|
||||
{
|
||||
return $def ;
|
||||
}
|
||||
}
|
||||
return array ( ) ;
|
||||
}
|
||||
function addRelateData($fieldname, $listfielddef) {
|
||||
$modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ];
|
||||
if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) {
|
||||
$listfielddef['module'] = $modFieldDef['module'];
|
||||
$listfielddef['id'] = strtoupper($modFieldDef['id_name']);
|
||||
$listfielddef['link'] = true;
|
||||
$listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name']));
|
||||
}
|
||||
return $listfielddef;
|
||||
}
|
||||
function _loadLayoutFromRequest ()
|
||||
{
|
||||
$GLOBALS['log']->debug("ParserModifyListView->_loadLayoutFromRequest()");
|
||||
$fields = array ( ) ;
|
||||
$rejectTypes = array ( 'html' , 'enum' , 'text' ) ;
|
||||
for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < 2 ; $i ++ )
|
||||
{
|
||||
//echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n";
|
||||
foreach ( $_POST [ 'group_' . $i ] as $field )
|
||||
{
|
||||
$fieldname = strtoupper ( $field ) ;
|
||||
//originalListViewDefs are all lower case
|
||||
$lowerFieldName = strtolower ( $field ) ;
|
||||
if (isset ( $this->originalListViewDefs [ $lowerFieldName ] ))
|
||||
{
|
||||
$fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ;
|
||||
} else
|
||||
{
|
||||
//check if we have the case wrong for custom fields
|
||||
if (! isset ( $this->module->field_defs [ $fieldname ] ))
|
||||
{
|
||||
foreach ( $this->module->field_defs as $key => $value )
|
||||
{
|
||||
if (strtoupper ( $key ) == $fieldname)
|
||||
{
|
||||
$fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
$fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ;
|
||||
}
|
||||
// sorting fields of certain types will cause a database engine problems
|
||||
// we only check this for custom fields, as we assume that OOB fields have been independently confirmed as ok
|
||||
if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] ) && (in_array ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ], $rejectTypes ) || isset($this->module->field_defs [ strtolower ( $fieldname ) ]['custom_module'])))
|
||||
{
|
||||
$fields [ $fieldname ] [ 'sortable' ] = false ;
|
||||
}
|
||||
// Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true
|
||||
if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type ' ] ) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'currency')
|
||||
{
|
||||
$fields [ $fieldname ] [ 'currency_format' ] = true;
|
||||
}
|
||||
}
|
||||
if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] ))
|
||||
{
|
||||
$width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ;
|
||||
if (strpos ( $width, "%" ) != false)
|
||||
{
|
||||
$width = substr ( $width, 0, 2 ) ;
|
||||
}
|
||||
if ($width < 101 && $width > 0)
|
||||
{
|
||||
$fields [ $fieldname ] [ 'width' ] = $width ;
|
||||
}
|
||||
} else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] ))
|
||||
{
|
||||
$fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ;
|
||||
}
|
||||
//Get additional Data for relate fields
|
||||
if (isset($this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ]) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'relate') {
|
||||
$fields [ $fieldname ] = $this->addRelateData($field, $fields [ $fieldname ]);
|
||||
}
|
||||
$fields [ $fieldname ] [ 'default' ] = ($i == 0) ;
|
||||
}
|
||||
}
|
||||
// Add the reserved fields back in to the end of the default fields in the layout
|
||||
// ASSUMPTION: reserved fields go back at the end
|
||||
// First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving
|
||||
$this->getDefaultFields();
|
||||
foreach ( $this->reserved as $key => $def)
|
||||
{
|
||||
$fields[ $key ] = $def;
|
||||
}
|
||||
|
||||
return $fields ;
|
||||
}
|
||||
function handleSave ()
|
||||
{
|
||||
$fields = $this->_loadLayoutFromRequest();
|
||||
$this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables);
|
||||
|
||||
$GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ;
|
||||
// now clear the cache so that the results are immediately visible
|
||||
include_once ('include/TemplateHandler/TemplateHandler.php') ;
|
||||
TemplateHandler::clearCache ( $this->module_name, "ListView.tpl" ) ; // not currently cached, but here for the future
|
||||
}
|
||||
}
|
||||
?>
|
||||
256
modules/ModuleBuilder/parsers/parser.modifysubpanel.php
Executable file
256
modules/ModuleBuilder/parsers/parser.modifysubpanel.php
Executable file
@@ -0,0 +1,256 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Modify an exising Subpanel
|
||||
* Typically called from Studio for a deployed (OOB or installed custom module)
|
||||
*
|
||||
* Uses the listview editor to modify the subpanel
|
||||
* Uses SubPanelDefinitions to load the definitions for the subpanel, and SubPanel to save them, using the unique SubPanel override mechanism
|
||||
* There are two relevant modules for every subpanel - the module whose detailview this subpanel will appear in ($module_name), and the module that is the source of the data for the subpanel ($subPanelParentModule)
|
||||
*/
|
||||
|
||||
require_once ('modules/ModuleBuilder/parsers/parser.modifylistview.php') ;
|
||||
|
||||
class ParserModifySubPanel extends ParserModifyListView
|
||||
{
|
||||
|
||||
var $listViewDefs = false ;
|
||||
var $defaults = array ( ) ;
|
||||
var $additional = array ( ) ;
|
||||
var $available = array ( ) ;
|
||||
var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
|
||||
function init ($module_name , $subPanelName)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( "in ParserModifySubPanel: module_name={$module_name} child_module={$subPanelName}" ) ;
|
||||
$this->moduleName = $module_name ;
|
||||
$this->subPanelName = $subPanelName ;
|
||||
global $beanList, $beanFiles ;
|
||||
|
||||
// Sometimes we receive a module name which is not in the correct CamelCase, so shift to lower case for all beanList lookups
|
||||
$beanListLower = array_change_key_case ( $beanList ) ;
|
||||
|
||||
// Retrieve the definitions for all the available subpanels for this module
|
||||
$class = $beanListLower [ strtolower ( $this->moduleName ) ] ;
|
||||
require_once ($beanFiles [ $class ]) ;
|
||||
$module = new $class ( ) ;
|
||||
require_once ('include/SubPanel/SubPanelDefinitions.php') ;
|
||||
$spd = new SubPanelDefinitions ( $module ) ;
|
||||
|
||||
// Get the lists of fields already in the subpanel and those that can be added in
|
||||
// Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object
|
||||
$this->originalListViewDefs = array ( ) ;
|
||||
if (array_key_exists ( strtolower ( $this->subPanelName ), $spd->layout_defs [ 'subpanel_setup' ] ))
|
||||
{
|
||||
$originalPanel = $spd->load_subpanel ( $this->subPanelName, true ) ;
|
||||
$this->originalListViewDefs = $originalPanel->get_list_fields () ;
|
||||
$this->panel = $spd->load_subpanel ( $subPanelName, false ) ;
|
||||
$this->listViewDefs = $this->panel->get_list_fields () ;
|
||||
|
||||
// Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout
|
||||
$subPanelParentModuleName = $this->panel->get_module_name () ;
|
||||
$this->subPanelParentModule = null ;
|
||||
|
||||
if (! empty ( $subPanelParentModuleName ) && isset($beanListLower[strtolower($subPanelParentModuleName)]))
|
||||
{
|
||||
$class = $beanListLower[strtolower($subPanelParentModuleName)];
|
||||
if (isset($beanFiles [ $class ]))
|
||||
{
|
||||
require_once ($beanFiles [ $class ]) ;
|
||||
$this->subPanelParentModule = new $class ( ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->language_module = $this->panel->template_instance->module_dir ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of the fields that will be displayed in the subpanel
|
||||
*/
|
||||
function getDefaultFields ()
|
||||
{
|
||||
$this->defaults = array ( ) ;
|
||||
foreach ( $this->listViewDefs as $key => $def )
|
||||
{
|
||||
if (! empty ( $def [ 'usage' ] ) && strcmp ( $def [ 'usage' ], 'query_only' ) == 0)
|
||||
continue ;
|
||||
if (! empty ( $def [ 'vname' ] ))
|
||||
$def [ 'label' ] = $def [ 'vname' ] ;
|
||||
$this->defaults [ $key ] = $def ;
|
||||
}
|
||||
return $this->defaults ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of fields that are not currently included in the subpanel but that are available for use
|
||||
*/
|
||||
function getAvailableFields ()
|
||||
{
|
||||
$this->availableFields = array ( ) ;
|
||||
if ($this->subPanelParentModule != null)
|
||||
{
|
||||
$lowerFieldList = array_change_key_case ( $this->listViewDefs ) ;
|
||||
foreach ( $this->originalListViewDefs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if (! isset ( $lowerFieldList [ $key ] ))
|
||||
{
|
||||
$this->availableFields [ $key ] = $def ;
|
||||
}
|
||||
}
|
||||
$GLOBALS [ 'log' ]->debug ( 'parser.modifylistview.php->getAvailableFields(): field_defs=' . print_r ( $this->availableFields, true ) ) ;
|
||||
foreach ( $this->subPanelParentModule->field_defs as $key => $fieldDefinition )
|
||||
{
|
||||
$fieldName = strtolower ( $key ) ;
|
||||
if (! isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
|
||||
{
|
||||
if ((empty ( $fieldDefinition [ 'source' ] ) || $fieldDefinition [ 'source' ] == 'db' || $fieldDefinition [ 'source' ] == 'custom_fields') && $fieldDefinition [ 'type' ] != 'id' && strcmp ( $fieldName, 'deleted' ) != 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) != false) || ! empty ( $def [ 'custom_type' ] ) && (empty ( $fieldDefinition [ 'dbType' ] ) || $fieldDefinition [ 'dbType' ] != 'id') && (empty ( $fieldDefinition [ 'dbtype' ] ) || $fieldDefinition [ 'dbtype' ] != 'id') || (! empty ( $fieldDefinition [ 'studio' ] ) && $fieldDefinition [ 'studio' ] == 'visible'))
|
||||
{
|
||||
$label = (isset ( $fieldDefinition [ 'vname' ] )) ? $fieldDefinition [ 'vname' ] : (isset ( $fieldDefinition [ 'label' ] ) ? $fieldDefinition [ 'label' ] : $fieldDefinition [ 'name' ]) ;
|
||||
$this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->availableFields ;
|
||||
}
|
||||
|
||||
function getField ($fieldName)
|
||||
{
|
||||
foreach ( $this->listViewDefs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if ($key == $fieldName)
|
||||
{
|
||||
return $def ;
|
||||
}
|
||||
}
|
||||
foreach ( $this->originalListViewDefs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if ($key == $fieldName)
|
||||
{
|
||||
return $def ;
|
||||
}
|
||||
}
|
||||
foreach ( $this->panel->template_instance->field_defs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
if ($key == $fieldName)
|
||||
{
|
||||
return $def ;
|
||||
}
|
||||
}
|
||||
return array ( ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the modified definitions for a subpanel
|
||||
* Obtains the field definitions from a _REQUEST array, and merges them with the other fields from the original definitions
|
||||
* Uses the subpanel override mechanism from SubPanel to save them
|
||||
*/
|
||||
function handleSave ()
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( "in ParserModifySubPanel->handleSave()" ) ;
|
||||
require_once ('include/SubPanel/SubPanel.php') ;
|
||||
$subpanel = new SubPanel ( $this->moduleName, 'fab4', $this->subPanelName, $this->panel ) ;
|
||||
|
||||
$newFields = array ( ) ;
|
||||
foreach ( $this->listViewDefs as $name => $field )
|
||||
{
|
||||
if (! isset ( $field [ 'usage' ] ) || $field [ 'usage' ] != 'query_only')
|
||||
{
|
||||
$existingFields [ $name ] = $field ;
|
||||
|
||||
} else
|
||||
{
|
||||
$newFields [ $name ] = $field ;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all of the fields defined in the 'Default' group of the ListView data in $_REQUEST
|
||||
// Replace the field specification in the originalListViewDef with this new updated specification
|
||||
foreach ( $_REQUEST [ 'group_0' ] as $field )
|
||||
{
|
||||
if (! empty ( $this->originalListViewDefs [ $field ] ))
|
||||
{
|
||||
$newFields [ $field ] = $this->originalListViewDefs [ $field ] ;
|
||||
} else
|
||||
{
|
||||
|
||||
$vname = '' ;
|
||||
if (isset ( $this->panel->template_instance->field_defs [ $field ] ))
|
||||
{
|
||||
$vname = $this->panel->template_instance->field_defs [ $field ] [ 'vname' ] ;
|
||||
}
|
||||
if (($this->subPanelParentModule != null) && (isset ( $this->subPanelParentModule->field_name_map [ $field ] ) && ($this->subPanelParentModule->field_name_map [ $field ] [ 'type' ] == 'bool' || (isset ( $this->subPanelParentModule->field_name_map [ $field ] [ 'custom_type' ] ) && $this->subPanelParentModule->field_name_map [ $field ] [ 'custom_type' ] == 'bool'))))
|
||||
{
|
||||
$newFields [ $field ] = array ( 'name' => $field , 'vname' => $vname , 'widget_type' => 'checkbox' ) ;
|
||||
} else
|
||||
{
|
||||
$newFields [ $field ] = array ( 'name' => $field , 'vname' => $vname ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Now set the field width if specified in the $_REQUEST data
|
||||
if (isset ( $_REQUEST [ strtolower ( $field ) . 'width' ] ))
|
||||
{
|
||||
$width = substr ( $_REQUEST [ strtolower ( $field ) . 'width' ], 6, 3 ) ;
|
||||
if (strpos ( $width, "%" ) != false)
|
||||
{
|
||||
$width = substr ( $width, 0, 2 ) ;
|
||||
}
|
||||
if ($width < 101 && $width > 0)
|
||||
{
|
||||
$newFields [ $field ] [ 'width' ] = $width ;
|
||||
}
|
||||
} else if (isset ( $this->listViewDefs [ $field ] [ 'width' ] ))
|
||||
{
|
||||
$newFields [ $field ] [ 'width' ] = $this->listViewDefs [ $field ] [ 'width' ] ;
|
||||
}
|
||||
}
|
||||
$subpanel->saveSubPanelDefOverride ( $this->panel, 'list_fields', $newFields ) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
658
modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php
Executable file
658
modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php
Executable file
@@ -0,0 +1,658 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
/*
|
||||
* A mechanism to dynamically define new Relationships between modules
|
||||
* This differs from the classes in modules/Relationships and data/Link in that they contain the implementation for pre-defined Relationships
|
||||
* Those classes use the metadata in the dictionary and layout definitions to implement the relationships; this class allows you to manage and manipulate that metadata
|
||||
*/
|
||||
class AbstractRelationship
|
||||
{
|
||||
|
||||
protected $definition ; // enough information to rebuild this relationship
|
||||
|
||||
|
||||
/*
|
||||
* These are the elements that fully define any Relationship
|
||||
* Any subclass of AbstractRelationship uses an array with a subset of the following keys as metadata to describe the Relationship it will implement
|
||||
* The base set of keys are those used in the Relationships table
|
||||
* Defined as Public as MBRelationship uses these to read the _POST data
|
||||
*/
|
||||
public static $definitionKeys = array (
|
||||
// atttributes of this relationship - here in the definition so they are preserved across saves and loads
|
||||
'for_activities',
|
||||
'is_custom',
|
||||
'from_studio',
|
||||
'readonly' , // a readonly relationship cannot be Built by subclasses of AbstractRelationships
|
||||
'deleted' , // a deleted relationship will not be built, and if it had been built previously the built relationship will be removed
|
||||
'relationship_only' , // means that we won't build any UI components for this relationship - required while the Subpanel code is restricted to one subpanel only from any module, and probably useful afterwards also for developers to build relationships for new code - it's a feature!
|
||||
// keys not found in Relationships table
|
||||
'label' , // optional
|
||||
'rhs_label', // optional
|
||||
'lhs_label', // optional
|
||||
'lhs_subpanel' , // subpanel FROM the lhs_module to display on the rhs_module detail view
|
||||
'rhs_subpanel' , // subpanel FROM the rhs_module to display on the lhs_module detail view
|
||||
// keys from Relationships table
|
||||
'relationship_name' ,
|
||||
'lhs_module' ,
|
||||
'lhs_table' ,
|
||||
'lhs_key' ,
|
||||
'rhs_module' ,
|
||||
'rhs_table' ,
|
||||
'rhs_key' ,
|
||||
'join_table' ,
|
||||
'join_key_lhs' ,
|
||||
'join_key_rhs' ,
|
||||
'relationship_type' ,
|
||||
'relationship_role_column' ,
|
||||
'relationship_role_column_value' ,
|
||||
'reverse' ) ;
|
||||
|
||||
/*
|
||||
* Relationship_role_column and relationship_role_column_value:
|
||||
* These two values define an additional condition on the relationship. If present, the value in relationship_role_column in the relationship table must equal relationship_role_column_value
|
||||
* Any update to the relationship made using a link field tied to the relationship (as is proper) will automatically (in Link.php) add in the relationship_role_column_value
|
||||
* The relationship table must of course contain a column with the name given in relationship_role_column
|
||||
*
|
||||
* relationship_role_column and relationship_role_column_value are here implemented in a slightly less optimized form than in the standard OOB application
|
||||
* In the OOB application, multiple relationships can, and do, share the same relationship table. Therefore, each variant of the relationship does not require its own table
|
||||
* Here for simplicity in implementation each relationship has its own unique table. Therefore, the relationship_role_column in these tables will only contain the value relationship_role_column_value
|
||||
* In the OOB relationships, the relationship_role_column will contain any of the relationship_role_column_values from the relationships that share the table
|
||||
* TODO: implement this optimization
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string $definition Definition array for this relationship. Parameters are given in self::keys
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
// set any undefined attributes to the default value
|
||||
foreach ( array ( 'readonly' , 'deleted' , 'relationship_only', 'for_activities', 'is_custom', 'from_studio' ) as $key )
|
||||
if (! isset ( $definition [ $key ] ))
|
||||
$definition [ $key ] = false ;
|
||||
|
||||
foreach ( self::$definitionKeys as $key )
|
||||
{
|
||||
$this->$key = isset ( $definition [ $key ] ) ? $definition [ $key ] : '' ;
|
||||
}
|
||||
$this->definition = $definition ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the unique name of this relationship
|
||||
* @return string The unique name (actually just that given to the constructor)
|
||||
*/
|
||||
public function getName ()
|
||||
{
|
||||
return isset ( $this->definition [ 'relationship_name' ] ) ? $this->definition [ 'relationship_name' ] : null ;
|
||||
}
|
||||
|
||||
public function setName ($relationshipName)
|
||||
{
|
||||
$this->relationship_name = $this->definition [ 'relationship_name' ] = $relationshipName ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this relationship readonly or not?
|
||||
* @return boolean True if cannot be changed; false otherwise
|
||||
*/
|
||||
public function readonly ()
|
||||
{
|
||||
return $this->definition [ 'readonly' ] ;
|
||||
}
|
||||
|
||||
public function setReadonly ()
|
||||
{
|
||||
$this->readonly = $this->definition [ 'readonly' ] = true ;
|
||||
}
|
||||
|
||||
public function setFromStudio ()
|
||||
{
|
||||
$this->from_studio = $this->definition [ 'from_studio' ] = true ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has this relationship been deleted? A deleted relationship does not get built, and is no longer visible in the list of relationships
|
||||
* @return boolean True if it has been deleted; false otherwise
|
||||
*/
|
||||
public function deleted ()
|
||||
{
|
||||
return $this->definition [ 'deleted' ] ;
|
||||
}
|
||||
|
||||
public function delete ()
|
||||
{
|
||||
$this->deleted = $this->definition [ 'deleted' ] = true ;
|
||||
}
|
||||
|
||||
|
||||
public function getType ()
|
||||
{
|
||||
return $this->relationship_type ;
|
||||
}
|
||||
|
||||
public function relationship_only ()
|
||||
{
|
||||
return $this->definition [ 'relationship_only' ] ;
|
||||
}
|
||||
|
||||
public function setRelationship_only ()
|
||||
{
|
||||
$this->relationship_only = $this->definition [ 'relationship_only' ] = true ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a complete description of this relationship, sufficient to pass back to a constructor to reestablish the relationship
|
||||
* Each subclass must provide enough information in $this->definition for its constructor
|
||||
* Used by UndeployedRelationships to save out a set of AbstractRelationship descriptions
|
||||
* The format is the same as the schema for the Relationships table for convenience, and is defined in self::keys. That is,
|
||||
* `relationship_name`, `lhs_module`, `lhs_table`, `lhs_key`, `rhs_module`, `rhs_table`,`rhs_key`, `join_table`, `join_key_lhs`, `join_key_rhs`, `relationship_type`, `relationship_role_column`, `relationship_role_column_value`, `reverse`,
|
||||
* @return array Set of parameters to pass to an AbstractRelationship constructor - must contain at least ['relationship_type']='OneToOne' or 'OneToMany' or 'ManyToMany'
|
||||
*/
|
||||
function getDefinition ()
|
||||
{
|
||||
return $this->definition ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define the labels to be added to the module for the new relationships
|
||||
* @return array An array of system value => display value
|
||||
*/
|
||||
function buildLabels ($update=false)
|
||||
{
|
||||
$labelDefinitions = array ( ) ;
|
||||
if (!$this->relationship_only)
|
||||
{
|
||||
if(!$this->is_custom && $update && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){
|
||||
include("modules/{$this->rhs_module}/metadata/subpaneldefs.php");
|
||||
if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){
|
||||
$rightSysLabel = $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'];
|
||||
}
|
||||
$layout_defs = array();
|
||||
}
|
||||
if(!$this->is_custom && $update && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){
|
||||
include("modules/{$this->lhs_module}/metadata/subpaneldefs.php");
|
||||
if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){
|
||||
$leftSysLabel = $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'];
|
||||
}
|
||||
$layout_defs = array();
|
||||
}
|
||||
$labelDefinitions [] = array (
|
||||
'module' => $this->rhs_module ,
|
||||
'system_label' => isset($rightSysLabel)?$rightSysLabel : 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ,
|
||||
'display_label' => ($update && !empty($_REQUEST [ 'lhs_label' ] ))?$_REQUEST [ 'lhs_label' ] :(empty($this->lhs_label) ? translate ( $this->lhs_module ) : $this->lhs_label),
|
||||
) ;
|
||||
$labelDefinitions [] = array (
|
||||
'module' => $this->lhs_module ,
|
||||
'system_label' => isset($leftSysLabel)?$leftSysLabel :'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ,
|
||||
'display_label' => ($update && !empty($_REQUEST [ 'rhs_label' ] ))?$_REQUEST [ 'rhs_label' ] :(empty($this->rhs_label) ? translate ( $this->rhs_module ) : $this->rhs_label),
|
||||
) ;
|
||||
}
|
||||
return $labelDefinitions ;
|
||||
}
|
||||
|
||||
function getLeftModuleSystemLabel()
|
||||
{
|
||||
if($this->lhs_module == $this->rhs_module){
|
||||
return $this->lhs_module.'_L';
|
||||
}
|
||||
return $this->lhs_module;
|
||||
}
|
||||
|
||||
function getRightModuleSystemLabel()
|
||||
{
|
||||
if($this->lhs_module == $this->rhs_module){
|
||||
return $this->rhs_module.'_R';
|
||||
}
|
||||
return $this->rhs_module;
|
||||
}
|
||||
|
||||
/*
|
||||
* GET methods called by the BUILD methods of the subclasses to construct the relationship metadata
|
||||
*/
|
||||
|
||||
/*
|
||||
* Build a description of a Subpanel that can be turned into an actual Subpanel by saveSubpanelDefinition in the implementation
|
||||
* Note that we assume that the subpanel name we are given is valid - that is, a subpanel definition by that name exists, and that a module won't have attempt to define multiple subpanels with the same name
|
||||
* Among the elements we construct is get_subpanel_data which is used as follows in SugarBean:
|
||||
* $related_field_name = $this_subpanel->get_data_source_name();
|
||||
* $parentbean->load_relationship($related_field_name);
|
||||
* ...where $related_field_name must be the name of a link field that references the Relationship used to obtain the subpanel data
|
||||
* @param string $sourceModule Name of the source module for this field
|
||||
* @param string $relationshipName Name of the relationship
|
||||
* @param string $subpanelName Name of the subpanel provided by the sourceModule
|
||||
* @param string $titleKeyName Name of the subpanel title , if none, we will use the module name as the subpanel title.
|
||||
*/
|
||||
protected function getSubpanelDefinition ($relationshipName , $sourceModule , $subpanelName, $titleKeyName = '', $source = "")
|
||||
{
|
||||
if (empty($source))
|
||||
$source = $relationshipName;
|
||||
$subpanelDefinition = array ( ) ;
|
||||
$subpanelDefinition [ 'order' ] = 100 ;
|
||||
$subpanelDefinition [ 'module' ] = $sourceModule ;
|
||||
$subpanelDefinition [ 'subpanel_name' ] = $subpanelName ;
|
||||
// following two lines are required for the subpanel pagination code in ListView.php->processUnionBeans() to correctly determine the relevant field for sorting
|
||||
$subpanelDefinition [ 'sort_order' ] = 'asc' ;
|
||||
$subpanelDefinition [ 'sort_by' ] = 'id' ;
|
||||
if(!empty($titleKeyName)){
|
||||
$subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $titleKeyName ) . '_TITLE' ;
|
||||
}else{
|
||||
$subpanelDefinition [ 'title_key' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ;
|
||||
}
|
||||
$subpanelDefinition [ 'get_subpanel_data' ] = $source ;
|
||||
$subpanelDefinition [ 'top_buttons' ] = array(
|
||||
array('widget_class' => "SubPanelTopButtonQuickCreate"),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect')
|
||||
);
|
||||
|
||||
return array ( $subpanelDefinition );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Construct a first link id field for the relationship for use in Views
|
||||
* It is used during the save from an edit view in SugarBean->save_relationship_changes(): for each relate field, $this->$linkfieldname->add( $this->$def['id_name'] )
|
||||
* @param string $sourceModule Name of the source module for this field
|
||||
* @param string $relationshipName Name of the relationship
|
||||
*/
|
||||
protected function getLinkFieldDefinition ($sourceModule , $relationshipName, $right_side = false, $vname = "")
|
||||
{
|
||||
$vardef = array ( ) ;
|
||||
|
||||
$vardef [ 'name' ] = $relationshipName ;
|
||||
$vardef [ 'type' ] = 'link' ;
|
||||
$vardef [ 'relationship' ] = $relationshipName ;
|
||||
$vardef [ 'source' ] = 'non-db' ;
|
||||
if ($right_side)
|
||||
$vardef [ 'side' ] = 'right' ;
|
||||
if (!empty($vname))
|
||||
$vardef [ 'vname' ] = $vname;
|
||||
|
||||
return $vardef ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a second link id field for the relationship for use in Views
|
||||
* It is used in two places:
|
||||
* - the editview.tpl for Relate fields requires that a field with the same name as the relate field's id_name exists
|
||||
* - it is loaded in SugarBean->fill_in_link_field while SugarBean processes the relate fields in fill_in_relationship_fields
|
||||
* @param string $sourceModule Name of the source module for this field
|
||||
* @param string $relationshipName Name of the relationship
|
||||
*/
|
||||
protected function getLink2FieldDefinition ($sourceModule , $relationshipName, $right_side = false, $vname = "")
|
||||
{
|
||||
$vardef = array ( ) ;
|
||||
|
||||
$vardef [ 'name' ] = $this->getIDName( $sourceModule ) ; // must match the id_name field value in the relate field definition
|
||||
$vardef [ 'type' ] = 'link' ;
|
||||
$vardef [ 'relationship' ] = $relationshipName ;
|
||||
$vardef [ 'source' ] = 'non-db' ;
|
||||
$vardef ['reportable'] = false;
|
||||
if ($right_side)
|
||||
$vardef [ 'side' ] = 'right' ;
|
||||
else
|
||||
$vardef [ 'side' ] = 'left' ;
|
||||
if (!empty($vname))
|
||||
$vardef [ 'vname' ] = $vname;
|
||||
|
||||
return $vardef ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a relate field for the vardefs
|
||||
* The relate field is the element that is shown in the UI
|
||||
* @param string $sourceModule Name of the source module for this field
|
||||
* @param string $relationshipName Name of the relationship
|
||||
* @param string $moduleType Optional - "Types" of the module - array of SugarObject types such as "file" or "basic"
|
||||
*/
|
||||
protected function getRelateFieldDefinition ($sourceModule , $relationshipName , $vnameLabel='')
|
||||
{
|
||||
$vardef = array ( ) ;
|
||||
$vardef [ 'name' ] = $relationshipName . "_name" ; // must end in _name for the QuickSearch code in TemplateHandler->createQuickSearchCode
|
||||
$vardef [ 'type' ] = 'relate' ;
|
||||
|
||||
$vardef [ 'source' ] = 'non-db' ;
|
||||
if(!empty($vnameLabel)){
|
||||
$vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $vnameLabel ) . '_TITLE' ;
|
||||
}else{
|
||||
$vardef [ 'vname' ] = 'LBL_' . strtoupper ( $relationshipName . '_FROM_' . $sourceModule ) . '_TITLE' ;
|
||||
}
|
||||
|
||||
$vardef [ 'save' ] = true; // the magic value to tell SugarBean to save this relate field even though it is not listed in the $relationship_fields array
|
||||
|
||||
// id_name matches the join_key_ column in the relationship table for the sourceModule - that is, the column in the relationship table containing the id of the corresponding field in the source module's table (vardef['table'])
|
||||
$vardef [ 'id_name' ] = $this->getIDName( $sourceModule ) ;
|
||||
|
||||
// link cannot match id_name otherwise the $bean->$id_name value set from the POST is overwritten by the Link object created by this 'link' entry
|
||||
$vardef [ 'link' ] = $relationshipName ; // the name of the link field that points to the relationship - required for the save to function
|
||||
$vardef [ 'table' ] = $this->getTablename( $sourceModule ) ;
|
||||
$vardef [ 'module' ] = $sourceModule ;
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
$parsedModuleName = AbstractRelationships::parseDeployedModuleName( $sourceModule ) ;
|
||||
|
||||
// now determine the appropriate 'rname' field for this relate
|
||||
// the 'rname' points to the field in source module that contains the displayable name for the record
|
||||
// usually this is 'name' but sometimes it is not...
|
||||
|
||||
$vardef [ 'rname' ] = 'name' ;
|
||||
if ( isset( $parsedModuleName['packageName'] ) )
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = $mb->getPackageModule ( $parsedModuleName['packageName'] , $parsedModuleName['moduleName'] ) ;
|
||||
if (in_array( 'file' , array_keys ( $module->config [ 'templates' ] ) ) )
|
||||
$vardef [ 'rname' ] = 'document_name' ;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( strtolower( $sourceModule ) )
|
||||
{
|
||||
case 'prospects' :
|
||||
$vardef [ 'rname' ] = 'account_name' ;
|
||||
break ;
|
||||
case 'documents' :
|
||||
$vardef [ 'rname' ] = 'document_name' ;
|
||||
break ;
|
||||
case 'kbdocuments' :
|
||||
$vardef [ 'rname' ] = 'kbdocument_name' ;
|
||||
break ;
|
||||
case 'leads' :
|
||||
case 'contacts' :
|
||||
// special handling as these modules lack a name column in the database; instead 'name' refers to a non-db field that concatenates first_name and last_name
|
||||
// luckily, the relate field mechanism can handle this with an equivalent additional db_concat_fields entry
|
||||
$vardef [ 'rname' ] = 'name' ;
|
||||
$vardef [ 'db_concat_fields' ] = array( 0 =>'first_name', 1 =>'last_name') ;
|
||||
break ;
|
||||
default :
|
||||
// now see if we have any module inheriting from the 'file' template - records in file-type modules are named by the document_name field, not the usual 'name' field
|
||||
$object = $GLOBALS ['beanList'] [ $sourceModule ];
|
||||
require_once ( $GLOBALS ['beanFiles'] [ $object ] );
|
||||
$bean = new $object();
|
||||
if ( isset ( $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] ) && in_array ( 'file' , $GLOBALS [ 'dictionary' ] [ $object ] [ 'templates'] ) )
|
||||
$vardef [ 'rname' ] = 'document_name' ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $vardef ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct the contents of the Relationships MetaData entry in the dictionary for a generic relationship
|
||||
* The entry we build will have three sections:
|
||||
* 1. relationships: the relationship definition
|
||||
* 2. table: name of the join table for this many-to-many relationship
|
||||
* 3. fields: fields within the join table
|
||||
* 4. indicies: indicies on the join table
|
||||
* @param string $relationshipType Cardinality of the relationship, for example, MB_ONETOONE or MB_ONETOMANY or MB_MANYTOMANY
|
||||
*/
|
||||
function getRelationshipMetaData ($relationshipType)
|
||||
{
|
||||
$relationshipName = $this->definition [ 'relationship_name' ] ;
|
||||
$lhs_module = $this->lhs_module ;
|
||||
$rhs_module = $this->rhs_module ;
|
||||
|
||||
$lhs_table = $this->getTablename ( $lhs_module ) ;
|
||||
$rhs_table = $this->getTablename ( $rhs_module ) ;
|
||||
|
||||
$properties = array ( ) ;
|
||||
|
||||
// first define section 1, the relationship element of the metadata entry
|
||||
|
||||
$rel_properties = array ( ) ;
|
||||
$rel_properties [ 'lhs_module' ] = $lhs_module ;
|
||||
$rel_properties [ 'lhs_table' ] = $lhs_table ;
|
||||
$rel_properties [ 'lhs_key' ] = 'id' ;
|
||||
$rel_properties [ 'rhs_module' ] = $rhs_module ;
|
||||
$rel_properties [ 'rhs_table' ] = $rhs_table ;
|
||||
$rel_properties [ 'rhs_key' ] = 'id' ;
|
||||
|
||||
// because the implementation of one-to-many relationships within SugarBean does not use a join table and so requires schema changes to add a foreign key for each new relationship,
|
||||
// we currently implement all new relationships as many-to-many regardless of the real type and enforce cardinality through the relate fields and subpanels
|
||||
$rel_properties [ 'relationship_type' ] = MB_MANYTOMANY ;
|
||||
// but as we need to display the true cardinality in Studio and ModuleBuilder we also record the actual relationship type
|
||||
// this property is only used by Studio/MB
|
||||
$properties [ 'true_relationship_type' ] = $relationshipType ;
|
||||
if ($this->from_studio)
|
||||
$properties [ 'from_studio' ] = true;
|
||||
|
||||
$rel_properties [ 'join_table' ] = $this->getValidDBName ( $relationshipName."_c" ) ;
|
||||
// a and b are in case the module relates to itself
|
||||
$rel_properties [ 'join_key_lhs' ] = $this->getJoinKeyLHS() ;
|
||||
$rel_properties [ 'join_key_rhs' ] = $this->getJoinKeyRHS() ;
|
||||
|
||||
// set the extended properties if they exist = for now, many-to-many definitions do not have to contain a role_column even if role_column_value is set; we'll just create a likely name if missing
|
||||
if (isset ( $this->definition [ 'relationship_role_column_value' ] ))
|
||||
{
|
||||
if (! isset ( $this->definition [ 'relationship_role_column' ] ))
|
||||
$this->definition [ 'relationship_role_column' ] = 'relationship_role_column' ;
|
||||
$rel_properties [ 'relationship_role_column' ] = $this->definition [ 'relationship_role_column' ] ;
|
||||
$rel_properties [ 'relationship_role_column_value' ] = $this->definition [ 'relationship_role_column_value' ] ;
|
||||
}
|
||||
|
||||
$properties [ 'relationships' ] [ $relationshipName ] = $rel_properties ;
|
||||
|
||||
// construct section 2, the name of the join table
|
||||
|
||||
$properties [ 'table' ] = $rel_properties [ 'join_table' ] ;
|
||||
|
||||
// now construct section 3, the fields in the join table
|
||||
|
||||
$properties [ 'fields' ] [] = array ( 'name' => 'id' , 'type' => 'varchar' , 'len' => 36 ) ;
|
||||
$properties [ 'fields' ] [] = array ( 'name' => 'date_modified' , 'type' => 'datetime' ) ;
|
||||
$properties [ 'fields' ] [] = array ( 'name' => 'deleted' , 'type' => 'bool' , 'len' => '1' , 'default' => '0' , 'required' => true ) ;
|
||||
$properties [ 'fields' ] [] = array ( 'name' => $rel_properties [ 'join_key_lhs' ] , 'type' => 'varchar' , 'len' => 36 ) ;
|
||||
$properties [ 'fields' ] [] = array ( 'name' => $rel_properties [ 'join_key_rhs' ] , 'type' => 'varchar' , 'len' => 36 ) ;
|
||||
if (strtolower ( $lhs_module ) == 'documents' || strtolower ( $rhs_module ) == 'documents' )
|
||||
{
|
||||
$properties [ 'fields' ] [] = array ( 'name' => 'document_revision_id' , 'type' => 'varchar' , 'len' => '36' ) ;
|
||||
}
|
||||
// if we have an extended relationship condition, then add in the corresponding relationship_role_column to the relationship (join) table
|
||||
// for now this is restricted to extended relationships that can be specified by a varchar
|
||||
if (isset ( $this->definition [ 'relationship_role_column_value' ] ))
|
||||
{
|
||||
$properties [ 'fields' ] [] = array ( 'name' => $this->definition [ 'relationship_role_column' ] , 'type' => 'varchar' ) ;
|
||||
}
|
||||
|
||||
// finally, wrap up with section 4, the indices on the join table
|
||||
|
||||
$indexBase = $this->getValidDBName ( $relationshipName ) ;
|
||||
$properties [ 'indices' ] [] = array ( 'name' => $indexBase . 'spk' , 'type' => 'primary' , 'fields' => array ( 'id' ) ) ;
|
||||
|
||||
switch ($relationshipType)
|
||||
{
|
||||
case MB_ONETOONE:
|
||||
$alternateKeys = array () ;
|
||||
$properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_ida1' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_lhs' ] ) ) ;
|
||||
$properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_idb2' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_rhs' ] ) ) ;
|
||||
break;
|
||||
case MB_ONETOMANY :
|
||||
$alternateKeys = array ( $rel_properties [ 'join_key_rhs' ] ) ;
|
||||
$properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_ida1' , 'type' => 'index' , 'fields' => array ( $rel_properties [ 'join_key_lhs' ] ) ) ;
|
||||
break;
|
||||
default:
|
||||
$alternateKeys = array ( $rel_properties [ 'join_key_lhs' ] , $rel_properties [ 'join_key_rhs' ] ) ;
|
||||
}
|
||||
|
||||
if (count($alternateKeys)>0)
|
||||
$properties [ 'indices' ] [] = array ( 'name' => $indexBase . '_alt' , 'type' => 'alternate_key' , 'fields' => $alternateKeys ) ; // type must be set to alternate_key for Link.php to correctly update an existing record rather than inserting a copy - it uses the fields in this array as the keys to check if a duplicate record already exists
|
||||
|
||||
return $properties ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* UTILITY methods
|
||||
*/
|
||||
|
||||
/*
|
||||
* Method to build a name for a relationship between a module and an Activities submodule
|
||||
* Used primarily in UndeployedRelationships to ensure that the subpanels we construct for Activities get their data from the correct relationships
|
||||
* @param string $activitiesSubModuleName Name of the activities submodule, such as Tasks
|
||||
*/
|
||||
function getActivitiesSubModuleRelationshipName ( $activitiesSubModuleName )
|
||||
{
|
||||
return $this->lhs_module . "_" . strtolower ( $activitiesSubModuleName ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a version of $proposed that can be used as a column name in any of our supported databases
|
||||
* Practically this means no longer than 25 characters as the smallest identifier length for our supported DBs is 30 chars for Oracle plus we add on at least four characters in some places (for indicies for example)
|
||||
* TODO: Ideally this should reside in DBHelper as it is such a common db function...
|
||||
* @param string $name Proposed name for the column
|
||||
* @param string $ensureUnique
|
||||
* @return string Valid column name trimmed to right length and with invalid characters removed
|
||||
*/
|
||||
static function getValidDBName ($name, $ensureUnique = false)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
// first strip any invalid characters - all but alphanumerics and -
|
||||
$name = preg_replace ( '/[^\w-]+/i', '', $name ) ;
|
||||
$len = strlen ( $name ) ;
|
||||
$result = $name;
|
||||
if ($ensureUnique)
|
||||
{
|
||||
$md5str = md5($name);
|
||||
$tail = substr ( $name, -11) ;
|
||||
$temp = substr($md5str , strlen($md5str)-4 );
|
||||
$result = substr ( $name, 0, 10) . $temp . $tail ;
|
||||
}else if ($len > (MB_MAXDBIDENTIFIERLENGTH - 5))
|
||||
{
|
||||
$result = substr ( $name, 0, 11) . substr ( $name, 11 - MB_MAXDBIDENTIFIERLENGTH + 5);
|
||||
}
|
||||
return strtolower ( $result ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tidy up any provided relationship type - convert all the variants of a name to the canonical type - for example, One To Many = MB_ONETOMANY
|
||||
* @param string $type Relationship type
|
||||
* @return string Canonical type
|
||||
*/
|
||||
static function parseRelationshipType ($type)
|
||||
{
|
||||
$type = strtolower ( $type ) ;
|
||||
$type = preg_replace ( '/[^\w]+/i', '', strtolower ( $type ) ) ;
|
||||
$canonicalTypes = array ( ) ;
|
||||
foreach ( array ( MB_ONETOONE , MB_ONETOMANY , MB_MANYTOMANY , MB_MANYTOONE) as $canonicalType )
|
||||
{
|
||||
if ($type == preg_replace ( '/[^\w]+/i', '', strtolower ( $canonicalType ) ))
|
||||
return $canonicalType ;
|
||||
}
|
||||
// ok, we give up...
|
||||
return MB_MANYTOMANY ;
|
||||
}
|
||||
|
||||
|
||||
function getJoinKeyLHS()
|
||||
{
|
||||
if (!isset($this->joinKeyLHS))
|
||||
$this->joinKeyLHS = $this->getValidDBName ( $this->relationship_name . $this->lhs_module . "_ida" , true) ;
|
||||
|
||||
return $this->joinKeyLHS;
|
||||
}
|
||||
|
||||
function getJoinKeyRHS()
|
||||
{
|
||||
if (!isset($this->joinKeyRHS))
|
||||
$this->joinKeyRHS = $this->getValidDBName ( $this->relationship_name . $this->rhs_module . "_idb" , true) ;
|
||||
|
||||
return $this->joinKeyRHS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of the ID field that will be used to link the subpanel, the link field and the relationship metadata
|
||||
* @param string $sourceModule The name of the primary module in the relationship
|
||||
* @return string Name of the id field
|
||||
*/
|
||||
function getIDName( $sourceModule )
|
||||
{
|
||||
return ($sourceModule == $this->lhs_module ) ? $this->getJoinKeyLHS() : $this->getJoinKeyRHS() ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of a module's standard (non-cstm) table in the database
|
||||
* @param string $moduleName Name of the module for which we are to find the table
|
||||
* @return string Tablename
|
||||
*/
|
||||
protected function getTablename ($moduleName)
|
||||
{
|
||||
// Check the moduleName exists in the beanList before calling get_module_info - Activities is the main culprit here
|
||||
if (isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] ))
|
||||
{
|
||||
$module = get_module_info ( $moduleName ) ;
|
||||
return $module->table_name ;
|
||||
}
|
||||
return strtolower ( $moduleName ) ;
|
||||
}
|
||||
|
||||
public function getTitleKey($left=false){
|
||||
if(!$this->is_custom && !$left && file_exists("modules/{$this->rhs_module}/metadata/subpaneldefs.php")){
|
||||
include("modules/{$this->rhs_module}/metadata/subpaneldefs.php");
|
||||
if(isset($layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'])){
|
||||
return $layout_defs[$this->rhs_module]['subpanel_setup'][strtolower($this->lhs_module)]['title_key'];
|
||||
}
|
||||
}else if(!$this->is_custom && file_exists("modules/{$this->lhs_module}/metadata/subpaneldefs.php")){
|
||||
include("modules/{$this->lhs_module}/metadata/subpaneldefs.php");
|
||||
if(isset($layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'])){
|
||||
return $layout_defs[$this->lhs_module]['subpanel_setup'][strtolower($this->rhs_module)]['title_key'];
|
||||
}
|
||||
}
|
||||
|
||||
if($left){
|
||||
$titleKeyName = $this->getRightModuleSystemLabel();
|
||||
$sourceModule = $this->rhs_module;
|
||||
}else{
|
||||
$titleKeyName = $this->getLeftModuleSystemLabel();
|
||||
$sourceModule = $this->lhs_module;
|
||||
}
|
||||
|
||||
if(!empty($titleKeyName)){
|
||||
$title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $titleKeyName ) . '_TITLE' ;
|
||||
}else{
|
||||
$title_key = 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $sourceModule ) . '_TITLE' ;
|
||||
}
|
||||
|
||||
return $title_key;
|
||||
}
|
||||
}
|
||||
556
modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php
Executable file
556
modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php
Executable file
@@ -0,0 +1,556 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
/*
|
||||
* Abstract class for managing a set of Relationships
|
||||
* The Relationships we're managing consist of metadata about relationships, rather than relationship implementations used by the application
|
||||
* Relationships defined here are implemented by the build() method to become a relationship that the application can use
|
||||
* Note that the modules/Relationships/Relationship.php contains some methods that look similar; remember though that the methods in that file are acting on implemented relationships, not the metadata that we deal with here
|
||||
*/
|
||||
class AbstractRelationships
|
||||
{
|
||||
|
||||
static $methods = array ( 'Labels' => 'language' , 'RelationshipMetaData' => 'relationships' , 'SubpanelDefinitions' => 'layoutdefs' , 'Vardefs' => 'vardefs' , 'FieldsToLayouts' => 'layoutfields' ) ;
|
||||
static $activities = array ( 'calls' => 'Calls' , 'meetings' => 'Meetings' , 'notes' => 'Notes' , 'tasks' => 'Tasks' , 'emails' => 'Emails' ) ;
|
||||
|
||||
protected $relationships = array ( ) ; // array containing all the AbstractRelationship objects that are in this set of relationships
|
||||
protected $moduleName ;
|
||||
|
||||
/*
|
||||
* Find all deployed modules that can participate in a relationship
|
||||
* Return a list of modules with associated subpanels
|
||||
* @param boolean $includeActivitiesSubmodules True if the list should include Calls, Meetings etc; false if they should be replaced by the parent, Activities
|
||||
* @return array Array of [$module][$subpanel]
|
||||
*/
|
||||
static function findRelatableModules ($includeActivitiesSubmodules = true)
|
||||
{
|
||||
$relatableModules = array ( ) ;
|
||||
|
||||
// add in activities automatically if required
|
||||
$relatableModules [ 'Activities' ] [ 'default' ] = translate( 'LBL_DEFAULT' ) ;
|
||||
|
||||
// find all deployed modules
|
||||
require_once 'modules/ModuleBuilder/Module/StudioBrowser.php' ;
|
||||
$browser = new StudioBrowser() ;
|
||||
$browser->loadRelatableModules();
|
||||
reset($browser->modules) ;
|
||||
|
||||
while ( list( $moduleName , $module ) = each($browser->modules) )
|
||||
{
|
||||
// do not include the submodules of Activities as already have the parent...
|
||||
if (! $includeActivitiesSubmodules && in_array ( $module->module, self::$activities ))
|
||||
continue ;
|
||||
|
||||
$relatableModules [ $module->module ] = $module->getProvidedSubpanels() ;
|
||||
}
|
||||
|
||||
return $relatableModules ;
|
||||
|
||||
}
|
||||
|
||||
static function validSubpanel ($filename)
|
||||
{
|
||||
if (! file_exists ( $filename ))
|
||||
return false ;
|
||||
|
||||
include $filename ;
|
||||
return (isset ( $subpanel_layout ) && (isset ( $subpanel_layout [ 'top_buttons' ] ) && isset ( $subpanel_layout [ 'list_fields' ] ))) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a list of all relationships (which have not been deleted)
|
||||
* @return array Array of relationship names, ready for use in get()
|
||||
*/
|
||||
function getRelationshipList ()
|
||||
{
|
||||
$list = array ( ) ;
|
||||
foreach ( $this->relationships as $name => $relationship )
|
||||
{
|
||||
if (! $relationship->deleted ())
|
||||
$list [ $name ] = $name ;
|
||||
}
|
||||
return $list ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a relationship by name
|
||||
* @param string $relationshipName The unique name for this relationship, as returned by $relationship->getName()
|
||||
* @return AbstractRelationship or false if $relationshipName is not in this set of relationships
|
||||
*/
|
||||
function get ($relationshipName)
|
||||
{
|
||||
if (isset ( $this->relationships [ $relationshipName ] ))
|
||||
{
|
||||
return $this->relationships [ $relationshipName ] ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a relationship from the information in the $_REQUEST array
|
||||
* If a relationship_name is provided, and that relationship is not read only, then modify the existing relationship, overriding the definition with any AbstractRelationship::$definitionkeys entries set in the $_REQUEST
|
||||
* Otherwise, create and add a new relationship with the information in the $_REQUEST
|
||||
* @return AbstractRelationship
|
||||
*/
|
||||
function addFromPost ()
|
||||
{
|
||||
$definition = array ( ) ;
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
foreach ( AbstractRelationship::$definitionKeys as $key )
|
||||
{
|
||||
if (! empty ( $_REQUEST [ $key ] ))
|
||||
{
|
||||
$definition [ $key ] = ($key == 'relationship_type') ? AbstractRelationship::parseRelationshipType ( $_REQUEST [ $key ] ) : $_REQUEST [ $key ] ;
|
||||
}
|
||||
}
|
||||
|
||||
// if this is a change to an existing relationship, and it is not readonly, then delete the old one
|
||||
if (! empty ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
if ($relationship = $this->get ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
unset( $definition[ 'relationship_name' ] ) ; // in case the related modules have changed; this name is probably no longer appropriate
|
||||
if (! $relationship->readonly ())
|
||||
$this->delete ( $_REQUEST [ 'relationship_name' ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
$newRelationship = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
// TODO: error handling in case we get a badly formed definition and hence relationship
|
||||
$this->add ( $newRelationship ) ;
|
||||
return $newRelationship ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a relationship to the set
|
||||
* @param AbstractRelationship $relationship The relationship to add
|
||||
*/
|
||||
function add ($relationship)
|
||||
{
|
||||
$name = $this->getUniqueName ( $relationship ) ;
|
||||
$relationship->setName ( $name ) ;
|
||||
$this->relationships [ $name ] = $relationship ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a set of relationships from a file
|
||||
* The saved relationships are stored as AbstractRelationship objects, which isn't the same as the old MBRelationships definition
|
||||
* @param string $basepath Base directory in which to store the relationships information
|
||||
* @return Array of AbstractRelationship objects
|
||||
*/
|
||||
protected function _load ($basepath)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": loading relationships from " . $basepath . '/relationships.php' ) ;
|
||||
$objects = array ( ) ;
|
||||
if (file_exists ( $basepath . '/relationships.php' ))
|
||||
{
|
||||
include ($basepath . '/relationships.php') ;
|
||||
foreach ( $relationships as $name => $definition )
|
||||
{
|
||||
// update any pre-5.1 relationships to the new definitions
|
||||
// we do this here, rather than when upgrading from 5.0 to 5.1, as modules exported from MB in 5.0 may be loaded into 5.1 at any time
|
||||
// note also that since these definitions are only found in the relationships.php working file they only occur for deployed or exported modules, not published then loaded modules
|
||||
$definition = $this->_updateRelationshipDefinition( $definition ) ;
|
||||
$relationship = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
// make sure it has a unique name
|
||||
if (! isset( $definition [ 'relationship_name' ] ) )
|
||||
{
|
||||
$name = $this->getUniqueName ( $relationship ) ;
|
||||
$relationship->setName ( $name ) ;
|
||||
}
|
||||
$objects [ $name ] = $relationship ;
|
||||
}
|
||||
}
|
||||
return $objects ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the set of relationships to a file
|
||||
* @param string $basepath Base directory in which to store the relationships information
|
||||
*/
|
||||
protected function _save ($relationships , $basepath)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": saving relationships to " . $basepath . '/relationships.php' ) ;
|
||||
$header = file_get_contents ( 'modules/ModuleBuilder/MB/header.php' ) ;
|
||||
|
||||
$definitions = array ( ) ;
|
||||
|
||||
foreach ( $relationships as $relationship )
|
||||
{
|
||||
// if (! $relationship->readonly ())
|
||||
$definitions [ $relationship->getName () ] = $relationship->getDefinition () ;
|
||||
}
|
||||
|
||||
mkdir_recursive ( $basepath ) ;
|
||||
// replace any existing relationships.php
|
||||
write_array_to_file ( 'relationships', $definitions, $basepath . '/relationships.php', 'w', $header ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return all known deployed relationships
|
||||
* All are set to read-only - the assumption for now is that we can't directly modify a deployed relationship
|
||||
* However, if it was created through this AbstractRelationships class a modifiable version will be held in the relationships working file,
|
||||
* and that one will override the readonly version in load()
|
||||
*
|
||||
* TODO: currently we ignore the value of the 'reverse' field in the relationships definition. This is safe to do as only one
|
||||
* relationship (products-products) uses it (and there it makes no difference from our POV) and we don't use it when creating new ones
|
||||
* @return array Array of $relationshipName => $relationshipDefinition as an array
|
||||
*/
|
||||
protected function getDeployedRelationships ()
|
||||
{
|
||||
|
||||
$db = DBManagerFactory::getInstance () ;
|
||||
$query = "SELECT * FROM relationships WHERE deleted = 0" ;
|
||||
$result = $db->query ( $query ) ;
|
||||
while ( $row = $db->fetchByAssoc ( $result ) )
|
||||
{
|
||||
// set this relationship to readonly
|
||||
$row [ 'readonly' ] = true ;
|
||||
$relationships [ $row [ 'relationship_name' ] ] = $row ;
|
||||
}
|
||||
|
||||
return $relationships ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a name for this relationship that is unique across all of the relationships we are aware of
|
||||
* We make the name unique by simply adding on a suffix until we achieve uniqueness
|
||||
* @param AbstractRelationship The relationship object
|
||||
* @return string A globally unique relationship name
|
||||
*/
|
||||
protected function getUniqueName ($relationship)
|
||||
{
|
||||
$allRelationships = $this->getRelationshipList () ;
|
||||
$basename = $relationship->getName () ;
|
||||
|
||||
if (empty ( $basename ))
|
||||
{
|
||||
// start off with the proposed name being simply lhs_module_rhs_module
|
||||
$definition = $relationship->getDefinition () ;
|
||||
$basename = strtolower ( $definition [ 'lhs_module' ] . '_' . $definition [ 'rhs_module' ] ) ;
|
||||
}
|
||||
|
||||
$name = $basename ;
|
||||
$suffix = 1 ;
|
||||
while ( isset ( $allRelationships [ $name ] ) )
|
||||
{
|
||||
$name = $basename . "_" . ( string ) ($suffix ++) ;
|
||||
}
|
||||
return $name ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate the set of relationship objects into files that the Module Loader can work with
|
||||
* @param string $basepath Pathname of the directory to contain the build
|
||||
* @param string $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param array $relationships Relationships to implement
|
||||
*/
|
||||
protected function build ($basepath , $installDefPrefix , $relationships )
|
||||
{
|
||||
global $sugar_config;
|
||||
// keep the relationships data separate from any other build data by ading /relationships to the basepath
|
||||
$basepath .= '/relationships' ;
|
||||
|
||||
$installDefs = array ( ) ;
|
||||
$compositeAdded = false ;
|
||||
foreach ( self::$methods as $method => $key )
|
||||
{
|
||||
$buildMethod = 'build' . $method ;
|
||||
$saveMethod = 'save' . $method ;
|
||||
|
||||
foreach ( $relationships as $name => $relationship )
|
||||
{
|
||||
if (! ($relationship->readonly () || $relationship->deleted ()))
|
||||
{
|
||||
if (method_exists ( $relationship, $buildMethod ) && method_exists ( $this, $saveMethod ))
|
||||
{
|
||||
$metadata = $relationship->$buildMethod () ;
|
||||
|
||||
if (count ( $metadata ) > 0) // don't clutter up the filesystem with empty files...
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": BUILD is running METHOD $saveMethod" ) ;
|
||||
$installDef = $this->$saveMethod ( $basepath, $installDefPrefix, $name, $metadata ) ;
|
||||
|
||||
// some save methods (e.g., saveRelateFieldDefinition) handle the installDefs internally and so return null
|
||||
|
||||
|
||||
if (! is_null ( $installDef ))
|
||||
{
|
||||
foreach ( $installDef as $moduleName => $def )
|
||||
{
|
||||
$installDefs [ $key ] [ ] = $def ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $installDefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* SAVE methods called during the build to translate the metadata provided by each relationship into files for the module installer
|
||||
* Note that the installer expects only one file for each module in each section of the manifest - multiple files result in only the last one being implemented!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Add a set of labels to the module
|
||||
* @param string $basepath Basepath location for this module
|
||||
* @param $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param string $relationshipName Name of this relationship (for uniqueness)
|
||||
* @param array $labelDefinitions Array of System label => Display label pairs
|
||||
* @return null Nothing to be added to the installdefs for an undeployed module
|
||||
*/
|
||||
protected function saveLabels ($basepath , $installDefPrefix , $relationshipName , $labelDefinitions)
|
||||
{
|
||||
global $sugar_config;
|
||||
|
||||
mkdir_recursive ( "$basepath/language" ) ;
|
||||
|
||||
$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n" ;
|
||||
$installDefs = array ( ) ;
|
||||
foreach ( $labelDefinitions as $definition )
|
||||
{
|
||||
$mod_strings = array();
|
||||
$app_list_strings = array();
|
||||
|
||||
$out = $headerString;
|
||||
|
||||
$filename = "{$basepath}/language/{$definition['module']}.php" ;
|
||||
|
||||
if (file_exists ( $filename ))
|
||||
include ($filename);
|
||||
|
||||
|
||||
//Check for app strings
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveLabels(): saving the following to {$filename}"
|
||||
. print_r ( $definition, true ) ) ;
|
||||
if ($definition['module'] == 'application') {
|
||||
$app_list_strings[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
|
||||
foreach ($app_list_strings as $key => $val)
|
||||
$out .= override_value_to_string_recursive2('app_list_strings', $key, $val);
|
||||
} else {
|
||||
$mod_strings[ $definition [ 'system_label' ]] = $definition [ 'display_label' ];
|
||||
foreach ($mod_strings as $key => $val)
|
||||
$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
|
||||
}
|
||||
|
||||
$fh = fopen ( $filename, 'w' ) ;
|
||||
fputs ( $fh, $out, strlen ( $out ) ) ;
|
||||
fclose ( $fh ) ;
|
||||
|
||||
|
||||
foreach($sugar_config['languages'] as $lk => $lv)
|
||||
{
|
||||
$installDefs [ $definition [ 'module' ] . "_$lk" ] = array (
|
||||
'from' => "{$installDefPrefix}/relationships/language/{$definition [ 'module' ]}.php" ,
|
||||
'to_module' => $definition [ 'module' ] ,
|
||||
'language' => $lk
|
||||
) ;
|
||||
}
|
||||
|
||||
/* do not use the following write_array_to_file method to write the label file -
|
||||
* module installer appends each of the label files together (as it does for all files)
|
||||
* into a combined label file and so the last $mod_strings is the only one received by the application */
|
||||
// write_array_to_file ( 'mod_strings', array ( $definition [ 'system_label' ] => $definition [ 'display_label' ] ), $filename, "a" ) ;
|
||||
}
|
||||
|
||||
return $installDefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate a set of relationship metadata definitions into files for the Module Loader
|
||||
* @param string $basepath Basepath location for this module
|
||||
* @param $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param string $relationshipName Name of this relationship (for uniqueness)
|
||||
* @param array $relationshipMetaData Set of metadata definitions in the form $relationshipMetaData[$relationshipName]
|
||||
* @return array $installDefs Set of new installDefs
|
||||
*/
|
||||
protected function saveRelationshipMetaData ($basepath , $installDefPrefix , $relationshipName , $relationshipMetaData)
|
||||
{
|
||||
mkdir_recursive ( "$basepath/relationships" ) ;
|
||||
|
||||
$installDefs = array ( ) ;
|
||||
list ( $rhs_module, $properties ) = each ( $relationshipMetaData ) ;
|
||||
$filename = "$basepath/relationships/{$relationshipName}MetaData.php" ;
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveRelationshipMetaData(): saving the following to {$filename}" . print_r ( $properties, true ) ) ;
|
||||
write_array_to_file ( 'dictionary["' . $relationshipName . '"]', $properties, "{$filename}", 'w' ) ;
|
||||
$installDefs [ $relationshipName ] = array ( /*'module' => $rhs_module , 'module_vardefs' => "<basepath>/Vardefs/{$relationshipName}.php" ,*/ 'meta_data' => "{$installDefPrefix}/relationships/relationships/{$relationshipName}MetaData.php" ) ;
|
||||
|
||||
return $installDefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate a set of subpanelDefinitions into files for the Module Loader
|
||||
* @param string $basepath Basepath location for this module
|
||||
* @param $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param array $subpanelDefinitions Set of subpanel definitions in the form $subpanelDefinitions[$for_module][]
|
||||
* @return array $installDefs Set of new installDefs
|
||||
*/
|
||||
protected function saveSubpanelDefinitions ($basepath , $installDefPrefix , $relationshipName , $subpanelDefinitions)
|
||||
{
|
||||
mkdir_recursive ( "$basepath/layoutdefs/" ) ;
|
||||
|
||||
foreach ( $subpanelDefinitions as $moduleName => $definitions )
|
||||
{
|
||||
$filename = "$basepath/layoutdefs/{$relationshipName}_{$moduleName}.php" ;
|
||||
$out = "<?php\n// created: " . date('Y-m-d H:i:s') . "\n";
|
||||
foreach ( $definitions as $definition )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveSubpanelDefinitions(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
|
||||
if (empty($definition ['get_subpanel_data']) || $definition ['subpanel_name'] == 'history' || $definition ['subpanel_name'] == 'activities') {
|
||||
$definition ['get_subpanel_data'] = $definition ['subpanel_name'];
|
||||
}
|
||||
$out .= '$layout_defs["' . $moduleName . '"]["subpanel_setup"]["' . $definition ['get_subpanel_data'] . '"] = '
|
||||
. var_export_helper($definition) . ";\n";
|
||||
}
|
||||
file_put_contents($filename, $out);
|
||||
$installDefs [ $moduleName ] = array ( 'from' => "{$installDefPrefix}/relationships/layoutdefs/{$relationshipName}_{$moduleName}.php" , 'to_module' => $moduleName ) ;
|
||||
}
|
||||
return $installDefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate a set of linkFieldDefinitions into files for the Module Loader
|
||||
* Note that the Module Loader will only accept one entry in the vardef section of the Manifest for each module
|
||||
* This means that we cannot simply build a file for each relationship as relationships that involve the same module will end up overwriting each other when installed
|
||||
* So we have to append the vardefs for each relationship to a single file for each module
|
||||
* @param string $basepath Basepath location for this module
|
||||
* @param $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param string $relationshipName Name of this relationship (for uniqueness)
|
||||
* @param array $linkFieldDefinitions Set of link field definitions in the form $linkFieldDefinitions[$for_module]
|
||||
* @return array $installDefs Set of new installDefs
|
||||
*/
|
||||
protected function saveVardefs ($basepath , $installDefPrefix , $relationshipName , $vardefs)
|
||||
{
|
||||
mkdir_recursive ( "$basepath/vardefs/" ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): vardefs =" . print_r ( $vardefs, true ) ) ;
|
||||
|
||||
foreach ( $vardefs as $moduleName => $definitions )
|
||||
{
|
||||
// find this module's Object name - the object name, not the module name, is used as the key in the vardefs...
|
||||
if (isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] ))
|
||||
{
|
||||
$module = get_module_info ( $moduleName ) ;
|
||||
$object = $module->object_name ;
|
||||
} else
|
||||
{
|
||||
$object = $moduleName ;
|
||||
}
|
||||
|
||||
$relName = $moduleName;
|
||||
foreach ( $definitions as $definition )
|
||||
{
|
||||
if (!empty($definition['relationship']))
|
||||
{
|
||||
$relName = $definition['relationship'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$filename = "$basepath/vardefs/{$relName}_{$moduleName}.php" ;
|
||||
|
||||
$out = "<?php\n// created: " . date('Y-m-d H:i:s') . "\n";
|
||||
foreach ( $definitions as $definition )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
|
||||
$out .= '$dictionary["' . $object . '"]["fields"]["' . $definition [ 'name' ] . '"] = '
|
||||
. var_export_helper($definition) . ";\n";
|
||||
}
|
||||
file_put_contents($filename, $out);
|
||||
|
||||
$installDefs [ $moduleName ] = array (
|
||||
'from' => "{$installDefPrefix}/relationships/vardefs/{$relName}_{$moduleName}.php" ,
|
||||
'to_module' => $moduleName
|
||||
) ;
|
||||
}
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveVardefs(): installDefs =" . print_r ( $installDefs, true ) ) ;
|
||||
|
||||
return $installDefs ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine if we're dealing with a deployed or undeployed module based on the name
|
||||
* Undeployed modules are those known to ModuleBuilder; the twist is that the deployed names of modulebuilder modules are keyname_modulename not packagename_modulename
|
||||
* and ModuleBuilder doesn't have any accessor methods based around keys, so we must convert keynames to packagenames
|
||||
* @param $deployedName Name of the module in the deployed form - that is, keyname_modulename or modulename
|
||||
* @return array ('moduleName'=>name, 'packageName'=>package) if undeployed, ('moduleName'=>name) if deployed
|
||||
*/
|
||||
static function parseDeployedModuleName ($deployedName)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
|
||||
$packageName = '' ;
|
||||
$moduleName = $deployedName ;
|
||||
|
||||
foreach ( $mb->getPackageList () as $name )
|
||||
{
|
||||
// convert the keyName into a packageName, needed for checking to see if this is really an undeployed module, or just a module with a _ in the name...
|
||||
$package = $mb->getPackage ( $name ) ; // seem to need to call getPackage twice to get the key correctly... TODO: figure out why...
|
||||
$key = $mb->getPackage ( $name )->key ;
|
||||
if (strlen ( $key ) < strlen ( $deployedName ))
|
||||
{
|
||||
$position = stripos ( $deployedName, $key ) ;
|
||||
$moduleName = trim( substr( $deployedName , strlen($key) ) , '_' ); //use trim rather than just assuming that _ is between packageName and moduleName in the deployedName
|
||||
if ( $position !== false && $position == 0 && (isset ( $mb->packages [ $name ]->modules [ $moduleName ] )))
|
||||
{
|
||||
$packageName = $name ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty ( $packageName ))
|
||||
{
|
||||
return array ( 'moduleName' => $moduleName , 'packageName' => $packageName ) ;
|
||||
} else
|
||||
{
|
||||
return array ( 'moduleName' => $deployedName ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
275
modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php
Executable file
275
modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php
Executable file
@@ -0,0 +1,275 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
|
||||
|
||||
/*
|
||||
* Class to manage the metadata for a One-To-Many Relationship
|
||||
* The One-To-Many relationships created by this class are a combination of a subpanel and a custom relate field
|
||||
* The LHS (One) module will receive a new subpanel for the RHS module. The subpanel gets its data ('get_subpanel_data') from a link field that references a new Relationship
|
||||
* The RHS (Many) module will receive a new relate field to point back to the LHS
|
||||
*
|
||||
* OOB modules implement One-To-Many relationships as:
|
||||
*
|
||||
* On the LHS (One) side:
|
||||
* A Relationship of type one-to-many in the rhs modules vardefs.php
|
||||
* A link field in the same vardefs.php with 'relationship'= the relationship name and 'source'='non-db'
|
||||
* A subpanel which gets its data (get_subpanel_data) from the link field
|
||||
*
|
||||
* On the RHS (Many) side:
|
||||
* A Relate field in the vardefs, formatted as in this example, which references a link field:
|
||||
* 'name' => 'account_name',
|
||||
* 'rname' => 'name',
|
||||
* 'id_name' => 'account_id',
|
||||
* 'vname' => 'LBL_ACCOUNT_NAME',
|
||||
* 'join_name'=>'accounts',
|
||||
* 'type' => 'relate',
|
||||
* 'link' => 'accounts',
|
||||
* 'table' => 'accounts',
|
||||
* 'module' => 'Accounts',
|
||||
* 'source' => 'non-db'
|
||||
* A link field which references the shared Relationship
|
||||
*/
|
||||
|
||||
class ActivitiesRelationship extends OneToManyRelationship
|
||||
{
|
||||
|
||||
protected static $subpanelsAdded = array();
|
||||
protected static $labelsAdded = array();
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param array $definition Parameters passed in as array defined in parent::$definitionKeys
|
||||
* The lhs_module value is for the One side; the rhs_module value is for the Many
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
parent::__construct ( $definition ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define the labels to be added to the module for the new relationships
|
||||
* @return array An array of system value => display value
|
||||
*/
|
||||
function buildLabels ()
|
||||
{
|
||||
$labelDefinitions = array ( ) ;
|
||||
if (!$this->relationship_only )
|
||||
{
|
||||
if (!isset(ActivitiesRelationship::$labelsAdded[$this->lhs_module])) {
|
||||
$labelDefinitions [] = array (
|
||||
'module' => 'application' ,
|
||||
'system_label' => 'parent_type_display',
|
||||
'display_label' => array ( $this->lhs_module => ucfirst ( $this->lhs_module ))
|
||||
) ;
|
||||
|
||||
$labelDefinitions [] = array (
|
||||
'module' => 'application' ,
|
||||
'system_label' => 'record_type_display',
|
||||
'display_label' => array ( $this->lhs_module => ucfirst ( $this->lhs_module ))
|
||||
) ;
|
||||
|
||||
$labelDefinitions [] = array (
|
||||
'module' => 'application' ,
|
||||
'system_label' => 'record_type_display_notes',
|
||||
'display_label' => array ( $this->lhs_module => ucfirst ( $this->lhs_module ))
|
||||
) ;
|
||||
}
|
||||
|
||||
$labelDefinitions [] = array (
|
||||
'module' => $this->lhs_module ,
|
||||
'system_label' => 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ,
|
||||
'display_label' => /*'*' .*/ ucfirst ( $this->rhs_module )
|
||||
) ;
|
||||
ActivitiesRelationship::$labelsAdded[$this->lhs_module] = true;
|
||||
}
|
||||
return $labelDefinitions ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @return array An array of field definitions, ready for the vardefs, keyed by module
|
||||
*/
|
||||
function buildVardefs ( )
|
||||
{
|
||||
$vardefs = array ( ) ;
|
||||
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name ) ;
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name ) ;
|
||||
|
||||
|
||||
return $vardefs ;
|
||||
}
|
||||
|
||||
protected function getLinkFieldDefinition ($sourceModule , $relationshipName)
|
||||
{
|
||||
$vardef = array ( ) ;
|
||||
$vardef [ 'name' ] = $relationshipName;
|
||||
$vardef [ 'type' ] = 'link' ;
|
||||
$vardef [ 'relationship' ] = $relationshipName ;
|
||||
$vardef [ 'source' ] = 'non-db' ;
|
||||
return $vardef ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Define what fields to add to which modules layouts
|
||||
* @return array An array of module => fieldname
|
||||
*/
|
||||
function buildFieldsToLayouts ()
|
||||
{
|
||||
if ($this->relationship_only)
|
||||
return array () ;
|
||||
|
||||
return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
|
||||
}
|
||||
|
||||
function buildSubpanelDefinitions ()
|
||||
{
|
||||
if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module]))
|
||||
return array () ;
|
||||
|
||||
ActivitiesRelationship::$subpanelsAdded[$this->lhs_module] = true;
|
||||
$relationshipName = substr($this->relationship_name, 0, strrpos($this->relationship_name, '_'));
|
||||
return array( $this->lhs_module => array (
|
||||
'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ),
|
||||
'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) ,
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of relationship metadata definitions
|
||||
*/
|
||||
function buildRelationshipMetaData ()
|
||||
{
|
||||
$relationshipName = $this->definition [ 'relationship_name' ];
|
||||
$relMetadata = array ( ) ;
|
||||
$relMetadata [ 'lhs_module' ] = $this->definition [ 'lhs_module' ] ;
|
||||
$relMetadata [ 'lhs_table' ] = $this->getTablename($this->definition [ 'lhs_module' ]) ;
|
||||
$relMetadata [ 'lhs_key' ] = 'id' ;
|
||||
$relMetadata [ 'rhs_module' ] = $this->definition [ 'rhs_module' ] ;
|
||||
$relMetadata [ 'rhs_table' ] = $this->getTablename($this->definition [ 'rhs_module' ]) ;
|
||||
$relMetadata ['rhs_key'] = 'parent_id';
|
||||
$relMetadata ['relationship_type'] = 'one-to-many';
|
||||
$relMetadata ['relationship_role_column'] = 'parent_type';
|
||||
$relMetadata ['relationship_role_column_value'] = $this->definition [ 'lhs_module' ] ;
|
||||
|
||||
return array( $this->lhs_module => array(
|
||||
'relationships' => array ($relationshipName => $relMetadata),
|
||||
'fields' => '', 'indices' => '', 'table' => '')
|
||||
) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut to construct an Activities collection subpanel
|
||||
* @param AbstractRelationship $relationship Source relationship to Activities module
|
||||
*/
|
||||
protected function buildActivitiesSubpanelDefinition ( $relationshipName )
|
||||
{
|
||||
return array (
|
||||
'order' => 10 ,
|
||||
'sort_order' => 'desc' ,
|
||||
'sort_by' => 'date_start' ,
|
||||
'title_key' => 'LBL_ACTIVITIES_SUBPANEL_TITLE' ,
|
||||
'type' => 'collection' ,
|
||||
'subpanel_name' => 'activities' , //this value is not associated with a physical file
|
||||
'module' => 'Activities' ,
|
||||
'top_buttons' => array (
|
||||
array ( 'widget_class' => 'SubPanelTopCreateTaskButton' ) ,
|
||||
array ( 'widget_class' => 'SubPanelTopScheduleMeetingButton' ) ,
|
||||
array ( 'widget_class' => 'SubPanelTopScheduleCallButton' ) ,
|
||||
array ( 'widget_class' => 'SubPanelTopComposeEmailButton' ) ) ,
|
||||
'collection_list' => array (
|
||||
'meetings' => array (
|
||||
'module' => 'Meetings' ,
|
||||
'subpanel_name' => 'ForActivities' ,
|
||||
'get_subpanel_data' => $relationshipName. '_meetings' ) ,
|
||||
'tasks' => array (
|
||||
'module' => 'Tasks' ,
|
||||
'subpanel_name' => 'ForActivities' ,
|
||||
'get_subpanel_data' => $relationshipName. '_tasks' ) ,
|
||||
'calls' => array (
|
||||
'module' => 'Calls' ,
|
||||
'subpanel_name' => 'ForActivities' ,
|
||||
'get_subpanel_data' => $relationshipName. '_calls' ) ) ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut to construct a History collection subpanel
|
||||
* @param AbstractRelationship $relationship Source relationship to Activities module
|
||||
*/
|
||||
protected function buildHistorySubpanelDefinition ( $relationshipName )
|
||||
{
|
||||
return array (
|
||||
'order' => 20 ,
|
||||
'sort_order' => 'desc' ,
|
||||
'sort_by' => 'date_modified' ,
|
||||
'title_key' => 'LBL_HISTORY' ,
|
||||
'type' => 'collection' ,
|
||||
'subpanel_name' => 'history' , //this values is not associated with a physical file.
|
||||
'module' => 'History' ,
|
||||
'top_buttons' => array (
|
||||
array ( 'widget_class' => 'SubPanelTopCreateNoteButton' ) ,
|
||||
array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'),
|
||||
array ( 'widget_class' => 'SubPanelTopSummaryButton' ) ) ,
|
||||
'collection_list' => array (
|
||||
'meetings' => array (
|
||||
'module' => 'Meetings' ,
|
||||
'subpanel_name' => 'ForHistory' ,
|
||||
'get_subpanel_data' => $relationshipName. '_meetings' ) ,
|
||||
'tasks' => array (
|
||||
'module' => 'Tasks' ,
|
||||
'subpanel_name' => 'ForHistory' ,
|
||||
'get_subpanel_data' => $relationshipName. '_tasks' ) ,
|
||||
'calls' => array (
|
||||
'module' => 'Calls' ,
|
||||
'subpanel_name' => 'ForHistory' ,
|
||||
'get_subpanel_data' => $relationshipName. '_calls' ) ,
|
||||
'notes' => array (
|
||||
'module' => 'Notes' ,
|
||||
'subpanel_name' => 'ForHistory' ,
|
||||
'get_subpanel_data' => $relationshipName. '_notes' ) ,
|
||||
'emails' => array (
|
||||
'module' => 'Emails' ,
|
||||
'subpanel_name' => 'ForHistory' ,
|
||||
'get_subpanel_data' => $relationshipName. '_emails' ) ) ) ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
382
modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php
Executable file
382
modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php
Executable file
@@ -0,0 +1,382 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ;
|
||||
|
||||
|
||||
class DeployedRelationships extends AbstractRelationships implements RelationshipsInterface
|
||||
{
|
||||
|
||||
function __construct ($moduleName)
|
||||
{
|
||||
$this->moduleName = $moduleName ;
|
||||
$this->load () ;
|
||||
}
|
||||
|
||||
static function findRelatableModules ()
|
||||
{
|
||||
return parent::findRelatableModules ( true ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the set of relationships for this module - the set is the combination of that held in the working file plus all of the relevant deployed relationships for the module
|
||||
* Note that deployed relationships are readonly and cannot be modified - getDeployedRelationships() takes care of marking them as such
|
||||
* Assumes that only called for modules which exist in $beansList - otherwise get_module_info will break
|
||||
* This means that load() cannot be called for Activities, only Tasks, Notes, etc
|
||||
*
|
||||
* Note that we may need to adjust the cardinality for any custom relationships that we do not have entries for in the working directory
|
||||
* These relationships might have been loaded from an installation package by ModuleInstaller, or the custom/working directory might have been cleared at some point
|
||||
* The cardinality in the installed relationship is not necessarily correct for custom relationships, which currently are all built as many-to-many relationships
|
||||
* Instead we must obtain the true cardinality from a property we added to the relationship metadata when we created the relationship
|
||||
* This relationship metadata is accessed through the Table Dictionary
|
||||
*/
|
||||
function load ()
|
||||
{
|
||||
|
||||
$relationships = $this->getDeployedRelationships () ;
|
||||
|
||||
if (! empty ( $relationships ))
|
||||
{
|
||||
// load the relationship definitions for all installed custom relationships into $dictionary
|
||||
$dictionary = array ( ) ;
|
||||
if (file_exists ( 'custom/application/Ext/TableDictionary/tabledictionary.ext.php' ))
|
||||
{
|
||||
include ('custom/application/Ext/TableDictionary/tabledictionary.ext.php') ;
|
||||
}
|
||||
|
||||
$invalidModules = array ( 'Users' ) ;
|
||||
$validModules = array_keys ( self::findRelatableModules () ) ;
|
||||
|
||||
// now convert the relationships array into an array of AbstractRelationship objects
|
||||
foreach ( $relationships as $name => $definition )
|
||||
{
|
||||
if (($definition [ 'lhs_module' ] == $this->moduleName) || ($definition [ 'rhs_module' ] == $this->moduleName))
|
||||
{
|
||||
if (in_array ( $definition [ 'lhs_module' ], $validModules ) && in_array ( $definition [ 'rhs_module' ], $validModules ) && ! in_array ( $definition [ 'lhs_module' ], $invalidModules ) && ! in_array ( $definition [ 'rhs_module' ], $invalidModules ))
|
||||
{
|
||||
// identify the subpanels for this relationship - TODO: optimize this - currently does m x n scans through the subpanel list...
|
||||
$definition [ 'rhs_subpanel' ] = self::identifySubpanel ( $definition [ 'lhs_module' ], $definition [ 'rhs_module' ] ) ;
|
||||
$definition [ 'lhs_subpanel' ] = self::identifySubpanel ( $definition [ 'rhs_module' ], $definition [ 'lhs_module' ] ) ;
|
||||
|
||||
// now adjust the cardinality with the true cardinality found in the relationships metadata (see method comment above)
|
||||
|
||||
|
||||
if (! empty ( $dictionary ) && ! empty ( $dictionary [ $name ] ) ) {
|
||||
if (! empty ( $dictionary [ $name ] [ 'true_relationship_type' ] )) {
|
||||
$definition [ 'relationship_type' ] = $dictionary [ $name ] [ 'true_relationship_type' ] ;
|
||||
}
|
||||
if (! empty ( $dictionary [ $name ] [ 'from_studio' ] )) {
|
||||
$definition [ 'from_studio' ] = $dictionary [ $name ] [ 'from_studio' ] ;
|
||||
}
|
||||
$definition [ 'is_custom' ] = true;
|
||||
}
|
||||
|
||||
|
||||
$this->relationships [ $name ] = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* // Now override with any definitions from the working directory
|
||||
// must do this to capture one-to-ones that we have created as these don't show up in the relationship table that is the source for getDeployedRelationships()
|
||||
$overrides = parent::_load ( "custom/working/modules/{$this->moduleName}" ) ;
|
||||
foreach ( $overrides as $name => $relationship )
|
||||
{
|
||||
$this->relationships [ $name ] = $relationship ;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Save this modules relationship definitions out to a working file
|
||||
*/
|
||||
function save ()
|
||||
{
|
||||
parent::_save ( $this->relationships, "custom/working/modules/{$this->moduleName}" ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update pre-5.1 relationships to the 5.1 relationship definition
|
||||
* There is nothing to do for Deployed relationships as these were only introduced in 5.1
|
||||
* @param array definition The 5.0 relationship definition
|
||||
* @return array The definition updated to 5.1 format
|
||||
*/
|
||||
protected function _updateRelationshipDefinition ($definition)
|
||||
{
|
||||
return $definition ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the module Loader to delete the relationship from the instance.
|
||||
*/
|
||||
function delete ($rel_name)
|
||||
{
|
||||
require_once("ModuleInstall/ModuleInstaller.php");
|
||||
require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
$mi = new ModuleInstaller();
|
||||
$mi->silent = true;
|
||||
$mi->uninstall_relationship("custom/metadata/{$rel_name}MetaData.php");
|
||||
|
||||
// now clear all caches so that our changes are visible
|
||||
Relationship::delete_cache();
|
||||
$mi->rebuild_tabledictionary();
|
||||
|
||||
$MBmodStrings = $GLOBALS [ 'mod_strings' ];
|
||||
$GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
|
||||
$rac = new RepairAndClear ( ) ;
|
||||
$rac->repairAndClearAll ( array ( 'clearAll', 'rebuildExtensions', ), array ( $GLOBALS [ 'mod_strings' ] [ 'LBL_ALL_MODULES' ] ), true, false ) ;
|
||||
$GLOBALS [ 'mod_strings' ] = $MBmodStrings;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the set of all known relevant relationships for a deployed module
|
||||
* The set is made up of the relationships held in this class, plus all those already deployed in the application
|
||||
* @return array Set of all relevant relationships
|
||||
*/
|
||||
protected function getAllRelationships ()
|
||||
{
|
||||
return array_merge ( $this->relationships, parent::getDeployedRelationships () ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of the first (currently only) subpanel displayed in the DetailView of $thisModuleName provided by $sourceModuleName
|
||||
* We can assume that both sides of the relationship are deployed modules as this is only called within the context of DeployedRelationships
|
||||
* @param string $thisModuleName Name of the related module
|
||||
* @param string $sourceModuleName Name of the primary module
|
||||
* @return string Name of the subpanel if found; null otherwise
|
||||
*/
|
||||
static private function identifySubpanel ($thisModuleName , $sourceModuleName)
|
||||
{
|
||||
$module = get_module_info ( $thisModuleName ) ;
|
||||
require_once ('include/SubPanel/SubPanelDefinitions.php') ;
|
||||
$spd = new SubPanelDefinitions ( $module ) ;
|
||||
$subpanelNames = $spd->get_available_tabs () ; // actually these are the displayed subpanels
|
||||
|
||||
|
||||
$subPanels = array ( ) ;
|
||||
foreach ( $subpanelNames as $key => $name )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( $thisModuleName . " " . $name ) ;
|
||||
$subPanel = $spd->load_subpanel ( $name ) ;
|
||||
if (! isset ( $subPanel->_instance_properties [ 'collection_list' ] ))
|
||||
{
|
||||
if ($sourceModuleName == $subPanel->_instance_properties [ 'module' ])
|
||||
{
|
||||
return $subPanel->_instance_properties [ 'subpanel_name' ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of the first (currently only) relate field of $thisModuleName sourced from by $sourceModuleName
|
||||
* We can assume that both sides of the relationship are deployed modules as this is only called within the context of DeployedRelationships
|
||||
* @param string $thisModuleName Name of the related module
|
||||
* @param string $sourceModuleName Name of the primary module
|
||||
* @return string Name of the relate field, if found; null otherwise
|
||||
*/
|
||||
|
||||
static private function identifyRelateField ($thisModuleName , $sourceModuleName)
|
||||
{
|
||||
$module = get_module_info ( $thisModuleName ) ;
|
||||
|
||||
foreach ( $module->field_defs as $field )
|
||||
{
|
||||
if ($field [ 'type' ] == 'relate' && isset ( $field [ 'module' ] ) && $field [ 'module' ] == $sourceModuleName)
|
||||
return $field [ 'name' ] ;
|
||||
}
|
||||
return null ;
|
||||
}
|
||||
|
||||
/*
|
||||
* As of SugarCRM 5.1 the subpanel code and the widgets have difficulty handling multiple subpanels or relate fields from the same module
|
||||
* Until this is fixed, we new relationships which will trigger this problem must be flagged as "relationship_only" and built without a UI component
|
||||
* This function is called from the view when constructing a new relationship
|
||||
* We can assume that both sides of the relationship are deployed modules as this is only called within the context of DeployedRelationships
|
||||
* @param AbstractRelationship $relationship The relationship to be enforced
|
||||
*/
|
||||
public function enforceRelationshipOnly ($relationship)
|
||||
{
|
||||
$lhs = $relationship->lhs_module ;
|
||||
$rhs = $relationship->rhs_module ;
|
||||
// if the lhs_module already has a subpanel or relate field sourced from the rhs_module,
|
||||
// or the rhs_module already has a subpanel or relate field sourced from the lhs_module,
|
||||
// then set "relationship_only" in the relationship
|
||||
|
||||
|
||||
// if (($relationship->getType() != MB_ONETOONE && ! is_null ( self::identifySubpanel ( $lhs, $rhs ) )) || ($relationship->getType() == MB_MANYTOMANY && ! is_null ( self::identifySubpanel ( $rhs, $lhs ) )) || ($relationship->getType() == MB_ONETOONE && ! is_null ( self::identifyRelateField ( $rhs, $lhs ) )) || ($relationship->getType() != MB_MANYTOMANY && ! is_null ( self::identifyRelateField ( $lhs, $rhs ) )))
|
||||
// $relationship->setRelationship_only () ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implement all of the Relationships in this set of relationships
|
||||
* This is more general than it needs to be given that deployed relationships are built immediately - there should only be one relationship to build here...
|
||||
* We use the Extension mechanism to do this for DeployedRelationships
|
||||
* All metadata is placed in the modules Ext directory, and then Rebuild is called to activate them
|
||||
*/
|
||||
function build ()
|
||||
{
|
||||
$basepath = "custom/Extension/modules" ;
|
||||
|
||||
$this->activitiesToAdd = false ;
|
||||
|
||||
// and mark all as built so that the next time we come through we'll know and won't build again
|
||||
foreach ( $this->relationships as $name => $relationship )
|
||||
{
|
||||
$definition = $relationship->getDefinition () ;
|
||||
// activities will always appear on the rhs only - lhs will be always be this module in MB
|
||||
if (strtolower ( $definition [ 'rhs_module' ] ) == 'activities')
|
||||
{
|
||||
$this->activitiesToAdd = true ;
|
||||
$relationshipName = $definition [ 'relationship_name' ] ;
|
||||
foreach ( self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName )
|
||||
{
|
||||
$definition [ 'rhs_module' ] = $activitiesSubModuleName ;
|
||||
$definition [ 'for_activities' ] = true ;
|
||||
$definition [ 'relationship_name' ] = $relationshipName . '_' . $activitiesSubModuleLower ;
|
||||
$this->relationships [ $definition [ 'relationship_name' ] ] = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
}
|
||||
unset ( $this->relationships [ $name ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->build(): installing relationships" ) ;
|
||||
|
||||
$MBModStrings = $GLOBALS [ 'mod_strings' ] ;
|
||||
$adminModStrings = return_module_language ( '', 'Administration' ) ; // required by ModuleInstaller
|
||||
|
||||
foreach ( $this->relationships as $name => $relationship )
|
||||
{
|
||||
$relationship->setFromStudio();
|
||||
$GLOBALS [ 'mod_strings' ] = $MBModStrings ;
|
||||
$installDefs = parent::build ( $basepath, "<basepath>", array ($name => $relationship ) ) ;
|
||||
|
||||
// and mark as built so that the next time we come through we'll know and won't build again
|
||||
$relationship->setReadonly () ;
|
||||
$this->relationships [ $name ] = $relationship ;
|
||||
|
||||
// now install the relationship - ModuleInstaller normally only does this as part of a package load where it installs the relationships defined in the manifest. However, we don't have a manifest or a package, so...
|
||||
|
||||
// If we were to chose to just use the Extension mechanism, without using the ModuleInstaller install_...() methods, we must :
|
||||
// 1) place the information for each side of the relationship in the appropriate Ext directory for the module, which means specific $this->save...() methods for DeployedRelationships, and
|
||||
// 2) we must also manually add the relationship into the custom/application/Ext/TableDictionary/tabledictionary.ext.php file as install_relationship doesn't handle that (install_relationships which requires the manifest however does)
|
||||
// Relationships must be in tabledictionary.ext.php for the Admin command Rebuild Relationships to reliably work:
|
||||
// Rebuild Relationships looks for relationships in the modules vardefs.php, in custom/modules/<modulename>/Ext/vardefs/vardefs.ext.php, and in modules/TableDictionary.php and custom/application/Ext/TableDictionary/tabledictionary.ext.php
|
||||
// if the relationship is not defined in one of those four places it could be deleted during a rebuilt, or during a module installation (when RebuildRelationships.php deletes all entries in the Relationships table)
|
||||
// So instead of doing this, we use common save...() methods between DeployedRelationships and UndeployedRelationships that will produce installDefs,
|
||||
// and rather than building a full manifest file to carry them, we manually add these installDefs to the ModuleInstaller, and then
|
||||
// individually call the appropriate ModuleInstaller->install_...() methods to take our relationship out of our staging area and expand it out to the individual module Ext areas
|
||||
|
||||
$GLOBALS [ 'mod_strings' ] = $adminModStrings ;
|
||||
require_once 'ModuleInstall/ModuleInstaller.php' ;
|
||||
$mi = new ModuleInstaller ( ) ;
|
||||
|
||||
$mi->id_name = 'custom' . $name ; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
|
||||
$mi->installdefs = $installDefs ;
|
||||
$mi->base_dir = $basepath ;
|
||||
$mi->silent = true ;
|
||||
|
||||
|
||||
VardefManager::clearVardef () ;
|
||||
|
||||
$mi->install_relationships () ;
|
||||
$mi->install_languages () ;
|
||||
$mi->install_vardefs () ;
|
||||
$mi->install_layoutdefs () ;
|
||||
|
||||
}
|
||||
|
||||
// now clear all caches so that our changes are visible
|
||||
require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
$rac = new RepairAndClear ( ) ;
|
||||
$rac->repairAndClearAll ( array ( 'clearAll' ), array ( $GLOBALS [ 'mod_strings' ] [ 'LBL_ALL_MODULES' ] ), true, false ) ;
|
||||
|
||||
$GLOBALS [ 'mod_strings' ] = $MBModStrings ; // finally, restore the ModuleBuilder mod_strings
|
||||
|
||||
// save out the updated definitions so that we keep track of the change in built status
|
||||
$this->save () ;
|
||||
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->build(): finished relationship installation" ) ;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Add any fields to the DetailView and EditView of the appropriate modules
|
||||
* @param string $basepath Basepath location for this module (not used)
|
||||
* @param string $relationshipName Name of this relationship (for uniqueness)
|
||||
* @param array $layoutAdditions An array of module => fieldname
|
||||
* return null
|
||||
*/
|
||||
protected function saveFieldsToLayouts ($basepath , $dummy , $relationshipName , $layoutAdditions)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
|
||||
// these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. In either case, we don't want to attempt to add a relate field to them
|
||||
// would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here
|
||||
$invalidModules = array ( 'emails' , 'kbdocuments' ) ;
|
||||
|
||||
foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
|
||||
{
|
||||
if (! in_array ( strtolower ( $deployedModuleName ), $invalidModules ))
|
||||
foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ;
|
||||
$parser = new GridLayoutMetaDataParser ( $view, $deployedModuleName ) ;
|
||||
$parser->addField ( array ( 'name' => $fieldName ) ) ;
|
||||
$parser->handleSave ( false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
105
modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php
Executable file
105
modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
|
||||
/*
|
||||
* Class to manage the metadata for a Many-To-Many Relationship
|
||||
* The LHS (One) module will receive a new subpanel for the RHS module
|
||||
* The RHS (Many) module will receive a new subpanel for the RHS module
|
||||
* The subpanels get their data ('get_subpanel_data') from two link fields (one each) that reference a new Relationship
|
||||
*
|
||||
* In OOB modules it's done the same way (e.g. cases_bugs)
|
||||
*/
|
||||
|
||||
class ManyToManyRelationship extends AbstractRelationship
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param array $definition Parameters passed in as array with keys defined in parent::keys
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
parent::__construct ( $definition ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
/*
|
||||
* Construct subpanel definitions
|
||||
* The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
|
||||
* @return array An array of subpanel definitions, keyed by module
|
||||
*/
|
||||
function buildSubpanelDefinitions ()
|
||||
{
|
||||
$subpanelDefinitions = array ( ) ;
|
||||
if (!$this->relationship_only)
|
||||
{
|
||||
$subpanelDefinitions [ $this->rhs_module ] = $this->getSubpanelDefinition ( $this->relationship_name, $this->lhs_module, $this->lhs_subpanel, $this->getLeftModuleSystemLabel() ) ;
|
||||
$subpanelDefinitions [ $this->lhs_module ] = $this->getSubpanelDefinition ( $this->relationship_name, $this->rhs_module, $this->rhs_subpanel, $this->getRightModuleSystemLabel() ) ;
|
||||
}
|
||||
return $subpanelDefinitions ;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of field definitions, ready for the vardefs, keyed by module
|
||||
*/
|
||||
function buildVardefs ( )
|
||||
{
|
||||
$vardefs = array ( ) ;
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name, false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
return $vardefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of relationship metadata definitions
|
||||
*/
|
||||
function buildRelationshipMetaData ()
|
||||
{
|
||||
return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_MANYTOMANY ) ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
149
modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php
Executable file
149
modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php
Executable file
@@ -0,0 +1,149 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
/*
|
||||
* Class to manage the metadata for a many-To-one Relationship
|
||||
* Exactly the same as a one-to-many relationship except lhs and rhs modules have been reversed.
|
||||
*/
|
||||
|
||||
class ManyToOneRelationship extends AbstractRelationship
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param array $definition Parameters passed in as array defined in parent::$definitionKeys
|
||||
* The lhs_module value is for the One side; the rhs_module value is for the Many
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
|
||||
parent::__construct ( $definition ) ;
|
||||
$onetomanyDef = array_merge($definition, array(
|
||||
'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null,
|
||||
'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null,
|
||||
'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null,
|
||||
'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null,
|
||||
'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null,
|
||||
'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null,
|
||||
'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null,
|
||||
'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null,
|
||||
'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null,
|
||||
'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null,
|
||||
'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null,
|
||||
'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null,
|
||||
'relationship_type' => MB_ONETOMANY,
|
||||
));
|
||||
$this->one_to_many = new OneToManyRelationship($onetomanyDef);
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
function buildLabels ()
|
||||
{
|
||||
return $this->one_to_many->buildLabels();
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct subpanel definitions
|
||||
* The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
|
||||
* @return array An array of subpanel definitions, keyed by the module
|
||||
*/
|
||||
function buildSubpanelDefinitions ()
|
||||
{
|
||||
return $this->one_to_many->buildSubpanelDefinitions();
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of field definitions, ready for the vardefs, keyed by module
|
||||
*/
|
||||
function buildVardefs ( )
|
||||
{
|
||||
return $this->one_to_many->buildVardefs();
|
||||
}
|
||||
|
||||
/*
|
||||
* Define what fields to add to which modules layouts
|
||||
* @return array An array of module => fieldname
|
||||
*/
|
||||
function buildFieldsToLayouts ()
|
||||
{
|
||||
if ($this->relationship_only)
|
||||
return array () ;
|
||||
|
||||
return array( $this->lhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of relationship metadata definitions
|
||||
*/
|
||||
function buildRelationshipMetaData ()
|
||||
{
|
||||
return $this->one_to_many->buildRelationshipMetaData();
|
||||
}
|
||||
|
||||
public function setName ($relationshipName)
|
||||
{
|
||||
parent::setName($relationshipName);
|
||||
$this->one_to_many->setname($relationshipName);
|
||||
}
|
||||
|
||||
public function setReadonly ()
|
||||
{
|
||||
parent::setReadonly();
|
||||
$this->one_to_many->setReadonly();
|
||||
}
|
||||
|
||||
public function delete ()
|
||||
{
|
||||
parent::delete();
|
||||
$this->one_to_many->delete();
|
||||
}
|
||||
|
||||
public function setRelationship_only ()
|
||||
{
|
||||
parent::setRelationship_only();
|
||||
$this->one_to_many->setRelationship_only();
|
||||
}
|
||||
}
|
||||
?>
|
||||
153
modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php
Executable file
153
modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php
Executable file
@@ -0,0 +1,153 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
|
||||
/*
|
||||
* Class to manage the metadata for a One-To-Many Relationship
|
||||
* The One-To-Many relationships created by this class are a combination of a subpanel and a custom relate field
|
||||
* The LHS (One) module will receive a new subpanel for the RHS module. The subpanel gets its data ('get_subpanel_data') from a link field that references a new Relationship
|
||||
* The RHS (Many) module will receive a new relate field to point back to the LHS
|
||||
*
|
||||
* OOB modules implement One-To-Many relationships as:
|
||||
*
|
||||
* On the LHS (One) side:
|
||||
* A Relationship of type one-to-many in the rhs modules vardefs.php
|
||||
* A link field in the same vardefs.php with 'relationship'= the relationship name and 'source'='non-db'
|
||||
* A subpanel which gets its data (get_subpanel_data) from the link field
|
||||
*
|
||||
* On the RHS (Many) side:
|
||||
* A Relate field in the vardefs, formatted as in this example, which references a link field:
|
||||
* 'name' => 'account_name',
|
||||
* 'rname' => 'name',
|
||||
* 'id_name' => 'account_id',
|
||||
* 'vname' => 'LBL_ACCOUNT_NAME',
|
||||
* 'join_name'=>'accounts',
|
||||
* 'type' => 'relate',
|
||||
* 'link' => 'accounts',
|
||||
* 'table' => 'accounts',
|
||||
* 'module' => 'Accounts',
|
||||
* 'source' => 'non-db'
|
||||
* A link field which references the shared Relationship
|
||||
*/
|
||||
|
||||
class OneToManyRelationship extends AbstractRelationship
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param array $definition Parameters passed in as array defined in parent::$definitionKeys
|
||||
* The lhs_module value is for the One side; the rhs_module value is for the Many
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
parent::__construct ( $definition ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
/*
|
||||
* Construct subpanel definitions
|
||||
* The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php
|
||||
* @return array An array of subpanel definitions, keyed by the module
|
||||
*/
|
||||
function buildSubpanelDefinitions ()
|
||||
{
|
||||
if ($this->relationship_only)
|
||||
return array () ;
|
||||
|
||||
$source = "";
|
||||
if ($this->rhs_module == $this->lhs_module)
|
||||
{
|
||||
$source = $this->getJoinKeyLHS();
|
||||
}
|
||||
|
||||
return array(
|
||||
$this->lhs_module => $this->getSubpanelDefinition (
|
||||
$this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of field definitions, ready for the vardefs, keyed by module
|
||||
*/
|
||||
function buildVardefs ( )
|
||||
{
|
||||
$vardefs = array ( ) ;
|
||||
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name, false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE') ;
|
||||
if ($this->rhs_module != $this->lhs_module )
|
||||
{
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE');
|
||||
}
|
||||
if (! $this->relationship_only)
|
||||
{
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getRelateFieldDefinition ( $this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel() ) ;
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLink2FieldDefinition ( $this->lhs_module, $this->relationship_name, true,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE');
|
||||
}
|
||||
|
||||
return $vardefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Define what fields to add to which modules layouts
|
||||
* @return array An array of module => fieldname
|
||||
*/
|
||||
function buildFieldsToLayouts ()
|
||||
{
|
||||
if ($this->relationship_only)
|
||||
return array () ;
|
||||
|
||||
return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs
|
||||
}
|
||||
|
||||
/*
|
||||
* @return array An array of relationship metadata definitions
|
||||
*/
|
||||
function buildRelationshipMetaData ()
|
||||
{
|
||||
return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_ONETOMANY ) ) ;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
128
modules/ModuleBuilder/parsers/relationships/OneToOneRelationship.php
Executable file
128
modules/ModuleBuilder/parsers/relationships/OneToOneRelationship.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
|
||||
/*
|
||||
* Class to manage the metadata for a One-To-One Relationship
|
||||
* The LHS module will receive a new relate field to point back to the RHS
|
||||
* The RHS module will receive a new relate field to point back to the LHS
|
||||
*
|
||||
* OOB modules implement One-To-One relationships as:
|
||||
* A Relationship of type one-to-one in one modules vardefs.php
|
||||
* A single link field in the same vardefs.php with 'relationship'= the relationship name, and 'link-type'='one', 'Module'=other side, and 'source'='non-db'
|
||||
* These are not common - examples are in InboundEmail and Schedulers, both pre-5.0 modules
|
||||
* InboundEmail:
|
||||
* 'created_by_link' => array (
|
||||
'name' => 'created_by_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'inbound_email_created_by',
|
||||
'vname' => 'LBL_CREATED_BY_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
),
|
||||
|
||||
*/
|
||||
|
||||
class OneToOneRelationship extends AbstractRelationship
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param array $definition Parameters passed in as array with keys defined in parent::keys
|
||||
*/
|
||||
function __construct ($definition)
|
||||
{
|
||||
parent::__construct ( $definition ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD methods called during the build
|
||||
*/
|
||||
|
||||
/*
|
||||
* @return array An array of relationship metadata definitions
|
||||
*/
|
||||
function buildRelationshipMetaData ()
|
||||
{
|
||||
return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_ONETOONE ) ) ;
|
||||
}
|
||||
|
||||
/* Build a set of Link Field definitions for this relationship
|
||||
* @return array An array of field definitions, ready for the vardefs, keyed by module
|
||||
*/
|
||||
function buildVardefs ( )
|
||||
{
|
||||
$vardefs = array ( ) ;
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name , false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
|
||||
if (!$this->relationship_only)
|
||||
{
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getRelateFieldDefinition ( $this->rhs_module, $this->relationship_name, $this->getRightModuleSystemLabel() ) ;
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getRelateFieldDefinition ( $this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel() ) ;
|
||||
$vardefs [ $this->lhs_module ] [] = $this->getLink2FieldDefinition ( $this->rhs_module, $this->relationship_name , false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
$vardefs [ $this->rhs_module ] [] = $this->getLink2FieldDefinition ( $this->lhs_module, $this->relationship_name , false,
|
||||
'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE' ) ;
|
||||
}
|
||||
|
||||
return $vardefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Define what fields to add to which modules layouts
|
||||
* @return array An array of module => fieldname
|
||||
*/
|
||||
function buildFieldsToLayouts ()
|
||||
{
|
||||
if ($this->relationship_only)
|
||||
return array () ;
|
||||
|
||||
if ($this->lhs_module == $this->rhs_module) // don't add in two fields on recursive relationships
|
||||
return array ( $this->lhs_module => $this->relationship_name . "_name" );
|
||||
else
|
||||
return array ( $this->lhs_module => $this->relationship_name . "_name" , $this->rhs_module => $this->relationship_name . "_name" ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
81
modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php
Executable file
81
modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class RelationshipFactory
|
||||
{
|
||||
|
||||
/*
|
||||
* Construct a new relationship of type as provided by the $definition
|
||||
* @param array $definition Complete definition of the relationship, as specified by AbstractRelationship::keys
|
||||
*/
|
||||
static function newRelationship ($definition = array())
|
||||
{
|
||||
// handle the case where a relationship_type is not provided - set it to Many-To-Many as this was the usual type in ModuleBuilder
|
||||
if (! isset ( $definition [ 'relationship_type' ] ))
|
||||
$definition [ 'relationship_type' ] = MB_MANYTOMANY ;
|
||||
|
||||
if (!empty ($definition['for_activities']) && $definition['for_activities'] == true) {
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/ActivitiesRelationship.php';
|
||||
return new ActivitiesRelationship ($definition);
|
||||
}
|
||||
|
||||
switch ( strtolower ( $definition [ 'relationship_type' ] ))
|
||||
{
|
||||
case strtolower ( MB_ONETOONE ) :
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/OneToOneRelationship.php' ;
|
||||
return new OneToOneRelationship ( $definition ) ;
|
||||
|
||||
case strtolower ( MB_ONETOMANY ) :
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ;
|
||||
return new OneToManyRelationship ( $definition ) ;
|
||||
|
||||
case strtolower ( MB_MANYTOONE ) :
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/ManyToOneRelationship.php' ;
|
||||
return new ManyToOneRelationship ( $definition ) ;
|
||||
|
||||
// default case is Many-To-Many as this was the only type ModuleBuilder could create and so much of the MB code assumes Many-To-Many
|
||||
default :
|
||||
$definition [ 'relationship_type' ] = MB_MANYTOMANY ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/ManyToManyRelationship.php' ;
|
||||
return new ManyToManyRelationship ( $definition ) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
55
modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php
Executable file
55
modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
interface RelationshipsInterface
|
||||
{
|
||||
|
||||
static public function findRelatableModules () ;
|
||||
|
||||
public function load () ;
|
||||
|
||||
// public function build () ;
|
||||
|
||||
public function getRelationshipList ();
|
||||
|
||||
public function get ($relationshipName) ;
|
||||
|
||||
public function add ($relationship) ;
|
||||
|
||||
// public function delete ($relationshipName) ;
|
||||
|
||||
}
|
||||
415
modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php
Executable file
415
modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php
Executable file
@@ -0,0 +1,415 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/relationships/AbstractRelationships.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipsInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ;
|
||||
|
||||
class UndeployedRelationships extends AbstractRelationships implements RelationshipsInterface
|
||||
{
|
||||
|
||||
protected $basepath ; // Base directory for the lhs_module
|
||||
protected $packageName ;
|
||||
private $activitiesToAdd ; // if we need to add in the composite Activities and History subpanels to the module during the build
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Automatically loads in any saved relationships
|
||||
* @param string $path The pathname of the base module directory
|
||||
*/
|
||||
function __construct ($path)
|
||||
{
|
||||
$this->basepath = $path ;
|
||||
// pull the module and package names out of the path
|
||||
$this->moduleName = basename ( $path, "/" ) ; // just in case there are any trailing /
|
||||
$this->packageName = basename ( dirname ( dirname ( $path ) ) ) ; // simpler than explode :)
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$this->packageKey = $mb->getPackageKey ( $this->packageName ) ;
|
||||
|
||||
$this->load () ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Find all modules, deployed and undeployed, that can participate in a relationship
|
||||
* @return array Array of [$module][$subpanel]
|
||||
*/
|
||||
static function findRelatableModules ()
|
||||
{
|
||||
// first find all deployed modules that we might participate in a relationship
|
||||
$relatableModules = parent::findRelatableModules ( ) ;
|
||||
|
||||
// now add in the undeployed modules - those in custom/modulebuilder
|
||||
// note that if a module exists in both deployed and undeployed forms, the subpanels from the undeployed form are used...
|
||||
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$mb->getPackages () ;
|
||||
foreach ( $mb->getPackageList () as $packageName )
|
||||
{
|
||||
$package = $mb->packages [ $packageName ] ;
|
||||
foreach ( $package->modules as $module )
|
||||
{
|
||||
$relatableModules [ $package->key . "_" . $module->name ] = $module->getProvidedSubpanels () ;
|
||||
}
|
||||
}
|
||||
|
||||
return $relatableModules ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a relationship to the set
|
||||
* For undeployed relationships we always make the fields in the relationship visible in the layouts now, rather than waiting until build time, so
|
||||
* that the admin may move them around or otherwise edit them before the module is deployed
|
||||
* @param AbstractRelationship $relationship The relationship to add
|
||||
*/
|
||||
function add ($relationship)
|
||||
{
|
||||
parent::add ( $relationship ) ;
|
||||
$this->addFieldsToUndeployedLayouts ( $relationship ) ; // must come after parent::add as we need the relationship_name in the relationships getFieldsToLayouts() which is called by addFieldsToUndeployedLayouts()
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a relationship by name
|
||||
* In future, if we need to actually track deleted relationships then just call $relationship->delete() instead
|
||||
* @param string $relationshipName The unique name for this relationship, as returned by $relationship->getName()
|
||||
*/
|
||||
function delete ($relationshipName)
|
||||
{
|
||||
if ($relationship = $this->get ( $relationshipName ))
|
||||
{
|
||||
$this->removeFieldsFromUndeployedLayouts ( $relationship ) ;
|
||||
unset ( $this->relationships [ $relationshipName ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the saved relationship definitions for this module
|
||||
*/
|
||||
function load ()
|
||||
{
|
||||
$this->relationships = parent::_load ( $this->basepath ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save this modules relationship definitions out to a working file
|
||||
*/
|
||||
function save ()
|
||||
{
|
||||
parent::_save ( $this->relationships, $this->basepath ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update pre-5.1 relationships to the 5.1 relationship definition
|
||||
* @param array definition The 5.0 relationship definition
|
||||
* @return array The definition updated to 5.1 format
|
||||
*/
|
||||
protected function _updateRelationshipDefinition ($definition)
|
||||
{
|
||||
if (isset ( $definition [ 'relate' ] ))
|
||||
{
|
||||
$newDefinition = array ( ) ;
|
||||
foreach ( array ( 'relate' => 'rhs_module' , 'rsub' => 'rhs_subpanel' , 'msub' => 'lhs_subpanel' , 'label' => 'label' ) as $oldParameter => $newParameter )
|
||||
{
|
||||
if (isset ( $definition [ $oldParameter ] ))
|
||||
{
|
||||
$definition [ $newParameter ] = $definition [ $oldParameter ] ;
|
||||
unset ( $definition [ $oldParameter ] ) ;
|
||||
}
|
||||
}
|
||||
$definition [ 'lhs_module' ] = "{$this->packageKey}_{$this->moduleName}" ;
|
||||
// finally update the relationship name
|
||||
unset ( $definition [ 'name' ] ) ; // clear the oldstyle name
|
||||
}
|
||||
return $definition ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of getAllRelationships() for Undeployed modules
|
||||
* The set of all relevant relationships for undeployed modules is the superset of that for deployed modules and all of the relationships known to ModuleBuilder
|
||||
* @return array Set of all relevant relationships
|
||||
*/
|
||||
protected function getAllRelationships ()
|
||||
{
|
||||
// start with the set of relationships known to this module plus those already deployed
|
||||
$allRelationships = array_merge ( $this->relationships, parent::getDeployedRelationships () ) ;
|
||||
|
||||
// add in the relationships known to ModuleBuilder
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$mb->getPackages () ;
|
||||
foreach ( $mb->getPackageList () as $packageName )
|
||||
{
|
||||
$package = $mb->packages [ $packageName ] ;
|
||||
foreach ( $package->modules as $module )
|
||||
{
|
||||
|
||||
foreach ( $module->relationships->getRelationshipList () as $relationshipName )
|
||||
{
|
||||
$relationship = $module->relationships->get ( $relationshipName ) ;
|
||||
$allRelationships [ $relationship->getName () ] = $relationship->getDefinition () ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allRelationships ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* As of SugarCRM 5.1 the subpanel code and the widgets have difficulty handling multiple subpanels or relate fields from the same module
|
||||
* Until this is fixed, we new relationships which will trigger this problem must be flagged as "relationship_only" and built without a UI component
|
||||
* This function is called from the view when constructing a new relationship
|
||||
* @param AbstractRelationship $relationship The relationship to be enforced
|
||||
*/
|
||||
public function enforceRelationshipOnly ($relationship)
|
||||
{
|
||||
// if we already have a relationship between this lhs_module and this rhs_module then set RelationshipOnly flag
|
||||
foreach ( $this->relationships as $rel )
|
||||
{
|
||||
if ($rel->lhs_module == $relationship->lhs_module && $rel->rhs_module == $relationship->rhs_module)
|
||||
{
|
||||
$rel->setRelationship_only () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* BUILD FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Translate the set of relationship objects into files that the Module Loader can work with
|
||||
* @param $basepath string Pathname of the directory to contain the build
|
||||
*/
|
||||
function build ($basepath)
|
||||
{
|
||||
|
||||
// first expand out any reference to Activities to its submodules
|
||||
// we do this here rather than in the subcomponents of the build as most of those subcomponents make use of elements of the definition, such
|
||||
// as the relationship name, that must be unique
|
||||
// the only special case is the subpanel for Activities, which is a composite, and is applied only once for all the submodules - this is handled in saveSubpanelDefinitions() for Undeployed modules
|
||||
|
||||
$relationships = array ( ) ;
|
||||
$this->activitiesToAdd = false ;
|
||||
foreach ( $this->relationships as $relationshipName => $relationship )
|
||||
{
|
||||
$definition = $relationship->getDefinition () ;
|
||||
// activities will always appear on the rhs only - lhs will be always be this module in MB
|
||||
if (strtolower ( $definition [ 'rhs_module' ] ) == 'activities')
|
||||
{
|
||||
$this->activitiesToAdd = true ;
|
||||
$relationshipName = $definition [ 'relationship_name' ] ;
|
||||
foreach ( self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName )
|
||||
{
|
||||
$definition [ 'rhs_module' ] = $activitiesSubModuleName ;
|
||||
$definition [ 'for_activities' ] = true ;
|
||||
$definition [ 'relationship_name' ] = $relationshipName . '_' . $activitiesSubModuleLower ;
|
||||
$relationships [ $definition [ 'relationship_name' ] ] = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
$relationships [ $definition [ 'relationship_name' ] ] = $relationship ;
|
||||
}
|
||||
}
|
||||
|
||||
require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = $mb->getPackageModule ( $this->packageName, $this->moduleName ) ;
|
||||
if ($this->activitiesToAdd)
|
||||
{
|
||||
$appStrings = $module->getAppListStrings () ;
|
||||
$appStrings [ 'parent_type_display' ] [ $module->key_name ] = $module->getlabel ( 'en_us', 'LBL_MODULE_TITLE' ) ;
|
||||
$appStrings [ 'record_type_display' ] [ $module->key_name ] = $module->getlabel ( 'en_us', 'LBL_MODULE_TITLE' ) ;
|
||||
$appStrings [ 'record_type_display_notes' ] [ $module->key_name ] = $module->getlabel ( 'en_us', 'LBL_MODULE_TITLE' ) ;
|
||||
$module->setAppListStrings ( 'en_us', $appStrings ) ;
|
||||
$module->save () ;
|
||||
|
||||
}
|
||||
|
||||
// use an installDefPrefix of <basepath>/SugarModules for compatibility with the rest of ModuleBuilder
|
||||
$this->installDefs = parent::build ( $basepath, "<basepath>/SugarModules", $relationships ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate a set of subpanelDefinitions into files for the Module Loader
|
||||
* @param string $basepath Basepath location for this module
|
||||
* @param $installDefPrefix Pathname prefix for the installdefs, for example for ModuleBuilder use "<basepath>/SugarModules"
|
||||
* @param array $subpanelDefinitions Set of subpanel definitions in the form $subpanelDefinitions[$for_module][]
|
||||
* @param string $relationshipName The name of the relationship for this subpanel definition
|
||||
* @return array $installDefs Set of new installDefs
|
||||
*/
|
||||
protected function saveSubpanelDefinitions ($basepath , $installDefPrefix , $relationshipName , $subpanelDefinitions)
|
||||
{
|
||||
mkdir_recursive ( "$basepath/layoutdefs/" ) ;
|
||||
|
||||
foreach ( $subpanelDefinitions as $moduleName => $definitions )
|
||||
{
|
||||
$filename = "$basepath/layoutdefs/{$relationshipName}_{$moduleName}.php" ;
|
||||
|
||||
foreach ( $definitions as $definition )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->saveSubpanelDefinitions(): saving the following to {$filename}" . print_r ( $definition, true ) ) ;
|
||||
if (empty($definition ['get_subpanel_data']) || $definition ['subpanel_name'] == 'history' || $definition ['subpanel_name'] == 'activities') {
|
||||
$definition ['get_subpanel_data'] = $definition ['subpanel_name'];
|
||||
}
|
||||
write_array_to_file ( 'layout_defs["' . $moduleName . '"]["subpanel_setup"]["' . strtolower ( $definition [ 'get_subpanel_data' ] ) . '"]', $definition, $filename, "a" ) ;
|
||||
}
|
||||
|
||||
$installDefs [ $moduleName ] = array ( 'from' => "{$installDefPrefix}/relationships/layoutdefs/{$relationshipName}_{$moduleName}.php" , 'to_module' => $moduleName ) ;
|
||||
}
|
||||
return $installDefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the installDefs for this relationship to the definitions in the parameter
|
||||
* Required by MBModule
|
||||
* @param reference installDef Reference to the set of installDefs to which this relationship's installDefs should be added
|
||||
*/
|
||||
function addInstallDefs (&$installDef)
|
||||
{
|
||||
foreach ( $this->installDefs as $name => $def )
|
||||
{
|
||||
if (! empty ( $def ))
|
||||
{
|
||||
foreach ( $def as $val )
|
||||
{
|
||||
$installDef [ $name ] [] = $val ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addFieldsToUndeployedLayouts ($relationship)
|
||||
{
|
||||
return $this->updateUndeployedLayout ( $relationship, true ) ;
|
||||
}
|
||||
|
||||
private function removeFieldsFromUndeployedLayouts ($relationship)
|
||||
{
|
||||
return $this->updateUndeployedLayout ( $relationship, false ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add any relate fields to the DetailView and EditView of the appropriate module immediately (don't wait for a build)
|
||||
* @param AbstractRelationship $relationship The relationship whose fields we are to add or remove
|
||||
* @param boolean $actionAdd True if we are to add; false if to remove
|
||||
* return null
|
||||
*/
|
||||
private function updateUndeployedLayout ($relationship , $actionAdd = true)
|
||||
{
|
||||
|
||||
// many-to-many relationships don't have fields so if we have a many-to-many we can just skip this...
|
||||
if ($relationship->getType () == MB_MANYTOMANY)
|
||||
return false ;
|
||||
|
||||
$successful = true ;
|
||||
$layoutAdditions = $relationship->buildFieldsToLayouts () ;
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
|
||||
{
|
||||
foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
|
||||
{
|
||||
$parsedName = AbstractRelationships::parseDeployedModuleName ( $deployedModuleName ) ;
|
||||
if (isset ( $parsedName [ 'packageName' ] ))
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": " . (($actionAdd) ? "adding" : "removing") . " $fieldName on $view layout for undeployed module {$parsedName [ 'moduleName' ]} in package {$parsedName [ 'packageName' ]}" ) ;
|
||||
$parser = new GridLayoutMetaDataParser ( $view, $parsedName [ 'moduleName' ], $parsedName [ 'packageName' ] ) ;
|
||||
|
||||
if (($actionAdd) ? $parser->addField ( array ( 'name' => $fieldName ) ) : $parser->removeField ( $fieldName ))
|
||||
{
|
||||
$parser->handleSave ( false ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": couldn't " . (($actionAdd) ? "add" : "remove") . " $fieldName on $view layout for undeployed module $deployedModuleName" ) ;
|
||||
$successful = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $successful ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add any fields to the DetailView and EditView of the appropriate modules
|
||||
* Only add into deployed modules, as addFieldsToUndeployedLayouts has done this already for undeployed modules (and the admin might have edited the layouts already)
|
||||
* @param string $basepath Basepath location for this module (not used)
|
||||
* @param string $relationshipName Name of this relationship (for uniqueness)
|
||||
* @param array $layoutAdditions An array of module => fieldname
|
||||
* return null
|
||||
*/
|
||||
protected function saveFieldsToLayouts ($basepath , $dummy , $relationshipName , $layoutAdditions)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
|
||||
// these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. In either case, we don't want to attempt to add a relate field to them
|
||||
// would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here
|
||||
$invalidModules = array ( 'emails' , 'kbdocuments' ) ;
|
||||
|
||||
$fieldsToAdd = array();
|
||||
foreach ( $layoutAdditions as $deployedModuleName => $fieldName )
|
||||
{
|
||||
if ( ! in_array( strtolower ( $deployedModuleName ) , $invalidModules ) ) {
|
||||
foreach ( array ( MB_EDITVIEW , MB_DETAILVIEW ) as $view )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": adding $fieldName to $view layout for module $deployedModuleName" ) ;
|
||||
$parsedName = self::parseDeployedModuleName ( $deployedModuleName ) ;
|
||||
if (! isset ( $parsedName [ 'packageName' ] ))
|
||||
{
|
||||
$fieldsToAdd [$parsedName [ 'moduleName' ]] = $fieldName;
|
||||
}
|
||||
//Bug 22348: We should add in the field for custom modules not in this package, if they have been deployed.
|
||||
else if ($parsedName [ 'packageName' ] != $this->packageName
|
||||
&& isset ( $GLOBALS [ 'beanList' ] [ $deployedModuleName ])){
|
||||
$fieldsToAdd [$deployedModuleName] = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(array('additional_fields' => $fieldsToAdd));
|
||||
}
|
||||
|
||||
}
|
||||
301
modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php
Executable file
301
modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php
Executable file
@@ -0,0 +1,301 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
/*
|
||||
* Abstract base clase for Parser Implementations (using a Bridge Pattern)
|
||||
* The Implementations hide the differences between :
|
||||
* - Deployed modules (such as OOB modules and deployed ModuleBuilder modules) that are located in the /modules directory and have metadata in modules/<name>/metadata and in the custom directory
|
||||
* - WIP modules which are being worked on in ModuleBuilder and that are located in custom
|
||||
*/
|
||||
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/History.php' ;
|
||||
|
||||
abstract class AbstractMetaDataImplementation
|
||||
{
|
||||
protected $_view ;
|
||||
protected $_moduleName ;
|
||||
protected $_viewdefs ;
|
||||
protected $_originalViewdefs = array();
|
||||
protected $_fielddefs ;
|
||||
protected $_sourceFilename = '' ; // the name of the file from which we loaded the definition we're working on - needed when we come to write out the historical record
|
||||
// would like this to be a constant, but alas, constants cannot contain arrays...
|
||||
protected $_fileVariables = array (
|
||||
MB_DASHLETSEARCH => 'dashletData',
|
||||
MB_DASHLET => 'dashletData',
|
||||
MB_POPUPSEARCH => 'popupMeta',
|
||||
MB_POPUPLIST => 'popupMeta',
|
||||
MB_LISTVIEW => 'listViewDefs',
|
||||
MB_BASICSEARCH => 'searchdefs',
|
||||
MB_ADVANCEDSEARCH => 'searchdefs',
|
||||
MB_EDITVIEW => 'viewdefs',
|
||||
MB_DETAILVIEW => 'viewdefs',
|
||||
MB_QUICKCREATE => 'viewdefs',
|
||||
) ;
|
||||
|
||||
/*
|
||||
* Getters for the definitions loaded by the Constructor
|
||||
*/
|
||||
function getViewdefs ()
|
||||
{
|
||||
$GLOBALS['log']->debug( get_class ( $this ) . '->getViewdefs:'.print_r($this->_viewdefs,true) ) ;
|
||||
return $this->_viewdefs ;
|
||||
}
|
||||
|
||||
function getOriginalViewdefs() {
|
||||
return $this->_originalViewdefs;
|
||||
}
|
||||
|
||||
function getFielddefs ()
|
||||
{
|
||||
return $this->_fielddefs ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain a new accessor for the history of this layout
|
||||
* Ideally the History object would be a singleton; however given the use case (modulebuilder/studio) it's unlikely to be an issue
|
||||
*/
|
||||
function getHistory ()
|
||||
{
|
||||
return $this->_history ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a layout from a file, given a filename
|
||||
* Doesn't do any preprocessing on the viewdefs - just returns them as found for other classes to make sense of
|
||||
* @param string filename The full path to the file containing the layout
|
||||
* @return array The layout, null if the file does not exist
|
||||
*/
|
||||
protected function _loadFromFile ($filename)
|
||||
{
|
||||
// BEGIN ASSERTIONS
|
||||
if (! file_exists ( $filename ))
|
||||
{
|
||||
return null ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
$GLOBALS['log']->debug(get_class($this)."->_loadFromFile(): reading from ".$filename );
|
||||
require $filename ; // loads the viewdef - must be a require not require_once to ensure can reload if called twice in succession
|
||||
|
||||
// Check to see if we have the module name set as a variable rather than embedded in the $viewdef array
|
||||
// If we do, then we have to preserve the module variable when we write the file back out
|
||||
// This is a format used by ModuleBuilder templated modules to speed the renaming of modules
|
||||
// OOB Sugar modules don't use this format
|
||||
|
||||
$moduleVariables = array ( 'module_name' , '_module_name' , 'OBJECT_NAME' , '_object_name' ) ;
|
||||
|
||||
$variables = array ( ) ;
|
||||
foreach ( $moduleVariables as $name )
|
||||
{
|
||||
if (isset ( $$name ))
|
||||
{
|
||||
$variables [ $name ] = $$name ;
|
||||
}
|
||||
}
|
||||
|
||||
// Extract the layout definition from the loaded file - the layout definition is held under a variable name that varies between the various layout types (e.g., listviews hold it in listViewDefs, editviews in viewdefs)
|
||||
$viewVariable = $this->_fileVariables [ $this->_view ] ;
|
||||
$defs = $$viewVariable ;
|
||||
|
||||
// Now tidy up the module name in the viewdef array
|
||||
// MB created definitions store the defs under packagename_modulename and later methods that expect to find them under modulename will fail
|
||||
|
||||
if (isset ( $variables [ 'module_name' ] ))
|
||||
{
|
||||
$mbName = $variables [ 'module_name' ] ;
|
||||
if ($mbName != $this->_moduleName)
|
||||
{
|
||||
$defs [ $this->_moduleName ] = $defs [ $mbName ] ;
|
||||
unset ( $defs [ $mbName ] ) ;
|
||||
}
|
||||
}
|
||||
$this->_variables = $variables ;
|
||||
// now remove the modulename preamble from the loaded defs
|
||||
reset($defs);
|
||||
$temp = each($defs);
|
||||
|
||||
$GLOBALS['log']->debug( get_class ( $this ) . "->_loadFromFile: returning ".print_r($temp['value'],true)) ;
|
||||
return $temp['value']; // 'value' contains the value part of 'key'=>'value' part
|
||||
}
|
||||
|
||||
|
||||
protected function _loadFromPopupFile ($filename, $mod, $view, $forSave = false)
|
||||
{
|
||||
// BEGIN ASSERTIONS
|
||||
if (!file_exists ( $filename ))
|
||||
{
|
||||
return null ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
$GLOBALS['log']->debug(get_class($this)."->_loadFromFile(): reading from ".$filename );
|
||||
|
||||
if(!empty($mod)){
|
||||
$oldModStrings = $GLOBALS['mod_strings'];
|
||||
$GLOBALS['mod_strings'] = $mod;
|
||||
}
|
||||
|
||||
require $filename ; // loads the viewdef - must be a require not require_once to ensure can reload if called twice in succession
|
||||
$viewVariable = $this->_fileVariables [ $this->_view ] ;
|
||||
$defs = $$viewVariable ;
|
||||
if(!$forSave){
|
||||
//Now we will unset the reserve field in pop definition file.
|
||||
$limitFields = PopupMetaDataParser::$reserveProperties;
|
||||
foreach($limitFields as $v){
|
||||
if(isset($defs[$v])){
|
||||
unset($defs[$v]);
|
||||
}
|
||||
}
|
||||
if(isset($defs[PopupMetaDataParser::$defsMap[$view]])){
|
||||
$defs = $defs[PopupMetaDataParser::$defsMap[$view]];
|
||||
}else{
|
||||
//If there are no defs for this view, grab them from the non-popup view
|
||||
if ($view == MB_POPUPLIST)
|
||||
{
|
||||
$this->_view = MB_LISTVIEW;
|
||||
$defs = $this->_loadFromFile ( $this->getFileName ( MB_LISTVIEW, $this->_moduleName, MB_CUSTOMMETADATALOCATION ) ) ;
|
||||
if ($defs == null)
|
||||
$defs = $this->_loadFromFile ( $this->getFileName ( MB_LISTVIEW, $this->_moduleName, MB_BASEMETADATALOCATION ) ) ;
|
||||
$this->_view = $view;
|
||||
}
|
||||
else if ($view == MB_POPUPSEARCH)
|
||||
{
|
||||
$this->_view = MB_ADVANCEDSEARCH;
|
||||
$defs = $this->_loadFromFile ( $this->getFileName ( MB_ADVANCEDSEARCH, $this->_moduleName, MB_CUSTOMMETADATALOCATION ) ) ;
|
||||
if ($defs == null)
|
||||
$defs = $this->_loadFromFile ( $this->getFileName ( MB_ADVANCEDSEARCH, $this->_moduleName, MB_BASEMETADATALOCATION ) ) ;
|
||||
|
||||
if (isset($defs['layout']) && isset($defs['layout']['advanced_search']))
|
||||
$defs = $defs['layout']['advanced_search'];
|
||||
$this->_view = $view;
|
||||
}
|
||||
if ($defs == null)
|
||||
$defs = array();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_variables = array();
|
||||
if(!empty($oldModStrings)){
|
||||
$GLOBALS['mod_strings'] = $oldModStrings;
|
||||
}
|
||||
return $defs;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a layout to a file
|
||||
* Must be the exact inverse of _loadFromFile
|
||||
* Obtains the additional variables, such as module_name, to include in beginning of the file (as required by ModuleBuilder) from the internal variable _variables, set in the Constructor
|
||||
* @param string filename The full path to the file to contain the layout
|
||||
* @param array defs Array containing the layout definition; the top level should be the definition itself; not the modulename or viewdef= preambles found in the file definitions
|
||||
* @param boolean useVariables Write out with placeholder entries for module name and object name - used by ModuleBuilder modules
|
||||
*/
|
||||
protected function _saveToFile ($filename , $defs , $useVariables = true, $forPopup = false )
|
||||
{
|
||||
|
||||
mkdir_recursive ( dirname ( $filename ) ) ;
|
||||
|
||||
$useVariables = (count ( $this->_variables ) > 0) && $useVariables ; // only makes sense to do the variable replace if we have variables to replace...
|
||||
|
||||
// create the new metadata file contents, and write it out
|
||||
$out = "<?php\n" ;
|
||||
if ($useVariables)
|
||||
{
|
||||
// write out the $<variable>=<modulename> lines
|
||||
foreach ( $this->_variables as $key => $value )
|
||||
{
|
||||
$out .= "\$$key = '" . $value . "';\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
$viewVariable = $this->_fileVariables [ $this->_view ] ;
|
||||
if($forPopup){
|
||||
$out .= "\$$viewVariable = \n" . var_export_helper ( $defs ) ;
|
||||
}else{
|
||||
$out .= "\$$viewVariable [".(($useVariables) ? '$module_name' : "'$this->_moduleName'")."] = \n" . var_export_helper ( $defs ) ;
|
||||
}
|
||||
|
||||
$out .= ";\n?>\n" ;
|
||||
|
||||
if ( file_put_contents ( $filename, $out ) === false)
|
||||
$GLOBALS [ 'log' ]->fatal ( get_class($this).": could not write new viewdef file " . $filename ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fielddefs are obtained from two locations:
|
||||
*
|
||||
* 1. The starting point is the module's fielddefs, sourced from the Bean
|
||||
* 2. Second comes any overrides from the layouts themselves. Note though that only visible fields are included in a layoutdef, which
|
||||
* means fields that aren't present in the current layout may have a layout defined in a lower-priority layoutdef, for example, the base layoutdef
|
||||
*
|
||||
* Thus to determine the current fielddef for any given field, we take the fielddef defined in the module's Bean and then override with first the base layout,
|
||||
* then the customlayout, then finally the working layout...
|
||||
*
|
||||
* The complication is that although generating these merged fielddefs is naturally a method of the implementation, not the parser,
|
||||
* we therefore lack knowledge as to which type of layout we are merging - EditView or ListView. So we can't use internal knowledge of the
|
||||
* layout to locate the field definitions. Instead, we need to look for sections of the layout that match the template for a field definition...
|
||||
*/
|
||||
function _mergeFielddefs ( &$fielddefs , $layout )
|
||||
{
|
||||
foreach ( $layout as $key => $def )
|
||||
{
|
||||
|
||||
if ( (string) $key == 'templateMeta' )
|
||||
continue ;
|
||||
|
||||
if ( is_array ( $def ) )
|
||||
{
|
||||
if ( isset ( $def [ 'name' ] ) && ! is_array ( $def [ 'name' ] ) ) // found a 'name' definition, that is not the definition of a field called name :)
|
||||
{
|
||||
// if this is a module field, then merge in the definition, otherwise this is a new field defined in the layout, so just take the definition
|
||||
$fielddefs [ $def [ 'name'] ] = ( isset ($fielddefs [ $def [ 'name' ] ] ) ) ? array_merge ( $fielddefs [ $def [ 'name' ] ], $def ) : $def ;
|
||||
}
|
||||
else if ( isset ( $def [ 'label' ] ) || isset ( $def [ 'vname' ] ) || isset($def ['widget_class']) ) // dealing with a listlayout which lacks 'name' keys, but which does have 'label' keys
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
$fielddefs [ $key ] = ( isset ($fielddefs [ $key ] ) ) ? array_merge ( $fielddefs [ $key ], $def ) : $def ;
|
||||
}
|
||||
else
|
||||
$this->_mergeFielddefs( $fielddefs , $def ) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
127
modules/ModuleBuilder/parsers/views/AbstractMetaDataParser.php
Executable file
127
modules/ModuleBuilder/parsers/views/AbstractMetaDataParser.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
abstract class AbstractMetaDataParser
|
||||
{
|
||||
|
||||
//Make these properties public for now until we can create some usefull accessors
|
||||
public $_fielddefs ;
|
||||
public $_viewdefs ;
|
||||
protected $_moduleName ;
|
||||
protected $implementation ; // the DeployedMetaDataImplementation or UndeployedMetaDataImplementation object to handle the reading and writing of files and field data
|
||||
|
||||
function getLayoutAsArray ()
|
||||
{
|
||||
$viewdefs = $this->_panels ;
|
||||
}
|
||||
|
||||
function getLanguage ()
|
||||
{
|
||||
return $this->implementation->getLanguage () ;
|
||||
}
|
||||
|
||||
function getHistory ()
|
||||
{
|
||||
return $this->implementation->getHistory () ;
|
||||
}
|
||||
|
||||
function removeField ($fieldName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this field something we wish to show in Studio/ModuleBuilder layout editors?
|
||||
* @param array $def Field definition in the standard SugarBean field definition format - name, vname, type and so on
|
||||
* @return boolean True if ok to show, false otherwise
|
||||
*/
|
||||
static function validField ( $def, $view = "")
|
||||
{
|
||||
//Studio invisible fields should always be hidden
|
||||
if (isset ($def[ 'studio' ] ) )
|
||||
{
|
||||
if (is_array($def [ 'studio' ]))
|
||||
{
|
||||
if (!empty($view) && isset($def [ 'studio' ][$view]))
|
||||
return $def [ 'studio' ][$view] !== false && $def [ 'studio' ][$view] != 'false' && $def [ 'studio' ][$view] != 'hidden';
|
||||
if (isset($def [ 'studio' ]['visible']))
|
||||
return $def [ 'studio' ]['visible'];
|
||||
} else {
|
||||
return ($def [ 'studio' ] != 'false' && $def [ 'studio' ] != 'hidden' && $def [ 'studio' ] !== false) ;
|
||||
}
|
||||
}
|
||||
|
||||
// bug 19656: this test changed after 5.0.0b - we now remove all ID type fields - whether set as type, or dbtype, from the fielddefs
|
||||
return
|
||||
(
|
||||
(
|
||||
(empty ( $def [ 'source' ] ) || $def [ 'source' ] == 'db' || $def [ 'source' ] == 'custom_fields')
|
||||
&& isset($def [ 'type' ]) && $def [ 'type' ] != 'id' && $def [ 'type' ] != 'parent_type'
|
||||
&& (empty ( $def [ 'dbType' ] ) || $def [ 'dbType' ] != 'id')
|
||||
&& ( isset ( $def [ 'name' ] ) && strcmp ( $def [ 'name' ] , 'deleted' ) != 0 )
|
||||
) // db and custom fields that aren't ID fields
|
||||
||
|
||||
// exclude fields named *_name regardless of their type...just convention
|
||||
(isset ( $def [ 'name' ] ) && substr ( $def [ 'name' ], -5 ) === '_name' ) ) ;
|
||||
}
|
||||
|
||||
protected function _standardizeFieldLabels ( &$fielddefs )
|
||||
{
|
||||
foreach ( $fielddefs as $key => $def )
|
||||
{
|
||||
if ( !isset ($def [ 'label' ] ) )
|
||||
{
|
||||
$fielddefs [ $key ] [ 'label'] = ( isset ( $def [ 'vname' ] ) ) ? $def [ 'vname' ] : $key ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract static function _trimFieldDefs ( $def ) ;
|
||||
|
||||
public function getRequiredFields(){
|
||||
$fieldDefs = $this->implementation->getFielddefs();
|
||||
$newAry = array();
|
||||
foreach($fieldDefs as $field){
|
||||
if(isset($field['required']) && $field['required'] && isset($field['name'])){
|
||||
array_push($newAry , '"'.$field['name'].'"');
|
||||
}
|
||||
}
|
||||
return $newAry;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
175
modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php
Executable file
175
modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php
Executable file
@@ -0,0 +1,175 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class DashletMetaDataParser extends ListLayoutMetaDataParser
|
||||
{
|
||||
|
||||
// Columns is used by the view to construct the listview - each column is built by calling the named function
|
||||
public $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Must set:
|
||||
* $this->columns Array of 'Column LBL'=>function_to_retrieve_fields_for_this_column() - expected by the view
|
||||
*
|
||||
* @param string moduleName The name of the module to which this listview belongs
|
||||
* @param string packageName If not empty, the name of the package to which this listview belongs
|
||||
*/
|
||||
function __construct ($view, $moduleName , $packageName = '')
|
||||
{
|
||||
|
||||
$this->search = ($view == MB_DASHLETSEARCH) ? true : false;
|
||||
$this->_moduleName = $moduleName;
|
||||
$this->_packageName = $packageName;
|
||||
$this->_view = $view ;
|
||||
if ($this->search)
|
||||
{
|
||||
$this->columns = array ( 'LBL_DEFAULT' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
parent::__construct ( MB_DASHLETSEARCH, $moduleName, $packageName ) ;
|
||||
} else
|
||||
{
|
||||
parent::__construct ( MB_DASHLET, $moduleName, $packageName ) ;
|
||||
}
|
||||
$this->_viewdefs = $this->mergeFieldDefinitions($this->_viewdefs, $this->_fielddefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashlets contain both a searchview and list view definition, therefore we need to merge only the relevant info
|
||||
*/
|
||||
function mergeFieldDefinitions ( $viewdefs, $fielddefs ) {
|
||||
if ($this->_view == MB_DASHLETSEARCH && isset($viewdefs['searchfields']))
|
||||
{
|
||||
//Remove any relate fields from the possible defs as they will break the homepage
|
||||
foreach($fielddefs as $id=>$def) {
|
||||
if (isset($def['type']) && $def['type'] == 'relate') {
|
||||
if( isset($fielddefs[$id]['id_name'])){
|
||||
$fielddefs[$fielddefs[$id]['id_name']] = $def;
|
||||
unset($fielddefs[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$viewdefs = array_change_key_case($viewdefs['searchfields']);
|
||||
$viewdefs = $this->_viewdefs = $this->convertSearchToListDefs($viewdefs);
|
||||
}
|
||||
else if ($this->_view == MB_DASHLET && isset($viewdefs['columns']))
|
||||
{
|
||||
$viewdefs = $this->_viewdefs = array_change_key_case($viewdefs['columns']);
|
||||
$viewdefs = $this->_viewdefs = $this->convertSearchToListDefs($viewdefs);
|
||||
}
|
||||
|
||||
return $viewdefs;
|
||||
}
|
||||
|
||||
function convertSearchToListDefs($defs) {
|
||||
$temp = array();
|
||||
foreach($defs as $key=>$value) {
|
||||
$temp[$key] = $value;
|
||||
if (!isset ($temp[$key]['name'])) {
|
||||
$temp[$key]['name'] = $key;
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
private function ConvertSearchToDashletDefs($defs) {
|
||||
$temp = array();
|
||||
foreach($defs as $key=>$value) {
|
||||
if($value['default']) {
|
||||
//$temp[$key] = $value;
|
||||
$temp[$key] = array('default' => '');
|
||||
}else{
|
||||
$temp[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
if (empty ( $this->_packageName ))
|
||||
{
|
||||
foreach(array(MB_CUSTOMMETADATALOCATION , MB_BASEMETADATALOCATION) as $value){
|
||||
$file = $this->implementation->getFileName(MB_DASHLET, $this->_moduleName, $value);
|
||||
if(file_exists($file)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$writeTodashletName = $dashletName = $this->implementation->getLanguage().'Dashlet';
|
||||
if(!file_exists($file)){
|
||||
$file = "modules/{$this->_moduleName}/Dashlets/My{$this->_moduleName}Dashlet/My{$this->_moduleName}Dashlet.data.php";
|
||||
$dashletName = 'My'.$this->implementation->getLanguage().'Dashlet';
|
||||
}
|
||||
$writeFile = $this->implementation->getFileName(MB_DASHLET, $this->_moduleName);
|
||||
if(!file_exists($writeFile)){
|
||||
mkdir_recursive ( dirname ( $writeFile ) ) ;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$writeFile = $file = $this->implementation->getFileName(MB_DASHLET, $this->_moduleName, $this->_packageName);
|
||||
$writeTodashletName = $dashletName =$this->implementation->module->key_name . 'Dashlet';
|
||||
}
|
||||
|
||||
$this->implementation->_history->append ( $file ) ;
|
||||
if ($populate)
|
||||
$this->_populateFromRequest() ;
|
||||
$out = "<?php\n" ;
|
||||
|
||||
require($file);
|
||||
if (!isset($dashletData[$dashletName])) {
|
||||
sugar_die ("unable to load Module Dashlet Definition");
|
||||
}
|
||||
if ($fh = sugar_fopen ( $writeFile, 'w' ))
|
||||
{
|
||||
if ($this->_view == MB_DASHLETSEARCH)
|
||||
{
|
||||
$dashletData[$dashletName]['searchFields'] = $this->ConvertSearchToDashletDefs($this->_viewdefs);
|
||||
} else
|
||||
{
|
||||
$dashletData[$dashletName]['columns'] = $this->_viewdefs;
|
||||
}
|
||||
$out .= "\$dashletData['$writeTodashletName']['searchFields'] = " . var_export_helper ($dashletData[$dashletName]['searchFields']) . ";\n";
|
||||
$out .= "\$dashletData['$writeTodashletName']['columns'] = " . var_export_helper ($dashletData[$dashletName]['columns']) . ";\n";
|
||||
fputs ( $fh, $out) ;
|
||||
fclose ( $fh ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
364
modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php
Executable file
364
modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php
Executable file
@@ -0,0 +1,364 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Implementation class (following a Bridge Pattern) for handling loading and saving deployed module metadata
|
||||
* For example, listview or editview viewdefs
|
||||
*/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class DeployedMetaDataImplementation extends AbstractMetaDataImplementation implements MetaDataImplementationInterface
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string $view
|
||||
* @param string $moduleName
|
||||
* @throws Exception Thrown if the provided view doesn't exist for this module
|
||||
*/
|
||||
function __construct ($view , $moduleName)
|
||||
{
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( $this->_fileVariables [ $view ] ))
|
||||
{
|
||||
sugar_die ( get_class ( $this ) . ": View $view is not supported" ) ;
|
||||
}
|
||||
if (! isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] ))
|
||||
{
|
||||
sugar_die ( get_class ( $this ) . ": Modulename $moduleName is not a Deployed Module" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
$this->_view = strtolower ( $view ) ;
|
||||
$this->_moduleName = $moduleName ;
|
||||
|
||||
$module = StudioModuleFactory::getStudioModule( $moduleName ) ;
|
||||
$this->module_dir = $module->seed->module_dir;
|
||||
$fielddefs = $module->getFields();
|
||||
|
||||
$loaded = null ;
|
||||
foreach ( array ( MB_BASEMETADATALOCATION , MB_CUSTOMMETADATALOCATION , MB_WORKINGMETADATALOCATION , MB_HISTORYMETADATALOCATION ) as $type )
|
||||
{
|
||||
$this->_sourceFilename = $this->getFileName ( $view, $moduleName, $type ) ;
|
||||
if($view == MB_POPUPSEARCH || $view == MB_POPUPLIST){
|
||||
global $current_language;
|
||||
$mod = return_module_language($current_language , $moduleName);
|
||||
$layout = $this->_loadFromPopupFile ( $this->_sourceFilename , $mod, $view);
|
||||
}else{
|
||||
$layout = $this->_loadFromFile ( $this->_sourceFilename );
|
||||
}
|
||||
if ( null !== $layout )
|
||||
{
|
||||
// merge in the fielddefs from this layout
|
||||
$this->_mergeFielddefs ( $fielddefs , $layout ) ;
|
||||
$loaded = $layout ;
|
||||
}
|
||||
}
|
||||
|
||||
if ($loaded === null)
|
||||
{
|
||||
switch ( $view )
|
||||
{
|
||||
case MB_QUICKCREATE:
|
||||
// Special handling for QuickCreates - if we don't have a QuickCreate definition in the usual places, then use an EditView
|
||||
|
||||
$loaded = $this->_loadFromFile ( $this->getFileName ( MB_EDITVIEW, $this->_moduleName, MB_BASEMETADATALOCATION ) ) ;
|
||||
|
||||
if ($loaded === null)
|
||||
throw new Exception( get_class ( $this ) . ": cannot convert from EditView to QuickCreate for Module $this->_moduleName - definitions for EditView are missing" ) ;
|
||||
|
||||
// Now change the array index
|
||||
$temp = $loaded [ GridLayoutMetaDataParser::$variableMap [ MB_EDITVIEW ] ] ;
|
||||
unset ( $loaded [ GridLayoutMetaDataParser::$variableMap [ MB_EDITVIEW ] ] ) ;
|
||||
$loaded [ GridLayoutMetaDataParser::$variableMap [ MB_QUICKCREATE ] ] = $temp ;
|
||||
// finally, save out our new definition so that we have a base record for the history to work from
|
||||
$this->_sourceFilename = self::getFileName ( MB_QUICKCREATE, $this->_moduleName, MB_CUSTOMMETADATALOCATION ) ;
|
||||
$this->_saveToFile ( $this->_sourceFilename, $loaded ) ;
|
||||
$this->_mergeFielddefs ( $fielddefs , $loaded ) ;
|
||||
break;
|
||||
|
||||
case MB_DASHLETSEARCH:
|
||||
case MB_DASHLET:
|
||||
$type = $module->getType () ;
|
||||
$this->_sourceFilename = self::getFileName ( $view, $moduleName, MB_CUSTOMMETADATALOCATION ) ;
|
||||
$needSave = false;
|
||||
if(file_exists( "custom/modules/{$moduleName}/metadata/".basename ( $this->_sourceFilename))){
|
||||
$loaded = $this->_loadFromFile ( "custom/modules/{$moduleName}/metadata/".basename ( $this->_sourceFilename) ) ;
|
||||
}
|
||||
elseif(file_exists(
|
||||
"modules/{$moduleName}/Dashlets/My{$moduleName}Dashlet/My{$moduleName}Dashlet.data.php")){
|
||||
$loaded = $this->_loadFromFile ( "modules/{$moduleName}/Dashlets/My{$moduleName}Dashlet/My{$moduleName}Dashlet.data.php");
|
||||
}
|
||||
else{
|
||||
$loaded = $this->_loadFromFile ( "include/SugarObjects/templates/$type/metadata/".basename ( $this->_sourceFilename ) ) ;
|
||||
$needSave = true;
|
||||
}
|
||||
if ($loaded === null)
|
||||
throw new Exception( get_class ( $this ) . ": cannot create dashlet view for module $moduleName - definitions for $view are missing in the SugarObject template for type $type" ) ;
|
||||
$loaded = $this->replaceVariables($loaded, $module);
|
||||
$temp = $this->_moduleName;
|
||||
if($needSave){
|
||||
$this->_moduleName = $this->_moduleName.'Dashlet';
|
||||
$this->_saveToFile ( $this->_sourceFilename, $loaded,false) ; // write out without the placeholder module_name and object
|
||||
$this->_moduleName = $temp;
|
||||
unset($temp);
|
||||
}
|
||||
$this->_mergeFielddefs ( $fielddefs , $loaded ) ;
|
||||
break;
|
||||
case MB_POPUPLIST:
|
||||
case MB_POPUPSEARCH:
|
||||
$type = $module->getType () ;
|
||||
$this->_sourceFilename = self::getFileName ( $view, $moduleName, MB_CUSTOMMETADATALOCATION ) ;
|
||||
|
||||
// Now we can copy the wireless view from the template
|
||||
global $current_language;
|
||||
$mod = return_module_language($current_language , $moduleName);
|
||||
$loadedForWrite = $this->_loadFromPopupFile ( "include/SugarObjects/templates/$type/metadata/".basename ( $this->_sourceFilename ) , $mod, $view, true);
|
||||
if ($loadedForWrite === null)
|
||||
throw new Exception( get_class ( $this ) . ": cannot create popup view for module $moduleName - definitions for $view are missing in the SugarObject template for type $type" ) ;
|
||||
$loadedForWrite = $this->replaceVariables($loadedForWrite, $module);
|
||||
$this->_saveToFile ( $this->_sourceFilename, $loadedForWrite , false , true) ; // write out without the placeholder module_name and object
|
||||
$loaded = $this->_loadFromPopupFile ( "include/SugarObjects/templates/$type/metadata/".basename ( $this->_sourceFilename ) , $mod, $view);
|
||||
$this->_mergeFielddefs ( $fielddefs , $loaded ) ;
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
if ( $loaded === null )
|
||||
throw new Exception( get_class ( $this ) . ": view definitions for View $this->_view and Module $this->_moduleName are missing" ) ;
|
||||
}
|
||||
|
||||
$this->_viewdefs = $loaded ;
|
||||
// Set the original Viewdefs - required to ensure we don't lose fields from the base layout
|
||||
// Check the base location first, then if nothing is there (which for example, will be the case for some QuickCreates, and some mobile layouts - see above)
|
||||
// we need to check the custom location where the derived layouts will be
|
||||
foreach ( array ( MB_BASEMETADATALOCATION , MB_CUSTOMMETADATALOCATION ) as $type )
|
||||
{
|
||||
$sourceFilename = $this->getFileName ( $view, $moduleName, $type ) ;
|
||||
if($view == MB_POPUPSEARCH || $view == MB_POPUPLIST){
|
||||
global $current_language;
|
||||
$mod = return_module_language($current_language , $moduleName);
|
||||
$layout = $this->_loadFromPopupFile ( $sourceFilename , $mod, $view);
|
||||
}else{
|
||||
$layout = $this->_loadFromFile ( $sourceFilename );
|
||||
}
|
||||
if ( null !== ($layout ) )
|
||||
{
|
||||
$this->_originalViewdefs = $layout ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
//For quick create viewdefs, if there is no quickcreatedefs.php under MB_BASEMETADATALOCATION, the original defs is editview defs.
|
||||
if ($view == MB_QUICKCREATE) {
|
||||
foreach(array(MB_QUICKCREATE, MB_EDITVIEW) as $v){
|
||||
$sourceFilename = $this->getFileName($v, $moduleName, MB_BASEMETADATALOCATION ) ;
|
||||
if (file_exists($sourceFilename )) {
|
||||
$layout = $this->_loadFromFile($sourceFilename );
|
||||
if (null !== $layout && isset($layout[GridLayoutMetaDataParser::$variableMap[$v]])) {
|
||||
$layout = array(GridLayoutMetaDataParser::$variableMap[MB_QUICKCREATE] => $layout[GridLayoutMetaDataParser::$variableMap[$v]]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $layout) {
|
||||
$sourceFilename = $this->getFileName($view, $moduleName, MB_CUSTOMMETADATALOCATION );
|
||||
$layout = $this->_loadFromFile($sourceFilename );
|
||||
}
|
||||
|
||||
if (null !== $layout ) {
|
||||
$this->_originalViewdefs = $layout ;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_fielddefs = $fielddefs ;
|
||||
$this->_history = new History ( $this->getFileName ( $view, $moduleName, MB_HISTORYMETADATALOCATION ) ) ;
|
||||
|
||||
}
|
||||
|
||||
function getLanguage ()
|
||||
{
|
||||
return $this->_moduleName ;
|
||||
}
|
||||
|
||||
function getOriginalViewdefs()
|
||||
{
|
||||
return $this->_originalViewdefs;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save a draft layout
|
||||
* @param array defs Layout definition in the same format as received by the constructor
|
||||
*/
|
||||
function save ($defs)
|
||||
{
|
||||
//If we are pulling from the History Location, that means we did a restore, and we need to save the history for the previous file.
|
||||
if ($this->_sourceFilename == $this->getFileName ( $this->_view, $this->_moduleName, MB_HISTORYMETADATALOCATION )) {
|
||||
foreach ( array ( MB_WORKINGMETADATALOCATION , MB_CUSTOMMETADATALOCATION , MB_BASEMETADATALOCATION ) as $type ) {
|
||||
if (file_exists($this->getFileName ( $this->_view, $this->_moduleName, $type ))) {
|
||||
$this->_history->append ( $this->getFileName ( $this->_view, $this->_moduleName, $type )) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_history->append ( $this->_sourceFilename ) ;
|
||||
}
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->save(): writing to " . $this->getFileName ( $this->_view, $this->_moduleName, MB_WORKINGMETADATALOCATION ) ) ;
|
||||
$this->_saveToFile ( $this->getFileName ( $this->_view, $this->_moduleName, MB_WORKINGMETADATALOCATION ), $defs ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deploy a layout
|
||||
* @param array defs Layout definition in the same format as received by the constructor
|
||||
*/
|
||||
function deploy ($defs)
|
||||
{
|
||||
if ($this->_sourceFilename == $this->getFileName ( $this->_view, $this->_moduleName, MB_HISTORYMETADATALOCATION )) {
|
||||
foreach ( array ( MB_WORKINGMETADATALOCATION , MB_CUSTOMMETADATALOCATION , MB_BASEMETADATALOCATION ) as $type ) {
|
||||
if (file_exists($this->getFileName ( $this->_view, $this->_moduleName, $type ))) {
|
||||
$this->_history->append ( $this->getFileName ( $this->_view, $this->_moduleName, $type )) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_history->append ( $this->_sourceFilename ) ;
|
||||
}
|
||||
// when we deploy get rid of the working file; we have the changes in the MB_CUSTOMMETADATALOCATION so no need for a redundant copy in MB_WORKINGMETADATALOCATION
|
||||
// this also simplifies manual editing of layouts. You can now switch back and forth between Studio and manual changes without having to keep these two locations in sync
|
||||
$workingFilename = $this->getFileName ( $this->_view, $this->_moduleName, MB_WORKINGMETADATALOCATION ) ;
|
||||
|
||||
if (file_exists ( $workingFilename ))
|
||||
unlink ( $this->getFileName ( $this->_view, $this->_moduleName, MB_WORKINGMETADATALOCATION ) ) ;
|
||||
$filename = $this->getFileName ( $this->_view, $this->_moduleName, MB_CUSTOMMETADATALOCATION ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->deploy(): writing to " . $filename ) ;
|
||||
$this->_saveToFile ( $filename, $defs ) ;
|
||||
|
||||
// now clear the cache so that the results are immediately visible
|
||||
include_once ('include/TemplateHandler/TemplateHandler.php') ;
|
||||
TemplateHandler::clearCache ( $this->_moduleName ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a full pathname for the requested metadata
|
||||
* Can be called statically
|
||||
* @param string view The view type, that is, EditView, DetailView etc
|
||||
* @param string modulename The name of the module that will use this layout
|
||||
* @param string type
|
||||
*/
|
||||
public static function getFileName ($view , $moduleName , $type = MB_CUSTOMMETADATALOCATION)
|
||||
{
|
||||
|
||||
$pathMap = array ( MB_BASEMETADATALOCATION => '' , MB_CUSTOMMETADATALOCATION => 'custom/' , MB_WORKINGMETADATALOCATION => 'custom/working/' , MB_HISTORYMETADATALOCATION => 'custom/history/' ) ;
|
||||
$type = strtolower ( $type ) ;
|
||||
|
||||
$filenames = array (
|
||||
MB_DASHLETSEARCH => 'dashletviewdefs',
|
||||
MB_DASHLET => 'dashletviewdefs',
|
||||
MB_POPUPSEARCH => 'popupdefs',
|
||||
MB_POPUPLIST => 'popupdefs',
|
||||
MB_LISTVIEW => 'listviewdefs' ,
|
||||
MB_BASICSEARCH => 'searchdefs' ,
|
||||
MB_ADVANCEDSEARCH => 'searchdefs' ,
|
||||
MB_EDITVIEW => 'editviewdefs' ,
|
||||
MB_DETAILVIEW => 'detailviewdefs' ,
|
||||
MB_QUICKCREATE => 'quickcreatedefs',
|
||||
) ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( $pathMap [ $type ] ))
|
||||
{
|
||||
sugar_die ( "DeployedMetaDataImplementation->getFileName(): Type $type is not recognized" ) ;
|
||||
}
|
||||
if (! isset ( $filenames [ $view ] ))
|
||||
{
|
||||
sugar_die ( "DeployedMetaDataImplementation->getFileName(): View $view is not recognized" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
|
||||
|
||||
// Construct filename
|
||||
return $pathMap [ $type ] . 'modules/' . $moduleName . '/metadata/' . $filenames [ $view ] . '.php' ;
|
||||
}
|
||||
|
||||
private function replaceVariables($defs, $module) {
|
||||
$var_values = array(
|
||||
"<object_name>" => $module->seed->object_name,
|
||||
"<_object_name>" => strtolower($module->seed->object_name),
|
||||
"<OBJECT_NAME>" => strtoupper($module->seed->object_name),
|
||||
"<module_name>" => $module->seed->module_dir,
|
||||
'<_module_name>'=> strtolower ( $module->seed->module_dir )
|
||||
);
|
||||
return $this->recursiveVariableReplace($defs, $module, $var_values);
|
||||
}
|
||||
|
||||
public function getModuleDir(){
|
||||
return $this->module_dir;
|
||||
}
|
||||
|
||||
private function recursiveVariableReplace($arr, $module, $replacements) {
|
||||
$ret = array();
|
||||
foreach ($arr as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
$newkey = $key;
|
||||
$val = $this->recursiveVariableReplace($val, $module, $replacements);
|
||||
foreach ($replacements as $var => $rep) {
|
||||
$newkey = str_replace($var, $rep, $newkey);
|
||||
}
|
||||
$ret[$newkey] = $val;
|
||||
} else {
|
||||
$newkey = $key;
|
||||
$newval = $val;
|
||||
foreach ($replacements as $var => $rep) {
|
||||
$newkey = str_replace($var, $rep, $newkey);
|
||||
$newval = str_replace($var, $rep, $newval);
|
||||
}
|
||||
$ret[$newkey] = $newval;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
168
modules/ModuleBuilder/parsers/views/DeployedSubpanelImplementation.php
Executable file
168
modules/ModuleBuilder/parsers/views/DeployedSubpanelImplementation.php
Executable file
@@ -0,0 +1,168 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Changes to AbstractSubpanelImplementation for DeployedSubpanels
|
||||
* The main differences are in the load and save of the definitions
|
||||
* For subpanels we must make use of the SubPanelDefinitions class to do this; this also means that the history mechanism,
|
||||
* which tracks files, not objects, needs us to create an intermediate file representation of the definition that it can manage and restore
|
||||
*/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class DeployedSubpanelImplementation extends AbstractMetaDataImplementation implements MetaDataImplementationInterface
|
||||
{
|
||||
|
||||
const HISTORYFILENAME = 'restored.php' ;
|
||||
const HISTORYVARIABLENAME = 'layout_defs' ;
|
||||
|
||||
private $_subpanelName ;
|
||||
private $_aSubPanelObject ; // an aSubPanel Object representing the current subpanel
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string subpanelName The name of this subpanel
|
||||
* @param string moduleName The name of the module to which this subpanel belongs
|
||||
*/
|
||||
function __construct ($subpanelName , $moduleName)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->__construct($subpanelName , $moduleName)" ) ;
|
||||
$this->_subpanelName = $subpanelName ;
|
||||
$this->_moduleName = $moduleName ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( $GLOBALS [ 'beanList' ] [ $moduleName ] ))
|
||||
{
|
||||
sugar_die ( get_class ( $this ) . ": Modulename $moduleName is not a Deployed Module" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
$this->historyPathname = 'custom/history/modules/' . $moduleName . '/subpanels/' . $subpanelName . '/' . self::HISTORYFILENAME ;
|
||||
$this->_history = new History ( $this->historyPathname ) ;
|
||||
|
||||
$module = get_module_info ( $moduleName ) ;
|
||||
|
||||
require_once ('include/SubPanel/SubPanelDefinitions.php') ;
|
||||
// retrieve the definitions for all the available subpanels for this module from the subpanel
|
||||
$spd = new SubPanelDefinitions ( $module ) ;
|
||||
|
||||
// Get the lists of fields already in the subpanel and those that can be added in
|
||||
// Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object
|
||||
$this->_viewdefs = array ( ) ;
|
||||
$this->_fielddefs = array ( ) ;
|
||||
$this->_language = '' ;
|
||||
if (! empty ( $spd->layout_defs ))
|
||||
if (array_key_exists ( strtolower ( $subpanelName ), $spd->layout_defs [ 'subpanel_setup' ] ))
|
||||
{
|
||||
//First load the original defs from the module folder
|
||||
$originalSubpanel = $spd->load_subpanel( $subpanelName , false, true);
|
||||
$this->_fullFielddefs = $originalSubpanel->get_list_fields ();
|
||||
$this->_mergeFielddefs ( $this->_fielddefs , $this->_fullFielddefs ) ;
|
||||
|
||||
$this->_aSubPanelObject = $spd->load_subpanel ( $subpanelName ) ;
|
||||
// now check if there is a restored subpanel in the history area - if there is, then go ahead and use it
|
||||
if (file_exists ( $this->historyPathname ))
|
||||
{
|
||||
// load in the subpanelDefOverride from the history file
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": loading from history" ) ;
|
||||
require $this->historyPathname ;
|
||||
$this->_viewdefs = $layout_defs;
|
||||
} else
|
||||
{
|
||||
$this->_viewdefs = $this->_aSubPanelObject->get_list_fields () ;
|
||||
}
|
||||
|
||||
// don't attempt to access the template_instance property if our subpanel represents a collection, as it won't be there - the sub-sub-panels get this value instead
|
||||
if ( ! $this->_aSubPanelObject->isCollection() )
|
||||
$this->_language = $this->_aSubPanelObject->template_instance->module_dir ;
|
||||
|
||||
// Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout
|
||||
$subPanelParentModuleName = $this->_aSubPanelObject->get_module_name () ;
|
||||
$beanListLower = array_change_key_case ( $GLOBALS [ 'beanList' ] ) ;
|
||||
if (! empty ( $subPanelParentModuleName ) && isset ( $beanListLower [ strtolower ( $subPanelParentModuleName ) ] ))
|
||||
{
|
||||
$subPanelParentModule = get_module_info ( $subPanelParentModuleName ) ;
|
||||
|
||||
// Run through the preliminary list, keeping only those fields that are valid to include in a layout
|
||||
foreach ( $subPanelParentModule->field_defs as $key => $def )
|
||||
{
|
||||
$key = strtolower ( $key ) ;
|
||||
|
||||
if (AbstractMetaDataParser::validField( $def ))
|
||||
{
|
||||
if ( ! isset ( $def [ 'label' ] ) )
|
||||
$def [ 'label' ] = $def [ 'name' ] ;
|
||||
$this->_fielddefs [ $key ] = $def ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_mergeFielddefs ( $this->_fielddefs , $this->_viewdefs ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getLanguage ()
|
||||
{
|
||||
return $this->_language ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a definition that will be used to display a subpanel for $this->_moduleName
|
||||
* @param array defs Layout definition in the same format as received by the constructor
|
||||
*/
|
||||
function deploy ($defs)
|
||||
{
|
||||
// first sort out the historical record...
|
||||
write_array_to_file ( self::HISTORYVARIABLENAME, $this->_viewdefs, $this->historyPathname, 'w', '' ) ;
|
||||
$this->_history->append ( $this->historyPathname ) ;
|
||||
|
||||
$this->_viewdefs = $defs ;
|
||||
|
||||
require_once 'include/SubPanel/SubPanel.php' ;
|
||||
$subpanel = new SubPanel ( $this->_moduleName, 'fab4', $this->_subpanelName , $this->_aSubPanelObject ) ;
|
||||
|
||||
$subpanel->saveSubPanelDefOverride ( $this->_aSubPanelObject, 'list_fields', $defs ) ;
|
||||
// now clear the cache so that the results are immediately visible
|
||||
include_once ('include/TemplateHandler/TemplateHandler.php') ;
|
||||
TemplateHandler::clearCache ( $this->_moduleName ) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
723
modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php
Executable file
723
modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php
Executable file
@@ -0,0 +1,723 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/views/AbstractMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataParserInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class GridLayoutMetaDataParser extends AbstractMetaDataParser implements MetaDataParserInterface
|
||||
{
|
||||
|
||||
static $variableMap = array (
|
||||
MB_EDITVIEW => 'EditView' ,
|
||||
MB_DETAILVIEW => 'DetailView' ,
|
||||
MB_QUICKCREATE => 'QuickCreate',
|
||||
) ;
|
||||
|
||||
protected $FILLER ;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string view The view type, that is, editview, searchview etc
|
||||
* @param string moduleName The name of the module to which this view belongs
|
||||
* @param string packageName If not empty, the name of the package to which this view belongs
|
||||
*/
|
||||
function __construct ($view , $moduleName , $packageName = '')
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->__construct( {$view} , {$moduleName} , {$packageName} )" ) ;
|
||||
|
||||
$view = strtolower ( $view ) ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( self::$variableMap [ $view ] ) )
|
||||
sugar_die ( get_class ( $this ) . ": View $view is not supported" ) ;
|
||||
// END ASSERTIONS
|
||||
|
||||
$this->FILLER = array ( 'name' => MBConstants::$FILLER['name'] , 'label' => translate ( MBConstants::$FILLER['label'] ) ) ;
|
||||
|
||||
$this->_moduleName = $moduleName ;
|
||||
$this->_view = $view ;
|
||||
|
||||
if (empty ( $packageName ))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new DeployedMetaDataImplementation ( $view, $moduleName, self::$variableMap ) ;
|
||||
} else
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new UndeployedMetaDataImplementation ( $view, $moduleName, $packageName ) ;
|
||||
}
|
||||
|
||||
$viewdefs = $this->implementation->getViewdefs () ;
|
||||
|
||||
if (! isset ( $viewdefs [ self::$variableMap [ $view ] ] ))
|
||||
sugar_die ( get_class ( $this ) . ": missing variable " . self::$variableMap [ $view ] . " in layout definition" ) ;
|
||||
|
||||
$viewdefs = $viewdefs [ self::$variableMap [ $view ] ] ;
|
||||
if (! isset ( $viewdefs [ 'templateMeta' ] ))
|
||||
sugar_die ( get_class ( $this ) . ": missing templateMeta section in layout definition (case sensitive)" ) ;
|
||||
|
||||
if (! isset ( $viewdefs [ 'panels' ] ))
|
||||
sugar_die ( get_class ( $this ) . ": missing panels section in layout definition (case sensitive)" ) ;
|
||||
|
||||
$this->_viewdefs = $viewdefs ;
|
||||
if ($this->getMaxColumns () < 1)
|
||||
sugar_die ( get_class ( $this ) . ": maxColumns=" . $this->getMaxColumns () . " - must be greater than 0!" ) ;
|
||||
|
||||
$this->_fielddefs = $this->implementation->getFielddefs() ;
|
||||
$this->_standardizeFieldLabels( $this->_fielddefs );
|
||||
$this->_viewdefs [ 'panels' ] = $this->_convertFromCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ; // put into our internal format
|
||||
$this->_originalViewDef = $this->getFieldsFromLayout($this->implementation->getOriginalViewdefs ());
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a draft layout
|
||||
*/
|
||||
function writeWorkingFile ()
|
||||
{
|
||||
$this->_populateFromRequest ( $this->_fielddefs ) ;
|
||||
$viewdefs = $this->_viewdefs ;
|
||||
$viewdefs [ 'panels' ] = $this->_convertToCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ;
|
||||
$this->implementation->save ( array ( self::$variableMap [ $this->_view ] => $viewdefs ) ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deploy the layout
|
||||
* @param boolean $populate If true (default), then update the layout first with new layout information from the $_REQUEST array
|
||||
*/
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->handleSave()" ) ;
|
||||
|
||||
if ($populate)
|
||||
$this->_populateFromRequest ( $this->_fielddefs ) ;
|
||||
|
||||
$viewdefs = $this->_viewdefs ;
|
||||
$viewdefs [ 'panels' ] = $this->_convertToCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ;
|
||||
$this->implementation->deploy ( array ( self::$variableMap [ $this->_view ] => $viewdefs ) ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the layout, padded out with (empty) and (filler) fields ready for display
|
||||
*/
|
||||
function getLayout ()
|
||||
{
|
||||
$viewdefs = array () ;
|
||||
$fielddefs = $this->_fielddefs;
|
||||
$fielddefs [ $this->FILLER [ 'name' ] ] = $this->FILLER ;
|
||||
$fielddefs [ MBConstants::$EMPTY [ 'name' ] ] = MBConstants::$EMPTY ;
|
||||
|
||||
foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
|
||||
{
|
||||
foreach ( $panel as $rowID => $row )
|
||||
{
|
||||
foreach ( $row as $colID => $fieldname )
|
||||
{
|
||||
if (isset ($this->_fielddefs [ $fieldname ]))
|
||||
{
|
||||
$viewdefs [ $panelID ] [ $rowID ] [ $colID ] = self::_trimFieldDefs( $this->_fielddefs [ $fieldname ] ) ;
|
||||
}
|
||||
else if (isset($this->_originalViewDef [ $fieldname ]) && is_array($this->_originalViewDef [ $fieldname ]))
|
||||
{
|
||||
$viewdefs [ $panelID ] [ $rowID ] [ $colID ] = self::_trimFieldDefs( $this->_originalViewDef [ $fieldname ] ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
$viewdefs [ $panelID ] [ $rowID ] [ $colID ] = array("name" => $fieldname, "label" => $fieldname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $viewdefs ;
|
||||
}
|
||||
|
||||
function getMaxColumns ()
|
||||
{
|
||||
if (!empty( $this->_viewdefs) && isset($this->_viewdefs [ 'templateMeta' ] [ 'maxColumns' ]))
|
||||
{
|
||||
return $this->_viewdefs [ 'templateMeta' ] [ 'maxColumns' ] ;
|
||||
}else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
function getAvailableFields ()
|
||||
{
|
||||
|
||||
// Obtain the full list of valid fields in this module
|
||||
$availableFields = array () ;
|
||||
foreach ( $this->_fielddefs as $key => $def )
|
||||
{
|
||||
if ( AbstractMetaDataParser::validField ( $def, $this->_view ) || isset($this->_originalViewDef[$key]) )
|
||||
{
|
||||
//If the field original label existing, we should use the original label instead the label in its fielddefs.
|
||||
if(isset($this->_originalViewDef[$key]) && is_array($this->_originalViewDef[$key]) && isset($this->_originalViewDef[$key]['label'])){
|
||||
$availableFields [ $key ] = array ( 'name' => $key , 'label' => $this->_originalViewDef[$key]['label']) ;
|
||||
}else{
|
||||
$availableFields [ $key ] = array ( 'name' => $key , 'label' => isset($def [ 'label' ]) ? $def [ 'label' ] : $def['vname'] ) ; // layouts use 'label' not 'vname' for the label entry
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Available fields are those that are in the Model and the original layout definition, but not already shown in the View
|
||||
// So, because the formats of the two are different we brute force loop through View and unset the fields we find in a copy of Model
|
||||
if (! empty ( $this->_viewdefs ))
|
||||
{
|
||||
foreach ( $this->_viewdefs [ 'panels' ] as $panel )
|
||||
{
|
||||
foreach ( $panel as $row )
|
||||
{
|
||||
foreach ( $row as $field )
|
||||
{
|
||||
unset ( $availableFields [ $field ] ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $availableFields ;
|
||||
}
|
||||
|
||||
function getPanelDependency ( $panelID )
|
||||
{
|
||||
if ( ! isset ( $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] ) && ! isset ( $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] [ $panelID ] ) )
|
||||
return false;
|
||||
|
||||
return $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] [ $panelID ] ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new field to the layout
|
||||
* If $panelID is passed in, attempt to add to that panel, otherwise add to the first panel
|
||||
* The field is added in place of the first empty (not filler) slot after the last field in the panel; if that row is full, then a new row will be added to the end of the panel
|
||||
* and the field added to the start of it.
|
||||
* @param array $def Set of properties for the field, in same format as in the viewdefs
|
||||
* @param string $panelID Identifier of the panel to add the field to; empty or false if we should use the first panel
|
||||
*/
|
||||
function addField ( $def , $panelID = FALSE)
|
||||
{
|
||||
|
||||
if (count ( $this->_viewdefs [ 'panels' ] ) == 0)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->error ( get_class ( $this ) . "->addField(): _viewdefs empty for module {$this->_moduleName} and view {$this->_view}" ) ;
|
||||
}
|
||||
|
||||
// if a panelID was not provided, use the first available panel in the list
|
||||
if (! $panelID)
|
||||
{
|
||||
$panels = array_keys ( $this->_viewdefs [ 'panels' ] ) ;
|
||||
list ( $dummy, $panelID ) = each ( $panels ) ;
|
||||
}
|
||||
|
||||
if (isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ))
|
||||
{
|
||||
|
||||
$panel = $this->_viewdefs [ 'panels' ] [ $panelID ] ;
|
||||
$lastrow = count ( $panel ) - 1 ; // index starts at 0
|
||||
$maxColumns = $this->getMaxColumns () ;
|
||||
for ( $column = 0 ; $column < $maxColumns ; $column ++ )
|
||||
{
|
||||
if (! isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] [ $column ] ) || ($this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] [ $column ] [ 'name' ] == '(empty)'))
|
||||
break ;
|
||||
}
|
||||
|
||||
// if we're on the last column of the last row, start a new row
|
||||
if ($column >= $maxColumns)
|
||||
{
|
||||
$lastrow ++ ;
|
||||
$this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] = array ( ) ;
|
||||
$column = 0 ;
|
||||
}
|
||||
|
||||
$this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] [ $column ] = $def [ 'name' ] ;
|
||||
// now update the fielddefs
|
||||
if (isset($this->_fielddefs [ $def [ 'name' ] ]))
|
||||
{
|
||||
$this->_fielddefs [ $def [ 'name' ] ] = array_merge ( $this->_fielddefs [ $def [ 'name' ] ] , $def ) ;
|
||||
} else
|
||||
{
|
||||
$this->_fielddefs [ $def [ 'name' ] ] = $def;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all instances of a field from the layout, and replace by (filler)
|
||||
* Filler because we attempt to preserve the customized layout as much as possible - replacing by (empty) would mean that the positions or sizes of adjacent fields may change
|
||||
* If the last row of a panel only consists of (filler) after removing the fields, then remove the row also. This undoes the standard addField() scenario;
|
||||
* If the fields had been moved around in the layout however then this will not completely undo any addField()
|
||||
* @param string $fieldName Name of the field to remove
|
||||
* @return boolean True if the field was removed; false otherwise
|
||||
*/
|
||||
function removeField ($fieldName)
|
||||
{
|
||||
$GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->removeField($fieldName)" ) ;
|
||||
|
||||
$result = false ;
|
||||
reset ( $this->_viewdefs ) ;
|
||||
$firstPanel = each ( $this->_viewdefs [ 'panels' ] ) ;
|
||||
$firstPanelID = $firstPanel [ 'key' ] ;
|
||||
|
||||
foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
|
||||
{
|
||||
$lastRowTouched = false ;
|
||||
$lastRowID = count ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) - 1 ; // zero offset
|
||||
|
||||
foreach ( $panel as $rowID => $row )
|
||||
{
|
||||
|
||||
foreach ( $row as $colID => $field )
|
||||
if ($field == $fieldName)
|
||||
{
|
||||
$lastRowTouched = $rowID ;
|
||||
$this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] = $this->FILLER [ 'name' ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if we removed a field from the last row of this panel, tidy up if the last row now consists only of (empty) or (filler)
|
||||
|
||||
if ( $lastRowTouched == $lastRowID )
|
||||
{
|
||||
$lastRow = $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastRowID ] ; // can't use 'end' for this as we need the key as well as the value...
|
||||
|
||||
$empty = true ;
|
||||
|
||||
foreach ( $lastRow as $colID => $field )
|
||||
$empty &= $field == MBConstants::$EMPTY ['name' ] || $field == $this->FILLER [ 'name' ] ;
|
||||
|
||||
if ($empty)
|
||||
{
|
||||
unset ( $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastRowID ] ) ;
|
||||
// if the row was the only one in the panel, and the panel is not the first (default) panel, then remove the panel also
|
||||
if ( count ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) == 0 && $panelID != $firstPanelID )
|
||||
unset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result |= ($lastRowTouched !== false ); // explicitly compare to false as row 0 will otherwise evaluate as false
|
||||
}
|
||||
|
||||
return $result ;
|
||||
|
||||
}
|
||||
|
||||
function setPanelDependency ( $panelID , $dependency )
|
||||
{
|
||||
// only accept dependencies for pre-existing panels
|
||||
if ( ! isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) )
|
||||
return false;
|
||||
|
||||
$this->_viewdefs [ 'templateMeta' ] [ 'dependency' ] [ $panelID ] = $dependency ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return an integer value for the next unused panel identifier, such that it and any larger numbers are guaranteed to be unused already in the layout
|
||||
* Necessary when adding new panels to a layout
|
||||
* @return integer First unique panel ID suffix
|
||||
*/
|
||||
function getFirstNewPanelId ()
|
||||
{
|
||||
$firstNewPanelId = 0 ;
|
||||
foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
|
||||
{
|
||||
// strip out all but the numerics from the panelID - can't just use a cast as numbers may not be first in the string
|
||||
for ( $i = 0, $result = '' ; $i < strlen ( $panelID ) ; $i ++ )
|
||||
{
|
||||
if (is_numeric ( $panelID [ $i ] ))
|
||||
{
|
||||
$result .= $panelID [ $i ] ;
|
||||
}
|
||||
}
|
||||
|
||||
$firstNewPanelId = max ( ( int ) $result, $firstNewPanelId ) ;
|
||||
}
|
||||
return $firstNewPanelId + 1 ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the panel layout from the submitted form and update the _viewdefs
|
||||
*/
|
||||
protected function _populateFromRequest ( &$fielddefs )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->populateFromRequest()" ) ;
|
||||
$i = 1 ;
|
||||
|
||||
// set up the map of panel# (as provided in the _REQUEST) to panel ID (as used in $this->_viewdefs['panels'])
|
||||
$i = 1 ;
|
||||
foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
|
||||
{
|
||||
$panelMap [ $i ++ ] = $panelID ;
|
||||
}
|
||||
|
||||
foreach ( $_REQUEST as $key => $displayLabel )
|
||||
{
|
||||
$components = explode ( '-', $key ) ;
|
||||
if ($components [ 0 ] == 'panel' && $components [ 2 ] == 'label')
|
||||
{
|
||||
$panelMap [ $components [ '1' ] ] = $displayLabel ;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_viewdefs [ 'panels' ] = array () ; // because the new field properties should replace the old fields, not be merged
|
||||
|
||||
// run through the $_REQUEST twice - first to obtain the fieldnames, the second to update the field properties
|
||||
for ( $pass=1 ; $pass<=2 ; $pass++ )
|
||||
{
|
||||
foreach ( $_REQUEST as $slot => $value )
|
||||
{
|
||||
$slotComponents = explode ( '-', $slot ) ; // [0] = 'slot', [1] = panel #, [2] = slot #, [3] = property name
|
||||
|
||||
if ($slotComponents [ 0 ] == 'slot')
|
||||
{
|
||||
$slotNumber = $slotComponents [ '2' ] ;
|
||||
$panelID = $panelMap [ $slotComponents [ '1' ] ] ;
|
||||
$rowID = floor ( $slotNumber / $this->getMaxColumns () ) ;
|
||||
$colID = $slotNumber - ($rowID * $this->getMaxColumns ()) ;
|
||||
$property = $slotComponents [ '3' ] ;
|
||||
|
||||
//If this field has a custom definition, copy that over
|
||||
if ( $pass == 1 )
|
||||
{
|
||||
if ( $property == 'name' )
|
||||
$this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] = $value ;
|
||||
} else
|
||||
{
|
||||
// update fielddefs for this property in the provided position
|
||||
if ( isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] ) )
|
||||
{
|
||||
$fieldname = $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] ;
|
||||
$fielddefs [ $fieldname ] [ $property ] = $value ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Set the tabs setting
|
||||
if (isset($_REQUEST['panels_as_tabs']))
|
||||
{
|
||||
if ($_REQUEST['panels_as_tabs'] == false || $_REQUEST['panels_as_tabs'] == "false")
|
||||
$this->setUseTabs( false );
|
||||
else
|
||||
$this->setUseTabs( true );
|
||||
}
|
||||
|
||||
$GLOBALS [ 'log' ]->debug ( print_r ( $this->_viewdefs [ 'panels' ], true ) ) ;
|
||||
|
||||
}
|
||||
|
||||
/* Convert our internal format back to the standard Canonical MetaData layout
|
||||
* First non-(empty) field goes in at column 0; all other (empty)'s removed
|
||||
* Studio required fields are also added to the layout.
|
||||
* Do this AFTER reading in all the $_REQUEST parameters as can't guarantee the order of those, and we need to operate on complete rows
|
||||
*/
|
||||
protected function _convertToCanonicalForm ( $panels , $fielddefs )
|
||||
{
|
||||
$previousViewDef = $this->getFieldsFromLayout($this->implementation->getViewdefs ());
|
||||
$oldDefs = $this->implementation->getViewdefs ();
|
||||
$currentFields = $this->getFieldsFromLayout($this->_viewdefs);
|
||||
foreach($fielddefs as $field => $def)
|
||||
{
|
||||
if (self::fieldIsRequired($def) && !isset($currentFields[$field]))
|
||||
{
|
||||
//Use the previous viewdef if this field was on it.
|
||||
if (isset($previousViewDef[$field]))
|
||||
{
|
||||
$def = $previousViewDef[$field];
|
||||
}
|
||||
//next see if the field was on the original layout.
|
||||
else if (isset ($this->_originalViewDef [ $field ]))
|
||||
{
|
||||
$def = $this->_originalViewDef [ $field ] ;
|
||||
}
|
||||
//Otherwise make up a viewdef for it from field_defs
|
||||
else
|
||||
{
|
||||
$def = self::_trimFieldDefs( $def ) ;
|
||||
}
|
||||
$this->addField($def);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $panels as $panelID => $panel )
|
||||
{
|
||||
// remove all (empty)s
|
||||
foreach ( $panel as $rowID => $row )
|
||||
{
|
||||
$startOfRow = true ;
|
||||
$offset = 0 ;
|
||||
foreach ( $row as $colID => $fieldname )
|
||||
{
|
||||
if ($fieldname == MBConstants::$EMPTY[ 'name' ])
|
||||
{
|
||||
// if a leading (empty) then remove (by noting that remaining fields need to be shuffled along)
|
||||
if ($startOfRow)
|
||||
{
|
||||
$offset ++ ;
|
||||
}
|
||||
unset ( $row [ $colID ] ) ;
|
||||
} else
|
||||
{
|
||||
$startOfRow = false ;
|
||||
}
|
||||
}
|
||||
|
||||
// reindex to remove leading (empty)s and replace fieldnames by full definition from fielddefs
|
||||
$newRow = array ( ) ;
|
||||
foreach ( $row as $colID => $fieldname )
|
||||
{
|
||||
if ($fieldname == null)
|
||||
continue;
|
||||
|
||||
//Backwards compatibility and a safeguard against multiple calls to _convertToCanonicalForm
|
||||
if(is_array($fieldname))
|
||||
{
|
||||
$newRow [ $colID - $offset ] = $fieldname;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Replace (filler) with the empty string
|
||||
if ($fieldname == $this->FILLER[ 'name' ]) {
|
||||
$newRow [ $colID - $offset ] = '' ;
|
||||
}
|
||||
//Use the previous viewdef if this field was on it.
|
||||
else if (isset($previousViewDef[$fieldname]))
|
||||
{
|
||||
$newRow [ $colID - $offset ] = $previousViewDef[$fieldname];
|
||||
//We should copy over the tabindex if it is set.
|
||||
if (isset ($fielddefs [ $fieldname ]) && !empty($fielddefs [ $fieldname ]['tabindex']))
|
||||
$newRow [ $colID - $offset ]['tabindex'] = $fielddefs [ $fieldname ]['tabindex'];
|
||||
}
|
||||
//next see if the field was on the original layout.
|
||||
else if (isset ($this->_originalViewDef [ $fieldname ]))
|
||||
{
|
||||
$newRow [ $colID - $offset ] = $this->_originalViewDef [ $fieldname ] ;
|
||||
//We should copy over the tabindex if it is set.
|
||||
if (isset ($fielddefs [ $fieldname ]) && !empty($fielddefs [ $fieldname ]['tabindex']))
|
||||
$newRow [ $colID - $offset ]['tabindex'] = $fielddefs [ $fieldname ]['tabindex'];
|
||||
}
|
||||
//Otherwise make up a viewdef for it from field_defs
|
||||
else if (isset ($fielddefs [ $fieldname ]))
|
||||
{
|
||||
$newRow [ $colID - $offset ] = self::_trimFieldDefs( $fielddefs [ $fieldname ] ) ;
|
||||
|
||||
}
|
||||
//No additional info on this field can be found, jsut use the name;
|
||||
else
|
||||
{
|
||||
$newRow [ $colID - $offset ] = $fieldname;
|
||||
}
|
||||
}
|
||||
$panels [ $panelID ] [ $rowID ] = $newRow ;
|
||||
}
|
||||
}
|
||||
|
||||
return $panels ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert from the standard MetaData format to our internal format
|
||||
* Replace NULL with (filler) and missing entries with (empty)
|
||||
*/
|
||||
protected function _convertFromCanonicalForm ( $panels , $fielddefs )
|
||||
{
|
||||
if (empty ( $panels ))
|
||||
return ;
|
||||
|
||||
// Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined,
|
||||
// it goes straight into rows
|
||||
// See EditView2 for similar treatment
|
||||
if (! empty ( $panels ) && count ( $panels ) > 0)
|
||||
{
|
||||
$keys = array_keys ( $panels ) ;
|
||||
if (is_numeric ( $keys [ 0 ] ))
|
||||
{
|
||||
$defaultPanel = $panels ;
|
||||
unset ( $panels ) ; //blow away current value
|
||||
$panels [ 'default' ] = $defaultPanel ;
|
||||
}
|
||||
}
|
||||
|
||||
$newPanels = array ( ) ;
|
||||
|
||||
// replace '' with (filler)
|
||||
foreach ( $panels as $panelID => $panel )
|
||||
{
|
||||
foreach ( $panel as $rowID => $row )
|
||||
{
|
||||
$cols = 0;
|
||||
foreach ( $row as $colID => $col )
|
||||
{
|
||||
if ( ! empty ( $col ) )
|
||||
{
|
||||
if ( is_string ( $col ))
|
||||
{
|
||||
$fieldname = $col ;
|
||||
} else if (! empty ( $col [ 'name' ] ))
|
||||
{
|
||||
$fieldname = $col [ 'name' ] ;
|
||||
}
|
||||
} else
|
||||
{
|
||||
$fieldname = $this->FILLER['name'] ;
|
||||
}
|
||||
|
||||
$newPanels [ $panelID ] [ $rowID ] [ $cols ] = $fieldname ;
|
||||
$cols++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// replace missing fields with (empty)
|
||||
foreach ( $newPanels as $panelID => $panel )
|
||||
{
|
||||
$column = 0 ;
|
||||
foreach ( $panel as $rowID => $row )
|
||||
{
|
||||
// pad between fields on a row
|
||||
foreach ( $row as $colID => $col )
|
||||
{
|
||||
for ( $i = $column + 1 ; $i < $colID ; $i ++ )
|
||||
{
|
||||
$row [ $i ] = MBConstants::$EMPTY ['name'];
|
||||
}
|
||||
$column = $colID ;
|
||||
}
|
||||
// now pad out to the end of the row
|
||||
if (($column + 1) < $this->getMaxColumns ())
|
||||
{ // last column is maxColumns-1
|
||||
for ( $i = $column + 1 ; $i < $this->getMaxColumns () ; $i ++ )
|
||||
{
|
||||
$row [ $i ] = MBConstants::$EMPTY ['name'] ;
|
||||
}
|
||||
}
|
||||
ksort ( $row ) ;
|
||||
$newPanels [ $panelID ] [ $rowID ] = $row ;
|
||||
}
|
||||
}
|
||||
|
||||
return $newPanels ;
|
||||
}
|
||||
|
||||
protected function getFieldsFromLayout($viewdef) {
|
||||
if (isset($viewdef['panels']))
|
||||
{
|
||||
$panels = $viewdef['panels'];
|
||||
} else {
|
||||
$panels = $viewdef[self::$variableMap [ $this->_view ] ]['panels'];
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
if (is_array($panels))
|
||||
{
|
||||
foreach ( $panels as $rows) {
|
||||
foreach ($rows as $fields) {
|
||||
//wireless layouts have one less level of depth
|
||||
if (is_array($fields) && isset($fields['name'])) {
|
||||
$ret[$fields['name']] = $fields;
|
||||
continue;
|
||||
}
|
||||
if (!is_array($fields)) {
|
||||
$ret[$fields] = $fields;
|
||||
continue;
|
||||
}
|
||||
foreach ($fields as $field) {
|
||||
if (is_array($field) && !empty($field['name']))
|
||||
{
|
||||
$ret[$field['name']] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function fieldIsRequired($def)
|
||||
{
|
||||
if (isset($def['studio']))
|
||||
{
|
||||
if (is_array($def['studio']))
|
||||
{
|
||||
if (!empty($def['studio'][$this->_view]) && $def['studio'][$this->_view] == "required")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!empty($def['studio']['required']) && $def['studio']['required'] == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ($def['studio'] == "required" ){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static function _trimFieldDefs ( $def )
|
||||
{
|
||||
$ret = array_intersect_key ( $def ,
|
||||
array ( 'studio' => true , 'name' => true , 'label' => true , 'displayParams' => true , 'comment' => true ,
|
||||
'customCode' => true , 'customLabel' => true , 'tabIndex' => true , 'hideLabel' => true) ) ;
|
||||
if (!empty($def['vname']) && empty($def['label']))
|
||||
$ret['label'] = $def['vname'];
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getUseTabs(){
|
||||
if (isset($this->_viewdefs [ 'templateMeta' ]['useTabs']))
|
||||
return $this->_viewdefs [ 'templateMeta' ]['useTabs'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setUseTabs($useTabs){
|
||||
$this->_viewdefs [ 'templateMeta' ]['useTabs'] = $useTabs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
218
modules/ModuleBuilder/parsers/views/History.php
Executable file
218
modules/ModuleBuilder/parsers/views/History.php
Executable file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class History
|
||||
{
|
||||
|
||||
private $_dirname ; // base directory for the history files
|
||||
private $_basename ; // base name for a history file, for example, listviewdef.php
|
||||
private $_list ; // the history - a list of history files
|
||||
|
||||
private $_previewFilename ; // the location of a file for preview
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string $previewFilename The filename which the caller expects for a preview file
|
||||
*/
|
||||
function __construct ($previewFilename )
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->__construct( {$previewFilename} )" ) ;
|
||||
$this->_previewFilename = $previewFilename ;
|
||||
$this->_list = array ( ) ;
|
||||
|
||||
$this->_dirname = dirname ( $this->_previewFilename ) ;
|
||||
// create the history directory if it does not already exist
|
||||
if (! is_dir ( $this->_dirname ))
|
||||
{
|
||||
mkdir_recursive ( $this->_dirname ) ;
|
||||
}
|
||||
$this->_basename = basename ( $this->_previewFilename ) ;
|
||||
// Reconstruct the history from the saved files
|
||||
foreach ( scandir ( $this->_dirname ) as $filename )
|
||||
{
|
||||
if ($filename != "." && $filename != "..")
|
||||
{
|
||||
// history files are of the form {$basename}_{$timestamp}
|
||||
if (preg_match ( '/(' . $this->_basename . ')_(.*)/', $filename, $matches ) == 1)
|
||||
{
|
||||
$this->_list [ $matches [ 2 ] ] = $matches [ 2 ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// now sort the files, oldest first
|
||||
if (count ( $this->_list ) > 0)
|
||||
{
|
||||
ksort ( $this->_list ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the most recent item in the history
|
||||
* @return timestamp of the first item
|
||||
*/
|
||||
function getCount ()
|
||||
{
|
||||
return count ( $this->_list ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the most recent item in the history
|
||||
* @return timestamp of the first item
|
||||
*/
|
||||
function getFirst ()
|
||||
{
|
||||
return end ( $this->_list ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the oldest item in the history (the default layout)
|
||||
* @return timestamp of the last item
|
||||
*/
|
||||
function getLast ()
|
||||
{
|
||||
return reset ( $this->_list ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next oldest item in the history
|
||||
* @return timestamp of the next item
|
||||
*/
|
||||
function getNext ()
|
||||
{
|
||||
return prev ( $this->_list ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the nth item in the history (where the zeroeth record is the most recent)
|
||||
* @return timestamp of the nth item
|
||||
*/
|
||||
function getNth ($index)
|
||||
{
|
||||
$value = end ( $this->_list ) ;
|
||||
$i = 0 ;
|
||||
while ( $i < $index )
|
||||
{
|
||||
$value = prev ( $this->_list ) ;
|
||||
$i ++ ;
|
||||
}
|
||||
return $value ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an item to the history
|
||||
* @return String A GMT Unix timestamp for this newly added item
|
||||
*/
|
||||
function append ($path)
|
||||
{
|
||||
// make sure we don't have a duplicate filename - highly unusual as two people should not be using Studio/MB concurrently, but when testing quite possible to do two appends within one second...
|
||||
// because so unlikely in normal use we handle this the naive way by waiting a second so our naming scheme doesn't get overelaborated
|
||||
$retries = 0 ;
|
||||
|
||||
$time = strtotime ( gmdate ( 'r' ) ) ;
|
||||
while ( (file_exists ( $this->_previewFilename . "_" . $time ) && $retries < 5) )
|
||||
|
||||
{
|
||||
sleep ( 1 ) ;
|
||||
$time = strtotime ( gmdate ( 'r' ) ) ;
|
||||
$retries ++ ;
|
||||
}
|
||||
// now we have a unique filename, copy the file into the history
|
||||
copy ( $path, $this->_previewFilename . "_" . $time ) ;
|
||||
$this->_list [ $time ] = $time ;
|
||||
|
||||
// finally, trim the number of files we're holding in the history to that specified in the configuration
|
||||
$max_history = (isset ( $GLOBALS [ 'sugar_config' ] [ 'studio_max_history' ] )) ? $GLOBALS [ 'sugar_config' ] [ 'studio_max_history' ] : 50 ;
|
||||
$count = count ( $this->_list ) ;
|
||||
// truncate the oldest files, keeping only the most recent $GLOBALS['sugar_config']['studio_max_history'] files (zero=keep them all)
|
||||
if (($max_history != 0) && ($count > $max_history))
|
||||
{
|
||||
// most recent files are at the end of the list, so we strip out the first count-max_history records
|
||||
// can't just use array_shift because it renumbers numeric keys (our timestamp keys) to start from zero...
|
||||
for ( $i = 0 ; $i < $count - $max_history ; $i ++ )
|
||||
{
|
||||
$timestamp = reset ( $this->_list ) ;
|
||||
unset ( $this->_list [ $timestamp ] ) ;
|
||||
if (! unlink ( $this->_dirname . "/" . $this->_basename . "_" . $timestamp ))
|
||||
{
|
||||
$GLOBALS [ 'log' ]->warn ( "History.php: unable to remove history file {$this->_basename}_$timestamp from directory {$this->_dirname} - permissions problem?" ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally, remove any history preview file that might be lurking around - as soon as we append a new record it supercedes any old preview, so that must be removed (bug 20130)
|
||||
if (file_exists($this->_previewFilename))
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug( get_class($this)."->append(): removing old history file at {$this->_previewFilename}");
|
||||
unlink ( $this->_previewFilename);
|
||||
}
|
||||
|
||||
return $time ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore the historical layout identified by timestamp
|
||||
* @param Unix timestamp $timestamp GMT Timestamp of the layout to recover
|
||||
* @return GMT Timestamp if successful, null if failure (if the file could not be copied for some reason)
|
||||
*/
|
||||
function restoreByTimestamp ($timestamp)
|
||||
{
|
||||
$filename = $this->_previewFilename . "_" . $timestamp ;
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": restoring from $filename to {$this->_previewFilename}" ) ;
|
||||
|
||||
if (file_exists ( $filename ))
|
||||
{
|
||||
copy ( $filename, $this->_previewFilename ) ;
|
||||
return $timestamp ;
|
||||
}
|
||||
return null ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Undo the restore - revert back to the layout before the restore
|
||||
*/
|
||||
function undoRestore ()
|
||||
{
|
||||
if (file_exists ( $this->_previewFilename ))
|
||||
{
|
||||
unlink ( $this->_previewFilename ) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
75
modules/ModuleBuilder/parsers/views/HistoryInterface.php
Executable file
75
modules/ModuleBuilder/parsers/views/HistoryInterface.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
interface HistoryInterface
|
||||
{
|
||||
|
||||
/*
|
||||
* Get the most recent item in the history
|
||||
* @return Id of the first item
|
||||
*/
|
||||
function getFirst () ;
|
||||
|
||||
/*
|
||||
* Get the next oldest item in the history
|
||||
* @return Id of the next item
|
||||
*/
|
||||
function getNext () ;
|
||||
|
||||
/*
|
||||
* Get the nth item in the history (where the zeroeth record is the most recent)
|
||||
* @return Id of the nth item
|
||||
*/
|
||||
function getNth ($n) ;
|
||||
|
||||
/*
|
||||
* Restore the historical layout identified by timestamp
|
||||
* @return Timestamp if successful, null if failure (if the file could not be copied for some reason)
|
||||
*/
|
||||
function restoreByTimestamp ($timestamp) ;
|
||||
|
||||
/*
|
||||
* Undo the restore - revert back to the layout before the restore
|
||||
*/
|
||||
function undoRestore () ;
|
||||
|
||||
/*
|
||||
* Add an item to the history
|
||||
* @return String An timestamp for this newly added item
|
||||
*/
|
||||
function append ($path) ;
|
||||
}
|
||||
361
modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php
Executable file
361
modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php
Executable file
@@ -0,0 +1,361 @@
|
||||
<?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 'modules/ModuleBuilder/parsers/views/AbstractMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataParserInterface.php' ;
|
||||
|
||||
class ListLayoutMetaDataParser extends AbstractMetaDataParser implements MetaDataParserInterface
|
||||
{
|
||||
|
||||
// Columns is used by the view to construct the listview - each column is built by calling the named function
|
||||
public $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
protected $labelIdentifier = 'label' ; // labels in the listviewdefs.php are tagged 'label' =>
|
||||
protected $allowParent = false;
|
||||
|
||||
/*
|
||||
* Simple function for array_udiff_assoc function call in getAvailableFields()
|
||||
*/
|
||||
static function getArrayDiff ($one , $two)
|
||||
{
|
||||
$retArray = array();
|
||||
foreach($one as $key => $value)
|
||||
{
|
||||
if (!isset($two[$key]))
|
||||
{
|
||||
$retArray[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $retArray;
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string view The view type, that is, editview, searchview etc
|
||||
* @param string moduleName The name of the module to which this listview belongs
|
||||
* @param string packageName If not empty, the name of the package to which this listview belongs
|
||||
*/
|
||||
function __construct ($view , $moduleName , $packageName = '')
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": __construct()" ) ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
$views = array ( MB_LISTVIEW, MB_DASHLET, MB_DASHLETSEARCH, MB_POPUPLIST, MB_POPUPSEARCH ) ;
|
||||
if (! in_array ( $view , $views ) )
|
||||
{
|
||||
sugar_die ( "ListLayoutMetaDataParser: View $view is not supported" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
if (empty ( $packageName ))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new DeployedMetaDataImplementation ( $view, $moduleName ) ;
|
||||
} else
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new UndeployedMetaDataImplementation ( $view, $moduleName, $packageName ) ;
|
||||
}
|
||||
$this->view = $view;
|
||||
|
||||
$this->_fielddefs = $this->implementation->getFielddefs () ;
|
||||
$this->_standardizeFieldLabels( $this->_fielddefs );
|
||||
$this->_viewdefs = array_change_key_case ( $this->implementation->getViewdefs () ) ; // force to lower case so don't have problems with case mismatches later
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Deploy the layout
|
||||
* @param boolean $populate If true (default), then update the layout first with new layout information from the $_REQUEST array
|
||||
*/
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
if ($populate)
|
||||
$this->_populateFromRequest () ;
|
||||
$this->implementation->deploy ( array_change_key_case ( $this->_viewdefs, CASE_UPPER ) ) ; // force the field names back to upper case so the list view will work correctly
|
||||
}
|
||||
|
||||
function getLayout ()
|
||||
{
|
||||
return $this->_viewdefs ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of the default fields for a listview
|
||||
* @return array List of default fields as an array, where key = value = <field name>
|
||||
*/
|
||||
function getDefaultFields ()
|
||||
{
|
||||
$defaultFields = array ( ) ;
|
||||
foreach ( $this->_viewdefs as $key => $def )
|
||||
{
|
||||
// add in the default fields from the listviewdefs but hide fields disabled in the listviewdefs.
|
||||
if (! empty ( $def [ 'default' ] )
|
||||
&& (!isset($def [ 'studio' ]) || ($def [ 'studio' ] !== false && $def [ 'studio' ] != "false")))
|
||||
{
|
||||
if (isset($this->_fielddefs [ $key ] )) {
|
||||
$defaultFields [ $key ] = self::_trimFieldDefs ( $this->_fielddefs [ $key ] ) ;
|
||||
if (!empty($def['label']))
|
||||
$defaultFields [ $key ]['label'] = $def['label'];
|
||||
}
|
||||
else {
|
||||
$defaultFields [ $key ] = $def;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaultFields ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns additional fields available for users to create fields
|
||||
@return array List of additional fields as an array, where key = value = <field name>
|
||||
*/
|
||||
function getAdditionalFields ()
|
||||
{
|
||||
$additionalFields = array ( ) ;
|
||||
foreach ( $this->_viewdefs as $key => $def )
|
||||
{
|
||||
//#25322
|
||||
if(strtolower ( $key ) == 'email_opt_out'){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty ( $def [ 'default' ] ))
|
||||
{
|
||||
if (isset($this->_fielddefs [ $key ] ))
|
||||
$additionalFields [ $key ] = self::_trimFieldDefs ( $this->_fielddefs [ $key ] ) ;
|
||||
else
|
||||
$additionalFields [ $key ] = $def;
|
||||
}
|
||||
}
|
||||
return $additionalFields ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns unused fields that are available for use in either default or additional list views
|
||||
* @return array List of available fields as an array, where key = value = <field name>
|
||||
*/
|
||||
function getAvailableFields ()
|
||||
{
|
||||
$availableFields = array ( ) ;
|
||||
// Select available fields from the field definitions - don't need to worry about checking if ok to include as the Implementation has done that already in its constructor
|
||||
foreach ( $this->_fielddefs as $key => $def )
|
||||
{
|
||||
if ($this->isValidField($key, $def))
|
||||
$availableFields [ $key ] = self::_trimFieldDefs( $this->_fielddefs [ $key ] ) ;
|
||||
|
||||
$origDefs = $this->getOriginalViewDefs();
|
||||
foreach($origDefs as $key => $def)
|
||||
{
|
||||
$availableFields [ $key ] = $def;
|
||||
}
|
||||
}
|
||||
|
||||
//$GLOBALS['log']->debug(get_class($this).'->getAvailableFields(): '.print_r($availableFields,true));
|
||||
// now remove all fields that are already in the viewdef - they are not available; they are in use
|
||||
return ListLayoutMetaDataParser::getArrayDiff ( $availableFields, $this->_viewdefs) ;
|
||||
}
|
||||
|
||||
public function isValidField($key, $def)
|
||||
{
|
||||
//Studio invisible fields should always be hidden
|
||||
if (! empty ($def[ 'studio' ] ) )
|
||||
{
|
||||
if (is_array($def [ 'studio' ]))
|
||||
{
|
||||
if (isset($def [ 'studio' ]['listview']))
|
||||
return $def [ 'studio' ]['listview'] !== false && $def [ 'studio' ]['listview'] != 'false';
|
||||
if (isset($def [ 'studio' ]['visible']))
|
||||
return $def [ 'studio' ]['visible'];
|
||||
} else
|
||||
{
|
||||
return ($def [ 'studio' ] != 'false' && $def [ 'studio' ] !== false && $def [ 'studio' ] != 'hidden') ;
|
||||
}
|
||||
}
|
||||
|
||||
//Bug 32520. We need to dissalow currency_id fields on list views.
|
||||
//This should be removed once array based studio definitions are in.
|
||||
if (isset($def['type']) && $def['type'] == "id" && $def['name'] == 'currency_id')
|
||||
return false;
|
||||
|
||||
//Check fields types
|
||||
if (isset($def['dbType']) && $def['dbType'] == "id")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($def['type']))
|
||||
{
|
||||
if ($def['type'] == 'html' || ($def['type'] == 'parent' && !$this->allowParent)
|
||||
|| $def['type'] == "id" || $def['type'] == "link" || $def['type'] == 'image')
|
||||
return false;
|
||||
}
|
||||
|
||||
//hide currency_id, deleted, and _name fields by key-name
|
||||
if(strcmp ( $key, 'deleted' ) == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//if all the tests failed, the field is probably ok
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _populateFromRequest ()
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->populateFromRequest() - fielddefs = ".print_r($this->_fielddefs, true));
|
||||
// Transfer across any reserved fields, that is, any where studio !== true, which are not editable but must be preserved
|
||||
$newViewdefs = array ( ) ;
|
||||
$rejectTypes = array ( 'html'=>'html' , 'enum'=>'enum' , 'text'=>'text', 'encrypt'=>'encrypt' ) ;
|
||||
|
||||
$originalViewDefs = $this->getOriginalViewDefs();
|
||||
|
||||
foreach ( $this->_viewdefs as $key => $def )
|
||||
{
|
||||
//If the field is on the layout, but studio disabled, put it back on the layout at the front
|
||||
if (isset ($def['studio']) && (
|
||||
(is_array($def['studio']) && isset($def['studio']['listview']) &&
|
||||
($def['studio']['listview'] === false || strtolower($def['studio']['listview']) == 'false'
|
||||
|| strtolower($def['studio']['listview']) == 'required')
|
||||
)
|
||||
|| (!is_array($def['studio']) &&
|
||||
($def [ 'studio' ] === false || strtolower($def['studio']) == 'false' || strtolower($def['studio']) == 'required'))
|
||||
))
|
||||
{
|
||||
$newViewdefs [ $key ] = $def ;
|
||||
}
|
||||
}
|
||||
// only take items from group_0 for searchviews (basic_search or advanced_search) and subpanels (which both are missing the Available column) - take group_0, _1 and _2 for all other list views
|
||||
$lastGroup = (isset ( $this->columns [ 'LBL_AVAILABLE' ] )) ? 2 : 1 ;
|
||||
|
||||
for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < $lastGroup ; $i ++ )
|
||||
{
|
||||
foreach ( $_POST [ 'group_' . $i ] as $fieldname )
|
||||
{
|
||||
$fieldname = strtolower ( $fieldname ) ;
|
||||
//Check if the field was previously on the layout
|
||||
if (isset ($this->_viewdefs[$fieldname])) {
|
||||
$newViewdefs [ $fieldname ] = $this->_viewdefs[$fieldname];
|
||||
// print_r($this->_viewdefs[ $fieldname ]);
|
||||
}
|
||||
//Next check if the original view def contained it
|
||||
else if (isset($originalViewDefs[ $fieldname ]))
|
||||
{
|
||||
$newViewdefs [ $fieldname ] = $originalViewDefs[ $fieldname ];
|
||||
}
|
||||
//create a definition from the fielddefs
|
||||
else
|
||||
{
|
||||
// if we don't have a valid fieldname then just ignore it and move on...
|
||||
if ( ! isset ( $this->_fielddefs [ $fieldname ] ) )
|
||||
continue ;
|
||||
|
||||
$newViewdefs [ $fieldname ] = $this->_trimFieldDefs($this->_fielddefs [ $fieldname ]) ;
|
||||
// sorting fields of certain types will cause a database engine problems
|
||||
if ( isset($this->_fielddefs[$fieldname]['type']) &&
|
||||
isset ( $rejectTypes [ $this->_fielddefs [ $fieldname ] [ 'type' ] ] ))
|
||||
{
|
||||
$newViewdefs [ $fieldname ] [ 'sortable' ] = false ;
|
||||
}
|
||||
|
||||
// Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true
|
||||
if (isset ( $this->_fielddefs [ $fieldname ] [ 'type' ]) && $this->_fielddefs [ $fieldname ] [ 'type' ] == 'currency')
|
||||
{
|
||||
$newViewdefs [ $fieldname ] [ 'currency_format' ] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] ))
|
||||
{
|
||||
$width = substr ( $_REQUEST [ $fieldname . 'width' ], 6, 3 ) ;
|
||||
if (strpos ( $width, "%" ) != false)
|
||||
{
|
||||
$width = substr ( $width, 0, 2 ) ;
|
||||
}
|
||||
if (!($width < 101 && $width > 0))
|
||||
{
|
||||
$width = 10;
|
||||
}
|
||||
$newViewdefs [ $fieldname ] [ 'width' ] = $width."%" ;
|
||||
} else if (isset ( $this->_viewdefs [ $fieldname ] [ 'width' ] ))
|
||||
{
|
||||
$newViewdefs [ $fieldname ] [ 'width' ] = $this->_viewdefs [ $fieldname ] [ 'width' ] ;
|
||||
}
|
||||
else {
|
||||
$newViewdefs [ $fieldname ] [ 'width' ] = "10%";
|
||||
}
|
||||
|
||||
$newViewdefs [ $fieldname ] [ 'default' ] = ($i == 0) ;
|
||||
}
|
||||
}
|
||||
$this->_viewdefs = $newViewdefs ;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all instances of a field from the layout
|
||||
* @param string $fieldName Name of the field to remove
|
||||
* @return boolean True if the field was removed; false otherwise
|
||||
*/
|
||||
function removeField ($fieldName)
|
||||
{
|
||||
if (isset ( $this->_viewdefs [ $fieldName ] ))
|
||||
{
|
||||
unset( $this->_viewdefs [ $fieldName ] ) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
function getOriginalViewDefs() {
|
||||
$defs = $this->implementation->getOriginalViewdefs ();
|
||||
$out = array();
|
||||
foreach ($defs as $field => $def)
|
||||
{
|
||||
$out[strtolower($field)] = $def;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
static function _trimFieldDefs ( $def )
|
||||
{
|
||||
if ( isset ( $def [ 'vname' ] ) )
|
||||
$def [ 'label' ] = $def [ 'vname' ] ;
|
||||
return array_intersect_key ( $def , array ( 'type' => true, 'studio' => true , 'label' => true , 'width' => true , 'sortable' => true , 'related_fields' => true , 'default' => true , 'link' => true , 'align' => true , 'orderBy' => true ,'hideLabel' => true, 'customLable' => true , 'currency_format' => true ) ) ;
|
||||
}
|
||||
|
||||
}
|
||||
45
modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php
Executable file
45
modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
interface MetaDataImplementationInterface
|
||||
{
|
||||
public function getViewdefs () ;
|
||||
public function getFielddefs () ;
|
||||
public function getLanguage () ;
|
||||
public function deploy ($defs) ;
|
||||
public function getHistory () ;
|
||||
}
|
||||
50
modules/ModuleBuilder/parsers/views/MetaDataParserInterface.php
Executable file
50
modules/ModuleBuilder/parsers/views/MetaDataParserInterface.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
|
||||
interface MetaDataParserInterface
|
||||
{
|
||||
|
||||
public function handleSave () ;
|
||||
|
||||
public function getLayout () ;
|
||||
|
||||
public function getLanguage () ;
|
||||
|
||||
public function getHistory () ;
|
||||
|
||||
}
|
||||
?>
|
||||
233
modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php
Executable file
233
modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php
Executable file
@@ -0,0 +1,233 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class PopupMetaDataParser extends ListLayoutMetaDataParser
|
||||
{
|
||||
|
||||
// Columns is used by the view to construct the listview - each column is built by calling the named function
|
||||
public $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
|
||||
public static $reserveProperties = array('moduleMain', 'varName' , 'orderBy', 'whereClauses', 'searchInputs', 'create');
|
||||
|
||||
public static $defsMap = array(MB_POPUPSEARCH => 'searchdefs' , MB_POPUPLIST => 'listviewdefs');
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Must set:
|
||||
* $this->columns Array of 'Column LBL'=>function_to_retrieve_fields_for_this_column() - expected by the view
|
||||
*
|
||||
* @param string moduleName The name of the module to which this listview belongs
|
||||
* @param string packageName If not empty, the name of the package to which this listview belongs
|
||||
*/
|
||||
function __construct ($view, $moduleName , $packageName = '')
|
||||
{
|
||||
$this->search = ($view == MB_POPUPSEARCH) ? true : false;
|
||||
$this->_moduleName = $moduleName;
|
||||
$this->_packageName = $packageName;
|
||||
$this->_view = $view ;
|
||||
$this->columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
|
||||
if ($this->search)
|
||||
{
|
||||
$this->columns = array ( 'LBL_DEFAULT' => 'getSearchFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
parent::__construct ( MB_POPUPSEARCH, $moduleName, $packageName ) ;
|
||||
} else
|
||||
{
|
||||
parent::__construct ( MB_POPUPLIST, $moduleName, $packageName ) ;
|
||||
}
|
||||
|
||||
$this->_viewdefs = $this->mergeFieldDefinitions($this->_viewdefs, $this->_fielddefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashlets contain both a searchview and list view definition, therefore we need to merge only the relevant info
|
||||
*/
|
||||
function mergeFieldDefinitions ( $viewdefs, $fielddefs ) {
|
||||
$viewdefs = $this->_viewdefs = array_change_key_case($viewdefs );
|
||||
$viewdefs = $this->_viewdefs = $this->convertSearchToListDefs($viewdefs);
|
||||
return $viewdefs;
|
||||
}
|
||||
|
||||
function convertSearchToListDefs($defs) {
|
||||
$temp = array();
|
||||
foreach($defs as $key=>$value) {
|
||||
if(!is_array($value)){
|
||||
$temp[$value] = array('name'=>$value);
|
||||
}else{
|
||||
$temp[$key] = $value;
|
||||
if(isset($value['name']) && $value['name'] != $key){
|
||||
$temp[$value['name']] = $value;
|
||||
unset($temp[$key] );
|
||||
}else if( !isset($value['name']) ){
|
||||
$temp[$key]['name'] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
function getOriginalViewDefs(){
|
||||
$defs = parent::getOriginalViewDefs();
|
||||
return $this->convertSearchToListDefs($defs);
|
||||
}
|
||||
|
||||
public function getSearchFields()
|
||||
{
|
||||
$searchFields = array ( ) ;
|
||||
foreach ( $this->_viewdefs as $key => $def )
|
||||
{
|
||||
if (isset($this->_fielddefs [ $key ] )) {
|
||||
$searchFields [ $key ] = self::_trimFieldDefs ( $this->_fielddefs [ $key ] ) ;
|
||||
if (!empty($def['label']))
|
||||
$searchFields [ $key ]['label'] = $def['label'];
|
||||
}
|
||||
else {
|
||||
$searchFields [ $key ] = $def;
|
||||
}
|
||||
}
|
||||
|
||||
return $searchFields ;
|
||||
}
|
||||
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
if (empty ( $this->_packageName ))
|
||||
{
|
||||
foreach(array(MB_CUSTOMMETADATALOCATION , MB_BASEMETADATALOCATION) as $value){
|
||||
$file = $this->implementation->getFileName(MB_POPUPLIST, $this->_moduleName, $value);
|
||||
if(file_exists($file)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$writeFile = $this->implementation->getFileName(MB_POPUPLIST, $this->_moduleName);
|
||||
if(!file_exists($writeFile)){
|
||||
mkdir_recursive ( dirname ( $writeFile ) ) ;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$writeFile = $file = $this->implementation->getFileName(MB_POPUPLIST, $this->_moduleName, $this->_packageName);
|
||||
}
|
||||
$this->implementation->_history->append ( $file ) ;
|
||||
if ($populate)
|
||||
$this->_populateFromRequest() ;
|
||||
$out = "<?php\n" ;
|
||||
|
||||
//Load current module languages
|
||||
global $mod_strings , $current_language;
|
||||
$oldModStrings = $mod_strings;
|
||||
$GLOBALS['mod_strings'] = return_module_language($current_language , $this->_moduleName);
|
||||
require($file);
|
||||
if (!isset($popupMeta)) {
|
||||
sugar_die ("unable to load Module Popup Definition");
|
||||
}
|
||||
|
||||
if ($this->_view == MB_POPUPSEARCH)
|
||||
{
|
||||
foreach($this->_viewdefs as $k => $v){
|
||||
if(isset($this->_viewdefs[$k]) && isset($this->_viewdefs[$k]['default'])){
|
||||
unset($this->_viewdefs[$k]['default']);
|
||||
}
|
||||
}
|
||||
$this->_viewdefs = $this->convertSearchToListDefs($this->_viewdefs);
|
||||
$popupMeta['searchdefs'] = $this->_viewdefs;
|
||||
$this->addNewSearchDef($this->_viewdefs , $popupMeta);
|
||||
} else
|
||||
{
|
||||
$popupMeta['listviewdefs'] = array_change_key_case($this->_viewdefs , CASE_UPPER );
|
||||
}
|
||||
$allProperties = array_merge(self::$reserveProperties , array('searchdefs', 'listviewdefs'));
|
||||
|
||||
$out .= "\$popupMeta = array (\n";
|
||||
foreach( $allProperties as $p){
|
||||
if(isset($popupMeta[$p])){
|
||||
$out .= " '$p' => ". var_export_helper ($popupMeta[$p]) . ",\n";
|
||||
}
|
||||
}
|
||||
$out .= ");\n";
|
||||
file_put_contents($writeFile, $out);
|
||||
|
||||
//return back mod strings
|
||||
$GLOBALS['mod_strings'] = $oldModStrings;
|
||||
}
|
||||
|
||||
public function addNewSearchDef($searchDefs, &$popupMeta){
|
||||
if(!empty($searchDefs)){
|
||||
$this->__diffAndUpdate( $searchDefs , $popupMeta['whereClauses'] , true);
|
||||
$this->__diffAndUpdate( $searchDefs , $popupMeta['searchInputs'] );
|
||||
}
|
||||
}
|
||||
|
||||
private function __diffAndUpdate($newDefs , &$targetDefs , $forWhere = false){
|
||||
if(!is_array($targetDefs)){
|
||||
$targetDefs = array();
|
||||
}
|
||||
foreach($newDefs as $key =>$def){
|
||||
if(!isset($targetDefs[$key]) && $forWhere){
|
||||
$targetDefs[$key] = $this->__getTargetModuleName($def).'.'.$key;
|
||||
}else if( !in_array($key , $targetDefs ) && !$forWhere){
|
||||
array_push($targetDefs , $key);
|
||||
}
|
||||
}
|
||||
|
||||
if($forWhere){
|
||||
foreach(array_diff( array_keys($targetDefs) , array_keys($newDefs) ) as $key ){
|
||||
unset($targetDefs[$key]);
|
||||
}
|
||||
}else{
|
||||
foreach($targetDefs as $key =>$value){
|
||||
if(!isset($newDefs[$value]))
|
||||
unset($targetDefs[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function __getTargetModuleName($def){
|
||||
$dir = strtolower($this->implementation->getModuleDir());
|
||||
if(isset($this->_fielddefs[$def['name']]) && isset($this->_fielddefs[$def['name']]['source']) && $this->_fielddefs[$def['name']]['source'] == 'custom_fields'){
|
||||
return $dir.'_cstm';
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
200
modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php
Executable file
200
modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php
Executable file
@@ -0,0 +1,200 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class SearchViewMetaDataParser extends ListLayoutMetaDataParser
|
||||
{
|
||||
static $variableMap = array (
|
||||
MB_BASICSEARCH => 'basic_search' ,
|
||||
MB_ADVANCEDSEARCH => 'advanced_search' ,
|
||||
) ;
|
||||
// Columns is used by the view to construct the listview - each column is built by calling the named function
|
||||
public $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
protected $allowParent = true;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Must set:
|
||||
* $this->columns Array of 'Column LBL'=>function_to_retrieve_fields_for_this_column() - expected by the view
|
||||
* @param string searchLayout The type of search layout, e.g., MB_BASICSEARCH or MB_ADVANCEDSEARCH
|
||||
* @param string moduleName The name of the module to which this listview belongs
|
||||
* @param string packageName If not empty, the name of the package to which this listview belongs
|
||||
*/
|
||||
function __construct ($searchLayout, $moduleName , $packageName = '')
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": __construct( $searchLayout , $moduleName , $packageName )" ) ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( self::$variableMap [ $searchLayout ] ) )
|
||||
{
|
||||
sugar_die ( get_class ( $this ) . ": View $searchLayout is not supported" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
$this->_searchLayout = $searchLayout ;
|
||||
|
||||
// unsophisticated error handling for now...
|
||||
try
|
||||
{
|
||||
if (empty ( $packageName ))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new DeployedMetaDataImplementation ( $searchLayout, $moduleName ) ;
|
||||
} else
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php' ;
|
||||
$this->implementation = new UndeployedMetaDataImplementation ( $searchLayout, $moduleName, $packageName ) ;
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
throw $e ;
|
||||
}
|
||||
|
||||
$this->_saved = array_change_key_case ( $this->implementation->getViewdefs () ) ; // force to lower case so don't have problems with case mismatches later
|
||||
if(isset($this->_saved['templatemeta'])) {
|
||||
$this->_saved['templateMeta'] = $this->_saved['templatemeta'];
|
||||
unset($this->_saved['templatemeta']);
|
||||
}
|
||||
|
||||
if ( ! isset ( $this->_saved [ 'layout' ] [ self::$variableMap [ $this->_searchLayout ] ] ) )
|
||||
{
|
||||
// attempt to fallback on a basic_search layout...
|
||||
|
||||
if ( ! isset ( $this->_saved [ 'layout' ] [ self::$variableMap [ MB_BASICSEARCH ] ] ) )
|
||||
throw new Exception ( get_class ( $this ) . ": {$this->_searchLayout} does not exist for module $moduleName" ) ;
|
||||
|
||||
$this->_saved [ 'layout'] [ MB_ADVANCEDSEARCH ] = $this->_saved [ 'layout' ] [ MB_BASICSEARCH ] ;
|
||||
}
|
||||
|
||||
$this->view = $searchLayout;
|
||||
// convert the search view layout (which has its own unique layout form) to the standard listview layout so that the parser methods and views can be reused
|
||||
$this->_viewdefs = $this->convertSearchViewToListView ( $this->_saved [ 'layout' ] [ self::$variableMap [ $this->_searchLayout ] ] ) ;
|
||||
$this->_fielddefs = $this->implementation->getFielddefs () ;
|
||||
$this->_standardizeFieldLabels( $this->_fielddefs );
|
||||
|
||||
}
|
||||
|
||||
public function isValidField($key, $def)
|
||||
{
|
||||
|
||||
if (!parent::isValidField($key, $def))
|
||||
return false;
|
||||
|
||||
if (isset($def [ 'studio' ]) && is_array($def [ 'studio' ]) && isset($def [ 'studio' ]['searchview']))
|
||||
{
|
||||
return $def [ 'studio' ]['searchview'] !== false && $def [ 'studio' ]['searchview'] != 'false';
|
||||
}
|
||||
|
||||
//Special case to prevent multiple copies of assigned user on the search view
|
||||
if (empty ($def[ 'studio' ] ) && $key == "assigned_user_name" )
|
||||
{
|
||||
$origDefs = $this->getOriginalViewDefs();
|
||||
if (isset($origDefs['assigned_user_id']))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Remove image fields (unless studio was set)
|
||||
if (!empty($def [ 'studio' ]) && isset($def['type']) && $def['type'] == "image")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the modified searchLayout
|
||||
* Have to preserve the original layout format, which is array('metadata'=>array,'layouts'=>array('basic'=>array,'advanced'=>array))
|
||||
*/
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
if ($populate)
|
||||
$this->_populateFromRequest() ;
|
||||
|
||||
|
||||
$this->_saved [ 'layout' ] [ self::$variableMap [ $this->_searchLayout ] ] = $this->convertSearchViewToListView($this->_viewdefs);;
|
||||
$this->implementation->deploy ( $this->_saved ) ;
|
||||
}
|
||||
|
||||
private function convertSearchViewToListView ($viewdefs)
|
||||
{
|
||||
$temp = array ( ) ;
|
||||
foreach ( $viewdefs as $key => $value )
|
||||
{
|
||||
if (! is_array ( $value ))
|
||||
{
|
||||
$key = $value ;
|
||||
$def = array ( ) ;
|
||||
$def[ 'name' ] = $key;
|
||||
$value = $def ;
|
||||
}
|
||||
|
||||
if (!isset ( $value [ 'name' ] ))
|
||||
{
|
||||
$value [ 'name' ] = $key;
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key
|
||||
}
|
||||
// now add in the standard listview default=>true
|
||||
$value [ 'default' ] = true ;
|
||||
$temp [ strtolower ( $key ) ] = $value ;
|
||||
}
|
||||
return $temp ;
|
||||
}
|
||||
|
||||
function getOriginalViewDefs() {
|
||||
$defs = $this->implementation->getOriginalViewdefs ();
|
||||
$out = array();
|
||||
if (!empty($defs) && !empty($defs['layout']) && !empty($defs['layout'][$this->_searchLayout]))
|
||||
{
|
||||
$defs = $defs['layout'][$this->_searchLayout];
|
||||
foreach ($defs as $def)
|
||||
{
|
||||
if (is_array($def) && isset($def['name']))
|
||||
{
|
||||
$out[strtolower($def['name'])] = $def;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
161
modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php
Executable file
161
modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php
Executable file
@@ -0,0 +1,161 @@
|
||||
<?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 ('modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class SubpanelMetaDataParser extends ListLayoutMetaDataParser
|
||||
{
|
||||
|
||||
// Columns is used by the view to construct the listview - each column is built by calling the named function
|
||||
public $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
|
||||
protected $labelIdentifier = 'vname' ; // labels in the subpanel defs are tagged 'vname' =>
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* Must set:
|
||||
* $this->columns Array of 'Column LBL'=>function_to_retrieve_fields_for_this_column() - expected by the view
|
||||
*
|
||||
* @param string subpanelName The name of this subpanel
|
||||
* @param string moduleName The name of the module to which this subpanel belongs
|
||||
* @param string packageName If not empty, the name of the package to which this subpanel belongs
|
||||
*/
|
||||
function __construct ($subpanelName , $moduleName , $packageName = '')
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . ": __construct()" ) ;
|
||||
|
||||
// TODO: check the implementations
|
||||
if (empty ( $packageName ))
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DeployedSubpanelImplementation.php' ;
|
||||
$this->implementation = new DeployedSubpanelImplementation ( $subpanelName, $moduleName ) ;
|
||||
//$this->originalViewDef = $this->implementation->getOriginalDefs ();
|
||||
} else
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/views/UndeployedSubpanelImplementation.php' ;
|
||||
$this->implementation = new UndeployedSubpanelImplementation ( $subpanelName, $moduleName, $packageName ) ;
|
||||
}
|
||||
|
||||
$this->_viewdefs = array_change_key_case ( $this->implementation->getViewdefs () ) ; // force to lower case so don't have problems with case mismatches later
|
||||
$this->_fielddefs = $this->implementation->getFielddefs ();
|
||||
$this->_standardizeFieldLabels( $this->_fielddefs );
|
||||
$GLOBALS['log']->debug ( get_class($this)."->__construct(): viewdefs = ".print_r($this->_viewdefs,true));
|
||||
$GLOBALS['log']->debug ( get_class($this)."->__construct(): viewdefs = ".print_r($this->_viewdefs,true));
|
||||
$this->_invisibleFields = $this->findInvisibleFields( $this->_viewdefs ) ;
|
||||
|
||||
$GLOBALS['log']->debug ( get_class($this)."->__construct(): invisibleFields = ".print_r($this->_invisibleFields,true));
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the layout
|
||||
*/
|
||||
function handleSave ($populate = true)
|
||||
{
|
||||
if ($populate)
|
||||
{
|
||||
$this->_populateFromRequest() ;
|
||||
if (isset ($_REQUEST['subpanel_title']) && isset($_REQUEST['subpanel_title_key'])) {
|
||||
$selected_lang = (!empty($_REQUEST['selected_lang'])? $_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
|
||||
if(empty($selected_lang)){
|
||||
$selected_lang = $GLOBALS['sugar_config']['default_language'];
|
||||
}
|
||||
require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
|
||||
$labelParser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
|
||||
$labelParser->addLabels($selected_lang, array($_REQUEST['subpanel_title_key'] => $_REQUEST['subpanel_title']), $_REQUEST['view_module']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->implementation->deploy ( $this->restoreInvisibleFields ( $this->_invisibleFields , $this->_viewdefs ) ) ; // unlike our parent, do not force the field names back to upper case
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of the default fields for a subpanel
|
||||
* TODO: have this return just a list of fields, without definitions
|
||||
* @return array List of default fields as an array, where key = value = <field name>
|
||||
*/
|
||||
function getDefaultFields ()
|
||||
{
|
||||
$defaultFields = array ( ) ;
|
||||
foreach ( $this->_viewdefs as $key => $def )
|
||||
{
|
||||
if (empty ( $def [ 'usage' ] ) || strcmp ( $def [ 'usage' ], 'query_only' ) == 1)
|
||||
{
|
||||
$defaultFields [ strtolower ( $key ) ] = $this->_viewdefs [ $key ] ;
|
||||
}
|
||||
}
|
||||
|
||||
return $defaultFields ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the query_only fields in the viewdefs
|
||||
* Query_only fields are used by the MVC to generate the subpanel but are not editable - they must be maintained in the layout
|
||||
* @param viewdefs The viewdefs to be searched for invisible fields
|
||||
* @return Array of invisible fields, ready to be provided to $this->restoreInvisibleFields
|
||||
*/
|
||||
function findInvisibleFields( $viewdefs )
|
||||
{
|
||||
$invisibleFields = array () ;
|
||||
foreach ( $viewdefs as $name => $def )
|
||||
if ( isset($def [ 'usage' ] ) && ($def [ 'usage'] == 'query_only') )
|
||||
$invisibleFields [ $name ] = $def ;
|
||||
return $invisibleFields ;
|
||||
}
|
||||
|
||||
function restoreInvisibleFields ( $invisibleFields , $viewdefs )
|
||||
{
|
||||
foreach ( $invisibleFields as $name => $def )
|
||||
{
|
||||
$viewdefs [ $name ] = $def ;
|
||||
}
|
||||
return $viewdefs ;
|
||||
}
|
||||
|
||||
static function _trimFieldDefs ( $def )
|
||||
{
|
||||
$listDef = parent::_trimFieldDefs($def);
|
||||
if (isset($listDef ['label']))
|
||||
{
|
||||
$listDef ['vname'] = $listDef ['label'];
|
||||
unset($listDef ['label']);
|
||||
}
|
||||
return $listDef;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
206
modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php
Executable file
206
modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php
Executable file
@@ -0,0 +1,206 @@
|
||||
<?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 'modules/ModuleBuilder/MB/ModuleBuilder.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class UndeployedMetaDataImplementation extends AbstractMetaDataImplementation implements MetaDataImplementationInterface
|
||||
{
|
||||
|
||||
private $_packageName ;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string $view
|
||||
* @param string $moduleName
|
||||
* @throws Exception Thrown if the provided view doesn't exist for this module
|
||||
*/
|
||||
|
||||
function __construct ($view , $moduleName , $packageName)
|
||||
{
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if (! isset ( $this->_fileVariables [ $view ] ))
|
||||
{
|
||||
sugar_die ( get_class ( $this ) . ": View $view is not supported" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
$this->_view = strtolower ( $view ) ;
|
||||
$this->_moduleName = $moduleName ;
|
||||
$this->_packageName = $packageName ;
|
||||
|
||||
//get the bean from ModuleBuilder
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$this->module = $module = & $mb->getPackageModule ( $packageName, $moduleName ) ;
|
||||
$pak = $mb->getPackage($packageName);
|
||||
$module->mbvardefs->updateVardefs () ;
|
||||
|
||||
// Set the list of fields associated with this module
|
||||
$fielddefs = array_change_key_case ( $module->mbvardefs->vardefs [ 'fields' ] ) ;
|
||||
|
||||
// Set the global mod_strings directly as Sugar does not automatically load the language files for undeployed modules (how could it?)
|
||||
$GLOBALS [ 'mod_strings' ] = array_merge ( $GLOBALS [ 'mod_strings' ], $module->getModStrings () ) ;
|
||||
|
||||
//Load relationshhip based fields and labels
|
||||
$moduleRels = $pak->getRelationshipsForModule($moduleName);
|
||||
foreach($moduleRels as $rName => $rel ) {
|
||||
$varDefsSet = $rel->buildVardefs();
|
||||
if (!empty($varDefsSet[$module->key_name])) {
|
||||
foreach ($varDefsSet[$module->key_name] as $def) {
|
||||
$fielddefs[$def['name']] = $def;
|
||||
}
|
||||
}
|
||||
$labels = $rel->buildLabels();
|
||||
foreach ($labels as $def) {
|
||||
if ($def['module'] == $module->key_name) {
|
||||
$GLOBALS [ 'mod_strings' ][$def['system_label']] = $def['display_label'];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$loaded = null ;
|
||||
foreach ( array ( MB_WORKINGMETADATALOCATION , MB_HISTORYMETADATALOCATION ) as $type )
|
||||
{
|
||||
$this->_sourceFilename = $this->getFileName ( $view, $moduleName, $packageName , $type ) ;
|
||||
if($view == MB_POPUPSEARCH || $view == MB_POPUPLIST){
|
||||
$layout = $this->_loadFromPopupFile ( $this->_sourceFilename , null, $view);
|
||||
}else{
|
||||
$layout = $this->_loadFromFile ( $this->_sourceFilename );
|
||||
}
|
||||
if ( null !== $layout )
|
||||
{
|
||||
// merge in the fielddefs from this layout
|
||||
$this->_mergeFielddefs ( $fielddefs , $layout ) ;
|
||||
$loaded = $layout ;
|
||||
}
|
||||
}
|
||||
|
||||
if ($loaded === null)
|
||||
{
|
||||
throw new Exception ( get_class ( $this ) . ": view definitions for View $this->_view and Module $this->_moduleName are missing" ) ;
|
||||
}
|
||||
|
||||
$this->_viewdefs = $loaded ;
|
||||
$sourceFilename = $this->getFileName ( $view, $moduleName, $packageName, MB_WORKINGMETADATALOCATION );
|
||||
if($view == MB_POPUPSEARCH || $view == MB_POPUPLIST){
|
||||
$layout = $this->_loadFromPopupFile ( $sourceFilename , null, $view);
|
||||
}else{
|
||||
$layout = $this->_loadFromFile ($sourceFilename) ;
|
||||
}
|
||||
$this->_originalViewdefs = $layout ;
|
||||
$this->_fielddefs = $fielddefs ;
|
||||
$this->_history = new History ( $this->getFileName ( $view, $moduleName, $packageName, MB_HISTORYMETADATALOCATION ) ) ;
|
||||
}
|
||||
|
||||
function getLanguage ()
|
||||
{
|
||||
return $this->_packageName . $this->_moduleName ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deploy a layout
|
||||
* @param array defs Layout definition in the same format as received by the constructor
|
||||
*/
|
||||
function deploy ($defs)
|
||||
{
|
||||
//If we are pulling from the History Location, that means we did a restore, and we need to save the history for the previous file.
|
||||
if ($this->_sourceFilename == $this->getFileName ( $this->_view, $this->_moduleName, $this->_packageName, MB_HISTORYMETADATALOCATION )
|
||||
&& file_exists($this->getFileName ( $this->_view, $this->_moduleName, $this->_packageName, MB_WORKINGMETADATALOCATION ))) {
|
||||
$this->_history->append ( $this->getFileName ( $this->_view, $this->_moduleName, $this->_packageName, MB_WORKINGMETADATALOCATION )) ;
|
||||
} else {
|
||||
$this->_history->append ( $this->_sourceFilename ) ;
|
||||
}
|
||||
$filename = $this->getFileName ( $this->_view, $this->_moduleName, $this->_packageName, MB_WORKINGMETADATALOCATION ) ;
|
||||
$GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->deploy(): writing to " . $filename ) ;
|
||||
$this->_saveToFile ( $filename, $defs ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a full pathname for the requested metadata
|
||||
* @param string view The view type, that is, EditView, DetailView etc
|
||||
* @param string modulename The name of the module that will use this layout
|
||||
* @param string type
|
||||
*/
|
||||
public static function getFileName ($view , $moduleName , $packageName , $type = MB_BASEMETADATALOCATION)
|
||||
{
|
||||
|
||||
$type = strtolower ( $type ) ;
|
||||
|
||||
// BEGIN ASSERTIONS
|
||||
if ($type != MB_BASEMETADATALOCATION && $type != MB_HISTORYMETADATALOCATION)
|
||||
{
|
||||
// just warn rather than die
|
||||
$GLOBALS [ 'log' ]->warning ( "UndeployedMetaDataImplementation->getFileName(): view type $type is not recognized" ) ;
|
||||
}
|
||||
// END ASSERTIONS
|
||||
|
||||
$filenames = array ( MB_DASHLETSEARCH => 'dashletviewdefs',
|
||||
MB_DASHLET => 'dashletviewdefs',
|
||||
MB_LISTVIEW => 'listviewdefs' ,
|
||||
MB_BASICSEARCH => 'searchdefs' ,
|
||||
MB_ADVANCEDSEARCH => 'searchdefs' ,
|
||||
MB_EDITVIEW => 'editviewdefs' ,
|
||||
MB_DETAILVIEW => 'detailviewdefs' ,
|
||||
MB_QUICKCREATE => 'quickcreatedefs',
|
||||
MB_POPUPSEARCH => 'popupdefs',
|
||||
MB_POPUPLIST => 'popupdefs',
|
||||
) ;
|
||||
|
||||
switch ( $type)
|
||||
{
|
||||
case MB_HISTORYMETADATALOCATION :
|
||||
return 'custom/history/modulebuilder/packages/' . $packageName . '/modules/' . $moduleName . '/metadata/' . $filenames [ $view ] . '.php' ;
|
||||
default :
|
||||
// get the module again, all so we can call this method statically without relying on the module stored in the class variables
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $packageName, $moduleName ) ;
|
||||
return $module->getModuleDir () . '/metadata/' . $filenames [ $view ] . '.php' ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getModuleDir(){
|
||||
return $this->module->key_name;
|
||||
}
|
||||
}
|
||||
?>
|
||||
109
modules/ModuleBuilder/parsers/views/UndeployedSubpanelImplementation.php
Executable file
109
modules/ModuleBuilder/parsers/views/UndeployedSubpanelImplementation.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?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".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Changes to AbstractSubpanelImplementation for DeployedSubpanels
|
||||
* The main differences are in the load and save of the definitions
|
||||
* For subpanels we must make use of the SubPanelDefinitions class to do this; this also means that the history mechanism,
|
||||
* which tracks files, not objects, needs us to create an intermediate file representation of the definition that it can manage and restore
|
||||
*/
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/MetaDataImplementationInterface.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class UndeployedSubpanelImplementation extends AbstractMetaDataImplementation implements MetaDataImplementationInterface
|
||||
{
|
||||
|
||||
const HISTORYFILENAME = 'restored.php' ;
|
||||
const HISTORYVARIABLENAME = 'layout_defs' ;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @param string subpanelName The name of this subpanel
|
||||
* @param string moduleName The name of the module to which this subpanel belongs
|
||||
* @param string packageName If not empty, the name of the package to which this subpanel belongs
|
||||
*/
|
||||
function __construct ($subpanelName , $moduleName , $packageName)
|
||||
{
|
||||
$this->_subpanelName = $subpanelName ;
|
||||
$this->_moduleName = $moduleName ;
|
||||
|
||||
// TODO: history
|
||||
$this->historyPathname = 'custom/history/modulebuilder/packages/' . $packageName . '/modules/' . $moduleName . '/metadata/' . self::HISTORYFILENAME ;
|
||||
$this->_history = new History ( $this->historyPathname ) ;
|
||||
|
||||
//get the bean from ModuleBuilder
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$this->module = & $mb->getPackageModule ( $packageName, $moduleName ) ;
|
||||
$this->module->mbvardefs->updateVardefs () ;
|
||||
$this->_fielddefs = & $this->module->mbvardefs->vardefs [ 'fields' ] ;
|
||||
|
||||
$subpanel_layout = $this->module->getAvailibleSubpanelDef ( $this->_subpanelName ) ;
|
||||
$this->_viewdefs = & $subpanel_layout [ 'list_fields' ] ;
|
||||
$this->_mergeFielddefs($this->_fielddefs, $this->_viewdefs);
|
||||
|
||||
// Set the global mod_strings directly as Sugar does not automatically load the language files for undeployed modules (how could it?)
|
||||
$GLOBALS [ 'mod_strings' ] = array_merge ( $GLOBALS [ 'mod_strings' ], $this->module->getModStrings () ) ;
|
||||
}
|
||||
|
||||
function getLanguage ()
|
||||
{
|
||||
return "" ; // '' is the signal to translate() to use the global mod_strings
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a subpanel
|
||||
* @param array defs Layout definition in the same format as received by the constructor
|
||||
* @param string type The location for the file - for example, MB_BASEMETADATALOCATION for a location in the OOB metadata directory
|
||||
*/
|
||||
function deploy ($defs)
|
||||
{
|
||||
$outputDefs = $this->module->getAvailibleSubpanelDef ( $this->_subpanelName ) ;
|
||||
// first sort out the historical record...
|
||||
// copy the definition to a temporary file then let the history object add it
|
||||
write_array_to_file ( self::HISTORYVARIABLENAME, $outputDefs, $this->historyPathname, 'w', '' ) ;
|
||||
$this->_history->append ( $this->historyPathname ) ;
|
||||
// no need to unlink the temporary file as being handled by in history->append()
|
||||
//unlink ( $this->historyPathname ) ;
|
||||
|
||||
$outputDefs [ 'list_fields' ] = $defs ;
|
||||
$this->_viewdefs = $defs ;
|
||||
$this->module->saveAvailibleSubpanelDef ( $this->_subpanelName, $outputDefs ) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
227
modules/ModuleBuilder/views/view.dashlet.php
Executable file
227
modules/ModuleBuilder/views/view.dashlet.php
Executable file
@@ -0,0 +1,227 @@
|
||||
<?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 ('modules/ModuleBuilder/views/view.listview.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class ViewDashlet extends ViewListView
|
||||
{
|
||||
function ViewDashlet()
|
||||
{
|
||||
$this->init () ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->editModule = $_REQUEST [ 'view_module' ] ;
|
||||
$this->editLayout = $_REQUEST [ 'view' ] ;
|
||||
$this->editPackage = (isset ( $_REQUEST [ 'view_package' ] ) && ! empty ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
|
||||
$this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (isset($_REQUEST['view_package']) && $_REQUEST['view_package'] && $_REQUEST['view_package'] != 'studio') ;
|
||||
|
||||
if (!$this->fromModuleBuilder)
|
||||
{
|
||||
global $app_list_strings ;
|
||||
$moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
|
||||
$this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
// DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
|
||||
function preDisplay()
|
||||
{
|
||||
}
|
||||
|
||||
function display(
|
||||
$preview = false
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $this->editLayout, $this->editModule, $this->editPackage) ;
|
||||
|
||||
$smarty = $this->constructSmarty ( $parser ) ;
|
||||
if ($preview)
|
||||
{
|
||||
echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
|
||||
} else
|
||||
{
|
||||
$ajax = $this->constructAjax () ;
|
||||
$ajax->addSection ( 'center', translate('LBL_DASHLET'), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
}
|
||||
|
||||
function constructAjax()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->editPackage . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->editPackage . '&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")');
|
||||
$ajax->addCrumb ( translate('LBL_DASHLET', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=dashlet&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")' );
|
||||
|
||||
$ViewLabel = ($this->editLayout == MB_DASHLET) ? 'LBL_DASHLETLISTVIEW' : 'LBL_DASHLETSEARCHVIEW';
|
||||
$ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
|
||||
}else{
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->editModule . '")');
|
||||
$ajax->addCrumb ( translate('LBL_DASHLET', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=dashlet&view_module=' . $this->editModule . '")' );
|
||||
$ViewLabel = ($this->editLayout == MB_DASHLET) ? 'LBL_DASHLETLISTVIEW' : 'LBL_DASHLETSEARCHVIEW';
|
||||
$ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
|
||||
}
|
||||
return $ajax ;
|
||||
}
|
||||
|
||||
function constructSmarty($parser)
|
||||
{
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->assign ( 'translate', true ) ;
|
||||
$smarty->assign ( 'language', $parser->getLanguage () ) ;
|
||||
|
||||
$smarty->assign ( 'view', $this->editLayout ) ;
|
||||
$smarty->assign ( 'action', 'dashletSave' ) ;
|
||||
$smarty->assign( 'module', 'ModuleBuilder');
|
||||
$smarty->assign ( 'view_module', $this->editModule ) ;
|
||||
$helpName = (isset( $_REQUEST['view']) && $_REQUEST['view']=='dashletsearch') ? 'searchViewEditor' : 'listViewEditor';
|
||||
$smarty->assign ( 'helpName', $helpName ) ;
|
||||
$smarty->assign ( 'helpDefault', 'modify' ) ;
|
||||
if ($this->fromModuleBuilder) {
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $this->editPackage, $this->editModule ) ;
|
||||
$smarty->assign('current_mod_strings', $module->getModStrings());
|
||||
}
|
||||
$smarty->assign ( 'title', $this->_constructTitle () ) ;
|
||||
$groups = array ( ) ;
|
||||
foreach ( $parser->columns as $column => $function )
|
||||
{
|
||||
// update this so that each field has a properties set
|
||||
// properties are name, value, title (optional)
|
||||
$groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ; // call the parser functions to populate the list view columns, by default 'default', 'available' and 'hidden'
|
||||
}
|
||||
foreach ( $groups as $groupKey => $group )
|
||||
{
|
||||
foreach ( $group as $fieldKey => $field )
|
||||
{
|
||||
if (isset ( $field [ 'width' ] ))
|
||||
{
|
||||
if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
|
||||
{
|
||||
|
||||
$groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign ( 'groups', $groups ) ;
|
||||
|
||||
global $image_path ;
|
||||
$imageSave = SugarThemeRegistry::current()->getImage('studio_save') ;
|
||||
// $imageHelp = SugarThemeRegistry::current()->getImage('help') ;
|
||||
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
|
||||
if (isset($this->searchlayout))
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->searchlayout}\")" ;
|
||||
|
||||
$buttons = array ( ) ;
|
||||
if (! $this->fromModuleBuilder)
|
||||
{
|
||||
$buttons [] = array ( 'name' => 'savebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVEPUBLISH' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
|
||||
} else
|
||||
{
|
||||
$buttons [] = array ( 'name' => 'mbsavebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
|
||||
}
|
||||
$buttons [] = array ( 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
|
||||
$smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
|
||||
$editImage = SugarThemeRegistry::current()->getImage('edit_inline') ;
|
||||
$smarty->assign ( 'editImage', $editImage ) ;
|
||||
$deleteImage = SugarThemeRegistry::current()->getImage('delete_inline') ;
|
||||
$smarty->assign ( 'deleteImage', $deleteImage ) ;
|
||||
$smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$smarty->assign ( 'MB', true ) ;
|
||||
$smarty->assign ( 'view_package', $this->editPackage ) ;
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
}
|
||||
|
||||
return $smarty ;
|
||||
}
|
||||
|
||||
function _constructTitle()
|
||||
{
|
||||
global $app_list_strings ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
$title = $this->editModule ;
|
||||
else
|
||||
$title = $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
|
||||
|
||||
return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ': ' . $title ;
|
||||
}
|
||||
}
|
||||
60
modules/ModuleBuilder/views/view.deletemodule.php
Executable file
60
modules/ModuleBuilder/views/view.deletemodule.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
|
||||
class Viewdeletemodule extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addSection('center', 'Module Deleted', $_REQUEST['module'] . ' was deleted from ' . $_REQUEST['package']);
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
63
modules/ModuleBuilder/views/view.deletepackage.php
Executable file
63
modules/ModuleBuilder/views/view.deletepackage.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
|
||||
class Viewdeletepackage extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addSection('center', $mod_strings['LBL_PACKAGE_DELETED'],
|
||||
str_replace('[[package]]',$_REQUEST['package'],$mod_strings['LBL_PACKAGE_WAS_DELETED']));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
65
modules/ModuleBuilder/views/view.displaydeploy.php
Executable file
65
modules/ModuleBuilder/views/view.displaydeploy.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewDisplaydeploy extends SugarView
|
||||
{
|
||||
function ViewDisplaydeploy()
|
||||
{
|
||||
$smarty = new Sugar_Smarty();
|
||||
$smarty->assign('package', $_REQUEST['name']);
|
||||
$smarty->assign('message', $GLOBALS['mod_strings']['LBL_DEPLOY_IN_PROGRESS']);
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
|
||||
$ajax->addCrumb($_REQUEST['name'],'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package='.$_REQUEST['name'].'")');
|
||||
$ajax->addCrumb(translate('LBL_SECTION_DEPLOY', 'ModuleBuilder'), '');
|
||||
$ajax->addSection('center', translate('LBL_SECTION_DEPLOY', 'ModuleBuilder'), $smarty->fetch('modules/ModuleBuilder/tpls/MBPackage/deploy.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
}
|
||||
68
modules/ModuleBuilder/views/view.displaydeployresult.php
Executable file
68
modules/ModuleBuilder/views/view.displaydeployresult.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewDisplaydeployresult extends SugarView
|
||||
{
|
||||
function ViewDisplaydeployresult(){
|
||||
$this->show_header = false;
|
||||
$this->show_title = false;
|
||||
$this->show_subpanels = false;
|
||||
$this->show_search = false;
|
||||
$this->show_footer = true;
|
||||
$this->show_javascript = true;
|
||||
$this->view_print = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$message = $this->view_object_map['message'];
|
||||
echo $message."<script type='text/javascript' src='include/javascript/sugar_grp1_yui.js?s=".$GLOBALS['sugar_version']."&c=".$GLOBALS['sugar_config']['js_custom_version']."'></script><script type='text/javascript' language='Javascript'>YAHOO.util.Connect.asyncRequest('GET', 'index.php?module=Administration&action=RebuildRelationship&silent=true');</script>";
|
||||
}
|
||||
}
|
||||
159
modules/ModuleBuilder/views/view.dropdown.php
Executable file
159
modules/ModuleBuilder/views/view.dropdown.php
Executable file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewDropdown extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$ajax = new AjaxCompose();
|
||||
$smarty = $this->generateSmarty();
|
||||
|
||||
if (isset($_REQUEST['refreshTree']))
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/Module/DropDownTree.php');
|
||||
$mbt = new DropDownTree();
|
||||
$ajax->addSection('west', $mbt->getName(), $mbt->fetchNodes());
|
||||
$smarty->assign('refreshTree',true);
|
||||
}
|
||||
|
||||
$smarty->assign('deleteImage', SugarThemeRegistry::current()->getImage( 'delete_inline', ''));
|
||||
$smarty->assign('editImage', SugarThemeRegistry::current()->getImage( 'edit_inline', ''));
|
||||
$smarty->assign('action', 'savedropdown');
|
||||
$body = $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/dropdown.tpl');
|
||||
$ajax->addSection('east2', $GLOBALS['mod_strings']['LBL_SECTION_DROPDOWNED'], $body );
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
|
||||
function generateSmarty()
|
||||
{
|
||||
//get the selected language
|
||||
$selected_lang = (!empty($_REQUEST['dropdown_lang'])?$_REQUEST['dropdown_lang']:$_SESSION['authenticated_user_language']);
|
||||
$vardef = array();
|
||||
$package_name = 'studio';
|
||||
$package_strings = array();
|
||||
$new =false;
|
||||
$my_list_strings = return_app_list_strings_language( $selected_lang ) ;
|
||||
// $my_list_strings = $GLOBALS['app_list_strings'];
|
||||
|
||||
//if we are using ModuleBuilder then process the following
|
||||
if(!empty($_REQUEST['view_package']) && $_REQUEST['view_package'] != 'studio'){
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
$mb = new ModuleBuilder();
|
||||
$this->module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
|
||||
$package =& $mb->packages[$_REQUEST['view_package']];
|
||||
$package_name = $package->name;
|
||||
$this->module->getVardefs();
|
||||
if(empty($_REQUEST['dropdown_name']) && !empty($_REQUEST['field'])){
|
||||
$new = true;
|
||||
$_REQUEST['dropdown_name'] = $_REQUEST['field']. '_list';
|
||||
}
|
||||
|
||||
$vardef = (!empty($this->module->mbvardefs->fields[$_REQUEST['dropdown_name']]))? $this->module->mbvardefs->fields[$_REQUEST['dropdown_name']]: array();
|
||||
$this->module->mblanguage->generateAppStrings(false) ;
|
||||
$my_list_strings = array_merge( $my_list_strings, $this->module->mblanguage->appListStrings[$selected_lang.'.lang.php'] );
|
||||
}
|
||||
|
||||
foreach($my_list_strings as $key=>$value){
|
||||
if(!is_array($value)){
|
||||
unset($my_list_strings[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$dropdowns = array_keys($my_list_strings);
|
||||
asort($dropdowns);
|
||||
$keys = array_keys($dropdowns);
|
||||
$first_string = $my_list_strings[$dropdowns[$keys[0]]];
|
||||
if(!empty($cf))$smarty->assign('cf', $cf);
|
||||
|
||||
$name = '';
|
||||
$selected_dropdown = array();
|
||||
|
||||
$smarty = new Sugar_Smarty();
|
||||
$json = getJSONobj();
|
||||
|
||||
if(!empty($_REQUEST['dropdown_name']) && !$new){
|
||||
$name = $_REQUEST['dropdown_name'];
|
||||
|
||||
// handle the case where we've saved a dropdown in one language, and now attempt to edit it for another language. The $name exists, but $my_list_strings[$name] doesn't
|
||||
// for now, we just treat it as if it was new. A better approach might be to use the first language version as a template for future languages
|
||||
if (!isset($my_list_strings[$name]))
|
||||
$my_list_strings[$name] = array () ;
|
||||
|
||||
$selected_dropdown = (!empty($vardef['options']) && !empty($my_list_strings[$vardef['options']])) ? $my_list_strings[$vardef['options']] : $my_list_strings[$name];
|
||||
$smarty->assign('ul_list', 'list = '.$json->encode(array_keys($selected_dropdown)));
|
||||
$smarty->assign('dropdown_name', (!empty($vardef['options']) ? $vardef['options'] : $_REQUEST['dropdown_name']));
|
||||
$smarty->assign('name', $_REQUEST['dropdown_name']);
|
||||
$smarty->assign('options', $selected_dropdown);
|
||||
}else{
|
||||
$smarty->assign('ul_list', 'list = {}');
|
||||
//we should try to find a name for this dropdown based on the field name.
|
||||
$pre_pop_name = '';
|
||||
if(!empty($_REQUEST['field']))
|
||||
$pre_pop_name = $_REQUEST['field'];
|
||||
//ensure this dropdown name does not already exist
|
||||
$use_name = $pre_pop_name.'_list';
|
||||
for($i = 0; $i < 100; $i++){
|
||||
if(empty($my_list_strings[$use_name]))
|
||||
break;
|
||||
else
|
||||
$use_name = $pre_pop_name.'_'.$i;
|
||||
}
|
||||
$smarty->assign('prepopulated_name', $use_name);
|
||||
}
|
||||
|
||||
$smarty->assign('module', $this->module);
|
||||
$smarty->assign('APP', $GLOBALS['app_strings']);
|
||||
$smarty->assign('MOD', $GLOBALS['mod_strings']);
|
||||
$smarty->assign('selected_lang', $selected_lang);
|
||||
$smarty->assign('available_languages',get_languages());
|
||||
$smarty->assign('package_name', $package_name);
|
||||
return $smarty;
|
||||
}
|
||||
}
|
||||
82
modules/ModuleBuilder/views/view.dropdowns.php
Executable file
82
modules/ModuleBuilder/views/view.dropdowns.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewDropdowns extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$ajax = new AjaxCompose();
|
||||
$smarty = new Sugar_Smarty();
|
||||
|
||||
if (isset($_REQUEST['refreshTree']))
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/Module/DropDownTree.php');
|
||||
$mbt = new DropDownTree();
|
||||
$ajax->addSection('west', $mbt->getName(), $mbt->fetchNodes());
|
||||
$smarty->assign('refreshTree',true);
|
||||
}
|
||||
|
||||
global $mod_strings;
|
||||
$ajax->addCrumb($mod_strings['LBL_DROPDOWNEDITOR'], 'ModuleBuilder.main("dropdowns")');
|
||||
|
||||
require_once('modules/ModuleBuilder/Module/DropDownBrowser.php');
|
||||
$dd = new DropDownBrowser();
|
||||
|
||||
$smarty->assign('LBL_BTN_ADDDROPDOWN',translate('LBL_BTN_ADDDROPDOWN'));
|
||||
$smarty->assign('dropdowns', $dd->getNodes());
|
||||
$smarty->assign('deleteImage', SugarThemeRegistry::current()->getImage( 'delete_inline', ''));
|
||||
$smarty->assign('editImage', SugarThemeRegistry::current()->getImage( 'edit_inline', ''));
|
||||
$smarty->assign('action', 'savedropdown');
|
||||
|
||||
|
||||
$ajax->addSection('center', $GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR'], $smarty->fetch('modules/ModuleBuilder/tpls/MBModule/dropdowns.tpl') );
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
75
modules/ModuleBuilder/views/view.exportcustomizations.php
Executable file
75
modules/ModuleBuilder/views/view.exportcustomizations.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
class ViewExportcustomizations extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $current_user, $mod_strings;
|
||||
$smarty = new Sugar_Smarty();
|
||||
$mb = new MBPackage("packageCustom");
|
||||
$mod=$mb->getCustomModules();
|
||||
foreach($mod as $key => $value){
|
||||
$modules[]=$key;
|
||||
$custom[]=$value;
|
||||
}
|
||||
$nb_mod = count($modules);
|
||||
$smarty->assign('mod_strings', $mod_strings);
|
||||
$smarty->assign('modules', $mod);
|
||||
$smarty->assign('custom', $custom);
|
||||
$smarty->assign('nb_mod', $nb_mod);
|
||||
$smarty->assign('defaultHelp', 'exportHelp');
|
||||
$smarty->assign('moduleList',$GLOBALS['app_list_strings']['moduleList']);
|
||||
$smarty->assign('moduleList',$GLOBALS['app_list_strings']['moduleList']);
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
|
||||
$ajax->addSection('center', $mod_strings['LBL_EC_TITLE'],$smarty->fetch('modules/ModuleBuilder/tpls/exportcustomizations.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
182
modules/ModuleBuilder/views/view.history.php
Executable file
182
modules/ModuleBuilder/views/view.history.php
Executable file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/views/History.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
|
||||
|
||||
class ViewHistory extends SugarView
|
||||
{
|
||||
var $pageSize = 10 ;
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display ()
|
||||
{
|
||||
$this->layout = strtolower ( $_REQUEST [ 'view' ] ) ;
|
||||
|
||||
$subpanelName = null ;
|
||||
if ((strtolower ( $this->layout ) == 'listview') && (!empty ( $_REQUEST [ 'subpanel' ] )))
|
||||
{
|
||||
$subpanelName = $_REQUEST [ 'subpanel' ] ;
|
||||
|
||||
}
|
||||
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower ( $_REQUEST [ 'view_package' ] ) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
$this->module = $_REQUEST [ 'view_module' ] ;
|
||||
|
||||
$this->parser = ParserFactory::getParser ( $this->layout, $this->module, $packageName, $subpanelName ) ;
|
||||
$this->history = $this->parser->getHistory () ;
|
||||
$action = ! empty ( $_REQUEST [ 'histAction' ] ) ? $_REQUEST [ 'histAction' ] : 'browse' ;
|
||||
$GLOBALS['log']->debug( get_class($this)."->display(): performing History action {$action}" ) ;
|
||||
$this->$action () ;
|
||||
}
|
||||
|
||||
function browse ()
|
||||
{
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
global $mod_strings ;
|
||||
$smarty->assign ( 'mod_strings', $mod_strings ) ;
|
||||
$smarty->assign ( 'view_module', $this->module ) ;
|
||||
$smarty->assign ( 'view', $this->layout ) ;
|
||||
|
||||
if (! empty ( $_REQUEST [ 'subpanel' ] ))
|
||||
{
|
||||
$smarty->assign ( 'subpanel', $_REQUEST [ 'subpanel' ] ) ;
|
||||
}
|
||||
$stamps = array ( ) ;
|
||||
global $timedate ;
|
||||
$userFormat = $timedate->get_date_time_format () ;
|
||||
$page = ! empty ( $_REQUEST [ 'page' ] ) ? $_REQUEST [ 'page' ] : 0 ;
|
||||
$count = $this->history->getCount();
|
||||
$ts = $this->history->getNth ( $page * $this->pageSize ) ;
|
||||
$snapshots = array ( ) ;
|
||||
for ( $i = 0 ; $i <= $this->pageSize && $ts > 0 ; $i ++ )
|
||||
{
|
||||
$dbDate = gmdate ( $timedate->get_db_date_time_format (), $ts ) ;
|
||||
$displayTS = $timedate->to_display_date_time ( $dbDate ) ;
|
||||
if ($page * $this->pageSize + $i + 1 == $count)
|
||||
$displayTS = translate("LBL_MB_DEFAULT_LAYOUT");
|
||||
$snapshots [ $ts ] = $displayTS ;
|
||||
$ts = $this->history->getNext () ;
|
||||
}
|
||||
if (count ( $snapshots ) > $this->pageSize)
|
||||
{
|
||||
$smarty->assign ( 'nextPage', true ) ;
|
||||
}
|
||||
$snapshots = array_slice ( $snapshots, 0, $this->pageSize, true ) ;
|
||||
$smarty->assign ( 'currentPage', $page ) ;
|
||||
$smarty->assign ( 'snapshots', $snapshots ) ;
|
||||
|
||||
$html = $smarty->fetch ( 'modules/ModuleBuilder/tpls/history.tpl' ) ;
|
||||
echo $html ;
|
||||
}
|
||||
|
||||
function preview ()
|
||||
{
|
||||
global $mod_strings ;
|
||||
if (! isset ( $_REQUEST [ 'sid' ] ))
|
||||
{
|
||||
die ( 'SID Required' ) ;
|
||||
}
|
||||
$sid = $_REQUEST [ 'sid' ] ;
|
||||
$subpanel = '';
|
||||
if (! empty ( $_REQUEST [ 'subpanel' ] ))
|
||||
{
|
||||
$subpanel = ',"' . $_REQUEST [ 'subpanel' ] . '"' ;
|
||||
}
|
||||
echo "<input type='button' name='close$sid' value='". translate ( 'LBL_BTN_CLOSE' )."' " .
|
||||
"class='button' onclick='ModuleBuilder.tabPanel.removeTab(ModuleBuilder.tabPanel.get(\"activeTab\"));' style='margin:5px;'>" .
|
||||
"<input type='button' name='restore$sid' value='" . translate ( 'LBL_MB_RESTORE' ) . "' " .
|
||||
"class='button' onclick='ModuleBuilder.history.revert(\"$this->module\",\"{$this->layout}\",\"$sid\"$subpanel);' style='margin:5px;'>" ;
|
||||
$this->history->restoreByTimestamp ( $sid ) ;
|
||||
$view ;
|
||||
if ($this->layout == 'listview')
|
||||
{
|
||||
require_once ("modules/ModuleBuilder/views/view.listview.php") ;
|
||||
$view = new ViewListView ( ) ;
|
||||
} else if ($this->layout == 'basic_search' || $this->layout == 'advanced_search')
|
||||
{
|
||||
require_once ("modules/ModuleBuilder/views/view.searchview.php") ;
|
||||
$view = new ViewSearchView ( ) ;
|
||||
} else if ($this->layout == 'dashlet' || $this->layout == 'dashletsearch')
|
||||
{
|
||||
require_once ("modules/ModuleBuilder/views/view.dashlet.php") ;
|
||||
$view = new ViewDashlet ( ) ;
|
||||
} else if ($this->layout == 'popuplist' || $this->layout == 'popupsearch')
|
||||
{
|
||||
require_once ("modules/ModuleBuilder/views/view.popupview.php") ;
|
||||
$view = new ViewPopupview ( ) ;
|
||||
} else
|
||||
{
|
||||
require_once ("modules/ModuleBuilder/views/view.layoutview.php") ;
|
||||
$view = new ViewLayoutView ( ) ;
|
||||
}
|
||||
|
||||
$view->display ( true ) ;
|
||||
$this->history->undoRestore () ;
|
||||
}
|
||||
|
||||
function restore ()
|
||||
{
|
||||
if (! isset ( $_REQUEST [ 'sid' ] ))
|
||||
{
|
||||
die ( 'SID Required' ) ;
|
||||
}
|
||||
$sid = $_REQUEST [ 'sid' ] ;
|
||||
$this->history->restoreByTimestamp ( $sid ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a layout to its current customized state.
|
||||
* Called when leaving a restored layout without saving.
|
||||
*/
|
||||
function unrestore()
|
||||
{
|
||||
$this->history->undoRestore () ;
|
||||
}
|
||||
}
|
||||
86
modules/ModuleBuilder/views/view.home.php
Executable file
86
modules/ModuleBuilder/views/view.home.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
class ViewHome extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $current_user;
|
||||
global $mod_strings;
|
||||
$smarty = new Sugar_Smarty();
|
||||
$smarty->assign('title' , $mod_strings['LBL_DEVELOPER_TOOLS']);
|
||||
$smarty->assign('question', $mod_strings['LBL_QUESTION_EDITOR']);
|
||||
$smarty->assign('defaultHelp', 'mainHelp');
|
||||
$this->generateHomeButtons();
|
||||
$smarty->assign('buttons', $this->buttons);
|
||||
$assistant=array('group'=>'main', 'key'=>'welcome');
|
||||
$smarty->assign('assistant',$assistant);
|
||||
//initialize Assistant's display property.
|
||||
$userPref = $current_user->getPreference('mb_assist', 'Assistant');
|
||||
if(!$userPref) $userPref="na";
|
||||
$smarty->assign('userPref',$userPref);
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addSection('center', $mod_strings['LBL_HOME'],$smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
|
||||
|
||||
function generateHomeButtons()
|
||||
{
|
||||
global $current_user;
|
||||
if(displayStudioForCurrentUser() == true) {
|
||||
//$this->buttons['Application'] = array ('action' => '', 'imageTitle' => 'Application', 'size' => '128', 'help'=>'appBtn');
|
||||
$this->buttons[$GLOBALS['mod_strings']['LBL_STUDIO']] = array ('action' => 'javascript:ModuleBuilder.main("studio")', 'imageTitle' => 'Studio', 'size' => '128', 'help'=>'studioBtn');
|
||||
}
|
||||
if(is_admin($current_user)) {
|
||||
$this->buttons[$GLOBALS['mod_strings']['LBL_MODULEBUILDER']] = array ('action' => 'javascript:ModuleBuilder.main("mb")', 'imageTitle' => 'ModuleBuilder', 'size' => '128', 'help'=>'mbBtn');
|
||||
}
|
||||
$this->buttons[$GLOBALS['mod_strings']['LBL_DROPDOWNEDITOR']] = array ('action' => 'javascript:ModuleBuilder.main("dropdowns")', 'imageTitle' => $GLOBALS['mod_strings']['LBL_HOME_EDIT_DROPDOWNS'], 'imageName' => 'DropDownEditor', 'size' => '128', 'help'=>'dropDownEditorBtn');
|
||||
}
|
||||
}
|
||||
180
modules/ModuleBuilder/views/view.labels.php
Executable file
180
modules/ModuleBuilder/views/view.labels.php
Executable file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on Jul 24, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/views/view.modulefields.php');
|
||||
class ViewLabels extends ViewModulefields
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
//STUDIO LABELS ONLY//
|
||||
//TODO Bundle Studio and ModuleBuilder label handling to increase maintainability.
|
||||
function display()
|
||||
{
|
||||
$editModule = $_REQUEST['view_module'];
|
||||
if (!isset($_REQUEST['MB']))
|
||||
{
|
||||
global $app_list_strings;
|
||||
$moduleNames = array_change_key_case($app_list_strings['moduleList']);
|
||||
$translatedEditModule = $moduleNames[strtolower($editModule)];
|
||||
}
|
||||
$selected_lang = (!empty($_REQUEST['selected_lang'])? $_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
|
||||
if(empty($selected_lang)){
|
||||
$selected_lang = $GLOBALS['sugar_config']['default_language'];
|
||||
}
|
||||
|
||||
$smarty = new Sugar_Smarty();
|
||||
global $mod_strings;
|
||||
$smarty->assign('mod_strings', $mod_strings);
|
||||
$smarty->assign('available_languages',get_languages());
|
||||
|
||||
|
||||
global $beanList;
|
||||
$objectName = $beanList[$editModule];
|
||||
if($objectName == 'aCase') {
|
||||
$objectName = 'Case';
|
||||
}
|
||||
|
||||
VardefManager::loadVardef($editModule, $objectName);
|
||||
global $dictionary;
|
||||
$vnames = array();
|
||||
//jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them.
|
||||
require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
|
||||
$parser = new ListLayoutMetaDataParser ( MB_LISTVIEW, $editModule ) ;
|
||||
foreach ( $parser->getLayout() as $key => $def )
|
||||
{
|
||||
if(isset($def['label']) ) {
|
||||
$vnames[$def['label']] = $def['label'];
|
||||
}
|
||||
}
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
|
||||
$variableMap = array ( MB_EDITVIEW => 'EditView' , MB_DETAILVIEW => 'DetailView' , MB_QUICKCREATE => 'QuickCreate' ) ;
|
||||
if($editModule == 'KBDocuments'){
|
||||
$variableMap = array();
|
||||
}
|
||||
foreach($variableMap as $key => $value){
|
||||
$gridLayoutMetaDataParserTemp = new GridLayoutMetaDataParser ( $value, $editModule) ;
|
||||
foreach ( $gridLayoutMetaDataParserTemp->getLayout() as $panel)
|
||||
{
|
||||
foreach ( $panel as $row )
|
||||
{
|
||||
foreach ( $row as $fieldArray )
|
||||
{ // fieldArray is an array('name'=>name,'label'=>label)
|
||||
if (isset ( $fieldArray [ 'label' ] ))
|
||||
{
|
||||
$vnames[$fieldArray [ 'label' ] ] = $fieldArray [ 'label' ] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//end
|
||||
|
||||
//Get Subpanel Labels:
|
||||
require_once ('include/SubPanel/SubPanel.php') ;
|
||||
$subList = SubPanel::getModuleSubpanels ( $editModule );
|
||||
foreach($subList as $subpanel => $titleLabel) {
|
||||
$vnames[$titleLabel] = $titleLabel;
|
||||
}
|
||||
|
||||
foreach($dictionary[$objectName]['fields'] as $name=>$def) {
|
||||
if(isset($def['vname'])) {
|
||||
$vnames[$def['vname']] = $def['vname'];
|
||||
}
|
||||
}
|
||||
$formatted_mod_strings = array();
|
||||
|
||||
//we shouldn't set the $refresh=true here, or will lost template language mod_strings.
|
||||
//return_module_language($selected_lang, $editModule,false) : the mod_strings will be included from cache files here.
|
||||
foreach(return_module_language($selected_lang, $editModule,false) as $name=>$label) {
|
||||
//#25294
|
||||
if(isset($vnames[$name]) || preg_match( '/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si' , $name)) {
|
||||
$formatted_mod_strings[$name] = htmlentities($label, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
//Grab everything from the custom files
|
||||
$mod_bak = $mod_strings;
|
||||
$files = array(
|
||||
"custom/modules/$editModule/language/$selected_lang.lang.php",
|
||||
"custom/modules/$editModule/Ext/Language/$selected_lang.lang.ext.php"
|
||||
);
|
||||
foreach($files as $langfile){
|
||||
$mod_strings = array();
|
||||
if (is_file($langfile))
|
||||
{
|
||||
include($langfile);
|
||||
foreach($mod_strings as $key => $label)
|
||||
{
|
||||
$formatted_mod_strings[$key] = htmlentities($label, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
}
|
||||
$mod_strings = $mod_bak;
|
||||
ksort($formatted_mod_strings);
|
||||
$smarty->assign('MOD', $formatted_mod_strings);
|
||||
$smarty->assign('view_module', $editModule);
|
||||
$smarty->assign('APP', $GLOBALS['app_strings']);
|
||||
$smarty->assign('selected_lang', $selected_lang);
|
||||
$smarty->assign('defaultHelp', 'labelsBtn');
|
||||
$smarty->assign('assistant', array('key'=>'labels', 'group'=>'module'));
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
|
||||
$ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module='.$editModule.'")');
|
||||
$ajax->addCrumb($mod_strings['LBL_LABELS'], '');
|
||||
|
||||
$html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl');
|
||||
$ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html);
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
222
modules/ModuleBuilder/views/view.layoutview.php
Executable file
222
modules/ModuleBuilder/views/view.layoutview.php
Executable file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( 'Not A Valid Entry Point' ) ;
|
||||
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: This file is used to override the default Meta-data EditView behavior
|
||||
* to provide customization specific to the Calls module.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once ('include/MVC/View/views/view.edit.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
//require_once('include/Utils.php');
|
||||
|
||||
|
||||
class ViewLayoutView extends ViewEdit
|
||||
{
|
||||
function ViewLayoutView ()
|
||||
{
|
||||
$GLOBALS [ 'log' ]->debug ( 'in ViewLayoutView' ) ;
|
||||
$this->editModule = $_REQUEST [ 'view_module' ] ;
|
||||
$this->editLayout = $_REQUEST [ 'view' ] ;
|
||||
$this->package = null;
|
||||
$this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || !empty($_REQUEST [ 'view_package' ]);
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$this->package = $_REQUEST [ 'view_package' ] ;
|
||||
} else
|
||||
{
|
||||
global $app_list_strings ;
|
||||
$moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
|
||||
$this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
// DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
|
||||
function preDisplay ()
|
||||
{
|
||||
}
|
||||
|
||||
function display ($preview = false)
|
||||
{
|
||||
|
||||
global $mod_strings ;
|
||||
$parser = ParserFactory::getParser($this->editLayout,$this->editModule,$this->package);
|
||||
$history = $parser->getHistory () ;
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
//Add in the module we are viewing to our current mod strings
|
||||
if (! $this->fromModuleBuilder) {
|
||||
global $current_language;
|
||||
$editModStrings = return_module_language($current_language, $this->editModule);
|
||||
$mod_strings = sugarArrayMerge($editModStrings, $mod_strings);
|
||||
}
|
||||
$smarty->assign('mod', $mod_strings);
|
||||
$smarty->assign('MOD', $mod_strings);
|
||||
// assign buttons
|
||||
$images = array ( 'icon_save' => 'studio_save' , 'icon_publish' => 'studio_publish' , 'icon_address' => 'icon_Address' , 'icon_emailaddress' => 'icon_EmailAddress' , 'icon_phone' => 'icon_Phone' ) ;
|
||||
foreach ( $images as $image => $file )
|
||||
{
|
||||
$smarty->assign ( $image, SugarThemeRegistry::current()->getImage($file) ) ;
|
||||
}
|
||||
|
||||
$requiredFields = implode($parser->getRequiredFields () , ',');
|
||||
$slashedRequiredFields = addslashes($requiredFields);
|
||||
$buttons = array ( ) ;
|
||||
|
||||
if ($preview)
|
||||
{
|
||||
$smarty->assign ( 'layouttitle', translate ( 'LBL_LAYOUT_PREVIEW', 'ModuleBuilder' ) ) ;
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'layouttitle', translate ( 'LBL_CURRENT_LAYOUT', 'ModuleBuilder' ) ) ;
|
||||
if (! $this->fromModuleBuilder)
|
||||
{
|
||||
$buttons [] = array ( 'id' => 'saveBtn' , 'text' => translate ( 'LBL_BTN_SAVE' ) , 'actionScript' => "onclick='if(Studio2.checkGridLayout()) Studio2.handleSave();'" ) ;
|
||||
$buttons [] = array ( 'id' => 'publishBtn' , 'text' => translate ( 'LBL_BTN_SAVEPUBLISH' ) , 'actionScript' => "onclick='if(Studio2.checkGridLayout()) Studio2.handlePublish();'" ) ;
|
||||
$buttons [] = array ( 'id' => 'spacer' , 'width' => '50px' ) ;
|
||||
$buttons [] = array ( 'id' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'") ;
|
||||
$buttons [] = array ( 'id' => 'historyDefault' , 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) , 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'" ) ;
|
||||
} else
|
||||
{
|
||||
$buttons [] = array ( 'id' => 'saveBtn' , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] , 'actionScript' => "onclick='if(Studio2.checkGridLayout()) Studio2.handlePublish();'" ) ;
|
||||
$buttons [] = array ( 'id' => 'spacer' , 'width' => '50px' ) ;
|
||||
$buttons [] = array ( 'id' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'" ) ;
|
||||
$buttons [] = array ( 'id' => 'historyDefault' , 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) , 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'" ) ;
|
||||
}
|
||||
}
|
||||
|
||||
$html = "" ;
|
||||
foreach ( $buttons as $button )
|
||||
{
|
||||
if ($button['id'] == "spacer") {
|
||||
$html .= "<td style='width:{$button['width']}'> </td>";
|
||||
} else {
|
||||
$html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' "
|
||||
. "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' "
|
||||
. "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}' ></td>" ;
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign ( 'buttons', $html ) ;
|
||||
|
||||
// assign fields and layout
|
||||
$smarty->assign ( 'available_fields', $parser->getAvailableFields () ) ;
|
||||
$smarty->assign ( 'required_fields', $requiredFields) ;
|
||||
$smarty->assign ( 'layout', $parser->getLayout () ) ;
|
||||
$smarty->assign ( 'view_module', $this->editModule ) ;
|
||||
$smarty->assign ( 'view', $this->editLayout ) ;
|
||||
$smarty->assign ( 'maxColumns', $parser->getMaxColumns() ) ;
|
||||
$smarty->assign ( 'nextPanelId', $parser->getFirstNewPanelId() ) ;
|
||||
$smarty->assign ( 'displayAsTabs', $parser->getUseTabs() ) ;
|
||||
$smarty->assign ( 'fieldwidth', 150 ) ;
|
||||
$smarty->assign ( 'translate', $this->fromModuleBuilder ? false : true ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ;
|
||||
$smarty->assign ( 'view_package', $this->package ) ;
|
||||
}
|
||||
|
||||
$labels = array (
|
||||
MB_EDITVIEW => 'LBL_EDITVIEW' ,
|
||||
MB_DETAILVIEW => 'LBL_DETAILVIEW' ,
|
||||
MB_QUICKCREATE => 'LBL_QUICKCREATE',
|
||||
) ;
|
||||
|
||||
$layoutLabel = 'LBL_LAYOUTS' ;
|
||||
$layoutView = 'layouts' ;
|
||||
|
||||
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
$viewType;
|
||||
|
||||
$translatedViewType = '' ;
|
||||
if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
|
||||
$translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
|
||||
$ajax->addCrumb ( $translatedViewType, '' ) ;
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.main("studio")' ) ;
|
||||
$ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( $translatedViewType, '' ) ;
|
||||
}
|
||||
|
||||
// set up language files
|
||||
$smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template
|
||||
$smarty->assign('from_mb',$this->fromModuleBuilder);
|
||||
if ($this->fromModuleBuilder) {
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $this->package, $this->editModule ) ;
|
||||
$smarty->assign('current_mod_strings', $module->getModStrings());
|
||||
}
|
||||
|
||||
$ajax->addSection ( 'center', $translatedViewType, $smarty->fetch ( 'modules/ModuleBuilder/tpls/layoutView.tpl' ) ) ;
|
||||
if ($preview) {
|
||||
echo $smarty->fetch ( 'modules/ModuleBuilder/tpls/Preview/layoutView.tpl' );
|
||||
} else {
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
}
|
||||
}
|
||||
340
modules/ModuleBuilder/views/view.listview.php
Executable file
340
modules/ModuleBuilder/views/view.listview.php
Executable file
@@ -0,0 +1,340 @@
|
||||
<?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/MVC/View/views/view.edit.php') ;
|
||||
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
require_once ('include/SubPanel/SubPanel.php') ;
|
||||
|
||||
class ViewListView extends ViewEdit
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
|
||||
*/
|
||||
function init ()
|
||||
{
|
||||
$this->editModule = $_REQUEST [ 'view_module' ] ;
|
||||
$this->editLayout = $_REQUEST [ 'view' ] ;
|
||||
$this->subpanel = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : false ;
|
||||
$this->subpanelLabel = (! empty ( $_REQUEST [ 'subpanelLabel' ] )) ? $_REQUEST [ 'subpanelLabel' ] : false ;
|
||||
|
||||
$this->fromModuleBuilder = ! empty ( $_REQUEST [ 'view_package' ] ) ;
|
||||
if (! $this->fromModuleBuilder)
|
||||
{
|
||||
$moduleNames = array_change_key_case ( $GLOBALS['app_list_strings'] [ 'moduleList' ] ) ;
|
||||
$this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
// DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
|
||||
function preDisplay ()
|
||||
{
|
||||
}
|
||||
|
||||
function display ($preview = false)
|
||||
{
|
||||
|
||||
$packageName = (! empty ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
$subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $this->editLayout , $this->editModule , $packageName, $subpanelName ) ;
|
||||
$smarty = $this->constructSmarty ( $parser ) ;
|
||||
|
||||
if ($preview)
|
||||
{
|
||||
echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
|
||||
} else
|
||||
{
|
||||
$ajax = $this->constructAjax () ;
|
||||
$ajax->addSection ( 'center', $this->translatedViewType, $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
|
||||
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
}
|
||||
|
||||
function constructAjax ()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
|
||||
$layoutLabel = 'LBL_LAYOUTS' ;
|
||||
$layoutView = 'layouts' ;
|
||||
|
||||
|
||||
$labels = array (
|
||||
MB_LISTVIEW => 'LBL_LISTVIEW' ,
|
||||
) ;
|
||||
$translatedViewType = '' ;
|
||||
if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
|
||||
$translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
|
||||
$this->translatedViewType = $translatedViewType;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $_REQUEST [ 'view_package' ] . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $_REQUEST [ 'view_package' ] . '&view_module=' . $_REQUEST [ 'view_module' ] . '")' ) ;
|
||||
if ($this->subpanel != "")
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_AVAILABLE_SUBPANELS', 'ModuleBuilder' ), '' ) ;
|
||||
if ($this->subpanelLabel)
|
||||
{
|
||||
$ajax->addCrumb ( $this->subpanelLabel, '' ) ;
|
||||
$this->translatedViewType = $this->subpanelLabel . " " . translate("LBL_SUBPANEL", "ModuleBuilder");
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( $this->subpanel, '' ) ;
|
||||
$this->translatedViewType = translate("LBL_SUBPANEL", "ModuleBuilder");
|
||||
}
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view_module=' . $_REQUEST [ 'view_module' ] . '&view_package=' . $_REQUEST [ 'view_package' ] . '")' ) ;
|
||||
$ajax->addCrumb ( $translatedViewType, '' ) ;
|
||||
}
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")' ) ;
|
||||
$ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
|
||||
|
||||
if ($this->subpanel)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_SUBPANELS', 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&subpanels=1&view_module=' . $this->editModule . '")' ) ;
|
||||
if ($this->subpanelLabel)
|
||||
{
|
||||
$ajax->addCrumb ( $this->subpanelLabel, '' ) ;
|
||||
$this->translatedViewType = $this->subpanelLabel . " " . translate("LBL_SUBPANEL", "ModuleBuilder");
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( $this->subpanel, '' ) ;
|
||||
$this->translatedViewType = translate("LBL_SUBPANEL", "ModuleBuilder");
|
||||
}
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( $translatedViewType, '' ) ;
|
||||
}
|
||||
}
|
||||
return $ajax ;
|
||||
}
|
||||
|
||||
function constructSmarty ($parser)
|
||||
{
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->assign ( 'translate', true ) ;
|
||||
$smarty->assign ( 'language', $parser->getLanguage () ) ;
|
||||
|
||||
$smarty->assign ( 'view', $this->editLayout ) ;
|
||||
$smarty->assign ( 'module', "ModuleBuilder" ) ;
|
||||
$smarty->assign ( 'action', 'listViewSave' ) ;
|
||||
$smarty->assign ( 'view_module', $this->editModule ) ;
|
||||
if (!empty ( $this->subpanel ) )
|
||||
{
|
||||
$smarty->assign ( 'subpanel', $this->subpanel ) ;
|
||||
if (!$this->fromModuleBuilder) {
|
||||
$subList = SubPanel::getModuleSubpanels ( $this->editModule);
|
||||
$subRef = $subList[strtolower($this->subpanel)];
|
||||
$subTitleKey = empty($subRef) ? $subRef : "LBL_" . strtoupper($this->subpanel) . "_SUBPANEL_TITLE";
|
||||
$subTitle = !empty($subRef) ? translate($subTitleKey, $this->editModule) : UCfirst($this->subpanel);
|
||||
$smarty->assign ( 'subpanel_label', $subTitleKey ) ;
|
||||
$smarty->assign ( 'subpanel_title', $subTitle ) ;
|
||||
}
|
||||
}
|
||||
$helpName = $this->subpanel ? 'subPanelEditor' : 'listViewEditor';
|
||||
$smarty->assign ( 'helpName', $helpName ) ;
|
||||
$smarty->assign ( 'helpDefault', 'modify' ) ;
|
||||
|
||||
$smarty->assign ( 'title', $this->_constructTitle () ) ;
|
||||
$groups = array ( ) ;
|
||||
foreach ( $parser->columns as $column => $function )
|
||||
{
|
||||
// update this so that each field has a properties set
|
||||
// properties are name, value, title (optional)
|
||||
$groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ; // call the parser functions to populate the list view columns, by default 'default', 'available' and 'hidden'
|
||||
}
|
||||
foreach ( $groups as $groupKey => $group )
|
||||
{
|
||||
foreach ( $group as $fieldKey => $field )
|
||||
{
|
||||
if (isset ( $field [ 'width' ] ))
|
||||
{
|
||||
if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
|
||||
{
|
||||
|
||||
$groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign ( 'groups', $groups ) ;
|
||||
$smarty->assign('from_mb', $this->fromModuleBuilder);
|
||||
|
||||
global $image_path ;
|
||||
$imageSave = SugarThemeRegistry::current()->getImage('studio_save') ;
|
||||
// $imageHelp = SugarThemeRegistry::current()->getImage('help') ;
|
||||
|
||||
$history = $parser->getHistory () ;
|
||||
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
|
||||
if ($this->subpanel)
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->subpanel}\")" ;
|
||||
|
||||
$restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'";
|
||||
if ($this->subpanel)
|
||||
$restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"{$this->subpanel}\")'";
|
||||
|
||||
$buttons = array ( ) ;
|
||||
$buttons [] = array ( 'id' =>'savebtn', 'name' => 'savebtn' , 'image' => $imageSave , 'text' => (! $this->fromModuleBuilder)?$GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVEPUBLISH' ]: $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ], 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");if (countListFields()==0) ModuleBuilder.layoutValidation.popup() ; else ModuleBuilder.handleSave(\"edittabs\" )'" ) ;
|
||||
$buttons [] = array ( 'id' => 'spacer' , 'width' => '50px' ) ;
|
||||
$buttons [] = array ( 'id' =>'historyBtn', 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
|
||||
$buttons [] = array ( 'id' => 'historyDefault' , 'name' => 'historyDefault', 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) , 'actionScript' => $restoreAction ) ;
|
||||
|
||||
$smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
|
||||
|
||||
$editImage = SugarThemeRegistry::current()->getImage('edit_inline') ;
|
||||
$smarty->assign ( 'editImage', $editImage ) ;
|
||||
$deleteImage = SugarThemeRegistry::current()->getImage('delete_inline') ;
|
||||
$smarty->assign ( 'deleteImage', $deleteImage ) ;
|
||||
$smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$smarty->assign ( 'MB', true ) ;
|
||||
$smarty->assign ( 'view_package', $_REQUEST [ 'view_package' ] ) ;
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $this->editModule ) ;
|
||||
$smarty->assign('current_mod_strings', $module->getModStrings());
|
||||
if ($this->subpanel)
|
||||
{
|
||||
if (isset ( $_REQUEST [ 'local' ] ))
|
||||
{
|
||||
$smarty->assign ( 'local', '1' ) ;
|
||||
}
|
||||
$smarty->assign ( "subpanel", $this->subpanel ) ;
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
if ($this->subpanel)
|
||||
{
|
||||
$smarty->assign ( "subpanel", "$this->subpanel" ) ;
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return $smarty ;
|
||||
}
|
||||
|
||||
function _constructTitle ()
|
||||
|
||||
{
|
||||
|
||||
global $app_list_strings ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$title = $this->editModule ;
|
||||
if ($this->subpanel != "")
|
||||
{
|
||||
$title .= ":$this->subpanel" ;
|
||||
}
|
||||
} else
|
||||
{
|
||||
$title = ($this->subpanel) ? ':' . $this->subpanel : $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
|
||||
}
|
||||
return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ': ' . $title ;
|
||||
|
||||
}
|
||||
|
||||
function _buildImageButtons ($buttons , $horizontal = true)
|
||||
{
|
||||
$text = '<table cellspacing=2><tr>' ;
|
||||
foreach ( $buttons as $button )
|
||||
{
|
||||
if (empty($button['id'])) {
|
||||
$button['id'] = $button['name'];
|
||||
}
|
||||
if (! $horizontal)
|
||||
{
|
||||
$text .= '</tr><tr>' ;
|
||||
}
|
||||
if ($button['id'] == "spacer") {
|
||||
$text .= "<td style='width:{$button['width']}'> </td>";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! empty ( $button [ 'plain' ] ))
|
||||
{
|
||||
$text .= <<<EOQ
|
||||
<td><input name={$button['name']} id={$button['id']} class="button" type="button" valign='center' {$button['actionScript']}
|
||||
EOQ;
|
||||
|
||||
} else
|
||||
{
|
||||
$text .= <<<EOQ
|
||||
<td><input name={$button['name']} id={$button['id']} class="button" type="button" valign='center' style='cursor:default' {$button['actionScript']}
|
||||
EOQ;
|
||||
}
|
||||
$text .= "value=\"{$button['text']}\"/></td>" ;
|
||||
}
|
||||
$text .= '</tr></table>' ;
|
||||
return $text ;
|
||||
}
|
||||
}
|
||||
119
modules/ModuleBuilder/views/view.main.php
Executable file
119
modules/ModuleBuilder/views/view.main.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
class ViewMain extends SugarView
|
||||
{
|
||||
function ViewMain(){
|
||||
$this->options['show_footer'] = true;
|
||||
parent::SugarView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $app_strings, $current_user, $mod_strings, $theme;
|
||||
|
||||
$smarty = new Sugar_Smarty();
|
||||
$type = (!empty($_REQUEST['type']))?$_REQUEST['type']:'main';
|
||||
$mbt = false;
|
||||
$admin = false;
|
||||
$mb = strtolower($type);
|
||||
$smarty->assign('TYPE', $type);
|
||||
$smarty->assign('app_strings', $app_strings);
|
||||
$smarty->assign('mod', $mod_strings);
|
||||
//Replaced by javascript function "setMode"
|
||||
switch($type){
|
||||
case 'studio':
|
||||
//$smarty->assign('ONLOAD','ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
|
||||
require_once('modules/ModuleBuilder/Module/StudioTree.php');
|
||||
$mbt = new StudioTree();
|
||||
break;
|
||||
case 'mb':
|
||||
//$smarty->assign('ONLOAD','ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=")');
|
||||
require_once('modules/ModuleBuilder/MB/MBPackageTree.php');
|
||||
$mbt = new MBPackageTree();
|
||||
break;
|
||||
case 'dropdowns':
|
||||
// $admin = is_admin($current_user);
|
||||
require_once('modules/ModuleBuilder/Module/DropDownTree.php');
|
||||
$mbt = new DropDownTree();
|
||||
break;
|
||||
default:
|
||||
//$smarty->assign('ONLOAD','ModuleBuilder.getContent("module=ModuleBuilder&action=home")');
|
||||
require_once('modules/ModuleBuilder/Module/MainTree.php');
|
||||
$mbt = new MainTree();
|
||||
}
|
||||
$smarty->assign('TEST_STUDIO', displayStudioForCurrentUser());
|
||||
$smarty->assign('ADMIN', is_admin($current_user));
|
||||
$smarty->display('modules/ModuleBuilder/tpls/includes.tpl');
|
||||
if($mbt)
|
||||
{
|
||||
$smarty->assign('TREE',$mbt->fetch());
|
||||
$smarty->assign('TREElabel', $mbt->getName());
|
||||
}
|
||||
$userPref = $current_user->getPreference('mb_assist', 'Assistant');
|
||||
if(!$userPref) $userPref="na";
|
||||
$smarty->assign('userPref',$userPref);
|
||||
|
||||
///////////////////////////////////
|
||||
require_once('include/SugarTinyMCE.php');
|
||||
$tiny = new SugarTinyMCE();
|
||||
$tiny->defaultConfig['width']=300;
|
||||
$tiny->defaultConfig['height']=300;
|
||||
$tiny->buttonConfig = "code,separator,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,
|
||||
justifyfull,separator,forecolor,backcolor,
|
||||
";
|
||||
$tiny->buttonConfig2 = "pastetext,pasteword,fontselect,fontsizeselect,";
|
||||
$tiny->buttonConfig3 = "";
|
||||
$ed = $tiny->getInstance();
|
||||
$smarty->assign("tiny", $ed);
|
||||
|
||||
$smarty->display('modules/ModuleBuilder/tpls/index.tpl');
|
||||
|
||||
}
|
||||
}
|
||||
101
modules/ModuleBuilder/views/view.module.php
Executable file
101
modules/ModuleBuilder/views/view.module.php
Executable file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewModule extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $mod_strings;
|
||||
$smarty = new Sugar_Smarty();
|
||||
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
$mb = new ModuleBuilder();
|
||||
$mb->getPackage($_REQUEST['view_package']);
|
||||
$package = $mb->packages[$_REQUEST['view_package']];
|
||||
$module_name = (!empty($_REQUEST['view_module']))?$_REQUEST['view_module']:'';
|
||||
$package->getModule($module_name);
|
||||
$this->module = $package->modules[$module_name];
|
||||
$this->loadPackageHelp($module_name);
|
||||
|
||||
// set up the list of either available types for a new module, or implemented types for an existing one
|
||||
$types = (empty($module_name)) ? MBModule::getTypes() : $this->module->mbvardefs->templates ;
|
||||
|
||||
foreach( $types as $type=>$definition)
|
||||
{
|
||||
$translated_type[$type]=translate('LBL_TYPE_'.strtoupper($type),'ModuleBuilder');
|
||||
}
|
||||
natcasesort($translated_type);
|
||||
$smarty->assign('types',$translated_type);
|
||||
|
||||
$smarty->assign('package', $package);
|
||||
$smarty->assign('module', $this->module);
|
||||
$smarty->assign('mod_strings', $mod_strings);
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
|
||||
$ajax->addCrumb(' '. $package->name,'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package='.$package->name.'")');
|
||||
if(empty($module_name))$module_name = translate('LBL_NEW_MODULE', 'ModuleBuilder');
|
||||
$ajax->addCrumb($module_name, '');
|
||||
$html=$smarty->fetch('modules/ModuleBuilder/tpls/MBModule/module.tpl');
|
||||
if(!empty($_REQUEST['action']) && $_REQUEST['action']=='SaveModule')
|
||||
$html .="<script>ModuleBuilder.treeRefresh('ModuleBuilder')</script>";
|
||||
$ajax->addSection('center', translate('LBL_SECTION_MODULE', 'ModuleBuilder'), $html);
|
||||
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
|
||||
function loadPackageHelp(
|
||||
$name
|
||||
)
|
||||
{
|
||||
$this->module->help['default'] = (empty($name))?'create':'modify';
|
||||
$this->module->help['group'] = 'module';
|
||||
}
|
||||
}
|
||||
306
modules/ModuleBuilder/views/view.modulefield.php
Executable file
306
modules/ModuleBuilder/views/view.modulefield.php
Executable file
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/DynamicFields/FieldViewer.php');
|
||||
|
||||
class ViewModulefield extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$ac = $this->fetch();
|
||||
echo $ac->getJavascript();
|
||||
}
|
||||
|
||||
function fetch(
|
||||
$ac = false
|
||||
)
|
||||
{
|
||||
$fv = new FieldViewer();
|
||||
if(empty($_REQUEST['field'])&& !empty($_REQUEST['name']))$_REQUEST['field'] = $_REQUEST['name'];
|
||||
$field_name = '';
|
||||
if(!empty($this->view_object_map['field_name']))
|
||||
$field_name = $this->view_object_map['field_name'];
|
||||
elseif(!empty($_REQUEST['field']))
|
||||
$field_name = $_REQUEST['field'];
|
||||
else
|
||||
$field_name = '';
|
||||
|
||||
$action = 'saveField'; // tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
|
||||
// fields we override this so don't create a new dynamic field instead of updating the existing field
|
||||
|
||||
$isClone = false;
|
||||
if(!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'])
|
||||
$isClone = true;
|
||||
/*
|
||||
$field_types = array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
|
||||
'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
|
||||
'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
|
||||
*/
|
||||
$field_types = $GLOBALS['mod_strings']['fieldTypes'];
|
||||
$field_name_exceptions = array(
|
||||
//bug 22264: Field name must not be an SQL keyword.
|
||||
//Taken from SQL Server's list of reserved keywords; http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx
|
||||
'ADD','EXCEPT','PERCENT','ALL','EXEC','PLAN','ALTER','EXECUTE','PRECISION','AND','EXISTS','PRIMARY',
|
||||
'ANY','EXIT','PRINT','AS','FETCH','PROC','ASC','FILE','PROCEDURE','AUTHORIZATION','FILLFACTOR','PUBLIC',
|
||||
'BACKUP','FOR','RAISERROR','BEGIN','FOREIGN','READ','BETWEEN','FREETEXT','READTEXT','BREAK','FREETEXTTABLE',
|
||||
'RECONFIGURE','BROWSE','FROM','REFERENCES','BULK','FULL','REPLICATION','BY','FUNCTION','RESTORE',
|
||||
'CASCADE','GOTO','RESTRICT','CASE','GRANT','RETURN','CHECK','GROUP','REVOKE','CHECKPOINT','HAVING','RIGHT','CLOSE',
|
||||
'HOLDLOCK','ROLLBACK','CLUSTERED','IDENTITY','ROWCOUNT','COALESCE','IDENTITY_INSERT','ROWGUIDCOL','COLLATE','IDENTITYCOL',
|
||||
'RULE','COLUMN','IF','SAVE','COMMIT','IN','SCHEMA','COMPUTE','INDEX','SELECT','CONSTRAINT','INNER','SESSION_USER',
|
||||
'CONTAINS','INSERT','SET','CONTAINSTABLE','INTERSECT','SETUSER','CONTINUE','INTO','SHUTDOWN','CONVERT','IS','SOME',
|
||||
'CREATE','JOIN','STATISTICS','CROSS','KEY','SYSTEM_USER','CURRENT','KILL','TABLE','CURRENT_DATE','LEFT','TEXTSIZE',
|
||||
'CURRENT_TIME','LIKE','THEN','CURRENT_TIMESTAMP','LINENO','TO','CURRENT_USER','LOAD','TOP','CURSOR','NATIONAL','TRAN',
|
||||
'DATABASE','NOCHECK','TRANSACTION','DBCC','NONCLUSTERED','TRIGGER','DEALLOCATE','NOT','TRUNCATE','DECLARE','NULL','TSEQUAL',
|
||||
'DEFAULT','NULLIF','UNION','DELETE','OF','UNIQUE','DENY','OFF','UPDATE','DESC','OFFSETS','UPDATETEXT',
|
||||
'DISK','ON','USE','DISTINCT','OPEN','USER','DISTRIBUTED','OPENCONNECTOR','VALUES','DOUBLE','OPENQUERY','VARYING',
|
||||
'DROP','OPENROWSET','VIEW','DUMMY','OPENXML','WAITFOR','DUMP','OPTION','WHEN','ELSE','OR','WHERE',
|
||||
'END','ORDER','WHILE','ERRLVL','OUTER','WITH','ESCAPE','OVER','WRITETEXT',
|
||||
//Mysql Keywords from http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html (those not in MSSQL's list)
|
||||
'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER',
|
||||
'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED',
|
||||
'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN',
|
||||
'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE',
|
||||
'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8',
|
||||
'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK',
|
||||
'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT',
|
||||
'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE',
|
||||
'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE',
|
||||
'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME',
|
||||
'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS',
|
||||
'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT',
|
||||
'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP',
|
||||
'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE',
|
||||
//Oracle datatypes
|
||||
'DATE','VARCHAR','VARCHAR2','NVARCHAR2','CHAR','NCHAR','NUMBER','PLS_INTEGER','BINARY_INTEGER','LONG','TIMESTAMP',
|
||||
'INTERVAL','RAW','ROWID','UROWID','MLSLABEL','CLOB','NCLOB','BLOB','BFILE','XMLTYPE',
|
||||
//SugarCRM reserved
|
||||
'ID', 'ID_C',
|
||||
);
|
||||
|
||||
if(! isset($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio' || empty ( $_REQUEST [ 'view_package' ] ) ) {
|
||||
$module = new stdClass;
|
||||
$moduleName = $_REQUEST['view_module'];
|
||||
|
||||
global $beanList;
|
||||
|
||||
$objectName = $beanList[$moduleName];
|
||||
$className = $objectName;
|
||||
if($objectName == 'aCase') // Bug 17614 - renamed aCase as Case in vardefs for backwards compatibililty with 451 modules
|
||||
$objectName = 'Case';
|
||||
|
||||
$module = new $className();
|
||||
|
||||
VardefManager::loadVardef($moduleName, $objectName,true);
|
||||
global $dictionary;
|
||||
$module->mbvardefs->vardefs = $dictionary[$objectName];
|
||||
|
||||
// $GLOBALS['log']->debug('vardefs from dictionary = '.print_r($module->mbvardefs->vardefs,true));
|
||||
$module->name = $moduleName;
|
||||
if(!$ac){
|
||||
$ac = new AjaxCompose();
|
||||
}
|
||||
$vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name]))? $module->mbvardefs->vardefs['fields'][$field_name]: array();
|
||||
if($isClone){
|
||||
unset($vardef['name']);
|
||||
}
|
||||
|
||||
if(empty($vardef['name'])){
|
||||
if(!empty($_REQUEST['type']))
|
||||
$vardef['type'] = $_REQUEST['type'];
|
||||
$fv->ss->assign('hideLevel', 0);
|
||||
}elseif(isset($vardef['custom_module'])){
|
||||
$fv->ss->assign('hideLevel', 2);
|
||||
}else{
|
||||
$action = 'saveSugarField'; // tyoung - for OOB fields we currently only support modifying the label
|
||||
$fv->ss->assign('hideLevel', 3);
|
||||
}
|
||||
if($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime'){
|
||||
$vardef['type'] = 'datetimecombo';
|
||||
}
|
||||
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ;
|
||||
$tf->module = $module;
|
||||
$tf->populateFromRow($vardef);
|
||||
$vardef = array_merge($vardef, $tf->get_field_def());
|
||||
|
||||
// $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
|
||||
|
||||
|
||||
//Check if autoincrement fields are allowed
|
||||
$allowAutoInc = true;
|
||||
foreach($module->field_defs as $field => $def)
|
||||
{
|
||||
if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) {
|
||||
$allowAutoInc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$fv->ss->assign( 'allowAutoInc', $allowAutoInc);
|
||||
|
||||
$GLOBALS['log']->warn('view.modulefield: hidelevel '.$fv->ss->get_template_vars('hideLevel')." ".print_r($vardef,true));
|
||||
if(!empty($vardef['vname'])){
|
||||
$fv->ss->assign('lbl_value', htmlentities(translate($vardef['vname'], $moduleName), ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
$fv->ss->assign('module', $module);
|
||||
if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent'))
|
||||
$field_types['parent'] = $GLOBALS['mod_strings']['parent'];
|
||||
|
||||
$edit_or_add = 'editField' ;
|
||||
|
||||
} else
|
||||
{
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
$mb = new ModuleBuilder();
|
||||
$module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
|
||||
$package =& $mb->packages[$_REQUEST['view_package']];
|
||||
$module->getVardefs();
|
||||
if(!$ac){
|
||||
$ac = new AjaxCompose();
|
||||
}
|
||||
$vardef = (!empty($module->mbvardefs->vardefs['fields'][$field_name]))? $module->mbvardefs->vardefs['fields'][$field_name]: array();
|
||||
if($isClone){
|
||||
unset($vardef['name']);
|
||||
}
|
||||
|
||||
if(empty($vardef['name'])){
|
||||
if(!empty($_REQUEST['type']))$vardef['type'] = $_REQUEST['type'];
|
||||
$fv->ss->assign('hideLevel', 0);
|
||||
}else{
|
||||
if(!empty($module->mbvardefs->vardef['fields'][$vardef['name']])){
|
||||
$fv->ss->assign('hideLevel', 1);
|
||||
}elseif(isset($vardef['custom_module'])){
|
||||
$fv->ss->assign('hideLevel', 2);
|
||||
}else{
|
||||
$fv->ss->assign('hideLevel', 3); // tyoung bug 17350 - effectively mark template derived fields as readonly
|
||||
}
|
||||
}
|
||||
|
||||
require_once ('modules/DynamicFields/FieldCases.php') ;
|
||||
$tf = get_widget ( empty($vardef [ 'type' ]) ? "" : $vardef [ 'type' ]) ;
|
||||
$tf->module = $module;
|
||||
$tf->populateFromRow($vardef);
|
||||
$vardef = array_merge($vardef, $tf->get_field_def());
|
||||
|
||||
|
||||
|
||||
$fv->ss->assign('module', $module);
|
||||
$fv->ss->assign('package', $package);
|
||||
$fv->ss->assign('MB','1');
|
||||
|
||||
if(isset($vardef['vname']))
|
||||
$fv->ss->assign('lbl_value', htmlentities($module->getLabel('en_us',$vardef['vname']), ENT_QUOTES, 'UTF-8'));
|
||||
if(empty($module->mbvardefs->vardefs['fields']['parent_name']) || (isset($vardef['type']) && $vardef['type'] == 'parent'))
|
||||
$field_types['parent'] = $GLOBALS['mod_strings']['parent'];
|
||||
|
||||
$edit_or_add = 'mbeditField';
|
||||
}
|
||||
|
||||
if($_REQUEST['action'] == 'RefreshField'){
|
||||
require_once('modules/DynamicFields/FieldCases.php');
|
||||
$field = get_widget($_POST['type']);
|
||||
$field->populateFromPost();
|
||||
$vardef = $field->get_field_def();
|
||||
$vardef['options'] = $_REQUEST['new_dropdown'];
|
||||
$fv->ss->assign('lbl_value', htmlentities($_REQUEST['labelValue'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
foreach(array("formula", "default", "comments", "help") as $toEscape)
|
||||
{
|
||||
if (!empty($vardef[$toEscape]) && is_string($vardef[$toEscape])) {
|
||||
$vardef[$toEscape] = htmlentities($vardef[$toEscape], ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($vardef['studio']) && is_array($vardef['studio']) && !empty($vardef['studio']['no_duplicate']) && $vardef['studio']['no_duplicate'] == true) {
|
||||
$fv->ss->assign('no_duplicate', true);
|
||||
}
|
||||
|
||||
$fv->ss->assign('action',$action);
|
||||
$fv->ss->assign('isClone', ($isClone ? 1 : 0));
|
||||
$json = getJSONobj();
|
||||
|
||||
$fv->ss->assign('field_name_exceptions', $json->encode($field_name_exceptions));
|
||||
ksort($field_types);
|
||||
$fv->ss->assign('field_types',$field_types);
|
||||
$fv->ss->assign('importable_options', $GLOBALS['app_list_strings']['custom_fields_importable_dom']);
|
||||
$fv->ss->assign('duplicate_merge_options', $GLOBALS['app_list_strings']['custom_fields_merge_dup_dom']);
|
||||
|
||||
$triggers = array () ;
|
||||
foreach ( $module->mbvardefs->vardefs['fields'] as $field )
|
||||
{
|
||||
if ($field [ 'type' ] == 'enum' || $field [ 'type'] == 'multienum' )
|
||||
{
|
||||
$triggers [] = $field [ 'name' ] ;
|
||||
}
|
||||
}
|
||||
$fv->ss->assign('triggers',$triggers);
|
||||
|
||||
$fv->ss->assign('mod_strings',$GLOBALS['mod_strings']);
|
||||
|
||||
// jchi #24880
|
||||
// end
|
||||
$layout = $fv->getLayout($vardef);
|
||||
|
||||
$fv->ss->assign('fieldLayout', $layout);
|
||||
if(empty($vardef['type']))
|
||||
$vardef['type'] = 'varchar';
|
||||
$fv->ss->assign('vardef', $vardef);
|
||||
|
||||
|
||||
if(empty($_REQUEST['field'])){
|
||||
$edit_or_add = 'addField';
|
||||
}
|
||||
|
||||
$fv->ss->assign('help_group', $edit_or_add);
|
||||
$body = $fv->ss->fetch('modules/ModuleBuilder/tpls/MBModule/field.tpl');
|
||||
$ac->addSection('east', translate('LBL_SECTION_FIELDEDITOR','ModuleBuilder'), $body );
|
||||
return $ac;
|
||||
}
|
||||
}
|
||||
210
modules/ModuleBuilder/views/view.modulefields.php
Executable file
210
modules/ModuleBuilder/views/view.modulefields.php
Executable file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/views/view.modulefield.php');
|
||||
|
||||
class ViewModulefields extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$smarty = new Sugar_Smarty();
|
||||
global $mod_strings;
|
||||
$bak_mod_strings=$mod_strings;
|
||||
$smarty->assign('mod_strings', $mod_strings);
|
||||
|
||||
$module_name = $_REQUEST['view_module'];
|
||||
|
||||
if(! isset($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
|
||||
//$this->loadPackageHelp($module_name);
|
||||
$studioClass = new stdClass;
|
||||
$studioClass->name = $module_name;
|
||||
|
||||
global $beanList;
|
||||
$objectName = $beanList[$module_name];
|
||||
|
||||
if($objectName == 'aCase') // Bug 17614 - renamed aCase as Case in vardefs for backwards compatibililty with 451 modules
|
||||
$objectName = 'Case';
|
||||
|
||||
VardefManager::loadVardef($module_name, $objectName);
|
||||
global $dictionary;
|
||||
$f = array($mod_strings['LBL_HCUSTOM']=>array(), $mod_strings['LBL_HDEFAULT']=>array());
|
||||
|
||||
// TODO: replace this section to select fields to list with the algorithm in AbstractMetaDataImplmentation::validField()
|
||||
$def = $this->cullFields($dictionary[$objectName]['fields']);
|
||||
|
||||
foreach($dictionary[$objectName]['fields'] as $def) {
|
||||
if ($this->isValidStudioField($def))
|
||||
{
|
||||
//Custom relate fields will have a non-db source, but custom_module set
|
||||
if(isset($def['source']) && $def['source'] == 'custom_fields' || isset($def['custom_module'])) {
|
||||
$f[$mod_strings['LBL_HCUSTOM']][$def['name']] = $def;
|
||||
} else {
|
||||
$f[$mod_strings['LBL_HDEFAULT']][$def['name']] = $def;
|
||||
}
|
||||
}
|
||||
}
|
||||
$studioClass->mbvardefs->vardefs['fields'] = $f;
|
||||
$smarty->assign('module', $studioClass);
|
||||
|
||||
$package = new stdClass;
|
||||
$package->name = '';
|
||||
$smarty->assign('package', $package);
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
|
||||
$ajax->addCrumb(translate($module_name), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module='.$module_name.'")');
|
||||
$ajax->addCrumb($mod_strings['LBL_FIELDS'], '');
|
||||
$ajax->addSection('center', $mod_strings['LBL_EDIT_FIELDS'],$smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
|
||||
$_REQUEST['field'] = '';
|
||||
|
||||
echo $ajax->getJavascript();
|
||||
} else {
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
$mb = new ModuleBuilder();
|
||||
$mb->getPackage($_REQUEST['view_package']);
|
||||
$package = $mb->packages[$_REQUEST['view_package']];
|
||||
|
||||
$package->getModule($module_name);
|
||||
$this->module = $package->modules[$module_name];
|
||||
$this->loadPackageHelp($module_name);
|
||||
$this->module->getVardefs(true);
|
||||
$this->module->mbvardefs->vardefs['fields'] = array_reverse($this->module->mbvardefs->vardefs['fields'], true);
|
||||
$loadedFields = array();
|
||||
foreach($this->module->mbvardefs->vardefs['fields'] as $k=>$v){
|
||||
if($k != $module_name)
|
||||
$titleLBL[$k]=translate("LBL_".strtoupper($k),'ModuleBuilder');
|
||||
else{
|
||||
$titleLBL[$k]=$k;
|
||||
}
|
||||
foreach($v as $field => $def)
|
||||
{
|
||||
if (isset($loadedFields[$field]))
|
||||
unset($this->module->mbvardefs->vardefs['fields'][$k][$field]);
|
||||
else
|
||||
$loadedFields[$field] = true;
|
||||
}
|
||||
}
|
||||
$this->module->mbvardefs->vardefs['fields'][$module_name] = $this->cullFields($this->module->mbvardefs->vardefs['fields'][$module_name]);
|
||||
if(file_exists($this->module->path. '/language/'.$GLOBALS['current_language'].'.lang.php')){
|
||||
include($this->module->path .'/language/'. $GLOBALS['current_language'].'.lang.php');
|
||||
$this->module->setModStrings($GLOBALS['current_language'],$mod_strings);
|
||||
}
|
||||
elseif(file_exists($this->module->path. '/language/en_us.lang.php')){
|
||||
include($this->module->path .'/language/en_us.lang.php');
|
||||
$this->module->setModStrings('en_us',$mod_strings);
|
||||
}
|
||||
$smarty->assign('title', $titleLBL);
|
||||
$smarty->assign('package', $package);
|
||||
$smarty->assign('module', $this->module);
|
||||
$smarty->assign('editLabelsMb','1'); //need to merge MB labels and studio labels. quick fix for now.
|
||||
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($bak_mod_strings['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
|
||||
$ajax->addCrumb($package->name,'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package='.$package->name.'")');
|
||||
$ajax->addCrumb($module_name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package='.$package->name.'&view_module='. $module_name . '")');
|
||||
$ajax->addCrumb($bak_mod_strings['LBL_FIELDS'], '');
|
||||
$ajax->addSection('center', $bak_mod_strings["LBL_FIELDS"],$smarty->fetch('modules/ModuleBuilder/tpls/MBModule/fields.tpl'));
|
||||
$_REQUEST['field'] = '';
|
||||
|
||||
echo $ajax->getJavascript();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function loadPackageHelp(
|
||||
$name
|
||||
)
|
||||
{
|
||||
$this->module->help['default'] = (empty($name))?'create':'modify';
|
||||
$this->module->help['group'] = 'module';
|
||||
}
|
||||
|
||||
function cullFields(
|
||||
$def
|
||||
)
|
||||
{
|
||||
if(!empty($def['parent_id']))
|
||||
unset($def['parent_id']);
|
||||
if(!empty($def['parent_type']))
|
||||
unset($def['parent_type']);
|
||||
if(!empty($def['currency_id']))
|
||||
unset($def['currency_id']);
|
||||
return $def;
|
||||
}
|
||||
|
||||
function isValidStudioField(
|
||||
$def
|
||||
)
|
||||
{
|
||||
if (isset($def['studio'])) {
|
||||
if (is_array($def [ 'studio' ]))
|
||||
{
|
||||
if (isset($def['studio']['editField']) && $def['studio']['editField'] == true)
|
||||
return true;
|
||||
if (isset($def['studio']['required']) && $def['studio']['required'])
|
||||
return true;
|
||||
|
||||
} else
|
||||
{
|
||||
if ($def['studio'] == 'visible')
|
||||
return true;
|
||||
if ($def['studio'] == 'hidden' || $def['studio'] == 'false' || !$def['studio'] )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (empty($def ['source']) || $def ['source'] == 'db' || $def ['source'] == 'custom_fields')
|
||||
{
|
||||
if ($def ['type'] != 'id' && (empty($def ['dbType']) || $def ['dbType'] != 'id'))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
102
modules/ModuleBuilder/views/view.modulelabels.php
Executable file
102
modules/ModuleBuilder/views/view.modulelabels.php
Executable file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on Aug 6, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
|
||||
class ViewModulelabels extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $mod_strings;
|
||||
$bak_mod_strings=$mod_strings;
|
||||
$smarty = new Sugar_Smarty();
|
||||
$smarty->assign('mod_strings', $mod_strings);
|
||||
$package_name = $_REQUEST['view_package'];
|
||||
$module_name = $_REQUEST['view_module'];
|
||||
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
$mb = new ModuleBuilder();
|
||||
$mb->getPackage($_REQUEST['view_package']);
|
||||
$package = $mb->packages[$_REQUEST['view_package']];
|
||||
$package->getModule($module_name);
|
||||
$this->module = $package->modules[$module_name];
|
||||
$selected_lang = (!empty($_REQUEST['selected_lang'])?$_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
|
||||
if(empty($selected_lang)){
|
||||
$selected_lang = $GLOBALS['sugar_config']['default_language'];
|
||||
}
|
||||
//need to change the following to interface with MBlanguage.
|
||||
$smarty->assign('MOD', $this->module->getModStrings($selected_lang));
|
||||
$smarty->assign('APP', $GLOBALS['app_strings']);
|
||||
$smarty->assign('selected_lang', $selected_lang);
|
||||
$smarty->assign('view_package', $package_name);
|
||||
$smarty->assign('view_module', $module_name);
|
||||
$smarty->assign('mb','1');
|
||||
$smarty->assign('available_languages', get_languages());
|
||||
///////////////////////////////////////////////////////////////////
|
||||
////ASSISTANT
|
||||
$smarty->assign('assistant',array('group'=>'module', 'key'=>'labels'));
|
||||
/////////////////////////////////////////////////////////////////
|
||||
////ASSISTANT
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($bak_mod_strings['LBL_MODULEBUILDER'], 'ModuleBuilder.main("mb")');
|
||||
$ajax->addCrumb($package_name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package='.$package->name. '")');
|
||||
$ajax->addCrumb($module_name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&package='.$package->name.'&module='. $module_name . '")');
|
||||
$ajax->addCrumb($bak_mod_strings['LBL_LABELS'], '');
|
||||
$ajax->addSection('center', $bak_mod_strings['LBL_LABELS'],$smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
|
||||
141
modules/ModuleBuilder/views/view.package.php
Executable file
141
modules/ModuleBuilder/views/view.package.php
Executable file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
|
||||
class Viewpackage extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $mod_strings;
|
||||
$smarty = new Sugar_Smarty();
|
||||
$mb = new ModuleBuilder();
|
||||
//if (!empty($_REQUEST['package'])) {
|
||||
if (empty($_REQUEST['package']) && empty($_REQUEST['new'])) {
|
||||
$this->generatePackageButtons($mb->getPackageList());
|
||||
|
||||
$smarty->assign('buttons', $this->buttons);
|
||||
$smarty->assign('title', $GLOBALS['mod_strings']['LBL_MODULEBUILDER']);
|
||||
$smarty->assign("question", $GLOBALS['mod_strings']['LBL_QUESTION_PACKAGE']);
|
||||
$smarty->assign("defaultHelp", "mbHelp");
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")');
|
||||
$ajax->addCrumb($GLOBALS['mod_strings']['LBL_PACKAGE_LIST'],'');
|
||||
$ajax->addSection('center', $GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], $smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
else {
|
||||
$name = (!empty($_REQUEST['package']))?$_REQUEST['package']:'';
|
||||
$mb->getPackage($name);
|
||||
$this->package =& $mb->packages[$name];
|
||||
$this->loadModuleTypes();
|
||||
$this->loadPackageHelp($name);
|
||||
$this->package->date_modified = $GLOBALS['timedate']->to_display_date_time($this->package->date_modified);
|
||||
$smarty->assign('package', $this->package);
|
||||
$smarty->assign('mod_strings',$mod_strings);
|
||||
$smarty->assign('package_already_deployed', 'false');
|
||||
foreach($this->package->modules as $a_module){
|
||||
if(in_array($a_module->key_name, $GLOBALS['moduleList'])){
|
||||
$smarty->assign('package_already_deployed', 'true');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ajax = new AjaxCompose();
|
||||
$ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")');
|
||||
if(empty($name))$name = $mod_strings['LBL_NEW_PACKAGE'];
|
||||
$ajax->addCrumb($name,'');
|
||||
$html=$smarty->fetch('modules/ModuleBuilder/tpls/MBPackage/package.tpl');
|
||||
if(!empty($_REQUEST['action']) && $_REQUEST['action']=='SavePackage')
|
||||
$html.="<script>ModuleBuilder.treeRefresh('ModuleBuilder')</script>";
|
||||
$ajax->addSection('center', translate('LBL_SECTION_PACKAGE', 'ModuleBuilder'), $html);
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
|
||||
function loadModuleTypes()
|
||||
{
|
||||
$this->package->moduleTypes = array();
|
||||
$this->package->loadModules();
|
||||
foreach(array_keys($this->package->modules) as $name){
|
||||
foreach($this->package->modules[$name]->config['templates'] as $template=>$var){
|
||||
|
||||
$this->package->moduleTypes[$name] = $template;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
function loadPackageHelp(
|
||||
$name
|
||||
)
|
||||
{
|
||||
$this->package->help['default'] = (empty($name))?'create':'modify';
|
||||
$this->package->help['group'] = 'package';
|
||||
}
|
||||
|
||||
function generatePackageButtons(
|
||||
$packages
|
||||
)
|
||||
{
|
||||
global $mod_strings;
|
||||
$this->buttons[$mod_strings['LBL_NEW_PACKAGE']] = array(
|
||||
'action' => "module=ModuleBuilder&action=package&new=1",
|
||||
'imageTitle' => 'package_create',
|
||||
'size' => '64',
|
||||
'help' => 'newPackage',
|
||||
);
|
||||
foreach($packages as $package) {
|
||||
$this->buttons[$package] = array(
|
||||
'action' =>"module=ModuleBuilder&action=package&package={$package}",
|
||||
'imageTitle' => 'package',
|
||||
'size' => '64',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
224
modules/ModuleBuilder/views/view.popupview.php
Executable file
224
modules/ModuleBuilder/views/view.popupview.php
Executable file
@@ -0,0 +1,224 @@
|
||||
<?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 ('modules/ModuleBuilder/views/view.listview.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class ViewPopupview extends ViewListView
|
||||
{
|
||||
function ViewPopupview()
|
||||
{
|
||||
$this->init ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->editModule = $_REQUEST [ 'view_module' ] ;
|
||||
$this->editLayout = $_REQUEST [ 'view' ] ;
|
||||
$this->editPackage = (isset ( $_REQUEST [ 'view_package' ] ) && ! empty ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
|
||||
|
||||
$this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (isset($_REQUEST['view_package']) && $_REQUEST['view_package'] && $_REQUEST['view_package'] != 'studio') ;
|
||||
if (!$this->fromModuleBuilder)
|
||||
{
|
||||
global $app_list_strings ;
|
||||
$moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
|
||||
$this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
|
||||
}
|
||||
}
|
||||
|
||||
function preDisplay()
|
||||
{
|
||||
}
|
||||
|
||||
function display(
|
||||
$preview = false
|
||||
)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $this->editLayout, $this->editModule, $this->editPackage) ;
|
||||
|
||||
$smarty = $this->constructSmarty ( $parser ) ;
|
||||
if ($preview)
|
||||
{
|
||||
echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
|
||||
} else
|
||||
{
|
||||
$ajax = $this->constructAjax () ;
|
||||
$ajax->addSection ( 'center', translate('LBL_POPUP'), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
}
|
||||
|
||||
function constructAjax()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->editPackage . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->editPackage . '&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")');
|
||||
$ajax->addCrumb ( translate('LBL_POPUP', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=popup&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")' );
|
||||
|
||||
$ViewLabel = ($this->editLayout == MB_POPUPLIST) ? 'LBL_POPUPLISTVIEW' : 'LBL_POPUPSEARCH';
|
||||
$ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
|
||||
}else{
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->editModule . '")');
|
||||
$ajax->addCrumb ( translate('LBL_POPUP', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=popup&view_module=' . $this->editModule . '")' );
|
||||
$ViewLabel = ($this->editLayout == MB_POPUPLIST) ? 'LBL_POPUPLISTVIEW' : 'LBL_POPUPSEARCH';
|
||||
$ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
|
||||
}
|
||||
return $ajax ;
|
||||
}
|
||||
|
||||
function constructSmarty(
|
||||
$parser
|
||||
)
|
||||
{
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->assign ( 'translate', true ) ;
|
||||
$smarty->assign ( 'language', $parser->getLanguage () ) ;
|
||||
|
||||
$smarty->assign ( 'view', $this->editLayout ) ;
|
||||
$smarty->assign ( 'action', 'popupSave' ) ;
|
||||
$smarty->assign( 'module', 'ModuleBuilder');
|
||||
$smarty->assign ( 'view_module', $this->editModule ) ;
|
||||
$helpName = (isset( $_REQUEST['view']) && $_REQUEST['view']==MB_POPUPSEARCH) ? 'searchViewEditor' : 'popupListViewEditor';
|
||||
$smarty->assign ( 'helpName', $helpName ) ;
|
||||
$smarty->assign ( 'helpDefault', 'modify' ) ;
|
||||
if ($this->fromModuleBuilder) {
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $this->editPackage, $this->editModule ) ;
|
||||
$smarty->assign('current_mod_strings', $module->getModStrings());
|
||||
}
|
||||
|
||||
$smarty->assign ( 'title', $this->_constructTitle () ) ;
|
||||
$groups = array ( ) ;
|
||||
foreach ( $parser->columns as $column => $function )
|
||||
{
|
||||
$groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ;
|
||||
}
|
||||
foreach ( $groups as $groupKey => $group )
|
||||
{
|
||||
foreach ( $group as $fieldKey => $field )
|
||||
{
|
||||
if (isset ( $field [ 'width' ] ))
|
||||
{
|
||||
if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
|
||||
{
|
||||
$groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign ( 'groups', $groups ) ;
|
||||
|
||||
global $image_path ;
|
||||
$imageSave = SugarThemeRegistry::current()->getImage('studio_save') ;
|
||||
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
|
||||
if (isset($this->searchlayout))
|
||||
$histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->searchlayout}\")" ;
|
||||
|
||||
$buttons = array ( ) ;
|
||||
if (! $this->fromModuleBuilder)
|
||||
{
|
||||
$buttons [] = array ( 'name' => 'savebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVEPUBLISH' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
|
||||
} else
|
||||
{
|
||||
$buttons [] = array ( 'name' => 'mbsavebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
|
||||
}
|
||||
$buttons [] = array ( 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
|
||||
$smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
|
||||
$editImage = SugarThemeRegistry::current()->getImage('edit_inline') ;
|
||||
$smarty->assign ( 'editImage', $editImage ) ;
|
||||
$deleteImage = SugarThemeRegistry::current()->getImage('delete_inline') ;
|
||||
$smarty->assign ( 'deleteImage', $deleteImage ) ;
|
||||
$smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$smarty->assign ( 'MB', true ) ;
|
||||
$smarty->assign ( 'view_package', $this->editPackage ) ;
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
|
||||
}
|
||||
|
||||
return $smarty ;
|
||||
}
|
||||
|
||||
function _constructTitle()
|
||||
{
|
||||
|
||||
global $app_list_strings ;
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$title = $this->editModule ;
|
||||
} else
|
||||
{
|
||||
$title = $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
|
||||
}
|
||||
return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ': ' . $title ;
|
||||
|
||||
}
|
||||
}
|
||||
131
modules/ModuleBuilder/views/view.property.php
Executable file
131
modules/ModuleBuilder/views/view.property.php
Executable file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once ('include/MVC/View/SugarView.php');
|
||||
require_once ('modules/ModuleBuilder/parsers/ParserFactory.php');
|
||||
|
||||
class ViewProperty extends SugarView
|
||||
{
|
||||
function ViewProperty()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function init () // pseduo-constuctor - given a well-known name to allow subclasses to call this classes constructor
|
||||
{
|
||||
$this->editModule = (! empty($_REQUEST['view_module'])) ? $_REQUEST['view_module'] : null;
|
||||
$this->editPackage = (! empty($_REQUEST['view_package'])) ? $_REQUEST['view_package'] : null;
|
||||
$this->id = (! empty($_REQUEST['id'])) ? $_REQUEST['id'] : null;
|
||||
$this->subpanel = (! empty($_REQUEST['subpanel'])) ? $_REQUEST['subpanel'] : "";
|
||||
$this->properties = array();
|
||||
foreach($_REQUEST as $key=>$value)
|
||||
{
|
||||
if (substr($key,0,4) == 'name')
|
||||
{
|
||||
$this->properties[substr($key,5)]['name'] = $value;
|
||||
}
|
||||
if (substr($key,0,2) == 'id')
|
||||
{
|
||||
$this->properties[substr($key,3)]['id'] = $value;
|
||||
}
|
||||
if (substr($key,0,5) == 'value')
|
||||
{
|
||||
$this->properties[substr($key,6)]['value'] = $value;
|
||||
// tyoung - now a nasty hack to disable editing of labels which contain Smarty functions - this is envisaged to be a temporary fix to prevent admins modifying these functions then being unable to restore the original complicated value if they regret it
|
||||
if (substr($key,6) == 'label')
|
||||
{
|
||||
//#29796 , we disable the edit function for sub panel label
|
||||
if (preg_match('/\{.*\}/',$value) || !empty($this->subpanel))
|
||||
{
|
||||
$this->properties[substr($key,6)]['hidden'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (substr($key,0,5) == 'title')
|
||||
{
|
||||
$this->properties[substr($key,6)]['title'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
global $mod_strings;
|
||||
$ajax = new AjaxCompose();
|
||||
$smarty = new Sugar_Smarty();
|
||||
if (isset($_REQUEST['MB']) && $_REQUEST['MB'] == "1")
|
||||
{
|
||||
$smarty->assign("MB", $_REQUEST['MB']);
|
||||
$smarty->assign("view_package", $_REQUEST['view_package']);
|
||||
}
|
||||
|
||||
$selected_lang = (!empty($_REQUEST['selected_lang'])?$_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
|
||||
if(empty($selected_lang)){
|
||||
$selected_lang = $GLOBALS['sugar_config']['default_language'];
|
||||
}
|
||||
$smarty->assign('available_languages', get_languages());
|
||||
$smarty->assign('selected_lang', $selected_lang);
|
||||
|
||||
ksort($this->properties);
|
||||
|
||||
$smarty->assign("properties",$this->properties);
|
||||
// $smarty->assign("id",$this->id);
|
||||
|
||||
$smarty->assign("mod_strings",$mod_strings);
|
||||
$smarty->assign('APP', $GLOBALS['app_strings']);
|
||||
$smarty->assign("view_module", $this->editModule);
|
||||
$smarty->assign("subpanel", $this->subpanel);
|
||||
if (isset($this->editPackage))
|
||||
$smarty->assign("view_package", $this->editPackage);
|
||||
|
||||
$ajax->addSection('east', translate('LBL_SECTION_PROPERTIES', 'ModuleBuilder'), $smarty->fetch('modules/ModuleBuilder/tpls/editProperty.tpl'));
|
||||
echo $ajax->getJavascript();
|
||||
}
|
||||
}
|
||||
272
modules/ModuleBuilder/views/view.relationship.php
Executable file
272
modules/ModuleBuilder/views/view.relationship.php
Executable file
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioModuleFactory.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ;
|
||||
require_once ('modules/ModuleBuilder/parsers/constants.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/RelationshipFactory.php' ;
|
||||
|
||||
class ViewRelationship extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function overrideDefinitionFromPOST(
|
||||
$definition
|
||||
)
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ;
|
||||
foreach ( AbstractRelationship::$definitionKeys as $key )
|
||||
{
|
||||
if(!empty($_REQUEST ['ajaxLoad']) && in_array($key, array('label', 'rhs_label', 'lhs_label')) ){
|
||||
continue;
|
||||
}
|
||||
if (! empty ( $_REQUEST [ $key ] ))
|
||||
{
|
||||
$definition [ $key ] = $_REQUEST [ $key ] ;
|
||||
}
|
||||
}
|
||||
return $definition ;
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
|
||||
$this->smarty = new Sugar_Smarty ( ) ;
|
||||
$ac = new AjaxCompose ( ) ;
|
||||
$this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (!empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio') ;
|
||||
$this->smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ;
|
||||
|
||||
if (!$this->fromModuleBuilder)
|
||||
{
|
||||
$module = StudioModuleFactory::getStudioModule( $_REQUEST [ 'view_module' ] ) ;
|
||||
$moduleName = $_REQUEST [ 'view_module' ] ;
|
||||
$fields = $module->fields ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
$relatableModules = DeployedRelationships::findRelatableModules () ;
|
||||
$appStrings = return_app_list_strings_language( $selected_lang ) ;
|
||||
$modStrings = return_module_language( $selected_lang, $_REQUEST [ 'view_module' ], true ) ;
|
||||
$appStrings = $appStrings['moduleList'];
|
||||
} else
|
||||
{
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$mb->getPackages();
|
||||
//display the latest module name rather than what is in or not in the loaded app_list_strings.
|
||||
$mb->getPackage($_REQUEST ['view_package'])->loadModuleTitles();
|
||||
$module = $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$moduleName = empty($module->key_name) ? $module->getModuleName() : $module->key_name;
|
||||
$this->smarty->assign ( 'view_package', $_REQUEST [ 'view_package' ] ) ;
|
||||
$mbvardefs = $module->getVardefs () ;
|
||||
$fields = $mbvardefs [ 'fields' ] ;
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
|
||||
$relatableModules = UndeployedRelationships::findRelatableModules () ;
|
||||
$appStrings = $module->getModStrings( $selected_lang ) ;
|
||||
}
|
||||
|
||||
ksort( $relatableModules ) ;
|
||||
$lhs_subpanels = $module->getProvidedSubpanels () ;
|
||||
// Fix to re-add sorting of the subpanel names so that the 'default' subpanel always appears first in the list.
|
||||
// This assumes that subpanels are usually named ForXYZ which is the case currently, and hence 'default' will be sorted first.
|
||||
//I f this assumption is incorrect, then a better solution would be to remove 'default' from the subpanel list, then sort, and finally array_unshift it back on.
|
||||
natcasesort($lhs_subpanels);
|
||||
|
||||
$cardinality = array ( MB_ONETOONE => translate ( 'LBL_ONETOONE' ) , MB_ONETOMANY => translate ( 'LBL_ONETOMANY' ) , MB_MANYTOONE=> translate ( 'LBL_MANYTOONE' ), MB_MANYTOMANY => translate ( 'LBL_MANYTOMANY' ), ) ;
|
||||
|
||||
if (!$this->fromModuleBuilder)
|
||||
unset($cardinality[MB_MANYTOONE]);
|
||||
|
||||
$relationships = $module->getRelationships () ;
|
||||
|
||||
// if a description for this relationship already exists, then load it so it can be modified
|
||||
if (! empty ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
$relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] ) ;
|
||||
$relationship->setName($_REQUEST [ 'relationship_name' ] );
|
||||
$definition = $relationship->getDefinition();
|
||||
if (!$this->fromModuleBuilder){
|
||||
$modStrings = return_module_language( $selected_lang, $relationship->rhs_module, true ) ;
|
||||
$definition['lhs_label'] = isset($modStrings[$relationship->getTitleKey()])?$modStrings[$relationship->getTitleKey()] : $relationship->lhs_module;
|
||||
$modStrings = return_module_language( $selected_lang, $relationship->lhs_module, true ) ;
|
||||
$definition['rhs_label'] = isset($modStrings[$relationship->getTitleKey(true)])?$modStrings[$relationship->getTitleKey(true)] : $relationship->rhs_module ;
|
||||
}else{
|
||||
#30624
|
||||
if(!empty($_REQUEST['rhs_module'])){
|
||||
$definition['rhs_label'] = $_REQUEST['rhs_module'];
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
$definition = array ( ) ;
|
||||
$firstModuleDefinition = each ( $relatableModules ) ;
|
||||
$definition [ 'rhs_module' ] = $firstModuleDefinition [ 'key' ] ;
|
||||
$definition [ 'lhs_module' ] = $moduleName ;
|
||||
$definition [ 'lhs_label' ] = translate($moduleName);
|
||||
$definition [ 'relationship_type' ] = MB_MANYTOMANY ;
|
||||
}
|
||||
// load the relationship from post - required as we can call view.relationship.php from Ajax when changing the rhs_module for example
|
||||
$definition = $this->overrideDefinitionFromPOST ( $definition ) ;
|
||||
|
||||
if (empty($definition ['rhs_label']))
|
||||
{
|
||||
$definition ['rhs_label'] = translate($definition [ 'rhs_module' ]);
|
||||
}
|
||||
if (empty($definition ['lhs_label']))
|
||||
{
|
||||
$definition ['lhs_label'] = translate($definition [ 'lhs_module' ]);
|
||||
}
|
||||
$relationship = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
|
||||
$rhs_subpanels = $relatableModules [ $relationship->rhs_module ] ;
|
||||
// Fix to re-add sorting of the subpanel names so that the 'default' subpanel always appears first in the list. This assumes that subpanels are usually named ForXYZ which is the case currently, and hence 'default' will be sorted first. If this assumption is incorrect, then a better solution would be to remove 'default' from the subpanel list, then sort, and finally array_unshift it back on.
|
||||
natcasesort($rhs_subpanels);
|
||||
|
||||
if (empty ( $_REQUEST [ 'relationship_name' ] ))
|
||||
{
|
||||
// tidy up the options for the view based on the modules participating in the relationship and the cardinality
|
||||
// some modules (e.g., Knowledge Base/KBDocuments) lack subpanels. That means they can't be the lhs of a 1-many or many-many, or the rhs of a many-many for example
|
||||
|
||||
// fix up the available cardinality options
|
||||
$relationship_type = $relationship->getType () ;
|
||||
if (count ( $lhs_subpanels ) == 0 || count ( $rhs_subpanels ) == 0)
|
||||
{
|
||||
unset ( $cardinality [ MB_MANYTOMANY ] ) ;
|
||||
}
|
||||
if (count ( $rhs_subpanels ) == 0)
|
||||
{
|
||||
unset ( $cardinality [ MB_ONETOMANY ] ) ;
|
||||
}
|
||||
|
||||
if (isset ($definition['rhs_module']) && $definition['rhs_module'] == 'Activities') {
|
||||
$cardinality = array( MB_ONETOMANY => translate ( 'LBL_ONETOMANY' ));
|
||||
}
|
||||
//Bug 23139, Campaigns module current cannot display custom subpanels, so we need to ban it from any
|
||||
//relationships that would require a new subpanel to be shown in Campaigns.
|
||||
if (isset ($definition['lhs_module']) && $definition['lhs_module'] == 'Campaigns') {
|
||||
unset ( $cardinality [ MB_MANYTOMANY ] ) ;
|
||||
unset ( $cardinality [ MB_ONETOMANY ] ) ;
|
||||
}
|
||||
if (isset ($definition['rhs_module']) && $definition['rhs_module'] == 'Campaigns' && isset($cardinality [ MB_MANYTOMANY ])) {
|
||||
unset ( $cardinality [ MB_MANYTOMANY ] ) ;
|
||||
unset ( $cardinality [ MB_MANYTOONE ] );
|
||||
}
|
||||
if (! isset($cardinality[$relationship->getType()]))
|
||||
{
|
||||
end ($cardinality) ;
|
||||
$definition [ 'relationship_type' ] = key ( $cardinality ) ;
|
||||
$relationship = RelationshipFactory::newRelationship ( $definition ) ;
|
||||
}
|
||||
|
||||
$this->smarty->assign ( 'is_new', true ) ;
|
||||
} else {
|
||||
$this->smarty->assign ( 'is_new', false ) ;
|
||||
}
|
||||
|
||||
//Remove Activities if one-to-many is not availible
|
||||
if (!isset($cardinality [ MB_ONETOMANY ]) && isset ($relatableModules['Activities'])) {
|
||||
unset ($relatableModules['Activities']);
|
||||
}
|
||||
|
||||
|
||||
// now enforce the relationship_only requirement - that is, only construct the underlying relationship and link fields, and not the UI, if the subpanel code will have troubles displaying the UI
|
||||
$relationships->enforceRelationshipOnly ( $relationship ) ;
|
||||
$this->smarty->assign ( 'view_module', $_REQUEST['view_module'] ) ;
|
||||
$this->smarty->assign ( 'rel', $relationship->getDefinition () ) ;
|
||||
$this->smarty->assign ( 'mod_strings', $GLOBALS [ 'mod_strings' ] ) ;
|
||||
$this->smarty->assign ( 'module_key', $relationship->lhs_module ) ;
|
||||
$this->smarty->assign ( 'cardinality', array_keys ( $cardinality ) ) ;
|
||||
$this->smarty->assign ( 'translated_cardinality', $cardinality ) ;
|
||||
$this->smarty->assign ( 'selected_cardinality', translate ( $relationship->getType () ) ) ;
|
||||
|
||||
$relatable = array ( ) ;
|
||||
foreach ( $relatableModules as $name => $dummy )
|
||||
{
|
||||
$relatable [ $name ] = translate ( $name ) ;
|
||||
}
|
||||
unset($relatable [ 'KBDocuments' ] ) ;
|
||||
natcasesort ( $relatable ) ;
|
||||
$this->smarty->assign ( 'relatable', array_keys ( $relatable ) ) ;
|
||||
$this->smarty->assign ( 'translated_relatable', $relatable ) ;
|
||||
$this->smarty->assign ( 'rhspanels', $rhs_subpanels ) ;
|
||||
$this->smarty->assign ( 'lhspanels', $lhs_subpanels ) ;
|
||||
$this->smarty->assign('selected_lang', $selected_lang);
|
||||
$this->smarty->assign('available_languages',get_languages());
|
||||
|
||||
switch ( $relationship->relationship_type)
|
||||
{
|
||||
case MB_ONETOONE :
|
||||
break ;
|
||||
|
||||
case MB_ONETOMANY :
|
||||
if (empty ( $relationship->relationship_column_name ))
|
||||
{
|
||||
$validRoleColumnFields = array ( ) ;
|
||||
foreach ( $fields as $field )
|
||||
{
|
||||
$validRoleColumnFields [] = $field ;
|
||||
}
|
||||
$this->smarty->assign ( 'relationship_role_column_enum', $validRoleColumnFields ) ;
|
||||
}
|
||||
if (! empty ( $relationship->relationship_role_column_value ))
|
||||
$this->smarty->assign ( 'relationship_role_column_value', $relationship->relationship_role_column_value ) ;
|
||||
break ;
|
||||
case MB_MANYTOMANY :
|
||||
if (! empty ( $relationship->relationship_role_column_value ))
|
||||
$this->smarty->assign ( 'relationship_role_column_value', $relationship->relationship_role_column_value ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
//see if we use the new system
|
||||
if (isset ( $_REQUEST [ 'json' ] ) && $_REQUEST [ 'json' ] == 'false')
|
||||
{
|
||||
echo $this->smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationship.tpl' ) ;
|
||||
} else
|
||||
{
|
||||
$ac->addSection ( 'east', $module->name . ' ' . $GLOBALS [ 'mod_strings' ] [ 'LBL_RELATIONSHIPS' ], $this->smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationship.tpl' ) ) ;
|
||||
echo $ac->getJavascript () ;
|
||||
}
|
||||
}
|
||||
}
|
||||
151
modules/ModuleBuilder/views/view.relationships.php
Executable file
151
modules/ModuleBuilder/views/view.relationships.php
Executable file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
require_once ('modules/ModuleBuilder/views/view.relationship.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioModule.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ;
|
||||
|
||||
class ViewRelationships extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$moduleName = ! empty ( $_REQUEST [ 'view_module' ] ) ? $_REQUEST [ 'view_module' ] : $_REQUEST [ 'edit_module' ] ;
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
// set the mod_strings as we can be called after doing a Repair and the mod_strings are set to Administration
|
||||
$GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'ModuleBuilder');
|
||||
$smarty->assign ( 'mod_strings', $GLOBALS [ 'mod_strings' ] ) ;
|
||||
$smarty->assign ( 'view_module', $moduleName ) ;
|
||||
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
$json = getJSONobj () ;
|
||||
$this->fromModuleBuilder = !empty ( $_REQUEST [ 'MB' ] ) || (!empty($_REQUEST['view_package']) && $_REQUEST['view_package'] != 'studio') ;
|
||||
$smarty->assign('fromModuleBuilder', $this->fromModuleBuilder);
|
||||
if (!$this->fromModuleBuilder)
|
||||
{
|
||||
$smarty->assign ( 'view_package', '' ) ;
|
||||
|
||||
$relationships = new DeployedRelationships ( $moduleName ) ;
|
||||
$ajaxRelationships = $this->getAjaxRelationships( $relationships ) ;
|
||||
$smarty->assign ( 'relationships', $json->encode ( $ajaxRelationships ) ) ;
|
||||
$smarty->assign ( 'empty', (sizeof ( $ajaxRelationships ) == 0) ) ;
|
||||
$smarty->assign ( 'studio', true ) ;
|
||||
|
||||
//crumb
|
||||
global $app_list_strings ;
|
||||
$moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
|
||||
$translatedModule = $moduleNames [ strtolower ( $moduleName ) ] ;
|
||||
$ajax->addCrumb ( translate('LBL_STUDIO'), 'ModuleBuilder.main("studio")' ) ;
|
||||
$ajax->addCrumb ( $translatedModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $moduleName . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_RELATIONSHIPS'), '' ) ;
|
||||
$ajax->addSection ( 'center', $moduleName . ' ' . translate('LBL_RELATIONSHIPS'), $smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationships.tpl' ) ) ;
|
||||
|
||||
} else
|
||||
{
|
||||
$smarty->assign ( 'view_package', $_REQUEST [ 'view_package' ] ) ;
|
||||
|
||||
$mb = new ModuleBuilder ( ) ;
|
||||
$module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
|
||||
$package = $mb->packages [ $_REQUEST [ 'view_package' ] ] ;
|
||||
$package->loadModuleTitles();
|
||||
$relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
|
||||
$ajaxRelationships = $this->getAjaxRelationships( $relationships ) ;
|
||||
$smarty->assign ( 'relationships', $json->encode ( $ajaxRelationships ) ) ;
|
||||
$smarty->assign ( 'empty', (sizeof ( $ajaxRelationships ) == 0) ) ;
|
||||
|
||||
$module->help [ 'default' ] = (empty ( $_REQUEST [ 'view_module' ] )) ? 'create' : 'modify' ;
|
||||
$module->help [ 'group' ] = 'module' ;
|
||||
|
||||
$ajax->addCrumb ( translate('LBL_MODULEBUILDER'), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $package->name, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $package->name . '")' ) ;
|
||||
$ajax->addCrumb ( $moduleName, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $package->name . '&view_module=' . $moduleName . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_RELATIONSHIPS'), '' ) ;
|
||||
$ajax->addSection ( 'center', $moduleName . ' ' . translate('LBL_RELATIONSHIPS'), //$smarty->fetch('modules/ModuleBuilder/tpls/MBRelationship/relationships.tpl'));
|
||||
$smarty->fetch ( 'modules/ModuleBuilder/tpls/studioRelationships.tpl' ) ) ;
|
||||
}
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the relationships for this module for display in the Ext grid layout
|
||||
*/
|
||||
function getAjaxRelationships ( $relationships )
|
||||
{
|
||||
$ajaxrels = array ( ) ;
|
||||
foreach ( $relationships->getRelationshipList () as $relationshipName )
|
||||
{
|
||||
$rel = $relationships->get ( $relationshipName )->getDefinition () ;
|
||||
$rel [ 'lhs_module' ] = translate( $rel [ 'lhs_module' ] ) ;
|
||||
$rel [ 'rhs_module' ] = translate( $rel [ 'rhs_module' ] ) ;
|
||||
|
||||
//#28668 , translate the relationship type before render it .
|
||||
switch($rel['relationship_type']){
|
||||
case 'one-to-one':
|
||||
$rel['relationship_type'] = translate ( 'LBL_ONETOONE' );
|
||||
break;
|
||||
case 'one-to-many':
|
||||
$rel['relationship_type'] = translate ( 'LBL_ONETOMANY' );
|
||||
break;
|
||||
case 'many-to-one':
|
||||
$rel['relationship_type'] = translate ( 'LBL_MANYTOONE' );
|
||||
break;
|
||||
case 'many-to-many':
|
||||
$rel['relationship_type'] = translate ( 'LBL_MANYTOMANY' );
|
||||
break;
|
||||
default: $rel['relationship_type'] = '';
|
||||
}
|
||||
$rel [ 'name' ] = $relationshipName ;
|
||||
if ($rel [ 'is_custom' ] && isset($rel [ 'from_studio' ]) && $rel [ 'from_studio' ]) {
|
||||
$rel [ 'name' ] = $relationshipName . "*";
|
||||
}
|
||||
$ajaxrels [] = $rel ;
|
||||
}
|
||||
return $ajaxrels ;
|
||||
}
|
||||
}
|
||||
248
modules/ModuleBuilder/views/view.resetmodule.php
Executable file
248
modules/ModuleBuilder/views/view.resetmodule.php
Executable file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioModule.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ;
|
||||
require_once ('modules/DynamicFields/DynamicField.php') ;
|
||||
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php';
|
||||
|
||||
class ViewResetmodule extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$moduleName = $this->module = $_REQUEST['view_module'];
|
||||
if (isset($_REQUEST['handle']) && $_REQUEST['handle'] == "execute") {
|
||||
return $this->handleSave();
|
||||
}
|
||||
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
$ajax->addCrumb ( translate('LBL_STUDIO'), 'ModuleBuilder.main("studio")' ) ;
|
||||
$ajax->addCrumb ( translate($moduleName), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $moduleName . '")' ) ;
|
||||
$ajax->addCrumb ( translate('LBL_RESET') . " " . translate($moduleName) , '') ;
|
||||
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
$smarty->assign("module", $moduleName);
|
||||
$smarty->assign("actions", array(
|
||||
array("name" => "relationships", "label" => translate("LBL_CLEAR_RELATIONSHIPS")),
|
||||
array("name" => "fields", "label" => translate("LBL_REMOVE_FIELDS")),
|
||||
array("name" => "layouts", "label" => translate("LBL_RESET_LAYOUTS")),
|
||||
array("name" => "labels", "label" => translate("LBL_RESET_LABELS")),
|
||||
array("name" => "extensions", "label" => translate("LBL_CLEAR_EXTENSIONS")),
|
||||
));
|
||||
|
||||
$ajax->addSection (
|
||||
'center',
|
||||
"Reset ". translate($moduleName) ,
|
||||
$smarty->fetch('modules/ModuleBuilder/tpls/resetModule.tpl') //"This works now"
|
||||
) ;
|
||||
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
|
||||
function handleSave()
|
||||
{
|
||||
$out = "<script>ajaxStatus.flashStatus(SUGAR.language.get('app_strings', 'LBL_REQUEST_PROCESSED'), 2000);</script>";
|
||||
|
||||
if (!empty($_REQUEST['relationships']))
|
||||
$out .= $this->removeCustomRelationships();
|
||||
|
||||
if (!empty($_REQUEST['fields']))
|
||||
$out .= $this->removeCustomFields();
|
||||
|
||||
if (!empty($_REQUEST['layouts']))
|
||||
$out .= $this->removeCustomLayouts();
|
||||
|
||||
if (!empty($_REQUEST['labels']))
|
||||
$out .= $this->removeCustomLabels();
|
||||
|
||||
if (!empty($_REQUEST['extensions']))
|
||||
$out .= $this->removeCustomExtensions();
|
||||
|
||||
|
||||
$out .= "Complete!";
|
||||
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
|
||||
$ajax->addCrumb ( translate('LBL_STUDIO'), 'ModuleBuilder.main("studio")' ) ;
|
||||
$ajax->addCrumb ( translate($this->module), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->module . '")' ) ;
|
||||
$ajax->addCrumb ( "Reset ". translate($this->module) , '') ;
|
||||
|
||||
|
||||
$ajax->addSection (
|
||||
'center',
|
||||
"Reset ". translate($this->module) ,
|
||||
$out
|
||||
) ;
|
||||
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all custom fields created in studio
|
||||
*
|
||||
* @return html output record of the field deleted
|
||||
*/
|
||||
function removeCustomFields()
|
||||
{
|
||||
$moduleName = $this->module;
|
||||
$class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
|
||||
require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
|
||||
$seed = new $class_name ( ) ;
|
||||
$df = new DynamicField ( $moduleName ) ;
|
||||
$df->setup ( $seed ) ;
|
||||
|
||||
|
||||
$module = StudioModuleFactory::getStudioModule( $moduleName ) ;
|
||||
$customFields = array();
|
||||
foreach($seed->field_defs as $def) {
|
||||
if(isset($def['source']) && $def['source'] == 'custom_fields') {
|
||||
$field = $df->getFieldWidget($moduleName, $def['name']);
|
||||
$field->delete ( $df ) ;
|
||||
|
||||
$module->removeFieldFromLayouts( $def['name'] );
|
||||
$customFields[] = $def['name'];
|
||||
}
|
||||
}
|
||||
$out = "";
|
||||
foreach ($customFields as $field) {
|
||||
$out .= "Removed field $field<br/>";
|
||||
}
|
||||
return ($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the metadata files for all known studio layouts.
|
||||
*
|
||||
* @return html output record of the files deleted
|
||||
*/
|
||||
function removeCustomLayouts()
|
||||
{
|
||||
$module = StudioModuleFactory::getStudioModule( $this->module ) ;
|
||||
$sources = $module->getViewMetadataSources();
|
||||
|
||||
$out = "";
|
||||
foreach($sources as $view)
|
||||
{
|
||||
$file = DeployedMetaDataImplementation::getFileName($view['type'], $this->module);
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
$out .= "Removed layout {$view['type']}.php<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
// now clear the cache
|
||||
include_once ('include/TemplateHandler/TemplateHandler.php') ;
|
||||
TemplateHandler::clearCache ( $this->module ) ;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all custom relationships containing this module
|
||||
*
|
||||
* @return html output record of the files deleted
|
||||
*/
|
||||
function removeCustomRelationships()
|
||||
{
|
||||
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
|
||||
$out = "";
|
||||
$madeChanges = false;
|
||||
$relationships = new DeployedRelationships ( $this->module ) ;
|
||||
|
||||
foreach ( $relationships->getRelationshipList () as $relationshipName )
|
||||
{
|
||||
$rel = $relationships->get ( $relationshipName )->getDefinition () ;
|
||||
if ($rel [ 'is_custom' ] || (isset($rel [ 'from_studio' ]) && $rel [ 'from_studio' ])) {
|
||||
$relationships->delete ($relationshipName);
|
||||
$out .= "Removed relationship $relationshipName<br/>";
|
||||
}
|
||||
}
|
||||
if ($madeChanges)
|
||||
$relationships->save () ;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
function removeCustomLabels()
|
||||
{
|
||||
$out = "";
|
||||
$languageDir = "custom/modules/{$this->module}/language";
|
||||
if (is_dir($languageDir)) {
|
||||
$files = scandir($languageDir);
|
||||
foreach ($files as $langFile) {
|
||||
if (substr($langFile, 0 ,1) == '.') continue;
|
||||
$language = substr($langFile, 0, strlen($langFile) - 9);
|
||||
unlink($languageDir . "/" . $langFile);
|
||||
|
||||
LanguageManager::clearLanguageCache ( $this->module, $language ) ;
|
||||
$out .= "Removed language file $langFile<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
function removeCustomExtensions()
|
||||
{
|
||||
$out = "";
|
||||
$extDir = "custom/Extension/modules/{$this->module}";
|
||||
if (is_dir($extDir)) {
|
||||
rmdir_recursive($extDir);
|
||||
require_once ('modules/Administration/QuickRepairAndRebuild.php') ;
|
||||
$rac = new RepairAndClear ( ) ;
|
||||
$rac->repairAndClearAll ( array ( 'clearAll' ), array ( $this->module ), true, false ) ;
|
||||
$rac->rebuildExtensions();
|
||||
$out .= "Cleared extensions for {$this->module}<br/>";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
137
modules/ModuleBuilder/views/view.searchview.php
Executable file
137
modules/ModuleBuilder/views/view.searchview.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?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 ('modules/ModuleBuilder/views/view.listview.php') ;
|
||||
require_once 'modules/ModuleBuilder/parsers/constants.php' ;
|
||||
|
||||
class ViewSearchView extends ViewListView
|
||||
{
|
||||
function ViewSearchView()
|
||||
{
|
||||
$this->init () ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
parent::init () ;
|
||||
if (!empty($_REQUEST['searchlayout'])) {
|
||||
$this->editLayout = $_REQUEST['searchlayout'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
|
||||
function preDisplay()
|
||||
{
|
||||
}
|
||||
|
||||
function display(
|
||||
$preview = false
|
||||
)
|
||||
{
|
||||
$packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : '' ;
|
||||
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
|
||||
$parser = ParserFactory::getParser ( $this->editLayout , $this->editModule, $packageName ) ;
|
||||
|
||||
$smarty = parent::constructSmarty ( $parser ) ;
|
||||
$smarty->assign ( 'action', 'searchViewSave' ) ;
|
||||
$smarty->assign ( 'view', $this->editLayout ) ;
|
||||
$smarty->assign ( 'helpName', 'searchViewEditor' ) ;
|
||||
$smarty->assign ( 'helpDefault', 'modify' ) ;
|
||||
|
||||
if ($preview)
|
||||
{
|
||||
echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
|
||||
} else
|
||||
{
|
||||
$ajax = $this->constructAjax () ;
|
||||
$ajax->addSection ( 'center', translate ($this->title), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
|
||||
echo $ajax->getJavascript () ;
|
||||
}
|
||||
}
|
||||
|
||||
function constructAjax()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
$ajax = new AjaxCompose ( ) ;
|
||||
switch ( $this->editLayout )
|
||||
{
|
||||
default:
|
||||
$searchLabel = 'LBL_' . strtoupper ( $this->editLayout) ;
|
||||
}
|
||||
|
||||
$layoutLabel = 'LBL_LAYOUTS' ;
|
||||
$layoutView = 'layouts' ;
|
||||
|
||||
|
||||
if ($this->fromModuleBuilder)
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $_REQUEST [ 'view_package' ] . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $_REQUEST [ 'view_package' ] . "&view_module={$this->editModule}" . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view_module=' . $this->editModule. '&view_package=' . $_REQUEST['view_package'] . '")' ) ;
|
||||
if ( $layoutLabel == 'LBL_LAYOUTS' ) $ajax->addCrumb ( translate ( 'LBL_SEARCH_FORMS', 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=search&view_module=' .$this->editModule . '&view_package=' . $_REQUEST [ 'view_package' ] . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $searchLabel, 'ModuleBuilder' ), '' ) ;
|
||||
} else
|
||||
{
|
||||
$ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.main("studio")' ) ;
|
||||
$ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
|
||||
if ( $layoutLabel == 'LBL_LAYOUTS' ) $ajax->addCrumb ( translate ( 'LBL_SEARCH_FORMS', 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=search&view_module=' .$this->editModule . '")' ) ;
|
||||
$ajax->addCrumb ( translate ( $searchLabel, 'ModuleBuilder' ), '' ) ;
|
||||
}
|
||||
$this->title = $searchLabel;
|
||||
return $ajax ;
|
||||
}
|
||||
}
|
||||
80
modules/ModuleBuilder/views/view.tree.php
Executable file
80
modules/ModuleBuilder/views/view.tree.php
Executable file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
|
||||
require_once('modules/ModuleBuilder/Module/StudioModule.php');
|
||||
require_once('modules/ModuleBuilder/Module/StudioBrowser.php') ;
|
||||
require_once('include/ytree/ExtNode.php') ;
|
||||
|
||||
class ViewHistory extends SugarView
|
||||
{
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
//STUDIO LABELS ONLY//
|
||||
//TODO Bundle Studio and ModuleBuilder label handling to increase maintainability.
|
||||
function display()
|
||||
{
|
||||
$root = new ExtNode('root', 'root', true);
|
||||
$sb = new StudioBrowser();
|
||||
$sb->loadModules();
|
||||
foreach($sb->modules as $name => $studioMod) {
|
||||
$root->add_node($this->buildStudioNode($studioMod));
|
||||
}
|
||||
$json = getJSONobj();
|
||||
echo($json->encode($root));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ExtNode built from the passed StudioModule
|
||||
* @param $module StudioModule
|
||||
*/
|
||||
function buildStudioNode($module) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
339
modules/ModuleBuilder/views/view.wizard.php
Executable file
339
modules/ModuleBuilder/views/view.wizard.php
Executable file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
|
||||
require_once ('modules/ModuleBuilder/Module/StudioModuleFactory.php') ;
|
||||
require_once ('include/MVC/View/SugarView.php') ;
|
||||
|
||||
class ModuleBuilderViewWizard extends SugarView
|
||||
{
|
||||
private $view = null ; // the wizard view to display
|
||||
private $actions ;
|
||||
private $buttons ;
|
||||
private $question ;
|
||||
private $title ;
|
||||
private $help ;
|
||||
|
||||
private $editModule ;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
if ( isset ( $_REQUEST [ 'view' ] ) )
|
||||
$this->view = $_REQUEST [ 'view' ] ;
|
||||
|
||||
$this->editModule = (! empty ( $_REQUEST [ 'view_module' ] ) ) ? $_REQUEST [ 'view_module' ] : null ;
|
||||
$this->buttons = array(); // initialize so that modules without subpanels for example don't result in this being unset and causing problems in the smarty->assign
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SugarView::_getModuleTitleParams()
|
||||
*/
|
||||
protected function _getModuleTitleParams()
|
||||
{
|
||||
global $mod_strings;
|
||||
|
||||
return array(
|
||||
translate('LBL_MODULE_NAME','Administration'),
|
||||
$mod_strings['LBL_MODULEBUILDER'],
|
||||
);
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$this->ajax = new AjaxCompose ( ) ;
|
||||
$smarty = new Sugar_Smarty ( ) ;
|
||||
|
||||
if (isset ( $_REQUEST [ 'MB' ] ))
|
||||
{
|
||||
$this->processMB ( $this->ajax ) ;
|
||||
} else
|
||||
{
|
||||
|
||||
$this->processStudio ( $this->ajax ) ;
|
||||
|
||||
}
|
||||
|
||||
$smarty->assign ( 'buttons', $this->buttons ) ;
|
||||
$smarty->assign ( 'image_path', $GLOBALS [ 'image_path' ] ) ;
|
||||
$smarty->assign ( "title", $this->title ) ;
|
||||
$smarty->assign ( "question", $this->question ) ;
|
||||
$smarty->assign ( "defaultHelp", $this->help ) ;
|
||||
$smarty->assign ( "actions", $this->actions ) ;
|
||||
|
||||
$this->ajax->addSection ( 'center', $this->title, $smarty->fetch ( 'modules/ModuleBuilder/tpls/wizard.tpl' ) ) ;
|
||||
echo $this->ajax->getJavascript () ;
|
||||
}
|
||||
|
||||
function processStudio(
|
||||
$ajax
|
||||
)
|
||||
{
|
||||
|
||||
$this->ajax->addCrumb ( translate( 'LBL_STUDIO' ), 'ModuleBuilder.main("studio")' ) ;
|
||||
|
||||
if (! isset ( $this->editModule ))
|
||||
{
|
||||
//Studio Select Module Page
|
||||
$this->generateStudioModuleButtons () ;
|
||||
$this->question = translate('LBL_QUESTION_EDIT') ;
|
||||
$this->title = translate( 'LBL_STUDIO' );
|
||||
global $current_user;
|
||||
if (is_admin($current_user))
|
||||
$this->actions = "<input class=\"button\" type=\"button\" id=\"exportBtn\" name=\"exportBtn\" onclick=\"ModuleBuilder.getContent('module=ModuleBuilder&action=exportcustomizations');\" value=\"" . translate ( 'LBL_BTN_EXPORT' ) . '">' ;
|
||||
|
||||
$this->help = 'studioHelp' ;
|
||||
} else
|
||||
{
|
||||
$module = StudioModuleFactory::getStudioModule( $this->editModule ) ;
|
||||
$this->ajax->addCrumb ( $module->name, !empty($this->view) ? 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' : '' ) ;
|
||||
switch ( $this->view )
|
||||
{
|
||||
case 'layouts':
|
||||
//Studio Select Layout page
|
||||
$this->buttons = $module->getLayouts() ;
|
||||
$this->title = $module->name . " " . translate('LBL_LAYOUTS') ;
|
||||
$this->question = translate( 'LBL_QUESTION_LAYOUT' ) ;
|
||||
$this->help = 'layoutsHelp' ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), '' ) ;
|
||||
break;
|
||||
|
||||
|
||||
case 'subpanels':
|
||||
//Studio Select Subpanel page.
|
||||
$this->buttons = $module->getSubpanels() ;
|
||||
$this->title = $module->name . " " . translate( 'LBL_SUBPANELS' ) ;
|
||||
$this->question = translate( 'LBL_QUESTION_SUBPANEL' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_SUBPANELS' ), '' ) ;
|
||||
$this->help = 'subpanelHelp' ;
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
//Studio Select Search Layout page.
|
||||
$this->buttons = $module->getSearch() ;
|
||||
$this->title = $module->name . " " . translate('LBL_SEARCH');
|
||||
$this->question = translate( 'LBL_QUESTION_SEARCH' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_SEARCH' ), '' ) ;
|
||||
$this->help = 'searchHelp' ;
|
||||
break;
|
||||
|
||||
case 'dashlet':
|
||||
$this->generateStudioDashletButtons();
|
||||
$this->title = $this->editModule ." " .translate('LBL_DASHLET');
|
||||
$this->question = translate( 'LBL_QUESTION_DASHLET' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_DASHLET' ), '' ) ;
|
||||
$this->help = 'dashletHelp' ;
|
||||
break;
|
||||
|
||||
case 'popup':
|
||||
$this->generateStudioPopupButtons();
|
||||
$this->title = $this->editModule ." " .translate('LBL_POPUP');
|
||||
$this->question = translate( 'LBL_QUESTION_POPUP' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_POPUP' ), '' ) ;
|
||||
$this->help = 'popupHelp' ;
|
||||
break;
|
||||
default:
|
||||
//Studio Edit Module Page
|
||||
$this->buttons = $module->getModule () ;
|
||||
$this->question = translate( 'LBL_QUESTION_MODULE' ) ;
|
||||
$this->title = translate( 'LBL_EDIT' ) . " " . $module->name ;
|
||||
$this->help = 'moduleHelp' ;
|
||||
global $current_user;
|
||||
if (is_admin($current_user))
|
||||
$this->actions = "<input class=\"button\" type=\"button\" id=\"exportBtn\" name=\"exportBtn\" "
|
||||
. "onclick=\"ModuleBuilder.getContent('module=ModuleBuilder&action=resetmodule&view_module=$this->editModule');\" value=\""
|
||||
. "Reset Module". '">' ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processMB (
|
||||
$ajax
|
||||
)
|
||||
{
|
||||
if (! isset ( $_REQUEST [ 'view_package' ] ))
|
||||
{
|
||||
sugar_die ( "no ModuleBuilder package set" ) ;
|
||||
}
|
||||
|
||||
$this->editModule = $_REQUEST [ 'view_module' ] ;
|
||||
$this->package = $_REQUEST [ 'view_package' ] ;
|
||||
|
||||
$ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
|
||||
$ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&view_package=' . $this->package . '")' ) ;
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '&view_package=' . $this->package . '")') ;
|
||||
|
||||
switch ( $this->view )
|
||||
{
|
||||
case 'search':
|
||||
//MB Select Search Layout page.
|
||||
$this->generateMBSearchButtons () ;
|
||||
$this->title = $this->editModule . " " . translate( 'LBL_SEARCH' ) ;
|
||||
$this->question = translate( 'LBL_QUESTION_SEARCH' ) ;
|
||||
$ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
|
||||
$ajax->addCrumb ( translate( 'LBL_SEARCH_FORMS' ), '' ) ;
|
||||
$this->help = "searchHelp" ;
|
||||
break;
|
||||
|
||||
case 'subpanel':
|
||||
//ModuleBuilder Select Subpanel
|
||||
$ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
|
||||
$ajax->addCrumb ( translate( 'LBL_SUBPANELS' ), '' ) ;
|
||||
$this->question = translate( 'LBL_QUESTION_SUBPANEL' ) ;
|
||||
$this->help = 'subpanelHelp' ;
|
||||
break;
|
||||
|
||||
case 'dashlet':
|
||||
$this->generateMBDashletButtons ();
|
||||
$this->title = $this->editModule ." " .translate('LBL_DASHLET');
|
||||
$this->question = translate( 'LBL_QUESTION_DASHLET' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&MB=1&view_package='.$this->package.'&view_module=' . $this->editModule . '")' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_DASHLET' ), '' ) ;
|
||||
$this->help = 'dashletHelp' ;
|
||||
break;
|
||||
|
||||
|
||||
case 'popup':
|
||||
$this->generateMBPopupButtons();
|
||||
$this->title = $this->editModule ." " .translate('LBL_POPUP');
|
||||
$this->question = translate( 'LBL_QUESTION_POPUP' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=layouts&MB=1&view_package='.$this->package.'&view_module=' . $this->editModule . '")' ) ;
|
||||
$this->ajax->addCrumb ( translate( 'LBL_POPUP' ), '' ) ;
|
||||
$this->help = 'popupHelp' ;
|
||||
break;
|
||||
default:
|
||||
$ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), '' ) ;
|
||||
$this->generateMBViewButtons () ;
|
||||
$this->title = $this->editModule . " " . translate( 'LBL_LAYOUTS' ) ;
|
||||
$this->question = translate( 'LBL_QUESTION_LAYOUT' ) ;
|
||||
$this->help = "layoutsHelp" ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generateStudioModuleButtons()
|
||||
{
|
||||
require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ;
|
||||
$sb = new StudioBrowser ( ) ;
|
||||
$sb->loadModules () ;
|
||||
$nodes = $sb->getNodes () ;
|
||||
$this->buttons = array ( ) ;
|
||||
//$GLOBALS['log']->debug(print_r($nodes,true));
|
||||
foreach ( $nodes as $module )
|
||||
{
|
||||
$this->buttons [ $module [ 'name' ] ] = array ( 'action' => $module [ 'action' ] , 'imageTitle' => ucfirst ( $module [ 'module' ] . "_32" ) , 'size' => '32' ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function generateMBViewButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_EDITVIEW' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_EDITVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'EditView',
|
||||
'help'=>'viewBtnEditView'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DETAILVIEW' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_DETAILVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'DetailView',
|
||||
'help'=>'viewBtnListView'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_LISTVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'ListView',
|
||||
'help'=>'viewBtnListView'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_QUICKCREATE' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_QUICKCREATE."&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'QuickCreate',
|
||||
'help'=>'viewBtnQuickCreate'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_SEARCH' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=wizard&view=search&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'SearchForm' ,
|
||||
'help'=> 'searchBtn'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DASHLET' ] ] =
|
||||
array (
|
||||
'action' => "module=ModuleBuilder&MB=true&action=wizard&view=dashlet&view_module={$this->editModule}&view_package={$this->package}" ,
|
||||
'imageTitle' => 'Dashlet',
|
||||
'help'=>'viewBtnDashlet'
|
||||
) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] ['LBL_POPUP'] ] =
|
||||
array (
|
||||
'imageTitle' => 'Popup',
|
||||
'action' => "module=ModuleBuilder&MB=true&action=wizard&view=popup&view_module={$this->editModule}&view_package={$this->package}",
|
||||
'help'=>'PopupListViewBtn'
|
||||
);
|
||||
}
|
||||
|
||||
function generateMBDashletButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&MB=true&action=editLayout&view=dashlet&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETLISTVIEW'], 'imageName'=>'ListView', 'help'=>'DashletListViewBtn');
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETSEARCHVIEW' ] ] = array('action'=> "module=ModuleBuilder&MB=true&action=editLayout&view=dashletsearch&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETSEARCHVIEW'], 'imageName'=>'BasicSearch','help'=> 'DashletSearchViewBtn');
|
||||
}
|
||||
|
||||
function generateMBPopupButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popuplist&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPLISTVIEW'], 'imageName'=>'ListView', 'help'=>'PopupListViewBtn');
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPSEARCH' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popupsearch&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPSEARCH'], 'imageName'=>'BasicSearch','help'=> 'PopupSearchViewBtn');
|
||||
}
|
||||
|
||||
function generateStudioDashletButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=dashlet&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETLISTVIEW'], 'imageName'=>'ListView', 'help'=>'DashletListViewBtn');
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETSEARCHVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=dashletsearch&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETSEARCHVIEW'], 'imageName'=>'BasicSearch','help'=> 'DashletSearchViewBtn');
|
||||
}
|
||||
|
||||
function generateStudioPopupButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popuplist&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPLISTVIEW'], 'imageName'=>'ListView', 'help'=>'PopupListViewBtn');
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPSEARCH' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popupsearch&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPSEARCH'], 'imageName'=>'BasicSearch','help'=> 'PopupSearchViewBtn');
|
||||
}
|
||||
|
||||
function generateMBSearchButtons()
|
||||
{
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_BASIC' ] ] = array ( 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view_module={$this->editModule}&view_package={$this->package}&view=SearchView&searchlayout=basic_search" , 'imageTitle' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BASIC_SEARCH' ] , 'imageName' => 'BasicSearch','help' => "BasicSearchBtn" ) ;
|
||||
$this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_ADVANCED' ] ] = array ( 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view_module={$this->editModule}&view_package={$this->package}&view=SearchView&searchlayout=advanced_search" , 'imageTitle' => $GLOBALS [ 'mod_strings' ] [ 'LBL_ADVANCED_SEARCH' ] , 'imageName' => 'AdvancedSearch','help' => "AdvancedSearchBtn" ) ;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user