mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Add User Entity
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
protected static $number = '3.9.0.a1';
|
||||
protected static $number = '3.9.0.a2';
|
||||
protected static $name = 'Diplodocus';
|
||||
|
||||
public static function getNumber()
|
||||
|
795
lib/Doctrine/Entities/User.php
Normal file
795
lib/Doctrine/Entities/User.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="Users",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="email_unique",columns={"email"}),
|
||||
* @ORM\UniqueConstraint(name="login_unique",columns={"login"})
|
||||
* },
|
||||
* indexes={
|
||||
* @ORM\index(name="login", columns={"login"}),
|
||||
* @ORM\index(name="mail", columns={"email"}),
|
||||
* @ORM\index(name="model_of", columns={"model_of"}),
|
||||
* @ORM\index(name="salted_password", columns={"salted_password"}),
|
||||
* @ORM\index(name="admin", columns={"admin"}),
|
||||
* @ORM\index(name="guest", columns={"guest"})
|
||||
* }
|
||||
* )
|
||||
* @ORM\Entity(repositoryClass="Repositories\UserRepository")
|
||||
*/
|
||||
class User
|
||||
{
|
||||
const GENDER_MR = 'mr';
|
||||
const GENDER_MRS = 'mrs';
|
||||
const GENDER_MISS = 'miss';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $login;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128, nullable=true)
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
*/
|
||||
private $nonce;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="salted_password")
|
||||
*/
|
||||
private $saltedPassword = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64, name="first_name")
|
||||
*/
|
||||
private $firstName = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64, name="last_name")
|
||||
*/
|
||||
private $lastName = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=8, nullable=true)
|
||||
*/
|
||||
private $gender;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private $address = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*/
|
||||
private $city = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*/
|
||||
private $country = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32, name="zip_code")
|
||||
*/
|
||||
private $zipCode = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", name="geoname_id", nullable=true)
|
||||
*/
|
||||
private $geonameId;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=8, nullable=true)
|
||||
*/
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $timezone = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $job = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=256)
|
||||
*/
|
||||
private $activity = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64)
|
||||
*/
|
||||
private $company = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
private $phone = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
private $fax= '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $admin = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $guest = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="mail_notifications")
|
||||
*/
|
||||
private $mailNotificationsActivated = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="request_notifications")
|
||||
*/
|
||||
private $requestNotificationsActivated = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="ldap_created")
|
||||
*/
|
||||
private $ldapCreated = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", name="model_of", nullable=true)
|
||||
*/
|
||||
private $modelOf;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64, name="last_model", nullable=true)
|
||||
*/
|
||||
private $lastModel;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", name="push_list")
|
||||
*/
|
||||
private $pushList = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="can_change_profil")
|
||||
*/
|
||||
private $canChangeProfil = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="can_change_ftp_profil")
|
||||
*/
|
||||
private $canChangeFtpProfil = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", name="last_connection", nullable=true)
|
||||
*/
|
||||
private $lastConnection;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="mail_locked")
|
||||
*/
|
||||
private $mailLocked = false;
|
||||
|
||||
/**
|
||||
* @Gedmo\Timestampable(on="create")
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $created;
|
||||
|
||||
/**
|
||||
* @Gedmo\Timestampable(on="update")
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $updated;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNonce()
|
||||
{
|
||||
return $this->nonce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $nonce
|
||||
*/
|
||||
public function setNonce($nonce)
|
||||
{
|
||||
$this->nonce = $nonce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSaltedPassword()
|
||||
{
|
||||
return $this->saltedPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $saltedPassword
|
||||
*/
|
||||
public function setSaltedPassword($saltedPassword)
|
||||
{
|
||||
$this->saltedPassword = (Boolean) $saltedPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName()
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $firstName
|
||||
*/
|
||||
public function setFirstName($firstName)
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName()
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $lastName
|
||||
*/
|
||||
public function setLastName($lastName)
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGender()
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $gender
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setGender($gender)
|
||||
{
|
||||
if (null !== $gender && !in_array($gender, array(
|
||||
self::GENDER_MISS,
|
||||
self::GENDER_MR,
|
||||
self::GENDER_MRS
|
||||
))) {
|
||||
throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender));
|
||||
}
|
||||
|
||||
$this->gender = $gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $city
|
||||
*/
|
||||
public function setCity($city)
|
||||
{
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $country
|
||||
*/
|
||||
public function setCountry($country)
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getZipCode()
|
||||
{
|
||||
return $this->zipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zipCode
|
||||
*/
|
||||
public function setZipCode($zipCode)
|
||||
{
|
||||
$this->zipCode = $zipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getGeonameId()
|
||||
{
|
||||
return $this->geonameId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $geonameId
|
||||
*/
|
||||
public function setGeonameId($geonameId)
|
||||
{
|
||||
if (null !== $geonameId && $geonameId < 1) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid geonameid %s.', $geonameId));
|
||||
}
|
||||
|
||||
$this->geonameId = $geonameId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
if (null !== $locale && !array_key_exists($locale, Application::getAvailableLanguages())) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid locale %s.', $locale));
|
||||
}
|
||||
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTimezone()
|
||||
{
|
||||
return $this->timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $timezone
|
||||
*/
|
||||
public function setTimezone($timezone)
|
||||
{
|
||||
$this->timezone = $timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJob()
|
||||
{
|
||||
return $this->job;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $job
|
||||
*/
|
||||
public function setJob($job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getActivity()
|
||||
{
|
||||
return $this->activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $activity
|
||||
*/
|
||||
public function setActivity($activity)
|
||||
{
|
||||
$this->activity = $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $company
|
||||
*/
|
||||
public function setCompany($company)
|
||||
{
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone()
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phone
|
||||
*/
|
||||
public function setPhone($phone)
|
||||
{
|
||||
$this->phone = $phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFax()
|
||||
{
|
||||
return $this->fax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fax
|
||||
*/
|
||||
public function setFax($fax)
|
||||
{
|
||||
$this->fax = $fax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $admin
|
||||
*/
|
||||
public function setAdmin($admin)
|
||||
{
|
||||
$this->admin = (Boolean) $admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isGuest()
|
||||
{
|
||||
return $this->guest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $guest
|
||||
*/
|
||||
public function setGuest($guest)
|
||||
{
|
||||
$this->guest = (Boolean) $guest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasMailNotificationsActivated()
|
||||
{
|
||||
return $this->mailNotificationsActivated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $mailNotifications
|
||||
*/
|
||||
public function setMailNotificationsActivated($mailNotifications)
|
||||
{
|
||||
$this->mailNotificationsActivated = (Boolean) $mailNotifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasRequestNotificationsActivated()
|
||||
{
|
||||
return $this->requestNotificationsActivated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $requestNotifications
|
||||
*/
|
||||
public function setRequestNotificationsActivated($requestNotifications)
|
||||
{
|
||||
$this->requestNotificationsActivated = (Boolean) $requestNotifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasLdapCreated()
|
||||
{
|
||||
return $this->ldapCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $ldapCreated
|
||||
*/
|
||||
public function setLdapCreated($ldapCreated)
|
||||
{
|
||||
$this->ldapCreated = (Boolean) $ldapCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getModelOf()
|
||||
{
|
||||
return $this->modelOf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $modelOf
|
||||
*/
|
||||
public function setModelOf($modelOf)
|
||||
{
|
||||
$this->modelOf = $modelOf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModel()
|
||||
{
|
||||
return $this->lastModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lastModel
|
||||
*/
|
||||
public function setLastModel($lastModel)
|
||||
{
|
||||
$this->lastModel = $lastModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPushList()
|
||||
{
|
||||
return $this->pushList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pushList
|
||||
*/
|
||||
public function setPushList($pushList)
|
||||
{
|
||||
$this->pushList = $pushList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function canChangeProfil()
|
||||
{
|
||||
return $this->canChangeProfil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $canChangeProfil
|
||||
*/
|
||||
public function setCanChangeProfil($canChangeProfil)
|
||||
{
|
||||
$this->canChangeProfil = (Boolean) $canChangeProfil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function canChangeFtpProfil()
|
||||
{
|
||||
return $this->canChangeFtpProfil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $canChangeFtpProfil
|
||||
*/
|
||||
public function setCanChangeFtpProfil($canChangeFtpProfil)
|
||||
{
|
||||
$this->canChangeFtpProfil = (Boolean) $canChangeFtpProfil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getLastConnection()
|
||||
{
|
||||
return $this->lastConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $lastConnection
|
||||
*/
|
||||
public function setLastConnection(\DateTime $lastConnection)
|
||||
{
|
||||
$this->lastConnection = $lastConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMailLocked()
|
||||
{
|
||||
return $this->mailLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $mailLocked
|
||||
*/
|
||||
public function setMailLocked($mailLocked)
|
||||
{
|
||||
$this->mailLocked = (Boolean) $mailLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getUpdated()
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Datetime $created
|
||||
*/
|
||||
public function setCreated(\Datetime $created)
|
||||
{
|
||||
$this->created = $created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Datetime $updated
|
||||
*/
|
||||
public function setUpdated(\Datetime $updated)
|
||||
{
|
||||
|
||||
$this->updated = $updated;
|
||||
}
|
||||
}
|
24
lib/Doctrine/Repositories/UserRepository.php
Normal file
24
lib/Doctrine/Repositories/UserRepository.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class UserRepository extends EntityRepository
|
||||
{
|
||||
}
|
138
lib/classes/patch/3902.php
Normal file
138
lib/classes/patch/3902.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Entities\User;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
|
||||
class patch_3902 implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0.a2';
|
||||
|
||||
/** @var array */
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT * FROM usr';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n = 0;
|
||||
$em = $app['EM'];
|
||||
$em->getEventManager()->removeEventSubscriber(new TimestampableListener());
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$user = new User();
|
||||
$user->setActivity($row['activite']);
|
||||
$user->setAddress($row['adresse']);
|
||||
$user->setAdmin(!!$row['create_db']);
|
||||
$user->setCanChangeFtpProfil(!!$row['canchgftpprofil']);
|
||||
$user->setCanChangeProfil(!!$row['canchgprofil']);
|
||||
$user->setCity($row['ville']);
|
||||
$user->setCompany($row['societe']);
|
||||
$user->setCountry((string) $row['pays']);
|
||||
$user->setEmail($row['usr_mail']);
|
||||
$user->setFax($row['fax']);
|
||||
$user->setFirstName($row['usr_prenom']);
|
||||
if ($row['geonameid'] > 0) {
|
||||
$user->setGeonameId($row['geonameid']);
|
||||
}
|
||||
$user->setGuest(!!$row['invite']);
|
||||
$user->setJob($row['fonction']);
|
||||
$user->setLastConnection(new \DateTime($row['last_conn']));
|
||||
$user->setLastModel($row['lastModel']);
|
||||
$user->setLastName($row['usr_nom']);
|
||||
$user->setLdapCreated(!!$row['ldap_created']);
|
||||
try {
|
||||
$user->setLocale($row['locale']);
|
||||
} catch (\InvalidArgumentException $e ) {
|
||||
|
||||
}
|
||||
$user->setLogin($row['usr_login']);
|
||||
$user->setMailLocked(!!$row['mail_locked']);
|
||||
$user->setMailNotificationsActivated(!!$row['mail_notifications']);
|
||||
$user->setModelOf($row['model_of']);
|
||||
$user->setNonce($row['nonce']);
|
||||
$user->setPassword($row['usr_password']);
|
||||
$user->setPushList($row['push_list']);
|
||||
$user->setRequestNotificationsActivated(!!$row['request_notifications']);
|
||||
$user->setSaltedPassword(!!$row['salted_password']);
|
||||
|
||||
switch ($row['usr_sexe'])
|
||||
{
|
||||
case 0:
|
||||
$gender = User::GENDER_MISS;
|
||||
break;
|
||||
case 1:
|
||||
$gender = User::GENDER_MRS;
|
||||
break;
|
||||
case 2:
|
||||
$gender = User::GENDER_MR;
|
||||
break;
|
||||
default:
|
||||
$gender = null;
|
||||
}
|
||||
|
||||
$user->setGender($gender);
|
||||
$user->setPhone($row['tel']);
|
||||
$user->setTimezone($row['timezone']);
|
||||
$user->setZipCode($row['cpostal']);
|
||||
$user->setCreated(new \DateTime($row['usr_creationdate']));
|
||||
$user->setupdated(new \DateTime($row['usr_modificationdate']));
|
||||
|
||||
$em->persist($user);
|
||||
|
||||
$n++;
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$em->getEventManager()->addEventSubscriber(new TimestampableListener());
|
||||
}
|
||||
}
|
103
tests/Doctrine/Tests/Entities/UserTest.php
Normal file
103
tests/Doctrine/Tests/Entities/UserTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Tests\Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Entities\User;
|
||||
|
||||
class UserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->user = new User();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider genderProvider
|
||||
*/
|
||||
public function testSetGender($gender)
|
||||
{
|
||||
$this->user->setGender($gender);
|
||||
$this->assertEquals($this->user->getGender(), $gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidGenderProvider
|
||||
*/
|
||||
public function testInvalidSetGender($gender)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Alchemy\Phrasea\Exception\InvalidArgumentException',
|
||||
'Invalid gender '. (string) $gender . '.'
|
||||
);
|
||||
$this->user->setGender($gender);
|
||||
}
|
||||
|
||||
public function testSetLocale()
|
||||
{
|
||||
foreach(array_keys(Application::getAvailableLanguages()) as $locale) {
|
||||
$this->user->setLocale($locale);
|
||||
$this->assertEquals($this->user->getLocale(), $locale);
|
||||
}
|
||||
|
||||
$this->user->setLocale(null);
|
||||
$this->assertEquals($this->user->getLocale(), null);
|
||||
}
|
||||
|
||||
public function testInvalidLocale()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Alchemy\Phrasea\Exception\InvalidArgumentException',
|
||||
'Invalid locale invalid_local.'
|
||||
);
|
||||
$this->user->setLocale('invalid_local');
|
||||
}
|
||||
|
||||
public function testSetGeonameId()
|
||||
{
|
||||
$this->user->setGeonameId(1234);
|
||||
$this->assertEquals($this->user->getGeonameId(), 1234);
|
||||
$this->user->setGeonameId(null);
|
||||
$this->assertEquals($this->user->getGeonameId(), null);
|
||||
}
|
||||
|
||||
public function testInvalidGeonamedId()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Alchemy\Phrasea\Exception\InvalidArgumentException',
|
||||
'Invalid geonameid -1.'
|
||||
);
|
||||
$this->user->setGeonameId(-1);
|
||||
}
|
||||
|
||||
public function genderProvider()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array(User::GENDER_MISS),
|
||||
array(User::GENDER_MR),
|
||||
array(User::GENDER_MR),
|
||||
);
|
||||
}
|
||||
|
||||
public function invalidGenderProvider()
|
||||
{
|
||||
return array(
|
||||
array(false),
|
||||
array(''),
|
||||
array(1),
|
||||
array('madame')
|
||||
);
|
||||
}
|
||||
}
|
@@ -2,4 +2,5 @@
|
||||
|
||||
$loader = require __DIR__ . '/../lib/autoload.php';
|
||||
$loader->add('Alchemy\\Tests', __DIR__);
|
||||
$loader->add('Doctrine\\Tests', __DIR__);
|
||||
$loader->add('', __DIR__ . "/classes");
|
||||
|
Reference in New Issue
Block a user