debug(print_r($_REQUEST,true)); if(!empty($_REQUEST['prospect_list_id']) and !empty($_REQUEST['prospect_ids'])) { add_prospects_to_prospect_list( $_REQUEST['prospect_list_id'], $_REQUEST['prospect_ids'] ); } else { $parent = BeanFactory::getBean($_REQUEST['module'], $_REQUEST['record']); add_to_prospect_list(urldecode($_REQUEST['subpanel_module_name']),$_REQUEST['parent_module'],$_REQUEST['parent_type'],$_REQUEST['subpanel_id'], $_REQUEST['child_id'],$_REQUEST['link_attribute'],$_REQUEST['link_type'], $parent); } $refreshsubpanel=false; }else if (isset($_REQUEST['return_type']) && $_REQUEST['return_type'] == 'addcampaignlog') { //if param is set to "addcampaignlog", then we need to create a campaign log entry //for each campaign id passed in. // Get a list of campaigns selected. if (isset($_REQUEST['subpanel_id']) && !empty($_REQUEST['subpanel_id'])) { $campaign_ids = $_REQUEST['subpanel_id']; global $beanFiles; global $beanList; //retrieve current bean $bean_name = $beanList[$_REQUEST['module']]; require_once($beanFiles[$bean_name]); $focus = new $bean_name(); $focus->retrieve($_REQUEST['record']); require_once('modules/Campaigns/utils.php'); //call util function to create the campaign log entry foreach($campaign_ids as $id){ create_campaign_log_entry($id, $focus, $focus->module_dir,$focus, $focus->id); } $refreshsubpanel=true; } } else { global $beanFiles,$beanList; $bean_name = $beanList[$_REQUEST['module']]; require_once($beanFiles[$bean_name]); $focus = new $bean_name(); $focus->retrieve($_REQUEST['record']); // If the user selected "All records" from the selection menu, we pull up the list // based on the query they used on that popup to relate them to the parent record if(!empty($_REQUEST['select_entire_list']) && $_REQUEST['select_entire_list'] != 'undefined' && isset($_REQUEST['current_query_by_page'])){ $order_by = ''; $current_query_by_page = $_REQUEST['current_query_by_page']; $current_query_by_page_array = unserialize(base64_decode($current_query_by_page)); $module = $current_query_by_page_array['module']; $seed = BeanFactory::getBean($module); if(empty($seed)) sugar_die($GLOBALS['app_strings']['ERROR_NO_BEAN']); $where_clauses = ''; require_once('include/SearchForm/SearchForm2.php'); if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){ require('custom/modules/'.$module.'/metadata/metafiles.php'); }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){ require('modules/'.$module.'/metadata/metafiles.php'); } if (file_exists('custom/modules/'.$module.'/metadata/searchdefs.php')) { require_once('custom/modules/'.$module.'/metadata/searchdefs.php'); } elseif (!empty($metafiles[$module]['searchdefs'])) { require_once($metafiles[$module]['searchdefs']); } elseif (file_exists('modules/'.$module.'/metadata/searchdefs.php')) { require_once('modules/'.$module.'/metadata/searchdefs.php'); } if(!empty($metafiles[$module]['searchfields'])){ require_once($metafiles[$module]['searchfields']); } elseif(file_exists('modules/'.$module.'/metadata/SearchFields.php')){ require_once('modules/'.$module.'/metadata/SearchFields.php'); } if(!empty($searchdefs) && !empty($searchFields)) { $searchForm = new SearchForm($seed, $module); $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl'); $searchForm->populateFromArray($current_query_by_page_array, 'advanced'); $where_clauses_arr = $searchForm->generateSearchWhere(true, $module); if (count($where_clauses_arr) > 0 ) { $where_clauses = '('. implode(' ) AND ( ', $where_clauses_arr) . ')'; } } $ret_array = create_export_query_relate_link_patch($module, $searchFields, $where_clauses); $query = $seed->create_export_query($order_by, $ret_array['where'], $ret_array['join']); $result = $GLOBALS['db']->query($query,true); $uids = array(); while($val = $GLOBALS['db']->fetchByAssoc($result,false)) { array_push($uids, $val['id']); } $_REQUEST['subpanel_id'] = $uids; } if($bean_name == 'Team'){ $subpanel_id = $_REQUEST['subpanel_id']; if(is_array($subpanel_id)){ foreach($subpanel_id as $id){ $focus->add_user_to_team($id); } } else{ $focus->add_user_to_team($subpanel_id); } } else{ //find request paramters with with prefix of REL_ATTRIBUTE_ //convert them into an array of name value pairs add pass them as //parameters to the add metod. $add_values =array(); foreach ($_REQUEST as $key=>$value) { if (strpos($key,"REL_ATTRIBUTE_") !== false) { $add_values[substr($key,14)]=$value; } } $focus->load_relationship($_REQUEST['subpanel_field_name']); $focus->$_REQUEST['subpanel_field_name']->add($_REQUEST['subpanel_id'],$add_values); $focus->save(); } } if ($refreshsubpanel) { //refresh contents of the sub-panel. $GLOBALS['log']->debug("Location: index.php?sugar_body_only=1&module=".$_REQUEST['module']."&subpanel=".$_REQUEST['subpanel_module_name']."&action=SubPanelViewer&inline=1&record=".$_REQUEST['record']); if( empty($_REQUEST['refresh_page']) || $_REQUEST['refresh_page'] != 1){ $inline = isset($_REQUEST['inline'])?$_REQUEST['inline']: $inline; header("Location: index.php?sugar_body_only=1&module=".$_REQUEST['module']."&subpanel=".$_REQUEST['subpanel_module_name']."&action=SubPanelViewer&inline=$inline&record=".$_REQUEST['record']); } exit; }