本文整理汇总了PHP中isCommandLine函数的典型用法代码示例。如果您正苦于以下问题:PHP isCommandLine函数的具体用法?PHP isCommandLine怎么用?PHP isCommandLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isCommandLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: glpiautoload
function glpiautoload($classname)
{
global $DEBUG_AUTOLOAD, $CFG_GLPI;
static $notfound = array();
// empty classname or non concerted plugin
if (empty($classname) || is_numeric($classname)) {
return FALSE;
}
$dir = GLPI_ROOT . "/inc/";
//$classname="PluginExampleProfile";
if ($plug = isPluginItemType($classname)) {
$plugname = strtolower($plug['plugin']);
$dir = GLPI_ROOT . "/plugins/{$plugname}/inc/";
$item = strtolower($plug['class']);
// Is the plugin activate ?
// Command line usage of GLPI : need to do a real check plugin activation
if (isCommandLine()) {
$plugin = new Plugin();
if (count($plugin->find("directory='{$plugname}' AND state=" . Plugin::ACTIVATED)) == 0) {
// Plugin does not exists or not activated
return FALSE;
}
} else {
// Standard use of GLPI
if (!in_array($plugname, $_SESSION['glpi_plugins'])) {
// Plugin not activated
return FALSE;
}
}
} else {
// Is ezComponent class ?
$matches = array();
if (preg_match('/^ezc([A-Z][a-z]+)/', $classname, $matches)) {
include_once GLPI_EZC_BASE;
ezcBase::autoload($classname);
return TRUE;
} else {
$item = strtolower($classname);
}
}
// No errors for missing classes due to implementation
if (!isset($CFG_GLPI['missingclasses']) or !in_array($item, $CFG_GLPI['missingclasses'])) {
if (file_exists("{$dir}{$item}.class.php")) {
include_once "{$dir}{$item}.class.php";
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$DEBUG_AUTOLOAD[] = $classname;
}
} else {
if (!isset($notfound["{$classname}"])) {
// trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case)
//Toolbox::logInFile('debug', "file $dir$item.class.php not founded trying to load class $classname\n");
trigger_error("GLPI autoload : file {$dir}{$item}.class.php not founded trying to load class '{$classname}'");
$notfound["{$classname}"] = TRUE;
}
}
}
}
示例2: getLoginUserID
/**
* Get the Login User ID or return cron user ID for cron jobs
*
* @param $force_human boolean : force human / do not return cron user
*
* return false if user is not logged in
*
* @return int or string : int for user id, string for cron jobs
**/
function getLoginUserID($force_human = true)
{
if (!$force_human) {
// Check cron jobs
if (isset($_SESSION["glpicronuserrunning"]) && (isCommandLine() || strpos($_SERVER['PHP_SELF'], "cron.php"))) {
return $_SESSION["glpicronuserrunning"];
}
}
if (isset($_SESSION["glpiID"])) {
return $_SESSION["glpiID"];
}
return false;
}
示例3: userErrorHandlerDebug
/**
* Specific error handler in Debug mode
*
* @param $errno integer level of the error raised.
* @param $errmsg string error message.
* @param $filename string filename that the error was raised in.
* @param $linenum integer line number the error was raised at.
* @param $vars array that points to the active symbol table at the point the error occurred.
**/
static function userErrorHandlerDebug($errno, $errmsg, $filename, $linenum, $vars)
{
// For file record
$type = self::userErrorHandlerNormal($errno, $errmsg, $filename, $linenum, $vars);
// Display
if (!isCommandLine()) {
echo '<div style="position:fload-left; background-color:red; z-index:10000">' . '<span class="b">PHP ' . $type . ': </span>';
echo $errmsg . ' in ' . $filename . ' at line ' . $linenum . '</div>';
} else {
echo 'PHP ' . $type . ': ' . $errmsg . ' in ' . $filename . ' at line ' . $linenum . "\n";
}
}
示例4: transferComputer
/**
* Do automatic transfer if option is enable
*
* @param $line_links array : data from glpi_plugin_ocsinventoryng_ocslinks table
* @return nothing
* @internal param array $line_ocs : data from ocs tables
*
*/
static function transferComputer($line_links)
{
global $DB, $CFG_GLPI;
$ocsClient = self::getDBocs($line_links["plugin_ocsinventoryng_ocsservers_id"]);
$cfg_ocs = self::getConfig($line_links["plugin_ocsinventoryng_ocsservers_id"]);
$ocsComputer = $ocsClient->getComputer($line_links["ocsid"]);
$locations_id = 0;
$contact = isset($ocsComputer['META']["USERID"]) ? $ocsComputer['META']["USERID"] : "";
if (!empty($contact)) {
$query = "SELECT `id`\n FROM `glpi_users`\n WHERE `name` = '" . $contact . "';";
$result = $DB->query($query);
if ($DB->numrows($result) == 1) {
$user_id = $DB->result($result, 0, 0);
$user = new User();
$user->getFromDB($user_id);
$locations_id = $user->fields["locations_id"];
}
}
// Get all rules for the current plugin_ocsinventoryng_ocsservers_id
$rule = new RuleImportEntityCollection();
$data = array();
$data = $rule->processAllRules(array('ocsservers_id' => $line_links["plugin_ocsinventoryng_ocsservers_id"], '_source' => 'ocsinventoryng', 'locations_id' => $locations_id), array('locations_id' => $locations_id), array('ocsid' => $line_links["ocsid"]));
// If entity is changing move items to the new entities_id
if (isset($data['entities_id']) && $data['entities_id'] > -1 && $data['entities_id'] != $line_links['entities_id']) {
if (!isCommandLine() && !Session::haveAccessToEntity($data['entities_id'])) {
Html::displayRightError();
}
$transfer = new Transfer();
$transfer->getFromDB($CFG_GLPI['transfers_id_auto']);
$item_to_transfer = array("Computer" => array($line_links['computers_id'] => $line_links['computers_id']));
$transfer->moveItems($item_to_transfer, $data['entities_id'], $transfer->fields);
}
//If location is update by a rule
self::updateLocation($line_links, $data, $cfg_ocs);
}
示例5: nullFooter
/**
* Print footer for null page
**/
static function nullFooter()
{
global $CFG_GLPI, $FOOTER_LOADED;
// Print foot for null page
if ($FOOTER_LOADED) {
return;
}
$FOOTER_LOADED = true;
if (!isCommandLine()) {
echo "</div></div>";
echo "<div id='footer-login'>";
echo "<a href='http://glpi-project.org/' title='Powered By Teclib'>";
echo "GLPI version " . (isset($CFG_GLPI["version"]) ? $CFG_GLPI["version"] : "") . " Copyright (C) " . "2015-" . " By Teclib'" . " - Copyright (C) 2003-2015 INDEPNET Development Team";
echo "</a></div>";
echo "</body></html>";
}
closeDBConnections();
}
示例6: updateDateMod
/**
* Update date mod of the ticket
*
* @since version 0.83.3 new proto
*
* @param $ID ID of the ticket
* @param $no_stat_computation boolean do not cumpute take into account stat (false by default)
* @param $users_id_lastupdater integer to force last_update id (default 0 = not used)
**/
function updateDateMod($ID, $no_stat_computation = false, $users_id_lastupdater = 0)
{
global $DB;
if ($this->getFromDB($ID)) {
if (!$no_stat_computation && (Session::haveRight('task', CommonITILTask::ADDALLITEM) || Session::haveRightsOr('followup', array(TicketFollowup::ADDALLTICKET, TicketFollowup::ADDMYTICKET, TicketFollowup::ADDGROUPTICKET)) || $this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $this->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']) || isCommandLine())) {
if ($this->fields['takeintoaccount_delay_stat'] == 0) {
return $this->update(array('id' => $ID, 'takeintoaccount_delay_stat' => $this->computeTakeIntoAccountDelayStat(), '_disablenotif' => true));
}
}
parent::updateDateMod($ID, $no_stat_computation, $users_id_lastupdater);
}
}
示例7: nullFooter
/**
* Print footer for null page
**/
static function nullFooter()
{
global $CFG_GLPI, $FOOTER_LOADED;
// Print foot for null page
if ($FOOTER_LOADED) {
return;
}
$FOOTER_LOADED = true;
if (!isCommandLine()) {
echo "</div></div>";
echo "<div id='footer-login'>" . self::getCopyrightMessage() . "</div>";
echo "</body></html>";
}
closeDBConnections();
}
示例8: replayRulesOnExistingDB
/**
* @see RuleCollection::replayRulesOnExistingDB()
**/
function replayRulesOnExistingDB($offset = 0, $maxtime = 0, $items = array(), $params = array())
{
global $DB;
if (isCommandLine()) {
printf(__('Replay rules on existing database started on %s') . "\n", date("r"));
}
$nb = 0;
$i = $offset;
//Select all the differents software
$sql = "SELECT DISTINCT `glpi_printers`.`name`,\n `glpi_manufacturers`.`name` AS manufacturer,\n `glpi_printers`.`manufacturers_id` AS manufacturers_id,\n `glpi_printers`.`comment` AS comment\n FROM `glpi_printers`\n LEFT JOIN `glpi_manufacturers`\n ON (`glpi_manufacturers`.`id` = `glpi_printers`.`manufacturers_id`) ";
// Do not replay on dustbin and templates
$sql .= "WHERE `glpi_printers`.`is_deleted` = '0'\n AND `glpi_printers`.`is_template` = '0' ";
if ($offset) {
$sql .= " LIMIT " . intval($offset) . ",999999999";
}
$res = $DB->query($sql);
$nb = $DB->numrows($res) + $offset;
$step = $nb > 1000 ? 50 : ($nb > 20 ? floor($DB->numrows($res) / 20) : 1);
while ($input = $DB->fetch_assoc($res)) {
if (!($i % $step)) {
if (isCommandLine()) {
//TRANS: %1$s is a date, %2$s is a row, %3$s is total row, %4$s is memory
printf(__('%1$s - replay rules on existing database: %2$s/%3$s (%4$s Mio)') . "\n", date("H:i:s"), $i, $nb, round(memory_get_usage() / (1024 * 1024), 2));
} else {
Html::changeProgressBarPosition($i, $nb, "{$i} / {$nb}");
}
}
//Replay printer dictionnary rules
$res_rule = $this->processAllRules($input, array(), array());
foreach (array('manufacturer', 'is_global', 'name') as $attr) {
if (isset($res_rule[$attr]) && $res_rule[$attr] == '') {
unset($res_rule[$attr]);
}
}
//If the software's name or version has changed
if (self::somethingHasChanged($res_rule, $input)) {
$IDs = array();
//Find all the printers in the database with the same name and manufacturer
$sql = "SELECT `id`\n FROM `glpi_printers`\n WHERE `name` = '" . $input["name"] . "'\n AND `manufacturers_id` = '" . $input["manufacturers_id"] . "'";
$res_printer = $DB->query($sql);
if ($DB->numrows($res_printer) > 0) {
//Store all the printer's IDs in an array
while ($result = $DB->fetch_assoc($res_printer)) {
$IDs[] = $result["id"];
}
//Replay dictionnary on all the printers
$this->replayDictionnaryOnPrintersByID($IDs, $res_rule);
}
}
$i++;
if ($maxtime) {
$crt = explode(" ", microtime());
if ($crt[0] + $crt[1] > $maxtime) {
break;
}
}
}
if (isCommandLine()) {
printf(__('Replay rules on existing database: %1$s/%2$s') . "\n", $i, $nb);
} else {
Html::changeProgressBarPosition($i, $nb, "{$i} / {$nb}");
}
if (isCommandLine()) {
printf(__('Replay rules on existing database ended on %s') . "\n", date("r"));
}
return $i == $nb ? -1 : $i;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:70,代码来源:ruledictionnaryprintercollection.class.php
示例9: chdir
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
// Ensure current directory when run from crontab
chdir(dirname($_SERVER["SCRIPT_FILENAME"]));
define('DO_NOT_CHECK_HTTP_REFERER', 1);
include '../inc/includes.php';
if (!is_writable(GLPI_LOCK_DIR)) {
//TRANS: %s is a directory
echo "\t" . sprintf(__('ERROR: %s is not writable') . "\n", GLPI_LOCK_DIR);
echo "\t" . __('run script as apache user') . "\n";
exit(1);
}
if (!isCommandLine()) {
//The advantage of using background-image is that cron is called in a separate
//request and thus does not slow down output of the main page as it would if called
//from there.
$image = pack("H*", "47494638396118001800800000ffffff00000021f90401000000002c0000000" . "018001800000216848fa9cbed0fa39cb4da8bb3debcfb0f86e248965301003b");
header("Content-Type: image/gif");
header("Content-Length: " . strlen($image));
header("Cache-Control: no-cache,no-store");
header("Pragma: no-cache");
header("Connection: close");
echo $image;
flush();
CronTask::launch(CronTask::MODE_INTERNAL);
} else {
if (isset($_SERVER['argc']) && $_SERVER['argc'] > 1) {
// Parse command line options
示例10: glpi_autoload
/**
* To load classes
*
* @param $classname : class to load
**/
function glpi_autoload($classname)
{
global $DEBUG_AUTOLOAD, $CFG_GLPI;
static $notfound = array('xStates' => true, 'xAllAssets' => true);
// empty classname or non concerted plugin or classname containing dot (leaving GLPI main treee)
if (empty($classname) || is_numeric($classname) || strpos($classname, '.') !== false) {
return false;
}
$dir = GLPI_ROOT . "/inc/";
if ($plug = isPluginItemType($classname)) {
$plugname = strtolower($plug['plugin']);
$dir = GLPI_ROOT . "/plugins/{$plugname}/inc/";
$item = strtolower($plug['class']);
// Is the plugin activate ?
// Command line usage of GLPI : need to do a real check plugin activation
if (isCommandLine()) {
$plugin = new Plugin();
if (count($plugin->find("directory='{$plugname}' AND state=" . Plugin::ACTIVATED)) == 0) {
// Plugin does not exists or not activated
return false;
}
} else {
// Standard use of GLPI
if (!in_array($plugname, $_SESSION['glpi_plugins'])) {
// Plugin not activated
return false;
}
}
} else {
// Is ezComponent class ?
if (preg_match('/^ezc([A-Z][a-z]+)/', $classname, $matches)) {
include_once GLPI_EZC_BASE;
ezcBase::autoload($classname);
return true;
}
// Is Zend class ?
// if (preg_match('/^Zend/',$classname,$matches)) {
// if (GLPI_ZEND_PATH) {
// set_include_path(GLPI_ZEND_PATH . PATH_SEPARATOR . get_include_path());
// }
// require_once("Zend/Loader.php");
//
// Zend_Loader::loadClass($classname);
// return true;
// }
// Do not try to load phpcas using GLPI autoload
if (preg_match('/^CAS_.*/', $classname)) {
return false;
}
$item = strtolower($classname);
}
// No errors for missing classes due to implementation
if (file_exists("{$dir}{$item}.class.php")) {
include_once "{$dir}{$item}.class.php";
if (isset($_SESSION['glpi_use_mode']) && $_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$DEBUG_AUTOLOAD[] = $classname;
}
} else {
if (!isset($notfound["x{$classname}"])) {
// trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case)
// trigger_error("GLPI autoload : file $dir$item.class.php not founded trying to load class '$classname'");
$notfound["x{$classname}"] = true;
}
}
}
示例11: isCron
/**
* Detect cron mode or interactive
*
* @since version 0.84
*
* @return Boolean
**/
static function isCron()
{
return isset($_SESSION["glpicronuserrunning"]) && (isCommandLine() || strpos($_SERVER['PHP_SELF'], 'cron.php') || strpos($_SERVER['PHP_SELF'], 'crontask.form.php'));
}
示例12: getSearchOptions
//.........这里部分代码省略.........
$tab[86]['name'] = __('Child entities');
$tab[86]['datatype'] = 'bool';
$tab[86]['massiveaction'] = false;
$tab['versions'] = _n('Version', 'Versions', Session::getPluralNumber());
$tab[5]['table'] = 'glpi_softwareversions';
$tab[5]['field'] = 'name';
$tab[5]['name'] = __('Version name');
$tab[5]['forcegroupby'] = true;
$tab[5]['massiveaction'] = false;
$tab[5]['joinparams'] = array('jointype' => 'child');
$tab[5]['datatype'] = 'dropdown';
$tab[31]['table'] = 'glpi_states';
$tab[31]['field'] = 'completename';
$tab[31]['name'] = __('Status');
$tab[31]['datatype'] = 'dropdown';
$tab[31]['forcegroupby'] = true;
$tab[31]['massiveaction'] = false;
$tab[31]['joinparams'] = array('beforejoin' => array('table' => 'glpi_softwareversions', 'joinparams' => array('jointype' => 'child')));
$tab[170]['table'] = 'glpi_softwareversions';
$tab[170]['field'] = 'comment';
$tab[170]['name'] = __('Version comments');
$tab[170]['forcegroupby'] = true;
$tab[170]['datatype'] = 'text';
$tab[170]['massiveaction'] = false;
$tab[170]['joinparams'] = array('jointype' => 'child');
$tab[4]['table'] = 'glpi_operatingsystems';
$tab[4]['field'] = 'name';
$tab[4]['datatype'] = 'dropdown';
$tab[4]['name'] = __('Operating system');
$tab[4]['forcegroupby'] = true;
$tab[4]['joinparams'] = array('beforejoin' => array('table' => 'glpi_softwareversions', 'joinparams' => array('jointype' => 'child')));
$tab += Notepad::getSearchOptionsToAdd();
$tab['license'] = _n('License', 'Licenses', Session::getPluralNumber());
$licjoin = array();
$licjoinexpire = array();
if (!Session::isCron() && !isCommandLine()) {
// no filter for cron
$licjoin = array('jointype' => 'child', 'condition' => getEntitiesRestrictRequest(' AND', "NEWTABLE", '', '', true));
$licjoinexpire = array('jointype' => 'child', 'condition' => getEntitiesRestrictRequest(' AND', "NEWTABLE", '', '', true) . " AND (NEWTABLE.`expire` IS NULL\n OR NEWTABLE.`expire` > NOW())");
}
$tab[160]['table'] = 'glpi_softwarelicenses';
$tab[160]['field'] = 'name';
$tab[160]['name'] = __('License name');
$tab[160]['datatype'] = 'dropdown';
$tab[160]['forcegroupby'] = true;
$tab[160]['massiveaction'] = false;
$tab[160]['joinparams'] = $licjoinexpire;
$tab[161]['table'] = 'glpi_softwarelicenses';
$tab[161]['field'] = 'serial';
$tab[161]['datatype'] = 'string';
$tab[161]['name'] = __('License serial number');
$tab[161]['forcegroupby'] = true;
$tab[161]['massiveaction'] = false;
$tab[161]['joinparams'] = $licjoinexpire;
$tab[162]['table'] = 'glpi_softwarelicenses';
$tab[162]['field'] = 'otherserial';
$tab[162]['datatype'] = 'string';
$tab[162]['name'] = __('License inventory number');
$tab[162]['forcegroupby'] = true;
$tab[162]['massiveaction'] = false;
$tab[162]['joinparams'] = $licjoinexpire;
$tab[163]['table'] = 'glpi_softwarelicenses';
$tab[163]['field'] = 'number';
$tab[163]['name'] = _x('phone', 'Number of licenses');
$tab[163]['forcegroupby'] = true;
$tab[163]['usehaving'] = true;
$tab[163]['datatype'] = 'number';
$tab[163]['massiveaction'] = false;
$tab[163]['joinparams'] = $licjoinexpire;
$tab[164]['table'] = 'glpi_softwarelicensetypes';
$tab[164]['field'] = 'name';
$tab[164]['datatype'] = 'dropdown';
$tab[164]['name'] = _n('License type', 'License types', Session::getPluralNumber());
$tab[164]['forcegroupby'] = true;
$tab[164]['massiveaction'] = false;
$tab[164]['joinparams'] = array('beforejoin' => array('table' => 'glpi_softwarelicenses', 'joinparams' => $licjoinexpire));
$tab[165]['table'] = 'glpi_softwarelicenses';
$tab[165]['field'] = 'comment';
$tab[165]['name'] = __('License comments');
$tab[165]['forcegroupby'] = true;
$tab[165]['datatype'] = 'text';
$tab[165]['massiveaction'] = false;
$tab[165]['joinparams'] = $licjoinexpire;
$tab[166]['table'] = 'glpi_softwarelicenses';
$tab[166]['field'] = 'expire';
$tab[166]['name'] = __('Expiration');
$tab[166]['forcegroupby'] = true;
$tab[166]['datatype'] = 'date';
$tab[166]['emptylabel'] = __('Never expire');
$tab[166]['massiveaction'] = false;
$tab[166]['joinparams'] = $licjoinexpire;
$tab[167]['table'] = 'glpi_softwarelicenses';
$tab[167]['field'] = 'is_valid';
$tab[167]['name'] = _x('adjective', 'Valid');
$tab[167]['forcegroupby'] = true;
$tab[167]['datatype'] = 'bool';
$tab[167]['massiveaction'] = false;
$tab[167]['joinparams'] = $licjoinexpire;
return $tab;
}
示例13: update
/**
* Update some elements of an item in the database.
*
* @param $input array the _POST vars returned by the item form when press update
* @param $history boolean do history log ? (default 1)
* @param options array with the insert options
*
* @return boolean : true on success
**/
function update(array $input, $history = 1, $options = array())
{
global $DB, $CFG_GLPI;
if ($DB->isSlave()) {
return false;
}
if (!$this->getFromDB($input[static::getIndexName()])) {
return false;
}
// Store input in the object to be available in all sub-method / hook
$this->input = $input;
// Plugin hook - $this->input can be altered
Plugin::doHook("pre_item_update", $this);
if ($this->input && is_array($this->input)) {
$this->input = $this->prepareInputForUpdate($this->input);
if (isset($this->input['update'])) {
$this->input['_update'] = $this->input['update'];
unset($this->input['update']);
}
$this->filterValues(!isCommandLine());
}
// Valid input for update
if ($this->checkUnicity(false, $options)) {
if ($this->input && is_array($this->input)) {
// Fill the update-array with changes
$x = 0;
$this->updates = array();
$this->oldvalues = array();
foreach ($this->input as $key => $val) {
if (array_key_exists($key, $this->fields)) {
// Prevent history for date statement (for date for example)
if (is_null($this->fields[$key]) && $this->input[$key] == 'NULL') {
$this->fields[$key] = 'NULL';
}
// Compare item
$ischanged = true;
$searchopt = $this->getSearchOptionByField('field', $key, $this->getTable());
if (isset($searchopt['datatype'])) {
switch ($searchopt['datatype']) {
case 'string':
case 'text':
$ischanged = strcmp($DB->escape($this->fields[$key]), $this->input[$key]) != 0;
break;
case 'itemlink':
if ($key == 'name') {
$ischanged = strcmp($DB->escape($this->fields[$key]), $this->input[$key]) != 0;
break;
}
// else default
// else default
default:
$ischanged = $DB->escape($this->fields[$key]) != $this->input[$key];
break;
}
} else {
// No searchoption case
$ischanged = $DB->escape($this->fields[$key]) != $this->input[$key];
}
if ($ischanged) {
if ($key != "id") {
// Store old values
if (!in_array($key, $this->history_blacklist)) {
$this->oldvalues[$key] = $this->fields[$key];
}
$this->fields[$key] = $this->input[$key];
$this->updates[$x] = $key;
$x++;
}
}
}
}
if (count($this->updates)) {
if (array_key_exists('date_mod', $this->fields)) {
// is a non blacklist field exists
if (count(array_diff($this->updates, $this->history_blacklist)) > 0) {
$this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
$this->updates[$x++] = 'date_mod';
}
}
$this->pre_updateInDB();
if (count($this->updates)) {
if ($this->updateInDB($this->updates, $this->dohistory && $history ? $this->oldvalues : array())) {
$this->addMessageOnUpdateAction();
Plugin::doHook("item_update", $this);
//Fill forward_entity_to array with itemtypes coming from plugins
if (isset(self::$plugins_forward_entity[$this->getType()])) {
foreach (self::$plugins_forward_entity[$this->getType()] as $itemtype) {
static::$forward_entity_to[] = $itemtype;
}
}
// forward entity information if needed
//.........这里部分代码省略.........
示例14: getSearchOptionsToAdd
static function getSearchOptionsToAdd()
{
$tab = array();
if (!self::canView()) {
return $tab;
}
$tab['license'] = _n('License', 'Licenses', Session::getPluralNumber());
$licjoin = array();
$licjoinexpire = array();
if (!Session::isCron() && !isCommandLine()) {
// no filter for cron
$licjoin = array('jointype' => 'child', 'condition' => getEntitiesRestrictRequest(' AND', "NEWTABLE", '', '', true));
$licjoinexpire = array('jointype' => 'child', 'condition' => getEntitiesRestrictRequest(' AND', "NEWTABLE", '', '', true) . " AND (NEWTABLE.`expire` IS NULL\n OR NEWTABLE.`expire` > NOW())");
}
$tab[160]['table'] = 'glpi_softwarelicenses';
$tab[160]['field'] = 'name';
$tab[160]['name'] = __('License name');
$tab[160]['datatype'] = 'dropdown';
$tab[160]['forcegroupby'] = true;
$tab[160]['massiveaction'] = false;
$tab[160]['joinparams'] = $licjoinexpire;
$tab[161]['table'] = 'glpi_softwarelicenses';
$tab[161]['field'] = 'serial';
$tab[161]['datatype'] = 'string';
$tab[161]['name'] = __('License serial number');
$tab[161]['forcegroupby'] = true;
$tab[161]['massiveaction'] = false;
$tab[161]['joinparams'] = $licjoinexpire;
$tab[162]['table'] = 'glpi_softwarelicenses';
$tab[162]['field'] = 'otherserial';
$tab[162]['datatype'] = 'string';
$tab[162]['name'] = __('License inventory number');
$tab[162]['forcegroupby'] = true;
$tab[162]['massiveaction'] = false;
$tab[162]['joinparams'] = $licjoinexpire;
$tab[163]['table'] = 'glpi_softwarelicenses';
$tab[163]['field'] = 'number';
$tab[163]['name'] = _x('phone', 'Number of licenses');
$tab[163]['forcegroupby'] = true;
$tab[163]['usehaving'] = true;
$tab[163]['datatype'] = 'number';
$tab[163]['massiveaction'] = false;
$tab[163]['joinparams'] = $licjoinexpire;
$tab[164]['table'] = 'glpi_softwarelicensetypes';
$tab[164]['field'] = 'name';
$tab[164]['datatype'] = 'dropdown';
$tab[164]['name'] = _n('License type', 'License types', Session::getPluralNumber());
$tab[164]['forcegroupby'] = true;
$tab[164]['massiveaction'] = false;
$tab[164]['joinparams'] = array('beforejoin' => array('table' => 'glpi_softwarelicenses', 'joinparams' => $licjoinexpire));
$tab[165]['table'] = 'glpi_softwarelicenses';
$tab[165]['field'] = 'comment';
$tab[165]['name'] = __('License comments');
$tab[165]['forcegroupby'] = true;
$tab[165]['datatype'] = 'text';
$tab[165]['massiveaction'] = false;
$tab[165]['joinparams'] = $licjoinexpire;
$tab[166]['table'] = 'glpi_softwarelicenses';
$tab[166]['field'] = 'expire';
$tab[166]['name'] = __('Expiration');
$tab[166]['forcegroupby'] = true;
$tab[166]['datatype'] = 'date';
$tab[166]['emptylabel'] = __('Never expire');
$tab[166]['massiveaction'] = false;
$tab[166]['joinparams'] = $licjoinexpire;
$tab[167]['table'] = 'glpi_softwarelicenses';
$tab[167]['field'] = 'is_valid';
$tab[167]['name'] = _x('adjective', 'Valid');
$tab[167]['forcegroupby'] = true;
$tab[167]['datatype'] = 'bool';
$tab[167]['massiveaction'] = false;
$tab[167]['joinparams'] = $licjoinexpire;
return $tab;
}
示例15: start
/**
* Start a task, timer, stat, log, ...
*
* @return bool : true if ok (not start by another)
**/
function start()
{
global $DB, $LANG;
if (!isset($this->fields['id']) || $DB->isSlave()) {
return false;
}
$query = "UPDATE `" . $this->getTable() . "`\n SET `state` = '" . self::STATE_RUNNING . "',\n `lastrun` = NOW()\n WHERE `id` = '" . $this->fields['id'] . "'\n AND `state` != '" . self::STATE_RUNNING . "'";
$result = $DB->query($query);
if ($DB->affected_rows($result) > 0) {
$this->timer = microtime(true);
$this->volume = 0;
$log = new CronTaskLog();
$txt = $LANG['crontask'][36] . " : " . $this->getModeName(isCommandLine() ? self::MODE_EXTERNAL : self::MODE_INTERNAL);
$this->startlog = $log->add(array('crontasks_id' => $this->fields['id'], 'date' => $_SESSION['glpi_currenttime'], 'content' => addslashes($txt), 'crontasklogs_id' => 0, 'state' => CronTaskLog::STATE_START, 'volume' => 0, 'elapsed' => 0));
return true;
}
return false;
}