When creating a new account the user must choose her/his language.
It is used to show the data from the database in the correct language
which was chosen by the user.
CREATE TABLE sf_guard_group_permission (group_id BIGINT, permission_id BIGINT, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(group_id, permission_id));
CREATE TABLE sf_guard_permission (id BIGSERIAL, name VARCHAR(255) UNIQUE, description VARCHAR(1000), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(id));
CREATE TABLE sf_guard_remember_key (id BIGSERIAL, user_id BIGINT, remember_key VARCHAR(32), ip_address VARCHAR(50), created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(id));
-CREATE TABLE sf_guard_user (id BIGSERIAL, first_name VARCHAR(255), last_name VARCHAR(255), email_address VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(128) NOT NULL UNIQUE, algorithm VARCHAR(128) DEFAULT 'sha1' NOT NULL, salt VARCHAR(128), password VARCHAR(128), is_active BOOLEAN DEFAULT 'true', is_super_admin BOOLEAN DEFAULT 'false', last_login TIMESTAMP, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(id));
+CREATE TABLE sf_guard_user (id BIGSERIAL, first_name VARCHAR(255), last_name VARCHAR(255), email_address VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(128) NOT NULL UNIQUE, algorithm VARCHAR(128) DEFAULT 'sha1' NOT NULL, salt VARCHAR(128), password VARCHAR(128), is_active BOOLEAN DEFAULT 'true', is_super_admin BOOLEAN DEFAULT 'false', last_login TIMESTAMP, language_id BIGINT, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(id));
CREATE TABLE sf_guard_user_group (user_id BIGINT, group_id BIGINT, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(user_id, group_id));
CREATE TABLE sf_guard_user_permission (user_id BIGINT, permission_id BIGINT, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, PRIMARY KEY(user_id, permission_id));
CREATE INDEX is_active_idx ON sf_guard_user (is_active);
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_permission_id_sf_guard_permission_id FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE sf_guard_remember_key ADD CONSTRAINT sf_guard_remember_key_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
+ALTER TABLE sf_guard_user ADD CONSTRAINT sf_guard_user_language_id_language_id FOREIGN KEY (language_id) REFERENCES language(id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE sf_guard_user_permission ADD CONSTRAINT sf_guard_user_permission_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
'is_active' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
'is_super_admin' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
'last_login' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
+ 'language_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Language'), 'add_empty' => true)),
'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
'groups_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup')),
'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
'is_super_admin' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
'last_login' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
+ 'language_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Language'), 'column' => 'id')),
'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
'groups_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup', 'required' => false)),
'is_active' => 'Boolean',
'is_super_admin' => 'Boolean',
'last_login' => 'Date',
+ 'language_id' => 'ForeignKey',
'created_at' => 'Date',
'updated_at' => 'Date',
'groups_list' => 'ManyKey',
'is_active' => new sfWidgetFormInputCheckbox(),
'is_super_admin' => new sfWidgetFormInputCheckbox(),
'last_login' => new sfWidgetFormDateTime(),
+ 'language_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Language'), 'add_empty' => true)),
'created_at' => new sfWidgetFormDateTime(),
'updated_at' => new sfWidgetFormDateTime(),
'groups_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup')),
'is_active' => new sfValidatorBoolean(array('required' => false)),
'is_super_admin' => new sfValidatorBoolean(array('required' => false)),
'last_login' => new sfValidatorDateTime(array('required' => false)),
+ 'language_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Language'), 'required' => false)),
'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(),
'groups_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup', 'required' => false)),
*
* @property string $language_name
* @property string $code
+ * @property Doctrine_Collection $sfGuardUser
* @property Doctrine_Collection $CompanyDescription
* @property Doctrine_Collection $CompanyCategoryDescription
* @property Doctrine_Collection $GeneralCategoryDescription
*
* @method string getLanguageName() Returns the current record's "language_name" value
* @method string getCode() Returns the current record's "code" value
+ * @method Doctrine_Collection getSfGuardUser() Returns the current record's "sfGuardUser" collection
* @method Doctrine_Collection getCompanyDescription() Returns the current record's "CompanyDescription" collection
* @method Doctrine_Collection getCompanyCategoryDescription() Returns the current record's "CompanyCategoryDescription" collection
* @method Doctrine_Collection getGeneralCategoryDescription() Returns the current record's "GeneralCategoryDescription" collection
* @method Doctrine_Collection getAdDescription() Returns the current record's "AdDescription" collection
* @method Language setLanguageName() Sets the current record's "language_name" value
* @method Language setCode() Sets the current record's "code" value
+ * @method Language setSfGuardUser() Sets the current record's "sfGuardUser" collection
* @method Language setCompanyDescription() Sets the current record's "CompanyDescription" collection
* @method Language setCompanyCategoryDescription() Sets the current record's "CompanyCategoryDescription" collection
* @method Language setGeneralCategoryDescription() Sets the current record's "GeneralCategoryDescription" collection
public function setUp()
{
parent::setUp();
+ $this->hasMany('sfGuardUser', array(
+ 'local' => 'id',
+ 'foreign' => 'language_id'));
+
$this->hasMany('CompanyDescription', array(
'local' => 'id',
'foreign' => 'language_id'));
* @property boolean $is_active
* @property boolean $is_super_admin
* @property timestamp $last_login
+ * @property integer $language_id
* @property Doctrine_Collection $Groups
* @property Doctrine_Collection $Permissions
+ * @property Language $Language
* @property Doctrine_Collection $sfGuardUserPermission
* @property Doctrine_Collection $sfGuardUserGroup
* @property sfGuardRememberKey $RememberKeys
* @method boolean getIsActive() Returns the current record's "is_active" value
* @method boolean getIsSuperAdmin() Returns the current record's "is_super_admin" value
* @method timestamp getLastLogin() Returns the current record's "last_login" value
+ * @method integer getLanguageId() Returns the current record's "language_id" value
* @method Doctrine_Collection getGroups() Returns the current record's "Groups" collection
* @method Doctrine_Collection getPermissions() Returns the current record's "Permissions" collection
+ * @method Language getLanguage() Returns the current record's "Language" value
* @method Doctrine_Collection getSfGuardUserPermission() Returns the current record's "sfGuardUserPermission" collection
* @method Doctrine_Collection getSfGuardUserGroup() Returns the current record's "sfGuardUserGroup" collection
* @method sfGuardRememberKey getRememberKeys() Returns the current record's "RememberKeys" value
* @method sfGuardUser setIsActive() Sets the current record's "is_active" value
* @method sfGuardUser setIsSuperAdmin() Sets the current record's "is_super_admin" value
* @method sfGuardUser setLastLogin() Sets the current record's "last_login" value
+ * @method sfGuardUser setLanguageId() Sets the current record's "language_id" value
* @method sfGuardUser setGroups() Sets the current record's "Groups" collection
* @method sfGuardUser setPermissions() Sets the current record's "Permissions" collection
+ * @method sfGuardUser setLanguage() Sets the current record's "Language" value
* @method sfGuardUser setSfGuardUserPermission() Sets the current record's "sfGuardUserPermission" collection
* @method sfGuardUser setSfGuardUserGroup() Sets the current record's "sfGuardUserGroup" collection
* @method sfGuardUser setRememberKeys() Sets the current record's "RememberKeys" value
$this->hasColumn('last_login', 'timestamp', null, array(
'type' => 'timestamp',
));
+ $this->hasColumn('language_id', 'integer', null, array(
+ 'type' => 'integer',
+ ));
$this->index('is_active_idx', array(
'local' => 'user_id',
'foreign' => 'permission_id'));
+ $this->hasOne('Language', array(
+ 'local' => 'language_id',
+ 'foreign' => 'id',
+ 'onDelete' => 'SET NULL'));
+
$this->hasMany('sfGuardUserPermission', array(
'local' => 'id',
'foreign' => 'user_id'));
default: false
last_login:
type: timestamp
+ language_id:
+ type: integer
indexes:
is_active_idx:
fields: [is_active]
foreign: permission_id
refClass: sfGuardUserPermission
foreignAlias: Users
+ Language:
+ class: Language
+ local: language_id
+ foreign: id
+ onDelete: SET NULL
sfGuardUserPermission:
options:
type: one
foreignType: one
foreignAlias: ForgotPassword
- onDelete: CASCADE
\ No newline at end of file
+ onDelete: CASCADE
sfGuardUser:
ADMIN:
+ Language: Spanish
first_name: Gustavo
last_name: Martin
email_address: gu.martinm@gmail.com
is_super_admin: true
is_active: true
DIA:
+ Language: Spanish
first_name: Gustavo
last_name: Empresa
email_address: gu.empresadia@gmail.com
is_super_admin: false
is_active: true
CARREFOUR:
+ Language: Spanish
first_name: Gustavo
last_name: Empresa
email_address: gu.empresacarrefour@gmail.com
is_super_admin: false
is_active: true
MOBILEADVERTISING:
+ Language: Spanish
first_name: Gustavo
last_name: Empresa
email_address: gu.empresamobile@gmail.com
is_super_admin: false
is_active: true
NORMAL_USER:
+ Language: Spanish
first_name: Gustavo
last_name: Usuario
email_address: gu.usuario@gmail.com