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


PHP Toolbox::addslashes_deep方法代码示例

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


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

示例1: testLog

 public function testLog()
 {
     global $DB;
     $DB->connect();
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $computer = new Computer();
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $date = date('Y-m-d H:i:s');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $this->a_inventory = array('fusioninventorycomputer' => array('winowner' => 'test', 'wincompany' => 'siprossii', 'operatingsystem_installationdate' => '2012-10-16 08:12:56', 'last_fusioninventory_update' => $date), 'soundcard' => array(), 'graphiccard' => array(), 'controller' => array(), 'processor' => array(), 'computerdisk' => array(), 'memory' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'networkport' => array(), 'SOFTWARES' => array(), 'harddrive' => array(), 'virtualmachine' => array(), 'antivirus' => array(), 'storage' => array(), 'licenseinfo' => array(), 'networkcard' => array(), 'drive' => array(), 'batteries' => array(), 'itemtype' => 'Computer');
     $this->a_inventory['Computer'] = array('name' => 'pc', 'users_id' => 0, 'operatingsystems_id' => 'freebsd', 'operatingsystemversions_id' => '9.1-RELEASE', 'uuid' => '68405E00-E5BE-11DF-801C-B05981201220', 'domains_id' => 'mydomain.local', 'os_licenseid' => '', 'os_license_number' => '', 'operatingsystemservicepacks_id' => 'GENERIC ()root@farrell.cse.buffalo.edu', 'manufacturers_id' => '', 'computermodels_id' => '', 'serial' => 'XB63J7D', 'computertypes_id' => 'Notebook', 'is_dynamic' => 1, 'contact' => 'ddurieux');
     $this->a_inventory['processor'] = array(array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400));
     $this->a_inventory['memory'] = array(array('size' => 2048, 'serial' => '98F6FF18', 'frequence' => '1067 MHz', 'devicememorytypes_id' => 'DDR3', 'designation' => 'DDR3 - SODIMM (None)', 'busID' => 1), array('size' => 2048, 'serial' => '95F1833E', 'frequence' => '1067 MHz', 'devicememorytypes_id' => 'DDR3', 'designation' => 'DDR3 - SODIMM (None)', 'busID' => 2));
     $this->a_inventory['monitor'] = array(array('name' => '', 'serial' => '', 'manufacturers_id' => ''));
     $this->a_inventory['networkport'] = array('em0-00:23:18:cf:0d:93' => array('name' => 'em0', 'netmask' => '255.255.255.0', 'subnet' => '192.168.30.0', 'mac' => '00:23:18:cf:0d:93', 'instantiation_type' => 'NetworkPortEthernet', 'virtualdev' => 0, 'ssid' => '', 'gateway' => '', 'dhcpserver' => '', 'logical_number' => 0, 'ipaddress' => array('192.168.30.198')), 'lo0-' => array('name' => 'lo0', 'virtualdev' => 1, 'mac' => '', 'instantiation_type' => 'NetworkPortLocal', 'subnet' => '', 'ssid' => '', 'gateway' => '', 'netmask' => '', 'dhcpserver' => '', 'logical_number' => 1, 'ipaddress' => array('::1', 'fe80::1', '127.0.0.1')));
     $this->a_inventory['software'] = array('gentiumbasic$$$$110$$$$1$$$$0' => array('name' => 'GentiumBasic', 'version' => 110, 'manufacturers_id' => 1, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1), 'imagemagick$$$$6.8.0.7_1$$$$2$$$$0' => array('name' => 'ImageMagick', 'version' => '6.8.0.7_1', 'manufacturers_id' => 2, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1), 'orbit2$$$$2.14.19$$$$3$$$$0' => array('name' => 'ORBit2', 'version' => '2.14.19', 'manufacturers_id' => 3, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1));
     $this->a_inventory = $pfFormatconvert->replaceids($this->a_inventory);
     $serialized = gzcompress(serialize($this->a_inventory));
     $this->a_inventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
     $computer->add(array('serial' => 'XB63J7D', 'entities_id' => 0));
     // truncate glpi_logs
     $DB->query('TRUNCATE TABLE `glpi_logs`;');
     $this->assertEquals(0, countElementsInTable('glpi_logs'), "Log must be empty (truncate)");
     $_SESSION['glpiactive_entity'] = 0;
     $pfiComputerLib->updateComputer($this->a_inventory, 1, TRUE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     foreach ($a_logs as $id => $data) {
         unset($data['date_mod']);
         $a_logs[$id] = $data;
     }
     $a_reference = array(1 => array('id' => 1, 'itemtype' => 'Software', 'items_id' => 1, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 2 => array('id' => 2, 'itemtype' => 'Software', 'items_id' => 2, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 3 => array('id' => 3, 'itemtype' => 'Software', 'items_id' => 3, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 4 => array('id' => 4, 'itemtype' => 'SoftwareVersion', 'items_id' => 1, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 5 => array('id' => 5, 'itemtype' => 'SoftwareVersion', 'items_id' => 2, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 6 => array('id' => 6, 'itemtype' => 'SoftwareVersion', 'items_id' => 3, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''));
     $this->assertEquals($a_reference, $a_logs, "Log must be 6 " . print_r($a_logs, true));
     $DB->query('TRUNCATE `glpi_logs`');
     // Update a second time and must not have any new lines in glpi_logs
     $pfiComputerLib->updateComputer($this->a_inventory, 1, FALSE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     $a_reference = array();
     $this->assertEquals($a_reference, $a_logs, "Log may be empty at second update " . print_r($a_logs, true));
     // * Modify: contact
     // * remove a processor
     // * Remove a software
     $this->a_inventory['Computer']['contact'] = 'root';
     unset($this->a_inventory['processor'][3]);
     unset($this->a_inventory['software']['orbit2$$$$2.14.19$$$$3$$$$0']);
     $DB->query('TRUNCATE `glpi_logs`');
     $pfiComputerLib->updateComputer($this->a_inventory, 1, FALSE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     foreach ($a_logs as $id => $data) {
         unset($data['date_mod']);
         $a_logs[$id] = $data;
     }
     $a_reference = array(1 => array('id' => '1', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => '', 'linked_action' => '0', 'user_name' => '', 'id_search_option' => '7', 'old_value' => 'ddurieux', 'new_value' => 'root'), 2 => array('id' => '2', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => 'DeviceProcessor', 'linked_action' => '3', 'user_name' => '', 'id_search_option' => '0', 'old_value' => 'Core i3 (1)', 'new_value' => ''), 3 => array('id' => '3', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => 'SoftwareVersion', 'linked_action' => '5', 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => '0', 'old_value' => 'ORBit2 - 2.14.19 (3)', 'new_value' => ''), 4 => array('id' => '4', 'itemtype' => 'SoftwareVersion', 'items_id' => '3', 'itemtype_link' => 'Computer', 'linked_action' => '5', 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => '0', 'old_value' => 'pc (1)', 'new_value' => ''));
     $this->assertEquals($a_reference, $a_logs, "May have 5 logs (update contact, remove processor\n         and remove a software)");
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:57,代码来源:ComputerLogTest.php

示例2: updatePrinter

 /**
  * Function to update Printer
  *
  * @param array $a_inventory data fron agent inventory
  * @param id $items_id id of the printer
  *
  * @return nothing
  */
 function updatePrinter($a_inventory, $items_id)
 {
     global $DB;
     $printer = new Printer();
     $pfPrinter = new PluginFusioninventoryPrinter();
     $printer->getFromDB($items_id);
     if (!isset($_SESSION['glpiactiveentities_string'])) {
         $_SESSION['glpiactiveentities_string'] = $printer->fields['entities_id'];
     }
     if (!isset($_SESSION['glpiactiveentities'])) {
         $_SESSION['glpiactiveentities'] = array($printer->fields['entities_id']);
     }
     if (!isset($_SESSION['glpiactive_entity'])) {
         $_SESSION['glpiactive_entity'] = $printer->fields['entities_id'];
     }
     // * Printer
     $db_printer = $printer->fields;
     $a_lockable = PluginFusioninventoryLock::getLockFields('glpi_printers', $items_id);
     $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['Printer'], $db_printer, $a_lockable);
     $a_inventory['Printer'] = $a_ret[0];
     $input = $a_inventory['Printer'];
     $input['id'] = $items_id;
     $printer->update($input);
     // * Printer fusion (ext)
     $db_printer = array();
     $query = "SELECT *\n            FROM `" . getTableForItemType("PluginFusioninventoryPrinter") . "`\n            WHERE `printers_id` = '{$items_id}'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_assoc($result)) {
         foreach ($data as $key => $value) {
             $db_printer[$key] = Toolbox::addslashes_deep($value);
         }
     }
     if (count($db_printer) == '0') {
         // Add
         $a_inventory['PluginFusioninventoryPrinter']['printers_id'] = $items_id;
         $pfPrinter->add($a_inventory['PluginFusioninventoryPrinter']);
     } else {
         // Update
         $idtmp = $db_printer['id'];
         unset($db_printer['id']);
         unset($db_printer['printers_id']);
         unset($db_printer['plugin_fusioninventory_configsecurities_id']);
         $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['PluginFusioninventoryPrinter'], $db_printer);
         $a_inventory['PluginFusioninventoryPrinter'] = $a_ret[0];
         $input = $a_inventory['PluginFusioninventoryPrinter'];
         $input['id'] = $idtmp;
         $pfPrinter->update($input);
     }
     // * Ports
     $this->importPorts($a_inventory, $items_id);
     // Page counters
     $this->importPageCounters($a_inventory['pagecounters'], $items_id);
     // Cartridges
     $this->importCartridges($a_inventory['cartridge'], $items_id);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:63,代码来源:inventoryprinterlib.class.php

示例3: postClone

 static function postClone(NotificationTemplate $clone, $oldid)
 {
     global $DB;
     $trad = new NotificationTemplateTranslation();
     $fkey = getForeignKeyFieldForTable($clone->getTable());
     $crit = array($fkey => $oldid);
     foreach ($DB->request($trad->getTable(), $crit) as $data) {
         unset($data['id']);
         $data[$fkey] = $clone->getID();
         $trad->add(Toolbox::addslashes_deep($data));
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:12,代码来源:notificationtemplate.class.php

示例4: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_billstates` (\n                 `id` int(11) NOT NULL AUTO_INCREMENT,\n                 `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n                 `comment` text COLLATE utf8_unicode_ci,\n                 PRIMARY KEY (`id`),\n                 KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     if (countElementsInTable($table) < 2) {
         $state = new self();
         foreach (array(self::PAID => __("Paid", "order"), self::NOTPAID => __("Not paid", "order")) as $id => $label) {
             $state->add(array('id' => $id, 'name' => Toolbox::addslashes_deep($label)));
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:16,代码来源:billstate.class.php

示例5: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     //1.2.0
     $DB->query("DROP TABLE IF EXISTS `glpi_dropdown_plugin_order_status`;");
     if (!TableExists($table)) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orderstates` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `comment` text collate utf8_unicode_ci,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     $state = new self();
     foreach (array(1 => __("Draft", "order"), 2 => __("Waiting for approval", "order"), 3 => __("Validated", "order"), 4 => __("Being delivered", "order"), 5 => __("Delivered", "order"), 6 => __("Canceled", "order"), 7 => __("Paid", "order")) as $id => $label) {
         if (!countElementsInTable($table, "`id`='{$id}'")) {
             $state->add(array('id' => $id, 'name' => Toolbox::addslashes_deep($label)));
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:18,代码来源:orderstate.class.php

示例6: postClone

 static function postClone(Rule $clone, $oldid)
 {
     global $DB;
     $fkey = getForeignKeyFieldForTable($clone->getTable());
     $crit = array($fkey => $oldid);
     $criteria = new RuleCriteria();
     foreach ($DB->request($criteria->getTable(), $crit) as $data) {
         unset($data['id']);
         $data[$fkey] = $clone->getID();
         $criteria->add(Toolbox::addslashes_deep($data));
     }
     $action = new RuleAction();
     foreach ($DB->request($action->getTable(), $crit) as $data) {
         unset($data['id']);
         $data[$fkey] = $clone->getID();
         $action->add(Toolbox::addslashes_deep($data));
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:18,代码来源:rule.class.php

示例7: cloneItem

 static function cloneItem($itemtype, $oldid, $newid)
 {
     global $DB;
     foreach (self::getDeviceTypes() as $link_type) {
         $query = "SELECT *\n                   FROM `" . $link_type::getTable() . "`\n                   WHERE `itemtype` = '{$itemtype}'\n                         AND `items_id` = '{$oldid}'";
         $result_iterator = $DB->request($query);
         if ($result_iterator->numrows() > 0) {
             $link = new $link_type();
             foreach ($result_iterator as $data) {
                 unset($data['id']);
                 $data['items_id'] = $newid;
                 $data['_itemtype'] = $itemtype;
                 $data['_no_history'] = true;
                 $data = Toolbox::addslashes_deep($data);
                 $link->add($data);
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:19,代码来源:item_devices.class.php

示例8: transfer

 static function transfer($ID, $entity)
 {
     global $DB;
     if ($ID > 0) {
         // Not already transfer
         // Search init item
         foreach ($DB->request('glpi_plugin_racks_racktypes', array('id' => $ID)) as $data) {
             $data = Toolbox::addslashes_deep($data);
             $input['name'] = $data['name'];
             $input['entities_id'] = $entity;
             $temp = new self();
             $newID = $temp->getID($input);
             if ($newID < 0) {
                 $newID = $temp->import($input);
             }
             return $newID;
         }
     }
     return 0;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:20,代码来源:racktype.class.php

示例9: transfer

 /**
  * During resource or employment transfer
  *
  * @static
  * @param $ID
  * @param $entity
  * @return ID|int|the
  */
 static function transfer($ID, $entity)
 {
     global $DB;
     if ($ID > 0) {
         // Not already transfer
         // Search init item
         $query = "SELECT *\n                   FROM `glpi_plugin_resources_professions`\n                   WHERE `id` = '{$ID}'";
         if ($result = $DB->query($query)) {
             if ($DB->numrows($result)) {
                 $data = $DB->fetch_assoc($result);
                 $data = Toolbox::addslashes_deep($data);
                 $input['name'] = $data['name'];
                 $input['entities_id'] = $entity;
                 $temp = new self();
                 $newID = $temp->getID($input);
                 if ($newID < 0) {
                     $newID = $temp->import($input);
                 }
                 //transfer of the linked line
                 $line = PluginResourcesProfessionLine::transfer($temp->fields["plugin_resources_professionlines_id"], $entity);
                 if ($line > 0) {
                     $values["id"] = $newID;
                     $values["plugin_resources_professionlines_id"] = $line;
                     $temp->update($values);
                 }
                 //transfer of the linked category
                 $category = PluginResourcesProfessionCategory::transfer($temp->fields["plugin_resources_professioncategories_id"], $entity);
                 if ($category > 0) {
                     $values["id"] = $newID;
                     $values["plugin_resources_professioncategories_id"] = $category;
                     $temp->update($values);
                 }
                 return $newID;
             }
         }
     }
     return 0;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:46,代码来源:profession.class.php

示例10: transfer

 static function transfer($ID, $entity)
 {
     global $DB;
     if ($ID > 0) {
         // Not already transfer
         // Search init item
         $query = "SELECT *\n                   FROM `glpi_plugin_webapplications_webapplicationtypes`\n                   WHERE `id` = '{$ID}'";
         if ($result = $DB->query($query)) {
             if ($DB->numrows($result)) {
                 $data = $DB->fetch_assoc($result);
                 $data = Toolbox::addslashes_deep($data);
                 $input['name'] = $data['name'];
                 $input['entities_id'] = $entity;
                 $temp = new self();
                 $newID = $temp->getID($input);
                 if ($newID < 0) {
                     $newID = $temp->import($input);
                 }
                 return $newID;
             }
         }
     }
     return 0;
 }
开发者ID:wittwerch,项目名称:webapplications,代码行数:24,代码来源:webapplicationtype.class.php

示例11: transfer

 static function transfer($ID, $entity)
 {
     global $DB;
     $simcardVoltage = new self();
     if ($ID > 0) {
         // Not already transfer
         // Search init item
         $query = "SELECT *\n                   FROM `" . $simcardVoltage->getTable() . "`\n                   WHERE `id` = '{$ID}'";
         if ($result = $DB->query($query)) {
             if ($DB->numrows($result)) {
                 $data = $DB->fetch_assoc($result);
                 $data = Toolbox::addslashes_deep($data);
                 $input['name'] = $data['name'];
                 $input['entities_id'] = $entity;
                 $newID = $simcardVoltage->getID($input);
                 if ($newID < 0) {
                     $newID = $simcardVoltage->import($input);
                 }
                 return $newID;
             }
         }
     }
     return 0;
 }
开发者ID:NandyJoshu,项目名称:simcard,代码行数:24,代码来源:simcardvoltage.class.php

示例12: getConfirmationOnActionScript

 /**
  * Get confirmation on button or link before action
  *
  * @since version 0.85
  *
  * @param $string             string   to display or array of string for using multilines
  * @param $additionalactions  string   additional actions to do on success confirmation
  *                                     (default '')
  *
  * @return confirmation script
  **/
 static function getConfirmationOnActionScript($string, $additionalactions = '')
 {
     if (!is_array($string)) {
         $string = array($string);
     }
     $string = Toolbox::addslashes_deep($string);
     $additionalactions = trim($additionalactions);
     $out = "";
     $multiple = false;
     $close_string = '';
     // Manage multiple confirmation
     foreach ($string as $tab) {
         if (is_array($tab)) {
             $multiple = true;
             $out .= "if (window.confirm('";
             $out .= implode('\\n', $tab);
             $out .= "')){ ";
             $close_string .= "return true;} else { return false;}";
         }
     }
     // manage simple confirmation
     if (!$multiple) {
         $out .= "if (window.confirm('";
         $out .= implode('\\n', $string);
         $out .= "')){ ";
         $close_string .= "return true;} else { return false;}";
     }
     $out .= $additionalactions . (substr($additionalactions, -1) != ';' ? ';' : '') . $close_string;
     return $out;
 }
开发者ID:OlivierLM,项目名称:glpi,代码行数:41,代码来源:html.class.php

示例13: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     global $CFG_GLPI;
     // Set default status to avoid notice
     if (!isset($input["status"])) {
         $input["status"] = self::INCOMING;
     }
     if (!isset($input["urgency"]) || !($CFG_GLPI['urgency_mask'] & 1 << $input["urgency"])) {
         $input["urgency"] = 3;
     }
     if (!isset($input["impact"]) || !($CFG_GLPI['impact_mask'] & 1 << $input["impact"])) {
         $input["impact"] = 3;
     }
     if (!isset($input["priority"])) {
         $input["priority"] = $this->computePriority($input["urgency"], $input["impact"]);
     }
     // set last updater if interactive user
     if (!Session::isCron() && ($last_updater = Session::getLoginUserID(true))) {
         $input['users_id_lastupdater'] = $last_updater;
     }
     // No Auto set Import for external source
     if (!isset($input['_auto_import'])) {
         if (!isset($input["_users_id_requester"])) {
             if ($uid = Session::getLoginUserID()) {
                 $input["_users_id_requester"] = $uid;
             }
         }
     }
     // No Auto set Import for external source
     if (($uid = Session::getLoginUserID()) && !isset($input['_auto_import'])) {
         $input["users_id_recipient"] = $uid;
     } else {
         if (isset($input["_users_id_requester"]) && $input["_users_id_requester"]) {
             $input["users_id_recipient"] = $input["_users_id_requester"];
         }
     }
     // No name set name
     $input["name"] = ltrim($input["name"]);
     $input['content'] = ltrim($input['content']);
     if (empty($input["name"])) {
         $input['name'] = Html::clean(Html::entity_decode_deep($input['content']));
         $input["name"] = preg_replace('/\\r\\n/', ' ', $input['name']);
         $input["name"] = preg_replace('/\\n/', ' ', $input['name']);
         // For mailcollector
         $input["name"] = preg_replace('/\\\\r\\\\n/', ' ', $input['name']);
         $input["name"] = preg_replace('/\\\\n/', ' ', $input['name']);
         $input['name'] = Toolbox::stripslashes_deep($input['name']);
         $input["name"] = Toolbox::substr($input['name'], 0, 70);
         $input['name'] = Toolbox::addslashes_deep($input['name']);
     }
     // Set default dropdown
     $dropdown_fields = array('entities_id', 'itilcategories_id');
     foreach ($dropdown_fields as $field) {
         if (!isset($input[$field])) {
             $input[$field] = 0;
         }
     }
     $input = $this->computeDefaultValuesForAdd($input);
     return $input;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:60,代码来源:commonitilobject.class.php

示例14: buildTicket


//.........这里部分代码省略.........
             $begin_strip = -1;
             $end_strip = -1;
             $begin_match = "/" . NotificationTargetTicket::HEADERTAG . ".*" . NotificationTargetTicket::HEADERTAG . "/";
             $end_match = "/" . NotificationTargetTicket::FOOTERTAG . ".*" . NotificationTargetTicket::FOOTERTAG . "/";
             foreach ($content as $ID => $val) {
                 // Get first tag for begin
                 if ($begin_strip < 0) {
                     if (preg_match($begin_match, $val)) {
                         $begin_strip = $ID;
                     }
                 }
                 // Get last tag for end
                 if ($begin_strip >= 0) {
                     if (preg_match($end_match, $val)) {
                         $end_strip = $ID;
                         continue;
                     }
                 }
             }
             if ($begin_strip >= 0) {
                 // Clean first and last lines
                 $content[$begin_strip] = preg_replace($begin_match, '', $content[$begin_strip]);
             }
             if ($end_strip >= 0) {
                 // Clean first and last lines
                 $content[$end_strip] = preg_replace($end_match, '', $content[$end_strip]);
             }
             if ($begin_strip >= 0) {
                 $length = count($content);
                 // Use end strip if set
                 if ($end_strip >= 0 && $end_strip < $length) {
                     $length = $end_strip;
                 }
                 for ($i = $begin_strip + 1; $i < $length; $i++) {
                     unset($content[$i]);
                 }
             }
             $to_keep = array();
             // Aditional clean for thunderbird
             foreach ($content as $ID => $val) {
                 if (!isset($val[0]) || $val[0] != '>') {
                     $to_keep[$ID] = $ID;
                 }
             }
             $tkt['content'] = "";
             foreach ($to_keep as $ID) {
                 $tkt['content'] .= $content[$ID] . "\n";
             }
             // Do not play rules for followups : WRONG : play rules only for refuse options
             //$play_rules = false;
         } else {
             // => to handle link in Ticket->post_addItem()
             $tkt['_linkedto'] = $tkt['tickets_id'];
             unset($tkt['tickets_id']);
         }
     }
     // Add message from getAttached
     if ($this->addtobody) {
         $tkt['content'] .= $this->addtobody;
     }
     $tkt['name'] = $this->textCleaner($head['subject']);
     if (!isset($tkt['tickets_id'])) {
         // Which entity ?
         //$tkt['entities_id']=$this->fields['entities_id'];
         //$tkt['Subject']= $head['subject'];   // not use for the moment
         // Medium
         $tkt['urgency'] = "3";
         // No hardware associated
         $tkt['itemtype'] = "";
         // Mail request type
     } else {
         // Reopen if needed
         $tkt['add_reopen'] = 1;
     }
     $tkt['requesttypes_id'] = RequestType::getDefault('mail');
     if ($play_rules) {
         $rule_options['ticket'] = $tkt;
         $rule_options['headers'] = $head;
         $rule_options['mailcollector'] = $options['mailgates_id'];
         $rule_options['_users_id_requester'] = $tkt['_users_id_requester'];
         $rulecollection = new RuleMailCollectorCollection();
         $output = $rulecollection->processAllRules(array(), array(), $rule_options);
         // New ticket : compute all
         if (!isset($tkt['tickets_id'])) {
             foreach ($output as $key => $value) {
                 $tkt[$key] = $value;
             }
         } else {
             // Followup only copy refuse data
             $tobecopied = array('_refuse_email_no_response', '_refuse_email_with_response');
             foreach ($tobecopied as $val) {
                 if (isset($output[$val])) {
                     $tkt[$val] = $output[$val];
                 }
             }
         }
     }
     $tkt = Toolbox::addslashes_deep($tkt);
     return $tkt;
 }
开发者ID:remicollet,项目名称:glpi,代码行数:101,代码来源:mailcollector.class.php

示例15: constructSQL

 /**
  * Construct SQL request depending of search parameters
  *
  * add to data array a field sql containing an array of requests :
  *      search : request to get items limited to wanted ones
  *      count : to count all items based on search criterias
  *                    may be an array a request : need to add counts
  *                    maybe empty : use search one to count
  *
  * @since version 0.85
  *
  * @param $data    array of search datas prepared to generate SQL
  *
  * @return nothing
  **/
 static function constructSQL(array &$data)
 {
     global $CFG_GLPI;
     if (!isset($data['itemtype'])) {
         return false;
     }
     $data['sql']['count'] = array();
     $data['sql']['search'] = '';
     $searchopt =& self::getOptions($data['itemtype']);
     $blacklist_tables = array();
     if (isset($CFG_GLPI['union_search_type'][$data['itemtype']])) {
         $itemtable = $CFG_GLPI['union_search_type'][$data['itemtype']];
         $blacklist_tables[] = getTableForItemType($data['itemtype']);
     } else {
         $itemtable = getTableForItemType($data['itemtype']);
     }
     // hack for AllAssets
     if (isset($CFG_GLPI['union_search_type'][$data['itemtype']])) {
         $entity_restrict = true;
     } else {
         $entity_restrict = $data['item']->isEntityAssign();
     }
     // Construct the request
     //// 1 - SELECT
     // request currentuser for SQL supervision, not displayed
     $SELECT = "SELECT '" . Toolbox::addslashes_deep($_SESSION['glpiname']) . "' AS currentuser,\n                        " . self::addDefaultSelect($data['itemtype']);
     // Add select for all toview item
     foreach ($data['toview'] as $key => $val) {
         $SELECT .= self::addSelect($data['itemtype'], $val, $key, 0);
     }
     //// 2 - FROM AND LEFT JOIN
     // Set reference table
     $FROM = " FROM `{$itemtable}`";
     // Init already linked tables array in order not to link a table several times
     $already_link_tables = array();
     // Put reference table
     array_push($already_link_tables, $itemtable);
     // Add default join
     $COMMONLEFTJOIN = self::addDefaultJoin($data['itemtype'], $itemtable, $already_link_tables);
     $FROM .= $COMMONLEFTJOIN;
     // Add all table for toview items
     foreach ($data['tocompute'] as $key => $val) {
         if (!in_array($searchopt[$val]["table"], $blacklist_tables)) {
             $FROM .= self::addLeftJoin($data['itemtype'], $itemtable, $already_link_tables, $searchopt[$val]["table"], $searchopt[$val]["linkfield"], 0, 0, $searchopt[$val]["joinparams"], $searchopt[$val]["field"]);
         }
     }
     // Search all case :
     if ($data['search']['all_search']) {
         foreach ($searchopt as $key => $val) {
             // Do not search on Group Name
             if (is_array($val)) {
                 if (!in_array($searchopt[$key]["table"], $blacklist_tables)) {
                     $FROM .= self::addLeftJoin($data['itemtype'], $itemtable, $already_link_tables, $searchopt[$key]["table"], $searchopt[$key]["linkfield"], 0, 0, $searchopt[$key]["joinparams"], $searchopt[$key]["field"]);
                 }
             }
         }
     }
     //// 3 - WHERE
     // default string
     $COMMONWHERE = self::addDefaultWhere($data['itemtype']);
     $first = empty($COMMONWHERE);
     // Add deleted if item have it
     if ($data['item'] && $data['item']->maybeDeleted()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_deleted` = '" . $data['search']['is_deleted'] . "' ";
     }
     // Remove template items
     if ($data['item'] && $data['item']->maybeTemplate()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_template` = '0' ";
     }
     // Add Restrict to current entities
     if ($entity_restrict) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
//.........这里部分代码省略.........
开发者ID:jose-martins,项目名称:glpi,代码行数:101,代码来源:search.class.php


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