本文整理汇总了PHP中Document::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::getFromDB方法的具体用法?PHP Document::getFromDB怎么用?PHP Document::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::getFromDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: geTimelineItems
static function geTimelineItems(Ticket $ticket, $rand)
{
global $DB, $CFG_GLPI;
$timeline = array();
$user = new User();
$group = new Group();
$followup_obj = new TicketFollowup();
$task_obj = new TicketTask();
$document_item_obj = new Document_Item();
$ticket_valitation_obj = new TicketValidation();
//checks rights
$showpublic = Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE)) && Session::haveRightsOr("task", array(TicketTask::SEEPUBLIC, TicketTask::SEEPRIVATE));
$restrict_fup = $restrict_task = "";
if (!Session::haveRight("ticket", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("ticket", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
$followups = $followup_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$can_edit = $followup_obj->canUpdateItem();
$followup['can_edit'] = $can_edit;
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
//add ticket tasks to timeline
$tasks = $task_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$can_edit = $task_obj->canUpdateItem();
$task['can_edit'] = $can_edit;
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $ticket->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add assign changes
/*$log_obj = new Log;
$gassign_items = $log_obj->find("itemtype = 'Ticket' AND items_id = ".$ticket->getID()."
AND itemtype_link = 'Group' AND linked_action = '15'");
foreach ($gassign_items as $logs_id => $gassign) {
//find group
$group_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['new_value']);
$groups = $group->find("name = '$group_name'");
$first_group = array_shift($groups);
$group->getFromDB($first_group['id']);
$content = __("Assigned to")." : ".
"<img src='".$CFG_GLPI['root_doc']."/plugins/talk/pics/group.png' class='group_assign' />".
" <strong>".$group->getLink()."</strong>";
//find user
$user_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['user_name']);
$users = $user->find("CONCAT(firstname, ' ', realname) = '$user_name'");
$first_user = array_shift($users);
if ($first_user == NULL) {
$first_user['id'] = false;
}
$timeline[$gassign['date_mod']."_assign_".$logs_id] = array('type' => 'Assign',
'item' => array(
'date' => $gassign['date_mod'],
'content' => $content,
'can_edit' => false,
'users_id' => $first_user['id']
));
}*/
//add existing solution
if (!empty($ticket->fields['solution'])) {
$users_id = 0;
$solution_date = $ticket->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT date_mod AS solution_date, user_name FROM glpi_logs\n WHERE itemtype = 'Ticket' \n AND items_id = " . $ticket->getID() . "\n AND id_search_option = 24\n ORDER BY id DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $ticket->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Html::clean(html_entity_decode($solution_content)), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $ticket->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $ticket->canSolve()));
}
// add ticket validation to timeline
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $ticket->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $ticket->getID());
//.........这里部分代码省略.........
示例2: displayField
public function displayField($canEdit = true)
{
if ($canEdit) {
$required = $this->isRequired() ? ' required' : '';
echo '<input type="hidden" class="form-control"
name="formcreator_field_' . $this->fields['id'] . '" value="" />' . PHP_EOL;
echo '<input type="file" class="form-control"
name="formcreator_field_' . $this->fields['id'] . '"
id="formcreator_field_' . $this->fields['id'] . '" />';
} else {
$doc = new Document();
$answer = $this->getAnswer();
if ($doc->getFromDB($answer)) {
echo $doc->getDownloadLink();
}
}
}
示例3: giveItem
//.........这里部分代码省略.........
$comp = '';
if ($split3[$k]) {
$comp = __(READ);
if ($split4[$k]) {
$comp = sprintf(__('%1$s%2$s'), $comp, ", ");
}
}
if ($split4[$k]) {
$comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
}
if (!empty($comp)) {
$text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$NAME . $num])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_deviceharddrives.specificity":
case "glpi_devicememories.specificity":
case "glpi_deviceprocessors.specificity":
return $data[$NAME . $num];
case "glpi_networkports.mac":
$out = "";
if ($itemtype == 'Computer') {
$displayed = array();
if (!empty($data[$NAME . $num . "_2"])) {
$split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
$lowstr = Toolbox::strtolower($split[$k]);
if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $split[$k];
$displayed[] = $lowstr;
}
}
if (!empty($data[$NAME . $num])) {
$out .= "<br>";
}
}
if (!empty($data[$NAME . $num])) {
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$count_display = 0;
示例4: showGeolocLocation
static function showGeolocLocation($itemtype, $id, $positions_id = 0)
{
global $CFG_GLPI;
$documents_id = self::getDocument($id);
$locations_id = $id;
$Doc = new Document();
if (isset($documents_id) && $Doc->getFromDB($documents_id)) {
$target = $CFG_GLPI["root_doc"] . "/plugins/positions/front/geoloc.php?positions_id=" . $positions_id . "&download=1&locations_id=" . $locations_id;
echo "<script type='text/javascript'>\n Position.openWindow('{$target}');\n </script>";
}
}
示例5: copyDocuments
/**
* Copy order documents into the newly generated item
* @since 1.5.3
* @param unknown_type $itemtype
* @param unknown_type $items_id
* @param unknown_type $orders_id
* @param unknown_type $entity
*/
static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
{
global $CFG_GLPI;
$config = PluginOrderConfig::getConfig();
if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
$document_item = new Document_Item();
$document = new Document();
foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder'\n AND `items_id`='{$orders_id}'") as $doc) {
$document->getFromDB($doc['documents_id']);
$mime = $document->fields['mime'];
$newdocument = clone $document;
$newdocument->fields['entities_id'] = $entity;
unset($newdocument->fields['id']);
$newID = $document->add($newdocument->fields);
$tmp['itemtype'] = $itemtype;
$tmp['items_id'] = $items_id;
$tmp['documents_id'] = $newID;
$document_item->add($tmp);
//force mimetype
$document->update(array('id' => $newID, 'mime' => $mime));
}
}
}
示例6: Document
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
if (!$CFG_GLPI["use_public_faq"]) {
Session::checkLoginUser();
}
$doc = new Document();
if (isset($_GET['docid'])) {
// docid for document
if (!$doc->getFromDB($_GET['docid'])) {
Html::displayErrorAndDie(__('Unknown file'), true);
}
if (!file_exists(GLPI_DOC_DIR . "/" . $doc->fields['filepath'])) {
Html::displayErrorAndDie(__('File not found'), true);
// Not found
} else {
if ($doc->canViewFile($_GET)) {
if ($doc->fields['sha1sum'] && $doc->fields['sha1sum'] != sha1_file(GLPI_DOC_DIR . "/" . $doc->fields['filepath'])) {
Html::displayErrorAndDie(__('File is altered (bad checksum)'), true);
// Doc alterated
} else {
$doc->send();
}
} else {
Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
示例7: giveItem
//.........这里部分代码省略.........
$comp = '';
if ($data[$num][$k]['is_recursive']) {
$comp = __('R');
if ($data[$num][$k]['is_dynamic']) {
$comp = sprintf(__('%1$s%2$s'), $comp, ", ");
}
}
if ($data[$num][$k]['is_dynamic']) {
$comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
}
if (!empty($comp)) {
$text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= self::LBBR;
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$num][0]['name'])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_tickets_tickets.tickets_id_1":
$out = "";
$displayed = array();
for ($k = 0; $k < $data[$num]['count']; $k++) {
$linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2'];
if ($linkid > 0 && !isset($displayed[$linkid])) {
$text = "<a ";
$text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
$text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
if (count($displayed)) {
$out .= self::LBBR;
}
$displayed[$linkid] = $linkid;
$out .= $text;
}
}
return $out;
case "glpi_problems.id":
if ($searchopt[$ID]["datatype"] == 'count') {
if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) {
if ($itemtype == 'ITILCategory') {
$options['criteria'][0]['field'] = 7;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $data['id'];
$options['criteria'][0]['link'] = 'AND';
} else {
$options['criteria'][0]['field'] = 12;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = 'all';
示例8: prepareInputForUpdate
function prepareInputForUpdate($input)
{
global $LANG, $CFG_GLPI;
// Get ticket : need for comparison
$this->getFromDB($input['id']);
if (isset($input["date"]) && empty($input["date"])) {
unset($input["date"]);
}
if (isset($input["closedate"]) && empty($input["closedate"])) {
unset($input["closedate"]);
}
if (isset($input["solvedate"]) && empty($input["solvedate"])) {
unset($input["solvedate"]);
}
// check mandatory fields
if ($CFG_GLPI["is_ticket_title_mandatory"] && isset($input['name'])) {
$title = trim($input['name']);
if (empty($title)) {
addMessageAfterRedirect($LANG['tracking'][6], false, ERROR);
unset($input['name']);
}
}
if ($CFG_GLPI["is_ticket_content_mandatory"] && isset($input['content'])) {
$content = trim($input['content']);
if (empty($content)) {
addMessageAfterRedirect($LANG['tracking'][7], false, ERROR);
unset($input['content']);
}
}
// Security checks
if (is_numeric(getLoginUserID(false)) && !haveRight("assign_ticket", "1")) {
if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'user') {
// must own_ticket to grab a non assign ticket
if ($this->countUsers(self::ASSIGN) == 0) {
if (!haveRight("steal_ticket", "1") && !haveRight("own_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
unset($input["_ticket_assign"]);
}
} else {
// Can not steal or can steal and not assign to me
if (!haveRight("steal_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
unset($input["_ticket_assign"]);
}
}
}
// No supplier assign
if (isset($input["suppliers_id_assign"])) {
unset($input["suppliers_id_assign"]);
}
// No group
if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'group') {
unset($input["_ticket_assign"]);
}
}
if (is_numeric(getLoginUserID(false)) && !haveRight("update_ticket", "1")) {
$allowed_fields = array('id');
if ($this->canApprove() && isset($input["status"])) {
$allowed_fields[] = 'status';
}
// for post-only with validate right
$ticketval = new TicketValidation();
if (TicketValidation::canValidate($this->fields['id']) || $ticketval->canCreate()) {
$allowed_fields[] = 'global_validation';
}
// Manage assign and steal right
if (haveRight('assign_ticket', 1) || haveRight('steal_ticket', 1)) {
$allowed_fields[] = '_ticket_assign';
}
if (haveRight('assign_ticket', 1)) {
$allowed_fields[] = 'suppliers_id_assign';
}
// Can only update initial fields if no followup or task already added
if ($this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0 && $this->isUser(self::REQUESTER, getLoginUserID())) {
$allowed_fields[] = 'content';
$allowed_fields[] = 'urgency';
$allowed_fields[] = 'ticketcategories_id';
$allowed_fields[] = 'itemtype';
$allowed_fields[] = 'items_id';
$allowed_fields[] = 'name';
}
if ($this->canSolve()) {
$allowed_fields[] = 'ticketsolutiontypes_id';
$allowed_fields[] = 'solution';
}
foreach ($allowed_fields as $field) {
if (isset($input[$field])) {
$ret[$field] = $input[$field];
}
}
$input = $ret;
}
// Manage fields from auto update : map rule actions to standard ones
if (isset($input['_auto_update'])) {
if (isset($input['_users_id_assign'])) {
$input['_ticket_assign']['_type'] = 'user';
$input['_ticket_assign']['users_id'] = $input['_users_id_assign'];
}
if (isset($input['_groups_id_assign'])) {
$input['_ticket_assign']['_type'] = 'group';
$input['_ticket_assign']['groups_id'] = $input['_groups_id_assign'];
}
//.........这里部分代码省略.........
示例9: copyDocuments
/**
* Copy order documents into the newly generated item
* @since 1.5.3
* @param unknown_type $itemtype
* @param unknown_type $items_id
* @param unknown_type $orders_id
* @param unknown_type $entity
*/
public static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
{
global $CFG_GLPI;
$config = PluginOrderConfig::getConfig();
if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
$document = new Document();
$docitem = new Document_Item();
$item = new $itemtype();
$item->getFromDB($items_id);
$is_recursive = 0;
foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder'\n AND `items_id`='{$orders_id}'") as $doc) {
//Create a new document
$document->getFromDB($doc['documents_id']);
if ($document->getEntityID() != $entity && !$document->fields['is_recursive'] || !in_array($entity, getSonsOf('glpi_entities', $document->getEntityID()))) {
$found_docs = getAllDatasFromTable('glpi_documents', "`entities_id`='{$entity}'\n AND `sha1sum`='" . $document->fields['sha1sum'] . "'");
if (empty($found_docs)) {
$tmpdoc = $document->fields;
$tmpdoc['entities_id'] = $entity;
unset($tmpdoc['id']);
$documents_id = $document->add($tmpdoc);
$is_recursive = $document->fields['is_recursive'];
} else {
$found_doc = array_pop($found_docs);
$documents_id = $found_doc['id'];
$is_recursive = $found_doc['is_recursive'];
}
} else {
$documents_id = $document->getID();
$is_recursive = $document->fields['is_recursive'];
}
//Link the document to the newly generated item
$fields['documents_id'] = $documents_id;
$fields['entities_id'] = $entity;
$fields['items_id'] = $items_id;
$fields['itemtype'] = $itemtype;
$fields['is_recursive'] = $is_recursive;
$newID = $docitem->add($fields);
}
}
}
示例10: sendMailById
/**
* Send mai lin queue
*
* @param $ID integer ID of the item
*
* @return true if send false if not
**/
function sendMailById($ID)
{
global $CFG_GLPI;
if ($this->getFromDB($ID)) {
$mmail = new GLPIMailer();
$headers = importArrayFromDB($this->fields['headers']);
if (is_array($headers) && count($headers)) {
foreach ($headers as $key => $val) {
$mmail->AddCustomHeader("{$key}: {$val}");
}
}
// Add custom header for mail grouping in reader
$mmail->AddCustomHeader("In-Reply-To: GLPI-" . $this->fields["itemtype"] . "-" . $this->fields["items_id"]);
$mmail->SetFrom($this->fields['sender'], $this->fields['sendername']);
if ($this->fields['replyto']) {
$mmail->AddReplyTo($this->fields['replyto'], $this->fields['replytoname']);
}
$mmail->Subject = $this->fields['name'];
if (empty($this->fields['body_html'])) {
$mmail->isHTML(false);
$mmail->Body = $this->fields['body_text'];
} else {
$mmail->isHTML(true);
$mmail->Body = '';
$this->fields['body_html'] = Html::entity_decode_deep($this->fields['body_html']);
$documents = importArrayFromDB($this->fields['documents']);
$link_doc = array();
if (is_array($documents) && count($documents)) {
$doc = new Document();
foreach ($documents as $docID) {
$doc->getFromDB($docID);
// Add embeded image if tag present in ticket content
if (preg_match_all('/' . Document::getImageTag($doc->fields['tag']) . '/', $this->fields['body_html'], $matches, PREG_PATTERN_ORDER)) {
$mmail->AddEmbeddedImage(GLPI_DOC_DIR . "/" . $doc->fields['filepath'], Document::getImageTag($doc->fields['tag']), $doc->fields['filename'], 'base64', $doc->fields['mime']);
// Else Add link to the document
} else {
$link_doc[] = "<a href='" . rtrim($CFG_GLPI["url_base"], '/') . "/front/document.send.php?docid=" . $doc->fields['id'] . "' >" . $doc->fields['name'] . "</a>";
}
}
}
$mmail->Body .= $this->fields['body_html'];
if (count($link_doc)) {
$mmail->Body .= '<p style="border:1px solid #cccccc;padding:5px">' . '<b>' . _n('Associated item', 'Associated items', Session::getPluralNumber()) . ' : </b>' . implode(', ', $link_doc) . '</p>';
}
$mmail->AltBody = $this->fields['body_text'];
}
$mmail->AddAddress($this->fields['recipient'], $this->fields['recipientname']);
if (!empty($this->fields['messageid'])) {
$mmail->MessageID = "<" . $this->fields['messageid'] . ">";
}
$messageerror = __('Error in sending the email');
if (!$mmail->Send()) {
Session::addMessageAfterRedirect($messageerror . "<br>" . $mmail->ErrorInfo, true);
$mmail->ClearAddresses();
$this->update(array('id' => $this->fields['id'], 'sent_try' => $this->fields['sent_try'] + 1));
return false;
} else {
//TRANS to be written in logs %1$s is the to email / %2$s is the subject of the mail
Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email was sent to %s'), $this->fields['recipient']), $this->fields['name'] . "\n"));
$mmail->ClearAddresses();
$this->update(array('id' => $this->fields['id'], 'sent_time' => $_SESSION['glpi_currenttime']));
$this->delete(array('id' => $this->fields['id']));
return true;
}
} else {
return false;
}
}
示例11: giveItem
//.........这里部分代码省略.........
$added = array();
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
if (strlen(trim($split[$k])) > 0) {
$text = $split[$k] . " - " . $split2[$k];
if ($split3[$k]) {
$text .= " (R)";
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
} else {
if ($data[$NAME . $num . "_2"] == 0) {
// Set name for Root entity
$data[$NAME . $num] = $LANG['entity'][2];
}
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$NAME . $num])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_deviceharddrives.specificity":
case "glpi_devicememories.specificity":
case "glpi_deviceprocessors.specificity":
return $data[$NAME . $num];
case "glpi_networkports.mac":
$out = "";
if ($itemtype == 'Computer') {
$displayed = array();
if (!empty($data[$NAME . $num . "_2"])) {
$split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
$lowstr = utf8_strtolower($split[$k]);
if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $split[$k];
$displayed[] = $lowstr;
}
}
if (!empty($data[$NAME . $num])) {
$out .= "<br>";
}
}
if (!empty($data[$NAME . $num])) {
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$count_display = 0;
示例12: giveItem
//.........这里部分代码省略.........
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
if (strlen(trim($split[$k])) > 0) {
$text = $split[$k] . " - " . Dropdown::getDropdownName('glpi_profiles', $split2[$k]);
if ($split3[$k]) {
$text .= " (R)";
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
}
break;
case "glpi_entities.completename":
if ($data[$NAME . $num . "_2"] == 0) {
// Set name for Root entity
$data[$NAME . $num] = $LANG['entity'][2];
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$NAME . $num])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_deviceharddrives.specificity":
case "glpi_devicememories.specificity":
case "glpi_deviceprocessors.specificity":
return $data[$NAME . $num];
case "glpi_networkports.mac":
$out = "";
if ($itemtype == 'Computer') {
$displayed = array();
if (!empty($data[$NAME . $num . "_2"])) {
$split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
$lowstr = utf8_strtolower($split[$k]);
if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $split[$k];
$displayed[] = $lowstr;
}
}
if (!empty($data[$NAME . $num])) {
$out .= "<br>";
}
}
if (!empty($data[$NAME . $num])) {
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$count_display = 0;
示例13: showForItem
//.........这里部分代码省略.........
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
echo "<input type='hidden' name='documentcategories_id' value='" . $CFG_GLPI["documentcategories_id_forticket"] . "'>";
}
Document::dropdown(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate an existing document') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number && $withtemplate < 2) {
$header_top .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
foreach ($columns as $key => $val) {
$header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>";
}
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
$used = array();
if ($number) {
// Don't use this for document associated to document
// To not loose navigation list for current document
if ($item->getType() != 'Document') {
Session::initNavigateListItems('Document', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
}
$document = new Document();
foreach ($documents as $data) {
$docID = $data["id"];
$link = NOT_AVAILABLE;
$downloadlink = NOT_AVAILABLE;
if ($document->getFromDB($docID)) {
$link = $document->getLink();
$downloadlink = $document->getDownloadLink($linkparam);
}
if ($item->getType() != 'Document') {
Session::addToNavigateListItems('Document', $docID);
}
$used[$docID] = $docID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
echo "<td class='center'>" . $data['entity'] . "</td>";
echo "<td class='center'>{$downloadlink}</td>";
echo "<td class='center'>";
if (!empty($data["link"])) {
echo "<a target=_blank href='" . formatOutputWebLink($data["link"]) . "'>" . $data["link"];
echo "</a>";
} else {
echo " ";
}
echo "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"]);
echo "</td>";
echo "<td class='center'>" . $data["mime"] . "</td>";
if ($CFG_GLPI['use_rich_text']) {
echo "<td class='center'>";
echo !empty($data["tag"]) ? Document::getImageTag($data["tag"]) : '';
echo "</td>";
}
echo "<td class='center'>" . Html::convDateTime($data["assocdate"]) . "</td>";
echo "</tr>";
$i++;
}
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例14: dropdownTaskItems
function dropdownTaskItems($ID, $name, $used = array())
{
global $DB, $CFG_GLPI;
$restrict = "`plugin_projet_projets_id` = '{$ID}'";
$items = getAllDatasFromTable("glpi_plugin_projet_projets_items", $restrict);
$restrictdoc = "`items_id` = '{$ID}' AND `itemtype` = 'PluginProjetProjet'";
$docs = getAllDatasFromTable("glpi_documents_items", $restrictdoc);
$restrictcontract = "`items_id` = '{$ID}' AND `itemtype` = 'PluginProjetProjet'";
$contracts = getAllDatasFromTable("glpi_contracts_items", $restrictcontract);
echo "<select name='{$name}'>";
echo "<option value='0' selected>" . Dropdown::EMPTY_VALUE . "</option>";
if (!empty($items)) {
foreach ($items as $item) {
$table = getTableForItemType($item["itemtype"]);
$query = "SELECT `" . $table . "`.*\n FROM `glpi_plugin_projet_projets_items`\n INNER JOIN `" . $table . "` ON (`" . $table . "`.`id` = `glpi_plugin_projet_projets_items`.`items_id`)\n WHERE `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item["itemtype"] . "'\n AND `glpi_plugin_projet_projets_items`.`items_id` = '" . $item["items_id"] . "' ";
if (count($used)) {
$query .= " AND `" . $table . "`.`id` NOT IN (0";
foreach ($used as $ID) {
$query .= ",{$ID}";
}
$query .= ")";
}
$query .= " GROUP BY `" . $table . "`.`name`";
$query .= " ORDER BY `" . $table . "`.`name`";
$result_linked = $DB->query($query);
if ($DB->numrows($result_linked)) {
while ($data = $DB->fetch_assoc($result_linked)) {
$name = $data["name"];
$itemclass = new $item["itemtype"]();
if ($item["itemtype"] == 'User') {
$name = getUserName($data["id"]);
}
echo "<option value='" . $data["id"] . "," . $item["itemtype"] . "'>" . $itemclass->getTypeName() . " - " . $name;
if (empty($data["name"]) || $_SESSION["glpiis_ids_visible"] == 1) {
echo " (";
echo $data["id"] . ")";
}
echo "</option>";
}
}
}
}
if (!empty($docs)) {
foreach ($docs as $doc) {
$docclass = new Document();
if ($docclass->getFromDB($doc["documents_id"])) {
$name = $docclass->fields["name"];
echo "<option value='" . $doc["documents_id"] . ",Document'>" . $docclass->getTypeName() . " - " . $name;
if (empty($name) || $_SESSION["glpiis_ids_visible"] == 1) {
echo " (";
echo $doc["documents_id"] . ")";
}
echo "</option>";
}
}
}
if (!empty($contracts)) {
foreach ($contracts as $contract) {
$contractclass = new Contract();
if ($contractclass->getFromDB($contract["contracts_id"])) {
$name = $contractclass->fields["name"];
echo "<option value='" . $contract["contracts_id"] . ",Contract'>" . $contractclass->getTypeName() . " - " . $name;
if (empty($name) || $_SESSION["glpiis_ids_visible"] == 1) {
echo " (";
echo $contract["contracts_id"] . ")";
}
echo "</option>";
}
}
}
echo "</select>";
}
示例15: showList
/**
* 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)
* */
static function showList($item, $canedit)
{
global $CFG_GLPI;
// validation des droits
if (!self::canView()) {
return false;
}
if (isset($_REQUEST["start"])) {
$start = $_REQUEST["start"];
} else {
$start = 0;
}
$rand = mt_rand();
// Get close informations
$data = self::getCloseTicketFromDB($item->getField('id'), array('start' => $start, 'limit' => $_SESSION['glpilist_limit']));
if (!count($data)) {
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No historical') . "</th></tr>";
echo "</table>";
echo "</div><br>";
} else {
$doc = new Document();
echo "<div class='center'>";
// Display the pager
Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, count($data));
if ($canedit) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('item' => __CLASS__, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th width='10'>";
if ($canedit) {
echo Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
}
echo "</th>";
echo "<th>" . __('Date') . "</th>";
echo "<th>" . __('Comments') . "</th>";
echo "<th>" . __('Writer') . "</th>";
echo "<th>" . __('Document') . "</th>";
echo "</tr>";
foreach ($data as $closeTicket) {
echo "<tr class='tab_bg_2'>";
echo "<td width='10'>";
if ($canedit) {
Html::showMassiveActionCheckBox(__CLASS__, $closeTicket['id']);
}
echo "</td>";
echo "<td>";
echo Html::convDateTime($closeTicket['date']);
echo "</td>";
echo "<td>";
echo $closeTicket['comment'];
echo "</td>";
echo "<td>";
echo getUserName($closeTicket['requesters_id']);
echo "</td>";
echo "<td>";
if ($doc->getFromDB($closeTicket['documents_id'])) {
echo $doc->getLink();
}
echo "</td>";
echo "</tr>";
}
if ($canedit) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</table>";
echo "</div>";
Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, count($data));
}
}