Created
September 24, 2012 15:46
-
-
Save eggsurplus/3776625 to your computer and use it in GitHub Desktop.
SugarCRM: Insert a panel via javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BEGIN - SECURITY GROUPS */ | |
//if popup select add panel if user is a member of multiple groups to metadataFile | |
global $sugar_config; | |
if(isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true | |
&& empty($this->bean->fetched_row['id']) && $this->bean->module_dir != "Users" && $this->bean->module_dir != "SugarFeed") { | |
//there are cases such as uploading an attachment to an email template where the request module may | |
//not be the same as the current bean module. If that happens we can just skip it | |
if(empty($_REQUEST['module']) || $_REQUEST['module'] != $this->bean->module_dir) return; | |
require_once('modules/SecurityGroups/SecurityGroup.php'); | |
$groupFocus = new SecurityGroup(); | |
$security_modules = $groupFocus->getSecurityModules(); | |
if(in_array($this->bean->module_dir,array_keys($security_modules))) { | |
global $current_user; | |
$group_count = $groupFocus->getMembershipCount($current_user->id); | |
if($group_count > 1) { | |
$groups = $groupFocus->getUserSecurityGroups($current_user->id); | |
$group_options = ''; | |
foreach($groups as $group) { | |
$group_options .= '<option value="'.$group['id'].'" label="'.$group['name'].'" selected="selected">'.$group['name'].'</option>'; | |
} | |
//multilingual support | |
global $current_language; | |
$ss_mod_strings = return_module_language($current_language, 'SecurityGroups'); | |
$lbl_securitygroups_select = $ss_mod_strings['LBL_GROUP_SELECT']; | |
$lbl_securitygroups = $ss_mod_strings['LBL_LIST_FORM_TITLE']; | |
$group_panel = <<<EOQ | |
<div class="edit view edit508 " id="detailpanel_securitygroups"> | |
<h4> | |
$lbl_securitygroups_select | |
</h4> | |
<table width="100%" cellspacing="1" cellpadding="0" border="0" class="edit view panelContainer" id="LBL_PANEL_SECURITYGROUPS"> | |
<tbody><tr> | |
<td width="12.5%" valign="top" scope="col" id="account_type_label"> | |
$lbl_securitygroups: | |
</td> | |
<td width="37.5%" valign="top"> | |
<select title="" id="securitygroup_list" name="securitygroup_list[]" multiple="multiple" size="${group_count}"> | |
$group_options | |
</select> | |
</td> | |
</tr> | |
</tbody></table> | |
</div> | |
EOQ; | |
$group_panel = preg_replace("/[\r\n]+/", "", $group_panel); | |
echo <<<EOQ | |
<script> | |
$('#EditView_tabs div:first').append($('${group_panel}')); | |
</script> | |
EOQ; | |
} | |
} | |
} | |
/* END - SECURITY GROUPS */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment