mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-07-01 16:18:41 +02:00
global code update : namespace and src folder
This commit is contained in:

committed by
Cédric Anne

parent
3351d0f268
commit
9f415e0d32
106
src/Child.php
Normal file
106
src/Child.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDBChild;
|
||||
use Session;
|
||||
|
||||
// Sample of class that inherit from CommonDBChild. The behaviour of CommonRelation is similar.
|
||||
// The main evolution introduced by 0.84 version of GLPI is a stronger control and log of
|
||||
// interactions. We suggest you to refer to the header of CommonDBConnexity class to see these
|
||||
// enhancements.
|
||||
// For CommonDBRelation, the variable are quiet equivalent, but they use _1 and _2 for each side
|
||||
// parent
|
||||
class Child extends CommonDBChild {
|
||||
|
||||
// A child rely on an item. If $itemtype=='itemtype', then that is a variable item.
|
||||
static public $itemtype = 'itemtype';
|
||||
static public $items_id = 'items_id';
|
||||
|
||||
|
||||
// With 0.84, you have to specify each right (create, view, update and delete), because
|
||||
// CommonDBChild(s) and CommonDBRelation(s) mainly depend on the rights on the parent item
|
||||
// All these methods rely on parent:can*. Two attributs are usefull :
|
||||
// * $checkParentRights: define what to check regarding the parent :
|
||||
// - CommonDBConnexity::DONT_CHECK_ITEM_RIGHTS don't eaven relly on parents rights
|
||||
// - CommonDBConnexity::HAVE_VIEW_RIGHT_ON_ITEM view right on the item is enough
|
||||
// - CommonDBConnexity::HAVE_SAME_RIGHT_ON_ITEM we must have at least update right
|
||||
// on the item
|
||||
// * $mustBeAttached: some CommonDBChild can be free, without any parent.
|
||||
static function canCreate() {
|
||||
|
||||
return (Session::haveRight('internet', UPDATE)
|
||||
&& parent::canCreate());
|
||||
}
|
||||
|
||||
|
||||
static function canView() {
|
||||
|
||||
return (Session::haveRight('internet', READ)
|
||||
&& parent::canView());
|
||||
}
|
||||
|
||||
|
||||
static function canUpdate() {
|
||||
|
||||
return (Session::haveRight('internet', UPDATE)
|
||||
&& parent::canUpdate());
|
||||
}
|
||||
|
||||
|
||||
static function canDelete() {
|
||||
|
||||
return (Session::haveRight('internet', DELETE)
|
||||
&& parent::canDelete());
|
||||
}
|
||||
|
||||
|
||||
// By default, post_addItem, post_updateItem and post_deleteFromDB are defined.
|
||||
// They define the history to add to the parents
|
||||
// This method define the name to set inside the history of the parent.
|
||||
// All these methods use $log_history_add, $log_history_update and $log_history_delete to
|
||||
// define the level of log (Log::HISTORY_ADD_DEVICE, Log::HISTORY_UPDATE_DEVICE ...)
|
||||
function getHistoryName_for_item($case) {
|
||||
}
|
||||
|
||||
// CommonDBChild also check if we can add or updatethe item regarding the new item
|
||||
// ($input[static::$itemtype] and $input[static::$items_id]).
|
||||
// But don't forget to call parent::prepareInputForAdd()
|
||||
function prepareInputForAdd($input) {
|
||||
// My preparation on $input
|
||||
return parent::prepareInputForAdd($input);
|
||||
}
|
||||
|
||||
}
|
83
src/Computer.php
Normal file
83
src/Computer.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDBTM;
|
||||
|
||||
// Class of the defined type
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
class Computer extends CommonDBTM {
|
||||
|
||||
static function showInfo() {
|
||||
|
||||
echo '<table class="tab_glpi" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<th>'.__('More information').'</th>';
|
||||
echo '</tr>';
|
||||
echo '<tr class="tab_bg_1">';
|
||||
echo '<td>';
|
||||
echo __('Test successful');
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
|
||||
static function item_can($item) {
|
||||
|
||||
if (($item->getType() == 'Computer')
|
||||
&& ($item->right == READ)
|
||||
&& ($item->fields['groups_id'] > 0)
|
||||
&& !in_array($item->fields['groups_id'], $_SESSION["glpigroups"])) {
|
||||
$item->right = 0; // unknown, so denied.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static function add_default_where($in) {
|
||||
|
||||
list($itemtype, $condition) = $in;
|
||||
if ($itemtype == 'Computer') {
|
||||
$table = getTableForItemType($itemtype);
|
||||
$condition .= " (".$table.".groups_id NOT IN (".implode(',', $_SESSION["glpigroups"])."))";
|
||||
}
|
||||
return [$itemtype, $condition];
|
||||
}
|
||||
|
||||
}
|
96
src/Config.php
Normal file
96
src/Config.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDBTM;
|
||||
use CommonGLPI;
|
||||
use Config as GlpiConfig;
|
||||
use Dropdown;
|
||||
use Html;
|
||||
use Session;
|
||||
use Toolbox;
|
||||
|
||||
class Config extends CommonDBTM {
|
||||
|
||||
static protected $notable = true;
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
|
||||
|
||||
if (!$withtemplate) {
|
||||
if ($item->getType() == 'Config') {
|
||||
return __('Example plugin');
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
static function configUpdate($input) {
|
||||
$input['configuration'] = 1 - $input['configuration'];
|
||||
return $input;
|
||||
}
|
||||
|
||||
function showFormExample() {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if (!Session::haveRight("config", UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$my_config = GlpiConfig::getConfigurationValues('plugin:Example');
|
||||
|
||||
echo "<form name='form' action=\"".Toolbox::getItemTypeFormURL('Config')."\" method='post'>";
|
||||
echo "<div class='center' id='tabsbody'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th colspan='4'>" . __('Example setup') . "</th></tr>";
|
||||
echo "<td >" . __('My boolean choice :') . "</td>";
|
||||
echo "<td colspan='3'>";
|
||||
echo "<input type='hidden' name='config_class' value='".__CLASS__."'>";
|
||||
echo "<input type='hidden' name='config_context' value='plugin:Example'>";
|
||||
Dropdown::showYesNo("configuration", $my_config['configuration']);
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_2'>";
|
||||
echo "<td colspan='4' class='center'>";
|
||||
echo "<input type='submit' name='update' class='submit' value=\""._sx('button', 'Save')."\">";
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</table></div>";
|
||||
Html::closeForm();
|
||||
}
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
|
||||
if ($item->getType() == 'Config') {
|
||||
$config = new self();
|
||||
$config->showFormExample();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
52
src/DeviceCamera.php
Normal file
52
src/DeviceCamera.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDevice;
|
||||
|
||||
// Class of the defined type
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
/// Class DeviceCamera
|
||||
class DeviceCamera extends CommonDevice {
|
||||
|
||||
static function getTypeName($nb = 0) {
|
||||
return _n('Camera', 'Cameras', $nb);
|
||||
}
|
||||
|
||||
}
|
224
src/Document.php
Normal file
224
src/Document.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------
|
||||
GLPI - Gestionnaire Libre de Parc Informatique
|
||||
Copyright (C) 2003-2011 by the INDEPNET Development Team.
|
||||
|
||||
http://indepnet.net/ http://glpi-project.org
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
LICENSE
|
||||
|
||||
This file is part of GLPI.
|
||||
|
||||
GLPI 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.
|
||||
|
||||
GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Show how to dowload a file (or any stream) from the REST API
|
||||
* as well as metatadata stored in DB
|
||||
*
|
||||
* This itemtype is designed to be the same as Document in GLPI Core
|
||||
* to focus on the file dowload and upload features
|
||||
*
|
||||
* Example to download a file with cURL
|
||||
*
|
||||
* $ curl -X GET \
|
||||
* -H 'Content-Type: application/json' \
|
||||
* -H 'Session-Token: s6f3jik227ttrsat7d8ap9laal' \
|
||||
* -H 'Accept: application/octet-stream' \
|
||||
* 'http://path/to/glpi/apirest.php/PluginExampleDocument/1' \
|
||||
* --output /tmp/test_download
|
||||
*
|
||||
* Example to upload a file with cURL
|
||||
*
|
||||
* $ curl -X POST \
|
||||
* -H 'Content-Type: multipart/form-data' \
|
||||
* -H "Session-Token: s6f3jik227ttrsat7d8ap9laal" \
|
||||
* -F 'uploadManifest={"input": {"name": "Uploaded document", "_filename" : ["file.txt"]}}' \
|
||||
* -F 'file[]=@/tmp/test.txt' \
|
||||
* 'http://path/to/glpi/apirest.php/PluginExampleDocument/'
|
||||
*
|
||||
*/
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use Document as GlpiDocument;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
class Document extends GlpiDocument {
|
||||
|
||||
/**
|
||||
* Return the table used to store this object. Overloads the implementation in CommonDBTM
|
||||
*
|
||||
* @param string $classname Force class (to avoid late_binding on inheritance)
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public static function getTable($classname = null) {
|
||||
if ($classname === null) {
|
||||
$classname = get_called_class();
|
||||
}
|
||||
if ($classname == get_called_class()) {
|
||||
return parent::getTable(Document::class);
|
||||
}
|
||||
|
||||
return parent::getTable($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare creation of an item
|
||||
*
|
||||
* @param array $input
|
||||
* @return array|false
|
||||
*/
|
||||
public function prepareInputForAdd($input) {
|
||||
$input['_only_if_upload_succeed'] = true;
|
||||
if (!isset($_FILES['file'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Move the uploaded file to GLPi's tmp dir
|
||||
while (count($_FILES['file']['name']) > 0) {
|
||||
$source = array_pop($_FILES['file']['name']);
|
||||
$destination = GLPI_TMP_DIR . '/' . $source;
|
||||
move_uploaded_file($source, $destination);
|
||||
$input['_filename'][] = $source;
|
||||
}
|
||||
|
||||
return parent::prepareInputForAdd($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare update of an item
|
||||
*
|
||||
* @param array $input
|
||||
* @return array|false
|
||||
*/
|
||||
public function prepareInputForUpdate($input) {
|
||||
// Do not allow update of document
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process required after loading an object from DB
|
||||
* In this example, a file is sent as a byte strem then stops execution.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function post_getFromDB() {
|
||||
// Check the user can view this itemtype and can view this item
|
||||
if ($this->canView() && $this->canViewItem()) {
|
||||
if (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream'
|
||||
|| isset($_GET['alt']) && $_GET['alt'] == 'media') {
|
||||
$this->sendFile(); // and terminate script
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a byte stream to the HTTP client and stops execution
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function sendFile() {
|
||||
$streamSource = GLPI_DOC_DIR . '/' . $this->fields['filepath'];
|
||||
|
||||
// Ensure the file exists
|
||||
if (!file_exists($streamSource) || !is_file($streamSource)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Download range defaults to the full file
|
||||
// get file metadata
|
||||
$size = filesize($streamSource);
|
||||
$begin = 0;
|
||||
$end = $size - 1;
|
||||
$mimeType = 'application/octet-stream';
|
||||
$time = date('r', filemtime($streamSource));
|
||||
|
||||
// Open the file
|
||||
$fileHandle = @fopen($streamSource, 'rb');
|
||||
if (!$fileHandle) {
|
||||
header ("HTTP/1.0 500 Internal Server Error");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// set range if specified by the client
|
||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||
if (preg_match('/bytes=\h*(\d+)?-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
|
||||
if (!empty($matches[1])) {
|
||||
$begin = intval($matches[1]);
|
||||
}
|
||||
if (!empty($matches[2])) {
|
||||
$end = min(intval($matches[2]), $end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// seek to the begining of the range
|
||||
$currentPosition = $begin;
|
||||
if (fseek($fileHandle, $begin, SEEK_SET) < 0) {
|
||||
header("HTTP/1.0 500 Internal Server Error");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// send headers to ensure the client is able to detect a corrupted download
|
||||
// example : less bytes than the expected range
|
||||
// send meta data
|
||||
// setup client's cache behavior
|
||||
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
|
||||
header('Pragma: private'); /// IE BUG + SSL
|
||||
header('Cache-control: private, must-revalidate'); /// IE BUG + SSL
|
||||
header("Content-disposition: attachment; filename=\"" . $this->fields['filename'] . "\"");
|
||||
header("Content-type: $mimeType");
|
||||
header("Last-Modified: $time");
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Content-Length:' . ($end - $begin + 1));
|
||||
header("Content-Range: bytes $begin-$end/$size");
|
||||
header("Content-Transfer-Encoding: binary\n");
|
||||
header('Connection: close');
|
||||
|
||||
// Prepare HTTP response
|
||||
if ($begin > 0 || $end < $size - 1) {
|
||||
header('HTTP/1.0 206 Partial Content');
|
||||
} else {
|
||||
header('HTTP/1.0 200 OK');
|
||||
}
|
||||
|
||||
// Sends bytes until the end of the range or connection closed
|
||||
while (!feof($fileHandle) && $currentPosition < $end && (connection_status() == 0)) {
|
||||
// allow a few seconds to send a few KB.
|
||||
set_time_limit(10);
|
||||
$content = fread($fileHandle, min(1024 * 16, $end - $currentPosition + 1));
|
||||
if ($content === false) {
|
||||
header("HTTP/1.0 500 Internal Server Error", true); // Replace previously sent headers
|
||||
exit(0);
|
||||
} else {
|
||||
print $content;
|
||||
}
|
||||
flush();
|
||||
$currentPosition += 1024 * 16;
|
||||
}
|
||||
|
||||
// End now to prevent any unwanted bytes
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
49
src/Dropdown.php
Normal file
49
src/Dropdown.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDropdown;
|
||||
|
||||
// Class for a Dropdown
|
||||
class Dropdown extends CommonDropdown {
|
||||
|
||||
|
||||
static function getTypeName($nb = 0) {
|
||||
|
||||
if ($nb > 0) {
|
||||
return __('Plugin Example Dropdowns', 'example');
|
||||
}
|
||||
return __('Plugin Example Dropdowns', 'example');
|
||||
}
|
||||
}
|
630
src/Example.php
Normal file
630
src/Example.php
Normal file
@ -0,0 +1,630 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use CommonDBTM;
|
||||
use CommonGLPI;
|
||||
use Computer;
|
||||
use Html;
|
||||
use Log;
|
||||
use MassiveAction;
|
||||
use Session;
|
||||
|
||||
// Class of the defined type
|
||||
class Example extends CommonDBTM {
|
||||
|
||||
static $tags = '[EXAMPLE_ID]';
|
||||
|
||||
// Should return the localized name of the type
|
||||
static function getTypeName($nb = 0) {
|
||||
return 'Example Type';
|
||||
}
|
||||
|
||||
|
||||
static function canCreate() {
|
||||
|
||||
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
||||
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static function canView() {
|
||||
|
||||
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
||||
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w'
|
||||
|| $_SESSION["glpi_plugin_example_profile"]['example'] == 'r');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see CommonGLPI::getMenuName()
|
||||
**/
|
||||
static function getMenuName() {
|
||||
return __('Example plugin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see CommonGLPI::getAdditionalMenuLinks()
|
||||
**/
|
||||
static function getAdditionalMenuLinks() {
|
||||
global $CFG_GLPI;
|
||||
$links = [];
|
||||
|
||||
$links['config'] = '/plugins/example/index.php';
|
||||
$links["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
|
||||
$links[__s('Test link', 'example')] = '/plugins/example/index.php';
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
function defineTabs($options = []) {
|
||||
|
||||
$ong = [];
|
||||
$this->addDefaultFormTab($ong);
|
||||
$this->addStandardTab('Link', $ong, $options);
|
||||
|
||||
return $ong;
|
||||
}
|
||||
|
||||
function showForm($ID, array $options = []) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
$this->initForm($ID, $options);
|
||||
$this->showFormHeader($options);
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
|
||||
echo "<td>" . __('ID') . "</td>";
|
||||
echo "<td>";
|
||||
echo $ID;
|
||||
echo "</td>";
|
||||
|
||||
$this->showFormButtons($options);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function rawSearchOptions() {
|
||||
|
||||
$tab = [];
|
||||
|
||||
$tab[] = [
|
||||
'id' => 'common',
|
||||
'name' => __('Header Needed')
|
||||
];
|
||||
|
||||
$tab[] = [
|
||||
'id' => '1',
|
||||
'table' => 'glpi_plugin_example_examples',
|
||||
'field' => 'name',
|
||||
'name' => __('Name'),
|
||||
];
|
||||
|
||||
$tab[] = [
|
||||
'id' => '2',
|
||||
'table' => 'glpi_plugin_example_dropdowns',
|
||||
'field' => 'name',
|
||||
'name' => __('Dropdown'),
|
||||
];
|
||||
|
||||
$tab[] = [
|
||||
'id' => '3',
|
||||
'table' => 'glpi_plugin_example_examples',
|
||||
'field' => 'serial',
|
||||
'name' => __('Serial number'),
|
||||
'usehaving' => true,
|
||||
'searchtype' => 'equals',
|
||||
];
|
||||
|
||||
$tab[] = [
|
||||
'id' => '30',
|
||||
'table' => 'glpi_plugin_example_examples',
|
||||
'field' => 'id',
|
||||
'name' => __('ID'),
|
||||
'usehaving' => true,
|
||||
'searchtype' => 'equals',
|
||||
];
|
||||
|
||||
return $tab;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Give localized information about 1 task
|
||||
*
|
||||
* @param $name of the task
|
||||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
static function cronInfo($name) {
|
||||
|
||||
switch ($name) {
|
||||
case 'Sample' :
|
||||
return ['description' => __('Cron description for example', 'example'),
|
||||
'parameter' => __('Cron parameter for example', 'example')];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute 1 task manage by the plugin
|
||||
*
|
||||
* @param $task Object of CronTask class for log / stat
|
||||
*
|
||||
* @return interger
|
||||
* >0 : done
|
||||
* <0 : to be run again (not finished)
|
||||
* 0 : nothing to do
|
||||
*/
|
||||
static function cronSample($task) {
|
||||
|
||||
$task->log("Example log message from class");
|
||||
$r = mt_rand(0, $task->fields['param']);
|
||||
usleep(1000000+$r*1000);
|
||||
$task->setVolume($r);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Hook done on before add item case (data from form, not altered)
|
||||
static function pre_item_add_computer(Computer $item) {
|
||||
if (isset($item->input['name']) && empty($item->input['name'])) {
|
||||
Session::addMessageAfterRedirect("Pre Add Computer Hook KO (name empty)", true);
|
||||
return $item->input = false;
|
||||
} else {
|
||||
Session::addMessageAfterRedirect("Pre Add Computer Hook OK", true);
|
||||
}
|
||||
}
|
||||
|
||||
// Hook done on before add item case (data altered by object prepareInputForAdd)
|
||||
static function post_prepareadd_computer(Computer $item) {
|
||||
Session::addMessageAfterRedirect("Post prepareAdd Computer Hook", true);
|
||||
}
|
||||
|
||||
|
||||
// Hook done on add item case
|
||||
static function item_add_computer(Computer $item) {
|
||||
|
||||
Session::addMessageAfterRedirect("Add Computer Hook, ID=".$item->getID(), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
|
||||
|
||||
if (!$withtemplate) {
|
||||
switch ($item->getType()) {
|
||||
case 'Profile' :
|
||||
if ($item->getField('central')) {
|
||||
return __('Example', 'example');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Phone' :
|
||||
if ($_SESSION['glpishow_count_on_tabs']) {
|
||||
return self::createTabEntry(__('Example', 'example'),
|
||||
countElementsInTable($this->getTable()));
|
||||
}
|
||||
return __('Example', 'example');
|
||||
|
||||
case 'ComputerDisk' :
|
||||
case 'Supplier' :
|
||||
return [1 => __("Test Plugin", 'example'),
|
||||
2 => __("Test Plugin 2", 'example')];
|
||||
|
||||
case 'Computer' :
|
||||
case 'Central' :
|
||||
case 'Preference':
|
||||
case 'Notification':
|
||||
return [1 => __("Test Plugin", 'example')];
|
||||
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
|
||||
switch ($item->getType()) {
|
||||
case 'Phone' :
|
||||
echo __("Plugin Example on Phone", 'example');
|
||||
break;
|
||||
|
||||
case 'Central' :
|
||||
echo __("Plugin central action", 'example');
|
||||
break;
|
||||
|
||||
case 'Preference' :
|
||||
// Complete form display
|
||||
$data = plugin_version_example();
|
||||
|
||||
echo "<form action='Where to post form'>";
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th colspan='3'>".$data['name']." - ".$data['version'];
|
||||
echo "</th></tr>";
|
||||
|
||||
echo "<tr class='tab_bg_1'><td>Name of the pref</td>";
|
||||
echo "<td>Input to set the pref</td>";
|
||||
|
||||
echo "<td><input class='submit' type='submit' name='submit' value='submit'></td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
break;
|
||||
|
||||
case 'Notification' :
|
||||
echo __("Plugin mailing action", 'example');
|
||||
break;
|
||||
|
||||
case 'ComputerDisk' :
|
||||
case 'Supplier' :
|
||||
if ($tabnum==1) {
|
||||
echo __('First tab of Plugin example', 'example');
|
||||
} else {
|
||||
echo __('Second tab of Plugin example', 'example');
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
//TRANS: %1$s is a class name, %2$d is an item ID
|
||||
printf(__('Plugin example CLASS=%1$s id=%2$d', 'example'), $item->getType(), $item->getField('id'));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static function getSpecificValueToDisplay($field, $values, array $options = []) {
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = [$field => $values];
|
||||
}
|
||||
switch ($field) {
|
||||
case 'serial' :
|
||||
return "S/N: ".$values[$field];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// Parm contains begin, end and who
|
||||
// Create data to be displayed in the planning of $parm["who"] or $parm["who_group"] between $parm["begin"] and $parm["end"]
|
||||
static function populatePlanning($parm) {
|
||||
|
||||
// Add items in the output array
|
||||
// Items need to have an unique index beginning by the begin date of the item to display
|
||||
// needed to be correcly displayed
|
||||
$output = [];
|
||||
$key = $parm["begin"]."$$$"."plugin_example1";
|
||||
$output[$key]["begin"] = date("Y-m-d 17:00:00");
|
||||
$output[$key]["end"] = date("Y-m-d 18:00:00");
|
||||
$output[$key]["name"] = __("test planning example 1", 'example');
|
||||
// Specify the itemtype to be able to use specific display system
|
||||
$output[$key]["itemtype"] = Example::class;
|
||||
// Set the ID using the ID of the item in the database to have unique ID
|
||||
$output[$key][getForeignKeyFieldForItemType(Example::class)] = 1;
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a Planning Item
|
||||
*
|
||||
* @param $val Array of the item to display
|
||||
* @param $who ID of the user (0 if all)
|
||||
* @param $type position of the item in the time block (in, through, begin or end)
|
||||
* @param $complete complete display (more details)
|
||||
*
|
||||
* @return Nothing (display function)
|
||||
**/
|
||||
static function displayPlanningItem(array $val, $who, $type = "", $complete = 0) {
|
||||
|
||||
// $parm["type"] say begin end in or from type
|
||||
// Add items in the items fields of the parm array
|
||||
switch ($type) {
|
||||
case "in" :
|
||||
//TRANS: %1$s is the start time of a planned item, %2$s is the end
|
||||
printf(__('From %1$s to %2$s :'),
|
||||
date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
|
||||
break;
|
||||
|
||||
case "through" :
|
||||
echo Html::resume_text($val["name"], 80);
|
||||
break;
|
||||
|
||||
case "begin" :
|
||||
//TRANS: %s is the start time of a planned item
|
||||
printf(__('Start at %s:'), date("H:i", strtotime($val["begin"])));
|
||||
break;
|
||||
|
||||
case "end" :
|
||||
//TRANS: %s is the end time of a planned item
|
||||
printf(__('End at %s:'), date("H:i", strtotime($val["end"])));
|
||||
break;
|
||||
}
|
||||
echo "<br>";
|
||||
echo Html::resume_text($val["name"], 80);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an history entry message
|
||||
*
|
||||
* @param $data Array from glpi_logs table
|
||||
*
|
||||
* @since GLPI version 0.84
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
static function getHistoryEntry($data) {
|
||||
|
||||
switch ($data['linked_action'] - Log::HISTORY_PLUGIN) {
|
||||
case 0:
|
||||
return __('History from plugin example', 'example');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
////// SPECIFIC MODIF MASSIVE FUNCTIONS ///////
|
||||
/**
|
||||
* @since version 0.85
|
||||
*
|
||||
* @see CommonDBTM::getSpecificMassiveActions()
|
||||
**/
|
||||
function getSpecificMassiveActions($checkitem = null) {
|
||||
|
||||
$actions = parent::getSpecificMassiveActions($checkitem);
|
||||
|
||||
$actions['Document_Item'.MassiveAction::CLASS_ACTION_SEPARATOR.'add'] =
|
||||
_x('button', 'Add a document'); // GLPI core one
|
||||
$actions[__CLASS__.MassiveAction::CLASS_ACTION_SEPARATOR.'do_nothing'] =
|
||||
__('Do Nothing - just for fun', 'example'); // Specific one
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since version 0.85
|
||||
*
|
||||
* @see CommonDBTM::showMassiveActionsSubForm()
|
||||
**/
|
||||
static function showMassiveActionsSubForm(MassiveAction $ma) {
|
||||
|
||||
switch ($ma->getAction()) {
|
||||
case 'DoIt':
|
||||
echo " <input type='hidden' name='toto' value='1'>".
|
||||
Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']).
|
||||
" ".__('Write in item history', 'example');
|
||||
return true;
|
||||
case 'do_nothing' :
|
||||
echo " ".Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']).
|
||||
" ".__('but do nothing :)', 'example');
|
||||
return true;
|
||||
}
|
||||
return parent::showMassiveActionsSubForm($ma);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since version 0.85
|
||||
*
|
||||
* @see CommonDBTM::processMassiveActionsForOneItemtype()
|
||||
**/
|
||||
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item,
|
||||
array $ids) {
|
||||
global $DB;
|
||||
|
||||
switch ($ma->getAction()) {
|
||||
case 'DoIt' :
|
||||
if ($item->getType() == 'Computer') {
|
||||
Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
|
||||
Session::addMessageAfterRedirect(__('Write in item history', 'example'));
|
||||
$changes = [0, 'old value', 'new value'];
|
||||
foreach ($ids as $id) {
|
||||
if ($item->getFromDB($id)) {
|
||||
Session::addMessageAfterRedirect("- ".$item->getField("name"));
|
||||
Log::history($id, 'Computer', $changes, Example::class,
|
||||
Log::HISTORY_PLUGIN);
|
||||
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
|
||||
} else {
|
||||
// Example of ko count
|
||||
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// When nothing is possible ...
|
||||
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
|
||||
}
|
||||
return;
|
||||
|
||||
case 'do_nothing' :
|
||||
If ($item->getType() == Example::class) {
|
||||
Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
|
||||
Session::addMessageAfterRedirect(__("But... I say I will do nothing for:",
|
||||
'example'));
|
||||
foreach ($ids as $id) {
|
||||
if ($item->getFromDB($id)) {
|
||||
Session::addMessageAfterRedirect("- ".$item->getField("name"));
|
||||
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
|
||||
} else {
|
||||
// Example for noright / Maybe do it with can function is better
|
||||
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
|
||||
}
|
||||
Return;
|
||||
}
|
||||
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
|
||||
}
|
||||
|
||||
static function generateLinkContents($link, CommonDBTM $item) {
|
||||
|
||||
if (strstr($link, "[EXAMPLE_ID]")) {
|
||||
$link = str_replace("[EXAMPLE_ID]", $item->getID(), $link);
|
||||
return [$link];
|
||||
}
|
||||
|
||||
return parent::generateLinkContents($link, $item);
|
||||
}
|
||||
|
||||
|
||||
static function dashboardTypes() {
|
||||
return [
|
||||
'example' => [
|
||||
'label' => __("Plugin Example", 'example'),
|
||||
'function' => Example::class . "::cardWidget",
|
||||
'image' => "https://via.placeholder.com/100x86?text=example",
|
||||
],
|
||||
'example_static' => [
|
||||
'label' => __("Plugin Example (static)", 'example'),
|
||||
'function' => Example::class . "::cardWidgetWithoutProvider",
|
||||
'image' => "https://via.placeholder.com/100x86?text=example+static",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
static function dashboardCards($cards = []) {
|
||||
if (is_null($cards)) {
|
||||
$cards = [];
|
||||
}
|
||||
$new_cards = [
|
||||
'plugin_example_card' => [
|
||||
'widgettype' => ["example"],
|
||||
'label' => __("Plugin Example card"),
|
||||
'provider' => Example::class . "::cardDataProvider",
|
||||
],
|
||||
'plugin_example_card_without_provider' => [
|
||||
'widgettype' => ["example_static"],
|
||||
'label' => __("Plugin Example card without provider"),
|
||||
],
|
||||
'plugin_example_card_with_core_widget' => [
|
||||
'widgettype' => ["bigNumber"],
|
||||
'label' => __("Plugin Example card with core provider"),
|
||||
'provider' => Example::class . "::cardBigNumberProvider",
|
||||
],
|
||||
];
|
||||
|
||||
return array_merge($cards, $new_cards);
|
||||
}
|
||||
|
||||
|
||||
static function cardWidget(array $params = []) {
|
||||
$default = [
|
||||
'data' => [],
|
||||
'title' => '',
|
||||
// this property is "pretty" mandatory,
|
||||
// as it contains the colors selected when adding widget on the grid send
|
||||
// without it, your card will be transparent
|
||||
'color' => '',
|
||||
];
|
||||
$p = array_merge($default, $params);
|
||||
|
||||
// you need to encapsulate your html in div.card to benefit core style
|
||||
$html = "<div class='card' style='background-color: {$p["color"]};'>";
|
||||
$html.= "<h2>{$p['title']}</h2>";
|
||||
$html.= "<ul>";
|
||||
foreach ($p['data'] as $line) {
|
||||
$html.= "<li>$line</li>";
|
||||
}
|
||||
$html.= "</ul>";
|
||||
$html.= "</div>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
static function cardDataProvider(array $params = []) {
|
||||
$default_params = [
|
||||
'label' => null,
|
||||
'icon' => "fas fa-smile-wink",
|
||||
];
|
||||
$params = array_merge($default_params, $params);
|
||||
|
||||
return [
|
||||
'title' => $params['label'],
|
||||
'icon' => $params['icon'],
|
||||
'data' => [
|
||||
'test1',
|
||||
'test2',
|
||||
'test3',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
static function cardWidgetWithoutProvider(array $params = []) {
|
||||
$default = [
|
||||
// this property is "pretty" mandatory,
|
||||
// as it contains the colors selected when adding widget on the grid send
|
||||
// without it, your card will be transparent
|
||||
'color' => '',
|
||||
];
|
||||
$p = array_merge($default, $params);
|
||||
|
||||
// you need to encapsulate your html in div.card to benefit core style
|
||||
$html = "<div class='card' style='background-color: {$p["color"]};'>
|
||||
static html (+optional javascript) as card is not matched with a data provider
|
||||
|
||||
<img src='https://www.linux.org/images/logo.png'>
|
||||
</div>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
static function cardBigNumberProvider(array $params = []) {
|
||||
$default_params = [
|
||||
'label' => null,
|
||||
'icon' => null,
|
||||
];
|
||||
$params = array_merge($default_params, $params);
|
||||
|
||||
return [
|
||||
'number' => rand(),
|
||||
'url' => "https://www.linux.org/",
|
||||
'label' => "plugin example - some text",
|
||||
'icon' => "fab fa-linux", // font awesome icon
|
||||
];
|
||||
}
|
||||
}
|
149
src/ItemForm.php
Normal file
149
src/ItemForm.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use Html;
|
||||
use Ticket;
|
||||
|
||||
/**
|
||||
* Summary of GlpiPlugin\Example\ItemForm
|
||||
* Example of *_item_form implementation
|
||||
* @see http://glpi-developer-documentation.rtfd.io/en/master/plugins/hooks.html#items-display-related
|
||||
* */
|
||||
class ItemForm {
|
||||
|
||||
/**
|
||||
* Display contents at the begining of item forms.
|
||||
*
|
||||
* @param array $params Array with "item" and "options" keys
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function preItemForm($params) {
|
||||
$item = $params['item'];
|
||||
$options = $params['options'];
|
||||
|
||||
$firstelt = ($item::getType() == Ticket::class ? 'th' : 'td');
|
||||
|
||||
$out = '<tr><th colspan="' . (isset($options['colspan']) ? $options['colspan'] * 2 : '4') . '">';
|
||||
$out .= sprintf(
|
||||
__('Start %1$s hook call for %2$s type'),
|
||||
'pre_item_form',
|
||||
$item::getType()
|
||||
);
|
||||
$out .= '</th></tr>';
|
||||
|
||||
$out .= "<tr><$firstelt>";
|
||||
$out .= '<label for="example_pre_form_hook">' . __('First pre form hook') . '</label>';
|
||||
$out .= "</$firstelt><td>";
|
||||
$out .= '<input type="text" name="example_pre_form_hook" id="example_pre_form_hook"/>';
|
||||
$out .= "</td><$firstelt>";
|
||||
$out .= '<label for="example_pre_form_hook2">' . __('Second pre form hook') . '</label>';
|
||||
$out .= "</$firstelt><td>";
|
||||
$out .= '<input type="text" name="example_pre_form_hook2" id="example_pre_form_hook2"/>';
|
||||
$out .= '</td></tr>';
|
||||
|
||||
$out .= '<tr><th colspan="' . (isset($options['colspan']) ? $options['colspan'] * 2 : '4') . '">';
|
||||
$out .= sprintf(
|
||||
__('End %1$s hook call for %2$s type'),
|
||||
'pre_item_form',
|
||||
$item::getType()
|
||||
);
|
||||
$out .= '</th></tr>';
|
||||
|
||||
echo $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display contents at the begining of item forms.
|
||||
*
|
||||
* @param array $params Array with "item" and "options" keys
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function postItemForm($params) {
|
||||
$item = $params['item'];
|
||||
$options = $params['options'];
|
||||
|
||||
$firstelt = ($item::getType() == Ticket::class ? 'th' : 'td');
|
||||
|
||||
$out = '<tr><th colspan="' . (isset($options['colspan']) ? $options['colspan'] * 2 : '4') . '">';
|
||||
$out .= sprintf(
|
||||
__('Start %1$s hook call for %2$s type'),
|
||||
'post_item_form',
|
||||
$item::getType()
|
||||
);
|
||||
$out .= '</th></tr>';
|
||||
|
||||
$out .= "<tr><$firstelt>";
|
||||
$out .= '<label for="example_post_form_hook">' . __('First post form hook') . '</label>';
|
||||
$out .= "</$firstelt><td>";
|
||||
$out .= '<input type="text" name="example_post_form_hook" id="example_post_form_hook"/>';
|
||||
$out .= "</td><$firstelt>";
|
||||
$out .= '<label for="example_post_form_hook2">' . __('Second post form hook') . '</label>';
|
||||
$out .= "</$firstelt><td>";
|
||||
$out .= '<input type="text" name="example_post_form_hook2" id="example_post_form_hook2"/>';
|
||||
$out .= '</td></tr>';
|
||||
|
||||
$out .= '<tr><th colspan="' . (isset($options['colspan']) ? $options['colspan'] * 2 : '4') . '">';
|
||||
$out .= sprintf(
|
||||
__('End %1$s hook call for %2$s type'),
|
||||
'post_item_form',
|
||||
$item::getType()
|
||||
);
|
||||
$out .= '</th></tr>';
|
||||
|
||||
echo $out;
|
||||
}
|
||||
|
||||
static public function timelineActions($params = []) {
|
||||
$rand = $params['rand'];
|
||||
$ticket = $params['item'];
|
||||
|
||||
if (get_class($ticket) !== "Ticket") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$edit_panel = "viewitem".$ticket->fields['id'].$rand;
|
||||
$JS = <<<JAVASCRIPT
|
||||
$(function() {
|
||||
$(document).on('click', '#email_transfer_{$rand}', function(event) {
|
||||
$('#{$edit_panel}').html('email send');
|
||||
});
|
||||
});
|
||||
JAVASCRIPT;
|
||||
|
||||
echo "<li class='followup' id='email_transfer_$rand'>
|
||||
<i class='far fa-envelope'></i>".
|
||||
__("Send a notification").
|
||||
Html::scriptBlock($JS)."
|
||||
</li>";
|
||||
}
|
||||
}
|
56
src/Item_DeviceCamera.php
Normal file
56
src/Item_DeviceCamera.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file:
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Class of the defined type
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use GlpiPlugin\Example\DeviceCamera;
|
||||
use Item_Devices;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation between item and devices
|
||||
**/
|
||||
class Item_DeviceCamera extends Item_Devices {
|
||||
|
||||
static public $itemtype_2 = DeviceCamera::class;
|
||||
static public $items_id_2 = 'plugin_example_devicecameras_id';
|
||||
|
||||
static protected $notable = false;
|
||||
|
||||
}
|
50
src/NotificationTargetExample.php
Normal file
50
src/NotificationTargetExample.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use NotificationTarget;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
// Class NotificationTarget
|
||||
class NotificationTargetExample extends NotificationTarget {
|
||||
|
||||
function getEvents() {
|
||||
return ['alert' => 'alert example'];
|
||||
}
|
||||
|
||||
function addDataForTemplate($event, $options = []) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
$this->data['##example.name##'] = __('Example', 'example');
|
||||
}
|
||||
}
|
87
src/RuleTest.php
Normal file
87
src/RuleTest.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Walid Nouh
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use Rule;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rule class store all informations about a GLPI rule :
|
||||
* - description
|
||||
* - criterias
|
||||
* - actions
|
||||
*
|
||||
**/
|
||||
class RuleTest extends Rule {
|
||||
|
||||
// From Rule
|
||||
public $rightname = 'rule_import';
|
||||
public $can_sort = true;
|
||||
|
||||
|
||||
function getTitle() {
|
||||
return 'test';
|
||||
}
|
||||
|
||||
|
||||
function maxActionsCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function getCriterias() {
|
||||
|
||||
$criterias = [];
|
||||
$criterias['name']['field'] = 'name';
|
||||
$criterias['name']['name'] = __('Software');
|
||||
$criterias['name']['table'] = 'glpi_softwares';
|
||||
|
||||
return $criterias;
|
||||
}
|
||||
|
||||
|
||||
function getActions() {
|
||||
|
||||
$actions = [];
|
||||
$actions['softwarecategories_id']['name'] = __('Category (class)', 'example');
|
||||
$actions['softwarecategories_id']['type'] = 'dropdown';
|
||||
$actions['softwarecategories_id']['table'] = 'glpi_softwarecategories';
|
||||
return $actions;
|
||||
}
|
||||
}
|
54
src/RuleTestCollection.php
Normal file
54
src/RuleTestCollection.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Original Author of file: Walid Nouh
|
||||
// Purpose of file:
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
use RuleCollection;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
class RuleTestCollection extends RuleCollection {
|
||||
|
||||
// From RuleCollection
|
||||
public $stop_on_first_match = true;
|
||||
public static $rightname = 'rule_import';
|
||||
public $menu_option = 'test';
|
||||
|
||||
function getTitle() {
|
||||
return 'Rulesengine test';
|
||||
}
|
||||
}
|
200
src/Showtabitem.php
Normal file
200
src/Showtabitem.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Example plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of Example.
|
||||
*
|
||||
* Example 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.
|
||||
*
|
||||
* Example 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 Example. If not, see <http://www.gnu.org/licenses/>.
|
||||
* -------------------------------------------------------------------------
|
||||
* @copyright Copyright (C) 2006-2022 by Example plugin team.
|
||||
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @link https://github.com/pluginsGLPI/example
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace GlpiPlugin\Example;
|
||||
|
||||
/**
|
||||
* Summary of GlpiPlugin\Example\Showtabitem
|
||||
* Example of pre_show_xxx and post_show_xxx implementation
|
||||
*
|
||||
*
|
||||
* pre_show_item will be fired before an item is shown
|
||||
* ex: when viewing a ticket, change, computer,...
|
||||
*
|
||||
* will be fired at each sub-item
|
||||
* ex: for each TicketTask, ITILFollowup, ...
|
||||
*
|
||||
* post_show_item will be fired after the item show
|
||||
*
|
||||
*
|
||||
* pre_show_tab will be fired before a tab is shown
|
||||
* when tabs are loaded,
|
||||
* ex: when viewing the Followup tab
|
||||
*
|
||||
* post_show_tab will be fired after the tab show
|
||||
*
|
||||
* */
|
||||
class Showtabitem {
|
||||
|
||||
/**
|
||||
* Summary of pre_show_tab
|
||||
* @param array $params is an array like following
|
||||
* array( 'item', 'options')
|
||||
* where 'item' is the parent object (like 'Ticket'),
|
||||
* and 'options' are options like following
|
||||
* array( 'tabnum', 'itemtype')
|
||||
* where 'tabnum' is the internal name of the tab that will be shown
|
||||
* and 'itemtype' is the type of the tab (ex: 'ITILFollowup' when showing followup tab in a ticket)
|
||||
* Note: you may pass datas to post_show_tab using the $param['options'] array (see example below)
|
||||
*/
|
||||
static function pre_show_tab($params) {
|
||||
switch ($params['item']->getType()) {
|
||||
case 'Ticket':
|
||||
if ($params['options']['itemtype']=='TicketValidation' && $params['options']['tabnum']==2) {
|
||||
// if tasks are not all done
|
||||
// then prevent solution div to show
|
||||
// this is an example to prevent solving of ticket
|
||||
if (true) { // here you should test if some tasks are in todo status.
|
||||
$params['options']['prevent_solution'] = true; // this will be passed to the post_show hook
|
||||
echo "<div id='toHideSolution' style='display: none;'>"; // in order to hide the default solution div
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of post_show_tab
|
||||
* @param array $params is identical to pre_show_tab parameter
|
||||
* Note: you may get datas from pre_show_tab in $param['options'] array (see example below)
|
||||
*/
|
||||
static function post_show_tab($params) {
|
||||
switch ($params['item']->getType()) {
|
||||
case 'Ticket':
|
||||
if (isset($params['options']['prevent_solution'])) {
|
||||
echo "</div>";
|
||||
echo "<div style='margin-bottom: 20px;' class='box'>
|
||||
<div class='box-tleft'>
|
||||
<div class='box-tright'>
|
||||
<div class='box-tcenter'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='box-mleft'>
|
||||
<div class='box-mright'>
|
||||
<div class='box-mcenter'>
|
||||
<h3>
|
||||
<span class='red'>"."Can't solve ticket"."
|
||||
<br>
|
||||
</span>
|
||||
</h3>
|
||||
<h3>
|
||||
<span >"."Tasks are waiting to be done"."
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='box-bleft'>
|
||||
<div class='box-bright'>
|
||||
<div class='box-bcenter'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> ";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Computer':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of pre_show_item
|
||||
* @param array $params is an array like following
|
||||
* array( 'item', 'options')
|
||||
* where 'item' is the object to show (like 'Ticket', 'TicketTask', ...),
|
||||
* BEWARE that sometimes it can be an array of data and not an object (ex: for solution item)
|
||||
* and 'options' are options like following
|
||||
* if item is a main object like a ticket, change, problem, ... then it contains
|
||||
* array( 'id' )
|
||||
* where 'id' is the id of object that will be shown (same than $param['item']->fields['id'])
|
||||
* or if item contains a sub-object like followup, task, ... then it contains
|
||||
* array( 'parent', 'rand', 'showprivate')
|
||||
* where 'parent' is the main object related to the current item (ex: if 'item' is ITILFollowup then it will be the related Ticket)
|
||||
* and 'rand' contains the random number that will be used to render the item
|
||||
* and 'showprivate' is the right to show private items
|
||||
* Note: you may pass datas to post_show_item using the $param['options'] array
|
||||
*/
|
||||
static function pre_show_item($params) {
|
||||
if (!is_array($params['item'])) {
|
||||
switch ($params['item']->getType()) {
|
||||
case 'Ticket':
|
||||
//echo 'test' ;
|
||||
break;
|
||||
case 'TicketTask' :
|
||||
//echo 'test' ;
|
||||
break;
|
||||
case 'ITILFollowup' :
|
||||
//echo 'test' ;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// here we are going to view a Solution
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of post_show_item
|
||||
* @param array $params is an array like following
|
||||
* array( 'item', 'options')
|
||||
* where 'item' is the object to show (like 'Ticket', 'TicketTask', ...),
|
||||
* and 'options' are options like following
|
||||
* if item is a main object like a ticket, change, problem, ... then it contains
|
||||
* array( 'id' )
|
||||
* where 'id' is the id of object that will be shown (same than $param['item']->fields['id'])
|
||||
* or if item contains a sub-object like followup, task, ... then it contains
|
||||
* array( 'parent', 'rand', 'showprivate')
|
||||
* where 'parent' is the main object related to the current item (ex: if 'item' is ITILFollowup then it will be the related Ticket)
|
||||
* and 'rand' contains the random number that will be used to render the item
|
||||
* and 'showprivate' is the right to show private items
|
||||
* Note: you may get datas from pre_show_item using the $param['options'] array
|
||||
*/
|
||||
static function post_show_item($params) {
|
||||
if (!is_array($params['item'])) {
|
||||
switch ($params['item']->getType()) {
|
||||
case 'Ticket':
|
||||
//echo 'test' ;
|
||||
break;
|
||||
case 'TicketTask' :
|
||||
//echo 'test' ;
|
||||
break;
|
||||
case 'ITILFollowup' :
|
||||
//echo 'test' ;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// here we are going to view a Solution
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user