Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

  1. #1
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Exclamation How is $layout_def['fields'] ['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

    How is the $layout_def['fields'] ['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

    I'm trying to replicate Opps -> Contacts relationship for
    Users -> Users to grant users read/full access to other users

    Several files involved

    I have the new panel showing under User DetailView and can add/delete users.
    I've copied the EditRole form (I changed 'Role' on everythign to 'UsersAccess').
    I've copied the EditRoleButton widget but cannot get the record param to populate.
    This value is in the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] of the old EditRole widget
    My new counterpart is $layout_def['fields']['USERSACCES_TYPE_ID']. It's there, but it's empty.

    So, question is: Where exactly is the $layout_def['fields']['USERSACCES_TYPE_ID'] passed to the
    SugarWidgetSubPanelEditRoleButton.php set/popluated ????

    Need ASAP!


    Thanks,
    Rey
    Last edited by andydreisch; 2006-10-24 at 11:46 PM. Reason: Allow breakup of title in Forge

  2. #2
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

    Anyone. I need this today.

  3. #3
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    Hi

    did you create an enrtry for user_acces_type_id in the file modules/Users/vardefs.php similar to the entry opportunity_role_id in the file modules/Contacts/vardefs.php?

    I don't know if this helps but the only (lowercase) reference to OPPORTUNITY_ROLE_ID is in the file vardefs.php...

    In the Contacts/vardefs.php file is another entry which might be interesting ... opportunity_role_fields.

    Hope it helps.
    Cheers Pascal
    Simplicity GmbH

  4. #4
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    Quote Originally Posted by simple
    Hi

    did you create an enrtry for user_acces_type_id in the file modules/Users/vardefs.php similar to the entry opportunity_role_id in the file modules/Contacts/vardefs.php?

    I don't know if this helps but the only (lowercase) reference to OPPORTUNITY_ROLE_ID is in the file vardefs.php...

    In the Contacts/vardefs.php file is another entry which might be interesting ... opportunity_role_fields.

    Hope it helps.

    Thanks for the assistance. This is what I've added to the Users\vardefs.php (counterparts to Contacts\vardefs.ph Opp entries)

    Code:
    	  	
    	'users' =>
    		array (
    			'name' => 'accessusers',
    			'type' => 'link',
    			'relationship' => 'users_access',
    			'source' => 'non-db',
    			'module' => 'Users',
    			'bean_name' => 'User',
    			'vname' => 'LBL_OPPORTUNITIES',
    		),
    	'usersaccess_type_fields' =>
    		array (
    			'name' => 'usersaccess_type_fields',
    			'rname' => 'id',
    			'relationship_fields'=>array('id' => 'usersaccess_type_id', 'access_type' => 'usersaccess_type'),
    			'vname' => 'LBL_ACCOUNT_NAME',
    			'type' => 'relate',
    			'link' => 'users',
    			'link_type' => 'relationship_info',
    			'join_link_name' => 'users_access',
    			'source' => 'non-db',
    			'Importable' => false
    		),
    	'usersaccess_type_id' => 
    		array(
    			'name' => 'usersaccess_type_id',
    			'type' => 'varchar',
    			'source' => 'non-db',
    			'vname' => 'LBL_OPPORTUNITY_ROLE_ID',
    		),
    	'usersaccess_type' =>
    		array(
    			'name' => 'usersaccess_type',
    			'type' => 'varchar',
    			'source' => 'non-db',
    			'vname' => 'LBL_OPPORTUNITY_ROLE',
    		),

    Add additions to Users\layout_defs.php:
    Code:
    		'users' => array(
    			'order' => 40,
    			'module' => 'Users',
    			'subpanel_name' => 'ForUsers',
    			'get_subpanel_data' => 'users',
    			'add_subpanel_data' => 'access_id',
    			'title_key' => 'LBL_USERS_ACCESS_SUBPANEL_TITLE',
    			'top_buttons' => array(
    				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect')
    			),
    		),
    And USers\subpanels\ForUsers.php:
    Code:
    $subpanel_layout = array(
    	'top_buttons' => array(
    		array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'Users'),
    	),
    
    	'where' => '',
    	'default_order_by' => '',
    
    	'list_fields' => array(
    
    		'edit_button'=>array(
    			'widget_class' => 'SubPanelEditAccessTypeButton',
    			'type_id'=>'usersaccess_type_id',
    		 	'module' => 'Users',
    			'width' => '15%',
    		),
    		'first_name'=>array(
    			'name'=>'first_name',
    			'usage' => 'query_only',
    		),
    		'last_name'=>array(
    			'name'=>'last_name',
    		 	'usage' => 'query_only',
    		),
    		'name'=>array(
    			'name'=>'name',		
    			'vname' => 'LBL_LIST_NAME',
    			'widget_class' => 'SubPanelDetailViewLink',
    		 	'module' => 'Users',
    			'width' => '33%',
    		),
    		'usersaccess_type_fields'=>array(
    			'usage' => 'query_only',
    		),
    		'usersaccess_type_id'=>array(
    			'usage' => 'query_only',
    		),
    		'usersaccess_type'=>array(
    			'name'=>'usersaccess_type',		
    			'vname' => 'LBL_LIST_ACCESS_TYPE_ROLE',
    			'width' => '47%',
    			'sortable'=>true,
    		),
    		'remove_button'=>array(
    			'widget_class' => 'SubPanelRemoveButton',
    		 	'module' => 'Users',
    			'width' => '5%',
    			
    		),
    		
    		
    	),
    );
    copied and renamed widget include\generic\SugarWidgets\SubPanelEditRoleButto n.php ->SubPanelEditAccessTypeButton.php

    with code:
    Code:
    require_once('include/generic/SugarWidgets/SugarWidgetField.php');
    
    class SugarWidgetSubPanelEditAccessTypeButton extends SugarWidgetField
    {
    	function displayHeaderCell(&$layout_def)
    	{
    		return ' ';
    	}
    
    	function displayList(&$layout_def)
    	{//pre_print($layout_def['fields']);
    		global $app_strings;
    		global $image_path;
    	
    		$href = 'index.php?module=' . $layout_def['module']
    			. '&action=' . 'UserUserRelationshipEdit'
    			. '&record=' . $layout_def['fields']['USERSACCESS_TYPE_ID']
    			. '&return_module=' . $_REQUEST['module']
    			. '&return_action=' . 'DetailView'
    			. '&return_id=' . $_REQUEST['record'];
    
    		$edit_icon_html = get_image($image_path . 'edit_inline',
    			'align="absmiddle" alt="' . $app_strings['LNK_EDIT'] . '" border="0"');
    	//based on listview since that lets you select records
    	if($layout_def['ListView']){
    		return '<a href="' . $href . '"'
    			. 'class="listViewTdToolsS1">' . $edit_icon_html . '&nbsp;' . $app_strings['LNK_EDIT'] .'</a>&nbsp;';
    	}else{
    		return '';
    	}
    	}
    }

    note: I haven't gotten around to setting different labels yet.
    Last edited by elRey; 2006-10-25 at 04:50 PM.

  5. #5
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    Sorry, but is this a working solution now or just what you have added/created but it is still not working?
    Cheers Pascal
    Simplicity GmbH

  6. #6
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Unhappy Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    Quote Originally Posted by simple
    Sorry, but is this a working solution now or just what you have added/created but it is still not working?
    the bolded

  7. #7
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

    Still not working , but here are some results from testing/playing with Contacts->Opps relationships:

    in the modules\Contacts\vardefs.php file the follow code deals with the relationship:

    Code:
    	'opportunities' =>
    		array (
    			'name' => 'opportunities',
    			'type' => 'link',
    			'relationship' => 'opportunities_contacts',
    			'source' => 'non-db',
    			'module' => 'Opportunities',
    			'bean_name' => 'Opportunity',
    			'vname' => 'LBL_OPPORTUNITIES',
    		),	
    	'opportunity_role_fields' =>
    		array (
    			'name' => 'opportunity_role_fields',
    			'rname' => 'id',
    			'relationship_fields'=>array('id' => 'opportunity_role_id', 'contact_role' => 'opportunity_role'),
    			'vname' => 'LBL_ACCOUNT_NAME',
    			'type' => 'relate',
    			'link' => 'opportunities',
    			'link_type' => 'relationship_info',
    			'join_link_name' => 'opportunities_contacts',
    			'source' => 'non-db',
    			'Importable' => false
    		),
    	'opportunity_role_id' => 
    		array(
    			'name' => 'opportunity_role_id',
    			'type' => 'varchar',
    			'source' => 'non-db',
    			'vname' => 'LBL_OPPORTUNITY_ROLE_ID',
    		),
    If I change 'id' => 'opportunity_role_id' to 'id' => 'opportunity_role_tid' in the 'opportunity_role_fields' array
    it loses the OPPORTUNITY_ROLE_ID value

    if I change the 'opportunity_role_id' => array key to 'opportunity_role_tid' =>
    it loses the OPPORTUNITY_ROLE_ID value

    if I change 'name' => 'opportunity_role_id', to 'name' => 'opportunity_role_tid', in the 'opportunity_role_id' array
    if KEEPS the OPPORTUNITY_ROLE_ID value

    again here is my new counterpart to the above code in the modules\Users\vardefs.php:
    Code:
    	'accessusers' =>
    		array (
    			'name' => 'accessusers',
    			'type' => 'link',
    			'relationship' => 'users_access',
    			'source' => 'non-db',
    			'module' => 'Users',
    			'bean_name' => 'User',
    			'vname' => 'LBL_OPPORTUNITIES',
    		),
    	'usersaccess_type_fields' =>
    		array (
    			'name' => 'usersaccess_type_fields',
    			'rname' => 'id',
    			'relationship_fields'=>array('id' => 'usersaccess_type_id', 'access_type' => 'usersaccess_type'),
    			'vname' => 'LBL_ACCOUNT_NAME',
    			'type' => 'relate',
    			'link' => 'accessusers',
    			'link_type' => 'relationship_info',
    			'join_link_name' => 'users_access',
    			'source' => 'non-db',
    			'Importable' => false
    		),
    	'usersaccess_type_id' => 
    		array(
    			'name' => 'usersaccess_type_id',
    			'type' => 'varchar',
    			'source' => 'non-db',
    			'vname' => 'LBL_OPPORTUNITY_ROLE_ID',
    		),

  8. #8
    elRey is offline Sugar Community Member
    Join Date
    Sep 2006
    Posts
    80

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in Opp

    logfile:

    10/25/06 16:45:39,031 [1460] DEBUG SugarCRM - SugarBean.load_relationships, Loading relationship (usersaccess).
    10/25/06 16:45:39,032 [1460] DEBUG SugarCRM - Link Constructor, relationship name: users_access
    10/25/06 16:45:39,032 [1460] DEBUG SugarCRM - Link Constructor, Table name:
    10/25/06 16:45:39,032 [1460] DEBUG SugarCRM - Link Constructor, Key name:
    10/25/06 16:45:39,033 [1460] DEBUG SugarCRM - Link Constructor, _bean_table_name: users
    10/25/06 16:45:39,033 [1460] DEBUG SugarCRM - Link Constructor, _bean_key_name: id
    10/25/06 16:45:39,033 [1460] DEBUG SugarCRM - Link Constructor, relationship record found.
    10/25/06 16:45:39,033 [1460] DEBUG SugarCRM - getQuery, Bean is LHS:
    10/25/06 16:45:39,034 [1460] DEBUG SugarCRM - getQuery, Relationship type=many-to-many
    10/25/06 16:45:39,034 [1460] DEBUG SugarCRM - getQuery, Relationship role column name=
    10/25/06 16:45:39,034 [1460] DEBUG SugarCRM - Processing many-to-many.
    10/25/06 16:45:39,036 [1460] INFO SugarCRM - tableExists: users_cstm
    10/25/06 16:45:39,036 [1460] INFO SugarCRM - Query:SHOW TABLES LIKE 'users_cstm'
    10/25/06 16:45:39,037 [1460] INFO SugarCRM - Query Execution Time:0.001141
    10/25/06 16:45:39,038 [1460] DEBUG SugarCRM - SugarBean.load_relationships, Loading relationship (usersaccess).
    10/25/06 16:45:39,039 [1460] DEBUG SugarCRM - Link Constructor, relationship name: users_access
    10/25/06 16:45:39,039 [1460] DEBUG SugarCRM - Link Constructor, Table name:
    10/25/06 16:45:39,039 [1460] DEBUG SugarCRM - Link Constructor, Key name:
    10/25/06 16:45:39,040 [1460] DEBUG SugarCRM - Link Constructor, _bean_table_name: users
    10/25/06 16:45:39,040 [1460] DEBUG SugarCRM - Link Constructor, _bean_key_name: id
    10/25/06 16:45:39,040 [1460] DEBUG SugarCRM - Link Constructor, relationship record found.
    10/25/06 16:45:39,042 [1460] DEBUG SugarCRM - process_list_query: SELECT users.id , users_cstm.*, users.first_name , users.last_name , CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,'')) as name, ' ' usersaccess_type_fields , ' ' grant_id , users.created_by , 'usersaccess' panel_name FROM users LEFT JOIN users_cstm ON users.id = users_cstm.id_c INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') where ( users_access.deleted=0 AND users.deleted=0) AND users.deleted=0
    10/25/06 16:45:39,042 [1460] INFO SugarCRM - Query SELECT count(*) FROM users INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') where ( users_access.deleted=0 AND users.deleted=0) AND users.deleted=0 )
    10/25/06 16:45:39,043 [1460] INFO SugarCRM - Query Execution Time:0.00088999999999999
    10/25/06 16:45:39,044 [1460] DEBUG SugarCRM - Limit Query: SELECT users.id , users_cstm.*, users.first_name , users.last_name , CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,'')) as name, ' ' usersaccess_type_fields , ' ' grant_id , users.created_by , 'usersaccess' panel_name FROM users LEFT JOIN users_cstm ON users.id = users_cstm.id_c INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') where ( users_access.deleted=0 AND users.deleted=0) AND users.deleted=0 Start: 0 count: 20
    10/25/06 16:45:39,044 [1460] INFO SugarCRM - Query: SELECT users.id , users_cstm.*, users.first_name , users.last_name , CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,'')) as name, ' ' usersaccess_type_fields , ' ' grant_id , users.created_by , 'usersaccess' panel_name FROM users LEFT JOIN users_cstm ON users.id = users_cstm.id_c INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') where ( users_access.deleted=0 AND users.deleted=0) AND users.deleted=0 LIMIT 0,20
    10/25/06 16:45:39,045 [1460] INFO SugarCRM - Query Execution Time:0.001187
    10/25/06 16:45:39,046 [1460] DEBUG SugarCRM - Found 1 Users
    10/25/06 16:45:39,046 [1460] INFO SugarCRM - Query: SELECT users.id ref_id , jt0.created_by usersaccess_type_fields_owner , 'Users' usersaccess_type_fields_mod, users_access.grant_id grant_id, users_access.id usersaccess_type_id, users_access.access_type usersaccess_type FROM users INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') where ( users_access.deleted=0 AND users.deleted=0) AND users.deleted=0
    10/25/06 16:45:39,047 [1460] INFO SugarCRM - Query Execution Time:0.000474
    10/25/06 16:45:39,047 [1460] ERROR SugarCRM - MySQL error 1109: Unknown table 'jt0' in field list
    10/25/06 16:45:39,048 [1460] DEBUG SugarCRM - Offsets: (start, previous, next, last)(0, -20, 20, 0)
    10/25/06 16:45:39,051 [1460] INFO SugarCRM - Offset (next, current, prev)(20, , -20)
    10/25/06 16:45:39,051 [1460] INFO SugarCRM - Start/end records (1, 2)
    10/25/06 16:45:39,076 [1460] INFO SugarCRM - Query:SELECT * FROM users where reports_to_id='dfbb0fc7-0ed7-6cfb-fe31-451bf782ec69'
    10/25/06 16:45:39,077 [1460] INFO SugarCRM - Query Execution Time:0.000972


    some incorrect selects from above:
    Code:
    SELECT  
    	users.id   , 
    	users_cstm.*, 
    	users.first_name , 
    	users.last_name , 
    	CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,'')) as name, 
    	'  ' usersaccess_type_fields , 
    	'  '  grant_id , 
    	users.created_by  , 
    	'usersaccess' panel_name  
    FROM 
    	users   
    		LEFT JOIN users_cstm ON users.id = users_cstm.id_c  
    		INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') 
    where 
    	(  users_access.deleted=0 AND users.deleted=0) 
    	AND users.deleted=0 
    Start: 0 count: 20
    
    ------------------------------------------------------------------------------------------
    
    SELECT  
    	users.id   , 
    	users_cstm.*, 
    	users.first_name , 
    	users.last_name , 
    	CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,'')) as name, 
    	'  ' usersaccess_type_fields , 
    	'  '  grant_id , users.created_by  , 
    	'usersaccess' panel_name  
    FROM 
    	users   
    		LEFT JOIN users_cstm ON users.id = users_cstm.id_c  
    		INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') 
    where 
    	(  users_access.deleted=0 AND users.deleted=0) 
    	AND users.deleted=0 
    LIMIT 0,20
    
    --------------------------------------------------------------------------------------------
    
    SELECT 
    	users.id ref_id   , 
    	jt0.created_by usersaccess_type_fields_owner , 
    	'Users' usersaccess_type_fields_mod, 
    	users_access.grant_id grant_id, 
    	users_access.id usersaccess_type_id, 
    	users_access.access_type usersaccess_type 
    FROM 
    	users  
    		INNER JOIN users_access ON (users.id=users_access.grant_id AND users_access.access_id='113d430d-6281-f8c1-abb6-44590a53d0ee') 
    where 
    	(  users_access.deleted=0 AND users.deleted=0) 
    	AND users.deleted=0

  9. #9
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    Hmm, I can't help you... Sorry.

    You need help from the Sugar Team or someone who knows exactly how the subpanels work.
    Cheers Pascal
    Simplicity GmbH

  10. #10
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: How is the $layout_def['fields']['OPPORTUNITY_ROLE_ID'] set? Contacts SubPanel in

    But why did you rename the key in the edit button def?

    Code:
    		'edit_button'=>array(
    			'widget_class' => 'SubPanelEditAccessTypeButton',
    			'type_id'=>'usersaccess_type_id',
    Why not 'role_id'? I don't think it helps...but I'd like to know why you use type_id
    Cheers Pascal
    Simplicity GmbH

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •