An error occurred while loading the file. Please try again.
-
dockx thibault authored
Adding a boolean trigger within tasks allowing more security in order to not trigger the tasks and subtasks.
Verifiedec8ddb14
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2022 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tasksDashboard extends management
{
// Actions collumn are removed compared to parent.
public static $columns = [
['Column', ['attributes' => 'cn', 'label' => 'Tasks']],
['TasksColumn', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']],
['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']],
['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']],
['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']],
['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']],
['ActionsColumn', ['label' => 'Actions']],
];
// No modification tools are required.
protected $skipCpHandler = TRUE;
public static $skipSnapshots = TRUE;
public static $skipTemplates = TRUE;
static function plInfo ()
{
return [
'plShortName' => _('Tasks Dashboard'),
'plDescription' => _('Provide a reporting mechanism for tasks'),
'plTitle' => _('Tasks Dashboard'),
'plIcon' => 'geticon.php?context=applications&icon=argonaut&size=48',
'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 40]],
'plPriority' => 10,
'plManages' => ['tasksGranular'],
'plProvidedAcls' => [],
];
}
protected function setUpFilter (array $filterElementDefinitions)
{
$this->filter = new tasksDashboardFilter($this, NULL, $filterElementDefinitions);
}
// Allowing us to add additional actions and remove unrequired ones.
protected function configureActions ()
{
$this->registerAction(
new Action(
'tasksRenew',
_('Renew the selected task'),
'geticon.php?context=actions&icon=view-refresh&size=16',
'+',
'tasksRenew'
)
);
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
$this->actions['tasksRenew']->setSeparator(TRUE);
$this->actions['tasksRenew']->setEnableFunction([$this, 'setTasksActionStatus']);
}
// This method is triggered by the user action click on tasksRenew
function tasksRenew (array $action)
{
foreach ((array)$action['targets'] as $dn) {
$this->tasksUpdate($dn);
}
}
function tasksUpdate ($dn)
{
$tabObject = objects::open($dn, 'tasksGranular');
$tabObject->by_object['tasksGranular']->attributesAccess['fdTasksGranularStatus']->setValue(1);
$errors = $tabObject->save();
if (!empty($errors)) {
$show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error updating: "%s" !.'), $dn)));
$show_error->display();
}
}
// This method is triggered during initiation of the dashboard, allowing proper icons status
function setTasksActionStatus () : BOOL
{
return TRUE;
}
// End of Class
}
// extending the class allows us to remove the rendering of filter.
class tasksDashboardFilter extends managementFilter
{
// Filter will be set soon
}