mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
Massive Actions
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@29 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
48480974d9
commit
2a3d7c78c2
1
db.sql
1
db.sql
@ -1,6 +1,7 @@
|
||||
CREATE TABLE `glpi_plugin_example` (
|
||||
`ID` int(11) NOT NULL auto_increment,
|
||||
`name` varchar(255) collate utf8_unicode_ci default NULL,
|
||||
`serial` varchar(255) collate utf8_unicode_ci NOT NULL,
|
||||
`FK_dropdown` int(11) NOT NULL default '0',
|
||||
`deleted` smallint(6) NOT NULL default '0',
|
||||
`is_template` smallint(6) NOT NULL default '0',
|
||||
|
103
setup.php
103
setup.php
@ -94,12 +94,6 @@ function plugin_version_example(){
|
||||
return array( 'name' => 'Plugin Example',
|
||||
'version' => '0.0.1');
|
||||
}
|
||||
// Define dropdown relations
|
||||
function plugin_example_getDatabaseRelations(){
|
||||
//
|
||||
return array("glpi_dropdown_plugin_example"=>array("glpi_plugin_example"=>"FK_dropdown"));
|
||||
}
|
||||
|
||||
|
||||
// Define rights for the plugin types
|
||||
function plugin_example_haveTypeRight($type,$right){
|
||||
@ -113,6 +107,13 @@ function plugin_example_haveTypeRight($type,$right){
|
||||
}
|
||||
}
|
||||
|
||||
// Define dropdown relations
|
||||
function plugin_example_getDatabaseRelations(){
|
||||
//
|
||||
return array("glpi_dropdown_plugin_example"=>array("glpi_plugin_example"=>"FK_dropdown"));
|
||||
}
|
||||
|
||||
|
||||
// Define Dropdown tables to be manage in GLPI :
|
||||
function plugin_example_getDropdown(){
|
||||
// Table => Name
|
||||
@ -139,6 +140,11 @@ function plugin_example_getSearchOption(){
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][2]['linkfield']='FK_dropdown';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][2]['name']='Dropdown';
|
||||
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['table']='glpi_plugin_example';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['field']='serial';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['linkfield']='serial';
|
||||
$sopt[PLUGIN_EXAMPLE_TYPE][3]['name']='Serial';
|
||||
|
||||
return $sopt;
|
||||
}
|
||||
|
||||
@ -223,6 +229,91 @@ function plugin_example_addOrderBy($type,$ID,$order,$key=0){
|
||||
// }
|
||||
return "";
|
||||
}
|
||||
//////////////////////////////
|
||||
////// SPECIFIC MODIF MASSIVE FUNCTIONS ///////
|
||||
|
||||
function plugin_example_MassiveActions($type){
|
||||
global $LANG;
|
||||
switch ($type){
|
||||
case PLUGIN_EXAMPLE_TYPE:
|
||||
return array(
|
||||
// GLPI core one
|
||||
"add_document"=>$LANG["document"][16],
|
||||
// Specific one
|
||||
"do_nothing"=>'Do Nothing - just for fun'
|
||||
);
|
||||
break;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
function plugin_example_MassiveActionsDisplay($type,$action){
|
||||
global $LANG;
|
||||
switch ($type){
|
||||
case PLUGIN_EXAMPLE_TYPE:
|
||||
switch ($action){
|
||||
// No case for add_document : use GLPI core one
|
||||
case "do_nothing":
|
||||
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" > but do nothing :)";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function plugin_example_MassiveActionsProcess($data){
|
||||
global $LANG;
|
||||
|
||||
switch ($data['action']){
|
||||
case 'do_nothing':
|
||||
if ($data['device_type']==PLUGIN_EXAMPLE_TYPE){
|
||||
print_r($data);
|
||||
$ci =new CommonItem();
|
||||
$_SESSION["MESSAGE_AFTER_REDIRECT"].= "Right it is the type I want...<br>";
|
||||
$_SESSION["MESSAGE_AFTER_REDIRECT"].= "But... I say I will do nothing for :<br>";
|
||||
foreach ($data['item'] as $key => $val){
|
||||
if ($val==1) {
|
||||
if ($ci->getFromDB($data["device_type"],$key)){
|
||||
$_SESSION["MESSAGE_AFTER_REDIRECT"].= "- ".$ci->getField("name")."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function plugin_example_MassiveActionsFieldsDisplay($type,$table,$field,$linkfield){
|
||||
global $LINK_ID_TABLE;
|
||||
if ($table==$LINK_ID_TABLE[$type]){
|
||||
// Table fields
|
||||
switch ($table.".".$field){
|
||||
case 'glpi_plugin_example.serial':
|
||||
echo "Not really specific - Just for example ";
|
||||
autocompletionTextField($linkfield,$table,$field);
|
||||
// dropdownYesNo($linkfield);
|
||||
// Need to return true if specific display
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Linked Fields
|
||||
switch ($table.".".$field){
|
||||
case "glpi_dropdown_plugin_example.name" :
|
||||
echo "Not really specific - Just for example ";
|
||||
dropdown($table,$linkfield,1,$_SESSION["glpiactive_entity"]);
|
||||
//dropdownUsers($linkfield,0,"own_ticket",0,1,$_SESSION["glpiactive_entity"]);
|
||||
// Need to return true if specific display
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Need to return false on non display item
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
// Hook done on update item case
|
||||
|
Loading…
x
Reference in New Issue
Block a user