mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
Fix CS (from phpcbf)
This commit is contained in:
parent
0900bde1c9
commit
46a15511a2
@ -44,7 +44,6 @@ Session::checkRight("config", UPDATE);
|
|||||||
// To be available when plugin in not activated
|
// To be available when plugin in not activated
|
||||||
Plugin::load('example');
|
Plugin::load('example');
|
||||||
|
|
||||||
Html::header("TITRE",$_SERVER['PHP_SELF'],"config","plugins");
|
Html::header("TITRE", $_SERVER['PHP_SELF'], "config", "plugins");
|
||||||
_e("This is the plugin config page", 'example');
|
_e("This is the plugin config page", 'example');
|
||||||
Html::footer();
|
Html::footer();
|
||||||
?>
|
|
||||||
|
@ -36,4 +36,3 @@ include ('../../../inc/includes.php');
|
|||||||
|
|
||||||
$dropdown = new PluginExampleDeviceCamera();
|
$dropdown = new PluginExampleDeviceCamera();
|
||||||
include (GLPI_ROOT . "/front/dropdown.common.form.php");
|
include (GLPI_ROOT . "/front/dropdown.common.form.php");
|
||||||
?>
|
|
@ -36,4 +36,3 @@ include ('../../../inc/includes.php');
|
|||||||
|
|
||||||
$dropdown = new PluginExampleDeviceCamera();
|
$dropdown = new PluginExampleDeviceCamera();
|
||||||
include (GLPI_ROOT . "/front/dropdown.common.php");
|
include (GLPI_ROOT . "/front/dropdown.common.php");
|
||||||
?>
|
|
||||||
|
@ -35,8 +35,7 @@
|
|||||||
|
|
||||||
include ('../../../inc/includes.php');
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
Plugin::load('example',true);
|
Plugin::load('example', true);
|
||||||
|
|
||||||
$dropdown = new PluginExampleDropdown();
|
$dropdown = new PluginExampleDropdown();
|
||||||
include (GLPI_ROOT . "/front/dropdown.common.form.php");
|
include (GLPI_ROOT . "/front/dropdown.common.form.php");
|
||||||
?>
|
|
@ -35,8 +35,7 @@
|
|||||||
|
|
||||||
include ('../../../inc/includes.php');
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
Plugin::load('example',true);
|
Plugin::load('example', true);
|
||||||
|
|
||||||
$dropdown = new PluginExampleDropdown();
|
$dropdown = new PluginExampleDropdown();
|
||||||
include (GLPI_ROOT . "/front/dropdown.common.php");
|
include (GLPI_ROOT . "/front/dropdown.common.php");
|
||||||
?>
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
include ('../../../inc/includes.php');
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
|
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
|
||||||
Html::header("TITRE", $_SERVER['PHP_SELF'],"plugins","pluginexampleexample","");
|
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", "");
|
||||||
} else {
|
} else {
|
||||||
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
|
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
|
||||||
}
|
}
|
||||||
@ -44,4 +44,3 @@ $example = new PluginExampleExample();
|
|||||||
$example->display($_GET);
|
$example->display($_GET);
|
||||||
|
|
||||||
Html::footer();
|
Html::footer();
|
||||||
?>
|
|
@ -35,7 +35,7 @@
|
|||||||
include ('../../../inc/includes.php');
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
|
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
|
||||||
Html::header("TITRE", $_SERVER['PHP_SELF'],"plugins","pluginexampleexample","");
|
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", "");
|
||||||
} else {
|
} else {
|
||||||
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
|
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
|
||||||
}
|
}
|
||||||
@ -46,4 +46,3 @@ if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
|
|||||||
Search::show('PluginExampleExample');
|
Search::show('PluginExampleExample');
|
||||||
|
|
||||||
Html::footer();
|
Html::footer();
|
||||||
?>
|
|
@ -38,17 +38,17 @@ if (isset($_GET["popup"])) {
|
|||||||
if (isset($_SESSION["glpipopup"]["name"])) {
|
if (isset($_SESSION["glpipopup"]["name"])) {
|
||||||
switch ($_SESSION["glpipopup"]["name"]) {
|
switch ($_SESSION["glpipopup"]["name"]) {
|
||||||
case "test_rule" :
|
case "test_rule" :
|
||||||
Html::popHeader(__('Test'),$_SERVER['PHP_SELF']);
|
Html::popHeader(__('Test'), $_SERVER['PHP_SELF']);
|
||||||
include "../../../front/rule.test.php";
|
include "../../../front/rule.test.php";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "test_all_rules" :
|
case "test_all_rules" :
|
||||||
Html::popHeader(__('Test rules engine'),$_SERVER['PHP_SELF']);
|
Html::popHeader(__('Test rules engine'), $_SERVER['PHP_SELF']);
|
||||||
include "../../../front/rulesengine.test.php";
|
include "../../../front/rulesengine.test.php";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "show_cache" :
|
case "show_cache" :
|
||||||
Html::popHeader(__('Cache information'),$_SERVER['PHP_SELF']);
|
Html::popHeader(__('Cache information'), $_SERVER['PHP_SELF']);
|
||||||
include "../../../front/rule.cache.php";
|
include "../../../front/rule.cache.php";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -56,4 +56,3 @@ if (isset($_SESSION["glpipopup"]["name"])) {
|
|||||||
echo "</div>";
|
echo "</div>";
|
||||||
Html::popFooter();
|
Html::popFooter();
|
||||||
}
|
}
|
||||||
?>
|
|
@ -38,4 +38,3 @@ include ('../../../inc/includes.php');
|
|||||||
$rulecollection = new PluginExampleRuleTestCollection();
|
$rulecollection = new PluginExampleRuleTestCollection();
|
||||||
|
|
||||||
include (GLPI_ROOT . "/front/rule.common.form.php");
|
include (GLPI_ROOT . "/front/rule.common.form.php");
|
||||||
?>
|
|
||||||
|
@ -38,4 +38,3 @@ include ('../../../inc/includes.php');
|
|||||||
$rulecollection = new PluginExampleRuleTestCollection();
|
$rulecollection = new PluginExampleRuleTestCollection();
|
||||||
|
|
||||||
include (GLPI_ROOT . "/front/rule.common.php");
|
include (GLPI_ROOT . "/front/rule.common.php");
|
||||||
?>
|
|
||||||
|
76
hook.php
76
hook.php
@ -36,10 +36,10 @@
|
|||||||
// And to save it in the session
|
// And to save it in the session
|
||||||
function plugin_change_profile_example() {
|
function plugin_change_profile_example() {
|
||||||
// For example : same right of computer
|
// For example : same right of computer
|
||||||
if (Session::haveRight('computer','w')) {
|
if (Session::haveRight('computer', 'w')) {
|
||||||
$_SESSION["glpi_plugin_example_profile"] = array('example' => 'w');
|
$_SESSION["glpi_plugin_example_profile"] = array('example' => 'w');
|
||||||
|
|
||||||
} else if (Session::haveRight('computer','r')) {
|
} else if (Session::haveRight('computer', 'r')) {
|
||||||
$_SESSION["glpi_plugin_example_profile"] = array('example' => 'r');
|
$_SESSION["glpi_plugin_example_profile"] = array('example' => 'r');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -116,7 +116,7 @@ function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables)
|
|||||||
// Example of default JOIN clause
|
// Example of default JOIN clause
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
// case "PluginExampleExample" :
|
// case "PluginExampleExample" :
|
||||||
case "MyType" :
|
case "MyType" :
|
||||||
return Search::addLeftJoin($type, $ref_table, $already_link_tables,
|
return Search::addLeftJoin($type, $ref_table, $already_link_tables,
|
||||||
"newtable", "linkfield");
|
"newtable", "linkfield");
|
||||||
@ -129,7 +129,7 @@ function plugin_example_addDefaultSelect($type) {
|
|||||||
// Example of default SELECT item to be added
|
// Example of default SELECT item to be added
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
// case "PluginExampleExample" :
|
// case "PluginExampleExample" :
|
||||||
case "MyType" :
|
case "MyType" :
|
||||||
return "`mytable`.`myfield` = 'myvalue' AS MYNAME, ";
|
return "`mytable`.`myfield` = 'myvalue' AS MYNAME, ";
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ function plugin_example_addDefaultWhere($type) {
|
|||||||
// Example of default WHERE item to be added
|
// Example of default WHERE item to be added
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
// case "PluginExampleExample" :
|
// case "PluginExampleExample" :
|
||||||
case "MyType" :
|
case "MyType" :
|
||||||
return " `mytable`.`myfield` = 'myvalue' ";
|
return " `mytable`.`myfield` = 'myvalue' ";
|
||||||
}
|
}
|
||||||
@ -175,20 +175,20 @@ function plugin_example_addWhere($link, $nott, $type, $ID, $val, $searchtype) {
|
|||||||
$table = $searchopt[$ID]["table"];
|
$table = $searchopt[$ID]["table"];
|
||||||
$field = $searchopt[$ID]["field"];
|
$field = $searchopt[$ID]["field"];
|
||||||
|
|
||||||
$SEARCH = Search::makeTextSearch($val,$nott);
|
$SEARCH = Search::makeTextSearch($val, $nott);
|
||||||
|
|
||||||
// Example of standard Where clause but use it ONLY for specific Where
|
// Example of standard Where clause but use it ONLY for specific Where
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
switch ($table.".".$field) {
|
switch ($table.".".$field) {
|
||||||
/*case "glpi_plugin_example.name" :
|
/*case "glpi_plugin_example.name" :
|
||||||
$ADD = "";
|
$ADD = "";
|
||||||
if ($nott && $val!="NULL") {
|
if ($nott && $val!="NULL") {
|
||||||
$ADD = " OR `$table`.`$field` IS NULL";
|
$ADD = " OR `$table`.`$field` IS NULL";
|
||||||
}
|
}
|
||||||
return $link." (`$table`.`$field` $SEARCH ".$ADD." ) ";*/
|
return $link." (`$table`.`$field` $SEARCH ".$ADD." ) ";*/
|
||||||
case "glpi_plugin_example_examples.serial" :
|
case "glpi_plugin_example_examples.serial" :
|
||||||
return $link." `$table`.`$field` = '$val' ";
|
return $link." `$table`.`$field` = '$val' ";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ function plugin_example_addHaving($link, $nott, $type, $ID, $val, $num) {
|
|||||||
$table = $searchopt[$ID]["table"];
|
$table = $searchopt[$ID]["table"];
|
||||||
$field = $searchopt[$ID]["field"];
|
$field = $searchopt[$ID]["field"];
|
||||||
|
|
||||||
$SEARCH = Search::makeTextSearch($val,$nott);
|
$SEARCH = Search::makeTextSearch($val, $nott);
|
||||||
|
|
||||||
// Example of standard Having clause but use it ONLY for specific Having
|
// Example of standard Having clause but use it ONLY for specific Having
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
@ -221,12 +221,12 @@ function plugin_example_addSelect($type,$ID,$num) {
|
|||||||
$table = $searchopt[$ID]["table"];
|
$table = $searchopt[$ID]["table"];
|
||||||
$field = $searchopt[$ID]["field"];
|
$field = $searchopt[$ID]["field"];
|
||||||
|
|
||||||
// Example of standard Select clause but use it ONLY for specific Select
|
// Example of standard Select clause but use it ONLY for specific Select
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
// switch ($table.".".$field) {
|
// switch ($table.".".$field) {
|
||||||
// case "glpi_plugin_example.name" :
|
// case "glpi_plugin_example.name" :
|
||||||
// return $table.".".$field." AS ITEM_$num, ";
|
// return $table.".".$field." AS ITEM_$num, ";
|
||||||
// }
|
// }
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,12 +236,12 @@ function plugin_example_addOrderBy($type,$ID,$order,$key=0) {
|
|||||||
$table = $searchopt[$ID]["table"];
|
$table = $searchopt[$ID]["table"];
|
||||||
$field = $searchopt[$ID]["field"];
|
$field = $searchopt[$ID]["field"];
|
||||||
|
|
||||||
// Example of standard OrderBy clause but use it ONLY for specific order by
|
// Example of standard OrderBy clause but use it ONLY for specific order by
|
||||||
// No need of the function if you do not have specific cases
|
// No need of the function if you do not have specific cases
|
||||||
// switch ($table.".".$field) {
|
// switch ($table.".".$field) {
|
||||||
// case "glpi_plugin_example.name" :
|
// case "glpi_plugin_example.name" :
|
||||||
// return " ORDER BY $table.$field $order ";
|
// return " ORDER BY $table.$field $order ";
|
||||||
// }
|
// }
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ function plugin_pre_item_update_example($item) {
|
|||||||
|
|
||||||
// Hook done on update item case
|
// Hook done on update item case
|
||||||
function plugin_item_update_example($item) {
|
function plugin_item_update_example($item) {
|
||||||
Session::addMessageAfterRedirect(sprintf(__("Update Computer Hook (%s)", 'example'),implode(',',$item->updates)), true);
|
Session::addMessageAfterRedirect(sprintf(__("Update Computer Hook (%s)", 'example'), implode(',', $item->updates)), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ function plugin_item_update_example($item) {
|
|||||||
// Hook done on get empty item case
|
// Hook done on get empty item case
|
||||||
function plugin_item_empty_example($item) {
|
function plugin_item_empty_example($item) {
|
||||||
if (empty($_SESSION['Already displayed "Empty Computer Hook"'])) {
|
if (empty($_SESSION['Already displayed "Empty Computer Hook"'])) {
|
||||||
Session::addMessageAfterRedirect(__("Empty Computer Hook", 'example'),true);
|
Session::addMessageAfterRedirect(__("Empty Computer Hook", 'example'), true);
|
||||||
$_SESSION['Already displayed "Empty Computer Hook"'] = true;
|
$_SESSION['Already displayed "Empty Computer Hook"'] = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -354,13 +354,13 @@ function plugin_item_empty_example($item) {
|
|||||||
// Hook done on before delete item case
|
// Hook done on before delete item case
|
||||||
function plugin_pre_item_delete_example($object) {
|
function plugin_pre_item_delete_example($object) {
|
||||||
// Manipulate data if needed
|
// Manipulate data if needed
|
||||||
Session::addMessageAfterRedirect(__("Pre Delete Computer Hook", 'example'),true);
|
Session::addMessageAfterRedirect(__("Pre Delete Computer Hook", 'example'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hook done on delete item case
|
// Hook done on delete item case
|
||||||
function plugin_item_delete_example($object) {
|
function plugin_item_delete_example($object) {
|
||||||
Session::addMessageAfterRedirect(__("Delete Computer Hook", 'example'),true);
|
Session::addMessageAfterRedirect(__("Delete Computer Hook", 'example'), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,13 +368,13 @@ function plugin_item_delete_example($object) {
|
|||||||
// Hook done on before purge item case
|
// Hook done on before purge item case
|
||||||
function plugin_pre_item_purge_example($object) {
|
function plugin_pre_item_purge_example($object) {
|
||||||
// Manipulate data if needed
|
// Manipulate data if needed
|
||||||
Session::addMessageAfterRedirect(__("Pre Purge Computer Hook", 'example'),true);
|
Session::addMessageAfterRedirect(__("Pre Purge Computer Hook", 'example'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hook done on purge item case
|
// Hook done on purge item case
|
||||||
function plugin_item_purge_example($object) {
|
function plugin_item_purge_example($object) {
|
||||||
Session::addMessageAfterRedirect(__("Purge Computer Hook", 'example'),true);
|
Session::addMessageAfterRedirect(__("Purge Computer Hook", 'example'), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ function plugin_item_restore_example($item) {
|
|||||||
// Hook done on restore item case
|
// Hook done on restore item case
|
||||||
function plugin_item_transfer_example($parm) {
|
function plugin_item_transfer_example($parm) {
|
||||||
//TRANS: %1$s is the source type, %2$d is the source ID, %3$d is the destination ID
|
//TRANS: %1$s is the source type, %2$d is the source ID, %3$d is the destination ID
|
||||||
Session::addMessageAfterRedirect(sprintf(__('Transfer Computer Hook %1$s %2$d -> %3$d', 'example'),$parm['type'],$parm['id'],
|
Session::addMessageAfterRedirect(sprintf(__('Transfer Computer Hook %1$s %2$d -> %3$d', 'example'), $parm['type'], $parm['id'],
|
||||||
$parm['newID']));
|
$parm['newID']));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -606,9 +606,9 @@ function plugin_example_postinit() {
|
|||||||
global $CFG_GLPI;
|
global $CFG_GLPI;
|
||||||
|
|
||||||
// All plugins are initialized, so all types are registered
|
// All plugins are initialized, so all types are registered
|
||||||
foreach (Infocom::getItemtypesThatCanHave() as $type) {
|
//foreach (Infocom::getItemtypesThatCanHave() as $type) {
|
||||||
// do something
|
// do something
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,4 +99,3 @@ class PluginExampleChild extends CommonDBChild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
@ -66,10 +66,9 @@ class PluginExampleConfig extends CommonDBTM {
|
|||||||
Dropdown::showYesNo("configuration", $my_config['configuration']);
|
Dropdown::showYesNo("configuration", $my_config['configuration']);
|
||||||
echo "</td></tr>";
|
echo "</td></tr>";
|
||||||
|
|
||||||
|
|
||||||
echo "<tr class='tab_bg_2'>";
|
echo "<tr class='tab_bg_2'>";
|
||||||
echo "<td colspan='4' class='center'>";
|
echo "<td colspan='4' class='center'>";
|
||||||
echo "<input type='submit' name='update' class='submit' value=\""._sx('button','Save')."\">";
|
echo "<input type='submit' name='update' class='submit' value=\""._sx('button', 'Save')."\">";
|
||||||
echo "</td></tr>";
|
echo "</td></tr>";
|
||||||
|
|
||||||
echo "</table></div>";
|
echo "</table></div>";
|
||||||
@ -85,4 +84,3 @@ class PluginExampleConfig extends CommonDBTM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
@ -46,4 +46,3 @@ class PluginExampleDeviceCamera extends CommonDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
@ -44,4 +44,3 @@ class PluginExampleDropdown extends CommonDropdown {
|
|||||||
return __('Plugin Example Dropdowns', 'example');
|
return __('Plugin Example Dropdowns', 'example');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
// Class of the defined type
|
// Class of the defined type
|
||||||
class PluginExampleExample extends CommonDBTM {
|
class PluginExampleExample extends CommonDBTM {
|
||||||
|
|
||||||
static $tags = '[EXAMPLE_ID]';
|
static $tags = '[EXAMPLE_ID]';
|
||||||
|
|
||||||
// Should return the localized name of the type
|
// Should return the localized name of the type
|
||||||
@ -68,8 +68,8 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
static function getMenuName() {
|
static function getMenuName() {
|
||||||
return __('Example plugin');
|
return __('Example plugin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CommonGLPI::getAdditionalMenuLinks()
|
* @see CommonGLPI::getAdditionalMenuLinks()
|
||||||
**/
|
**/
|
||||||
@ -92,8 +92,8 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
|
|
||||||
return $ong;
|
return $ong;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showForm($ID, $options = array()) {
|
function showForm($ID, $options = array()) {
|
||||||
global $CFG_GLPI;
|
global $CFG_GLPI;
|
||||||
|
|
||||||
$this->initForm($ID, $options);
|
$this->initForm($ID, $options);
|
||||||
@ -105,12 +105,12 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
echo "<td>";
|
echo "<td>";
|
||||||
echo $ID;
|
echo $ID;
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
|
|
||||||
$this->showFormButtons($options);
|
$this->showFormButtons($options);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchOptions() {
|
function getSearchOptions() {
|
||||||
|
|
||||||
$tab = array();
|
$tab = array();
|
||||||
@ -169,7 +169,7 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
static function cronSample($task) {
|
static function cronSample($task) {
|
||||||
|
|
||||||
$task->log("Example log message from class");
|
$task->log("Example log message from class");
|
||||||
$r = mt_rand(0,$task->fields['param']);
|
$r = mt_rand(0, $task->fields['param']);
|
||||||
usleep(1000000+$r*1000);
|
usleep(1000000+$r*1000);
|
||||||
$task->setVolume($r);
|
$task->setVolume($r);
|
||||||
|
|
||||||
@ -335,25 +335,25 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
case "in" :
|
case "in" :
|
||||||
//TRANS: %1$s is the start time of a planned item, %2$s is the end
|
//TRANS: %1$s is the start time of a planned item, %2$s is the end
|
||||||
printf(__('From %1$s to %2$s :'),
|
printf(__('From %1$s to %2$s :'),
|
||||||
date("H:i",strtotime($val["begin"])), date("H:i",strtotime($val["end"]))) ;
|
date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "through" :
|
case "through" :
|
||||||
echo Html::resume_text($val["name"],80);
|
echo Html::resume_text($val["name"], 80);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "begin" :
|
case "begin" :
|
||||||
//TRANS: %s is the start time of a planned item
|
//TRANS: %s is the start time of a planned item
|
||||||
printf(__('Start at %s:'), date("H:i", strtotime($val["begin"]))) ;
|
printf(__('Start at %s:'), date("H:i", strtotime($val["begin"])));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "end" :
|
case "end" :
|
||||||
//TRANS: %s is the end time of a planned item
|
//TRANS: %s is the end time of a planned item
|
||||||
printf(__('End at %s:'), date("H:i", strtotime($val["end"]))) ;
|
printf(__('End at %s:'), date("H:i", strtotime($val["end"])));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
echo "<br>";
|
echo "<br>";
|
||||||
echo Html::resume_text($val["name"],80);
|
echo Html::resume_text($val["name"], 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,7 +367,7 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
**/
|
**/
|
||||||
static function getHistoryEntry($data) {
|
static function getHistoryEntry($data) {
|
||||||
|
|
||||||
switch($data['linked_action'] - Log::HISTORY_PLUGIN) {
|
switch ($data['linked_action'] - Log::HISTORY_PLUGIN) {
|
||||||
case 0:
|
case 0:
|
||||||
return __('History from plugin example', 'example');
|
return __('History from plugin example', 'example');
|
||||||
}
|
}
|
||||||
@ -376,8 +376,8 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
////// SPECIFIC MODIF MASSIVE FUNCTIONS ///////
|
////// SPECIFIC MODIF MASSIVE FUNCTIONS ///////
|
||||||
/**
|
/**
|
||||||
* @since version 0.85
|
* @since version 0.85
|
||||||
*
|
*
|
||||||
@ -406,14 +406,14 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
switch ($ma->getAction()) {
|
switch ($ma->getAction()) {
|
||||||
case 'DoIt':
|
case 'DoIt':
|
||||||
echo " <input type='hidden' name='toto' value='1'>".
|
echo " <input type='hidden' name='toto' value='1'>".
|
||||||
Html::submit(_x('button','Post'), array('name' => 'massiveaction')).
|
Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')).
|
||||||
" ".__('Write in item history', 'example');
|
" ".__('Write in item history', 'example');
|
||||||
return true;
|
return true;
|
||||||
case 'do_nothing' :
|
case 'do_nothing' :
|
||||||
echo " ".Html::submit(_x('button','Post'), array('name' => 'massiveaction')).
|
echo " ".Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')).
|
||||||
" ".__('but do nothing :)', 'example');
|
" ".__('but do nothing :)', 'example');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return parent::showMassiveActionsSubForm($ma);
|
return parent::showMassiveActionsSubForm($ma);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,17 +471,15 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
}
|
}
|
||||||
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
|
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function generateLinkContents($link, CommonDBTM $item) {
|
static function generateLinkContents($link, CommonDBTM $item) {
|
||||||
|
|
||||||
if (strstr($link,"[EXAMPLE_ID]")) {
|
if (strstr($link, "[EXAMPLE_ID]")) {
|
||||||
$link = str_replace("[EXAMPLE_ID]", $item->getID(),$link);
|
$link = str_replace("[EXAMPLE_ID]", $item->getID(), $link);
|
||||||
return array($link);
|
return array($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return parent::generateLinkContents($link, $item);
|
return parent::generateLinkContents($link, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
@ -49,4 +49,3 @@ class PluginExampleItem_DeviceCamera extends Item_Devices {
|
|||||||
static protected $notable = false;
|
static protected $notable = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GLPI_ROOT')){
|
if (!defined('GLPI_ROOT')) {
|
||||||
die("Sorry. You can't access directly to this file");
|
die("Sorry. You can't access directly to this file");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,4 +44,3 @@ class PluginExampleNotificationTargetExample extends NotificationTarget {
|
|||||||
$this->datas['##example.name##'] = __('Example', 'example');
|
$this->datas['##example.name##'] = __('Example', 'example');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
@ -80,4 +80,3 @@ class PluginExampleRuleTest extends Rule {
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -47,4 +47,3 @@ class PluginExampleRuleTestCollection extends RuleCollection {
|
|||||||
return 'Rulesengine test';
|
return 'Rulesengine test';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -30,23 +30,23 @@ along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/**
|
/**
|
||||||
* Summary of PluginExampleShowtabitem
|
* Summary of PluginExampleShowtabitem
|
||||||
* Example of pre_show_xxx and post_show_xxx implementation
|
* Example of pre_show_xxx and post_show_xxx implementation
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* pre_show_item will be fired before an item is shown
|
* pre_show_item will be fired before an item is shown
|
||||||
* ex: when viewing a ticket, change, computer,...
|
* ex: when viewing a ticket, change, computer,...
|
||||||
*
|
*
|
||||||
* will be fired at each sub-item
|
* will be fired at each sub-item
|
||||||
* ex: for each TicketTask, TicketFollowup, ...
|
* ex: for each TicketTask, TicketFollowup, ...
|
||||||
*
|
*
|
||||||
* post_show_item will be fired after the item show
|
* post_show_item will be fired after the item show
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* pre_show_tab will be fired before a tab is shown
|
* pre_show_tab will be fired before a tab is shown
|
||||||
* when tabs are loaded,
|
* when tabs are loaded,
|
||||||
* ex: when viewing the Followup tab
|
* ex: when viewing the Followup tab
|
||||||
*
|
*
|
||||||
* post_show_tab will be fired after the tab show
|
* post_show_tab will be fired after the tab show
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
class PluginExampleShowtabitem {
|
class PluginExampleShowtabitem {
|
||||||
|
|
||||||
@ -62,15 +62,15 @@ class PluginExampleShowtabitem {
|
|||||||
* Note: you may pass datas to post_show_tab using the $param['options'] array (see example below)
|
* Note: you may pass datas to post_show_tab using the $param['options'] array (see example below)
|
||||||
*/
|
*/
|
||||||
static function pre_show_tab($params) {
|
static function pre_show_tab($params) {
|
||||||
switch( $params['item']->getType() ) {
|
switch ($params['item']->getType()) {
|
||||||
case 'Ticket':
|
case 'Ticket':
|
||||||
if( $params['options']['itemtype']=='Ticket' && $params['options']['tabnum']==2) {
|
if ($params['options']['itemtype']=='Ticket' && $params['options']['tabnum']==2) {
|
||||||
// if tasks are not all done
|
// if tasks are not all done
|
||||||
// then prevent solution div to show
|
// then prevent solution div to show
|
||||||
// this is an example to prevent solving of ticket
|
// this is an example to prevent solving of ticket
|
||||||
if( true ) { // here you should test if some tasks are in todo status.
|
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
|
$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
|
echo "<div id='toHideSolution' style='display: none;'>"; // in order to hide the default solution div
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,9 +82,9 @@ class PluginExampleShowtabitem {
|
|||||||
* Note: you may get datas from pre_show_tab in $param['options'] array (see example below)
|
* Note: you may get datas from pre_show_tab in $param['options'] array (see example below)
|
||||||
*/
|
*/
|
||||||
static function post_show_tab($params) {
|
static function post_show_tab($params) {
|
||||||
switch( $params['item']->getType() ) {
|
switch ($params['item']->getType()) {
|
||||||
case 'Ticket':
|
case 'Ticket':
|
||||||
if( isset($params['options']['prevent_solution'])) {
|
if (isset($params['options']['prevent_solution'])) {
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "<div style='margin-bottom: 20px;' class='box'>
|
echo "<div style='margin-bottom: 20px;' class='box'>
|
||||||
<div class='box-tleft'>
|
<div class='box-tleft'>
|
||||||
@ -116,7 +116,7 @@ class PluginExampleShowtabitem {
|
|||||||
</div>
|
</div>
|
||||||
</div> ";
|
</div> ";
|
||||||
}
|
}
|
||||||
break ;
|
break;
|
||||||
|
|
||||||
case 'Computer':
|
case 'Computer':
|
||||||
break;
|
break;
|
||||||
@ -141,21 +141,22 @@ class PluginExampleShowtabitem {
|
|||||||
* Note: you may pass datas to post_show_item using the $param['options'] array
|
* Note: you may pass datas to post_show_item using the $param['options'] array
|
||||||
*/
|
*/
|
||||||
static function pre_show_item($params) {
|
static function pre_show_item($params) {
|
||||||
if(!is_array($params['item'])) {
|
if (!is_array($params['item'])) {
|
||||||
switch( $params['item']->getType() ) {
|
switch ($params['item']->getType()) {
|
||||||
case 'Ticket':
|
case 'Ticket':
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
case 'TicketTask' :
|
case 'TicketTask' :
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
case 'TicketFollowup' :
|
case 'TicketFollowup' :
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// here we are going to view a Solution
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// here we are going to view a Solution
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,21 +176,22 @@ class PluginExampleShowtabitem {
|
|||||||
* Note: you may get datas from pre_show_item using the $param['options'] array
|
* Note: you may get datas from pre_show_item using the $param['options'] array
|
||||||
*/
|
*/
|
||||||
static function post_show_item($params) {
|
static function post_show_item($params) {
|
||||||
if(!is_array($params['item'])) {
|
if (!is_array($params['item'])) {
|
||||||
switch( $params['item']->getType() ) {
|
switch ($params['item']->getType()) {
|
||||||
case 'Ticket':
|
case 'Ticket':
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
case 'TicketTask' :
|
case 'TicketTask' :
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
case 'TicketFollowup' :
|
case 'TicketFollowup' :
|
||||||
//echo 'test' ;
|
//echo 'test' ;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// here we are going to view a Solution
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// here we are going to view a Solution
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,13 @@
|
|||||||
//header("Location:../../central.php");
|
//header("Location:../../central.php");
|
||||||
|
|
||||||
// Entry menu case
|
// Entry menu case
|
||||||
define('GLPI_ROOT', '../..');
|
define('GLPI_ROOT', '../..');
|
||||||
include (GLPI_ROOT . "/inc/includes.php");
|
include (GLPI_ROOT . "/inc/includes.php");
|
||||||
|
|
||||||
Session::checkRight("config", "w");
|
Session::checkRight("config", "w");
|
||||||
|
|
||||||
Html::header("TITRE",$_SERVER['PHP_SELF'],"plugins");
|
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins");
|
||||||
|
|
||||||
echo "This is the plugin report page";
|
echo "This is the plugin report page";
|
||||||
|
|
||||||
Html::footer();
|
Html::footer();
|
||||||
?>
|
|
25
setup.php
25
setup.php
@ -66,7 +66,7 @@ function plugin_init_example() {
|
|||||||
Plugin::registerClass('PluginExampleDeviceCamera',
|
Plugin::registerClass('PluginExampleDeviceCamera',
|
||||||
array('device_types' => true));
|
array('device_types' => true));
|
||||||
|
|
||||||
if (version_compare(GLPI_VERSION,'9.1','ge')) {
|
if (version_compare(GLPI_VERSION, '9.1', 'ge')) {
|
||||||
if (class_exists('PluginExampleExample')) {
|
if (class_exists('PluginExampleExample')) {
|
||||||
Link::registerTag(PluginExampleExample::$tags);
|
Link::registerTag(PluginExampleExample::$tags);
|
||||||
}
|
}
|
||||||
@ -78,21 +78,21 @@ function plugin_init_example() {
|
|||||||
'tools' => 'PluginExampleExample');
|
'tools' => 'PluginExampleExample');
|
||||||
|
|
||||||
// Old menu style
|
// Old menu style
|
||||||
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
|
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
|
||||||
//
|
//
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
|
||||||
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
|
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
|
||||||
|
|
||||||
$PLUGIN_HOOKS["helpdesk_menu_entry"]['example'] = true;
|
$PLUGIN_HOOKS["helpdesk_menu_entry"]['example'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config page
|
// Config page
|
||||||
if (Session::haveRight('config',UPDATE)) {
|
if (Session::haveRight('config', UPDATE)) {
|
||||||
$PLUGIN_HOOKS['config_page']['example'] = 'config.php';
|
$PLUGIN_HOOKS['config_page']['example'] = 'config.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ function plugin_version_example() {
|
|||||||
function plugin_example_check_prerequisites() {
|
function plugin_example_check_prerequisites() {
|
||||||
|
|
||||||
// Strict version check (could be less strict, or could allow various version)
|
// Strict version check (could be less strict, or could allow various version)
|
||||||
if (version_compare(GLPI_VERSION,'0.85','lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) {
|
if (version_compare(GLPI_VERSION, '0.85', 'lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) {
|
||||||
if (method_exists('Plugin', 'messageIncompatible')) {
|
if (method_exists('Plugin', 'messageIncompatible')) {
|
||||||
echo Plugin::messageIncompatible('core', '0.85');
|
echo Plugin::messageIncompatible('core', '0.85');
|
||||||
} else {
|
} else {
|
||||||
@ -265,4 +265,3 @@ function plugin_example_check_config($verbose = false) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
5
stat.php
5
stat.php
@ -36,14 +36,13 @@
|
|||||||
//header("Location:../../central.php");
|
//header("Location:../../central.php");
|
||||||
|
|
||||||
// Entry menu case
|
// Entry menu case
|
||||||
define('GLPI_ROOT', '../..');
|
define('GLPI_ROOT', '../..');
|
||||||
include (GLPI_ROOT . "/inc/includes.php");
|
include (GLPI_ROOT . "/inc/includes.php");
|
||||||
|
|
||||||
Session::checkRight("config", "w");
|
Session::checkRight("config", "w");
|
||||||
|
|
||||||
Html::header("TITLE",$_SERVER['PHP_SELF'],"plugins");
|
Html::header("TITLE", $_SERVER['PHP_SELF'], "plugins");
|
||||||
|
|
||||||
echo "This is the plugin stat page";
|
echo "This is the plugin stat page";
|
||||||
|
|
||||||
Html::footer();
|
Html::footer();
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user