当前位置: 首页>>代码示例>>PHP>>正文


PHP Toolbox::logDebug方法代码示例

本文整理汇总了PHP中Toolbox::logDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::logDebug方法的具体用法?PHP Toolbox::logDebug怎么用?PHP Toolbox::logDebug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Toolbox的用法示例。


在下文中一共展示了Toolbox::logDebug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendAlert

 /**
  * @return int
  */
 static function sendAlert()
 {
     global $DB, $CFG_GLPI;
     if (!$CFG_GLPI["use_mailing"]) {
         return 0;
     }
     $items_infos = array();
     $query = "SELECT `glpi_plugin_ocsinventoryng_notimportedcomputers`.*\n               FROM `glpi_plugin_ocsinventoryng_notimportedcomputers`\n               LEFT JOIN `glpi_alerts`\n                  ON (`glpi_plugin_ocsinventoryng_notimportedcomputers`.`id` = `glpi_alerts`.`items_id`\n                      AND `glpi_alerts`.`itemtype` = 'PluginOcsinventoryngNotimportedcomputer'\n                      AND `glpi_alerts`.`type` = '" . Alert::END . "')\n               WHERE `glpi_alerts`.`date` IS NULL";
     foreach ($DB->request($query) as $notimported) {
         $items_infos[$notimported['entities_id']][$notimported['id']] = $notimported;
     }
     foreach ($items_infos as $entity => $items) {
         if (NotificationEvent::raiseEvent('not_imported', new PluginOcsinventoryngNotimportedcomputer(), array('entities_id' => $entity, 'notimported' => $items))) {
             $alert = new Alert();
             $input["itemtype"] = 'PluginOcsinventoryngNotimportedcomputer';
             $input["type"] = Alert::END;
             foreach ($items as $id => $item) {
                 $input["items_id"] = $id;
                 $alert->add($input);
                 unset($alert->fields['id']);
             }
         } else {
             Toolbox::logDebug(__('%1$s: %2$s') . "\n", Dropdown::getDropdownName("glpi_entities", $entity), __('Send OCSNG not imported computers alert failed', 'ocsinventoryng'));
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:29,代码来源:notimportedcomputer.class.php

示例2: foreach

   foreach ($_POST["fields"] as $field => $value) {
      if ($type->can($_POST["id"], PURGE)
         && $value == 1
            && PluginGenericobjectField::checkNecessaryFieldsDelete($itemtype,  $field)) {
         PluginGenericobjectField::deleteField(getTableForItemType($itemtype), $field);
         Session::addMessageAfterRedirect(__("Field(s) deleted successfully", "genericobject"), true, INFO);
      }
   }
} elseif (isset ($_POST["add_field"])) {
   $type     = new PluginGenericobjectType();
   if ($_POST["new_field"] && $type->can($_POST["id"], UPDATE)) {
      $itemtype = $type->fields['itemtype'];
      PluginGenericobjectType::registerOneType($itemtype);

      Toolbox::logDebug(array(
         'itemtype' => $itemtype,
         'getTableForItemType'=>getTableForItemType($itemtype),
         'new_field' => $_POST['new_field']
      ));
      PluginGenericobjectField::addNewField(getTableForItemType($itemtype), $_POST["new_field"]);
      Session::addMessageAfterRedirect(__("Field added successfully", "genericobject"));
   }
} elseif (isset($_POST['action'])) {
   //Move field
   PluginGenericobjectField::changeFieldOrder($_POST);
}

Html::back();

开发者ID:euqip,项目名称:glpi-smartcities,代码行数:28,代码来源:field.form.php

示例3: stop

 function stop()
 {
     if (self::$run) {
         $data = xhprof_disable();
         $incl = defined('XHPROF_PATH') ? XHPROF_PATH : self::XHPROF_PATH;
         include_once $incl . '/utils/xhprof_lib.php';
         include_once $incl . '/utils/xhprof_runs.php';
         $runs = new XHProfRuns_Default();
         $id = $runs->save_run($data, 'glpi');
         $url = defined('XHPROF_URL') ? XHPROF_URL : self::XHPROF_URL;
         $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
         $link = "http://" . $host . "{$url}/index.php?run={$id}&source=glpi";
         Toolbox::logDebug("Stop profiling with XHProf, result URL", $link);
         self::$run = false;
     }
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:16,代码来源:xhprof.class.php

示例4: __construct

 /**
  * Constructor of massive actions.
  * There is three stages and each one have its own objectives:
  * - initial: propose the actions and filter the checkboxes (only once)
  * - specialize: add action specific fields and filter items. There can be as many as needed!
  * - process: process the massive action (only once, but can be reload to avoid timeout)
  *
  * We trust all previous stages: we don't redo the checks
  *
  * @param $POST  something like $_POST
  * @param $GET   something like $_GET
  * @param $stage the current stage
  *
  * @return nothing (it is a constructor).
  **/
 function __construct(array $POST, array $GET, $stage)
 {
     global $CFG_GLPI;
     if (!empty($POST)) {
         if (!isset($POST['is_deleted'])) {
             $POST['is_deleted'] = 0;
         }
         $this->nb_items = 0;
         if (isset($POST['item']) || isset($POST['items'])) {
             $remove_from_post = array();
             switch ($stage) {
                 case 'initial':
                     $POST['action_filter'] = array();
                     // 'specific_actions': restrict all possible actions or introduce new ones
                     // thus, don't try to load other actions and don't filter any item
                     if (isset($POST['specific_actions'])) {
                         $POST['actions'] = $POST['specific_actions'];
                         $specific_action = 1;
                         $dont_filter_for = array_keys($POST['actions']);
                     } else {
                         $specific_action = 0;
                         if (isset($POST['add_actions'])) {
                             $POST['actions'] = $POST['add_actions'];
                             $dont_filter_for = array_keys($POST['actions']);
                         } else {
                             $POST['actions'] = array();
                             $dont_filter_for = array();
                         }
                     }
                     if (count($dont_filter_for)) {
                         $POST['dont_filter_for'] = array_combine($dont_filter_for, $dont_filter_for);
                     } else {
                         $POST['dont_filter_for'] = array();
                     }
                     $remove_from_post[] = 'specific_actions';
                     $remove_from_post[] = 'add_actions';
                     $POST['items'] = array();
                     foreach ($POST['item'] as $itemtype => $ids) {
                         // initial are raw checkboxes: 0=unchecked or 1=checked
                         $items = array();
                         foreach ($ids as $id => $checked) {
                             if ($checked == 1) {
                                 $items[$id] = $id;
                                 $this->nb_items++;
                             }
                         }
                         $POST['items'][$itemtype] = $items;
                         if (!$specific_action) {
                             $actions = self::getAllMassiveActions($itemtype, $POST['is_deleted'], $this->getCheckItem($POST));
                             $POST['actions'] = array_merge($actions, $POST['actions']);
                             foreach ($actions as $action => $label) {
                                 $POST['action_filter'][$action][] = $itemtype;
                                 $POST['actions'][$action] = $label;
                             }
                         }
                     }
                     if (empty($POST['actions'])) {
                         throw new Exception(__('No action available'));
                     }
                     // Initial items is used to define $_SESSION['glpimassiveactionselected']
                     $POST['initial_items'] = $POST['items'];
                     $remove_from_post[] = 'item';
                     break;
                 case 'specialize':
                     if (!isset($POST['action'])) {
                         Toolbox::logDebug('Implementation error !');
                         throw new Exception(__('Implementation error !'));
                     }
                     if ($POST['action'] == -1) {
                         // Case when no action is choosen
                         exit;
                     }
                     if (isset($POST['actions'])) {
                         // First, get the name of current action !
                         if (!isset($POST['actions'][$POST['action']])) {
                             Toolbox::logDebug('Implementation error !');
                             throw new Exception(__('Implementation error !'));
                         }
                         $POST['action_name'] = $POST['actions'][$POST['action']];
                         $remove_from_post[] = 'actions';
                         // Then filter the items regarding the action
                         if (!isset($POST['dont_filter_for'][$POST['action']])) {
                             if (isset($POST['action_filter'][$POST['action']])) {
                                 $items = array();
                                 foreach ($POST['action_filter'][$POST['action']] as $itemtype) {
//.........这里部分代码省略.........
开发者ID:kipman,项目名称:glpi,代码行数:101,代码来源:massiveaction.class.php

示例5: getJoblogs


//.........这里部分代码省略.........
         //}
     }
     $agents = array();
     $format_chrono = array("start" => microtime(true), "end" => 0);
     foreach ($queries as $query_name => $contents) {
         if (!is_null($contents['result'])) {
             while ($result = $contents['result']->fetch_row()) {
                 // We need to check if the results are consistent with the view's structure gathered
                 // by the first query
                 $task_id = $result[$fieldmap['task.id']];
                 //if (!array_key_exists($task_id, $logs)) {
                 if (!isset($logs[$task_id])) {
                     continue;
                 }
                 $job_id = $result[$fieldmap['job.id']];
                 $jobs =& $logs[$task_id]['jobs'];
                 if (!isset($jobs[$job_id])) {
                     continue;
                 }
                 $target_id = $result[$fieldmap['run.itemtype']] . '_' . $result[$fieldmap['run.items_id']];
                 $targets =& $jobs[$job_id]['targets'];
                 if (!isset($targets[$target_id])) {
                     continue;
                 }
                 $counters =& $targets[$target_id]['counters'];
                 $agent_id = $result[$fieldmap['agent.id']];
                 $agents[$agent_id] = $result[$fieldmap['agent.name']];
                 if (!isset($targets[$target_id]['agents'][$agent_id])) {
                     $targets[$target_id]['agents'][$agent_id] = array();
                 }
                 $agent_state = '';
                 // Update counters
                 switch ($result[$fieldmap['run.state']]) {
                     case PluginFusioninventoryTaskjobstate::CANCELLED:
                         // We put this agent in the cancelled counter if it does not have any other job
                         // states.
                         if (!isset($counters['agents_prepared'][$agent_id]) and !isset($counters['agents_running'][$agent_id])) {
                             $counters['agents_cancelled'][$agent_id] = 1;
                             $agent_state = 'cancelled';
                         }
                         break;
                     case PluginFusioninventoryTaskjobstate::PREPARED:
                         // We put this agent in the prepared counter if it has not yet completed any job.
                         $counters['agents_prepared'][$agent_id] = 1;
                         $agent_state = 'prepared';
                         break;
                     case PluginFusioninventoryTaskjobstate::SERVER_HAS_SENT_DATA:
                     case PluginFusioninventoryTaskjobstate::AGENT_HAS_SENT_DATA:
                         // This agent is running so it must not be in any other counter
                         foreach ($agent_state_types as $type) {
                             if (isset($counters[$type][$agent_id])) {
                                 unset($counters[$type][$agent_id]);
                             }
                         }
                         $counters['agents_running'][$agent_id] = 1;
                         $agent_state = 'running';
                         break;
                     case PluginFusioninventoryTaskjobstate::IN_ERROR:
                         if (isset($counters['agents_success'][$agent_id])) {
                             unset($counters['agents_success'][$agent_id]);
                         }
                         $counters['agents_error'][$agent_id] = 1;
                         $agent_state = 'error';
                         if (isset($counters['agents_notdone'][$agent_id])) {
                             unset($counters['agents_notdone'][$agent_id]);
                         }
                         break;
                     case PluginFusioninventoryTaskjobstate::FINISHED:
                         if (isset($counters['agents_error'][$agent_id])) {
                             unset($counters['agents_error'][$agent_id]);
                         }
                         $counters['agents_success'][$agent_id] = 1;
                         $agent_state = 'success';
                         if (isset($counters['agents_notdone'][$agent_id])) {
                             unset($counters['agents_notdone'][$agent_id]);
                         }
                         break;
                 }
                 if (!isset($counters['agents_error'][$agent_id]) and !isset($counters['agents_success'][$agent_id])) {
                     $counters['agents_notdone'][$agent_id] = 1;
                 }
                 if (isset($counters['agents_running'][$agent_id]) or isset($counters['agents_prepared'][$agent_id])) {
                     unset($counters['agents_cancelled'][$agent_id]);
                 }
                 $targets[$target_id]['agents'][$agent_id][] = array('agent_id' => $agent_id, 'numstate' => $result[$fieldmap['run.state']], 'state' => $agent_state, 'jobstate_id' => $result[$fieldmap['run.id']], 'last_log_id' => $result[$fieldmap['log.last_id']], 'last_log_date' => $result[$fieldmap['log.last_date']], 'timestamp' => $result[$fieldmap['log.last_timestamp']], 'last_log' => $result[$fieldmap['log.last_comment']]);
             }
         }
     }
     $format_chrono['end'] = microtime(true);
     if ($debug_mode) {
         function tmp_display_log($log)
         {
             return "ID:" . $log['task_id'] . "(" . $log['task_name'] . ")";
         }
         if (PluginFusioninventoryConfig::isExtradebugActive()) {
             Toolbox::logDebug(array("tasks" => implode(',', array_map('tmp_display_log', $logs)), "row count" => count($logs), "Joblogs Query" => self::FormatChrono($query_chrono), "Format logs results" => self::FormatChrono($format_chrono)));
         }
     }
     return array('tasks' => $logs, 'agents' => $agents);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:task.class.php

示例6: generateTemplate

 public static function generateTemplate($fields)
 {
     $classname = "PluginFields" . ucfirst($fields['itemtype'] . preg_replace('/s$/', '', $fields['name']));
     $template_class = file_get_contents(GLPI_ROOT . "/plugins/fields/templates/container.class.tpl");
     $template_class = str_replace("%%CLASSNAME%%", $classname, $template_class);
     $template_class = str_replace("%%ITEMTYPE%%", $fields['itemtype'], $template_class);
     $template_class = str_replace("%%CONTAINER%%", $fields['id'], $template_class);
     $template_class = str_replace("%%ITEMTYPE_RIGHT%%", strtolower($fields['itemtype']), $template_class);
     $class_filename = strtolower($fields['itemtype'] . preg_replace('/s$/', '', $fields['name']) . ".class.php");
     if (file_put_contents(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}", $template_class) === false) {
         Toolbox::logDebug("Error : class file creation - {$class_filename}");
         return false;
     }
     // Generate Datainjection files
     $template_class = file_get_contents(GLPI_ROOT . "/plugins/fields/templates/injection.class.tpl");
     $template_class = str_replace("%%CLASSNAME%%", $classname, $template_class);
     $template_class = str_replace("%%ITEMTYPE%%", $fields['itemtype'], $template_class);
     $template_class = str_replace("%%CONTAINER_ID%%", $fields['id'], $template_class);
     $template_class = str_replace("%%CONTAINER_NAME%%", $fields['label'], $template_class);
     $class_filename = strtolower($fields['itemtype'] . preg_replace('/s$/', '', $fields['name']) . "injection.class.php");
     if (file_put_contents(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}", $template_class) === false) {
         Toolbox::logDebug("Error : datainjection class file creation - {$class_filename}");
         return false;
     }
     // Generate Datainjection injection files
     $template_class = file_get_contents(GLPI_ROOT . "/plugins/fields/templates/injectioninjection.class.tpl");
     $template_class = str_replace("%%CLASSNAME%%", $classname, $template_class);
     $template_class = str_replace("%%ITEMTYPE%%", $fields['itemtype'], $template_class);
     $template_class = str_replace("%%CONTAINER_ID%%", $fields['id'], $template_class);
     $class_filename = strtolower($fields['itemtype'] . preg_replace('/s$/', '', $fields['name']) . "injectioninjection.class.php");
     if (file_put_contents(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}", $template_class) === false) {
         Toolbox::logDebug("Error : datainjection class file creation - {$class_filename}");
         return false;
     }
     return true;
 }
开发者ID:publik1974,项目名称:fields,代码行数:36,代码来源:container.class.php

示例7: cronWakeupAgents

 static function cronWakeupAgents($crontask)
 {
     global $DB;
     $wakeupArray = array();
     $tasks = array();
     //Get the maximum number of agent to wakeup,
     //as allowed in the general configuration
     $config = new PluginFusioninventoryConfig();
     $maxWakeUp = $config->getValue('wakeup_agent_max');
     $counter = 0;
     $continue = true;
     //Get all active timeslots
     $timeslot = new PluginFusioninventoryTimeslot();
     $timeslots = $timeslot->getCurrentActiveTimeslots();
     if (empty($timeslots)) {
         $query_timeslot = '';
     } else {
         $query_timeslot = "OR (`plugin_fusioninventory_timeslots_id` IN (" . implode(',', $timeslots) . "))";
     }
     //Get all active task requiring an agent wakeup
     //Check all tasks without timeslot or task with a current active timeslot
     $query = "SELECT `id`, `wakeup_agent_counter`, `wakeup_agent_time`, `last_agent_wakeup` \n                 FROM `glpi_plugin_fusioninventory_tasks` \n                 WHERE `wakeup_agent_time` > 0 \n                    AND `wakeup_agent_counter` > 0\n                    AND `is_active`='1' \n                    AND ((`plugin_fusioninventory_timeslots_id`='0') \n                    {$query_timeslot})";
     foreach ($DB->request($query) as $task) {
         if (!is_null($task['wakeup_agent_time'])) {
             //Do not wake up is last wake up in inferior to the minimum wake up interval
             $interval = time() - strtotime($task['last_agent_wakeup']);
             if ($interval < $task['wakeup_agent_time'] * MINUTE_TIMESTAMP) {
                 continue;
             }
         }
         //For each task, get a number of taskjobs at the PREPARED state
         //(the maximum is defined in wakeup_agent_counter)
         $query_states = "SELECT `taskjobstates`.`plugin_fusioninventory_agents_id`, \n                                 `tasks`.`id` as `taskID`, \n                                 `tasks`.`wakeup_agent_time`,\n                                 `tasks`.`last_agent_wakeup`\n                          FROM `glpi_plugin_fusioninventory_taskjobstates` as `taskjobstates`,\n                               `glpi_plugin_fusioninventory_taskjobs` as `taskjobs`\n                          LEFT JOIN `glpi_plugin_fusioninventory_tasks` as `tasks` \n                             ON `tasks`.`id`=`taskjobs`.`plugin_fusioninventory_tasks_id`\n                          WHERE `tasks`.`id`='" . $task['id'] . "' \n                             AND `taskjobs`.`id`=`taskjobstates`.`plugin_fusioninventory_taskjobs_id` \n                             AND `taskjobstates`.`state`='" . PluginFusioninventoryTaskjobstate::PREPARED . "' \n                          ORDER BY `taskjobstates`.`id` ASC LIMIT " . $task['wakeup_agent_counter'];
         foreach ($DB->request($query_states) as $state) {
             $agents_id = $state['plugin_fusioninventory_agents_id'];
             //Check if agent is already added to the list of agents to wake up
             if (!isset($wakeupArray[$agents_id])) {
                 //This agent must be woken up
                 $wakeupArray[$agents_id] = $agents_id;
                 $counter++;
             }
             //Store task ID
             if (!in_array($state['taskID'], $tasks)) {
                 $tasks[] = $state['taskID'];
             }
             //Do not process more than the maximum number of wakeup allowed in the configuration
             if ($counter >= $maxWakeUp) {
                 if (PluginFusioninventoryConfig::isExtradebugActive()) {
                     Toolbox::logDebug(__("Maximum number of agent wakeup reached", 'fusioninventory') . ":" . $maxWakeUp);
                 }
                 $continue = false;
                 break;
             }
         }
         //We've reached the maximum number of agents to wake up !
         if (!$continue) {
             break;
         }
     }
     //Number of agents successfully woken up
     $wokeup = 0;
     $myTask = new PluginFusioninventoryTask();
     if (!empty($tasks)) {
         //Update last wake up time each task
         $query_lastrun = "UPDATE `glpi_plugin_fusioninventory_tasks` \n                           SET `last_agent_wakeup`='" . $_SESSION['glpi_currenttime'] . "' \n                           WHERE `id` IN (" . implode(",", $tasks) . ")";
         $DB->query($query_lastrun);
         $agent = new PluginFusioninventoryAgent();
         //Try to wake up agents one by one
         foreach ($wakeupArray as $ID => $value) {
             $agent->getFromDB($ID);
             if ($agent->wakeUp()) {
                 $wokeup++;
             }
         }
     }
     $crontask->addVolume($wokeup);
     return true;
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:78,代码来源:agentwakeup.class.php

示例8: optimize_tables

 /**
  *  Optimize sql table
  *
  * @param $migration   migration class (default NULL)
  * @param $cron        to know if optimize must be done (false by default)
  *
  * @return number of tables
  **/
 static function optimize_tables($migration = NULL, $cron = false)
 {
     global $DB;
     $crashed_tables = self::checkForCrashedTables();
     if (!empty($crashed_tables)) {
         Toolbox::logDebug("Cannot launch automatic action : crashed tables detected");
         return -1;
     }
     if (!is_null($migration) && method_exists($migration, 'displayMessage')) {
         $migration->displayTitle(__('Optimizing tables'));
         $migration->addNewMessageArea('optimize_table');
         // to force new ajax zone
         $migration->displayMessage(sprintf(__('%1$s - %2$s'), __('optimize'), __('Start')));
     }
     $result = $DB->list_tables();
     $nb = 0;
     while ($line = $DB->fetch_row($result)) {
         $table = $line[0];
         // For big database to reduce delay of migration
         if ($cron || countElementsInTable($table) < 15000000) {
             if (!is_null($migration) && method_exists($migration, 'displayMessage')) {
                 $migration->displayMessage(sprintf(__('%1$s - %2$s'), __('optimize'), $table));
             }
             $query = "OPTIMIZE TABLE `" . $table . "` ;";
             $DB->query($query);
             $nb++;
         }
     }
     $DB->free_result($result);
     if (!is_null($migration) && method_exists($migration, 'displayMessage')) {
         $migration->displayMessage(sprintf(__('%1$s - %2$s'), __('optimize'), __('End')));
     }
     return $nb;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:42,代码来源:dbmysql.class.php

示例9: array

    $json_response = array("success" => TRUE, "reason" => '');
    if (Session::haveRight('plugin_fusioninventory_package', UPDATE)) {
        PluginFusioninventoryDeployPackage::alter_json('move_item', $_REQUEST);
    } else {
        $json_response['success'] = FALSE;
        $json_response['reason'] = __('Package modification is forbidden by your profile.');
    }
    echo json_encode($json_response);
    exit;
}
if (!isset($_REQUEST['orders_id']) && !isset($_REQUEST['rand']) && !isset($_REQUEST['subtype'])) {
    exit;
}
if (!is_numeric($_REQUEST['orders_id'])) {
    Toolbox::logDebug("Error: orders_id in request is not an integer");
    Toolbox::logDebug(var_dump($_REQUEST['orders_id']));
    exit;
}
$order = new PluginFusioninventoryDeployOrder();
$order->getFromDB($_REQUEST['orders_id']);
//TODO: In the displayForm function, $_REQUEST is somewhat too much for the '$datas' parameter
// I think we could use only $order -- Kevin 'kiniou' Roy
switch ($_REQUEST['subtype']) {
    case 'check':
        PluginFusioninventoryDeployCheck::displayForm($order, $_REQUEST, $_REQUEST['rand'], $_POST['mode']);
        break;
    case 'file':
        PluginFusioninventoryDeployFile::displayForm($order, $_REQUEST, $_REQUEST['rand'], $_POST['mode']);
        break;
    case 'action':
        PluginFusioninventoryDeployAction::displayForm($order, $_REQUEST, $_REQUEST['rand'], $_POST['mode']);
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:deploypackage_form.php

示例10: destroy

 static function destroy($dropdown_name)
 {
     $classname = self::getClassname($dropdown_name);
     $class_filename = PLUGINFIELDS_CLASS_PATH . "/" . $dropdown_name . "dropdown.class.php";
     //call uninstall method in dropdown class
     if ($classname::uninstall() === false) {
         Toolbox::logDebug("Error : calling dropdown {$classname} uninstallation");
         return false;
     }
     //remove class file for this dropdown
     if (file_exists($class_filename)) {
         if (unlink($class_filename) === false) {
             Toolbox::logDebug("Error : dropdown class file creation - " . $dropdown_name . "dropdown.class.php");
             return false;
         }
     }
     //remove front file for this dropdown
     $front_filename = PLUGINFIELDS_FRONT_PATH . "/" . $dropdown_name . "dropdown.php";
     if (file_exists($front_filename)) {
         if (unlink($front_filename) === false) {
             Toolbox::logDebug("Error : dropdown front file removing - " . $dropdown_name . "dropdown.php");
             return false;
         }
     }
     //remove front.form file for this dropdown
     $form_filename = PLUGINFIELDS_FRONT_PATH . "/" . $dropdown_name . "dropdown.form.php";
     if (file_exists($form_filename)) {
         if (unlink($form_filename) === false) {
             Toolbox::logDebug("Error : dropdown form file removing - " . $dropdown_name . "dropdown.form.php");
             return false;
         }
     }
     return true;
 }
开发者ID:pluginsGLPI,项目名称:fields,代码行数:34,代码来源:dropdown.class.php

示例11: define

  @link      https://forge.indepnet.net/projects/barscode
  @since     2009

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!defined("GLPI_PLUGIN_DOC_DIR")) {
    define("GLPI_PLUGIN_DOC_DIR", GLPI_ROOT . "/files/_plugins");
}
$docDir = GLPI_PLUGIN_DOC_DIR . '/barcode';
if (isset($_GET['file'])) {
    $filename = $_GET['file'];
    // Security test : document in $docDir
    if (strstr($filename, "../") || strstr($filename, "..\\")) {
        echo "Security attack !!!";
        Toolbox::logDebug("[Plugin barcode][security][sendfile] " . $_SESSION["glpiname"] . " try to get a non standard file : " . $filename);
    }
    $file = $docDir . '/' . $filename;
    if (!file_exists($file)) {
        echo "Error file {$filename} does not exist";
        //TODO : traduire
    } else {
        // Now send the file with header() magic
        header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
        header('Pragma: private');
        /// IE BUG + SSL
        //header('Pragma: no-cache');
        header('Cache-control: private, must-revalidate');
        /// IE BUG + SSL
        header("Content-disposition: filename=\"{$filename}\"");
        header("Content-type: application/pdf");
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:send.php

示例12: destroy

 static function destroy($dropdown_name)
 {
     $classname = self::getClassname($dropdown_name);
     $class_filename = GLPI_ROOT . "/plugins/fields/inc/" . $dropdown_name . "dropdown.class.php";
     //load class manually on plugin uninstallation
     if (file_exists($class_filename)) {
         if (!class_exists($classname)) {
             require_once $dropdown_name . "dropdown.class.php";
         }
         //call uninstall method in dropdown class
         if ($classname::uninstall() === false) {
             Toolbox::logDebug("Error : calling dropdown {$classname} uninstallation");
             return false;
         }
     }
     //remove class file for this dropdown
     if (file_exists($class_filename)) {
         if (unlink($class_filename) === false) {
             Toolbox::logDebug("Error : dropdown class file creation - " . $dropdown_name . "dropdown.class.php");
             return false;
         }
     }
     //remove front file for this dropdown
     $front_filename = GLPI_ROOT . "/plugins/fields/front/" . $dropdown_name . "dropdown.php";
     if (file_exists($front_filename)) {
         if (unlink($front_filename) === false) {
             Toolbox::logDebug("Error : dropdown front file removing - " . $dropdown_name . "dropdown.php");
             return false;
         }
     }
     //remove front.form file for this dropdown
     $form_filename = GLPI_ROOT . "/plugins/fields/front/" . $dropdown_name . "dropdown.form.php";
     if (file_exists($form_filename)) {
         if (unlink($form_filename) === false) {
             Toolbox::logDebug("Error : dropdown form file removing - " . $dropdown_name . "dropdown.form.php");
             return false;
         }
     }
     return true;
 }
开发者ID:publik1974,项目名称:fields,代码行数:40,代码来源:dropdown.class.php

示例13: displayUserForm

 /**
  * Display the Form end-user form to be filled
  *
  * @param  CommonGLPI   $item       Instance of the Form to be displayed
  *
  * @return Null                     Nothing, just display the form
  */
 public function displayUserForm(CommonGLPI $item)
 {
     if (isset($_SESSION['formcreator']['datas'])) {
         $datas = $_SESSION['formcreator']['datas'];
         unset($_SESSION['formcreator']['datas']);
     } else {
         $datas = null;
     }
     echo '<form name="formcreator_form' . $item->getID() . '" method="post" role="form" enctype="multipart/form-data"
            action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/form.form.php"
            class="formcreator_form form_horizontal" onsubmit="return validateForm(this);">';
     echo '<h1 class="form-title">' . $item->fields['name'] . '</h1>';
     // Form Header
     if (!empty($item->fields['content'])) {
         echo '<div class="form_header">';
         echo html_entity_decode($item->fields['content']);
         echo '</div>';
     }
     // Get and display sections of the form
     $question = new PluginFormcreatorQuestion();
     $questions = array();
     $section_class = new PluginFormcreatorSection();
     $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . (int) $item->getID(), '`order` ASC');
     echo '<div class="form_section">';
     foreach ($find_sections as $section_line) {
         echo '<h2>' . $section_line['name'] . '</h2>';
         // Display all fields of the section
         $questions = $question->find('plugin_formcreator_sections_id = ' . (int) $section_line['id'], '`order` ASC');
         foreach ($questions as $question_line) {
             if (isset($datas[$question_line['id']])) {
                 // multiple choice question are saved as JSON and needs to be decoded
                 $answer = in_array($question_line['fieldtype'], array('checkboxes', 'multiselect')) ? json_decode($datas[$question_line['id']]) : $datas[$question_line['id']];
             } else {
                 $answer = null;
             }
             PluginFormcreatorFields::showField($question_line, $answer);
         }
     }
     echo '<script type="text/javascript">formcreatorShowFields();</script>';
     // Show validator selector
     if ($item->fields['validation_required'] > 0) {
         $validators = array(0 => Dropdown::EMPTY_VALUE);
         // Groups
         if ($item->fields['validation_required'] == 2) {
             $query = 'SELECT g.`id`, g.`completename`
                   FROM `glpi_groups` g
                   LEFT JOIN `glpi_plugin_formcreator_formvalidators` fv ON fv.`users_id` = g.`id`
                   WHERE fv.`forms_id` = ' . (int) $this->getID();
             Toolbox::logDebug($query);
             $result = $GLOBALS['DB']->query($query);
             while ($validator = $GLOBALS['DB']->fetch_assoc($result)) {
                 $validators[$validator['id']] = $validator['completename'];
             }
             // Users
         } else {
             $query = 'SELECT u.`id`, u.`name`, u.`realname`, u.`firstname`
                   FROM `glpi_users` u
                   LEFT JOIN `glpi_plugin_formcreator_formvalidators` fv ON fv.`users_id` = u.`id`
                   WHERE fv.`forms_id` = ' . (int) $this->getID();
             $result = $GLOBALS['DB']->query($query);
             while ($validator = $GLOBALS['DB']->fetch_assoc($result)) {
                 $validators[$validator['id']] = formatUserName($validator['id'], $validator['name'], $validator['realname'], $validator['firstname']);
             }
         }
         echo '<div class="form-group required liste line' . (count($questions) + 1) % 2 . '" id="form-validator">';
         echo '<label>' . __('Choose a validator', 'formcreator') . ' <span class="red">*</span></label>';
         Dropdown::showFromArray('formcreator_validator', $validators);
         echo '</div>';
     }
     echo '</div>';
     // Display submit button
     echo '<div class="center">';
     echo '<input type="submit" name="submit_formcreator" class="submit_button" value="' . __('Send') . '" />';
     echo '</div>';
     echo '<input type="hidden" name="formcreator_form" value="' . $item->getID() . '">';
     echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">';
     echo '</form>';
 }
开发者ID:ChristopheG77,项目名称:formcreator,代码行数:85,代码来源:form.class.php

示例14: get_tickets

 function get_tickets($from_date, $to_date, $date_fmt)
 {
     global $DEBUG_SQL;
     $response = array();
     $range_date = array();
     if (!is_null($from_date)) {
         $range_date_start = new DateTime($from_date->format('Y-m-d'));
     } else {
         $range_date_start = null;
     }
     $range_date_end = new DateTime($to_date->format('Y-m-d'));
     \Toolbox::logDebug($range_date_start, $range_date_end);
     // TODO: build dates filler at the end. If from_date is null it should
     // take the date from the first ticket created
     // while($range_date_start < $range_date_end) {
     //     $range_date[] = self::format_dates($range_date_start->format('Y-m-d'),$date_fmt);
     //     $range_date_start->add(DateInterval::createFromDateString('1 day'));
     // }
     $current_entity = $_SESSION['glpiactive_entity_name'];
     $entities_restrict = getEntitiesRestrictRequest('', getTableForItemtype('Ticket'), '', '', false, false);
     $filter = array();
     // TODO: Handle 'until' types of request.
     // Check if $from_date is null and get everything before $to_date
     if (is_null($from_date)) {
         $filter[] = " AND ( " . "    (date <= '" . $to_date->format('Y-m-d') . "')" . ") AND is_deleted = 0";
     } else {
         $filter[] = " AND ( " . " (date between '" . $from_date->format('Y-m-d') . "'" . " and '" . $to_date->format('Y-m-d') . "')" . " OR (solvedate between '" . $from_date->format('Y-m-d') . "'" . " and '" . $to_date->format('Y-m-d') . "')" . " OR (closedate between '" . $from_date->format('Y-m-d') . "'" . " and '" . $to_date->format('Y-m-d') . "')" . ") AND is_deleted = 0";
     }
     // $filter[] =
     //     " AND ( ".
     //     "date < '".$to_date->format('Y-m-d')."'".
     //     ")";
     $filter[] = " AND " . $entities_restrict;
     array_unshift($filter, '1');
     $tickets = $this->factories['tickets']->find(implode("\n", $filter), "id ASC");
     // Get Categories
     $categories = $this->factories['categories']->find(implode("\n", array("1 ")));
     $category_ids = array_keys($categories);
     $solutiontypes = $this->factories['solution_types']->find();
     $response['result'] = array();
     $result =& $response['result'];
     $category = null;
     foreach ($tickets as $ticket) {
         $category_id = $ticket['itilcategories_id'];
         $solutiontypes_id = $tickets['solutiontypes_id'];
         $solutiontype = null;
         if ($solutiontypes_id > 0) {
             $solutiontype = $solutiontypes[$solutiontypes_id]['name'];
         } else {
             $solutiontype = __('None');
         }
         if (!array_key_exists($category_id, $categories)) {
             $category = "N/A";
             $category_names = array("N/A");
         } else {
             $category = $categories[$category_id];
             //TODO: make the following configurable.
             $category_names = explode(" > ", $category['completename']);
         }
         $type = null;
         switch ($ticket['type']) {
             case Ticket::INCIDENT_TYPE:
                 $type = 'incident';
                 break;
             case Ticket::DEMAND_TYPE:
                 $type = 'request';
                 break;
         }
         $result[] = array('id' => $ticket['id'], 'date_opened' => self::format_dates($ticket['date'], $date_fmt), 'date_solved' => self::format_dates($ticket['solvedate'], $date_fmt), 'date_closed' => self::format_dates($ticket['closedate'], $date_fmt), 'status_code' => $ticket['status'], 'status' => Ticket::getStatus($ticket['status']), 'category' => $category_names, 'category_id' => $category_id, 'impact' => Ticket::getImpactName($ticket['impact']), 'priority' => Ticket::getPriorityName($ticket['priority']), 'urgency' => Ticket::getUrgencyName($ticket['urgency']), 'solve_delay_stat' => intval($ticket['solve_delay_stat']), 'type' => $type, 'type_name' => Ticket::getTicketTypeName($ticket['type']), 'solution_type' => $solutiontype);
     }
     $response['metadata'] = array('count' => count($result), 'from_date' => !is_null($from_date) ? $from_date->format('c') : null, 'to_date' => $to_date->format('c'), 'current_entity' => $current_entity, 'range_dates' => array_values(array_unique($range_date)));
     $response['_debug'] = array('entities_restrict' => $entities_restrict, 'filter' => $filter, 'DEBUG_SQL' => $DEBUG_SQL);
     return $response;
 }
开发者ID:kiniou,项目名称:glpi-plugin-databreakdown,代码行数:74,代码来源:utils.class.php

示例15: alter_json

 static function alter_json($action_type, $params)
 {
     //route to sub class
     $item_type = $params['itemtype'];
     if (in_array($item_type, array('PluginFusioninventoryDeployCheck', 'PluginFusioninventoryDeployFile', 'PluginFusioninventoryDeployAction'))) {
         switch ($action_type) {
             case "add_item":
                 $item_type::add_item($params);
                 break;
             case "save_item":
                 $item_type::save_item($params);
                 break;
             case "remove_item":
                 $item_type::remove_item($params);
                 break;
             case "move_item":
                 $item_type::move_item($params);
                 break;
         }
     } else {
         Toolbox::logDebug("package subtype not found : " . $params['itemtype']);
         Html::displayErrorAndDie("package subtype not found");
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:24,代码来源:deploypackage.class.php


注:本文中的Toolbox::logDebug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。