CS + call functions

git-svn-id: https://forge.glpi-project.org/svn/example/trunk@172 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
yllen
2011-09-08 09:51:40 +00:00
parent 6188cf8ad0
commit acf0490727
6 changed files with 90 additions and 81 deletions

View File

@ -36,23 +36,24 @@
// Class of the defined type
class PluginExampleExample extends CommonDBTM {
// From CommonDBTM
public $table = 'glpi_plugin_example_examples';
public $type = 'PluginExampleExample';
// Should return the localized name of the type
static function getTypeName() {
return 'Example Type';
}
function canCreate() {
if (isset($_SESSION["glpi_plugin_example_profile"])) {
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w');
}
return false;
}
function canView() {
if (isset($_SESSION["glpi_plugin_example_profile"])) {
return ($_SESSION["glpi_plugin_example_profile"]['example'] == 'w'
|| $_SESSION["glpi_plugin_example_profile"]['example'] == 'r');
@ -60,6 +61,7 @@ class PluginExampleExample extends CommonDBTM {
return false;
}
function getSearchOptions() {
global $LANG;
@ -87,6 +89,7 @@ class PluginExampleExample extends CommonDBTM {
return $tab;
}
/**
* Give localized information about 1 task
*
@ -105,6 +108,7 @@ class PluginExampleExample extends CommonDBTM {
return array();
}
/**
* Execute 1 task manage by the plugin
*
@ -123,16 +127,17 @@ class PluginExampleExample extends CommonDBTM {
return 1;
}
// Hook done on before add item case
static function pre_item_add_example($item) {
addMessageAfterRedirect("Pre Add Computer Hook",true);
Session::addMessageAfterRedirect("Pre Add Computer Hook", true);
}
// Hook done on add item case
static function item_add_example($item) {
addMessageAfterRedirect("Add Computer Hook, ID=".$item->getField('id'),true);
Session::addMessageAfterRedirect("Add Computer Hook, ID=".$item->getField('id'), true);
return true;
}

View File

@ -36,7 +36,6 @@ if (!defined('GLPI_ROOT')){
class PluginExampleNotificationTargetExample extends NotificationTarget {
function getEvents() {
global $LANG;
return array ('alert' => 'alert example');
}

View File

@ -47,21 +47,23 @@ if (!defined('GLPI_ROOT')) {
class PluginExampleRuleTest extends Rule {
// From Rule
public $right='rule_ocs';
public $can_sort=true;
public $right = 'rule_ocs';
public $can_sort = true;
function getTitle() {
global $LANG;
return 'test';
}
function maxActionsCount() {
return 1;
}
function getCriterias() {
global $LANG;
$criterias = array();
$criterias['name']['field'] = 'name';
$criterias['name']['name'] = $LANG['help'][31];
@ -70,8 +72,10 @@ class PluginExampleRuleTest extends Rule {
return $criterias;
}
function getActions() {
global $LANG;
$actions = array();
$actions['softwarecategories_id']['name'] = $LANG['common'][36];
$actions['softwarecategories_id']['type'] = 'dropdown';
@ -79,5 +83,4 @@ class PluginExampleRuleTest extends Rule {
return $actions;
}
}
?>

View File

@ -40,15 +40,12 @@ if (!defined('GLPI_ROOT')) {
class PluginExampleRuleTestCollection extends RuleCollection {
// From RuleCollection
public $stop_on_first_match=true;
public $right='rule_ocs';
public $menu_option='test';
public $stop_on_first_match = true;
public $right = 'rule_ocs';
public $menu_option = 'test';
function getTitle() {
global $LANG;
return 'Rulesengine test';
}
}
?>