Create a subpanel to a flex related module in sugarcrm - sugarcrm

I followed that tutorial ( http://developer.sugarcrm.com/2011/05/16/howto-create-a-flex-relate-for-other-modules/ ) to create a flex related module between the Leads and the Accounts module and PRO_Profil module.
One account can have multiple PRO_Profil items. Same for the lead module, it can have multiple PRO_Profil items. In the table pro_profil, there is a creation of parent_id and parent_name
Then I follow that tutorial ( http://developer.sugarcrm.com/2011/05/18/howto-add-a-subpanel-using-code/ ) to create a subpanel.
But the subpanel are not shown on the account detail view and neither in the lead detail view.
This result with the creation of 2 files
custom\Extension\modules\Leads\Ext\Layoutdefs_profil.php
<?php
$layout_defs["Leads"]["subpanel_setup"]['PRO_Profil'] = array (
'order' => 130,
'module' => 'PRO_Profil',
'get_subpanel_data'=>'PRO_Profil',
'sort_order' => 'asc',
'sort_by' => 'name',
'subpanel_name' => 'default',
'title_key' => 'LBL_TEST_FLEXPARENT',
);
?>
custom\Extension\modules\Leads\Ext\Vardefs\infos.php
<?php
$dictionary['Lead']['fields']['PRO_Profil'] = array(
'name' => 'PRO_Profil',
'type' => 'link',
'relationship' => 'profils_leads',
'module' => 'PRO_Profil',
'bean_name' => 'PRO_Profil',
'source' => 'non-db',
'vname' => 'LBL_TEST_FLEXPARENT',
);
?>
I have the feeling that sugarcrm 6.3 or 6.4 changed the system
where is the problem ?
regards
I tryied also :
http://forums.sugarcrm.com/f148/howto-prospect-list-subpanel-leads-sugarcem-6-4-maybe-6-3-a-78030/

Related

How can we add new fields in a new tab in user setting in TYPO3

How can we add new fields in a new tab in user setting in TYPO3 version 8.7?
Our problem is the creation of a new tab.
I can add new fields to personal data tab in user setting, but I need to create new fields into a new tab.
For backend admin user setting I added a new tab, but for user setting I want to try this. I have an extension and since the installation of the extension it will add-on.
I tried to create new tab in fe_user.php.
Previously I tried to change ext_tables.php, but that is not working at all.
// Add some fields to FE Users table to show TCA fields definitions
// USAGE: TCA Reference > $GLOBALS['TCA'] array reference >
// ['columns'][fieldname]['config'] / TYPE: "select"
$temporaryColumns = array (
'tx_examples_options' => array (
'exclude' => 1,
'label' => 'tx_examples_options',
'config' => array (
'type' => 'select',
'showitem' => array (
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.0', '1'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.1', '2'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.2', '--div--'),
array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:fe_users.tx_examples_options.I.3', '3'),
),
'size' => 1,
'maxitems' => 1,
)
),
'tx_examples_special' => array (
'exclude' => 1,
'label' => 'tx_examples_special',
'config' => array (
'type' => 'user',
'size' => '30',
'userFunc' => 'Documentation\\Examples\\Userfuncs\\Tca->specialField',
'parameters' => array(
'color' => 'blue'
)
)
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'fe_users',
$temporaryColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
'--div--;newtab,tx_examples_options, tx_examples_special'
);
When I changed into file ext_tables.php
$GLOBALS['TYPO3_USER_SETTINGS']['columns']['copy_directory'] = array(
'label' => 'Alternative directory for saving copies',
'type' => 'text',
'table' => 'be_users',
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings('copy_directory','after:lang');
then it's showing in "personal data" tab but I want new tab in user setting for non-admin user.
In general your code looks fine.
But you are in the wrong file!
Avoid ext_tables.php if possible.
If you change anything to the TCA you should do it in Configuration/TCA/ for new tables and Configuration/TCA/Overrides for enhancing existing tables.
Use filenames according to the table you are modifying.
In your case all the code should be located in Configuration/TCA/Overrides/fe_users.php.
And be sure you clear all caches if you develop anything with TCA!

TYPO3 changing an extension with own extension

I'm trying to create a extension to modify fields in a different extension.
My extension needs to add and disable fields in fe_users over the TSConfig Page.
Ive looked over google how to do this with a own extension. But I didn't find anything usefull that I could work with.
(Edited)
The admin shouldn't be able to see these fields:
Company
Name
Middle name
Address
Zipcode
Land
Phone
Fax
www
Image
TSConfig
Bind a Domain
Redirect after login
Start
Stop
Record Type
These fields should be added
Customer (INT, not able to edit on display) Manditory
swissaxis_id (INT, Unique number) if possible only displayable and
not editing possibility
shop_rights (Textarea, No defined Value. The Rights will be saved
there serialised.)
fe_groups
These fields shouldn't be displayed to any Admin
Bind a domain
TSConfig
Redirect after login
Record Type
I'm thankfull for any Feedback possible.
Here's a link on how you add new fields to fe_users: https://docs.typo3.org/typo3cms/TCAReference/ExtendingTca/Index.html
https://docs.typo3.org/typo3cms/TCAReference/ExtendingTca/Examples/Index.html
I'll give you an example from an old, makeshift extension zusatzfelder of mine that modifies the "pages" table. It's really old, please verify if everything is current. You can also look at any other, "real" extension...
ext_emconf.php (maybe created by extension_builder)
<?php
########################################################################
# Extension Manager/Repository config file for ext "zusatzfelder".
#
# Auto generated 29-08-2011 15:33
#
# Manual updates:
# Only the data in the array - everything else is removed by next
# writing. "version" and "dependencies" must not be touched!
########################################################################
$EM_CONF[$_EXTKEY] = array(
'title' => 'Zusatzfelder',
'description' => '',
'category' => '',
'author' => '',
'author_email' => '',
'shy' => '',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
'module' => '',
'state' => '',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'author_company' => '',
'version' => '0.0.0',
'constraints' => array(
'depends' => array(
),
'conflicts' => array(
),
'suggests' => array(
),
),
'_md5_values_when_last_written' => 'a:8:{s:9:"ChangeLog";s:4:"5b94";s:10:"README.txt";s:4:"ee2d";s:12:"ext_icon.gif";s:4:"1bdc";s:14:"ext_tables.php";s:4:"474a";s:14:"ext_tables.sql";s:4:"ead9";s:16:"locallang_db.xml";s:4:"7a92";s:19:"doc/wizard_form.dat";s:4:"0cba";s:20:"doc/wizard_form.html";s:4:"29e8";}',
);
?>
ext_tables.sql
CREATE TABLE pages (
tx_zusatzfelder_contentnav_title_addition tinytext,
tx_zusatzfelder_contentnav_title tinytext,
tx_zusatzfelder_contentnav_disable int(11) DEFAULT '0' NOT NULL,
);
ext_tables.php
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$tempColumns = array (
'tx_zusatzfelder_contentnav_title' => array (
'exclude' => 0,
'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_title',
'config' => array (
'type' => 'input',
'size' => '30',
)
),
'tx_zusatzfelder_contentnav_title_addition' => array (
'exclude' => 0,
'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_title_addition',
'config' => array (
'type' => 'input',
'size' => '30',
)
),
'tx_zusatzfelder_contentnav_disable' => array (
'exclude' => 0,
'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_disable',
'config' => array (
'type' => 'check',
'default' => '0',
)
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages',$tempColumns,1);
// http://typo3-blog.net/tutorials/news/addtoalltcatypes.html
// PS: the "after:"... is for placement in the BE, stopped working last week...
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_title;;;;1-1-1','','after:subtitle');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_title_addition;;;;1-1-1','','after:subtitle');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_disable;;;;1-1-1','','after:subtitle');
?>
locallang_db.xml
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'zusatzfelder'</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="pages.tx_zusatzfelder_contentnav_title_addition">Untermenu: Vorlauf Titel (zB. "Mehr zur")</label>
<label index="pages.tx_zusatzfelder_contentnav_title">Untermenu: Titellink anderer Text (Standard: Seitentitel; Leerschlag: kein Titel)</label>
<label index="pages.tx_zusatzfelder_contentnav_disable">Untermenu ausblenden</label>
</languageKey>
</data>
</T3locallang>
That's all you need to add new fields – you don't even need the locallang if you just prefer to do 'label' => 'My untranslated Label', in ext_tables.php.

wordpress WP Query and Custom Field filtering

I've encoutered problem with filtering pages to display in WP query.
I use Codex WP query reference for custom fields with ACF (Advanced Custom Fields plugin - but it doesn't matter, couse it works same as WP custom field) parameters to filter pages.
In "Multiple Custom Field Handling" paragraph, Codex got an example with 2 conditions. We can use OR or AND relation. I works for both until you have 3rd condition (array).
They use example:
'relation' => 'OR',
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE'
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
It has only 2 arrays. When I put 3rd, nothing shows. In debug mode I can see an error:
WordPress database error: [Lost connection to MySQL server during query]
When I use AND it works, but I got to use OR. Unfortunately it makes MySQL disconnect.
I've tryed asking phpMySQL for same query WP does. It couses problem - phpMyAdmin says same:
Lost connection
Any Idea?
Maybe I should try different aproach for filtering? (maybe I should use taxonomy?)
Here is code I use:
$query_array = array('relation' => 'OR');
array_push($query_array,
array(
'key' => 'filter1',
'value' => 'value1',
'compare' => 'LIKE'
),
array(
'key' => 'filter1',
'value' => 'value2',
'compare' => 'LIKE'
),
array(
'key' => 'filter1',
'value' => 'value3',
'compare' => 'LIKE'
)
);
$args = array(
'order' => $order_array,
'meta_key' => $meta_key,
'orderby' => $orderby,
'post_type' => 'page',
'paged' => $paged,
'post__in' => $postIDs,
'posts_per_page' => 12,
'paged' => get_query_var('paged'),
'meta_query' => $query_array
);
query_posts($args);
?>
(variables for $args are set of course)
I don't know why I can't use
'compare' => '='
but probably it is why I can't use:
$query_array = array('relation' => 'OR');
array_push($query_array,
array(
'key' => 'filter1',
'value' => array('value1', 'value2', 'value3'),
'compare' => 'IN'
)
);
Just wanted to say that your comment helped me; I'd been butting my head against a very similar problem for a while. I'm using ACF too, and using it to attach items of one post type to another custom post type was easy - for instance, to Attach Person_1 and Person_3 to "Project_A".
This made it easy to list out which users were attached to specific projects. But when it came to do the same in reverse - to show which projects were attached to which users - it became a massive headache.
I finally figured it out, in part thanks to your comment - I'll post my solution here in case someone else comes along with the same problem:
$args = array(
'numberposts' => -1,
'post_type' => 'project',
'meta_query' => array(
'relation' => 'IN',
array(
'key' => 'people',
'value' => ';s:1:"' . $person->ID . '";',
'compare' => 'LIKE'
)
)
);
In short: because the ACF values in repeater fields et cetera are serialized, the compare keyword has to be "LIKE", and I added some context to the value to eliminate false returns - just searching for an ID like "1" would match a lot of the (wrong) posts, but the ";s1;" part ensures that the given value is at index 1, which in my case is the correct index.
So it would need tweaking from case to case. Inspecting what you're trying to match up with var_dumping "get_post_meta($post->ID, 'people')" is helpful for getting the value correct.

How to replace a build in relationship field by a flexrelate field

For example in Opportunities and Cases there are relationship fields directly pointing to accounts. I have a custom module that integrates into those modules. I could add a separate relate field for the custom module, but what I want is a flexrelate allowing only Accounts and the Custom module. This works fine by setting a special options list in the parent_name. but results in a parent_type and parent_id field in db.
How do I configure the flexrelate so that on selecting accounts as parent_type it save to account_id and on selecting the custom module it saves to it's id field?
The options for the flexrelate:
$app_list_strings['parent_type_display_custom']['CustomMod'] = 'CustomMod';
$app_list_strings['parent_type_display_custom']['Accounts'] = 'Accounts';
$app_list_strings['record_type_display_custom']['CustomMod'] = 'CustomMod';
$app_list_strings['record_type_display_custom']['Accounts'] = 'Accounts';
The additional vardefs for Cases:
$dictionary["Case"]["fields"]["parent_type"] = array (
'name' => 'parent_type',
'type' => 'link',
'vname' => 'LBL_PARENT_TYPE',
'type' => 'parent_type',
'dbType' => 'varchar',
'group' => 'parent_name',
'options' => 'parent_type_display_custom',
'len' => '255',
);
$dictionary["Case"]["fields"]['parent_name'] =
array(
'name' => 'parent_name',
'parent_type' => 'record_type_display',
'type_name' => 'parent_type',
'id_name' => 'parent_id',
'vname' => 'LBL_RELATED_TO',
'type' => 'parent(_custom)',
'source' => 'non-db',
'options' => 'record_type_display_custom',
);
$dictionary["Case"]["fields"]['parent_id'] =
array(
'name' => 'parent_id',
'vname' => 'LBL_PARENT_ID',
'type' => 'id',
'required' => false,
'reportable' => true,
'comment' => 'eighter the Id of an account or a custommodule'
);
Does this SugarCRM developer blog post help?
http://developers.sugarcrm.com/wordpress/2011/05/16/howto-create-a-flex-relate-for-other-modules/

How to fix propect_lists subpanel in accounts, contacts and leads?

There is a description by Robert Lausegger (iscon group) which made it possible to show prospect list in a subpanel in other modules. But since SugarCRM 6.3 this wasn't working anymore.
How to fix this?
The site referenced in the above link was in German, so, courtesy of the author of that site, Robert Laussegger of the iscon group (www.iscongroup.net) in Germany, here is the english language version of the method. I used this on SugarCRM CE v 6.5 running on a LAMP stack with CentOS 6.4 base and it worked fine. Adjust to your install as appropriate.
The example given shows how to add a Target List (called Prospect List internally with SugarCRM) to a Contact DetailView; adjust the settings for Leads, ...
If the directories shown do not exist, create them, being careful to match not only spelling but capitalization. You will be adding 3 files in 3 separate directories.
Remember to set the file permissions and owner/group to allow the server to access the files created.
When finished adding the files and setting the permissions, as a CRM administrator, run:
Admin -> Repair -> Rebuild Relationships (to flush cache)
Admin -> Repair -> Quick Repair and Rebuild
Create the following files in the directories shown:
In /var/www/html//custom/Extension/modules/Contacts/Ext/Language
-Create file en_us.prospectlist_in_contacts_language.php
and into the file put
(the part of the filename " prospectlist_in_contacts_language" can be whatever you want, as long as you use the prefix "en_us." (for US English language) and the suffix ".php")
<?php
$mod_strings['LBL_PROSPECTLISTS_CONTACTS_FROM_PROSPECTLISTS_TITLE'] = 'Target Lists';
?>
In /var/www/html//custom/Extension/modules/Contacts/Ext/Layoutdefs
Create file prospectlist_in_contacts_layoutdef.php
and into the file put
(the part of the filename " prospectlist_in_contacts_layoutdef" can be whatever you want, as long as you use the suffix ".php")
<?php
$layout_defs["Contacts"]["subpanel_setup"]["prospect_list_contacts"] = array (
'order' => 100,
'module' => 'ProspectLists',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'LBL_PROSPECTLISTS_CONTACTS_FROM_PROSPECTLISTS_TITLE',
'get_subpanel_data' => 'prospect_list_contacts',
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
?>
In /var/www/html//custom/Extension/modules/Contacts/Ext/Vardefs
Create file prospectlist_in_contacts_vardef.php
and into the file put
(the part of the filename " prospectlist_in_contacts_vardef" can be whatever you want, as long as you use the suffix ".php")
<?php
$dictionary["Contact"]["fields"]["prospect_list_contacts"] = array (
'name' => 'prospect_list_contacts',
'type' => 'link',
'relationship' => 'prospect_list_contacts',
'source' => 'non-db',
'vname' => 'LBL_PROSPECTLISTS_CONTACTS_FROM_PROSPECTLISTS_TITLE',
);
$dictionary["Contact"]["fields"]["prospect_list_name"] = array (
'name' => 'prospect_list_name',
'rname' => 'name',
'id_name' => 'prospect_list_id',
'vname' => 'LBL_PROSPECTLISTS_CONTACTS_FROM_PROSPECTLISTS_TITLE',
'type' => 'relate',
'link' => 'prospect_lists',
'table' => 'prospect_lists',
'isnull' => 'true',
'module' => 'ProspectLists',
'dbType' => 'char',
'len' => '255',
'source' => 'non-db',
);
?>
Reset owner/permissions
Run, as CRM administrator
Admin -> Repair -> Rebuild Relationships (to flush cache)
Admin -> Repair -> Quick Repair and Rebuild
The vardefs have to be changed to:
$dictionary["Lead"]["fields"]["prospect_lists"] = array(
'name' => 'prospect_lists',
and the layoutdefs
'get_subpanel_data' => 'prospect_lists',
This solves the problem.