From 8db3eea0b73e540e6454c58f8d396ec81d08b4f3 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Tue, 12 Mar 2024 12:05:20 +0000 Subject: [PATCH] :ambulance: Fix(Snapshots) - issues resolved when creating from template Resolves issue when applying and creating from template. --- plugins/personal/generic/class_user.inc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index f32e0f140..e633565c3 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -273,14 +273,15 @@ class user extends simplePlugin $filename = './plugins/users/images/default.jpg'; $fd = fopen($filename, 'rb'); $this->attributesAccess['jpegPhoto']->setPlaceholder(fread($fd, filesize($filename))); - $this->was_locked = $this->attributesAccess['userPassword']->isLocked(); - // Verification is snapshot is enabled and automatic. - // Note : string values are stored in that array. - if (isset($config->current['ENABLEAUTOMATICSNAPSHOTS']) && isset($config->current['ENABLESNAPSHOTS'])) { - if (strtolower($config->current['ENABLEAUTOMATICSNAPSHOTS']) === 'true' && strtolower($config->current['ENABLESNAPSHOTS']) === 'true') { - $this->generateAutomaticSnapshot(); + // Do not apply automatic snap on templates nor if the DN is not yet processed (new creation from template) + if ($this->is_template !== TRUE && $this->dn !== 'new') { + // Verification is snapshot is enabled and automatic. + if (isset($config->current['ENABLEAUTOMATICSNAPSHOTS']) && isset($config->current['ENABLESNAPSHOTS'])) { + if (strtolower($config->current['ENABLEAUTOMATICSNAPSHOTS']) === 'true' && strtolower($config->current['ENABLESNAPSHOTS']) === 'true') { + $this->generateAutomaticSnapshot(); + } } } } @@ -395,12 +396,6 @@ class user extends simplePlugin return parent::post_save(); } - -// public function verifyLastSnapshotMD5 () : BOOL -// { -// -// } - /** * @return void * Note : Create a snapshot of current data before save, verifying if data have changed before taking a snap. -- GitLab