Verified Commit 1b8ebc50 authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(Task) - Dashboard v0.3

Updates for dashboard - version 0.3
Showing with 49 additions and 37 deletions
+49 -37
......@@ -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 )
......
......@@ -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');
}
}
......@@ -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 !')))
);
}
}
}
......
......@@ -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
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment