Example #1
0
}
$xtpl->assign("THEME", SugarThemeRegistry::current()->__toString());
//$xtpl->assign("IMAGE_PATH", $image_path);
$xtpl->assign("JAVASCRIPT", get_set_focus_js());
$xtpl->assign("ID", $focus->id);
$xtpl->assign('NAME', $focus->name);
$xtpl->assign('URL', $focus->url);
$xtpl->assign('URL_TITLE', $focus->url_title);
$xtpl->assign('NAME', $focus->name);
$xtpl->assign('DESCRIPTION', $focus->description);
$buttons = array('<input id="btn_teamnotices_save" title="' . $app_strings['LBL_SAVE_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_SAVE_BUTTON_KEY'] . '" class="button primary" onclick="this.form.action.value=\'Save\'; return check_form(\'EditView\');" type="submit" name="button" value="' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '">', '<input id="btn_teamnotices_cancel" title="' . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_CANCEL_BUTTON_KEY'] . '" onclick="this.form.action.value=\'index\';" class="button" type="submit" name="button" value="' . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . '">');
require_once 'include/SugarSmarty/plugins/function.sugar_action_menu.php';
$action_button = smarty_function_sugar_action_menu(array('id' => 'teamnotices_editview_buttons', 'buttons' => $buttons, 'flat' => true), $xtpl);
$xtpl->assign('ACTION_BUTTON', $action_button);
require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
$teamSetField = new SugarFieldTeamset('Teamset');
$code = $teamSetField->getClassicView($focus->field_defs);
$xtpl->assign("TEAM_SET_FIELD", $code);
if (!isset($focus->date_start)) {
    $xtpl->assign('DATE_START', $timedate->nowDate());
} else {
    $xtpl->assign('DATE_START', $focus->date_start);
}
if (!isset($focus->date_start)) {
    $xtpl->assign('DATE_END', $timedate->asUser($timedate->getNow()->get('+1 week')));
} else {
    $xtpl->assign('DATE_END', $focus->date_end);
}
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
$xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($mod_strings['dom_status'], $focus->status));
$xtpl->parse("main.pro");
Example #2
0
    }
    $xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
    $xtpl->assign("JAVASCRIPT", get_set_focus_js());
    $xtpl->assign("ID", $focus->id);
    $xtpl->assign('NAME', $focus->name);
    $xtpl->assign('DESCRIPTION', $focus->description);
    $xtpl->assign('CUSTOM_QUERY', $focus->custom_query);
    if ($focus->query_locked == 'on' or $focus->query_locked == '1') {
        $xtpl->assign("QUERY_LOCKED", "checked");
        $xtpl->assign("QUERY_DISABLED", "disabled");
    }
    if (empty($focus->id) && !isset($_REQUEST['isDuplicate'])) {
        $xtpl->assign("TEAM_OPTIONS", get_select_options_with_id(get_team_array(), $current_user->default_team));
    } else {
        $xtpl->assign("TEAM_OPTIONS", get_select_options_with_id(get_team_array(), $focus->team_id));
    }
    // adding custom fields:
    require_once 'modules/DynamicFields/templates/Files/EditView.php';
    require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
    $teamSetField = new SugarFieldTeamset('Teamset');
    $teamSetField->initClassicView($focus->field_defs);
    $code = $teamSetField->getClassicView($focus->field_defs, 'EditView');
    $xtpl->assign("TEAM_SET_FIELD", $code);
    $xtpl->parse("main");
    $xtpl->out("main");
    $javascript = new javascript();
    $javascript->setFormName('EditView');
    $javascript->setSugarBean($focus);
    $javascript->addAllFields('');
    echo $javascript->getScript();
}
 global $current_user;
 // Set the from and to user names so that we can display them in the results
 $fromusername = $_POST['fromuser'];
 $tousername = $_POST['touser'];
 $query = "select user_name, id from users where id in ('{$_POST['fromuser']}', '{$_POST['touser']}')";
 $res = $db->query($query);
 while ($row = $db->fetchByAssoc($res)) {
     if ($row['id'] == $_POST['fromuser']) {
         $fromusername = $row['user_name'];
     }
     if ($row['id'] == $_POST['touser']) {
         $tousername = $row['user_name'];
     }
 }
 //rrs bug: 31056 - instead of setting the team_id let's set the team_set_id and set the team_id as the primary
 $teamSetField = new SugarFieldTeamset('Teamset');
 $teams = $teamSetField->getTeamsFromRequest('team_name');
 $team_ids = array_keys($teams);
 $team_id = $teamSetField->getPrimaryTeamIdFromRequest('team_name', $_REQUEST);
 $teamSet = BeanFactory::getBean('TeamSets');
 $team_set_id = $teamSet->addTeams($team_ids);
 $toteamname = TeamSetManager::getCommaDelimitedTeams($team_set_id, $team_id, true);
 echo "{$mod_strings_users['LBL_REASS_DESC_PART2']}\n";
 echo "<form action=\"index.php?module=Users&action=reassignUserRecords&execute=true\" method=post>\n";
 echo "<BR>{$mod_strings_users['LBL_REASS_NOTES_TITLE']}\n";
 echo "<ul>\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_ONE']}\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_TWO']}\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_THREE']}\n";
 echo "</ul>\n";
 require_once 'include/SugarSmarty/plugins/function.sugar_help.php';
Example #4
0
 protected function saveMappingFile()
 {
     global $current_user;
     $firstrow = unserialize(base64_decode($_REQUEST['firstrow']));
     $mappingValsArr = $this->importColumns;
     $mapping_file = new ImportMap();
     if (isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on') {
         $header_to_field = array();
         foreach ($this->importColumns as $pos => $field_name) {
             if (isset($firstrow[$pos]) && isset($field_name)) {
                 $header_to_field[$firstrow[$pos]] = $field_name;
             }
         }
         $mappingValsArr = $header_to_field;
     }
     //get array of values to save for duplicate and locale settings
     $advMapping = $this->retrieveAdvancedMapping();
     //merge with mappingVals array
     if (!empty($advMapping) && is_array($advMapping)) {
         $mappingValsArr = $advMapping + $mappingValsArr;
     }
     //set mapping
     $mapping_file->setMapping($mappingValsArr);
     // save default fields
     $defaultValues = array();
     for ($i = 0; $i < $_REQUEST['columncount']; $i++) {
         if (isset($this->importColumns[$i]) && !empty($_REQUEST[$this->importColumns[$i]])) {
             $field = $this->importColumns[$i];
             $fieldDef = $this->bean->getFieldDefinition($field);
             if (!empty($fieldDef['custom_type']) && $fieldDef['custom_type'] == 'teamset') {
                 require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                 $sugar_field = new SugarFieldTeamset('Teamset');
                 $teams = $sugar_field->getTeamsFromRequest($field);
                 if (isset($_REQUEST['primary_team_name_collection'])) {
                     $primary_index = $_REQUEST['primary_team_name_collection'];
                 }
                 //If primary_index was selected, ensure that the first Array entry is the primary team
                 if (isset($primary_index)) {
                     $count = 0;
                     $new_teams = array();
                     foreach ($teams as $id => $name) {
                         if ($primary_index == $count++) {
                             $new_teams[$id] = $name;
                             unset($teams[$id]);
                             break;
                         }
                     }
                     foreach ($teams as $id => $name) {
                         $new_teams[$id] = $name;
                     }
                     $teams = $new_teams;
                 }
                 //if
                 $json = getJSONobj();
                 $defaultValues[$field] = $json->encode($teams);
             } else {
                 $defaultValues[$field] = $_REQUEST[$this->importColumns[$i]];
             }
         }
     }
     $mapping_file->setDefaultValues($defaultValues);
     $result = $mapping_file->save($current_user->id, $_REQUEST['save_map_as'], $_REQUEST['import_module'], $_REQUEST['source'], isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on', $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
 }
Example #5
0
if (isset($_REQUEST['return_id'])) {
    $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
}
// handle Create $module then Cancel
if (empty($_REQUEST['return_id'])) {
    $xtpl->assign("RETURN_ACTION", 'index');
}
$xtpl->assign("THEME", SugarThemeRegistry::current()->__toString());
$xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
$javascript = get_set_focus_js() . get_validate_record_js();
require_once 'include/QuickSearchDefaults.php';
require_once 'modules/KBDocuments/SearchUtils.php';
$qsd = QuickSearchDefaults::getQuickSearchDefaults();
$sqs_objects = array('team_name' => $qsd->getQSTeam(), 'EditView_assigned_user_name' => $qsd->getQSUser(), 'EditView_kbdoc_approver_name' => getQSApprover());
require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
$teamSetField = new SugarFieldTeamset('Teamset');
$teamSetField->initClassicView($focus->field_defs);
$sqs_objects = array_merge($sqs_objects, $teamSetField->getClassicViewQS());
$quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '; enableQS();</script>';
/*
$quicksearch_js .= '<script type="text/javascript" language="javascript">
						sqs_objects[\'tags\'] = ' . $json->encode($sqs_objects['tags']) . ';
						sqs_objects[\'team_name\'] = ' . $json->encode($sqs_objects['team_name']) . ';
						</script>';
*/
$javascript = get_set_focus_js() . $quicksearch_js;
$tag = BeanFactory::getBean('KBTags');
$xtpl->assign("TAG_NAME", $tag->tag_name);
//tree header.
$tagstree = new Tree('tagstree');
$tagstree->set_param('module', 'KBTags');
        $cols_name = $field_def['vname'];
        $col_arr[0] = $cols_name;
        $col_arr[1] = $field_def['name'];
    }
    if (!in_array($cols_name, $fields)) {
        array_push($fields, $col_arr);
    }
    $count++;
}
$xtpl->assign("WEB_POST_URL", $web_post_url);
//$xtpl->assign("LEAD_SELECT_FIELDS",'MOD.LBL_SELECT_LEAD_FIELDS');
require_once 'include/QuickSearchDefaults.php';
$qsd = QuickSearchDefaults::getQuickSearchDefaults();
$sqs_objects = array('account_name' => $qsd->getQSParent(), 'assigned_user_name' => $qsd->getQSUser(), 'campaign_name' => $qsd->getQSCampaigns(), 'team_name' => $qsd->getQSTeam());
require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
$teamSetField = new SugarFieldTeamset('Teamset');
$teamSetField->initClassicView($lead->field_defs, 'WebToLeadCreation');
$sqs_objects = array_merge($sqs_objects, $teamSetField->getClassicViewQS());
$quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
$xtpl->assign("JAVASCRIPT", $quicksearch_js);
if (empty($lead->id) && !isset($_REQUEST['isDuplicate'])) {
    $xtpl->assign("TEAM_OPTIONS", get_select_options_with_id(get_team_array(), $current_user->default_team));
    $xtpl->assign("TEAM_NAME", $current_user->default_team_name);
    $xtpl->assign("TEAM_ID", $current_user->default_team);
} else {
    $xtpl->assign("TEAM_OPTIONS", get_select_options_with_id(get_team_array(), $lead->team_id));
    $xtpl->assign("TEAM_NAME", $lead->assigned_name);
    $xtpl->assign("TEAM_ID", $lead->team_id);
}
$code = $teamSetField->getClassicView();
$xtpl->assign("TEAM_SET_FIELD", $code);
Example #7
0
 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $sugar_config;
     // Increase the max_execution_time since this step can take awhile
     ini_set("max_execution_time", max($sugar_config['import_max_execution_time'], 3600));
     // stop the tracker
     TrackerManager::getInstance()->pause();
     // use our own error handler
     set_error_handler('handleImportErrors', E_ALL);
     global $mod_strings, $app_strings, $current_user, $import_bean_map;
     global $app_list_strings, $timedate;
     $update_only = isset($_REQUEST['import_type']) && $_REQUEST['import_type'] == 'update';
     $firstrow = unserialize(base64_decode($_REQUEST['firstrow']));
     // All the Look Up Caches are initialized here
     $enum_lookup_cache = array();
     // Let's try and load the import bean
     $focus = loadImportBean($_REQUEST['import_module']);
     if (!$focus) {
         trigger_error($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], E_USER_ERROR);
     }
     // setup the importable fields array.
     $importable_fields = $focus->get_importable_fields();
     // loop through all request variables
     $importColumns = array();
     foreach ($_REQUEST as $name => $value) {
         // only look for var names that start with "fieldNum"
         if (strncasecmp($name, "colnum_", 7) != 0) {
             continue;
         }
         // pull out the column position for this field name
         $pos = substr($name, 7);
         if (isset($importable_fields[$value])) {
             // now mark that we've seen this field
             $importColumns[$pos] = $value;
         }
     }
     // set the default locale settings
     $ifs = new ImportFieldSanitize();
     $ifs->dateformat = $_REQUEST['importlocale_dateformat'];
     $ifs->timeformat = $_REQUEST['importlocale_timeformat'];
     $ifs->timezone = $_REQUEST['importlocale_timezone'];
     $currency = new Currency();
     $currency->retrieve($_REQUEST['importlocale_currency']);
     $ifs->currency_symbol = $currency->symbol;
     $ifs->default_currency_significant_digits = $_REQUEST['importlocale_default_currency_significant_digits'];
     $ifs->num_grp_sep = $_REQUEST['importlocale_num_grp_sep'];
     $ifs->dec_sep = $_REQUEST['importlocale_dec_sep'];
     $ifs->default_locale_name_format = $_REQUEST['importlocale_default_locale_name_format'];
     // Check to be sure we are getting an import file that is in the right place
     if (realpath(dirname($_REQUEST['tmp_file']) . '/') != realpath($sugar_config['upload_dir'])) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     // Open the import file
     $importFile = new ImportFile($_REQUEST['tmp_file'], $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     if (!$importFile->fileExists()) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     $fieldDefs = $focus->getFieldDefinitions();
     unset($focus);
     while ($row = $importFile->getNextRow()) {
         $focus = loadImportBean($_REQUEST['import_module']);
         $focus->unPopulateDefaultValues();
         $focus->save_from_post = false;
         $focus->team_id = null;
         $ifs->createdBeans = array();
         $do_save = true;
         for ($fieldNum = 0; $fieldNum < $_REQUEST['columncount']; $fieldNum++) {
             // loop if this column isn't set
             if (!isset($importColumns[$fieldNum])) {
                 continue;
             }
             // get this field's properties
             $field = $importColumns[$fieldNum];
             $fieldDef = $focus->getFieldDefinition($field);
             $fieldTranslated = translate(isset($fieldDef['vname']) ? $fieldDef['vname'] : $fieldDef['name'], $_REQUEST['module']) . " (" . $fieldDef['name'] . ")";
             // Bug 37241 - Don't re-import over a field we already set during the importing of another field
             if (!empty($focus->{$field})) {
                 continue;
             }
             //DETERMINE WHETHER OR NOT $fieldDef['name'] IS DATE_MODIFIED AND SET A VAR, USE DOWN BELOW
             // translate strings
             global $locale;
             if (empty($locale)) {
                 $locale = new Localization();
             }
             if (isset($row[$fieldNum])) {
                 $rowValue = $locale->translateCharset(strip_tags(trim($row[$fieldNum])), $_REQUEST['importlocale_charset'], $sugar_config['default_charset']);
             } else {
                 $rowValue = '';
             }
             // If there is an default value then use it instead
             if (!empty($_REQUEST[$field])) {
                 if (is_array($_REQUEST[$field])) {
                     $defaultRowValue = encodeMultienumValue($_REQUEST[$field]);
                 } else {
                     $defaultRowValue = $_REQUEST[$field];
                 }
                 // translate default values to the date/time format for the import file
                 if ($fieldDef['type'] == 'date' && $ifs->dateformat != $timedate->get_date_format()) {
                     $defaultRowValue = $timedate->swap_formats($defaultRowValue, $ifs->dateformat, $timedate->get_date_format());
                 }
                 if ($fieldDef['type'] == 'time' && $ifs->timeformat != $timedate->get_time_format()) {
                     $defaultRowValue = $timedate->swap_formats($defaultRowValue, $ifs->timeformat, $timedate->get_time_format());
                 }
                 if (($fieldDef['type'] == 'datetime' || $fieldDef['type'] == 'datetimecombo') && $ifs->dateformat . ' ' . $ifs->timeformat != $timedate->get_date_time_format()) {
                     $defaultRowValue = $timedate->swap_formats($defaultRowValue, $ifs->dateformat . ' ' . $ifs->timeformat, $timedate->get_date_time_format());
                 }
                 if (in_array($fieldDef['type'], array('currency', 'float', 'int', 'num')) && $ifs->num_grp_sep != $current_user->getPreference('num_grp_sep')) {
                     $defaultRowValue = str_replace($current_user->getPreference('num_grp_sep'), $ifs->num_grp_sep, $defaultRowValue);
                 }
                 if (in_array($fieldDef['type'], array('currency', 'float')) && $ifs->dec_sep != $current_user->getPreference('dec_sep')) {
                     $defaultRowValue = str_replace($current_user->getPreference('dec_sep'), $ifs->dec_sep, $defaultRowValue);
                 }
                 $currency->retrieve('-99');
                 $user_currency_symbol = $currency->symbol;
                 if ($fieldDef['type'] == 'currency' && $ifs->currency_symbol != $user_currency_symbol) {
                     $defaultRowValue = str_replace($user_currency_symbol, $ifs->currency_symbol, $defaultRowValue);
                 }
                 if (empty($rowValue)) {
                     $rowValue = $defaultRowValue;
                     unset($defaultRowValue);
                 }
             }
             // Bug 22705 - Don't update the First Name or Last Name value if Full Name is set
             if (in_array($field, array('first_name', 'last_name')) && !empty($focus->full_name)) {
                 continue;
             }
             // loop if this value has not been set
             if (!isset($rowValue)) {
                 continue;
             }
             // If the field is required and blank then error out
             if (array_key_exists($field, $focus->get_import_required_fields()) && empty($rowValue) && $rowValue != '0') {
                 $importFile->writeError($mod_strings['LBL_REQUIRED_VALUE'], $fieldTranslated, 'NULL');
                 $do_save = false;
             }
             // Handle the special case "Sync to Outlook"
             if ($focus->object_name == "Contacts" && $field == 'sync_contact') {
                 $bad_names = array();
                 $returnValue = $ifs->synctooutlook($rowValue, $fieldDef, $bad_names);
                 // try the default value on fail
                 if (!$returnValue && !empty($defaultRowValue)) {
                     $returnValue = $ifs->synctooutlook($defaultRowValue, $fieldDef, $bad_names);
                 }
                 if (!$returnValue) {
                     $importFile->writeError($mod_strings['LBL_ERROR_SYNC_USERS'], $fieldTranslated, explode(",", $bad_names));
                     $do_save = 0;
                 }
             }
             // Handle email1 and email2 fields ( these don't have the type of email )
             if ($field == 'email1' || $field == 'email2') {
                 $returnValue = $ifs->email($rowValue, $fieldDef);
                 // try the default value on fail
                 if (!$returnValue && !empty($defaultRowValue)) {
                     $returnValue = $ifs->email($defaultRowValue, $fieldDef);
                 }
                 if ($returnValue === FALSE) {
                     $do_save = 0;
                     $importFile->writeError($mod_strings['LBL_ERROR_INVALID_EMAIL'], $fieldTranslated, $rowValue);
                 } else {
                     $rowValue = $returnValue;
                     // check for current opt_out and invalid email settings for this email address
                     // if we find any, set them now
                     $emailres = $focus->db->query("SELECT opt_out, invalid_email FROM email_addresses \n                                WHERE email_address = '" . $focus->db->quote($rowValue) . "'");
                     if ($emailrow = $focus->db->fetchByAssoc($emailres)) {
                         $focus->email_opt_out = $emailrow['opt_out'];
                         $focus->invalid_email = $emailrow['invalid_email'];
                     }
                 }
             }
             // Handle splitting Full Name into First and Last Name parts
             if ($field == 'full_name' && !empty($rowValue)) {
                 $ifs->fullname($rowValue, $fieldDef, $focus);
             }
             // to maintain 451 compatiblity
             if (!isset($fieldDef['module']) && $fieldDef['type'] == 'relate') {
                 $fieldDef['module'] = ucfirst($fieldDef['table']);
             }
             if (isset($fieldDef['custom_type']) && !empty($fieldDef['custom_type'])) {
                 $fieldDef['type'] = $fieldDef['custom_type'];
             }
             // If the field is empty then there is no need to check the data
             if (!empty($rowValue)) {
                 switch ($fieldDef['type']) {
                     case 'enum':
                     case 'multienum':
                         if (isset($fieldDef['type']) && $fieldDef['type'] == "multienum") {
                             $returnValue = $ifs->multienum($rowValue, $fieldDef);
                         } else {
                             $returnValue = $ifs->enum($rowValue, $fieldDef);
                         }
                         // try the default value on fail
                         if (!$returnValue && !empty($defaultRowValue)) {
                             if (isset($fieldDef['type']) && $fieldDef['type'] == "multienum") {
                                 $returnValue = $ifs->multienum($defaultRowValue, $fieldDef);
                             } else {
                                 $returnValue = $ifs->enum($defaultRowValue, $fieldDef);
                             }
                         }
                         if ($returnValue === FALSE) {
                             $importFile->writeError($mod_strings['LBL_ERROR_NOT_IN_ENUM'] . implode(",", $app_list_strings[$fieldDef['options']]), $fieldTranslated, $rowValue);
                             $do_save = 0;
                         } else {
                             $rowValue = $returnValue;
                         }
                         break;
                     case 'relate':
                     case 'parent':
                         $returnValue = $ifs->relate($rowValue, $fieldDef, $focus, empty($defaultRowValue));
                         if (!$returnValue && !empty($defaultRowValue)) {
                             $returnValue = $ifs->relate($defaultRowValue, $fieldDef, $focus);
                         }
                         // Bug 33623 - Set the id value found from the above method call as an importColumn
                         if ($returnValue !== false) {
                             $importColumns[] = $fieldDef['id_name'];
                         }
                         break;
                     case 'teamset':
                         $returnValue = $ifs->teamset($rowValue, $fieldDef, $focus);
                         $importColumns[] = 'team_set_id';
                         $importColumns[] = 'team_id';
                         break;
                     case 'fullname':
                         break;
                     default:
                         if (method_exists('ImportFieldSanitize', $fieldDef['type'])) {
                             $fieldtype = $fieldDef['type'];
                             $returnValue = $ifs->{$fieldtype}($rowValue, $fieldDef);
                             // try the default value on fail
                             if (!$returnValue && !empty($defaultRowValue)) {
                                 $returnValue = $ifs->{$fieldtype}($defaultRowValue, $fieldDef);
                             }
                             if (!$returnValue) {
                                 $do_save = 0;
                                 $importFile->writeError($mod_strings['LBL_ERROR_INVALID_' . strtoupper($fieldDef['type'])], $fieldTranslated, $rowValue);
                             } else {
                                 $rowValue = $returnValue;
                             }
                         }
                 }
             }
             $focus->{$field} = $rowValue;
             unset($defaultRowValue);
         }
         // Now try to validate flex relate fields
         if (isset($focus->field_defs['parent_name']) && isset($focus->parent_name) && $focus->field_defs['parent_name']['type'] == 'parent') {
             // populate values from the picker widget if the import file doesn't have them
             $parent_idField = $focus->field_defs['parent_name']['id_name'];
             if (empty($focus->{$parent_idField}) && !empty($_REQUEST[$parent_idField])) {
                 $focus->{$parent_idField} = $_REQUEST[$parent_idField];
             }
             $parent_typeField = $focus->field_defs['parent_name']['type_name'];
             if (empty($focus->{$parent_typeField}) && !empty($_REQUEST[$parent_typeField])) {
                 $focus->{$parent_typeField} = $_REQUEST[$parent_typeField];
             }
             // now validate it
             $returnValue = $ifs->parent($focus->parent_name, $focus->field_defs['parent_name'], $focus, empty($_REQUEST['parent_name']));
             if (!$returnValue && !empty($_REQUEST['parent_name'])) {
                 $returnValue = $ifs->parent($_REQUEST['parent_name'], $focus->field_defs['parent_name'], $focus);
             }
         }
         // check to see that the indexes being entered are unique.
         if (isset($_REQUEST['display_tabs_def']) && $_REQUEST['display_tabs_def'] != "") {
             $idc = new ImportDuplicateCheck($focus);
             if ($idc->isADuplicateRecord(explode('&', $_REQUEST['display_tabs_def']))) {
                 $importFile->markRowAsDuplicate();
                 $this->_undoCreatedBeans($ifs->createdBeans);
                 continue;
             }
         }
         // if the id was specified
         $newRecord = true;
         if (!empty($focus->id)) {
             $focus->id = $this->_convertId($focus->id);
             // check if it already exists
             $query = "SELECT * FROM {$focus->table_name} WHERE id='" . $focus->db->quote($focus->id) . "'";
             $result = $focus->db->query($query) or sugar_die("Error selecting sugarbean: ");
             $dbrow = $focus->db->fetchByAssoc($result);
             if (isset($dbrow['id']) && $dbrow['id'] != -1) {
                 // if it exists but was deleted, just remove it
                 if (isset($dbrow['deleted']) && $dbrow['deleted'] == 1 && $update_only == false) {
                     $query2 = "DELETE FROM {$focus->table_name} WHERE id='" . $focus->db->quote($focus->id) . "'";
                     $result2 = $focus->db->query($query2) or sugar_die($mod_strings['LBL_ERROR_DELETING_RECORD'] . " " . $focus->id);
                     if ($focus->hasCustomFields()) {
                         $query3 = "DELETE FROM {$focus->table_name}_cstm WHERE id_c='" . $focus->db->quote($focus->id) . "'";
                         $result2 = $focus->db->query($query3);
                     }
                     $focus->new_with_id = true;
                 } else {
                     if (!$update_only) {
                         $do_save = 0;
                         $importFile->writeError($mod_strings['LBL_ID_EXISTS_ALREADY'], 'ID', $focus->id);
                         $this->_undoCreatedBeans($ifs->createdBeans);
                         continue;
                     }
                     $existing_focus = loadImportBean($_REQUEST['import_module']);
                     $newRecord = false;
                     if (!$existing_focus->retrieve($dbrow['id']) instanceof SugarBean) {
                         $do_save = 0;
                         $importFile->writeError($mod_strings['LBL_RECORD_CANNOT_BE_UPDATED'], 'ID', $focus->id);
                         $this->_undoCreatedBeans($ifs->createdBeans);
                         continue;
                     } else {
                         $newData = $focus->toArray();
                         foreach ($newData as $focus_key => $focus_value) {
                             if (in_array($focus_key, $importColumns)) {
                                 $existing_focus->{$focus_key} = $focus_value;
                             }
                         }
                         $focus = $existing_focus;
                     }
                     unset($existing_focus);
                 }
             } else {
                 $focus->new_with_id = true;
             }
         }
         if ($do_save) {
             // Populate in any default values to the bean
             $focus->populateDefaultValues();
             if (!isset($focus->assigned_user_id) || $focus->assigned_user_id == '' && $newRecord) {
                 $focus->assigned_user_id = $current_user->id;
             }
             /*
              * Bug 34854: Added all conditions besides the empty check on date modified. Currently, if
              * we do an update to a record, it doesn't update the date_modified value.
              * Hack note: I'm doing a to_display and back to_db on the fetched row to make sure that any truncating that happens
              * when $focus->date_modified goes to_display and back to_db also happens on the fetched db value. Otherwise,
              * in some cases we truncate the seconds on one and not the other, and the comparison fails when it should pass
              */
             if (!empty($focus->new_with_id) && !empty($focus->date_modified) || empty($focus->new_with_id) && $timedate->to_db($focus->date_modified) != $timedate->to_db($timedate->to_display_date_time($focus->fetched_row['date_modified']))) {
                 $focus->update_date_modified = false;
             }
             $focus->optimistic_lock = false;
             if ($focus->object_name == "Contacts" && isset($focus->sync_contact)) {
                 //copy the potential sync list to another varible
                 $list_of_users = $focus->sync_contact;
                 //and set it to false for the save
                 $focus->sync_contact = false;
             } else {
                 if ($focus->object_name == "User" && !empty($current_user) && $focus->is_admin && !is_admin($current_user) && is_admin_for_module($current_user, 'Users')) {
                     sugar_die($GLOBALS['mod_strings']['ERR_IMPORT_SYSTEM_ADMININSTRATOR']);
                 }
             }
             //bug# 40260 setting it true as the module in focus is involved in an import
             $focus->in_import = true;
             // call any logic needed for the module preSave
             $focus->beforeImportSave();
             $focus->save(false);
             // call any logic needed for the module postSave
             $focus->afterImportSave();
             if ($focus->object_name == "Contacts" && isset($list_of_users)) {
                 $focus->process_sync_to_outlook($list_of_users);
             }
             // Update the created/updated counter
             $importFile->markRowAsImported($newRecord);
             // Add ID to User's Last Import records
             if ($newRecord) {
                 ImportFile::writeRowToLastImport($_REQUEST['import_module'], $focus->object_name == 'Case' ? 'aCase' : $focus->object_name, $focus->id);
             }
         } else {
             $this->_undoCreatedBeans($ifs->createdBeans);
         }
     }
     // save mapping if requested
     if (isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') {
         $mapping_file = new ImportMap();
         if (isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on') {
             $header_to_field = array();
             foreach ($importColumns as $pos => $field_name) {
                 if (isset($firstrow[$pos]) && isset($field_name)) {
                     $header_to_field[$firstrow[$pos]] = $field_name;
                 }
             }
             $mapping_file->setMapping($header_to_field);
         } else {
             $mapping_file->setMapping($importColumns);
         }
         // save default fields
         $defaultValues = array();
         for ($i = 0; $i < $_REQUEST['columncount']; $i++) {
             if (isset($importColumns[$i]) && !empty($_REQUEST[$importColumns[$i]])) {
                 $field = $importColumns[$i];
                 $fieldDef = $focus->getFieldDefinition($field);
                 if (!empty($fieldDef['custom_type']) && $fieldDef['custom_type'] == 'teamset') {
                     require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                     $sugar_field = new SugarFieldTeamset('Teamset');
                     $teams = $sugar_field->getTeamsFromRequest($field);
                     if (isset($_REQUEST['primary_team_name_collection'])) {
                         $primary_index = $_REQUEST['primary_team_name_collection'];
                     }
                     //If primary_index was selected, ensure that the first Array entry is the primary team
                     if (isset($primary_index)) {
                         $count = 0;
                         $new_teams = array();
                         foreach ($teams as $id => $name) {
                             if ($primary_index == $count++) {
                                 $new_teams[$id] = $name;
                                 unset($teams[$id]);
                                 break;
                             }
                         }
                         foreach ($teams as $id => $name) {
                             $new_teams[$id] = $name;
                         }
                         $teams = $new_teams;
                     }
                     //if
                     $json = getJSONobj();
                     $defaultValues[$field] = $json->encode($teams);
                 } else {
                     $defaultValues[$field] = $_REQUEST[$importColumns[$i]];
                 }
             }
         }
         $mapping_file->setDefaultValues($defaultValues);
         $result = $mapping_file->save($current_user->id, $_REQUEST['save_map_as'], $_REQUEST['import_module'], $_REQUEST['source'], isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on', $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     }
     $importFile->writeStatus();
 }
Example #8
0
}
// Populate the custom fields
$sfh = new SugarFieldHandler();
foreach ($focus->field_defs as $fieldName => $field) {
    if (isset($field['source']) && $field['source'] == 'custom_fields') {
        $type = !empty($field['custom_type']) ? $field['custom_type'] : $field['type'];
        $sf = $sfh->getSugarField($type);
        if ($sf != null) {
            $sf->save($focus, $_POST, $fieldName, $field, '');
        } else {
            $GLOBALS['log']->fatal("Field '{$fieldName}' does not have a SugarField handler");
        }
    }
}
require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
$teamSetField = new SugarFieldTeamset('Teamset');
if (!$newUser && $teamSetField != null) {
    $teamSetField->save($focus, $_POST, 'team_name', '');
}
$portal = array("user_name", "last_name", "status", "portal_only");
$group = array("user_name", "last_name", "status", "is_group");
if (isset($_POST['portal_only']) && ($_POST['portal_only'] == '1' || $focus->portal_only)) {
    foreach ($portal as $field) {
        if (isset($_POST[$field])) {
            $value = $_POST[$field];
            $focus->{$field} = $value;
        }
    }
}
if (isset($_POST['is_group']) && ($_POST['is_group'] == '1' || $focus->is_group)) {
    foreach ($group as $field) {
function create_wiz_step_divs($steps, $ss)
{
    //Assign the Teamset field
    require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
    $teamSetField = new SugarFieldTeamset('Teamset');
    $focus = new Campaign();
    $code = $teamSetField->getClassicView($focus->field_defs, 'wizform');
    $ss->assign("TEAM_SET_FIELD", $code);
    $step_html = '';
    if (isset($steps) && !empty($steps)) {
        $i = 1;
        foreach ($steps as $name => $step) {
            $step_html .= "<p><div id='step{$i}'>";
            $step_html .= $ss->fetch($step);
            $step_html .= "</div></p>";
            $i = $i + 1;
        }
    }
    return $step_html;
}
Example #10
0
 //kbrill Bug #13826
 foreach ($linked_fields as $name => $properties) {
     if ($properties['name'] == 'modified_user_link' || in_array($properties['name'], $exclude)) {
         continue;
     }
     if (isset($properties['duplicate_merge'])) {
         if ($properties['duplicate_merge'] == 'disabled' or $properties['duplicate_merge'] == 'false' or $properties['name'] == 'assigned_user_link') {
             continue;
         }
     }
     if ($name == 'accounts' && $focus->merge_bean->module_dir == 'Opportunities') {
         continue;
     }
     if ($name == 'teams') {
         require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
         $teamSetField = new SugarFieldTeamset('Teamset');
         if ($teamSetField != null) {
             $teamSetField->save($focus->merge_bean, $_REQUEST, 'team_name', '');
             $focus->merge_bean->teams->setSaved(FALSE);
             $focus->merge_bean->teams->save();
             $focus->merge_bean->save();
         }
         continue;
     }
     if ($mergesource->load_relationship($name)) {
         //check to see if loaded relationship is with email address
         $relName = $mergesource->{$name}->getRelatedModuleName();
         if (!empty($relName) and strtolower($relName) == 'emailaddresses') {
             //handle email address merge
             handleEmailMerge($focus, $name, $mergesource->{$name}->get());
         } else {
 function setup()
 {
     $this->related_module = 'Teams';
     $this->value_name = 'team_set_id_values';
     $this->vardef['name'] = $this->name;
     if (!empty($GLOBALS['beanList'][$this->module_dir])) {
         $class = $GLOBALS['beanList'][$this->module_dir];
         if (SugarAutoLoader::fileExists($GLOBALS['beanFiles'][$class])) {
             $this->bean = BeanFactory::getBean($this->module_dir);
             $secondaries = array();
             $primary = false;
             $this->bean->{$this->value_name} = array('role_field' => 'team_name');
             if (!empty($this->team_id)) {
                 $this->bean->team_id = $this->team_id;
                 if (!empty($this->team_set_id)) {
                     $this->bean->team_set_id = $this->team_set_id;
                 }
             } else {
                 if (!empty($_REQUEST['record'])) {
                     $this->bean->retrieve($_REQUEST['record']);
                 }
             }
             if (!empty($this->bean->team_set_id)) {
                 require_once 'modules/Teams/TeamSetManager.php';
                 $teams = TeamSetManager::getTeamsFromSet($this->bean->team_set_id);
                 foreach ($teams as $row) {
                     if (empty($primary) && $this->bean->team_id == $row['id']) {
                         $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $row['id'], 'name' => $row['display_name'])));
                         $primary = true;
                     } else {
                         $secondaries['secondaries'][] = array('id' => $row['id'], 'name' => $row['display_name']);
                     }
                 }
                 //foreach
             } elseif (!empty($this->bean->team_id)) {
                 //since the team_set_id is not set, but the team_id is.
                 $focus = BeanFactory::getBean('Teams', $this->bean->team_id);
                 $display_name = Team::getDisplayName($focus->name, $focus->name_2);
                 $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $focus->id, 'name' => $display_name)));
             } elseif (empty($this->bean->team_id) && empty($this->bean->team_set_id)) {
                 require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                 $teams = SugarFieldTeamset::getTeamsFromRequest($this->bean->{$this->value_name}['role_field'], $_POST);
                 $primary_id = SugarFieldTeamset::getPrimaryTeamidFromRequest($this->bean->{$this->value_name}['role_field'], $_POST);
                 foreach ($teams as $id => $name) {
                     // getting strings of values is needed because some problems appears when compare '1' and md5 value which begins from '1'
                     if (strval($primary_id) === strval($id)) {
                         $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $id, 'name' => $name)));
                     } else {
                         $secondaries['secondaries'][] = array('id' => $id, 'name' => $name);
                     }
                 }
             }
             $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $secondaries);
         }
     }
     $this->skipModuleQuickSearch = true;
     $this->showSelectButton = false;
 }
Example #12
0
                $teamSetField = new SugarFieldTeamset('Teamset');
                $field_defs = VardefManager::loadVardef('Reports', 'SavedReport');
                $teamSetField->initClassicView($GLOBALS['dictionary']['SavedReport']['fields'], 'ReportsWizardForm');
                $team_html = $teamSetField->getClassicView();
                $sugar_smarty->assign("TEAM_HTML", $team_html);
                $sugar_smarty->assign("USER_HTML", $assigned_user_html);
                $sugar_smarty->assign("report_offset", $args['reporter']->report_offset);
                $sugar_smarty->assign("chart_description", htmlentities($args['reporter']->chart_description, ENT_QUOTES, 'UTF-8'));
                setSortByInfo($args['reporter'], $sugar_smarty);
                echo $sugar_smarty->fetch('modules/Reports/ReportsWizard.tpl');
            } else {
                $assigned_user_html_def = array('parent_id' => 'assigned_user_id', 'parent_id_value' => $current_user->id, 'parent_name' => 'assigned_user_name', 'parent_name_value' => $current_user->user_name, 'real_parent_name' => 'user_name', 'module' => 'Users');
                $assigned_user_html = get_select_related_html($assigned_user_html_def);
                $sugar_smarty->assign("do_round", 1);
                require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                $teamSetField = new SugarFieldTeamset('Teamset');
                $field_defs = VardefManager::loadVardef('Reports', 'SavedReport');
                $teamSetField->initClassicView($GLOBALS['dictionary']['SavedReport']['fields'], 'ReportsWizardForm');
                $team_html = $teamSetField->getClassicView();
                $sugar_smarty->assign("TEAM_HTML", $team_html);
                $sugar_smarty->assign("USER_HTML", $assigned_user_html);
                $sugar_smarty->assign("report_offset", $args['reporter']->report_offset);
                $sugar_smarty->assign("chart_description", htmlentities($args['reporter']->chart_description, ENT_QUOTES, 'UTF-8'));
                setSortByInfo($args['reporter'], $sugar_smarty);
                echo $sugar_smarty->fetch('modules/Reports/ReportsWizard.tpl');
            }
        }
    }
}
function setSortByInfo(&$reporter, &$smarty)
{