本文整理汇总了PHP中create_export_query_relate_link_patch函数的典型用法代码示例。如果您正苦于以下问题:PHP create_export_query_relate_link_patch函数的具体用法?PHP create_export_query_relate_link_patch怎么用?PHP create_export_query_relate_link_patch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_export_query_relate_link_patch函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleMassUpdate
/**
* Executes the massupdate form
* @param displayname Name to display in the popup window
* @param varname name of the variable
*/
function handleMassUpdate()
{
require_once 'include/formbase.php';
global $current_user, $db, $disable_date_format, $timedate;
foreach ($_POST as $post => $value) {
if (is_array($value)) {
if (empty($value)) {
unset($_POST[$post]);
}
} elseif (strlen($value) == 0) {
if (isset($this->sugarbean->field_defs[$post]) && $this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post])) {
$_POST[$post] = '';
} else {
unset($_POST[$post]);
}
}
if (is_string($value) && isset($this->sugarbean->field_defs[$post])) {
if ($this->sugarbean->field_defs[$post]['type'] == 'bool' || !empty($this->sugarbean->field_defs[$post]['custom_type']) && $this->sugarbean->field_defs[$post]['custom_type'] == 'bool') {
if (strcmp($value, '2') == 0) {
$_POST[$post] = 0;
}
if (!empty($this->sugarbean->field_defs[$post]['dbType']) && strcmp($this->sugarbean->field_defs[$post]['dbType'], 'varchar') == 0) {
if (strcmp($value, '1') == 0) {
$_POST[$post] = 'on';
}
if (strcmp($value, '2') == 0) {
$_POST[$post] = 'off';
}
}
}
if ($this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) && strlen($value) == 0) {
$_POST[$post] = '';
}
if ($this->sugarbean->field_defs[$post]['type'] == 'bool') {
$this->checkClearField($post, $value);
}
if ($this->sugarbean->field_defs[$post]['type'] == 'date' && !empty($_POST[$post])) {
$_POST[$post] = $timedate->to_db_date($_POST[$post]);
}
if ($this->sugarbean->field_defs[$post]['type'] == 'datetime' && !empty($_POST[$post])) {
$_POST[$post] = $timedate->to_db($this->date_to_dateTime($post, $value));
}
if ($this->sugarbean->field_defs[$post]['type'] == 'datetimecombo' && !empty($_POST[$post])) {
$_POST[$post] = $timedate->to_db($_POST[$post]);
}
}
}
//We need to disable_date_format so that date values for the beans remain in database format
//notice we make this call after the above section since the calls to TimeDate class there could wind up
//making it's way to the UserPreferences objects in which case we want to enable the global date formatting
//to correctly retrieve the user's date format preferences
$old_value = $disable_date_format;
$disable_date_format = true;
if (!empty($_REQUEST['uid'])) {
$_POST['mass'] = explode(',', $_REQUEST['uid']);
} elseif (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
if (empty($order_by)) {
$order_by = '';
}
$ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $this->searchFields, $this->where_clauses);
if (!isset($ret_array['join'])) {
$ret_array['join'] = '';
}
$query = $this->sugarbean->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
$result = $db->query($query, true);
$new_arr = array();
while ($val = $db->fetchByAssoc($result, -1, false)) {
array_push($new_arr, $val['id']);
}
$_POST['mass'] = $new_arr;
}
if (isset($_POST['mass']) && is_array($_POST['mass']) && $_REQUEST['massupdate'] == 'true') {
$count = 0;
foreach ($_POST['mass'] as $id) {
if (empty($id)) {
continue;
}
if (isset($_POST['Delete'])) {
$this->sugarbean->retrieve($id);
if ($this->sugarbean->ACLAccess('Delete')) {
//Martin Hu Bug #20872
if ($this->sugarbean->object_name == 'EmailMan') {
$query = "DELETE FROM emailman WHERE id = '" . $this->sugarbean->id . "'";
$db->query($query);
} else {
$this->sugarbean->mark_deleted($id);
}
}
} else {
if ($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])) {
// special for contacts module
if ($_POST['Sync'] == 'true') {
$this->sugarbean->retrieve($id);
if ($this->sugarbean->ACLAccess('Save')) {
if ($this->sugarbean->object_name == 'Contact') {
//.........这里部分代码省略.........
示例2: action_map_markers
//.........这里部分代码省略.........
$temp_marker_groups[] = $GLOBALS['app_list_strings']['moduleList'][$display_module];
}
}
$this->bean->map_markers_groups = $temp_marker_groups;
}
// Map Records
} elseif (!empty($_REQUEST['uid']) || !empty($_REQUEST['current_post'])) {
if (in_array($_REQUEST['display_module'], $this->settings['valid_geocode_modules'])) {
$display_module = $_REQUEST['display_module'];
} else {
$display_module = 'Accounts';
}
if ($_REQUEST['current_post'] == 'session') {
$current_post = $_SESSION['jjwg_Maps']['current_post'];
} else {
$current_post = $_REQUEST['current_post'];
}
$query = '';
$selected_query = '';
$records = array();
$order_by = '';
$this->display_object = get_module_info($display_module);
$mod_strings_display = return_module_language($GLOBALS['current_language'], $this->display_object->module_name);
$mod_strings_display = array_merge($mod_strings_display, $GLOBALS['mod_strings']);
if (!empty($_REQUEST['uid'])) {
// Several records selected or this page
$records = explode(',', $_REQUEST['uid']);
} elseif (!empty($current_post)) {
// Select all records (advanced search)
$search_array = generateSearchWhere($display_module, $current_post);
//var_dump($search_array);
if (!empty($search_array['where'])) {
// Related Field Bug: Get relate/link patched 'where' and 'join'
@($ret_array = create_export_query_relate_link_patch($display_module, $search_array['searchFields'], $search_array['where']));
if (!empty($ret_array['join'])) {
@($selected_query = $this->display_object->create_export_query($order_by, $ret_array['where'], $ret_array['join']));
} else {
@($selected_query = $this->display_object->create_export_query($order_by, $ret_array['where']));
}
// SugarOnDemand JOIN Bug: If $ret_array['join'] is not included in query, force it in!
if (strpos($ret_array['join'], $selected_query) === false) {
$selected_query = str_replace(' where ', $ret_array['join'] . ' where ', $selected_query);
}
// Avoiding subquery. Let's just record the record ID's for later
$selected_result = $this->bean->db->limitQuery($selected_query, 0, $this->settings['map_markers_limit']);
while ($display = $this->bean->db->fetchByAssoc($selected_result)) {
$records[] = $display['id'];
}
}
}
//var_dump($records);
// Find the Items to Display
// Assume there is no address at 0,0; it's in the Atlantic Ocean!
$where_conds = "(" . $this->display_object->table_name . "_cstm.jjwg_maps_lat_c != 0 OR " . "" . $this->display_object->table_name . "_cstm.jjwg_maps_lng_c != 0) " . " AND " . "(" . $this->display_object->table_name . "_cstm.jjwg_maps_geocode_status_c = 'OK')";
$query = $this->display_object->create_new_list_query('', $where_conds, array(), array(), 0, '', false, $this->display_object, false);
if ($display_module == 'Contacts') {
// Contacts - Account Name
$query = str_replace(' FROM contacts ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM contacts ', $query);
$query = str_replace(' FROM contacts ', ' FROM contacts LEFT JOIN accounts_contacts ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0 LEFT JOIN accounts ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 ', $query);
} elseif ($display_module == 'Opportunities') {
// Opps - Account Name
$query = str_replace(' FROM opportunities ', ' ,accounts.name AS account_name, accounts.id AS account_id FROM opportunities ', $query);
$query = str_replace(' FROM opportunities ', ' FROM opportunities LEFT JOIN accounts_opportunities ON opportunities.id=accounts_opportunities.opportunity_id and accounts_opportunities.deleted = 0 LEFT JOIN accounts ON accounts_opportunities.account_id=accounts.id AND accounts.deleted=0 ', $query);
}
//var_dump($query);
$display_result = $this->bean->db->limitQuery($query, 0, $this->settings['map_markers_limit']);
示例3: elseif
}
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, 'include/SearchForm/tpls/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, -1, 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 {
示例4: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
if (!empty($ret_array['join'])) {
$query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
} else {
$query = $focus->create_export_query($order_by, $ret_array['where']);
}
}
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result, true);
// setup the "header" line with proper delimiters
$header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
if ($members) {
$header = str_replace('"ea_deleted"' . getDelimiter() . '"ear_deleted"' . getDelimiter() . '"primary_address"' . getDelimiter() . '', '', $header);
}
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
$pre_id = '';
while ($val = $db->fetchByAssoc($result, -1, false)) {
$new_arr = array();
if ($members) {
if ($pre_id == $val['id']) {
continue;
}
if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $val['id'];
$vals = array_values($val);
foreach ($vals as $key => $value) {
//getting content values depending on their types
$fieldType = $focus->field_name_map[$fields_array[$key]]['type'];
if (isset($fieldType)) {
switch ($fieldType) {
//if our value is a currency field, then apply the users locale
//.........这里部分代码省略.........
示例5: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
/* BEGIN - SECURITY GROUPS */
if (ACLController::requireSecurityGroup($focus->module_dir, 'export')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $focus->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
if (!empty($owner_where)) {
if (empty($where)) {
$where = " (" . $owner_where . " or " . $group_where . ")";
} else {
$where .= " AND (" . $owner_where . " or " . $group_where . ")";
}
} else {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $group_where;
}
}
/* END - SECURITY GROUPS */
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
if (!empty($ret_array['join'])) {
$query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
} else {
$query = $focus->create_export_query($order_by, $ret_array['where']);
}
}
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result, true);
global $sugar_config;
$utf = utf8_encode("????");
$file = fopen('Export.csv', 'w');
//$val=iconv("UTF-8","WINDOWS-1255",html_entity_decode($utf,ENT_COMPAT,'utf-8'));
foreach ($fields_array as $head) {
$fields_array[] = array(utf8_decode($head));
}
fputcsv($file, $fields_array);
// setup the "header" line with proper delimiters
/*$header = implode("\"".getDelimiter()."\"", array_values($fields_array));
//.........这里部分代码省略.........
示例6: instance
$_REQUEST['module'] : the module associated with this Bean instance (will be used to get the class name)
$_REQUEST['prospect_lists'] : the id of the prospect list
$_REQUEST['uids'] : the ids of the records to be added to the prospect list, separated by ','
*/
require_once 'include/formbase.php';
global $beanFiles, $beanList;
$bean_name = $beanList[$_REQUEST['module']];
require_once $beanFiles[$bean_name];
$focus = new $bean_name();
$uids = array();
if ($_REQUEST['select_entire_list'] == '1') {
$order_by = '';
require_once 'include/MassUpdate.php';
$mass = new MassUpdate();
$mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
$ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $mass->searchFields, $mass->where_clauses);
$query = $focus->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']);
}
} else {
$uids = explode(',', $_POST['uids']);
}
// find the relationship to use
$relationship = '';
foreach ($focus->get_linked_fields() as $field => $def) {
if ($focus->load_relationship($field)) {
if ($focus->{$field}->getRelatedModuleName() == 'ProspectLists') {
$relationship = $field;
示例7: handleMassUpdate
/**
* Executes the massupdate form
* @param displayname Name to display in the popup window
* @param varname name of the variable
*/
function handleMassUpdate()
{
require_once 'include/formbase.php';
global $current_user, $db;
/*
C.L. - Commented this out... not sure why it's here
if(!is_array($this->sugarbean) && $this->sugarbean->bean_implements('ACL') && !ACLController::checkAccess($this->sugarbean->module_dir, 'edit', true))
{
}
*/
foreach ($_POST as $post => $value) {
if (is_array($value)) {
if (empty($value)) {
unset($_POST[$post]);
}
} elseif (strlen($value) == 0) {
unset($_POST[$post]);
}
if (is_string($value) && isset($this->sugarbean->field_defs[$post]) && ($this->sugarbean->field_defs[$post]['type'] == 'bool' || !empty($this->sugarbean->field_defs[$post]['custom_type']) && $this->sugarbean->field_defs[$post]['custom_type'] == 'bool')) {
if (strcmp($value, '2') == 0) {
$_POST[$post] = 0;
}
if (!empty($this->sugarbean->field_defs[$post]['dbType']) && strcmp($this->sugarbean->field_defs[$post]['dbType'], 'varchar') == 0) {
if (strcmp($value, '1') == 0) {
$_POST[$post] = 'on';
}
if (strcmp($value, '2') == 0) {
$_POST[$post] = 'off';
}
}
}
}
if (!empty($_REQUEST['uid'])) {
$_POST['mass'] = explode(',', $_REQUEST['uid']);
} elseif (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
if (empty($order_by)) {
$order_by = '';
}
$ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $this->searchFields, $this->where_clauses);
$query = $this->sugarbean->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
$result = $db->query($query, true);
$new_arr = array();
while ($val = $db->fetchByAssoc($result, -1, false)) {
array_push($new_arr, $val['id']);
}
$_POST['mass'] = $new_arr;
}
if (isset($_POST['mass']) && is_array($_POST['mass']) && $_REQUEST['massupdate'] == 'true') {
$count = 0;
foreach ($_POST['mass'] as $id) {
if (empty($id)) {
continue;
}
if (isset($_POST['Delete'])) {
$this->sugarbean->retrieve($id);
if ($this->sugarbean->ACLAccess('Delete')) {
//Martin Hu Bug #20872
if ($this->sugarbean->object_name == 'EmailMan') {
$query = "DELETE FROM emailman WHERE id = '" . $this->sugarbean->id . "'";
$db->query($query);
} else {
$this->sugarbean->mark_deleted($id);
}
}
} else {
if ($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])) {
// special for contacts module
if ($_POST['Sync'] == 'true') {
$this->sugarbean->retrieve($id);
if ($this->sugarbean->ACLAccess('Save')) {
if ($this->sugarbean->object_name == 'Contact') {
$this->sugarbean->contacts_users_id = $current_user->id;
$this->sugarbean->save(false);
}
}
} elseif ($_POST['Sync'] == 'false') {
$this->sugarbean->retrieve($id);
if ($this->sugarbean->ACLAccess('Save')) {
if ($this->sugarbean->object_name == 'Contact') {
if (!isset($this->sugarbean->users)) {
$this->sugarbean->load_relationship('user_sync');
}
$this->sugarbean->contacts_users_id = null;
$this->sugarbean->user_sync->delete($this->sugarbean->id, $current_user->id);
}
}
}
}
//end if for special Contact handling
if ($count++ != 0) {
//Create a new instance to clear values and handle additional updates to bean's 2,3,4...
$className = get_class($this->sugarbean);
$this->sugarbean = new $className();
}
//.........这里部分代码省略.........
示例8: testBug59168
/**
* @dataProvider searchFields
*/
public function testBug59168($module, $searchFields, $where)
{
$exportQuery = create_export_query_relate_link_patch($module, $searchFields, $where);
$this->assertInternalType('string', $exportQuery['join']);
}
示例9: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false, $sample = false)
{
global $locale;
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
global $mod_strings;
global $current_language;
$sampleRecordNum = 5;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
//Array of fields that should not be exported, and are only used for logic
$remove_from_members = array("ea_deleted", "ear_deleted", "primary_address");
$focus = 0;
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
/* BEGIN - SECURITY GROUPS */
if (ACLController::requireSecurityGroup($focus->module_dir, 'export')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $focus->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
if (!empty($owner_where)) {
if (empty($where)) {
$where = " (" . $owner_where . " or " . $group_where . ")";
} else {
$where .= " AND (" . $owner_where . " or " . $group_where . ")";
}
} else {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $group_where;
}
}
/* END - SECURITY GROUPS */
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
if (!empty($ret_array['join'])) {
$query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
} else {
$query = $focus->create_export_query($order_by, $ret_array['where']);
}
}
$result = '';
$populate = false;
if ($sample) {
$result = $db->limitQuery($query, 0, $sampleRecordNum, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
if ($focus->_get_num_rows_in_query($query) < 1) {
$populate = true;
}
//.........这里部分代码省略.........