Skip to content

Commit d75d25c

Browse files
committed
Add NameSpace files
1 parent e0196f4 commit d75d25c

File tree

6 files changed

+1695
-0
lines changed

6 files changed

+1695
-0
lines changed

src/Config.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/*
3+
-------------------------------------------------------------------------
4+
autoexportsearches plugin for GLPI
5+
Copyright (C) 2020-2025 by the autoexportsearches Development Team.
6+
7+
https://github.com/InfotelGLPI/autoexportsearches
8+
-------------------------------------------------------------------------
9+
10+
LICENSE
11+
12+
This file is part of autoexportsearches.
13+
14+
autoexportsearches is free software; you can redistribute it and/or modify
15+
it under the terms of the GNU General Public License as published by
16+
the Free Software Foundation; either version 2 of the License, or
17+
(at your option) any later version.
18+
19+
autoexportsearches is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
GNU General Public License for more details.
23+
24+
You should have received a copy of the GNU General Public License
25+
along with autoexportsearches. If not, see <http://www.gnu.org/licenses/>.
26+
--------------------------------------------------------------------------
27+
*/
28+
29+
namespace GlpiPlugin\Autoexportsearches;
30+
31+
use CommonDBTM;
32+
use Html;
33+
use Toolbox;
34+
35+
if (!defined('GLPI_ROOT')) {
36+
die("Sorry. You can't access directly to this file");
37+
}
38+
39+
class Config extends CommonDBTM
40+
{
41+
42+
static $rightname = 'plugin_autoexportsearches_configs';
43+
44+
/**
45+
* Show form
46+
*
47+
* @return boolean
48+
*/
49+
function showConfigForm()
50+
{
51+
52+
if (!$this->canView() && !$this->canUpdate()) {
53+
return false;
54+
}
55+
56+
if (! $this->getFromDB(1)) {
57+
$this->getEmpty();
58+
}
59+
60+
echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL(Config::class) . "'>";
61+
echo "<div class='center'><table class='tab_cadre_fixe'>";
62+
echo "<tr><th colspan='2'>" . __('Setup') . "</th></tr>";
63+
64+
echo "<tr class='tab_bg_1'>";
65+
echo "<td>" . __('Number of months before purge files', 'autoexportsearches') . "</td>";
66+
echo "<td>";
67+
echo Html::input('monthBeforePurge', ['value' => $this->fields['monthBeforePurge'], 'size' => 6]);
68+
echo "</td>";
69+
echo "</tr>";
70+
71+
echo "<tr><td class='tab_bg_2 center' colspan='2'>";
72+
echo Html::submit(_sx('button', 'Save'), ['name' => 'update', 'class' => 'btn btn-primary']);
73+
echo "</td></tr>";
74+
75+
echo "</table></div>";
76+
Html::closeForm();
77+
78+
return true;
79+
}
80+
}

src/Customsearchcriteria.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/*
3+
-------------------------------------------------------------------------
4+
autoexportsearches plugin for GLPI
5+
Copyright (C) 2020-2025 by the autoexportsearches Development Team.
6+
7+
https://github.com/InfotelGLPI/autoexportsearches
8+
-------------------------------------------------------------------------
9+
10+
LICENSE
11+
12+
This file is part of autoexportsearches.
13+
14+
autoexportsearches is free software; you can redistribute it and/or modify
15+
it under the terms of the GNU General Public License as published by
16+
the Free Software Foundation; either version 2 of the License, or
17+
(at your option) any later version.
18+
19+
autoexportsearches is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
GNU General Public License for more details.
23+
24+
You should have received a copy of the GNU General Public License
25+
along with autoexportsearches. If not, see <http://www.gnu.org/licenses/>.
26+
--------------------------------------------------------------------------
27+
*/
28+
29+
namespace GlpiPlugin\Autoexportsearches;
30+
31+
use CommonDBTM;
32+
33+
if (!defined('GLPI_ROOT')) {
34+
die("Sorry. You can't access directly to this file");
35+
}
36+
37+
class Customsearchcriteria extends CommonDBTM
38+
{
39+
const CRITERIA_FIRST_DAY_OF_MONTH = 'first day of ';
40+
const CRITERIA_FIRST_DAY_OF_WEEK = 'last monday';
41+
42+
public static function createCriterias(ExportConfig $exportConfig)
43+
{
44+
global $DB;
45+
// clear old relations (in case of update with the saved search criterias changed)
46+
$DB->delete(
47+
'glpi_plugin_autoexportsearches_customsearchcriterias',
48+
[
49+
'exportconfigs_id' => $exportConfig->fields['id'],
50+
'savedsearches_id' => $exportConfig->fields['savedsearches_id']
51+
]
52+
);
53+
54+
if (isset($exportConfig->input['custom_criterias'])) {
55+
$customCriterias = $exportConfig->input['custom_criterias'];
56+
if (is_array($customCriterias)) {
57+
foreach ($customCriterias as $criteria) {
58+
$criteria['exportconfigs_id'] = $exportConfig->fields['id'];
59+
$self = new self();
60+
$self->add($criteria);
61+
}
62+
}
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)