static function getReservations($protocol, $params = array(), $original_params = array()) { //Source itemtype (used to find the right _items table) $linked_itemtype = $params['options']['source_itemtype']; //Linked itemtype : items to look for in the _items table $source_itemtype = $params['options']['linked_itemtype']; $item = new $source_itemtype(); $linked_item = new $linked_itemtype(); $fk = "items_id"; foreach (getAllDatasFromTable('glpi_reservationitems', "`itemtype` = '" . $linked_itemtype . "'\n AND `{$fk}` = '" . $params['data']['id'] . "'") as $reservationitems) { $reservationitems_id = $reservationitems['id']; } $output = array(); foreach (getAllDatasFromTable('glpi_reservations', "`reservationitems_id`='" . $reservationitems_id . "' ") as $data) { $item->getFromDB($data['id']); $resp = array(); $toformat = array('data' => $item->fields, 'searchOptions' => Search::getOptions(get_class($item)), 'options' => $params['options']); PluginWebservicesMethodCommon::formatDataForOutput($toformat, $resp); $output[$item->fields['id']] = $resp; } return $output; }
static function getTicketLinkedObjects($protocol, $params = array()) { global $DB; //New task or followup $item = new $params['options']['linked_itemtype'](); $output = $resp = array(); if ($item->can(-1, 'r')) { if (isset($params['options']['orderby_date'])) { $date = $params['options']['orderby_date']; } else { $date = 'date'; } $RESTRICT = ""; if ($item->maybePrivate() && !Session::haveRight("show_full_ticket", "1")) { $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') "; } // Get Number of Followups $query = "SELECT *\n FROM `" . $item->getTable() . "`\n WHERE `tickets_id` = '" . $params['data']['id'] . "'\n {$RESTRICT}\n ORDER BY `{$date}` DESC"; foreach ($DB->request($query) as $data) { $resp = array(); $params = array('data' => $data, 'searchOptions' => $item->getSearchOptions(), 'options' => $params['options']); parent::formatDataForOutput($params, $resp); $output[] = $resp; } } return $output; }