diff --git a/include/management/snapshot/class_SnapshotCreateDialog.inc b/include/management/snapshot/class_SnapshotCreateDialog.inc index dab6b4f3f1e00d5459040db5928aebb14f2c52a6..3b07182fddc099d8a486d775d37a9671771f00b2 100644 --- a/include/management/snapshot/class_SnapshotCreateDialog.inc +++ b/include/management/snapshot/class_SnapshotCreateDialog.inc @@ -95,7 +95,6 @@ class SnapshotCreateDialog extends ManagementDialog return $recordedDataSources; } - /*! * \brief Get LDAP base to use for ACL checks */ diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index fe51e6d7488c37bc129128ffdf477b6986a54dee..1f42530c483820e64dfdd111292ca0f8ce88ee03 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -387,6 +387,7 @@ class user extends simplePlugin // 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(); } } return parent::post_save(); @@ -395,66 +396,10 @@ class user extends simplePlugin /* * Create the snapshot object in case of automated snapshot. */ - public function generateSlaveTasks () + public function generateAutomaticSnapshot () { - $emails = $this->attributesAccess['fdTasksEmailsFromDN']->getValue(); - // Ref is supposed to be the mail object CN in this class - $ref = $this->attributesAccess['fdTasksMailObject']->getValue(); - $from = $this->attributesAccess['fdTasksEmailSender']->getValue(); - // Incremental id allowing creation of different CN for sub tasks - $id = 0; - - // Take the attribute from the other tabs - attribute cannot be null or unset by default - $schedule = $this->parent->getBaseObject()->fdTasksScheduleDate ?? NULL; - - if (isset($emails) && !empty($emails)) { - foreach ($emails as $email) { - $id ++; - - // Here we create the object taskGranular - $tabObject = objects::create('TasksGranular'); - - // remove 'dn' keeping only 'cn' - $rmDn = preg_replace('/(?=,).*/', '', $this->dn); - - // only take the cn without dc - preg_match('/cn=(.*)/', $rmDn, $matches); - - $subTaskName = $matches[1].'-SubTask-'.$id; - - $values['tasksGranular'] = [ - "cn" => $subTaskName, - "fdTasksGranularType" => 'Mail Object', - "fdTasksGranularMaster" => $this->dn, - "fdTasksGranularMail" => $email, - "fdTasksGranularSchedule" => $schedule, - "fdTasksGranularRef" => $ref, - "fdTasksGranularMailFrom" => $from - ]; - - foreach ($values as $tab => $tabvalues) { - if (!isset($tabObject->by_object[$tab])) { - echo "Error tab does not contains attributes values" .PHP_EOL; - } - $error = $tabObject->by_object[$tab]->deserializeValues($tabvalues); - if ($error !== TRUE) { - echo 'Error during deserializing' .$error .PHP_EOL; - } - - $tabObject->current = $tab; - $tabObject->update(); - $tabObject->loadTabs(); - } - - $errors = $tabObject->save(); - - // Showing errors should be better, enhancement here required. - if (!empty($errors)) { - $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName))); - $show_error->display(); - } - } - } + $snapshotHandler = new snapshotHandler(); + $snapshotHandler->createSnapshot($this->dn, 'automatic snapshot', 'USER', 'FD'); }