diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index 22613dcf1c57fc5205f69b4c07c7fd7cb132bf74..6c7a7f66222f5ad40b8193107b7146da5c2bba8f 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -353,7 +353,7 @@ attributetype ( 1.3.6.1.4.1.38414.89.1.12 NAME 'fdTasksGranularType' SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.38414.89.1.13 NAME 'fdTasksGranularMail' - DESC 'Fusion Directory - Task Mail' + DESC 'Fusion Directory - Emails recipients if object mail' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) diff --git a/plugins/addons/tasks/class_tasksGranular.inc b/plugins/addons/tasks/class_tasksGranular.inc index 65b34f5f487b484b6bd23ca489c86e82e676c619..c71f54e77279ec004deef08fe00f023440e5dfee 100644 --- a/plugins/addons/tasks/class_tasksGranular.inc +++ b/plugins/addons/tasks/class_tasksGranular.inc @@ -53,7 +53,9 @@ class tasksGranular extends simplePlugin new HiddenAttribute('fdTasksGranularStatus', TRUE, '1', '', 'Status', 'Status of the task'), new HiddenAttribute('fdTasksGranularMaster', TRUE, '', '', 'Master CN', 'Name of the Master task'), new HiddenAttribute('fdTasksGranularType', TRUE, '', '', 'Type', 'Type of the task'), - new HiddenAttribute('fdTasksGranularMail', TRUE, '', '', 'Mail', 'Mail of the task'), + new MailAttribute( + _('Email'), + _('Email address which will be sent to'), 'fdTasksGranularMail', TRUE), new DateTimeAttribute( _('Schedule'), '', 'fdTasksGranularSchedule', FALSE @@ -67,10 +69,6 @@ class tasksGranular extends simplePlugin { global $config; parent::__construct($dn, $object, $parent, $mainTab); - - $this->attributesAccess['fdTasksGranularMaster']->setValue('testMaster'); - $this->attributesAccess['fdTasksGranularType']->setValue('testType'); - $this->attributesAccess['fdTasksGranularMail']->setValue('testMail'); } } diff --git a/plugins/addons/tasks/class_tasksMail.inc b/plugins/addons/tasks/class_tasksMail.inc index 5247534ec9aba06f19bb2c13d35864319b6b1aca..37b0723e3c7159278155986b2128a2168d5153ba 100644 --- a/plugins/addons/tasks/class_tasksMail.inc +++ b/plugins/addons/tasks/class_tasksMail.inc @@ -147,39 +147,62 @@ class tasksMail extends simplePlugin return $errors; } - public function generateSlaveTasks () : void + /* + * Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated (for now). + */ + public function generateSlaveTasks () { - $tabobject = objects::create('TasksGranular'); - $infos = objects::infos('TasksGranular'); $emails = $this->attributesAccess['fdTasksEmailsFromDN']->getValue(); - - // Testing purposes - $id = 1; + // Incremental id allowing creation of different CN for sub tasks + $id = 0; + + // Verification of set attributes required for granular tasks. + if ( isset($this->attrs['fdTasksScheduleDate'][0]) && !empty($this->attrs['fdTasksScheduleDate'][0]) ) { + $schedule = $this->attrs['fdTasksScheduleDate'][0]; + } else { + // testing purposes. + $schedule = '20222222222200'; + } if (isset($emails) && !empty($emails)) { foreach ($emails as $email) { - $id += $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; + $id ++; + $values['tasksGranular'] = [ - "cn" => "testCN-.$id", - "fdTasksGranularType" => 'Mail Object', + "cn" => $subTaskName, + "fdTasksGranularType" => 'Mail Object', + "fdTasksGranularMaster" => $this->dn, + "fdTasksGranularMail" => $email, + "fdTasksGranularSchedule" => $schedule, ]; foreach ($values as $tab => $tabvalues) { if (!isset($tabobject->by_object[$tab])) { - echo "Error tabObject by object tab is not set"; + echo "Error tab does not contains attributes values" .PHP_EOL; } - $error = $tabobject->by_object[$tab]->deserializeValues($tabvalues); + $error = $tabobject->by_object[$tab]->deserializeValues($tabvalues); if ($error !== TRUE) { - echo $error; + echo 'Error deserailizing' .PHP_EOL; } - $tabobject->current = $tab; - $tabobject->update(); - $tabobject->loadTabs(); + $tabobject->current = $tab; + $tabobject->update(); + $tabobject->loadTabs(); } + $errors = $tabobject->save(); if (!empty($errors)) { - print_r($errors); + Throw new FusionDirectoryError( + htmlescape(sprintf( _('SubTasks DN already exist ! You cannot modify a saved task !'))) + ); } } } diff --git a/plugins/admin/tasks/class_tasksDashboard.inc b/plugins/admin/tasks/class_tasksDashboard.inc index 8c6c286efbdd5fc1ab93a612ef68c4c0dec47c60..5000ad705b895135d5903f8a705590f783d32fda 100644 --- a/plugins/admin/tasks/class_tasksDashboard.inc +++ b/plugins/admin/tasks/class_tasksDashboard.inc @@ -21,9 +21,9 @@ class tasksDashboard extends management { - // Actions collumn are removed compared to parent + // Actions collumn are removed compared to parent. public static $columns = [ - ['LinkColumn', ['attributes' => 'cn', 'label' => 'Tasks']], + ['Column', ['attributes' => 'cn', 'label' => 'Tasks']], ['Column', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']], ['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']], ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], @@ -31,7 +31,7 @@ class tasksDashboard extends management ['Column', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], ]; - // No modification tools are required + // No modification tools are required. protected $skipCpHandler = TRUE; public static $skipSnapshots = TRUE; public static $skipTemplates = TRUE; @@ -56,15 +56,10 @@ class tasksDashboard extends management $this->filter = new tasksDashboardFilter($this, NULL, $filterElementDefinitions); } - // Allowing us to add additional actions and remove unrequired ones + // Allowing us to add additional actions and remove unrequired ones. protected function configureActions () { - $this->registerAction( - new Action( - 'edit', _('See Details'), 'geticon.php?context=actions&icon=document-edit&size=16', - '+', 'editEntry' - ) - ); + // Leaving empty as no default action allowed. } // End of Class } @@ -72,9 +67,5 @@ class tasksDashboard extends management // extending the class allows us to remove the rendering of filter. class tasksDashboardFilter extends managementFilter { - function render () : string - { - // must respect the string return from parent - return ''; - } + // Filter will be }