diff --git a/config.php b/config.php index b2fe132..9d01e7b 100755 --- a/config.php +++ b/config.php @@ -44,7 +44,6 @@ Session::checkRight("config", UPDATE); // To be available when plugin in not activated 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'); Html::footer(); -?> diff --git a/front/devicecamera.form.php b/front/devicecamera.form.php index 5b75494..9bf7265 100644 --- a/front/devicecamera.form.php +++ b/front/devicecamera.form.php @@ -36,4 +36,3 @@ include ('../../../inc/includes.php'); $dropdown = new PluginExampleDeviceCamera(); include (GLPI_ROOT . "/front/dropdown.common.form.php"); -?> \ No newline at end of file diff --git a/front/devicecamera.php b/front/devicecamera.php index f04da77..0eb769e 100644 --- a/front/devicecamera.php +++ b/front/devicecamera.php @@ -36,4 +36,3 @@ include ('../../../inc/includes.php'); $dropdown = new PluginExampleDeviceCamera(); include (GLPI_ROOT . "/front/dropdown.common.php"); -?> diff --git a/front/dropdown.form.php b/front/dropdown.form.php index 63cf501..cfb0669 100644 --- a/front/dropdown.form.php +++ b/front/dropdown.form.php @@ -35,8 +35,7 @@ include ('../../../inc/includes.php'); -Plugin::load('example',true); +Plugin::load('example', true); $dropdown = new PluginExampleDropdown(); include (GLPI_ROOT . "/front/dropdown.common.form.php"); -?> \ No newline at end of file diff --git a/front/dropdown.php b/front/dropdown.php index 395b837..51968f9 100644 --- a/front/dropdown.php +++ b/front/dropdown.php @@ -35,8 +35,7 @@ include ('../../../inc/includes.php'); -Plugin::load('example',true); +Plugin::load('example', true); $dropdown = new PluginExampleDropdown(); include (GLPI_ROOT . "/front/dropdown.common.php"); -?> diff --git a/front/example.form.php b/front/example.form.php index 7fe4b86..e6a3fff 100644 --- a/front/example.form.php +++ b/front/example.form.php @@ -35,7 +35,7 @@ include ('../../../inc/includes.php'); if ($_SESSION["glpiactiveprofile"]["interface"] == "central") { - Html::header("TITRE", $_SERVER['PHP_SELF'],"plugins","pluginexampleexample",""); + Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", ""); } else { Html::helpHeader("TITRE", $_SERVER['PHP_SELF']); } @@ -44,4 +44,3 @@ $example = new PluginExampleExample(); $example->display($_GET); Html::footer(); -?> \ No newline at end of file diff --git a/front/example.php b/front/example.php index 0b9f8fa..4f14316 100755 --- a/front/example.php +++ b/front/example.php @@ -35,7 +35,7 @@ include ('../../../inc/includes.php'); if ($_SESSION["glpiactiveprofile"]["interface"] == "central") { - Html::header("TITRE", $_SERVER['PHP_SELF'],"plugins","pluginexampleexample",""); + Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", ""); } else { Html::helpHeader("TITRE", $_SERVER['PHP_SELF']); } @@ -46,4 +46,3 @@ if ($_SESSION["glpiactiveprofile"]["interface"] == "central") { Search::show('PluginExampleExample'); Html::footer(); -?> \ No newline at end of file diff --git a/front/popup.php b/front/popup.php index ac6c491..44ef61d 100644 --- a/front/popup.php +++ b/front/popup.php @@ -38,17 +38,17 @@ if (isset($_GET["popup"])) { if (isset($_SESSION["glpipopup"]["name"])) { switch ($_SESSION["glpipopup"]["name"]) { case "test_rule" : - Html::popHeader(__('Test'),$_SERVER['PHP_SELF']); + Html::popHeader(__('Test'), $_SERVER['PHP_SELF']); include "../../../front/rule.test.php"; break; 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"; break; case "show_cache" : - Html::popHeader(__('Cache information'),$_SERVER['PHP_SELF']); + Html::popHeader(__('Cache information'), $_SERVER['PHP_SELF']); include "../../../front/rule.cache.php"; break; } @@ -56,4 +56,3 @@ if (isset($_SESSION["glpipopup"]["name"])) { echo ""; Html::popFooter(); } -?> \ No newline at end of file diff --git a/front/ruletest.form.php b/front/ruletest.form.php index b17a0a0..ba1ebbf 100644 --- a/front/ruletest.form.php +++ b/front/ruletest.form.php @@ -38,4 +38,3 @@ include ('../../../inc/includes.php'); $rulecollection = new PluginExampleRuleTestCollection(); include (GLPI_ROOT . "/front/rule.common.form.php"); -?> diff --git a/front/ruletest.php b/front/ruletest.php index 79e89e0..cee6ee7 100644 --- a/front/ruletest.php +++ b/front/ruletest.php @@ -38,4 +38,3 @@ include ('../../../inc/includes.php'); $rulecollection = new PluginExampleRuleTestCollection(); include (GLPI_ROOT . "/front/rule.common.php"); -?> diff --git a/hook.php b/hook.php index 39b17da..f234bec 100644 --- a/hook.php +++ b/hook.php @@ -36,10 +36,10 @@ // And to save it in the session function plugin_change_profile_example() { // For example : same right of computer - if (Session::haveRight('computer','w')) { + if (Session::haveRight('computer', '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'); } else { @@ -116,7 +116,7 @@ function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables) // Example of default JOIN clause // No need of the function if you do not have specific cases switch ($type) { -// case "PluginExampleExample" : + // case "PluginExampleExample" : case "MyType" : return Search::addLeftJoin($type, $ref_table, $already_link_tables, "newtable", "linkfield"); @@ -129,7 +129,7 @@ function plugin_example_addDefaultSelect($type) { // Example of default SELECT item to be added // No need of the function if you do not have specific cases switch ($type) { -// case "PluginExampleExample" : + // case "PluginExampleExample" : case "MyType" : return "`mytable`.`myfield` = 'myvalue' AS MYNAME, "; } @@ -141,7 +141,7 @@ function plugin_example_addDefaultWhere($type) { // Example of default WHERE item to be added // No need of the function if you do not have specific cases switch ($type) { -// case "PluginExampleExample" : + // case "PluginExampleExample" : case "MyType" : return " `mytable`.`myfield` = 'myvalue' "; } @@ -175,20 +175,20 @@ function plugin_example_addWhere($link, $nott, $type, $ID, $val, $searchtype) { $table = $searchopt[$ID]["table"]; $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 // No need of the function if you do not have specific cases - switch ($table.".".$field) { - /*case "glpi_plugin_example.name" : - $ADD = ""; - if ($nott && $val!="NULL") { - $ADD = " OR `$table`.`$field` IS NULL"; - } - return $link." (`$table`.`$field` $SEARCH ".$ADD." ) ";*/ - case "glpi_plugin_example_examples.serial" : - return $link." `$table`.`$field` = '$val' "; - } + switch ($table.".".$field) { + /*case "glpi_plugin_example.name" : + $ADD = ""; + if ($nott && $val!="NULL") { + $ADD = " OR `$table`.`$field` IS NULL"; + } + return $link." (`$table`.`$field` $SEARCH ".$ADD." ) ";*/ + case "glpi_plugin_example_examples.serial" : + return $link." `$table`.`$field` = '$val' "; + } return ""; } @@ -199,7 +199,7 @@ function plugin_example_addHaving($link, $nott, $type, $ID, $val, $num) { $table = $searchopt[$ID]["table"]; $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 // 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"]; $field = $searchopt[$ID]["field"]; -// Example of standard Select clause but use it ONLY for specific Select -// No need of the function if you do not have specific cases -// switch ($table.".".$field) { -// case "glpi_plugin_example.name" : -// return $table.".".$field." AS ITEM_$num, "; -// } + // Example of standard Select clause but use it ONLY for specific Select + // No need of the function if you do not have specific cases + // switch ($table.".".$field) { + // case "glpi_plugin_example.name" : + // return $table.".".$field." AS ITEM_$num, "; + // } return ""; } @@ -236,12 +236,12 @@ function plugin_example_addOrderBy($type,$ID,$order,$key=0) { $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; -// 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 -// switch ($table.".".$field) { -// case "glpi_plugin_example.name" : -// return " ORDER BY $table.$field $order "; -// } + // 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 + // switch ($table.".".$field) { + // case "glpi_plugin_example.name" : + // return " ORDER BY $table.$field $order "; + // } return ""; } @@ -336,7 +336,7 @@ function plugin_pre_item_update_example($item) { // Hook done on update item case 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; } @@ -344,7 +344,7 @@ function plugin_item_update_example($item) { // Hook done on get empty item case function plugin_item_empty_example($item) { 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; } return true; @@ -354,13 +354,13 @@ function plugin_item_empty_example($item) { // Hook done on before delete item case function plugin_pre_item_delete_example($object) { // 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 function plugin_item_delete_example($object) { - Session::addMessageAfterRedirect(__("Delete Computer Hook", 'example'),true); + Session::addMessageAfterRedirect(__("Delete Computer Hook", 'example'), true); return true; } @@ -368,13 +368,13 @@ function plugin_item_delete_example($object) { // Hook done on before purge item case function plugin_pre_item_purge_example($object) { // 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 function plugin_item_purge_example($object) { - Session::addMessageAfterRedirect(__("Purge Computer Hook", 'example'),true); + Session::addMessageAfterRedirect(__("Purge Computer Hook", 'example'), true); return true; } @@ -403,7 +403,7 @@ function plugin_item_restore_example($item) { // Hook done on restore item case 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 - 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'])); return false; @@ -606,9 +606,9 @@ function plugin_example_postinit() { global $CFG_GLPI; // All plugins are initialized, so all types are registered - foreach (Infocom::getItemtypesThatCanHave() as $type) { + //foreach (Infocom::getItemtypesThatCanHave() as $type) { // do something - } + //} } diff --git a/inc/child.class.php b/inc/child.class.php index 9c779fa..3ed3701 100644 --- a/inc/child.class.php +++ b/inc/child.class.php @@ -99,4 +99,3 @@ class PluginExampleChild extends CommonDBChild { } } -?> \ No newline at end of file diff --git a/inc/config.class.php b/inc/config.class.php index 59e731c..c74310f 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -66,10 +66,9 @@ class PluginExampleConfig extends CommonDBTM { Dropdown::showYesNo("configuration", $my_config['configuration']); echo ""; - echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; @@ -85,4 +84,3 @@ class PluginExampleConfig extends CommonDBTM { } } -?> \ No newline at end of file diff --git a/inc/devicecamera.class.php b/inc/devicecamera.class.php index cb31d44..80ac7b1 100644 --- a/inc/devicecamera.class.php +++ b/inc/devicecamera.class.php @@ -46,4 +46,3 @@ class PluginExampleDeviceCamera extends CommonDevice { } } -?> \ No newline at end of file diff --git a/inc/dropdown.class.php b/inc/dropdown.class.php index 8b5f8d1..5347219 100644 --- a/inc/dropdown.class.php +++ b/inc/dropdown.class.php @@ -44,4 +44,3 @@ class PluginExampleDropdown extends CommonDropdown { return __('Plugin Example Dropdowns', 'example'); } } -?> diff --git a/inc/example.class.php b/inc/example.class.php index 0a73810..cd9516a 100644 --- a/inc/example.class.php +++ b/inc/example.class.php @@ -34,7 +34,7 @@ // Class of the defined type class PluginExampleExample extends CommonDBTM { - + static $tags = '[EXAMPLE_ID]'; // Should return the localized name of the type @@ -68,8 +68,8 @@ class PluginExampleExample extends CommonDBTM { static function getMenuName() { return __('Example plugin'); } - - + + /** * @see CommonGLPI::getAdditionalMenuLinks() **/ @@ -92,8 +92,8 @@ class PluginExampleExample extends CommonDBTM { return $ong; } - - function showForm($ID, $options = array()) { + + function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); @@ -105,12 +105,12 @@ class PluginExampleExample extends CommonDBTM { echo ""; echo $ID; echo ""; - + $this->showFormButtons($options); return true; } - + function getSearchOptions() { $tab = array(); @@ -169,7 +169,7 @@ class PluginExampleExample extends CommonDBTM { static function cronSample($task) { $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); $task->setVolume($r); @@ -335,25 +335,25 @@ class PluginExampleExample extends CommonDBTM { case "in" : //TRANS: %1$s is the start time of a planned item, %2$s is the end 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; case "through" : - echo Html::resume_text($val["name"],80); + echo Html::resume_text($val["name"], 80); break; case "begin" : //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; case "end" : //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; } echo "
"; - 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) { - switch($data['linked_action'] - Log::HISTORY_PLUGIN) { + switch ($data['linked_action'] - Log::HISTORY_PLUGIN) { case 0: 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 * @@ -406,14 +406,14 @@ class PluginExampleExample extends CommonDBTM { switch ($ma->getAction()) { case 'DoIt': echo " ". - Html::submit(_x('button','Post'), array('name' => 'massiveaction')). + Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')). " ".__('Write in item history', 'example'); return true; 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'); return true; - } + } return parent::showMassiveActionsSubForm($ma); } @@ -471,17 +471,15 @@ class PluginExampleExample extends CommonDBTM { } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } - + static function generateLinkContents($link, CommonDBTM $item) { - if (strstr($link,"[EXAMPLE_ID]")) { - $link = str_replace("[EXAMPLE_ID]", $item->getID(),$link); + if (strstr($link, "[EXAMPLE_ID]")) { + $link = str_replace("[EXAMPLE_ID]", $item->getID(), $link); return array($link); } - return parent::generateLinkContents($link, $item); } } -?> \ No newline at end of file diff --git a/inc/item_devicecamera.class.php b/inc/item_devicecamera.class.php index 81d8c67..5743e09 100644 --- a/inc/item_devicecamera.class.php +++ b/inc/item_devicecamera.class.php @@ -49,4 +49,3 @@ class PluginExampleItem_DeviceCamera extends Item_Devices { static protected $notable = false; } -?> diff --git a/inc/notificationtargetexample.class.php b/inc/notificationtargetexample.class.php index 14bbfe6..2146842 100644 --- a/inc/notificationtargetexample.class.php +++ b/inc/notificationtargetexample.class.php @@ -27,7 +27,7 @@ -------------------------------------------------------------------------- */ -if (!defined('GLPI_ROOT')){ +if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } @@ -44,4 +44,3 @@ class PluginExampleNotificationTargetExample extends NotificationTarget { $this->datas['##example.name##'] = __('Example', 'example'); } } -?> \ No newline at end of file diff --git a/inc/ruletest.class.php b/inc/ruletest.class.php index 3c31fd4..7c00aed 100644 --- a/inc/ruletest.class.php +++ b/inc/ruletest.class.php @@ -80,4 +80,3 @@ class PluginExampleRuleTest extends Rule { return $actions; } } -?> diff --git a/inc/ruletestcollection.class.php b/inc/ruletestcollection.class.php index 306afc5..d2faf9f 100644 --- a/inc/ruletestcollection.class.php +++ b/inc/ruletestcollection.class.php @@ -47,4 +47,3 @@ class PluginExampleRuleTestCollection extends RuleCollection { return 'Rulesengine test'; } } -?> diff --git a/inc/showtabitem.class.php b/inc/showtabitem.class.php index b59e574..f0a7324 100644 --- a/inc/showtabitem.class.php +++ b/inc/showtabitem.class.php @@ -30,23 +30,23 @@ along with GLPI. If not, see . /** * Summary of PluginExampleShowtabitem * Example of pre_show_xxx and post_show_xxx implementation - * - * + * + * * pre_show_item will be fired before an item is shown * ex: when viewing a ticket, change, computer,... - * + * * will be fired at each sub-item * ex: for each TicketTask, TicketFollowup, ... - * + * * post_show_item will be fired after the item show - * - * + * + * * pre_show_tab will be fired before a tab is shown * when tabs are loaded, * ex: when viewing the Followup tab - * + * * post_show_tab will be fired after the tab show - * + * * */ 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) */ static function pre_show_tab($params) { - switch( $params['item']->getType() ) { + switch ($params['item']->getType()) { 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 // then prevent solution div to show // this is an example to prevent solving of ticket - 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 - echo "