Feature #36802 » saltedpasswords_example.diff
typo3/sysext/saltedpasswords/classes/tasks/class.tx_saltedpasswords_tasks_bulkupdate.php 2012-05-02 23:35:56.000000000 +0200 | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage saltedpasswords
|
||
*/
|
||
class tx_saltedpasswords_Tasks_BulkUpdate extends tx_scheduler_Task {
|
||
class tx_saltedpasswords_Tasks_BulkUpdate extends tx_scheduler_Task implements tx_scheduler_ProgressProvider {
|
||
/**
|
||
* @var boolean Whether or not the task is allowed to deactivate itself after processing all existing user records.
|
||
* @TODO: This could be set with an additional field later on.
|
||
... | ... | |
protected function deactivateSelf() {
|
||
$this->setDisabled(TRUE);
|
||
}
|
||
/**
|
||
* Gets the progress of a task.
|
||
*
|
||
* @return float Progress of the task as a two decimal precision float. f.e. 44.87
|
||
*/
|
||
public function getProgress() {
|
||
$progress = 100.00;
|
||
$totalUsers = 0;
|
||
$totalUsersToUpdate = 0;
|
||
foreach ($this->userRecordPointer as $mode => $pointer) {
|
||
if (tx_saltedpasswords_div::isUsageEnabled($mode)) {
|
||
$totalUsers += $this->getNumberOfUsers($mode);
|
||
$usersToUpdate = $this->findUsersToUpdate($mode);
|
||
$totalUsersToUpdate += count($usersToUpdate);
|
||
}
|
||
}
|
||
$usersConverted = $totalUsers - $totalUsersToUpdate;
|
||
$progress = $usersConverted * 100 / $totalUsers;
|
||
$progress = round($progress, 2);
|
||
return $progress;
|
||
}
|
||
/**
|
||
* Gets the total number of frontend or backend users.
|
||
*
|
||
* @param string 'FE' for frontend, 'BE' for backend user records
|
||
* @return integer Number of users for the given mode.
|
||
*/
|
||
protected function getNumberOfUsers($mode) {
|
||
$usersToUpdate = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
|
||
'uid',
|
||
strtolower($mode) . '_users',
|
||
'1 = 1' // retrieve and update all records (also disabled/deleted) for security reasons
|
||
);
|
||
return $usersToUpdate;
|
||
}
|
||
} // End of class
|
||
if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/saltedpasswords/classes/tasks/class.tx_saltedpasswords_tasks_bulkupdate.php']) {
|