Skip to content

Commit

Permalink
tweak(TB Profile Update) fix modlog modifiction_time on user model
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmhh committed Aug 14, 2024
1 parent 43b8061 commit 0ea17ef
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
19 changes: 19 additions & 0 deletions tests/tine20/Tinebase/Frontend/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,25 @@ public function testUpdateUserProfile()
$updatedProfileData = $updatedProfile['userProfile'];
$this->assertNotEquals('mustnotchange', $updatedProfileData['tel_home']);
$this->assertEquals('email@userprofile.set', $updatedProfileData['email_home']);


$user = Tinebase_User::getInstance()->getUserById(Tinebase_Core::getUser()->getId());
$user->seq = $user->seq - 1;
$userModLog = Tinebase_Timemachine_ModificationLog::getInstance()->getModificationsBySeq(Tinebase_Core::getTinebaseId(),
$user, $user->seq + 2);
$this->assertSame(1, $userModLog->count());
$userModLog = $userModLog->getFirstRecord();
/** @var Tinebase_Model_ModificationLog $userModLog */

$contact = Addressbook_Controller_Contact::getInstance()->get($user->contact_id);
$contact->seq = $contact->seq - 1;
$contactModLog = Tinebase_Timemachine_ModificationLog::getInstance()->getModificationsBySeq(Tinebase_Application::getInstance()->getApplicationByName(Addressbook_Config::APP_NAME)->getId(),
$contact, $contact->seq + 2);

$this->assertSame(1, $contactModLog->count());
$contactModLog = $contactModLog->getFirstRecord();
/** @var Tinebase_Model_ModificationLog $contactModLog */
$this->assertLessThan(3, abs($contactModLog->modification_time->getTimestamp() - $userModLog->modification_time->getTimestamp()));
}

/**
Expand Down
30 changes: 15 additions & 15 deletions tine20/Tinebase/Model/ModificationLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Timemachine
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Cornelius Weiss <c.weiss@metaways.de>
* @copyright Copyright (c) 2007-2017 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2007-2024 Metaways Infosystems GmbH (http://www.metaways.de)
*
*/

Expand All @@ -21,20 +21,20 @@
* @package Tinebase
* @subpackage Timemachine
*
* @property string id
* @property string instance_id
* @property int instance_seq
* @property string change_type
* @property string application_id
* @property string record_id
* @property string record_type
* @property string record_backend
* @property string modification_time
* @property string modification_account
* @property string modified_attribute
* @property string old_value
* @property string new_value
* @property string seq
* @property string $id
* @property string $instance_id
* @property int $instance_seq
* @property string $change_type
* @property string $application_id
* @property string $record_id
* @property string $record_type
* @property string $record_backend
* @property Tinebase_DateTime $modification_time
* @property string $modification_account
* @property string $modified_attribute
* @property string $old_value
* @property string $new_value
* @property string $seq
*/
class Tinebase_Model_ModificationLog extends Tinebase_Record_Abstract
{
Expand Down
1 change: 1 addition & 0 deletions tine20/Tinebase/User/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ public function updateContactInSqlBackend(Addressbook_Model_Contact $_contact)
$this->rowNameMapping['accountFirstName'] => $_contact->n_given,
$this->rowNameMapping['accountLastName'] => $_contact->n_family,
$this->rowNameMapping['accountEmailAddress'] => $_contact->email,
'last_modified_time' => new Zend_Db_Expr('NOW()'),
'seq' => $oldUser->seq + 1,
);

Expand Down

0 comments on commit 0ea17ef

Please sign in to comment.