本文整理汇总了PHP中Problem::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Problem::getFromDB方法的具体用法?PHP Problem::getFromDB怎么用?PHP Problem::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem::getFromDB方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canCreateItem
/**
* Is the current user have right to create the current task ?
*
* @return boolean
**/
function canCreateItem()
{
if (!parent::canReadITILItem()) {
return false;
}
$problem = new Problem();
if ($problem->getFromDB($this->fields['problems_id'])) {
return Session::haveRight("edit_all_problem", "1") || Session::haveRight("show_my_problem", "1") && ($problem->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $problem->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']));
}
return false;
}
示例2: showForm
function showForm($ID, $options = array())
{
global $CFG_GLPI, $DB;
if (!static::canView()) {
return false;
}
// In percent
$colsize1 = '13';
$colsize2 = '37';
$default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
// Set default options
if (!$ID) {
$values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
foreach ($values as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
if (isset($options['tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($options['tickets_id'])) {
$options['content'] = $ticket->getField('content');
$options['name'] = $ticket->getField('name');
$options['impact'] = $ticket->getField('impact');
$options['urgency'] = $ticket->getField('urgency');
$options['priority'] = $ticket->getField('priority');
$options['itilcategories_id'] = $ticket->getField('itilcategories_id');
$options['due_date'] = $ticket->getField('due_date');
}
}
if (isset($options['problems_id'])) {
$problem = new Problem();
if ($problem->getFromDB($options['problems_id'])) {
$options['content'] = $problem->getField('content');
$options['name'] = $problem->getField('name');
$options['impact'] = $problem->getField('impact');
$options['urgency'] = $problem->getField('urgency');
$options['priority'] = $problem->getField('priority');
$options['itilcategories_id'] = $problem->getField('itilcategories_id');
$options['due_date'] = $problem->getField('due_date');
}
}
}
if ($ID > 0) {
$this->check($ID, READ);
} else {
// Create item
$this->check(-1, CREATE, $options);
}
$showuserlink = 0;
if (User::canView()) {
$showuserlink = 1;
}
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
echo "<td class='left' width='{$colsize2}%'>";
if (isset($options['tickets_id'])) {
echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
}
if (isset($options['problems_id'])) {
echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
}
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
echo "<td width='{$colsize2}%' class='left'>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"] = '';
}
Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
echo "</td></tr>";
if ($ID) {
echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
echo "</td>";
echo "<th>" . __('Last update') . "</th>";
echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</td></tr>";
}
if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Date of solving') . "</th>";
echo "<td>";
Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
echo "<th>" . __('Closing date') . "</th>";
echo "<td>";
Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
} else {
echo "<td colspan='2'> </td>";
//.........这里部分代码省略.........
示例3: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
$datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
$datas['##ticket.content##'] = $datas['##ticket.description##'];
// Specific datas
$datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
$datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
$datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
$datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
$autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
$datas['##ticket.autoclose##'] = __('Never');
$datas['##lang.ticket.autoclosewarning##'] = "";
if ($autoclose_value > 0) {
$datas['##ticket.autoclose##'] = $autoclose_value;
$datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
}
$datas['##ticket.sla##'] = '';
if ($item->getField('slas_id')) {
$datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
}
$datas['##ticket.location##'] = '';
if ($item->getField('locations_id')) {
$datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
}
// is ticket deleted
$datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
//Tags associated with the object linked to the ticket
$datas['##ticket.itemtype##'] = '';
$datas['##ticket.item.name##'] = '';
$datas['##ticket.item.serial##'] = '';
$datas['##ticket.item.otherserial##'] = '';
$datas['##ticket.item.location##'] = '';
$datas['##ticket.item.contact##'] = '';
$datas['##ticket.item.contactnumber##'] = '';
$datas['##ticket.item.user##'] = '';
$datas['##ticket.item.group##'] = '';
$datas['##ticket.item.model##'] = '';
$item_ticket = new Item_Ticket();
$items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
$datas['items'] = array();
if (count($items)) {
foreach ($items as $val) {
if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
$tmp = array();
//Object type
$tmp['##ticket.itemtype##'] = $hardware->getTypeName();
//Object name
$tmp['##ticket.item.name##'] = $hardware->getField('name');
//Object serial
if ($hardware->isField('serial')) {
$tmp['##ticket.item.serial##'] = $hardware->getField('serial');
}
//Object contact
if ($hardware->isField('contact')) {
$tmp['##ticket.item.contact##'] = $hardware->getField('contact');
}
//Object contact num
if ($hardware->isField('contact_num')) {
$tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
}
//Object otherserial
if ($hardware->isField('otherserial')) {
$tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
}
//Object location
if ($hardware->isField('locations_id')) {
$tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
}
//Object user
if ($hardware->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($hardware->getField('users_id'))) {
$tmp['##ticket.item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($hardware->getField('groups_id')) {
$tmp['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $hardware->getField('groups_id'));
}
$modeltable = getSingular($hardware->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($hardware->isField($modelfield)) {
$tmp['##ticket.item.model##'] = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield));
}
$datas['items'][] = $tmp;
}
}
}
$datas['##ticket.numberofitems##'] = count($datas['items']);
// Get followups, log, validation, satisfaction, linked tickets
if (!$simple) {
// Linked tickets
$linked_tickets = Ticket_Ticket::getLinkedTicketsTo($item->getField('id'));
//.........这里部分代码省略.........
示例4: showForm
function showForm($ID, $options = array())
{
global $CFG_GLPI, $DB;
if (!static::canView()) {
return false;
}
// Set default options
if (!$ID) {
$values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
foreach ($values as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
if (isset($options['tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($options['tickets_id'])) {
$options['content'] = $ticket->getField('content');
$options['name'] = $ticket->getField('name');
$options['impact'] = $ticket->getField('impact');
$options['urgency'] = $ticket->getField('urgency');
$options['priority'] = $ticket->getField('priority');
$options['itilcategories_id'] = $ticket->getField('itilcategories_id');
}
}
if (isset($options['problems_id'])) {
$problem = new Problem();
if ($problem->getFromDB($options['problems_id'])) {
$options['content'] = $problem->getField('content');
$options['name'] = $problem->getField('name');
$options['impact'] = $problem->getField('impact');
$options['urgency'] = $problem->getField('urgency');
$options['priority'] = $problem->getField('priority');
$options['itilcategories_id'] = $problem->getField('itilcategories_id');
}
}
}
if ($ID > 0) {
$this->check($ID, 'r');
} else {
// Create item
$this->check(-1, 'w', $options);
}
$showuserlink = 0;
if (Session::haveRight('user', 'r')) {
$showuserlink = 1;
}
$this->showTabs($options);
$this->showFormHeader($options);
echo "<tr>";
echo "<th class='left' colspan='2'>";
if (isset($options['tickets_id'])) {
echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
}
if (isset($options['problems_id'])) {
echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
}
echo "<table>";
echo "<tr>";
echo "<td><span class='tracking_small'>" . __('Opening date') . "</span></td>";
echo "<td>";
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
Html::showDateTimeFormItem("date", $date, 1, false);
echo "</td></tr>";
if ($ID) {
echo "<tr><td><span class='tracking_small'>" . __('By') . "</span></td><td>";
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
echo "</td></tr>";
}
echo "</table>";
echo "</th>";
echo "<th class='left' colspan='2'>";
echo "<table>";
if ($ID) {
echo "<tr><td><span class='tracking_small'>" . __('Last update') . "</span></td>";
echo "<td><span class='tracking_small'>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
//TRANS: %s is the user name
printf(__('By %s'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</span>";
echo "</td></tr>";
}
// SLA
echo "<tr>";
echo "<td><span class='tracking_small'>" . __('Due date') . "</span></td>";
echo "<td>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"] = '';
}
Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true);
echo "</td></tr>";
if ($ID) {
switch ($this->fields["status"]) {
case self::CLOSED:
echo "<tr>";
echo "<td><span class='tracking_small'>" . __('Close date') . "</span></td>";
//.........这里部分代码省略.........
示例5: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case "solveticket":
$problem = new Problem();
$input = $ma->getInput();
if (isset($input['problems_id']) && $problem->getFromDB($input['problems_id'])) {
Ticket::showMassiveSolutionForm($problem->getEntityID());
echo "<br><br>";
echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
return true;
}
return false;
}
return parent::showMassiveActionsSubForm($ma);
}
示例6: showSpecificMassiveActionsParameters
/**
* @see CommonDBTM::showSpecificMassiveActionsParameters()
*
* @since version 0.84
**/
function showSpecificMassiveActionsParameters($input = array())
{
switch ($input['action']) {
case "solveticket":
$problem = new Problem();
if (isset($input['problems_id']) && $problem->getFromDB($input['problems_id'])) {
Ticket::showMassiveSolutionForm($problem->getEntityID());
echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>";
return true;
}
return false;
default:
return parent::showSpecificMassiveActionsParameters($input);
}
return false;
}
示例7: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
// Specific datas
$datas['##change.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $item->getField("id") . "_ChangeValidation\$1");
$datas['##change.globalvalidation##'] = ChangeValidation::getStatus($item->getField('global_validation'));
// $datas["##problem.impacts##"] = $item->getField('impactcontent');
// $datas["##problem.causes##"] = $item->getField('causecontent');
// $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode
if (!$simple) {
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_changes_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##change.numberoftickets##'] = count($datas['tickets']);
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$problems = getAllDatasFromTable('glpi_changes_problems', $restrict);
$datas['problems'] = array();
if (count($problems)) {
$problem = new Problem();
foreach ($problems as $data) {
if ($problem->getFromDB($data['problems_id'])) {
$tmp = array();
$tmp['##problem.id##'] = $data['problems_id'];
$tmp['##problem.date##'] = $problem->getField('date');
$tmp['##problem.title##'] = $problem->getField('name');
$tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Problem_" . $data['problems_id']);
$tmp['##problem.content##'] = $problem->getField('content');
$datas['problems'][] = $tmp;
}
}
}
$datas['##change.numberofproblems##'] = count($datas['problems']);
$restrict = "`changes_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_changes_items', $restrict);
$datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
}
}
$datas['##change.numberofitems##'] = count($datas['items']);
//Validation infos
$restrict = "`changes_id`='" . $item->getField('id') . "'";
if (isset($options['validation_id']) && $options['validation_id']) {
$restrict .= " AND `glpi_changevalidations`.`id` = '" . $options['validation_id'] . "'";
//.........这里部分代码省略.........