mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
fix add hook + remove static in canView / canCreate
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@121 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
8176e19a78
commit
0ee472bd2a
30
hook.php
30
hook.php
@ -351,29 +351,27 @@ function plugin_item_update_example($parm) {
|
|||||||
|
|
||||||
|
|
||||||
// Hook done on before add item case
|
// Hook done on before add item case
|
||||||
function plugin_pre_item_add_example($input) {
|
function plugin_pre_item_add_example($item) {
|
||||||
|
|
||||||
if (isset($input["_item_type_"])) {
|
switch (get_class($item)) {
|
||||||
switch ($input["_item_type_"]) {
|
case 'Computer' :
|
||||||
case 'Computer' :
|
// Manipulate data if needed
|
||||||
// Manipulate data if needed
|
if (isset($item->input['comment'])) {
|
||||||
addMessageAfterRedirect("Pre Add Computer Hook",true);
|
//$item->input['comment'] .= addslashes("\nFrom Example plugin");
|
||||||
break;
|
}
|
||||||
}
|
addMessageAfterRedirect("Pre Add Computer Hook",true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hook done on add item case
|
// Hook done on add item case
|
||||||
function plugin_item_add_example($parm) {
|
function plugin_item_add_example($item) {
|
||||||
|
|
||||||
if (isset($parm["type"])) {
|
switch (get_class($item)) {
|
||||||
switch ($parm["type"]) {
|
case 'Computer' :
|
||||||
case 'Computer' :
|
addMessageAfterRedirect("Add Computer Hook, ID=".$item->getField('id'),true);
|
||||||
addMessageAfterRedirect("Add Computer Hook",true);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,14 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
return 'Example Type';
|
return 'Example Type';
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canCreate() {
|
function canCreate() {
|
||||||
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
||||||
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w');
|
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canView() {
|
function canView() {
|
||||||
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
if (isset($_SESSION["glpi_plugin_example_profile"])) {
|
||||||
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w'
|
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w'
|
||||||
|| $_SESSION["glpi_plugin_example_profile"]['example'] == 'r');
|
|| $_SESSION["glpi_plugin_example_profile"]['example'] == 'r');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user