parent
d4d19d26f0
commit
e3a98cc8fd
@ -0,0 +1,33 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Loader; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Interfaces\LoaderInterface; |
||||
|
||||
/** |
||||
* Class TrackLoginLoader. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Loader |
||||
*/ |
||||
class TrackLoginLoader implements LoaderInterface |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function load(array $incomingData) |
||||
{ |
||||
$incomingData['login_date'] = $incomingData['login_date']->format('Y-m-d H:i:s'); |
||||
|
||||
if ($incomingData['logout_date']) { |
||||
$incomingData['logout_date'] = $incomingData['logout_date']->format('Y-m-d H:i:s'); |
||||
} |
||||
|
||||
$incomingData['user_ip'] = ''; |
||||
|
||||
return \Database::insert( |
||||
\Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN), |
||||
$incomingData |
||||
); |
||||
} |
||||
} |
||||
@ -0,0 +1,63 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Task; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Extractor\LoadedUsersFilterExtractor; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Loader\TrackLoginLoader; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\DateTimeObject; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedUserLookup; |
||||
|
||||
/** |
||||
* Class TrackLoginTask. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Task |
||||
*/ |
||||
class TrackLoginTask extends BaseTask |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getExtractConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => LoadedUsersFilterExtractor::class, |
||||
'query' => 'SELECT id, firstaccess, lastaccess FROM mdl_user WHERE firstaccess != 0', |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getTransformConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => BaseTransformer::class, |
||||
'map' => [ |
||||
'login_user_id' => [ |
||||
'class' => LoadedUserLookup::class, |
||||
'properties' => ['id'], |
||||
], |
||||
'login_date' => [ |
||||
'class' => DateTimeObject::class, |
||||
'properties' => ['firstaccess'], |
||||
], |
||||
'logout_date' => [ |
||||
'class' => DateTimeObject::class, |
||||
'properties' => ['lastaccess'], |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getLoadConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => TrackLoginLoader::class, |
||||
]; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue