mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Fix #786 Update baskets transfer
This commit is contained in:
@@ -88,6 +88,7 @@ class Session_Authentication_Guest implements Session_Authentication_Interface
|
|||||||
*/
|
*/
|
||||||
public function postlog()
|
public function postlog()
|
||||||
{
|
{
|
||||||
|
\Session_Handler::set_cookie('invite-usr_id', $this->user->get_id(), 0, true);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -186,22 +186,22 @@ class Session_Handler
|
|||||||
|
|
||||||
public function isset_postlog()
|
public function isset_postlog()
|
||||||
{
|
{
|
||||||
return $this->storage()->has('postlog');
|
return self::isset_cookie('postlog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_postlog($boolean)
|
public function set_postlog()
|
||||||
{
|
{
|
||||||
return $this->storage()->set('postlog', $boolean);
|
return self::set_cookie('postlog', '1', 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_postlog()
|
public function get_postlog()
|
||||||
{
|
{
|
||||||
return $this->storage()->get('postlog');
|
return self::get_cookie('postlog', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_postlog()
|
public function delete_postlog()
|
||||||
{
|
{
|
||||||
return $this->storage()->remove('postlog');
|
return self::set_cookie('postlog', '', -5, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,6 +403,7 @@ class Session_Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->set_usr_lastconn($conn, $user->get_id());
|
$this->set_usr_lastconn($conn, $user->get_id());
|
||||||
|
$this->transfer_baskets($user);
|
||||||
$this->delete_postlog();
|
$this->delete_postlog();
|
||||||
|
|
||||||
$auth->postlog();
|
$auth->postlog();
|
||||||
@@ -412,61 +413,28 @@ class Session_Handler
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function transfer_baskets()
|
protected function transfer_baskets(\User_Adapter $user)
|
||||||
{
|
{
|
||||||
$conn = $this->appbox->get_connection();
|
$Core = \bootstrap::getCore();
|
||||||
$transferBasks = ($this->isset_postlog() && $this->get_postlog() === true);
|
|
||||||
|
$transferBasks = ($this->isset_postlog() && $this->get_postlog() == '1');
|
||||||
|
if ($transferBasks && $user->is_guest() == false && Session_Handler::isset_cookie('invite-usr_id')) {
|
||||||
|
|
||||||
if ( ! $transferBasks)
|
|
||||||
self::set_cookie('last_act', '', -400000, true);
|
|
||||||
if ($transferBasks && Session_Handler::isset_cookie('invite-usr_id')) {
|
|
||||||
$basks = array();
|
|
||||||
$oldusr = self::get_cookie('invite-usr_id');
|
$oldusr = self::get_cookie('invite-usr_id');
|
||||||
|
|
||||||
if ($oldusr == $this->get_usr_id()) {
|
if ($oldusr == $user->get_id()) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT sselcont_id, s.ssel_id
|
$repo = $Core['EM']->getRepository('Entities\Basket');
|
||||||
FROM sselcont c, ssel s
|
$baskets = $repo->findBy(array('usr_id' => $oldusr));
|
||||||
WHERE s.usr_id = :usr_id
|
|
||||||
AND s.ssel_id = c.ssel_id';
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
foreach ($baskets as $basket) {
|
||||||
$stmt->execute(array(':usr_id' => $this->get_usr_id()));
|
$basket->setUsrId($user->get_id());
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$Core['EM']->persist($basket);
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = 'UPDATE ssel set usr_id = :usr_id WHERE ssel_id = :ssel_id AND usr_id = :old_usr_id';
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
$stmt->execute(array(':usr_id' => $this->get_usr_id(), ':ssel_id' => $row['ssel_id'], ':old_usr_id' => $oldusr));
|
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM ssel WHERE usr_id = :old_usr_id';
|
$Core['EM']->flush();
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':old_usr_id' => $oldusr));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = 'UPDATE dsel SET usr_id = :usr_id WHERE usr_id = :old_usr_id';
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':usr_id' => $this->get_usr_id(), ':old_usr_id' => $oldusr));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM usr WHERE usr_id = :old_usr_id';
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':old_usr_id' => $oldusr));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
$sql = 'DELETE FROM basusr WHERE usr_id = :old_usr_id';
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':old_usr_id' => $oldusr));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
$sql = 'DELETE FROM sbasusr WHERE usr_id = :old_usr_id';
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute(array(':old_usr_id' => $oldusr));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -171,50 +171,6 @@ class Session_HandlerTest extends PhraseanetPHPUnitAbstract
|
|||||||
$this->assertNull($this->object->get_ses_id());
|
$this->assertNull($this->object->get_ses_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIsset_postlog().
|
|
||||||
*/
|
|
||||||
public function testIsset_postlog()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_postlog().
|
|
||||||
*/
|
|
||||||
public function testSet_postlog()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testGet_postlog().
|
|
||||||
*/
|
|
||||||
public function testGet_postlog()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testDelete_postlog().
|
|
||||||
*/
|
|
||||||
public function testDelete_postlog()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSet_session_prefs()
|
public function testSet_session_prefs()
|
||||||
{
|
{
|
||||||
$datas = array('bla' => 1, 2 => 'boum');
|
$datas = array('bla' => 1, 2 => 'boum');
|
||||||
|
@@ -30,7 +30,7 @@ $parm = $request->get_parms('lng', 'error', 'confirm', 'badlog', 'postlog', 'usr
|
|||||||
if ($parm['postlog']) {
|
if ($parm['postlog']) {
|
||||||
$session->set_postlog(true);
|
$session->set_postlog(true);
|
||||||
|
|
||||||
return phrasea::redirect("/login/index.php?redirect=" . $parm['redirect']);
|
return phrasea::redirect("/login/logout.php?redirect=" . $parm['redirect']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $session->isset_postlog() && $session->is_authenticated() && $parm['error'] != 'no-connection') {
|
if ( ! $session->isset_postlog() && $session->is_authenticated() && $parm['error'] != 'no-connection') {
|
||||||
|
Reference in New Issue
Block a user