{$mod_strings_users['LBL_REASS_SCRIPT_TITLE']}"; // Include Metadata for processing require_once("modules/Users/metadata/reassignScriptMetadata.php"); if(file_exists("custom/modules/Users/reassignScriptMetadata_override.php")){ include("custom/modules/Users/reassignScriptMetadata_override.php"); } if(!empty($_GET['record'])){ unset($_SESSION['reassignRecords']); $_SESSION['reassignRecords']['fromuser'] = $_GET['record']; } if(!isset($_POST['fromuser']) && !isset($_GET['execute'])){ ///////////////////// BEGIN STEP 1 - Select users/modules ///////////////////////// $exclude_modules = array( "ImportMap", "UsersLastImport", "Dashboard", "SavedSearch", "UserPreference", "SugarFavorites", ); if(isset($_GET['clear']) && $_GET['clear'] == 'true'){ unset($_SESSION['reassignRecords']); } ?>
query($query); while($row = $GLOBALS['db']->fetchByAssoc($res)){ if($row['id'] == $_POST['fromuser']) $fromusername = $row['user_name']; if($row['id'] == $_POST['touser']) $tousername = $row['user_name']; } echo "{$mod_strings_users['LBL_REASS_DESC_PART2']}\n"; echo "\n"; // debug //print_r($_SESSION['reassignRecords']); ///////////////////// END STEP 2 - Confirm Selections ///////////////////////// } /////////////////// BEGIN STEP 3 - Execute reassignment /////////////////////// else if(isset($_GET['execute']) && $_GET['execute'] == true){ $fromuser = $_SESSION['reassignRecords']['fromuser']; $touser = $_SESSION['reassignRecords']['touser']; $fromusername = $_SESSION['reassignRecords']['fromusername']; $tousername = $_SESSION['reassignRecords']['tousername']; $beanListFlip = array_flip($_SESSION['reassignRecords']['assignedModuleListCache']); foreach($_SESSION['reassignRecords']['modules'] as $module => $queries){ $p_module = $beanListFlip[$module]; $workflow = false; if(isset($_POST[$module."_workflow"]) && $_POST[$module."_workflow"] = "on") $workflow = true; $query = $workflow ? $queries['query'] : $queries['update']; echo "\n";
if(! $workflow){
$affected_rows = $GLOBALS['db']->getAffectedRowCount();
echo "{$mod_strings_users['LBL_UPDATE_FINISH']}: $affected_rows {$mod_strings_users['LBL_AFFECTED']} \n"; } else{ $successarr = array(); $failarr = array(); require_once($beanFiles[$module]); while($row = $GLOBALS['db']->fetchByAssoc($res)){ $bean = new $module(); if(empty($row['id'])){ continue; } $bean->retrieve($row['id']); // So that we don't create new blank records. if(!isset($bean->id)){ continue; } $bean->assigned_user_id = $touser; if($bean->save()){ $linkname = "record with id {$bean->id}"; if(!empty($bean->name)){ $linkname = $bean->name; } else if(!empty($bean->last_name)){ $linkname = $locale->getLocaleFormattedName($bean->first_name, $bean->last_name); } else if(!empty($bean->document_name)){ $linkname = $bean->document_name; } $successstr = "{$mod_strings_users['LBL_REASS_SUCCESS_ASSIGN']} {$bean->object_name} \"module_dir}&action=DetailView&record={$bean->id}\">$linkname\" {$mod_strings_users['LBL_REASS_FROM']} $fromusername {$mod_strings_users['LBL_REASS_TO']} $tousername"; $successarr[] = $successstr; } else{ $failarr[] = "{$mod_strings_users['LBL_REASS_FAILED_SAVE']} \"module_dir}&action=DetailView&record={$bean->id}\">$linkname\"."; } } if(isset($_POST['verbose']) && $_POST['verbose'] == "on"){ echo " {$mod_strings_users['LBL_REASS_THE_FOLLOWING']} {$app_list_strings['moduleList'][$p_module]} {$mod_strings_users['LBL_REASS_HAVE_BEEN_UPDATED']}\n"; foreach($successarr as $ord){ echo "$ord\n\n"; } if(empty($successarr)) echo "{$mod_strings_users['LBL_REASS_NONE']}\n \n"; echo " {$mod_strings_users['LBL_REASS_THE_FOLLOWING']} {$app_list_strings['moduleList'][$p_module]} {$mod_strings_users['LBL_REASS_CANNOT_PROCESS']}\n"; foreach($failarr as $failure){ echo $failure."\n\n"; } if(empty($failarr)) echo "{$mod_strings_users['LBL_REASS_NONE']}\n \n"; } else{ echo "{$mod_strings_users['LBL_REASS_UPDATE_COMPLETE']}\n \n"; echo " ".count($successarr)." {$mod_strings_users['LBL_REASS_SUCCESSFUL']}\n \n"; echo " ".count($failarr)." {$mod_strings_users['LBL_REASS_FAILED']}\n"; } echo " \n"; } echo " |