Authored-by: Christian <christian1827@gmail.com>pull/4393/head
parent
a371e9450f
commit
518310dd5f
@ -0,0 +1,144 @@ |
||||
<?php |
||||
|
||||
declare(strict_types = 1); |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Entity; |
||||
|
||||
use Chamilo\CoreBundle\Traits\UserTrait; |
||||
use DateTime; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
/** |
||||
* Track Login Record. |
||||
* |
||||
* @ORM\Table(name="track_e_login_record") |
||||
* @ORM\Entity |
||||
*/ |
||||
class TrackELoginRecord |
||||
{ |
||||
|
||||
/** |
||||
* @ORM\Column(name="id", type="integer") |
||||
* @ORM\Id |
||||
* @ORM\GeneratedValue |
||||
*/ |
||||
protected int $id; |
||||
|
||||
/** |
||||
* @ORM\Column(name="username", type="string", length=100, nullable=false) |
||||
*/ |
||||
protected string $username; |
||||
|
||||
/** |
||||
* @ORM\Column(name="login_date", type="datetime", nullable=false) |
||||
*/ |
||||
protected DateTime $loginDate; |
||||
|
||||
/** |
||||
* @ORM\Column(name="user_ip", type="string", length=45, nullable=false) |
||||
*/ |
||||
protected string $userIp; |
||||
|
||||
/** |
||||
* @ORM\Column(name="success", type="boolean") |
||||
*/ |
||||
protected bool $success; |
||||
|
||||
/** |
||||
* Get the username. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function getUsername(): string |
||||
{ |
||||
return $this->username; |
||||
} |
||||
|
||||
/** |
||||
* Set the username. |
||||
* |
||||
* @param string $username |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function setUsername(string $username): self |
||||
{ |
||||
$this->username = $username; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Set Login date. |
||||
* |
||||
* @param DateTime $loginDate |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function setLoginDate(DateTime $loginDate): self |
||||
{ |
||||
$this->loginDate = $loginDate; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get login date. |
||||
* |
||||
* @return DateTime |
||||
*/ |
||||
public function getLoginDate() |
||||
{ |
||||
return $this->loginDate; |
||||
} |
||||
|
||||
/** |
||||
* Set user ip. |
||||
* |
||||
* @param string $userIp |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function setUserIp(string $userIp): self |
||||
{ |
||||
$this->userIp = $userIp; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get user Ip. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function getUserIp() |
||||
{ |
||||
return $this->userIp; |
||||
} |
||||
|
||||
/** |
||||
* Get the success value. |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public function getSuccess(): bool |
||||
{ |
||||
return $this->success; |
||||
} |
||||
|
||||
/** |
||||
* Set the success value. |
||||
* |
||||
* @param bool $boolean |
||||
* |
||||
* @return $this |
||||
*/ |
||||
public function setSuccess(bool $boolean): self |
||||
{ |
||||
$this->success = $boolean; |
||||
|
||||
return $this; |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
<?php |
||||
|
||||
declare(strict_types = 1); |
||||
|
||||
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
||||
|
||||
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20220628180435 extends AbstractMigrationChamilo |
||||
{ |
||||
/** |
||||
* Return desription of the migration step. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function getDescription(): string |
||||
{ |
||||
return 'track login record'; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
if (false === $schema->hasTable('track_e_login_record')) { |
||||
$this->addSql( |
||||
'CREATE TABLE track_e_login_record (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(100) NOT NULL, login_date DATETIME NOT NULL COMMENT "(DC2Type:datetime)", user_ip VARCHAR(39) NOT NULL, success TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;' |
||||
); |
||||
} |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
// this down() migration is auto-generated, please modify it to your needs |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
<?php |
||||
|
||||
declare(strict_types = 1); |
||||
|
||||
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
||||
|
||||
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20220909165130 extends AbstractMigrationChamilo |
||||
{ |
||||
/** |
||||
* Return desription of the migration step. |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function getDescription(): string |
||||
{ |
||||
return 'change field user_ip length 45 characters'; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_exercises CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_course_access CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE room CHANGE ip ip VARCHAR(45) DEFAULT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_access CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_online CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_login CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_login_record CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE c_wiki CHANGE user_ip user_ip VARCHAR(45) NOT NULL;' |
||||
); |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
$this->addSql( |
||||
'ALTER TABLE c_wiki CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_login_record CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_login CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_online CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_access CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE room CHANGE ip ip VARCHAR(39) DEFAULT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_course_access CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE track_e_exercises CHANGE user_ip user_ip VARCHAR(39) NOT NULL;' |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,25 @@ |
||||
<?php |
||||
|
||||
declare(strict_types = 1); |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Repository; |
||||
|
||||
use Chamilo\CoreBundle\Entity\TrackELoginRecord; |
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||
use Doctrine\Persistence\ManagerRegistry; |
||||
|
||||
final class TrackELoginRecordRepository extends ServiceEntityRepository |
||||
{ |
||||
public function __construct(ManagerRegistry $registry) |
||||
{ |
||||
parent::__construct($registry, TrackELoginRecord::class); |
||||
} |
||||
|
||||
public function create(TrackELoginRecord $trackELoginRecord): void |
||||
{ |
||||
$this->getEntityManager()->persist($trackELoginRecord); |
||||
$this->getEntityManager()->flush(); |
||||
} |
||||
} |
Loading…
Reference in new issue