本文整理汇总了PHP中Ticket::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::getFromDB方法的具体用法?PHP Ticket::getFromDB怎么用?PHP Ticket::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::getFromDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterAdd
static function afterAdd(Group_Ticket $item)
{
global $DB;
//Toolbox::logDebug(__METHOD__, $item);
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif')) {
if ($item->getField('type') == CommonITILActor::ASSIGN) {
$ticket = new Ticket();
if ($ticket->getFromDB($item->getField('tickets_id'))) {
NotificationEvent::raiseEvent('plugin_behaviors_ticketnewgrp', $ticket);
}
}
}
// Check is the connected user is a tech
if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('own_ticket', 1)) {
return false;
// No check
}
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('single_tech_mode') != 0 && $item->input['type'] == CommonITILActor::ASSIGN) {
$crit = array('tickets_id' => $item->input['tickets_id'], 'type' => CommonITILActor::ASSIGN);
foreach ($DB->request('glpi_groups_tickets', $crit) as $data) {
if ($data['id'] != $item->getID()) {
$gu = new Group_Ticket();
$gu->delete($data);
}
}
if ($config->getField('single_tech_mode') == 2) {
foreach ($DB->request('glpi_tickets_users', $crit) as $data) {
$gu = new Ticket_User();
$gu->delete($data);
}
}
}
}
示例2: afterUpdate
static function afterUpdate(TicketSatisfaction $ticketsatisfaction)
{
$config = PluginBehaviorsConfig::getInstance();
$ticket = new Ticket();
if ($config->getField('add_notif') && $ticket->getFromDB($ticketsatisfaction->getField('tickets_id')) && $ticketsatisfaction->input["date_answered"]) {
NotificationEvent::raiseEvent('plugin_behaviors_replysurvey', $ticket);
}
}
示例3: afterPurge
static function afterPurge(Document_Item $document_item)
{
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif') && $document_item->fields['itemtype'] == 'Ticket' && isset($_POST['item'])) {
// prevent not use in case of purge ticket
$ticket = new Ticket();
$ticket->getFromDB($document_item->fields['items_id']);
NotificationEvent::raiseEvent('plugin_behaviors_document_itemdel', $ticket);
}
}
示例4: getGroups
function getGroups($ticket_id, $removeAlreadyAssigned = true)
{
$groups = $user_groups = $ticket_groups = array();
// get groups for user connected
$tmp_user_groups = Group_User::getUserGroups($_SESSION['glpiID']);
foreach ($tmp_user_groups as $current_group) {
$user_groups[$current_group['id']] = $current_group['id'];
$groups[$current_group['id']] = $current_group['id'];
}
// get groups already assigned in the ticket
if ($ticket_id > 0) {
$ticket = new Ticket();
$ticket->getFromDB($ticket_id);
foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $current_group) {
$ticket_groups[$current_group['groups_id']] = $current_group['groups_id'];
}
}
// To do an escalation, the user must be in a group currently assigned to the ticket
// or no group is assigned to the ticket
// TODO : matching with "view all tickets (yes/no) option in profile user"
if (!empty($ticket_groups) && count(array_intersect($ticket_groups, $user_groups)) == 0) {
return array();
}
//get all group which we can climb
if (count($groups) > 0) {
$group_group = $this->find("groups_id_source IN (" . implode(", ", $groups) . ")");
foreach ($group_group as $current_group) {
$groups[$current_group['groups_id_destination']] = $current_group['groups_id_destination'];
}
}
//remove already assigned groups
if (!empty($ticket_groups) && $removeAlreadyAssigned) {
$groups = array_diff_assoc($groups, $ticket_groups);
}
//add name to returned groups and remove non assignable groups
$group_obj = new Group();
foreach ($groups as $groups_id => &$groupname) {
$group_obj->getFromDB($groups_id);
//check if we can assign this group
if ($group_obj->fields['is_assign'] == 0) {
unset($groups[$groups_id]);
continue;
}
//add name
$groupname = $group_obj->fields['name'];
}
//sort by group name (and keep associative index)
asort($groups);
return $groups;
}
示例5: canCreateItem
function canCreateItem()
{
// From Ticket Document Tab => check right to add followup.
if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields['tickets_id'])) {
return $ticket->canAddFollowups();
}
}
if (Session::haveRight('document', 'w')) {
return parent::canCreateItem();
}
return false;
}
示例6: canCreateItem
/**
* @since version 0.85
**/
function canCreateItem()
{
if ($this->canChildItem('canViewItem', 'canView')) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields['tickets_id'])) {
if ($ticket->fields['type'] == Ticket::INCIDENT_TYPE) {
return Session::haveRight(self::$rightname, self::CREATEINCIDENT);
}
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) {
return Session::haveRight(self::$rightname, self::CREATEREQUEST);
}
}
}
}
示例7: plugin_init_escalation
function plugin_init_escalation()
{
global $PLUGIN_HOOKS, $CFG_GLPI;
$PLUGIN_HOOKS['change_profile']['escalation'] = array('PluginEscalationProfile', 'changeprofile');
$PLUGIN_HOOKS['csrf_compliant']['escalation'] = true;
// After escalation, if user can't see the ticket (dan't see all ticket right), it redirect to ticket list
if (isset($_SERVER['HTTP_REFERER']) and strstr($_SERVER['HTTP_REFERER'], "escalation/front/group_group.form.php")) {
if (isset($_GET['id'])) {
$ticket = new Ticket();
$ticket->getFromDB($_GET['id']);
if (!$ticket->canViewItem()) {
// Can't see ticket, go in ticket list
$ticket->redirectToList();
}
}
}
if (isset($_SESSION["glpiID"])) {
$plugin = new Plugin();
if ($plugin->isActivated('escalation')) {
Plugin::registerClass('PluginEscalationProfile', array('addtabon' => array('Profile')));
Plugin::registerClass('PluginEscalationTicketCopy', array('addtabon' => array('Ticket')));
Plugin::registerClass('PluginEscalationConfig', array('addtabon' => array('Entity')));
Plugin::registerClass('PluginEscalationGroup_Group', array('addtabon' => array('Ticket', 'Group')));
$PLUGIN_HOOKS['menu_entry']['escalation'] = false;
PluginEscalationGroup_Group::convertNewTicket();
// limit group
$peConfig = new PluginEscalationConfig();
if ($peConfig->getValue('limitgroup', $_SESSION['glpidefault_entity']) == '1') {
if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id'])) {
$group = new Group();
$a_groups = array();
$a_groups[0] = Dropdown::EMPTY_VALUE;
foreach ($_SESSION['glpigroups'] as $groups_id) {
$group->getFromDB($groups_id);
$a_groups[$groups_id] = $group->getName();
}
$_SESSION['plugin_escalation_requestergroups'] = $a_groups;
register_shutdown_function('plugin_escalation_on_exit');
ob_start();
}
}
// end limit group
}
$PLUGIN_HOOKS['pre_item_add']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'selectGroupOnAdd'));
$PLUGIN_HOOKS['item_add']['escalation'] = array('Ticket' => array('PluginEscalationTicketCopy', 'finishAdd'));
// $PLUGIN_HOOKS['pre_item_update']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'notMultiple'));
}
}
示例8: canCreateItem
/**
* @since version 0.85
**/
function canCreateItem()
{
if ($this->canChildItem('canViewItem', 'canView')) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields['tickets_id'])) {
// No validation for closed tickets
if (in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) {
return false;
}
if ($ticket->fields['type'] == Ticket::INCIDENT_TYPE) {
return Session::haveRight(self::$rightname, self::CREATEINCIDENT);
}
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) {
return Session::haveRight(self::$rightname, self::CREATEREQUEST);
}
}
}
}
示例9: Ticket
function post_deleteFromDB()
{
global $CFG_GLPI;
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
$donotif = false;
}
$t = new Ticket();
if ($t->getFromDB($this->fields['tickets_id'])) {
if ($t->fields["suppliers_id_assign"] == 0 && $t->countUsers(Ticket::ASSIGN) == 0 && $t->countGroups(Ticket::ASSIGN) == 0) {
$t->update(array('id' => $this->fields['tickets_id'], 'status' => 'new'));
} else {
$t->updateDateMod($this->fields['tickets_id']);
if ($donotif) {
NotificationEvent::raiseEvent("update", $t);
}
}
}
parent::post_deleteFromDB();
}
示例10: canCreateItem
function canCreateItem()
{
if (isset($this->input['itemtype']) && isset($this->input['items_id'])) {
if ($item = getItemForItemtype($this->input['itemtype'])) {
if ($item->canAddItem('Document')) {
return true;
}
}
}
// From Ticket Document Tab => check right to add followup.
if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields['tickets_id'])) {
return $ticket->canAddFollowups();
}
}
if (Session::haveRight('document', 'w')) {
return parent::canCreateItem();
}
return false;
}
示例11: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'add_task':
if (!($task = getItemForItemtype('TicketTask'))) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
break;
}
$ticket = new Ticket();
$field = $ticket->getForeignKeyField();
$input = $ma->getInput();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id'])) {
$input2 = array($field => $item->fields['tickets_id'], 'taskcategories_id' => $input['taskcategories_id'], 'actiontime' => $input['actiontime'], 'content' => $input['content']);
if ($task->can(-1, CREATE, $input2)) {
if ($task->add($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
}
return;
case 'solveticket':
$input = $ma->getInput();
$ticket = new Ticket();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例12: getSQLCondition
/**
* get SQL condition for filtered dropdown assign groups
* @param int $tickets_id
* @param int $itilcategories_id
* @return string
*/
static function getSQLCondition($tickets_id, $itilcategories_id)
{
$ticket = new Ticket();
$group = new Group();
$params = array('entities_id' => $_SESSION['glpiactive_entity'], 'is_recursive' => 1);
if (!empty($tickets_id) && $ticket->getFromDB($tickets_id)) {
// == UPDATE EXISTING TICKET ==
$params['entities_id'] = $ticket->fields['entities_id'];
$params['condition'] = " AND " . ($ticket->fields['type'] == Ticket::DEMAND_TYPE ? "`is_request`='1'" : "`is_incident`='1'");
}
$found_groups = self::getGroupsForCategory($itilcategories_id, $params);
$groups_id_toshow = array();
//init
if (!empty($found_groups)) {
for ($lvl = 1; $lvl <= 4; $lvl++) {
if (isset($found_groups['groups_id_level' . $lvl])) {
if ($found_groups['groups_id_level' . $lvl] === "all") {
foreach (PluginItilcategorygroupsGroup_Level::getAllGroupForALevel($lvl, $params['entities_id']) as $groups_id) {
if ($group->getFromDB($groups_id)) {
$groups_id_toshow[] = $group->getID();
}
}
} else {
foreach ($found_groups['groups_id_level' . $lvl] as $groups_id) {
if (countElementsInTableForEntity("glpi_groups", $ticket->getEntityID(), "`id`='{$groups_id}'") > 0) {
$group->getFromDB($groups_id);
$groups_id_toshow[] = $group->getID();
}
}
}
}
}
}
$condition = "";
if (count($groups_id_toshow) > 0) {
// transform found groups (2 dimensions) in a flat array
$groups_id_toshow_flat = array();
array_walk_recursive($groups_id_toshow, function ($v, $k) use(&$groups_id_toshow_flat) {
array_push($groups_id_toshow_flat, $v);
});
$newarray = implode(", ", $groups_id_toshow_flat);
$condition = " id IN ({$newarray})";
}
return $condition;
}
示例13: TicketFollowup
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkLoginUser();
$fup = new TicketFollowup();
if (isset($_POST["add"])) {
$fup->check(-1, CREATE, $_POST);
$fup->add($_POST);
Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a followup'), $_SESSION["glpiname"]));
Html::back();
} else {
if (isset($_POST['add_close']) || isset($_POST['add_reopen'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($_POST["tickets_id"]) && $ticket->canApprove()) {
$fup->add($_POST);
Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s approves or refuses a solution'), $_SESSION["glpiname"]));
Html::back();
}
} else {
if (isset($_POST["update"])) {
$fup->check($_POST['id'], UPDATE);
$fup->update($_POST);
Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s updates a followup'), $_SESSION["glpiname"]));
Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id'));
} else {
if (isset($_POST["purge"])) {
$fup->check($_POST['id'], PURGE);
$fup->delete($_POST, 1);
Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s purges a followup'), $_SESSION["glpiname"]));
示例14: initBasedOnPrevious
/**
* Init cost for creation based on previous cost
**/
function initBasedOnPrevious()
{
$ticket = new Ticket();
if (!isset($this->fields['contracts_id']) || !$ticket->getFromDB($this->fields['contracts_id'])) {
return false;
}
$lastdata = $this->getLastCostForContract($this->fields['contracts_id']);
if (isset($lastdata['end_date'])) {
$this->fields['begin_date'] = $lastdata['end_date'];
}
if (isset($lastdata['cost'])) {
$this->fields['cost'] = $lastdata['cost'];
}
if (isset($lastdata['name'])) {
$this->fields['name'] = $lastdata['name'];
}
if (isset($lastdata['budgets_id'])) {
$this->fields['budgets_id'] = $lastdata['budgets_id'];
}
}
示例15: buildTicket
//.........这里部分代码省略.........
if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) {
$tkt['tickets_id'] = intval($match[1]);
}
}
// See in References
if (!isset($tkt['tickets_id']) && isset($head['references'])) {
if (preg_match($glpi_message_match, $head['references'], $match)) {
$tkt['tickets_id'] = intval($match[1]);
}
}
// See in title
if (!isset($tkt['tickets_id']) && preg_match('/\\[.+#(\\d+)\\]/', $head['subject'], $match)) {
$tkt['tickets_id'] = intval($match[1]);
}
$is_html = false;
//If files are present and content is html
if (isset($this->files) && count($this->files) && $tkt['content'] != strip_tags($tkt['content']) && !isset($tkt['tickets_id'])) {
$is_html = true;
$tkt['content'] = Ticket::convertContentForTicket($tkt['content'], array_merge($this->files, $this->altfiles), $this->tags);
}
$tkt['content'] = $this->cleanMailContent($tkt['content']);
if ($is_html && !isset($tkt['tickets_id'])) {
$tkt['content'] = nl2br($tkt['content']);
}
$tkt['_supplier_email'] = false;
// Found ticket link
if (isset($tkt['tickets_id'])) {
// it's a reply to a previous ticket
$job = new Ticket();
$tu = new Ticket_User();
$st = new Supplier_Ticket();
// Check if ticket exists and users_id exists in GLPI
/// TODO check if users_id have right to add a followup to the ticket
if ($job->getFromDB($tkt['tickets_id']) && $job->fields['status'] != CommonITILObject::CLOSED && ($CFG_GLPI['use_anonymous_followups'] || $tkt['_users_id_requester'] > 0 || $tu->isAlternateEmailForITILObject($tkt['tickets_id'], $head['from']) || ($tkt['_supplier_email'] = $st->isSupplierEmail($tkt['tickets_id'], $head['from'])))) {
if ($tkt['_supplier_email']) {
$tkt['content'] = sprintf(__('From %s'), $head['from']) . "\n\n" . $tkt['content'];
}
$content = explode("\n", $tkt['content']);
$tkt['content'] = "";
$to_keep = array();
// Move requester to author of followup :
$tkt['users_id'] = $tkt['_users_id_requester'];
$begin_strip = -1;
$end_strip = -1;
$begin_match = "/" . NotificationTargetTicket::HEADERTAG . ".*" . NotificationTargetTicket::HEADERTAG . "/";
$end_match = "/" . NotificationTargetTicket::FOOTERTAG . ".*" . NotificationTargetTicket::FOOTERTAG . "/";
foreach ($content as $ID => $val) {
// Get first tag for begin
if ($begin_strip < 0) {
if (preg_match($begin_match, $val)) {
$begin_strip = $ID;
}
}
// Get last tag for end
if ($begin_strip >= 0) {
if (preg_match($end_match, $val)) {
$end_strip = $ID;
continue;
}
}
}
if ($begin_strip >= 0) {
// Clean first and last lines
$content[$begin_strip] = preg_replace($begin_match, '', $content[$begin_strip]);
}
if ($end_strip >= 0) {