当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonDBTM::getTable方法代码示例

本文整理汇总了PHP中CommonDBTM::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getTable方法的具体用法?PHP CommonDBTM::getTable怎么用?PHP CommonDBTM::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonDBTM的用法示例。


在下文中一共展示了CommonDBTM::getTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHistoryData

 /**
  * Retrieve last history Data for an item
  *
  * @param $item                     CommonDBTM object
  * @param $start        integer     first line to retrieve (default 0)
  * @param $limit        integer     max number of line to retrive (0 for all) (default 0)
  * @param $sqlfilter    string      to add an SQL filter (default '')
  *
  * @return array of localized log entry (TEXT only, no HTML)
  **/
 static function getHistoryData(CommonDBTM $item, $start = 0, $limit = 0, $sqlfilter = '')
 {
     global $DB;
     $itemtype = $item->getType();
     $items_id = $item->getField('id');
     $itemtable = $item->getTable();
     $SEARCHOPTION = Search::getOptions($itemtype);
     $query = "SELECT *\n                FROM `glpi_logs`\n                WHERE `items_id` = '{$items_id}'\n                      AND `itemtype` = '{$itemtype}' ";
     if ($sqlfilter) {
         $query .= "AND ({$sqlfilter}) ";
     }
     $query .= "ORDER BY `id` DESC";
     if ($limit) {
         $query .= " LIMIT " . intval($start) . "," . intval($limit);
     }
     $changes = array();
     foreach ($DB->request($query) as $data) {
         $tmp = array();
         $tmp['display_history'] = true;
         $tmp['id'] = $data["id"];
         $tmp['date_mod'] = Html::convDateTime($data["date_mod"]);
         $tmp['user_name'] = $data["user_name"];
         $tmp['field'] = "";
         $tmp['change'] = "";
         $tmp['datatype'] = "";
         // This is an internal device ?
         if ($data["linked_action"]) {
             // Yes it is an internal device
             switch ($data["linked_action"]) {
                 case self::HISTORY_CREATE_ITEM:
                     $tmp['change'] = __('Add the item');
                     break;
                 case self::HISTORY_DELETE_ITEM:
                     $tmp['change'] = __('Delete the item');
                     break;
                 case self::HISTORY_LOCK_ITEM:
                     $tmp['change'] = __('Lock the item');
                     break;
                 case self::HISTORY_UNLOCK_ITEM:
                     $tmp['change'] = __('Unlock the item');
                     break;
                 case self::HISTORY_RESTORE_ITEM:
                     $tmp['change'] = __('Restore the item');
                     break;
                 case self::HISTORY_ADD_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if ($item2 = getItemForItemtype($data["itemtype_link"])) {
                         $tmp['field'] = $item2->getTypeName(1);
                     }
                     //TRANS: %s is the component name
                     $tmp['change'] = sprintf(__('%1$s: %2$s'), __('Add the component'), $data["new_value"]);
                     break;
                 case self::HISTORY_UPDATE_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     $change = '';
                     $linktype_field = explode('#', $data["itemtype_link"]);
                     $linktype = $linktype_field[0];
                     $field = $linktype_field[1];
                     $devicetype = $linktype::getDeviceType();
                     $tmp['field'] = $devicetype;
                     $specif_fields = $linktype::getSpecificities();
                     if (isset($specif_fields[$field]['short name'])) {
                         $tmp['field'] = $devicetype;
                         $tmp['field'] .= " (" . $specif_fields[$field]['short name'] . ")";
                     }
                     //TRANS: %1$s is the old_value, %2$s is the new_value
                     $tmp['change'] = sprintf(__('Change the component %1$s: %2$s'), $tmp['field'], sprintf(__('%1$s by %2$s'), $data["old_value"], $data["new_value"]));
                     break;
                 case self::HISTORY_DELETE_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if ($item2 = getItemForItemtype($data["itemtype_link"])) {
                         $tmp['field'] = $item2->getTypeName(1);
                     }
                     //TRANS: %s is the component name
                     $tmp['change'] = sprintf(__('%1$s: %2$s'), __('Delete the component'), $data["old_value"]);
                     break;
                 case self::HISTORY_LOCK_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if ($item2 = getItemForItemtype($data["itemtype_link"])) {
                         $tmp['field'] = $item2->getTypeName(1);
                     }
                     //TRANS: %s is the component name
                     $tmp['change'] = sprintf(__('%1$s: %2$s'), __('Lock the component'), $data["old_value"]);
                     break;
                 case self::HISTORY_UNLOCK_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if ($item2 = getItemForItemtype($data["itemtype_link"])) {
                         $tmp['field'] = $item2->getTypeName(1);
                     }
                     //TRANS: %s is the component name
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:log.class.php

示例2: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $input = $ma->getInput();
     switch ($ma->getAction()) {
         case 'move_under':
             if (isset($input['parent'])) {
                 $fk = $item->getForeignKeyField();
                 $parent = clone $item;
                 if (!$parent->getFromDB($input['parent'])) {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                     $ma->addMessage($parent->getErrorMessage(ERROR_NOT_FOUND));
                     return;
                 }
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         // Check if parent is not a child of the original one
                         if (!in_array($parent->getID(), getSonsOf($item->getTable(), $item->getID()))) {
                             if ($item->update(array('id' => $id, $fk => $parent->getID()))) {
                                 $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_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 $ma->addMessage($parent->getErrorMessage(ERROR_COMPAT));
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:korial29,项目名称:glpi,代码行数:45,代码来源:commontreedropdown.class.php

示例3: getSoftwareVersionsOrLicenses

 static function getSoftwareVersionsOrLicenses($protocol, $params = array(), CommonDBTM $item)
 {
     global $DB;
     $software = new Software();
     $resp = array();
     if ($software->can($params['data']['id'], READ)) {
         $query = "SELECT `gsv`.*\n                   FROM `" . Toolbox::addslashes_deep($item->getTable()) . "` AS gsv,\n                        `glpi_softwares` AS gs\n                   WHERE `gsv`.`softwares_id` = `gs`.`id`\n                         AND `gsv`.`softwares_id`\n                                 = '" . Toolbox::addslashes_deep($params['data']['id']) . "'\n                   GROUP BY `gsv`.`softwares_id`\n                   ORDER BY `gsv`.`softwares_id` ASC";
         $toformat = array('searchOptions' => Search::getOptions(get_class($item)), 'options' => $params['options']);
         foreach ($DB->request($query) as $version_or_license) {
             $toformat['data'] = $version_or_license;
             $result = array();
             parent::formatDataForOutput($toformat, $result);
             $resp[$version_or_license['id']] = $result;
         }
     }
     return $resp;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:17,代码来源:methodinventaire.class.php

示例4: constructHistory

 /**
  * Construct  history for an item
  *
  * @param $item CommonDBTM object
  * @param $oldvalues array of old values updated
  * @param $values array of all values of the item
  *
  * @return boolean for success (at least 1 log entry added)
  **/
 static function constructHistory(CommonDBTM $item, &$oldvalues, &$values)
 {
     global $LANG;
     if (!count($oldvalues)) {
         return false;
     }
     // needed to have  $SEARCHOPTION
     if ($item->getType() == 'TicketSatisfaction') {
         $real_type = 'Ticket';
         $real_id = $item->fields['tickets_id'];
     } else {
         if ($item->getType() == 'Infocom') {
             $real_type = $item->fields['itemtype'];
             $real_id = $item->fields['items_id'];
         } else {
             $real_type = $item->getType();
             $real_id = $item->fields['id'];
         }
     }
     $searchopt = Search::getOptions($real_type);
     if (!is_array($searchopt)) {
         return false;
     }
     $result = 0;
     foreach ($oldvalues as $key => $oldval) {
         $changes = array();
         if ($real_type == 'Infocom') {
             // Parsing $SEARCHOPTION to find infocom
             foreach ($searchopt as $key2 => $val2) {
                 if ($val2["field"] == $key && strpos($val2['table'], 'infocoms') || $key == 'budgets_id' && $val2['table'] == 'glpi_budgets' || $key == 'suppliers_id' && $val2['table'] == 'glpi_suppliers') {
                     $id_search_option = $key2;
                     // Give ID of the $SEARCHOPTION
                     if ($val2["table"] == "glpi_infocoms") {
                         // 1st case : text field -> keep datas
                         $changes = array($id_search_option, addslashes($oldval), $values[$key]);
                     } else {
                         if ($val2["table"] == "glpi_suppliers") {
                             // 2nd case ; link field -> get data from glpi_suppliers
                             $changes = array($id_search_option, addslashes(Dropdown::getDropdownName("glpi_suppliers", $oldval)), addslashes(Dropdown::getDropdownName("glpi_suppliers", $values[$key])));
                         } else {
                             // 3rd case ; link field -> get data from dropdown (budget)
                             $changes = array($id_search_option, addslashes(Dropdown::getDropdownName($val2["table"], $oldval)), addslashes(Dropdown::getDropdownName($val2["table"], $values[$key])));
                         }
                     }
                     break;
                     // foreach exit
                 }
             }
         } else {
             // Not an Infocom
             // Parsing $SEARCHOPTION to find changed field
             foreach ($searchopt as $key2 => $val2) {
                 // Linkfield or standard field not massive action enable
                 if ($val2["linkfield"] == $key || $key == $val2["field"] && $val2["table"] == $item->getTable()) {
                     $id_search_option = $key2;
                     // Give ID of the $SEARCHOPTION
                     // 1st case : Ticket specific dropdown case (without table)
                     if ($real_type == 'Ticket' && in_array($key, array('status', 'urgency', 'impact', 'priority', 'global_validation'))) {
                         switch ($key) {
                             case 'global_validation':
                                 $changes = array($id_search_option, addslashes(TicketValidation::getStatus($oldval)), addslashes(TicketValidation::getStatus($values[$key])));
                                 break;
                             case 'status':
                                 $changes = array($id_search_option, addslashes(Ticket::getStatus($oldval)), addslashes(Ticket::getStatus($values[$key])));
                                 break;
                             case 'urgency':
                                 $changes = array($id_search_option, addslashes(Ticket::getUrgencyName($oldval)), addslashes(Ticket::getUrgencyName($values[$key])));
                                 break;
                             case 'impact':
                                 $changes = array($id_search_option, addslashes(Ticket::getImpactName($oldval)), addslashes(Ticket::getImpactName($values[$key])));
                                 break;
                             case 'priority':
                                 $changes = array($id_search_option, addslashes(Ticket::getPriorityName($oldval)), addslashes(Ticket::getPriorityName($values[$key])));
                                 break;
                         }
                     } else {
                         if ($val2["table"] == $item->getTable()) {
                             // 2nd case : text field -> keep datas
                             $changes = array($id_search_option, addslashes($oldval), $values[$key]);
                         } else {
                             //                      if ($val2['table'] == 'glpi_users_validation') {
                             //                         $val2['table'] = 'glpi_users';
                             //                      }
                             // other cases ; link field -> get data from dropdown
                             if ($val2["table"] != 'glpi_complete_entities') {
                                 $changes = array($id_search_option, addslashes(Dropdown::getDropdownName($val2["table"], $oldval)), addslashes(Dropdown::getDropdownName($val2["table"], $values[$key])));
                             }
                         }
                     }
                     break;
                 }
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:log.class.php


注:本文中的CommonDBTM::getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。