本文整理汇总了PHP中Ticket::getEntityID方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::getEntityID方法的具体用法?PHP Ticket::getEntityID怎么用?PHP Ticket::getEntityID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::getEntityID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: showForTicket
/**
* Show changes for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!$ticket->can($ID, READ)) {
return false;
}
$canedit = $ticket->canEdit($ID);
$rand = mt_rand();
$query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_changes`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_changes`\n ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_changes`.`name`";
$result = $DB->query($query);
$changes = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$changes[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID()));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
if (Session::haveRight('change', CREATE)) {
echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>";
_e('Create a change from this ticket');
echo "</a>";
}
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>";
echo "</tr>";
if ($numrows) {
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
$i = 0;
foreach ($changes as $data) {
Session::addToNavigateListItems('Change', $data["id"]);
Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
$i++;
}
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例3: showForTicket
/**
* Show problems for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!Session::haveRight("show_all_problem", 1) || !$ticket->can($ID, 'r')) {
// if (!$ticket->can($ID,'r')) {
return false;
}
$canedit = $ticket->can($ID, 'w');
$rand = mt_rand();
$query = "SELECT DISTINCT `glpi_problems_tickets`.`id` AS linkID,\n `glpi_problems`.*\n FROM `glpi_problems_tickets`\n LEFT JOIN `glpi_problems`\n ON (`glpi_problems_tickets`.`problems_id` = `glpi_problems`.`id`)\n WHERE `glpi_problems_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_problems`.`name`";
$result = $DB->query($query);
$problems = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$problems[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='problemticket_form{$rand}' id='problemticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a problem') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
$condition = "`glpi_problems`.`status` NOT IN ('" . implode("', '", array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray())) . "')";
Problem::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID(), 'condition' => $condition));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
echo "<a href='" . Toolbox::getItemTypeFormURL('Problem') . "?tickets_id={$ID}'>";
_e('Create a problem from this ticket');
echo "</a>";
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='11'>" . Problem::getTypeName($numrows) . "</th>";
echo "</tr>";
if ($numrows) {
Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
$i = 0;
foreach ($problems as $data) {
Session::addToNavigateListItems('Problem', $data["id"]);
Problem::showShort($data['id'], Search::HTML_OUTPUT, $i, $data['linkID']);
$i++;
}
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例4: methodAddTicketDocument
/**
* Add a document to a existing ticket
* for an authenticated user
*
* @param $params array of options (ticket, uri, name, base64, comment)
* only one of uri and base64 must be set
* name is mandatory when base64 set, for extension check (filename)
* @param $protocol the communication protocol used
*
* @return array of hashtable
**/
static function methodAddTicketDocument($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'uri' => 'string,optional', 'base64' => 'string,optional', 'content' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
}
$ticket = new Ticket();
if (!isset($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
}
if (!is_numeric($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket');
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'closed ticket');
}
if (!$ticket->canAddFollowups()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'access denied');
}
if (isset($params['name']) && !empty($params['name'])) {
$document_name = addslashes($params['name']);
} else {
$document_name = addslashes(sprintf(__('%1$s %2$s'), _x('phone', 'Number'), $ticket->fields['id']));
}
$filename = tempnam(GLPI_DOC_DIR . '/_tmp', 'PWS');
$response = parent::uploadDocument($params, $protocol, $filename, $document_name);
//An error occured during document upload
if (parent::isError($protocol, $response)) {
return $response;
}
$doc = new Document();
$documentitem = new Document_Item();
$docid = $doc->getFromDBbyContent($ticket->fields["entities_id"], $filename);
if ($docid) {
$input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'documents_id' => $doc->getID());
if ($DB->request('glpi_documents_items', $input)->numrows()) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'document already associated to this ticket');
}
$new = $documentitem->add($input);
} else {
$input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'tickets_id' => $ticket->getID(), 'entities_id' => $ticket->getEntityID(), 'is_recursive' => $ticket->isRecursive(), 'documentcategories_id' => $CFG_GLPI["documentcategories_id_forticket"]);
$new = $doc->add($input);
}
// to not add it twice during followup
unset($_FILES['filename']);
if (!$new) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
}
if (isset($params['comment']) && !empty($params['comment'])) {
$params['content'] = $params['comment'];
unset($params['comment']);
}
if (isset($params['content']) && !empty($params['content'])) {
return self::methodAddTicketFollowup($params, $protocol);
}
return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol);
}
示例5: showForm
/**
* Print the wainting ticket form
*
* @param $ID integer ID of the item
* @param $options array
* - target filename : where to go when done.
* - withtemplate boolean : template or basic item
*
* @return Nothing (display)
* */
function showForm($ID, $options = array())
{
global $CFG_GLPI;
// validation des droits
if (!$this->canview()) {
return false;
}
$ticket = new Ticket();
if ($ID > 0) {
if (!$ticket->getFromDB($ID)) {
$ticket->getEmpty();
}
} else {
// Create item
$ticket->getEmpty();
}
// If values are saved in session we retrieve it
if (isset($_SESSION['glpi_plugin_moreticket_close'])) {
foreach ($_SESSION['glpi_plugin_moreticket_close'] as $key => $value) {
$ticket->fields[$key] = str_replace(array('\\r\\n', '\\r', '\\n'), '', $value);
}
}
unset($_SESSION['glpi_plugin_moreticket_close']);
echo "<div class='spaced' id='moreticket_close_ticket'>";
echo "</br>";
echo "<table class='moreticket_close_ticket' id='cl_menu'>";
echo "<tr><td>";
echo _n('Solution template', 'Solution templates', 1) . " : ";
$rand_template = mt_rand();
$rand_type = 0;
$rand_text = mt_rand();
$rand_type = mt_rand();
SolutionTemplate::dropdown(array('value' => 0, 'entity' => $ticket->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type))));
echo "</td></tr>";
echo "<tr><td>";
echo _n('Solution type', 'Solution types', 1);
$config = new PluginMoreticketConfig();
if ($config->mandatorySolutionType() == true) {
echo " : <span class='red'>*</span> ";
}
Dropdown::show('SolutionType', array('value' => $ticket->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $ticket->getEntityID()));
echo "</td></tr>";
echo "<tr><td>";
echo __('Solution description', 'moreticket') . " : <span class='red'>*</span> ";
$rand = mt_rand();
Html::initEditorSystem("solution" . $rand);
echo "<div id='solution{$rand_text}'>";
echo "<textarea id='solution{$rand}' name='solution' rows='3'>" . stripslashes($ticket->fields['solution']) . "</textarea></div>";
echo "</td></tr>";
echo "</table>";
echo "</div>";
}
示例6: showForTicket
/**
* Show changes for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!$ticket->can($ID, 'r')) {
return false;
}
$canedit = $ticket->can($ID, 'w');
$rand = mt_rand();
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
$query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_changes`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_changes`\n ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_changes`.`name`";
$result = $DB->query($query);
$changes = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$changes[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID()));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>";
_e('Create a change from this ticket');
echo "</a>";
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr>";
if ($canedit && $numrows) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Title') . "</th>";
echo "</tr>";
$used = array();
if ($numrows) {
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
foreach ($changes as $data) {
$used[$data['id']] = $data['id'];
Session::addToNavigateListItems('Change', $data["id"]);
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
echo "</td>";
}
echo "<td><a href='" . Toolbox::getItemTypeFormURL('Change') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>";
echo "</tr>";
}
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}