static function getForItemtype($itemtype)
 {
     $itemtypes = array();
     foreach (PluginFusioninventoryModule::getAll() as $data) {
         $class = PluginFusioninventoryStaticmisc::getStaticmiscClass($data['directory']);
         if (is_callable(array($class, 'credential_types'))) {
             foreach (call_user_func(array($class, 'credential_types')) as $credential) {
                 if (in_array($itemtype, $credential['targets'])) {
                     $itemtypes[$credential['itemtype']] = $credential['name'];
                 }
             }
         }
     }
     return $itemtypes;
 }
 /**
  * Display actions possible in device
  *
  * @return nothing
  *
  **/
 function showActions($items_id, $itemtype)
 {
     global $CFG_GLPI;
     // load all plugin and get method possible
     /*
      * Example :
      * * inventory
      * * snmpquery
      * * wakeonlan
      * * deploy => software
      *
      */
     echo "<div align='center'>";
     echo "<form method='post' name='' id=''  action=\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/taskjob.form.php\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='4'>";
     echo __('Action on this device', 'fusioninventory');
     echo " : </th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo __('Job', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td align='center'>";
     $a_methods = PluginFusioninventoryStaticmisc::getmethods();
     $a_parseMethods = array();
     $a_parseMethods[''] = "------";
     foreach ($a_methods as $data) {
         $class = PluginFusioninventoryStaticmisc::getStaticmiscClass($data['directory']);
         if (is_callable(array($class, 'task_action_' . $data['method']))) {
             $a_itemtype = call_user_func(array($class, 'task_action_' . $data['method']));
             if (in_array($itemtype, $a_itemtype)) {
                 $a_parseMethods[$data['module'] . "||" . $data['method']] = $data['method'];
             }
         }
     }
     Dropdown::showFromArray('methodaction', $a_parseMethods);
     echo "</td>";
     echo "<td align='center'>";
     echo __('Scheduled date', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td align='center'>";
     Html::showDateTimeFormItem("datetime_start", date("Y-m-d H:i:s"), 1);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center' colspan='4'>";
     echo "<input type='hidden' name='items_id' value='" . $items_id . "'/>";
     echo "<input type='hidden' name='itemtype' value='" . $itemtype . "'/>";
     echo "<input type='submit' name='itemaddaction' value=\"" . __('Add') . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
 /**
  * Get configuration for an agent
  *
  * @params an array of GET parameters given by the agent
  *
  * @return an array of orders to send to the agent
  */
 static function getConfigByAgent($params = array())
 {
     $schedule = array();
     $pfAgentModule = new PluginFusioninventoryAgentmodule();
     $a_agent = PluginFusioninventoryAgent::getByDeviceID($params['machineid']);
     if (isset($params['task'])) {
         foreach (array_keys($params['task']) as $task) {
             foreach (PluginFusioninventoryStaticmisc::getmethods() as $method) {
                 $classname = '';
                 if (strtolower($task) == 'deploy') {
                     $classname = 'PluginFusioninventoryDeployPackage';
                 } else {
                     if (strtolower($task) == 'esx') {
                         $classname = 'PluginFusioninventoryCredentialIp';
                     } else {
                         if (strtolower($task) == 'collect') {
                             $classname = 'PluginFusioninventoryCollect';
                         }
                     }
                 }
                 $taskname = $method['method'];
                 if (strstr($taskname, 'deploy')) {
                     $taskname = $method['task'];
                 }
                 $class = PluginFusioninventoryStaticmisc::getStaticmiscClass($method['module']);
                 if (isset($method['task']) && strtolower($method['task']) == strtolower($task) && (isset($method['use_rest']) && $method['use_rest']) && method_exists($class, self::getMethodForParameters($task)) && $pfAgentModule->isAgentCanDo($taskname, $a_agent['id']) && countElementsInTable('glpi_plugin_fusioninventory_taskjobstates', "`plugin_fusioninventory_agents_id`='" . $a_agent['id'] . "' " . " AND `itemtype`='" . $classname . "'" . " AND `state`='0'") > 0) {
                     /*
                      * Since migration, there is only one plugin in one directory
                      * It's maybe time to redo this function -- kiniou
                      */
                     $schedule[] = call_user_func(array($class, self::getMethodForParameters($task)), $a_agent['entities_id']);
                     break;
                     //Stop the loop since we found the module corresponding to the asked task
                 }
             }
         }
     }
     return array('configValidityPeriod' => 600, 'schedule' => $schedule);
 }
 /**
  * Get all methods of this plugin
  *
  * @return array ('module'=>'value', 'method'=>'value')
  *   module value name of plugin
  *   method value name of method
  *
  **/
 static function getmethods()
 {
     $a_methods = call_user_func(array('PluginFusioninventoryStaticmisc', 'task_methods'));
     $a_modules = PluginFusioninventoryModule::getAll();
     foreach ($a_modules as $data) {
         $class = $class = PluginFusioninventoryStaticmisc::getStaticmiscClass($data['directory']);
         if (is_callable(array($class, 'task_methods'))) {
             $a_methods = array_merge($a_methods, call_user_func(array($class, 'task_methods')));
         }
     }
     return $a_methods;
 }