本文整理汇总了PHP中Log::history方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::history方法的具体用法?PHP Log::history怎么用?PHP Log::history使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::history方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
// Unlink the computer
$sql = "DELETE\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '" . $event["items_id"] . "'";
if ($debug) {
echo "DEBUG: {$sql} \n";
}
if ($run) {
// Restore previous state
$comp->update($input);
// Unlink the computer
$resupd = $DB->query($sql);
if ($res) {
$nbupd += $DB->affected_rows();
$changes[0] = 0;
$changes[2] = "Rollback: restauration statut au {$maxti}";
$changes[1] = "";
Log::history($event["items_id"], 'Computer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
} else {
echo "*** MySQL : {$sql}\n*** Error : " . $DB->error() . "\n";
}
}
}
// Else
}
// If PC
}
// foreach event
printf("=> %d computers, %d updates\n", $nb, $nbupd);
echo "Saving reports in " . GLPI_LOG_DIR . "\n";
$nbc = 0;
foreach ($tabres as $ent => $comps) {
$name = Dropdown::getDropdownName("glpi_entities", $ent);
示例2: addHistory
public function addHistory($type, $old_value = '', $new_value = '', $ID)
{
$changes[0] = 0;
$changes[1] = $old_value;
$changes[2] = $new_value;
Log::history($ID, $type, $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
}
示例3: post_addItem
function post_addItem()
{
global $CFG_GLPI;
$donotif = $CFG_GLPI["use_mailing"];
// if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
// $donotif = false;
// }
$this->input["_job"]->updateDateMod($this->input["tickets_id"], false, $this->input["users_id"]);
if (isset($this->input["_close"]) && $this->input["_close"] && $this->input["_job"]->fields["status"] == CommonITILObject::SOLVED) {
$update['id'] = $this->input["_job"]->fields['id'];
$update['status'] = CommonITILObject::CLOSED;
$update['closedate'] = $_SESSION["glpi_currenttime"];
// Use update method for history
$this->input["_job"]->update($update);
$donotif = false;
// Done for ticket update (new status)
}
if (isset($this->input["_reopen"]) && $this->input["_reopen"] && in_array($this->input["_job"]->fields["status"], array(CommonITILObject::CLOSED, CommonITILObject::SOLVED, CommonITILObject::WAITING))) {
if ($this->input["_job"]->countUsers(CommonITILActor::ASSIGN) > 0 || $this->input["_job"]->countGroups(CommonITILActor::ASSIGN) > 0 || $this->input["_job"]->countSuppliers(CommonITILActor::ASSIGN) > 0) {
$update['status'] = CommonITILObject::ASSIGNED;
} else {
$update['status'] = CommonITILObject::INCOMING;
}
$update['id'] = $this->input["_job"]->fields['id'];
// Use update method for history
$this->input["_job"]->update($update);
$donotif = false;
// Done for ticket update (new status)
}
if ($donotif) {
$options = array('followup_id' => $this->fields["id"], 'is_private' => $this->fields['is_private']);
NotificationEvent::raiseEvent("add_followup", $this->input["_job"], $options);
}
// Add log entry in the ticket
$changes[0] = 0;
$changes[1] = '';
$changes[2] = $this->fields['id'];
Log::history($this->getField('tickets_id'), 'Ticket', $changes, $this->getType(), Log::HISTORY_ADD_SUBITEM);
}
示例4: post_deleteFromDB
function post_deleteFromDB()
{
$vers = new SoftwareVersion();
if (!$vers->getFromDB($this->fields['softwareversions_id'])) {
return false;
}
/// Could not be possible : because several computers may be linked to a version
// Update affected licenses
// $lic = new SoftwareLicense();
// $query = "SELECT `id`
// FROM `glpi_softwarelicenses`
// WHERE `softwares_id` = '".$vers->fields['softwares_id']."'
// AND `computers_id` = '".$this->fields['computers_id']."'
// AND `softwareversions_id_use` = '".$this->fields['softwareversions_id']."'";
// foreach ($DB->request($query) as $data) {
// $data['softwareversions_id_use'] = 0;
// $lic->update($data);
// }
if (isset($this->input['_no_history']) && $this->input['_no_history']) {
return false;
}
$soft = new Software();
if ($soft->getFromDB($vers->fields['softwares_id'])) {
$changes[0] = '0';
$changes[1] = addslashes($soft->fields["name"] . " " . $vers->fields["name"]);
$changes[2] = "";
// Log on Computer history
Log::history($this->fields['computers_id'], 'Computer', $changes, 0, HISTORY_UNINSTALL_SOFTWARE);
}
$comp = new Computer();
if ($comp->getFromDB($this->fields['computers_id'])) {
$changes[0] = '0';
$changes[1] = addslashes($comp->fields["name"]);
$changes[2] = "";
// Log on SoftwareVersion history
Log::history($this->fields['softwareversions_id'], 'SoftwareVersion', $changes, 0, HISTORY_UNINSTALL_SOFTWARE);
}
}
示例5: post_deleteFromDB
/**
* Actions done after the DELETE of the item in the database
*
* @since version 0.84
*
*@return nothing
**/
function post_deleteFromDB()
{
if (isset($this->input['_no_history']) && $this->input['_no_history'] || !static::$logs_for_item_1 && !static::$logs_for_item_2) {
return;
}
$item1 = $this->getConnexityItem(static::$itemtype_1, static::$items_id_1);
$item2 = $this->getConnexityItem(static::$itemtype_2, static::$items_id_2);
if ($item1 !== false && $item2 !== false) {
if ($item1->dohistory && static::$logs_for_item_1) {
$changes[0] = '0';
$changes[1] = addslashes($this->getHistoryNameForItem1($item2, 'delete'));
$changes[2] = "";
Log::history($item1->getID(), $item1->getType(), $changes, $item2->getType(), static::$log_history_1_delete);
}
if ($item2->dohistory && static::$logs_for_item_2) {
$changes[0] = '0';
$changes[1] = addslashes($this->getHistoryNameForItem2($item1, 'delete'));
$changes[2] = "";
Log::history($item2->getID(), $item2->getType(), $changes, $item1->getType(), static::$log_history_2_delete);
}
}
}
示例6: history
/**
* Add an history entry to a computer
*
* @param $computers_id Integer, ID of the computer
* @param $changes Array, see Log::history
* @param $action Integer in PluginOcsinventoryngOcslink::HISTORY_OCS_*
*
* @return Integer id of the inserted entry
**/
static function history($computers_id, $changes, $action)
{
return Log::history($computers_id, 'Computer', $changes, __CLASS__, Log::HISTORY_PLUGIN + $action);
}
示例7: post_deleteFromDB
function post_deleteFromDB()
{
global $LANG;
// Add log entry in the ticket
$changes[0] = 0;
$changes[1] = '';
$changes[2] = addslashes($LANG['validation'][30] . " " . getUserName($this->fields["users_id_validate"]));
Log::history($this->getField('tickets_id'), 'Ticket', $changes, $this->getType(), HISTORY_LOG_SIMPLE_MESSAGE);
}
示例8: cloneItem
static function cloneItem(array $param)
{
// Sanity check
if (!isset($param['itemtype']) || !isset($param['id']) || !isset($param['name']) || !array_key_exists($param['itemtype'], self::$clone_types) || empty($param['name']) || !($item = getItemForItemtype($param['itemtype']))) {
return false;
}
// Read original and prepare clone
$item->check($param['id'], 'r');
$input = ToolBox::addslashes_deep($item->fields);
$input['name'] = $param['name'];
$input['_add'] = 1;
$input['_old_id'] = $input['id'];
unset($input['id']);
if ($item->isEntityAssign()) {
$input['entities_id'] = $_SESSION['glpiactive_entity'];
}
// Manage NULL fields in original
foreach ($input as $k => $v) {
if (is_null($input[$k])) {
$input[$k] = "NULL";
}
}
// Specific to itemtype - before clone
if (method_exists(self::$clone_types[$param['itemtype']], 'preClone')) {
$input = call_user_func(array(self::$clone_types[$param['itemtype']], 'preClone'), $item, $input);
}
// Clone
$clone = clone $item;
$clone->check(-1, 'w', $input);
$new = $clone->add($input);
// Specific to itemtype - after clone
if (method_exists(self::$clone_types[$param['itemtype']], 'postClone')) {
call_user_func(array(self::$clone_types[$param['itemtype']], 'postClone'), $clone, $param['id']);
}
Plugin::doHook('item_clone', $clone);
// History
if ($clone->dohistory) {
$changes[0] = '0';
$changes[1] = '';
$changes[2] = addslashes(sprintf(__('%1$s %2$s'), __('Clone of', 'behaviors'), $item->getNameID(0, true)));
Log::history($clone->getID(), $clone->getType(), $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
}
}
示例9: restore
/**
* Restore an item trashed in the database.
*
* @param $input array : the _POST vars returned by the item form when press restore
* @param $history boolean : do history log ?
*
* @return boolean : true on success
**/
function restore($input, $history = 1)
{
if (!$this->getFromDB($input[$this->getIndexName()])) {
return false;
}
if (isset($input['restore'])) {
$input['_restore'] = $input['restore'];
unset($input['restore']);
}
// Store input in the object to be available in all sub-method / hook
$this->input = $input;
doHook("pre_item_restore", $this);
if ($this->restoreInDB()) {
$this->addMessageOnRestoreAction();
if ($this->dohistory && $history) {
$changes[0] = 0;
$changes[1] = $changes[2] = "";
Log::history($this->input["id"], $this->getType(), $changes, 0, HISTORY_RESTORE_ITEM);
}
$this->post_restoreItem();
doHook("item_restore", $this);
return true;
}
return false;
}
示例10: execute
/**
* Standard method execution : checks if client can execute method + manage session
*
* @param $method string method name
* @param $params array the method parameters
* @param $protocol the communication protocol used
*
* @return array the method response
**/
function execute($method, $params, $protocol)
{
global $DB, $WEBSERVICES_METHOD, $TIMER_DEBUG;
// Don't display error in result
set_error_handler(array('Toolbox', 'userErrorHandlerNormal'));
ini_set('display_errors', 'Off');
$iptxt = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
$ipnum = strstr($iptxt, ':') === false ? ip2long($iptxt) : '';
if (isset($_SESSION["MESSAGE_AFTER_REDIRECT"])) {
// Avoid to keep "info" message between call
$_SESSION["MESSAGE_AFTER_REDIRECT"] = '';
}
$plug = new Plugin();
if ($plug->isActivated('webservices')) {
if (isset($params['session'])) {
self::setSession($params['session']);
}
// Build query for security check
$sql = "SELECT *\n FROM `glpi_plugin_webservices_clients`\n WHERE '" . addslashes($method) . "' REGEXP pattern\n AND `is_active` = '1' ";
if ($ipnum) {
$sql .= " AND (`ip_start` IS NULL\n OR (`ip_start` <= '{$ipnum}' AND `ip_end` >= '{$ipnum}'))";
} else {
$sql .= " AND `ipv6` = '" . addslashes($iptxt) . "'";
}
if (isset($params["username"])) {
$username = addslashes($params["username"]);
$password = md5(isset($params["password"]) ? $params["password"] : '');
$sql .= " AND (`username` IS NULL\n OR (`username` = '{$username}' AND `password` = '{$password}'))";
unset($params["username"]);
unset($params["password"]);
} else {
$username = 'anonymous';
$sql .= " AND `username` IS NULL ";
}
$deflate = $debug = $log = false;
$entities = array();
if (Session::getLoginUserID() && isset($_SESSION['glpiactiveentities'])) {
$username = $_SESSION['glpiname'];
// for log (no t for SQL request)
}
foreach ($DB->request($sql) as $data) {
// Check matching rules
// Store entities for not authenticated user
if (!Session::getLoginUserID()) {
if ($data['is_recursive']) {
foreach (getSonsOf("glpi_entities", $data['entities_id']) as $entity) {
$entities[$entity] = $entity;
}
} else {
$entities[$data['entities_id']] = $data['entities_id'];
}
}
// Where to log
if ($data["do_log"] == 2) {
// Log to file
$log = LOGFILENAME;
} else {
if ($data["do_log"] == 1) {
// Log to History
$log = $data["id"];
}
}
$debug = $data['debug'];
$deflate = $data['deflate'];
}
$callname = '';
// Always log when connection denied
if (!Session::getLoginUserID() && !count($entities)) {
$resp = self::Error($protocol, 1, __('Access denied'));
// log to file (not macthing config to use history)
Toolbox::logInFile(LOGFILENAME, __('Access denied') . " ({$username}, {$iptxt}, {$method}, {$protocol})\n");
} else {
// Allowed
if (!Session::getLoginUserID()) {
// TODO : probably more data should be initialized here
$_SESSION['glpiactiveentities'] = $entities;
}
// Log if configured
if (is_numeric($log)) {
$changes[0] = 0;
$changes[1] = "";
$changes[2] = __('Connection') . " ({$username}, {$iptxt}, {$method}, {$protocol})";
Log::history($log, 'PluginWebservicesClient', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
} else {
if ($log && !$debug) {
Toolbox::logInFile($log, __('Connection') . " ({$username}, {$iptxt}, {$method})\n");
}
}
$defserver = ini_get('zlib.output_compression');
if ($deflate && !$defserver) {
// Globally off, try to enable for this client
//.........这里部分代码省略.........
示例11: post_addItem
function post_addItem()
{
global $CFG_GLPI;
if (isset($this->input['_planningrecall'])) {
$this->input['_planningrecall']['items_id'] = $this->fields['id'];
PlanningRecall::manageDatas($this->input['_planningrecall']);
}
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->fields["begin"]) && !empty($this->fields["begin"])) {
Planning::checkAlreadyPlanned($this->fields["users_id_tech"], $this->fields["begin"], $this->fields["end"], array($this->getType() => array($this->fields["id"])));
}
if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
$donotif = false;
}
$this->input["_job"]->updateDateMod($this->input[$this->input["_job"]->getForeignKeyField()]);
if (isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
$this->input["_job"]->updateActionTime($this->input[$this->input["_job"]->getForeignKeyField()]);
}
if (!empty($this->fields['begin']) && ($this->input["_job"]->fields["status"] == CommonITILObject::INCOMING || $this->input["_job"]->fields["status"] == CommonITILObject::ASSIGNED)) {
$input2['id'] = $this->input["_job"]->getID();
$input2['status'] = CommonITILObject::PLANNED;
$input2['_disablenotif'] = true;
$this->input["_job"]->update($input2);
}
if ($donotif) {
$options = array('task_id' => $this->fields["id"], 'is_private' => $this->isPrivate());
NotificationEvent::raiseEvent('add_task', $this->input["_job"], $options);
}
// Add log entry in the ITIL object
$changes[0] = 0;
$changes[1] = '';
$changes[2] = $this->fields['id'];
Log::history($this->getField($this->input["_job"]->getForeignKeyField()), $this->input["_job"]->getTYpe(), $changes, $this->getType(), Log::HISTORY_ADD_SUBITEM);
}
示例12: post_addItem
function post_addItem()
{
global $CFG_GLPI;
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
$donotif = false;
}
$this->input["_job"]->updateDateMod($this->input["tickets_id"]);
if (isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
$this->input["_job"]->updateActionTime($this->input["tickets_id"]);
}
// if ($this->input["_isadmin"] && $this->input["_type"]!="update") {
if (isset($this->input["_plan"])) {
$this->input["_plan"]['tickettasks_id'] = $this->fields['id'];
$this->input["_plan"]['tickets_id'] = $this->input['tickets_id'];
$this->input["_plan"]['_nomail'] = 1;
$pt = new TicketPlanning();
if (!$pt->add($this->input["_plan"])) {
return false;
}
}
if ($donotif) {
$options = array('task_id' => $this->fields["id"]);
NotificationEvent::raiseEvent('add_task', $this->input["_job"], $options);
}
// Add log entry in the ticket
$changes[0] = 0;
$changes[1] = '';
$changes[2] = $this->fields['id'];
Log::history($this->getField('tickets_id'), 'Ticket', $changes, $this->getType(), HISTORY_ADD_SUBITEM);
}
示例13: post_deleteFromDB
function post_deleteFromDB()
{
// Update to blank networking item
// clean datas of linked ports if network one
$np1 = new NetworkPort();
$np2 = new NetworkPort();
if ($np1->getFromDB($this->fields['networkports_id_1']) && $np2->getFromDB($this->fields['networkports_id_2'])) {
$npnet = NULL;
$npdev = NULL;
if ($np1->fields["itemtype"] != 'NetworkEquipment' && $np2->fields["itemtype"] == 'NetworkEquipment') {
$npnet = $np2;
$npdev = $np1;
}
if ($np2->fields["itemtype"] != 'NetworkEquipment' && $np1->fields["itemtype"] == 'NetworkEquipment') {
$npnet = $np2;
$npdev = $np1;
}
if ($npnet && $npdev) {
// If addresses are egal, was copied from device in GLPI 0.71 : clear it
// Unset MAC and IP from networking device
if ($npnet->fields['mac'] == $npdev->fields['mac']) {
$npnet->update(array('id' => $npnet->fields['id'], 'mac' => ''));
}
if ($np1->fields['ip'] == $np2->fields['ip']) {
$npnet->update(array('id' => $npnet->fields['id'], 'ip' => '', 'netmask' => '', 'subnet' => '', 'gateway' => ''));
}
// Unset netpoint from common device
$npdev->update(array('id' => $npdev->fields['id'], 'netpoints_id' => 0));
}
// Manage history
$name = NOT_AVAILABLE;
$dohistory = false;
if (class_exists($np2->fields["itemtype"])) {
$item = new $np2->fields["itemtype"]();
if ($item->getFromDB($np2->fields["items_id"])) {
$name = $item->getName();
$dohistory = $item->dohistory;
}
}
if ($dohistory) {
$changes[0] = 0;
$changes[1] = $name;
$changes[2] = '';
if ($np1->fields["itemtype"] == 'NetworkEquipment') {
$changes[1] = "#" . $np1->fields["name"] . " > " . $changes[1];
}
if ($np2->fields["itemtype"] == 'NetworkEquipment') {
$changes[1] = $changes[1] . " > #" . $np2->fields["name"];
}
Log::history($np1->fields["items_id"], $np1->fields["itemtype"], $changes, $np2->fields["itemtype"], HISTORY_DISCONNECT_DEVICE);
}
$name = NOT_AVAILABLE;
$dohistory = false;
if (class_exists($np1->fields["itemtype"])) {
$item = new $np1->fields["itemtype"]();
if ($item->getFromDB($np1->fields["items_id"])) {
$name = $item->getName();
$dohistory = $item->dohistory;
}
}
if ($dohistory) {
$changes[0] = 0;
$changes[1] = $name;
$changes[2] = '';
if ($np2->fields["itemtype"] == 'NetworkEquipment') {
$changes[1] = "#" . $np2->fields["name"] . " > " . $changes[1];
}
if ($np1->fields["itemtype"] == 'NetworkEquipment') {
$changes[1] = $changes[1] . " > #" . $np1->fields["name"];
}
Log::history($np2->fields["items_id"], $np2->fields["itemtype"], $changes, $np1->fields["itemtype"], HISTORY_DISCONNECT_DEVICE);
}
}
}
示例14: restore
/**
* Restore an item put in the dustbin in the database.
*
* @param $input array the _POST vars returned by the item form when press restore
* @param $history boolean do history log ? (default 1)
*
* @return boolean : true on success
**/
function restore(array $input, $history = 1)
{
if (!$this->getFromDB($input[static::getIndexName()])) {
return false;
}
if (isset($input['restore'])) {
$input['_restore'] = $input['restore'];
unset($input['restore']);
}
// Store input in the object to be available in all sub-method / hook
$this->input = $input;
Plugin::doHook("pre_item_restore", $this);
if ($this->restoreInDB()) {
$this->addMessageOnRestoreAction();
if ($this->dohistory && $history) {
$changes[0] = 0;
$changes[1] = $changes[2] = "";
$logaction = Log::HISTORY_RESTORE_ITEM;
if ($this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
$logaction = Log::HISTORY_UNLOCK_ITEM;
}
Log::history($this->input["id"], $this->getType(), $changes, 0, $logaction);
}
$this->post_restoreItem();
Plugin::doHook("item_restore", $this);
if ($this->mailqueueonaction) {
QueuedMail::forceSendFor($this->getType(), $this->fields['id']);
}
return true;
}
return false;
}
示例15: uninstall
/**
* UnLink a cartridge linked to a printer
*
* UnLink the cartridge identified by $ID
*
* @param $ID : cartridge identifier
*
* @return boolean
**/
function uninstall($ID)
{
global $DB;
if ($this->getFromDB($ID)) {
$printer = new Printer();
$toadd = '';
if ($printer->getFromDB($this->getField("printers_id"))) {
$toadd .= ", `pages` = '" . $printer->fields['last_pages_counter'] . "' ";
}
$query = "UPDATE`" . $this->getTable() . "`\n SET `date_out` = '" . date("Y-m-d") . "'\n {$toadd}\n WHERE `id`='{$ID}'";
if ($result = $DB->query($query) && $DB->affected_rows() > 0) {
$changes[0] = '0';
$changes[1] = '';
$changes[2] = __('Uninstalling a cartridge');
Log::history($this->getField("printers_id"), 'Printer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
return true;
}
return false;
}
}