Add FtpCredentials entity

This commit is contained in:
Nicolas Le Goff
2013-08-14 18:09:22 +02:00
parent 8790399214
commit 6a8312ca64
19 changed files with 591 additions and 536 deletions

View File

@@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Alchemy\Geonames\Exception\ExceptionInterface as GeonamesExceptionInterface;
use Entities\FtpCredential;
/**
*
@@ -246,58 +247,15 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
/**
*
* @var string
* @var FtpCredential
*/
protected $defaultftpdatas;
protected $ftpCredential;
/**
*
* @var string
*/
protected $mail_notifications;
/**
*
* @var string
*/
protected $activeftp;
/**
*
* @var string
*/
protected $ftp_address;
/**
*
* @var string
*/
protected $ftp_login;
/**
*
* @var string
*/
protected $ftp_password;
/**
*
* @var string
*/
protected $ftp_passif;
/**
*
* @var string
*/
protected $ftp_dir;
/**
*
* @var string
*/
protected $ftp_dir_prefix;
/**
*
* @var string
@@ -559,22 +517,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $usr_id;
}
/**
*
* @param int $datas
* @return User_Adapter
*/
public function set_defaultftpdatas($datas)
{
$sql = 'UPDATE usr SET defaultftpdatasent = :defaultftpdatas WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':defaultftpdatas' => $datas, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->defaultftpdatas = $datas;
return $this;
}
/**
*
* @param bollean $boolean
@@ -593,23 +535,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this;
}
/**
*
* @param boolean $boolean
* @return User_Adapter
*/
public function set_activeftp($boolean)
{
$value = $boolean ? '1' : '0';
$sql = 'UPDATE usr SET activeftp = :activeftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':activeftp' => $value, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->activeftp = $boolean;
return $this;
}
/**
*
* @param boolean $boolean
@@ -627,91 +552,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this;
}
/**
*
* @param string $address
* @return User_Adapter
*/
public function set_ftp_address($address)
{
$sql = 'UPDATE usr SET addrftp = :addrftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':addrftp' => $address, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_address = $address;
$this->delete_data_from_cache();
return $this;
}
/**
*
* @param string $login
* @return User_Adapter
*/
public function set_ftp_login($login)
{
$sql = 'UPDATE usr SET loginftp = :loginftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':loginftp' => $login, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_login = $login;
return $this;
}
/**
*
* @param type $password
* @return User_Adapter
*/
public function set_ftp_password($password)
{
$sql = 'UPDATE usr SET pwdFTP = :passwordftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':passwordftp' => $password, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_password = $password;
$this->delete_data_from_cache();
return $this;
}
public function set_ftp_passif($boolean)
{
$value = $boolean ? '1' : '0';
$sql = 'UPDATE usr SET passifftp = :passifftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':passifftp' => $value, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_passif = !!$boolean;
return $this;
}
public function set_ftp_dir($ftp_dir)
{
$sql = 'UPDATE usr SET destftp = :destftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':destftp' => $ftp_dir, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_dir = $ftp_dir;
$this->delete_data_from_cache();
return $this;
}
public function set_ftp_dir_prefix($ftp_dir_prefix)
{
$sql = 'UPDATE usr SET prefixFTPfolder = :prefixftp WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':prefixftp' => $ftp_dir_prefix, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ftp_dir_prefix = $ftp_dir_prefix;
return $this;
}
public function set_firstname($firstname)
{
$sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id';
@@ -891,18 +731,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->set_ftp_address('')
->set_activeftp(false)
$this
->set_city('')
->set_company('')
->set_email(null)
->set_fax('')
->set_firstname('')
->set_ftp_dir('')
->set_ftp_dir_prefix('')
->set_ftp_login('')
->set_ftp_passif('')
->set_ftp_password('')
->set_gender('')
->set_geonameid('')
->set_job('')
@@ -913,11 +747,28 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
->set_zip('')
->set_tel('');
$this->ftpCredential = new FtpCredential();
$this->ftpCredential->setUsrId($this->get_id());
$this->app['EM']->persist($this->ftpCredential);
$this->app['EM']->flush();
$this->delete_data_from_cache();
return $this;
}
public function getFtpCredential()
{
if (null === $this->ftpCredential) {
/* @var $ftpCredential \Entities\FtpCredential */
$this->ftpCredential = $this->app['EM']->getRepository('Entities\FtpCredential')->findOneBy(array(
'usrId' => $this->get_id()
));
}
return $this->ftpCredential;
}
public function is_template()
{
return $this->is_template;
@@ -1023,52 +874,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return;
}
public function get_defaultftpdatas()
{
return $this->defaultftpdatas;
}
public function get_mail_notifications()
{
return $this->mail_notifications;
}
public function get_activeftp()
{
return $this->activeftp;
}
public function get_ftp_address()
{
return $this->ftp_address;
}
public function get_ftp_login()
{
return $this->ftp_login;
}
public function get_ftp_password()
{
return $this->ftp_password;
}
public function get_ftp_passif()
{
return $this->ftp_passif;
}
public function get_ftp_dir()
{
return $this->ftp_dir;
}
public function get_ftp_dir_prefix()
{
return $this->ftp_dir_prefix;
}
/**
*
* @param <type> $id
@@ -1079,8 +889,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'SELECT usr_id, ldap_created, create_db, usr_login, usr_password, usr_nom, activite,
usr_prenom, usr_sexe as gender, usr_mail, adresse, usr_creationdate, usr_modificationdate,
ville, cpostal, tel, fax, fonction, societe, geonameid, lastModel, invite,
defaultftpdatasent, mail_notifications, activeftp, addrftp, loginftp,
pwdFTP, passifftp, destftp, prefixFTPfolder, mail_locked, model_of, locale
mail_notifications, mail_locked, model_of, locale
FROM usr WHERE usr_id= :id ';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
@@ -1100,15 +909,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$this->ldap_created = $row['ldap_created'];
$this->defaultftpdatas = $row['defaultftpdatasent'];
$this->mail_notifications = $row['mail_notifications'];
$this->activeftp = $row['activeftp'];
$this->ftp_address = $row['addrftp'];
$this->ftp_login = $row['loginftp'];
$this->ftp_password = $row['pwdFTP'];
$this->ftp_passif = $row['passifftp'];
$this->ftp_dir = $row['destftp'];
$this->ftp_dir_prefix = $row['prefixFTPfolder'];
$this->mail_locked = !!$row['mail_locked'];
@@ -1725,6 +1526,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$usr_id = $conn->lastInsertId();
$ftpCredential = new FtpCredential();
$ftpCredential->setUsrId($usr_id);
$app['EM']->persist($ftpCredential);
$app['EM']->flush();
if ($invite) {
$sql = 'UPDATE usr SET usr_login = "invite' . $usr_id . '" WHERE usr_id="' . $usr_id . '"';
$stmt = $conn->prepare($sql);

View File

@@ -34,24 +34,8 @@ interface User_Interface
public function get_country();
public function set_defaultftpdatas($datas);
public function set_mail_notifications($boolean);
public function set_activeftp($boolean);
public function set_ftp_address($address);
public function set_ftp_login($login);
public function set_ftp_password($password);
public function set_ftp_passif($boolean);
public function set_ftp_dir($ftp_dir);
public function set_ftp_dir_prefix($ftp_dir_prefix);
public function set_firstname($firstname);
public function set_lastname($lastname);
@@ -78,24 +62,8 @@ interface User_Interface
public function delete();
public function get_defaultftpdatas();
public function get_mail_notifications();
public function get_activeftp();
public function get_ftp_address();
public function get_ftp_login();
public function get_ftp_password();
public function get_ftp_passif();
public function get_ftp_dir();
public function get_ftp_dir_prefix();
public function load($id);
public function set_last_template(User_Interface $template);