-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
include ("../../../inc/includes.php"); | ||
use GlpiPlugin\Ticketfilter\Config; | ||
|
||
// Check if plugin is activated... | ||
$plugin = new Plugin(); | ||
if (!$plugin->isInstalled('ticketfilter') || !$plugin->isActivated('ticketfilter')) { | ||
Html::displayNotFoundError(); | ||
} | ||
|
||
$Config = new Config(); | ||
|
||
if (isset($_POST['add'])) { | ||
//Check CREATE ACL | ||
$Config->check(-1, CREATE, $_POST); | ||
//Do object creation | ||
$newid = $Config->add($_POST); | ||
//Redirect to newly created object form | ||
Html::redirect("{$CFG_GLPI['root_doc']}/plugins/front/myobject.form.php?id=$newid"); | ||
} else if (isset($_POST['update'])) { | ||
//Check UPDATE ACL | ||
$Config->check($_POST['id'], UPDATE); | ||
//Do object update | ||
$Config->update($_POST); | ||
//Redirect to object form | ||
Html::back(); | ||
} else if (isset($_POST['delete'])) { | ||
//Check DELETE ACL | ||
$Config->check($_POST['id'], DELETE); | ||
//Put object in dustbin | ||
$Config->delete($_POST); | ||
//Redirect to objects list | ||
$Config->redirectToList(); | ||
} else if (isset($_POST['purge'])) { | ||
//Check PURGE ACL | ||
$Config->check($_POST['id'], PURGE); | ||
//Do object purge | ||
$Config->delete($_POST, 1); | ||
//Redirect to objects list | ||
Html::redirect("{$CFG_GLPI['root_doc']}/plugins/front/myobject.php"); | ||
} else { | ||
//per default, display object | ||
$withtemplate = (isset($_GET['withtemplate']) ? $_GET['withtemplate'] : 0); | ||
$Config->display( | ||
[ | ||
'id' => $_GET['id'], | ||
'withtemplate' => $withtemplate | ||
] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
include ("../../../inc/includes.php"); | ||
use GlpiPlugin\Ticketfilter\Config; | ||
use Plugin; | ||
|
||
// Check if plugin is activated... | ||
$plugin = new Plugin(); | ||
if (!$plugin->isInstalled('ticketfilter') || !$plugin->isActivated('ticketfilter')) { | ||
Html::displayNotFoundError(); | ||
} | ||
|
||
//check for ACLs | ||
/*if (Config::canView()) { */ | ||
//View is granted: display the list. | ||
|
||
//Add page header | ||
Html::header( | ||
__('Ticket Filter', 'ticketfilter'), | ||
$_SERVER['PHP_SELF'], | ||
'assets', | ||
Config::class, | ||
'ticketfilter' | ||
); | ||
|
||
Search::show(Config::class); | ||
|
||
Html::footer(); | ||
|
||
/* | ||
} else { | ||
//View is not granted. | ||
Html::displayRightError(); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/** | ||
* ------------------------------------------------------------------------ | ||
* Chris Gralike Ticket Filter | ||
* Copyright (C) 2023 by Chris Gralike | ||
* ------------------------------------------------------------------------ | ||
* | ||
* LICENSE | ||
* | ||
* This file is part of Ticket Filter project. | ||
* | ||
* Ticket Filter plugin is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ticket Filter 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with ticket filter. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* ------------------------------------------------------------------------ | ||
* | ||
* @package TicketFilter | ||
* @version 1.0.0 | ||
* @author Chris Gralike | ||
* @copyright Copyright (c) 2023 by Chris Gralike | ||
* @license MIT | ||
* @see https://github.com/DonutsNL/ticketfilter/readme.md | ||
* @link https://github.com/DonutsNL/ticketfilter | ||
* @since 1.0.0 | ||
* @todo !Keep it stupid simple! | ||
* -Create a fancy configuration page | ||
* -Config [Followup Match string] [AutoSolve Match String] [Supress followups] [regEx101 testlink/comment] | ||
* -Option to automatically merge duplicate oldest/latest ticket if more then 1 ticket is found with matchstring. | ||
* -Option to automatically link with closed ticket(s) on match closed (how to deal with multiple closed tickets?) | ||
* -Default GLPI behaviour is to load Plugin trazilion times with each dashboard graph, maybe create singleton pattern/caching? | ||
* ------------------------------------------------------------------------ | ||
**/ | ||
|
||
namespace GlpiPlugin\Ticketfilter; | ||
|
||
use CommonDropdown; | ||
use Html; | ||
|
||
class Config extends CommonDropdown { | ||
|
||
public function showForm($ID, array $options = []) { | ||
global $CFG_GLPI; | ||
|
||
$this->initForm($ID, $options); | ||
$this->showFormHeader($options); | ||
|
||
if (!isset($options['display'])) { | ||
//display per default | ||
$options['display'] = true; | ||
} | ||
|
||
$params = $options; | ||
//do not display called elements per default; they'll be displayed or returned here | ||
$params['display'] = false; | ||
|
||
$out = '<tr>'; | ||
$out .= '<th>' . __('My label', 'Ticket Filter') . '</th>'; | ||
|
||
$objectName = autoName( | ||
$this->fields["name"], | ||
"name", | ||
(isset($options['withtemplate']) && $options['withtemplate']==2), | ||
$this->getType(), | ||
$this->fields["entities_id"] | ||
); | ||
|
||
$out .= '<td>'; | ||
$out .= Html::autocompletionTextField( | ||
$this, | ||
'name', | ||
[ | ||
'value' => $objectName, | ||
'display' => false | ||
] | ||
); | ||
$out .= '</td>'; | ||
|
||
$out .= $this->showFormButtons($params); | ||
|
||
if ($options['display'] == true) { | ||
echo $out; | ||
} else { | ||
return $out; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters