diff --git a/plugins/addons/tasks/class_tasks.inc b/plugins/addons/tasks/class_tasks.inc index 6f41382797a18d61d698816c16bb80c74e243307..11b96d29e62b6e99559e1eb754b177dc41b25568 100644 --- a/plugins/addons/tasks/class_tasks.inc +++ b/plugins/addons/tasks/class_tasks.inc @@ -45,7 +45,7 @@ class tasks extends simplePlugin return [ // Attributes are grouped by section 'tasks' => [ - 'name' => _('Tasks Generic'), + 'name' => _('Tasks Generic | Saving will create un-modifiable subtasks'), 'attrs' => [ new StringAttribute( _('Task Name'), _('Name for this task'), diff --git a/plugins/addons/tasks/class_tasksGranular.inc b/plugins/addons/tasks/class_tasksGranular.inc index c71f54e77279ec004deef08fe00f023440e5dfee..7a504f34f6f8bcb1d0a7a98ab6f787d0978e3dfa 100644 --- a/plugins/addons/tasks/class_tasksGranular.inc +++ b/plugins/addons/tasks/class_tasksGranular.inc @@ -39,6 +39,12 @@ class tasksGranular extends simplePlugin ]; } + /* + * Info : getAttributesInfo return is important for the management class. + * It is the return of that method which render the columns and data properly. + * Although not used by the interface directly, it is created by simpleTab during + * the save of mailTasks. + */ static function getAttributesInfo (): array { return [ diff --git a/plugins/addons/tasks/class_tasksMail.inc b/plugins/addons/tasks/class_tasksMail.inc index 37b0723e3c7159278155986b2128a2168d5153ba..5b9ec7603551afbd8ccbbf4a7f815174aa119e30 100644 --- a/plugins/addons/tasks/class_tasksMail.inc +++ b/plugins/addons/tasks/class_tasksMail.inc @@ -148,7 +148,8 @@ class tasksMail extends simplePlugin } /* - * Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated (for now). + * Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated. + * It would be dangerous to edit subs tasks if some are under processed already. */ public function generateSlaveTasks () { @@ -156,25 +157,23 @@ class tasksMail extends simplePlugin // 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'; - } + // 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' + // remove 'dn' keeping only 'cn' $rmDn = preg_replace('/(?=,).*/', '', $this->dn); - // only take the cn without dc + + // only take the cn without dc preg_match('/cn=(.*)/', $rmDn, $matches); - $subTaskName = $matches[1].'-SubTask-'.$id; - $id ++; + + $subTaskName = $matches[1].'-SubTask-'.$id; $values['tasksGranular'] = [ "cn" => $subTaskName, @@ -190,7 +189,7 @@ class tasksMail extends simplePlugin } $error = $tabobject->by_object[$tab]->deserializeValues($tabvalues); if ($error !== TRUE) { - echo 'Error deserailizing' .PHP_EOL; + echo 'Error during deserializing' .$error .PHP_EOL; } $tabobject->current = $tab; @@ -200,9 +199,8 @@ class tasksMail extends simplePlugin $errors = $tabobject->save(); if (!empty($errors)) { - Throw new FusionDirectoryError( - htmlescape(sprintf( _('SubTasks DN already exist ! You cannot modify a saved task !'))) - ); + $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName))); + $show_error->display(); } } } diff --git a/plugins/admin/tasks/class_tasksColumn.inc b/plugins/admin/tasks/class_tasksColumn.inc index d3009a144a3699c9a87d03fe6ef5f03da1335f41..664ee120d50f5f4a1770409d27be20b365a12311 100644 --- a/plugins/admin/tasks/class_tasksColumn.inc +++ b/plugins/admin/tasks/class_tasksColumn.inc @@ -34,14 +34,21 @@ class TasksColumn extends Column case 'fdTasksStatus': return static::filterStatus(intval($value)); + case 'fdTasksGranularStatus': + return static::filterStatus(intval($value)); + + // This case needs optimization case 'fdTasksMailObject': return "Mail Object"; case 'fdTasksScheduleDate': - // Z is added to value to match ldap generaliseztime - $datetime = (new LdapGeneralizedTime)->fromString($value.'Z'); - $result = $datetime->format('Y-m-d H:i:s'); - return $result; + return static::generateDateFormat($value); + + case 'fdTasksGranularSchedule': + return static::generateDateFormat($value); + + case 'fdTasksGranularMaster': + return static::generateMasterTaskName($value); default: return parent::renderSingleValue($entry, $value); @@ -61,8 +68,25 @@ class TasksColumn extends Column default : return "Error Encountered"; - } } + static function generateDateFormat ($value) : string + { + // Z is added to value to match ldap generaliseztime + $datetime = (new LdapGeneralizedTime)->fromString($value.'Z'); + $result = $datetime->format('Y-m-d H:i:s'); + return $result; + } + + static function generateMasterTaskName ($value) : string + { + // remove 'dn' keeping only 'cn' + $rmDn = preg_replace('/(?=,).*/', '', $value); + // only take the cn without dc + preg_match('/cn=(.*)/', $rmDn, $matches); + + return $matches[1]; + } + } diff --git a/plugins/admin/tasks/class_tasksDashboard.inc b/plugins/admin/tasks/class_tasksDashboard.inc index 5000ad705b895135d5903f8a705590f783d32fda..e75982ff3c2952a255d9311ee3dae2b54a831076 100644 --- a/plugins/admin/tasks/class_tasksDashboard.inc +++ b/plugins/admin/tasks/class_tasksDashboard.inc @@ -24,18 +24,17 @@ class tasksDashboard extends management // Actions collumn are removed compared to parent. public static $columns = [ ['Column', ['attributes' => 'cn', 'label' => 'Tasks']], - ['Column', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']], + ['TasksColumn', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']], ['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']], ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], - ['Column', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], - ['Column', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], + ['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], + ['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], ]; // No modification tools are required. protected $skipCpHandler = TRUE; public static $skipSnapshots = TRUE; public static $skipTemplates = TRUE; - protected $skipConfiguration = TRUE; static function plInfo () { @@ -59,7 +58,7 @@ class tasksDashboard extends management // Allowing us to add additional actions and remove unrequired ones. protected function configureActions () { - // Leaving empty as no default action allowed. + // Leaving empty as no default action allowed. } // End of Class } @@ -67,5 +66,5 @@ class tasksDashboard extends management // extending the class allows us to remove the rendering of filter. class tasksDashboardFilter extends managementFilter { - // Filter will be + // Filter will be set soon } diff --git a/plugins/admin/tasks/class_tasksManagement.inc b/plugins/admin/tasks/class_tasksManagement.inc index b59b90fcfa9917b90d7655baa218a8144dacfff4..5647d801dcfc9064b557dd4459d1e418a857bec0 100644 --- a/plugins/admin/tasks/class_tasksManagement.inc +++ b/plugins/admin/tasks/class_tasksManagement.inc @@ -21,7 +21,9 @@ class tasksManagement extends management { - /* + protected $skipCpHandler = TRUE; + + /* * LinkColumn exists by class collumn * TasksColumn is a new class for Tasks bassed on argonaut column definition */ @@ -54,7 +56,6 @@ class tasksManagement extends management { /* Set baseMode to FALSE */ $this->listing = new managementListing($this, FALSE); - } }