parent
f6bdd94db5
commit
d4d19d26f0
@ -0,0 +1,28 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Loader; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Interfaces\LoaderInterface; |
||||
|
||||
/** |
||||
* Class UserLastLoginLoader. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Loader |
||||
*/ |
||||
class UserLastLoginLoader implements LoaderInterface |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function load(array $incomingData) |
||||
{ |
||||
\Database::update( |
||||
\Database::get_main_table(TABLE_MAIN_USER), |
||||
['last_login' => $incomingData['last_login']->format('Y-m-d H:i:s')], |
||||
['id = ?' => [$incomingData['user_id']]] |
||||
); |
||||
|
||||
return $incomingData['user_id']; |
||||
} |
||||
} |
||||
@ -0,0 +1,59 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Task; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Extractor\LoadedUsersFilterExtractor; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Loader\UserLastLoginLoader; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\DateTimeObject; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedUserLookup; |
||||
|
||||
/** |
||||
* Class UsersLastLoginTask. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Task |
||||
*/ |
||||
class UsersLastLoginTask extends BaseTask |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getExtractConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => LoadedUsersFilterExtractor::class, |
||||
'query' => 'SELECT id, lastlogin FROM mdl_user WHERE lastlogin != 0', |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getTransformConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => BaseTransformer::class, |
||||
'map' => [ |
||||
'user_id' => [ |
||||
'class' => LoadedUserLookup::class, |
||||
'properties' => ['id'], |
||||
], |
||||
'last_login' => [ |
||||
'class' => DateTimeObject::class, |
||||
'properties' => ['lastlogin'], |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getLoadConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => UserLastLoginLoader::class, |
||||
]; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue