-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leaf 4630 - script to update existing disabled users
- Loading branch information
Showing
3 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
scripts/scheduled-task-commands/updateExistingDisabledEmployees.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
require_once 'globals.php'; | ||
require_once APP_PATH . '/Leaf/Db.php'; | ||
|
||
$VISNS = array('acc.dva.va.gov', | ||
'cem.va.gov', | ||
'dva.va.gov', | ||
'mpi.v21.med.va.gov', | ||
'r01.med.va.gov', | ||
'r02.med.va.gov', | ||
'r03.med.va.gov', | ||
'r04.med.va.gov', | ||
'va', | ||
'va.gov', | ||
'vba.va.gov', | ||
'vha.med.va.gov', | ||
'VHA01', | ||
'VHA02', | ||
'VHA03', | ||
'VHA04', | ||
'VHA05', | ||
'VHA06', | ||
'VHA07', | ||
'VHA08', | ||
'VHA09', | ||
'VHA10', | ||
'VHA11', | ||
'VHA12', | ||
'VHA15', | ||
'VHA16', | ||
'VHA17', | ||
'VHA18', | ||
'VHA19', | ||
'VHA20', | ||
'VHA21', | ||
'VHA22', | ||
'VHA23', | ||
); | ||
|
||
function updateEmps($VISNS) { | ||
foreach ($VISNS as $visn) { | ||
if (str_starts_with($visn['data'], 'DN,')) { | ||
exec("php /var/www/scripts/updateExistingDisabledNationalOrgchart.php {$visn} > /dev/null 2>/dev/null &"); | ||
echo "Deploying to: {$visn}\r\n"; | ||
} | ||
} | ||
} | ||
|
||
updateEmps($VISNS); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
require_once 'scheduled-task-commands/globals.php'; | ||
require_once APP_PATH . '/Leaf/Db.php'; | ||
require_once APP_PATH . '/Leaf/VAMCActiveDirectory.php'; | ||
|
||
$startTime = microtime(true); | ||
|
||
if (count($argv) < 1) { | ||
// no argument supplied | ||
exit(); | ||
} | ||
|
||
$file = $argv[1]; | ||
|
||
$national_db = new App\Leaf\Db(DIRECTORY_HOST, DIRECTORY_USER, DIRECTORY_PASS, 'national_orgchart'); | ||
|
||
$vars = array(':domain' => $file); | ||
$sql = 'SELECT `userName` | ||
FROM `employee` | ||
WHERE `deleted` > 0 | ||
AND LEFT(`userName`, 9) <> "disabled_" | ||
AND `domain` = :domain | ||
LIMIT 1000'; | ||
|
||
$VISNS = $db->prepared_query($sql, $vars); | ||
$users = array(); | ||
|
||
foreach ($VISNS as $user) { | ||
$users[] = $user['userName']; | ||
} | ||
|
||
$dir = new App\Leaf\VAMCActiveDirectory($national_db); | ||
|
||
$dir->disableNationalOrgchartEmployees($users); | ||
|
||
$endTime = microtime(true); | ||
$totalTime = round(($endTime - $startTime)/60, 2); | ||
|
||
error_log(print_r($file . " took " . $totalTime . " minutes to complete.", true), 3 , '/var/www/php-logs/update_existing.log'); |