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


PHP Infocom::add方法代码示例

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


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

示例1: addInfocomsForComputer

 /**
  * @param $computers_id
  * @param $date
  * @param $computer_updates
  * @return array
  */
 static function addInfocomsForComputer($computers_id, $date, $computer_updates)
 {
     global $DB;
     $infocom = new Infocom();
     $use_date = substr($date, 0, 10);
     if ($infocom->getFromDBByQuery("WHERE `items_id` = {$computers_id} AND `itemtype` = 'Computer'")) {
         if (empty($infocom->fields['use_date']) || $infocom->fields['use_date'] == 'NULL') {
             //add use_date
             $infocom->update(array('id' => $infocom->fields['id'], 'use_date' => $use_date));
         }
     } else {
         //add infocom
         $infocom->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'use_date' => $use_date));
     }
     //Add lock
     $ocslink = new PluginOcsinventoryngOcslink();
     if ($ocslink->getFromDBforComputer($computers_id)) {
         $cfg_ocs = PluginOcsinventoryngOcsServer::getConfig($ocslink->fields["plugin_ocsinventoryng_ocsservers_id"]);
         if ($cfg_ocs["use_locks"]) {
             $computer_updates[] = "use_date";
             $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n                         SET `computer_update` = '" . addslashes(exportArrayToDB($computer_updates)) . "'\n                         WHERE `computers_id` = '{$computers_id}'";
             $DB->query($query);
         }
     }
     return $computer_updates;
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:32,代码来源:ocsadmininfoslink.class.php

示例2: transferInfocoms

 /**
  * Transfer infocoms of an item
  *
  * @param $itemtype type of the item to transfer
  * @param $ID original ID of the item
  * @param $newID new ID of the item
  **/
 function transferInfocoms($itemtype, $ID, $newID)
 {
     global $DB;
     $ic = new Infocom();
     if ($ic->getFromDBforDevice($itemtype, $ID)) {
         switch ($this->options['keep_infocom']) {
             // delete
             case 0:
                 // Same item -> delete
                 if ($ID == $newID) {
                     $query = "DELETE\n                            FROM `glpi_infocoms`\n                            WHERE `itemtype` = '{$itemtype}'\n                                  AND `items_id` = '{$ID}'";
                     $result = $DB->query($query);
                 }
                 // Copy : nothing to do
                 break;
                 // Keep
             // Keep
             default:
                 // Transfer enterprise
                 $suppliers_id = 0;
                 if ($ic->fields['suppliers_id'] > 0) {
                     $suppliers_id = $this->transferSingleSupplier($ic->fields['suppliers_id']);
                 }
                 // Copy : copy infocoms
                 if ($ID != $newID) {
                     // Copy items
                     $input = $ic->fields;
                     $input['items_id'] = $newID;
                     $input['suppliers_id'] = $suppliers_id;
                     unset($input['id']);
                     unset($ic->fields);
                     $ic->add($input);
                 } else {
                     // Same Item : manage only enterprise move
                     // Update enterprise
                     if ($suppliers_id > 0 && $suppliers_id != $ic->fields['suppliers_id']) {
                         $ic->update(array('id' => $ic->fields['id'], 'suppliers_id' => $suppliers_id));
                     }
                 }
                 break;
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:50,代码来源:transfer.class.php

示例3: saveInfocoms

 static function saveInfocoms($options)
 {
     //valeurs d'origine
     $warranty_date = "";
     $buy_date = "";
     $warranty_duration = "";
     $suppliers_id = "";
     $ic_comments = "";
     //nouvelles valeurs
     $input_infocom = array();
     if ($options["supplierId"] != 0) {
         $input_infocom["suppliers_id"] = $options["supplierId"];
     }
     $input_infocom["warranty_date"] = $options["maDate"];
     $input_infocom["warranty_duration"] = $options["warranty"];
     $input_infocom["buy_date"] = $options["maDate"];
     $input_infocom["items_id"] = $options["ID"];
     $input_infocom["itemtype"] = $options["itemtype"];
     //add new infocoms
     $ic = new infocom();
     if ($ic->getfromDBforDevice($options["itemtype"], $options["ID"])) {
         //valeurs d'origine
         $warranty_date = Html::convdate($ic->fields["warranty_date"]);
         $warranty_duration = $ic->fields["warranty_duration"];
         $buy_date = $ic->fields["buy_date"];
         $suppliers_id = Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
         $ic_comment = $ic->fields["comment"];
         //nouvelles valeurs
         $input_infocom["id"] = $ic->fields["id"];
         if ($options["addcomments"]) {
             $input_infocom["comment"] = $ic_comment . "\n" . __('Imported from web site', 'manufacturersimports') . " " . $options["suppliername"] . " " . __('With the manufacturersimports plugin', 'manufacturersimports') . " (" . Html::convdate($options["date"]) . ")";
         }
         $infocom = new Infocom();
         $infocom->update($input_infocom);
     } else {
         if ($options["addcomments"]) {
             $input_infocom["comment"] = __('Imported from web site', 'manufacturersimports') . " " . $options["suppliername"] . " " . __('With the manufacturersimports plugin', 'manufacturersimports') . " (" . Html::convdate($options["date"]) . ")";
         }
         $infocom = new Infocom();
         $infocom->add($input_infocom);
     }
     //post message
     echo "<td><span class='plugin_manufacturersimports_import_OK'>";
     echo __('Import OK', 'manufacturersimports') . " (" . Html::convdate($options["date"]) . ")";
     echo "</span></td>";
     echo "<td>";
     echo _n('Supplier', 'Suppliers', 1) . ": ";
     echo $suppliers_id . "->" . Dropdown::getDropdownName("glpi_suppliers", $options["supplierId"]) . "<br>";
     echo __('Date of purchase') . ": ";
     echo Html::convdate($buy_date) . "->" . Html::convdate($options["maDate"]) . "<br>";
     echo __('Start date of warranty') . ": ";
     echo $warranty_date . "->" . Html::convdate($options["maDate"]) . "<br>";
     if ($warranty_duration == -1) {
         $warranty_duration = __('Lifelong');
         $warranty = __('Lifelong');
     } else {
         $warranty = $options["warranty"];
     }
     echo __('Warranty duration') . ": " . $warranty_duration . "->" . $warranty . "<br>";
     echo "</td>";
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:61,代码来源:postimport.class.php

示例4: Infocom

but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

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';
$ic = new Infocom();
if (isset($_POST['add'])) {
    $ic->check(-1, CREATE, $_POST);
    $newID = $ic->add($_POST, false);
    Event::log($newID, "infocom", 4, "financial", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID));
    Html::back();
} else {
    if (isset($_POST["purge"])) {
        $ic->check($_POST["id"], PURGE);
        $ic->delete($_POST, 1);
        Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        Html::back();
    } else {
        if (isset($_POST["update"])) {
            $ic->check($_POST["id"], UPDATE);
            $ic->update($_POST);
            Event::log($_POST["id"], "infocom", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:infocom.form.php

示例5: addInfocoms

/** Generate bigdump : add infocoms to an item
 *
 * @param $type            item type
 * @param $ID              item ID
 * @param $ID_entity       entity ID
 * @param $is_recursive    (default 0)
**/
function addInfocoms($type, $ID, $ID_entity, $is_recursive=0) {
   global $DB, $FIRST, $LAST;

   $current_year = date('Y');

   $orderdate     = strtotime(mt_rand(2000,$current_year)."-".mt_rand(1,12)."-".mt_rand(1,28));
   $buydate       = $orderdate+mt_rand(0, 60)*DAY_TIMESTAMP;
   $deliverydate  = $orderdate+mt_rand(0, 60)*DAY_TIMESTAMP;
   $usedate       = $deliverydate+mt_rand(0, 60)*DAY_TIMESTAMP;
   $warrantydate  = $deliverydate;
   $inventorydate = $deliverydate;

   $orderdate     = date("Y-m-d", intval($orderdate));
   $buydate       = date("Y-m-d", intval($buydate));
   $deliverydate  = date("Y-m-d", intval($deliverydate));
   $usedate       = date("Y-m-d", intval($usedate));
   $warrantydate  = date("Y-m-d", intval($warrantydate));
   $inventorydate = date("Y-m-d", intval($inventorydate));

   $i = new Infocom();
   $i->add(toolbox::addslashes_deep(
           array('itemtype'           => $type,
                  'items_id'          => $ID,
                  'entities_id'       => $ID_entity,
                  'is_recursive'      => $is_recursive,
                  'buy_date'          => $buydate,
                  'use_date'          => $usedate,
                  'warranty_duration' => mt_rand(12,36),
                  'warranty_info'     => "infowar ' $type $ID",
                  'suppliers_id'      => mt_rand($FIRST["enterprises"], $LAST['enterprises']),
                  'order_number'      => "commande ' $type $ID",
                  'delivery_number'   => "BL ' $type $ID",
                  'immo_number'       => "immo ' $type $ID",
                  'value'             => mt_rand(0,5000),
                  'warranty_value'    => mt_rand(0,500),
                  'sink_time'         => mt_rand(1,7),
                  'sink_type'         => mt_rand(1,2),
                  'sink_coeff'        => mt_rand(2,5),
                  'comment'           => "comment ' $type $ID",
                  'bill'              => "bill ' $type $ID",
                  'budgets_id'        => mt_rand($FIRST['budget'], $LAST['budget']),
                  'order_date'        => $orderdate,
                  'delivery_date'     => $deliverydate,
                  'inventory_date'    => $inventorydate,
                  'warranty_date'     => $warrantydate)));
}
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:53,代码来源:generate_bigdump.function.php

示例6: processMassiveActionsForOneItemtype

 /**
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     $action = $ma->getAction();
     switch ($action) {
         case 'delete':
             foreach ($ids as $id) {
                 if ($item->can($id, DELETE)) {
                     if ($item->delete(array("id" => $id))) {
                         $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_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'restore':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     if ($item->restore(array("id" => $id))) {
                         $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_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'purge_item_but_devices':
         case 'purge_but_item_linked':
         case 'purge':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     $force = 1;
                     // Only mark deletion for
                     if ($item->maybeDeleted() && $item->useDeletedToLockIfDynamic() && $item->isDynamic()) {
                         $force = 0;
                     }
                     $delete_array = array('id' => $id);
                     if ($action == 'purge_item_but_devices') {
                         $delete_array['keep_devices'] = true;
                     }
                     if ($item instanceof CommonDropdown) {
                         if ($item->haveChildren()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item by massive actions, because it has sub-items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                         if ($item->isUsed()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item, because it is used for one or more items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                     }
                     if ($item->delete($delete_array, $force)) {
                         $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_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'update':
             if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
                 return false;
             }
             $index = $ma->POST['search_options'][$item->getType()];
             $searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
             $input = $ma->POST;
             if (isset($searchopt[$index])) {
                 /// Infocoms case
                 if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$index]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
//.........这里部分代码省略.........
开发者ID:kipman,项目名称:glpi,代码行数:101,代码来源:massiveaction.class.php

示例7: generateInfoComRelatedToOrder

 public function generateInfoComRelatedToOrder($entity, $detailID, $itemtype, $items_id, $templateID = 0)
 {
     global $CFG_GLPI;
     //Do not try to generate infocoms if itemtype doesn't support it (ie contracts...)
     if (in_array($itemtype, $CFG_GLPI["infocom_types"])) {
         // Retrieve configuration for generate assets feature
         $config = PluginOrderConfig::getConfig();
         $fields = array();
         //Create empty infocom, in order to forward entities_id and is_recursive
         $ic = new Infocom();
         $infocomID = !$ic->getFromDBforDevice($itemtype, $items_id) ? false : $ic->fields["id"];
         $detail = new PluginOrderOrder_Item();
         $detail->getFromDB($detailID);
         $order = new PluginOrderOrder();
         $order->getFromDB($detail->fields["plugin_order_orders_id"]);
         $order_supplier = new PluginOrderOrder_Supplier();
         $order_supplier->getFromDBByOrder($detail->fields["plugin_order_orders_id"]);
         if ($templateID) {
             if ($ic->getFromDBforDevice($itemtype, $templateID)) {
                 $fields = $ic->fields;
                 unset($fields["id"]);
                 if (isset($fields["immo_number"])) {
                     $fields["immo_number"] = autoName($fields["immo_number"], "immo_number", 1, 'Infocom', $entity);
                 }
                 if (empty($fields['buy_date'])) {
                     unset($fields['buy_date']);
                 }
             }
         }
         $fields["entities_id"] = $entity;
         $fields["itemtype"] = $itemtype;
         $fields["items_id"] = $items_id;
         $fields["order_number"] = $order->fields["num_order"];
         $fields["delivery_number"] = $detail->fields["delivery_number"];
         $fields["budgets_id"] = $order->fields["budgets_id"];
         $fields["suppliers_id"] = $order->fields["suppliers_id"];
         $fields["value"] = $detail->fields["price_discounted"];
         $fields["order_date"] = $order->fields["order_date"];
         if (!is_null($detail->fields["delivery_date"])) {
             $fields["delivery_date"] = $detail->fields["delivery_date"];
         }
         // Get bill data
         if ($config->canAddBillDetails()) {
             $bill = new PluginOrderBill();
             if ($bill->getFromDB($detail->fields["plugin_order_bills_id"])) {
                 $fields['bill'] = $bill->fields['number'];
                 $fields['warranty_date'] = $bill->fields['billdate'];
             }
         }
         foreach (array('warranty_date', 'buy_date', 'inventory_date') as $date) {
             if (!isset($fields[$date])) {
                 $fields[$date] = 'NULL';
             }
         }
         $fields['_no_warning'] = true;
         if ($infocomID) {
             $fields['id'] = $infocomID;
             $ic->update($fields);
         } else {
             $ic->add($fields);
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:63,代码来源:link.class.php

示例8: foreach

         $contactsupplier = new Contact_Supplier();
         foreach ($_POST["item"] as $key => $val) {
             $input = array('suppliers_id' => $_POST['entID'], 'contacts_id' => $key);
             if ($contactsupplier->can(-1, 'w', $input)) {
                 $contactsupplier->add($input);
             }
         }
     }
     break;
 case "activate_infocoms":
     $ic = new Infocom();
     if ($ic->canCreate()) {
         foreach ($_POST["item"] as $key => $val) {
             $input = array('itemtype' => $_POST['itemtype'], 'items_id' => $key);
             if (!$ic->getFromDBforDevice($_POST['itemtype'], $key)) {
                 $ic->add($input);
             }
         }
     }
     break;
 case "change_authtype":
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $ids[] = $key;
         }
     }
     User::changeAuthMethod($ids, $_POST["authtype"], $_POST["auths_id"]);
     break;
 case "unlock_ocsng_field":
     $fields = OcsServer::getLockableFields();
     if ($_POST['field'] == 'all' || isset($fields[$_POST['field']])) {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php

示例9: add

 /**
  * Add an item in the database with all it's items.
  *
  * @param $input array : the _POST vars returned by the item form when press add
  * @param options an array with the insert options
  *   - unicity_message : do not display message if item it a duplicate (default is yes)
  * @param $history boolean : do history log ?
  *
  * @return integer the new ID of the added item (or false if fail)
  **/
 function add($input, $options = array(), $history = true)
 {
     global $DB, $CFG_GLPI;
     if ($DB->isSlave()) {
         return false;
     }
     // Store input in the object to be available in all sub-method / hook
     $this->input = $input;
     // Call the plugin hook - $this->input can be altered
     doHook("pre_item_add", $this);
     if ($this->input && is_array($this->input)) {
         if (isset($this->input['add'])) {
             $this->input['_add'] = $this->input['add'];
             unset($this->input['add']);
         }
         $this->input = $this->prepareInputForAdd($this->input);
         //Check values to inject
         $this->filterValues();
     }
     if ($this->input && is_array($this->input)) {
         $this->fields = array();
         $table_fields = $DB->list_fields($this->getTable());
         // fill array for add
         foreach ($this->input as $key => $val) {
             if ($key[0] != '_' && isset($table_fields[$key])) {
                 $this->fields[$key] = $this->input[$key];
             }
         }
         // Auto set date_mod if exsist
         if (isset($table_fields['date_mod'])) {
             $this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
         }
         if ($this->checkUnicity(true, $options)) {
             if ($this->addToDB()) {
                 $this->addMessageOnAddAction();
                 $this->post_addItem();
                 if ($this->dohistory && $history) {
                     $changes[0] = 0;
                     $changes[1] = $changes[2] = "";
                     Log::history($this->fields["id"], $this->getType(), $changes, 0, HISTORY_CREATE_ITEM);
                 }
                 // Auto create infocoms
                 if ($CFG_GLPI["auto_create_infocoms"] && in_array($this->getType(), $CFG_GLPI["infocom_types"])) {
                     $ic = new Infocom();
                     if (!$ic->getFromDBforDevice($this->getType(), $this->fields['id'])) {
                         $ic->add(array('itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
                     }
                 }
                 // If itemtype is in infocomtype and if states_id field is filled
                 // and item is not a template
                 if (in_array($this->getType(), $CFG_GLPI["infocom_types"]) && isset($this->input['states_id']) && (!isset($this->input['is_template']) || !$this->input['is_template'])) {
                     //Check if we have to automaticall fill dates
                     Infocom::manageDateOnStatusChange($this);
                 }
                 doHook("item_add", $this);
                 return $this->fields['id'];
             }
         }
     }
     $this->last_status = self::NOTHING_TO_DO;
     return false;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:72,代码来源:commondbtm.class.php

示例10: add

 /**
  * Add an item in the database with all it's items.
  *
  * @param $input     array    the _POST vars returned by the item form when press add
  * @param options    array    with the insert options
  *   - unicity_message : do not display message if item it a duplicate (default is yes)
  * @param $history   boolean  do history log ? (true by default)
  *
  * @return integer the new ID of the added item (or false if fail)
  **/
 function add(array $input, $options = array(), $history = true)
 {
     global $DB, $CFG_GLPI;
     if ($DB->isSlave()) {
         return false;
     }
     // Store input in the object to be available in all sub-method / hook
     $this->input = $input;
     if (isset($this->input['add'])) {
         // Input from the interface
         // Save this data to be available if add fail
         $this->saveInput();
     }
     // Call the plugin hook - $this->input can be altered
     // This hook get the data from the form, not yet altered
     Plugin::doHook("pre_item_add", $this);
     if ($this->input && is_array($this->input)) {
         if (isset($this->input['add'])) {
             $this->input['_add'] = $this->input['add'];
             unset($this->input['add']);
         }
         $this->input = $this->prepareInputForAdd($this->input);
     }
     if ($this->input && is_array($this->input)) {
         // Call the plugin hook - $this->input can be altered
         // This hook get the data altered by the object method
         Plugin::doHook("post_prepareadd", $this);
     }
     if ($this->input && is_array($this->input)) {
         //Check values to inject
         $this->filterValues(!isCommandLine());
     }
     if ($this->input && is_array($this->input)) {
         $this->fields = array();
         $table_fields = $DB->list_fields($this->getTable());
         // fill array for add
         foreach ($this->input as $key => $val) {
             if ($key[0] != '_' && isset($table_fields[$key])) {
                 $this->fields[$key] = $this->input[$key];
             }
         }
         // Auto set date_mod if exsist
         if (isset($table_fields['date_mod'])) {
             $this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
         }
         if ($this->checkUnicity(true, $options)) {
             if ($this->addToDB()) {
                 $this->post_addItem();
                 $this->addMessageOnAddAction();
                 if ($this->dohistory && $history) {
                     $changes[0] = 0;
                     $changes[1] = $changes[2] = "";
                     Log::history($this->fields["id"], $this->getType(), $changes, 0, Log::HISTORY_CREATE_ITEM);
                 }
                 // Auto create infocoms
                 if (isset($CFG_GLPI["auto_create_infocoms"]) && $CFG_GLPI["auto_create_infocoms"] && Infocom::canApplyOn($this)) {
                     $ic = new Infocom();
                     if (!$ic->getFromDBforDevice($this->getType(), $this->fields['id'])) {
                         $ic->add(array('itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
                     }
                 }
                 // If itemtype is in infocomtype and if states_id field is filled
                 // and item is not a template
                 if (InfoCom::canApplyOn($this) && isset($this->input['states_id']) && (!isset($this->input['is_template']) || !$this->input['is_template'])) {
                     //Check if we have to automatical fill dates
                     Infocom::manageDateOnStatusChange($this);
                 }
                 Plugin::doHook("item_add", $this);
                 // As add have suceed, clean the old input value
                 if (isset($this->input['_add'])) {
                     $this->clearSavedInput();
                 }
                 if ($this->mailqueueonaction) {
                     QueuedMail::forceSendFor($this->getType(), $this->fields['id']);
                 }
                 return $this->fields['id'];
             }
         }
     }
     $this->last_status = self::NOTHING_TO_DO;
     return false;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:92,代码来源:commondbtm.class.php

示例11: doMassiveActions

 /**
  * Do the standard massive actions
  *
  * @since version 0.84
  *
  * This must not be overloaded in Class
  * @param $input array of input datas
  *
  * @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
  **/
 function doMassiveActions($input = array())
 {
     global $CFG_GLPI;
     if (!isset($input["item"]) || count($input["item"]) == 0) {
         return false;
     }
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'add_document':
         case 'remove_document':
             $doc = new Document();
             return $doc->doSpecificMassiveActions($input);
         case "add_transfer_list":
             if (!isset($_SESSION['glpitransfer_list'])) {
                 $_SESSION['glpitransfer_list'] = array();
             }
             if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
                 $_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
             }
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
                     $res['ok']++;
                 }
             }
             $res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
             break;
         case "delete":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->delete(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "purge":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         $force = 1;
                         // Only mark deletion for
                         if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
                             $force = 0;
                         }
                         if ($this->delete(array("id" => $key), $force)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "restore":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->restore(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "update":
             $searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
             if (isset($searchopt[$input["id_field"]])) {
                 /// Infocoms case
                 if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
                             $link_entity_type = $ent->fields["entities_id"];
                         }
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:commondbtm.class.php

示例12: Infocom

You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
$ic = new Infocom();
if (isset($_GET["add"])) {
    $ic->check(-1, 'w', $_GET);
    $newID = $ic->add($_GET, false);
    Event::log($newID, "infocom", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][20]);
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $ic->check($_POST["id"], 'w');
        $ic->delete($_POST);
        Event::log($_POST["id"], "infocom", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
        glpi_header($_SERVER['HTTP_REFERER']);
    } else {
        if (isset($_POST["update"])) {
            $ic->check($_POST["id"], 'w');
            $ic->update($_POST);
            Event::log($_POST["id"], "infocom", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
            glpi_header($_SERVER['HTTP_REFERER']);
        } else {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:30,代码来源:infocom.form.php


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