Add v2 DB changes

pull/2487/head
jmontoyaa 7 years ago
parent 656bf9ea82
commit 3b8865fe50
  1. 26
      main/install/index.php
  2. 86
      src/UserBundle/Entity/User.php

@ -861,12 +861,6 @@ if (@$_POST['step2']) {
$connection->executeQuery(
'ALTER TABLE media__media ADD CONSTRAINT FK_5C6DD74E12469DE2 FOREIGN KEY (category_id) REFERENCES classification__category (id) ON DELETE SET NULL'
);
$connection->executeQuery(
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id)'
);
$connection->executeQuery(
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)'
);
$connection->executeQuery("CREATE TABLE timeline__timeline (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, subject_id INT DEFAULT NULL, context VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FFBC6AD59D32F035 (action_id), INDEX IDX_FFBC6AD523EDC87 (subject_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__component (id INT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, identifier LONGTEXT NOT NULL COMMENT '(DC2Type:array)', hash VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1B2F01CDD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
@ -888,6 +882,26 @@ if (@$_POST['step2']) {
$connection->executeQuery("ALTER TABLE faq_category_translation ADD CONSTRAINT FK_5493B0FC2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES faq_category (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE faq_question ADD CONSTRAINT FK_4A55B05912469DE2 FOREIGN KEY (category_id) REFERENCES faq_category (id);");
$connection->executeQuery("CREATE TABLE ext_translations (id INT AUTO_INCREMENT NOT NULL, locale VARCHAR(8) NOT NULL, object_class VARCHAR(255) NOT NULL, field VARCHAR(32) NOT NULL, foreign_key VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX translations_lookup_idx (locale, object_class, foreign_key), UNIQUE INDEX lookup_unique_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE ext_log_entries (id INT AUTO_INCREMENT NOT NULL, action VARCHAR(8) NOT NULL, logged_at DATETIME NOT NULL, object_id VARCHAR(64) DEFAULT NULL, object_class VARCHAR(255) NOT NULL, version INT NOT NULL, data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)', username VARCHAR(255) DEFAULT NULL, INDEX log_class_lookup_idx (object_class), INDEX log_date_lookup_idx (logged_at), INDEX log_user_lookup_idx (username), INDEX log_version_lookup_idx (object_id, object_class, version), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE contact_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_3E770F302C2AC5D3 (translatable_id), UNIQUE INDEX contact_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE contact_category (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE notification__message (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, body LONGTEXT NOT NULL COMMENT '(DC2Type:json)', state INT NOT NULL, restart_count INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, started_at DATETIME DEFAULT NULL, completed_at DATETIME DEFAULT NULL, INDEX notification_message_state_idx (state), INDEX notification_message_created_at_idx (created_at), INDEX idx_state (state), INDEX idx_created_at (created_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
//CREATE TABLE sylius_settings (id INT AUTO_INCREMENT NOT NULL, schema_alias VARCHAR(255) NOT NULL, namespace VARCHAR(255) DEFAULT NULL, parameters LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)', UNIQUE INDEX UNIQ_1AFEFB2A894A31AD33E16B56 (schema_alias, namespace), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
$connection->executeQuery("ALTER TABLE contact_category_translation ADD CONSTRAINT FK_3E770F302C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES contact_category (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE fos_group CHANGE name name VARCHAR(180) NOT NULL;");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_4B019DDB5E237E06 ON fos_group (name);");
$connection->executeQuery("DROP INDEX UNIQ_8D93D649F85E0677 ON user;");
$connection->executeQuery("UPDATE user set created_at = NOW() where created_at is null");
$connection->executeQuery("UPDATE user set updated_at = NOW() where updated_at is null");
$connection->executeQuery("ALTER TABLE user ADD date_of_birth DATETIME DEFAULT NULL, ADD website VARCHAR(64) DEFAULT NULL, ADD biography VARCHAR(1000) DEFAULT NULL, ADD gender VARCHAR(1) DEFAULT NULL, ADD locale VARCHAR(8) DEFAULT NULL, ADD timezone VARCHAR(64) DEFAULT NULL, ADD facebook_uid VARCHAR(255) DEFAULT NULL, ADD facebook_name VARCHAR(255) DEFAULT NULL, ADD facebook_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD twitter_uid VARCHAR(255) DEFAULT NULL, ADD twitter_name VARCHAR(255) DEFAULT NULL, ADD twitter_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD gplus_uid VARCHAR(255) DEFAULT NULL, ADD gplus_name VARCHAR(255) DEFAULT NULL, ADD gplus_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD token VARCHAR(255) DEFAULT NULL, ADD two_step_code VARCHAR(255) DEFAULT NULL, CHANGE username_canonical username_canonical VARCHAR(180) NOT NULL, CHANGE lastname lastname VARCHAR(64) DEFAULT NULL, CHANGE firstname firstname VARCHAR(64) DEFAULT NULL, CHANGE phone phone VARCHAR(64) DEFAULT NULL, CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D64992FC23A8 ON user (username_canonical);");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D649C05FB297 ON user (confirmation_token);");
$connection->executeQuery("ALTER TABLE page__site CHANGE locale locale VARCHAR(7) DEFAULT NULL;");
$connection->executeQuery("ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE CASCADE;");
$sysPath = api_get_path(SYS_PATH);
finishInstallation(

@ -47,6 +47,14 @@ use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
* @ORM\Entity(repositoryClass="Chamilo\UserBundle\Entity\Repository\UserRepository")
*
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="username",
* column=@ORM\Column(
* name="username",
* type="string",
* length=100,
* unique=false
* )
* ),
* @ORM\AttributeOverride(name="email",
* column=@ORM\Column(
* name="email",
@ -96,27 +104,27 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
*
* @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true)
*/
protected $username;
//protected $username;
/**
* @var string
*
* @ORM\Column(name="username_canonical", type="string", length=100, nullable=false)
*/
protected $usernameCanonical;
//protected $usernameCanonical;
/**
* @var string
* @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false)
*/
protected $emailCanonical;
//protected $emailCanonical;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false)
*/
protected $email;
//protected $email;
/**
* @var boolean
@ -128,7 +136,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
* @var boolean
* @ORM\Column(name="enabled", type="boolean")
*/
protected $enabled;
//protected $enabled;
/**
* @var boolean
@ -159,21 +167,21 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
*
* @ORM\Column(name="lastname", type="string", length=60, nullable=true, unique=false)
*/
protected $lastname;
//protected $lastname;
/**
* @var string
*
* @ORM\Column(name="firstname", type="string", length=60, nullable=true, unique=false)
*/
protected $firstname;
//protected $firstname;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255, nullable=false, unique=false)
*/
protected $password;
//protected $password;
/**
* @var string
@ -201,7 +209,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
*
* @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false)
*/
protected $phone;
//protected $phone;
/**
* @var string
@ -322,29 +330,34 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
*/
private $hrDeptId;
/**
* @var AccessUrl
**/
protected $currentUrl;
/**
* @ORM\Column(type="string", length=255)
*/
protected $salt;
//protected $salt;
/**
* @var \DateTime
*
* @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false)
*/
protected $lastLogin;
//protected $lastLogin;
/**
* @var \DateTime
* @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false)
*/
protected $createdAt;
//protected $createdAt;
/**
* @var \DateTime
* @ORM\Column(name="updated_at", type="datetime", nullable=true, unique=false)
*/
protected $updatedAt;
//protected $updatedAt;
/**
* Random string sent to the user email address in order to verify it
@ -352,14 +365,14 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
* @var string
* @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true)
*/
protected $confirmationToken;
//protected $confirmationToken;
/**
* @var \DateTime
*
* @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false)
*/
protected $passwordRequestedAt;
//protected $passwordRequestedAt;
/**
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user")
@ -389,7 +402,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
/**
* @ORM\Column(type="array")
*/
protected $roles;
//protected $roles;
/**
* @var boolean
@ -492,7 +505,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
*/
public function __toString()
{
return $this->getUsername();
return $this->getCompleteName();
}
/**
@ -1506,8 +1519,8 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
public function removeExtraField(ExtraFieldValues $attribute)
{
//if ($this->hasExtraField($attribute)) {
//$this->extraFields->removeElement($attribute);
//$attribute->setUser($this);
//$this->extraFields->removeElement($attribute);
//$attribute->setUser($this);
//}
return $this;
@ -1597,7 +1610,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
public function isPasswordRequestNonExpired($ttl)
{
return $this->getPasswordRequestedAt() instanceof \DateTime &&
$this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
$this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
}
public function getUsername()
@ -1929,7 +1942,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
return $this->locale;
}
/**
/**
* @param string $timezone
*
* @return User
@ -2111,7 +2124,7 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
}
}
/**
/**
* Returns the user roles
*
* @return array The roles
@ -2472,6 +2485,35 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
return $this;
}
/**
* Sets the AccessUrl for the current user in memory
* @param AccessUrl $url
*
* @return $this
*/
public function setCurrentUrl(AccessUrl $url)
{
$urlList = $this->getPortals();
/** @var AccessUrlRelUser $item */
foreach ($urlList as $item) {
if ($item->getPortal()->getId() == $url->getId()) {
$this->currentUrl = $url;
break;
}
}
return $this;
}
/**
* @return AccessUrl
*/
public function getCurrentUrl()
{
return $this->currentUrl;
}
/**
* Get sessionAsGeneralCoach
* @return ArrayCollection

Loading…
Cancel
Save