remove XXX_TYPE and switch to Plugin::registerClass()

git-svn-id: https://forge.glpi-project.org/svn/example/trunk@108 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
remicollet 2009-12-07 09:46:56 +00:00
parent fc2231adcf
commit 3b5913f295
3 changed files with 17 additions and 17 deletions

View File

@ -122,7 +122,7 @@ function plugin_example_addLeftJoin($type,$ref_table,$new_table,$linkfield){
function plugin_example_forceGroupBy($type){ function plugin_example_forceGroupBy($type){
switch ($type){ switch ($type){
case PLUGIN_EXAMPLE_TYPE : case 'PluginExampleExample' :
// Force add GROUP BY IN REQUEST // Force add GROUP BY IN REQUEST
return true; return true;
break; break;
@ -224,7 +224,7 @@ function plugin_example_MassiveActions($type){
break; break;
// Actions for types provided by the plugin // Actions for types provided by the plugin
case PLUGIN_EXAMPLE_TYPE : case 'PluginExampleExample' :
return array( return array(
// GLPI core one // GLPI core one
"add_document"=>$LANG["document"][16], "add_document"=>$LANG["document"][16],
@ -247,7 +247,7 @@ function plugin_example_MassiveActionsDisplay($type,$action){
break; break;
} }
break; break;
case PLUGIN_EXAMPLE_TYPE: case 'PluginExampleExample':
switch ($action){ switch ($action){
// No case for add_document : use GLPI core one // No case for add_document : use GLPI core one
case "do_nothing": case "do_nothing":
@ -280,7 +280,7 @@ function plugin_example_MassiveActionsProcess($data){
} }
break; break;
case 'do_nothing': case 'do_nothing':
if ($data['device_type']==PLUGIN_EXAMPLE_TYPE){ if ($data['device_type']=='PluginExampleExample'){
$ci =new CommonItem(); $ci =new CommonItem();
addMessageAfterRedirect("Right it is the type I want..."); addMessageAfterRedirect("Right it is the type I want...");
addMessageAfterRedirect("But... I say I will do nothing for :"); addMessageAfterRedirect("But... I say I will do nothing for :");
@ -673,7 +673,7 @@ function plugin_example_cron_info($name) {
// Do special actions for dynamic report // Do special actions for dynamic report
function plugin_example_dynamicReport($parm){ function plugin_example_dynamicReport($parm){
if ($parm["item_type"]==PLUGIN_EXAMPLE_TYPE){ if ($parm["item_type"]=='PluginExampleExample'){
// Do all what you want for export depending on $parm // Do all what you want for export depending on $parm
echo "Personalized export for type ".$parm["display_type"]; echo "Personalized export for type ".$parm["display_type"];
echo 'with additional datas : <br>'; echo 'with additional datas : <br>';
@ -690,7 +690,7 @@ function plugin_example_dynamicReport($parm){
// Add parameters to printPager in search system // Add parameters to printPager in search system
function plugin_example_addParamFordynamicReport($device_type){ function plugin_example_addParamFordynamicReport($device_type){
if ($device_type==PLUGIN_EXAMPLE_TYPE){ if ($device_type=='PluginExampleExample'){
// Return array data containing all params to add : may be single data or array data // Return array data containing all params to add : may be single data or array data
// Search config are available from session variable // Search config are available from session variable
return array( return array(
@ -779,7 +779,7 @@ function plugin_example_uninstall(){
function plugin_example_AssignToTicket($types) function plugin_example_AssignToTicket($types)
{ {
$types[PLUGIN_EXAMPLE_TYPE] = "Example"; $types['PluginExampleExample'] = "Example";
return $types; return $types;
} }

View File

@ -35,8 +35,8 @@
$NEEDED_ITEMS=array("search"); $NEEDED_ITEMS=array("search");
define('GLPI_ROOT', '../..'); define('GLPI_ROOT', '../..');
include (GLPI_ROOT . "/inc/includes.php"); include (GLPI_ROOT . "/inc/includes.php");
if ($_SESSION["glpiactiveprofile"]["interface"] == "central"){ if ($_SESSION["glpiactiveprofile"]["interface"] == "central"){
commonHeader("TITRE", $_SERVER['PHP_SELF'],"plugins","example","optionname"); commonHeader("TITRE", $_SERVER['PHP_SELF'],"plugins","example","optionname");
@ -44,13 +44,13 @@ if ($_SESSION["glpiactiveprofile"]["interface"] == "central"){
helpHeader("TITRE", $_SERVER['PHP_SELF']); helpHeader("TITRE", $_SERVER['PHP_SELF']);
} }
checkTypeRight(PLUGIN_EXAMPLE_TYPE,"r"); checkTypeRight('PluginExampleExample',"r");
manageGetValuesInSearch(PLUGIN_EXAMPLE_TYPE); manageGetValuesInSearch('PluginExampleExample');
searchForm(PLUGIN_EXAMPLE_TYPE,$_GET); searchForm('PluginExampleExample',$_GET);
showList(PLUGIN_EXAMPLE_TYPE,$_GET); showList('PluginExampleExample',$_GET);
commonFooter(); commonFooter();
?> ?>

View File

@ -38,7 +38,7 @@ function plugin_init_example() {
global $PLUGIN_HOOKS,$LANG,$CFG_GLPI; global $PLUGIN_HOOKS,$LANG,$CFG_GLPI;
// Params : plugin name - string type - ID - Array of attributes // Params : plugin name - string type - ID - Array of attributes
registerPluginType('example', 'PLUGIN_EXAMPLE_TYPE', 'PluginExampleExample', array( Plugin::registerClass('PluginExampleExample', array(
'classname' => 'PluginExampleExample', 'classname' => 'PluginExampleExample',
'tablename' => 'glpi_plugin_example_example', 'tablename' => 'glpi_plugin_example_example',
'formpage' => 'front/example.form.php', 'formpage' => 'front/example.form.php',
@ -53,7 +53,7 @@ function plugin_init_example() {
)); ));
// Params : plugin name - string type - ID - Array of attributes // Params : plugin name - string type - ID - Array of attributes
registerPluginType('example', 'PLUGIN_EXAMPLEDROPDOWN_TYPE', 'PluginExampleDropdown', array( Plugin::registerClass('PluginExampleDropdown', array(
'classname' => 'PluginExampleDropdown', 'classname' => 'PluginExampleDropdown',
'tablename' => 'glpi_plugin_example_dropdown', 'tablename' => 'glpi_plugin_example_dropdown',
'typename' => 'Example Dropdown Type', 'typename' => 'Example Dropdown Type',
@ -61,7 +61,7 @@ function plugin_init_example() {
'searchpage' => 'front/dropdown.php')); 'searchpage' => 'front/dropdown.php'));
// Display a menu entry ? // Display a menu entry ?
if (plugin_example_haveTypeRight(PLUGIN_EXAMPLE_TYPE,'r')) { // Right set in change_profile hook if (plugin_example_haveTypeRight('PluginExampleExample','r')) { // Right set in change_profile hook
$PLUGIN_HOOKS['menu_entry']['example'] = true; $PLUGIN_HOOKS['menu_entry']['example'] = true;
$PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title']="Search"; $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title']="Search";
@ -184,7 +184,7 @@ function plugin_example_haveTypeRight($type,$right){
return false; return false;
} }
switch ($type){ switch ($type){
case PLUGIN_EXAMPLE_TYPE : case 'PluginExampleExample' :
// Evaluate the right from data saved in session by change_profile hook // Evaluate the right from data saved in session by change_profile hook
return ($right=='r' || $_SESSION["glpi_plugin_example_profile"]=='w'); return ($right=='r' || $_SESSION["glpi_plugin_example_profile"]=='w');
} }