Fix CS (from phpcbf)

This commit is contained in:
Johan Cwiklinski 2017-02-08 15:42:19 +01:00 committed by Johan Cwiklinski
parent 0900bde1c9
commit 46a15511a2
24 changed files with 132 additions and 154 deletions

View File

@ -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();
?>

View File

@ -36,4 +36,3 @@ include ('../../../inc/includes.php');
$dropdown = new PluginExampleDeviceCamera();
include (GLPI_ROOT . "/front/dropdown.common.form.php");
?>

View File

@ -36,4 +36,3 @@ include ('../../../inc/includes.php');
$dropdown = new PluginExampleDeviceCamera();
include (GLPI_ROOT . "/front/dropdown.common.php");
?>

View File

@ -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");
?>

View File

@ -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");
?>

View File

@ -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();
?>

View File

@ -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();
?>

View File

@ -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 "</div>";
Html::popFooter();
}
?>

View File

@ -38,4 +38,3 @@ include ('../../../inc/includes.php');
$rulecollection = new PluginExampleRuleTestCollection();
include (GLPI_ROOT . "/front/rule.common.form.php");
?>

View File

@ -38,4 +38,3 @@ include ('../../../inc/includes.php');
$rulecollection = new PluginExampleRuleTestCollection();
include (GLPI_ROOT . "/front/rule.common.php");
?>

View File

@ -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,7 +175,7 @@ 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
@ -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
}
//}
}

View File

@ -99,4 +99,3 @@ class PluginExampleChild extends CommonDBChild {
}
}
?>

View File

@ -66,10 +66,9 @@ class PluginExampleConfig extends CommonDBTM {
Dropdown::showYesNo("configuration", $my_config['configuration']);
echo "</td></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td colspan='4' class='center'>";
echo "<input type='submit' name='update' class='submit' value=\""._sx('button','Save')."\">";
echo "<input type='submit' name='update' class='submit' value=\""._sx('button', 'Save')."\">";
echo "</td></tr>";
echo "</table></div>";
@ -85,4 +84,3 @@ class PluginExampleConfig extends CommonDBTM {
}
}
?>

View File

@ -46,4 +46,3 @@ class PluginExampleDeviceCamera extends CommonDevice {
}
}
?>

View File

@ -44,4 +44,3 @@ class PluginExampleDropdown extends CommonDropdown {
return __('Plugin Example Dropdowns', 'example');
}
}
?>

View File

@ -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 "<br>";
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,11 +406,11 @@ class PluginExampleExample extends CommonDBTM {
switch ($ma->getAction()) {
case 'DoIt':
echo "&nbsp;<input type='hidden' name='toto' value='1'>".
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 "&nbsp;".Html::submit(_x('button','Post'), array('name' => 'massiveaction')).
echo "&nbsp;".Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')).
" ".__('but do nothing :)', 'example');
return true;
}
@ -474,14 +474,12 @@ class PluginExampleExample extends CommonDBTM {
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);
}
}
?>

View File

@ -49,4 +49,3 @@ class PluginExampleItem_DeviceCamera extends Item_Devices {
static protected $notable = false;
}
?>

View File

@ -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');
}
}
?>

View File

@ -80,4 +80,3 @@ class PluginExampleRuleTest extends Rule {
return $actions;
}
}
?>

View File

@ -47,4 +47,3 @@ class PluginExampleRuleTestCollection extends RuleCollection {
return 'Rulesengine test';
}
}
?>

View File

@ -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 "<div id='toHideSolution' style='display: none;'>" ; // in order to hide the default solution div
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 "<div id='toHideSolution' style='display: none;'>"; // in order to hide the default solution div
}
}
}
@ -82,9 +82,9 @@ class PluginExampleShowtabitem {
* Note: you may get datas from pre_show_tab in $param['options'] array (see example below)
*/
static function post_show_tab($params) {
switch( $params['item']->getType() ) {
switch ($params['item']->getType()) {
case 'Ticket':
if( isset($params['options']['prevent_solution'])) {
if (isset($params['options']['prevent_solution'])) {
echo "</div>";
echo "<div style='margin-bottom: 20px;' class='box'>
<div class='box-tleft'>
@ -116,7 +116,7 @@ class PluginExampleShowtabitem {
</div>
</div> ";
}
break ;
break;
case 'Computer':
break;
@ -141,8 +141,8 @@ class PluginExampleShowtabitem {
* Note: you may pass datas to post_show_item using the $param['options'] array
*/
static function pre_show_item($params) {
if(!is_array($params['item'])) {
switch( $params['item']->getType() ) {
if (!is_array($params['item'])) {
switch ($params['item']->getType()) {
case 'Ticket':
//echo 'test' ;
break;
@ -155,6 +155,7 @@ class PluginExampleShowtabitem {
}
} else {
// here we are going to view a Solution
return;
}
}
@ -175,8 +176,8 @@ class PluginExampleShowtabitem {
* Note: you may get datas from pre_show_item using the $param['options'] array
*/
static function post_show_item($params) {
if(!is_array($params['item'])) {
switch( $params['item']->getType() ) {
if (!is_array($params['item'])) {
switch ($params['item']->getType()) {
case 'Ticket':
//echo 'test' ;
break;
@ -189,6 +190,7 @@ class PluginExampleShowtabitem {
}
} else {
// here we are going to view a Solution
return;
}
}

View File

@ -41,9 +41,8 @@ include (GLPI_ROOT . "/inc/includes.php");
Session::checkRight("config", "w");
Html::header("TITRE",$_SERVER['PHP_SELF'],"plugins");
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins");
echo "This is the plugin report page";
Html::footer();
?>

View File

@ -66,7 +66,7 @@ function plugin_init_example() {
Plugin::registerClass('PluginExampleDeviceCamera',
array('device_types' => true));
if (version_compare(GLPI_VERSION,'9.1','ge')) {
if (version_compare(GLPI_VERSION, '9.1', 'ge')) {
if (class_exists('PluginExampleExample')) {
Link::registerTag(PluginExampleExample::$tags);
}
@ -78,21 +78,21 @@ function plugin_init_example() {
'tools' => 'PluginExampleExample');
// Old menu style
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
//
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
// $PLUGIN_HOOKS['menu_entry']['example'] = 'front/example.php';
//
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['title'] = "Search";
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['page'] = '/plugins/example/front/example.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['search'] = '/plugins/example/front/example.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['add'] = '/plugins/example/front/example.form.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']['config'] = '/plugins/example/index.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".__s('Show all')."' alt='".__s('Show all')."'>"] = '/plugins/example/index.php';
// $PLUGIN_HOOKS['submenu_entry']['example']['options']['optionname']['links'][__s('Test link', 'example')] = '/plugins/example/index.php';
$PLUGIN_HOOKS["helpdesk_menu_entry"]['example'] = true;
}
// Config page
if (Session::haveRight('config',UPDATE)) {
if (Session::haveRight('config', UPDATE)) {
$PLUGIN_HOOKS['config_page']['example'] = 'config.php';
}
@ -237,7 +237,7 @@ function plugin_version_example() {
function plugin_example_check_prerequisites() {
// Strict version check (could be less strict, or could allow various version)
if (version_compare(GLPI_VERSION,'0.85','lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) {
if (version_compare(GLPI_VERSION, '0.85', 'lt') /*|| version_compare(GLPI_VERSION,'0.84','gt')*/) {
if (method_exists('Plugin', 'messageIncompatible')) {
echo Plugin::messageIncompatible('core', '0.85');
} else {
@ -265,4 +265,3 @@ function plugin_example_check_config($verbose = false) {
}
return false;
}
?>

View File

@ -41,9 +41,8 @@ include (GLPI_ROOT . "/inc/includes.php");
Session::checkRight("config", "w");
Html::header("TITLE",$_SERVER['PHP_SELF'],"plugins");
Html::header("TITLE", $_SERVER['PHP_SELF'], "plugins");
echo "This is the plugin stat page";
Html::footer();
?>