本文整理汇总了PHP中Toolbox类的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox类的具体用法?PHP Toolbox怎么用?PHP Toolbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Toolbox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: displayTabContentForItem
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' ";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class ='tab_cadre_fixe'>";
echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>';
echo '<td>' . __('Access', 'formcreator') . '</td>';
echo '<td>';
Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1));
echo '</td>';
if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) {
echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>';
$table = getTableForItemType(__CLASS__);
$table_profile = getTableForItemType('Profile');
$query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n FROM {$table_profile} p\n LEFT JOIN {$table} f\n ON p.`id` = f.`plugin_formcreator_profiles_id`\n AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id'];
$result = $GLOBALS['DB']->query($query);
while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) {
$checked = $profile ? ' checked' : '';
echo '<tr><td colspan="2"><label>';
echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> ';
echo $name;
echo '</label></td></tr>';
}
}
echo '<tr>';
echo '<td class="center" colspan="2">';
echo '<input type="hidden" name="profiles_id[]" value="0" />';
echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />';
echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />';
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
开发者ID:ChristopheG77,项目名称:formcreator,代码行数:34,代码来源:formprofiles.class.php
示例2: showForm
/**
* Show form
*
* @global type $CFG_GLPI
* @param type $ID
* @param type $options
*/
function showForm($ID = 0, $options = array())
{
global $CFG_GLPI;
echo "<div class='center first-bloc'>";
echo "<form name='field_form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th>" . self::getTypeName() . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='tab_bg_2 center'>";
echo PluginShellcommandsCommandGroup::getTypeName(1) . " ";
Dropdown::show('PluginShellcommandsCommandGroup', array('entity' => $_SESSION['glpiactive_entity'], 'width' => 200));
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='tab_bg_2 center'>";
$this->getEditValue();
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class='tab_bg_2 center'>";
echo "<input type='button' class='submit' onclick='shellcommand_advanced_execution(\"" . $CFG_GLPI['root_doc'] . "\",\"field_form\", \"advanced_execution_result\");' name='advanced_execution' value='" . __('Execute') . "'/>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
echo "<div class='spaced' id='advanced_execution_result'></div>";
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:37,代码来源:advanced_execution.class.php
示例3: showForDocumentCategory
static function showForDocumentCategory($item)
{
$documentCategory = new self();
if (!$documentCategory->getFromDBByQuery(" WHERE `documentcategories_id` = " . $item->fields['id'])) {
$documentCategory->getEmpty();
}
echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL($documentCategory->getType()) . "'>";
echo "<div align='center'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Document category prefix', 'order') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
// Dropdown group
echo "<td>";
echo __('Document category prefix', 'order');
echo "</td>";
echo "<td>";
echo "<input type='text' name='documentcategories_prefix' value='" . $documentCategory->fields['documentcategories_prefix'] . "'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class='tab_bg_2 center' colspan='6'>";
echo "<input type='submit' name='update' class='submit' value='" . _sx('button', 'Save') . "' >";
echo "<input type='hidden' name='documentcategories_id' class='submit' value='" . $item->fields['id'] . "' >";
echo "</td>";
echo "</tr>";
echo "</table></div>";
Html::closeForm();
}
开发者ID:equinoxefr,项目名称:order,代码行数:27,代码来源:documentcategory.class.php
示例4: showForm
public function showForm($ID, $options = array())
{
if (!$this->isNewID($ID)) {
$this->check($ID, READ);
} else {
$this->check(-1, UPDATE);
}
$options['colspan'] = 2;
$options['target'] = Toolbox::getItemTypeFormURL(__CLASS__);
$this->showFormHeader($options);
echo '<table class="tab_cadre_fixe">';
echo "<tr class='line0'><td>" . __('Name') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "name");
echo "</td>";
echo "</tr>";
echo "<tr class='line1'><td>" . __('Content') . "</td>";
echo "<td>";
echo "<textarea name='comment' id ='comment' >" . $this->fields['comment'] . "</textarea>";
Html::initEditorSystem('comment');
echo "</td>";
echo "</tr>";
$this->showFormButtons($options);
return true;
}
开发者ID:jcr0ch4,项目名称:formcreator,代码行数:25,代码来源:header.class.php
示例5: __construct
/**
* Constructor
*
**/
function __construct()
{
global $CFG_GLPI;
$this->WordWrap = 80;
$this->CharSet = "utf-8";
// Comes from config
$this->SetLanguage("en", Config::getLibraryDir("PHPMailer") . "/language/");
if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
$this->Mailer = "smtp";
$this->Host = $CFG_GLPI['smtp_host'] . ':' . $CFG_GLPI['smtp_port'];
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
$this->SMTPSecure = "ssl";
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
$this->SMTPSecure = "tls";
}
if (!$CFG_GLPI['smtp_check_certificate']) {
$this->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
}
}
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$this->do_debug = 3;
}
}
开发者ID:stweil,项目名称:glpi,代码行数:33,代码来源:glpimailer.class.php
示例6: parseLine
/**
* CSV File parsing methods
*
* @param $fic
* @param $data
* @param $encoding (default 1)
**/
static function parseLine($fic, $data, $encoding = 1)
{
global $DB;
$csv = array();
$num = count($data);
for ($c = 0; $c < $num; $c++) {
//If field is not the last, or if field is the last of the line and is not empty
if ($c < $num - 1 || $c == $num - 1 && $data[$num - 1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) {
$tmp = trim($DB->escape($data[$c]));
switch ($encoding) {
//If file is ISO8859-1 : encode the datas in utf8
case PluginDatainjectionBackend::ENCODING_ISO8859_1:
if (!Toolbox::seems_utf8($tmp)) {
$csv[0][] = utf8_encode($tmp);
} else {
$csv[0][] = $tmp;
}
break;
case PluginDatainjectionBackend::ENCODING_UFT8:
$csv[0][] = $tmp;
break;
default:
//PluginDatainjectionBackend :: ENCODING_AUTO :
$csv[0][] = PluginDatainjectionBackend::toUTF8($tmp);
}
}
}
return $csv;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:36,代码来源:backendcsv.class.php
示例7: logIfExtradebug
/**
* Log when extra-debug is activated
*/
static function logIfExtradebug($file, $message)
{
if (!PluginFusioninventoryConfig::isExtradebugActive()) {
return;
}
Toolbox::logInFile($file, $message);
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:10,代码来源:logger.class.php
示例8: showForGroup
static function showForGroup(Group $group)
{
global $DB;
$ID = $group->getField('id');
if (!$group->can($ID, READ)) {
return false;
}
$canedit = $group->can($ID, UPDATE);
if ($canedit) {
// Get data
$item = new self();
if (!$item->getFromDB($ID)) {
$item->getEmpty();
}
$rand = mt_rand();
echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
echo "</td></tr>";
echo "</td><td class='center'>";
if ($item->fields["id"]) {
echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n class='submit'>";
} else {
echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
}
echo "</td></tr>";
echo "</table></div>";
Html::closeForm();
}
}
开发者ID:erchbox,项目名称:itilcategorygroups,代码行数:35,代码来源:group_level.class.php
示例9: sendProlog
function sendProlog($input)
{
$input = gzcompress($input);
$fp = fsockopen($this->server_ip, 80, $errno, $errstr, 30);
if (!$fp) {
echo "{$errstr} ({$errno})\n";
} else {
$out = "POST " . $this->server_urlpath . " HTTP/1.1\r\n";
$out .= "Host: " . $this->server_ip . " \r\n";
$out .= "Content-Length: " . strlen($input) . "\r\n";
$out .= "Connection: close\r\n\r\n";
fputs($fp, $out . $input);
$zipped = "";
while (!feof($fp)) {
$line = fgets($fp, 4096);
$zipped .= $line;
if ($line == "\r\n") {
$zipped = "";
}
}
fclose($fp);
Toolbox::logInFile("RETSERV", $zipped . "\n");
if (!gzuncompress($zipped)) {
echo $zipped;
}
return gzuncompress($zipped);
}
}
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:28,代码来源:emulatoragent.php
示例10: testSlugify
public function testSlugify()
{
$original = 'My - string èé Ê À ß';
$expected = 'my-string-ee-e-a-sz';
$result = Toolbox::slugify($original);
$this->assertEquals($expected, $result);
}
开发者ID:glpi-project,项目名称:glpi,代码行数:7,代码来源:ToolboxTest.php
示例11: pdfMain
static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
{
global $DB;
$ID = $item->getField('id');
if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) {
return false;
}
$knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id');
$fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id));
$question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8")));
$answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8")));
$pdf->setColumnsSize(100);
if (Toolbox::strlen($fullcategoryname) > 0) {
$pdf->displayTitle('<b>' . __('Category name') . '</b>');
$pdf->displayLine($fullcategoryname);
}
if (Toolbox::strlen($question) > 0) {
$pdf->displayTitle('<b>' . __('Subject') . '</b>');
$pdf->displayText('', $question, 5);
} else {
$pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>');
}
if (Toolbox::strlen($answer) > 0) {
$pdf->displayTitle('<b>' . __('Content') . '</b>');
$pdf->displayText('', $answer, 5);
} else {
$pdf->displayTitle('<b>' . __('No answer found') . '</b>');
}
$pdf->setColumnsSize(50, 15, 15, 10, 10);
$pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2));
$pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]);
$pdf->displaySpace();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:33,代码来源:knowbaseitem.class.php
示例12: prepareInputForAdd
/**
* @see CommonDBTM::prepareInputForAdd()
**/
function prepareInputForAdd($input)
{
//LDAP parameters MUST be in lower case
//because the are retieved in lower case from the directory
$input["value"] = Toolbox::strtolower($input["value"]);
return $input;
}
开发者ID:stweil,项目名称:glpi,代码行数:10,代码来源:rulerightparameter.class.php
示例13: getMenuContent
static function getMenuContent()
{
global $CFG_GLPI;
$menu = array();
$menu['title'] = self::getMenuName();
$menu['page'] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight(static::$rightname, READ)) {
$image_model = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' title='";
$image_model .= PluginDatainjectionModel::getTypeName();
$image_model .= "' alt='" . PluginDatainjectionModel::getTypeName() . "'>";
$image_import = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' title='";
$image_import .= __s('Injection of the file', 'datainjection');
$image_import .= "' alt='" . __s('Injection of the file', 'datainjection') . "'>";
$menu['options']['client']['title'] = self::getMenuName();
$menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight('plugin_datainjection_model', READ)) {
$menu['options']['model']['title'] = PluginDatainjectionModel::getTypeName();
$menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
}
//$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
$menu['options']['model']['links'][$image_import] = '/plugins/datainjection/front/clientinjection.form.php';
if (Session::haveRight('plugin_datainjection_model', UPDATE) || Session::haveRight('plugin_datainjection_model', CREATE)) {
$menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginDatainjectionModel', false);
$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
}
}
return $menu;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:31,代码来源:menu.class.php
示例14: update_password
public function update_password($password, $email)
{
$password = Toolbox::helper('Hash')->encrypt($password);
$q = "UPDATE users SET password = ? WHERE email = ?";
$r = $this->db->prepare($q);
$r->execute(array($password, $email));
}
开发者ID:arout,项目名称:halcyon,代码行数:7,代码来源:AdminModel.php
示例15: getDatasForTemplate
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI;
if ($event == 'AlertNotValidatedTypology') {
$this->datas['##typology.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
$this->datas['##lang.typology.entity##'] = __('Entity');
$this->datas['##typology.action##'] = __('Elements not match with the typology', 'typology');
$this->datas['##lang.typology.name##'] = PluginTypologyTypology::getTypeName(1);
$this->datas['##lang.typology.itemtype##'] = __('Type');
$this->datas['##lang.typology.items_id##'] = __('Name');
$this->datas['##lang.typology.error##'] = __('Error');
$this->datas['##lang.typology.url##'] = __('Link to the typology', 'typology');
$this->datas['##lang.typology.itemurl##'] = __('Link to the element', 'typology');
$this->datas['##lang.typology.itemuser##'] = __('User');
$this->datas['##lang.typology.itemlocation##'] = __('Location');
foreach ($options['items'] as $id => $item) {
$tmp = array();
$tmp['##typology.name##'] = $item['name'];
$itemtype = new $item['itemtype']();
$itemtype->getFromDB($item["items_id"]);
$tmp['##typology.itemtype##'] = $itemtype->getTypeName();
$tmp['##typology.items_id##'] = $itemtype->getName();
$tmp['##typology.error##'] = PluginTypologyTypology_Item::displayErrors($item['error'], false);
$tmp['##typology.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_typology_" . $item['plugin_typology_typologies_id']);
$tmp['##typology.itemurl##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . Toolbox::strtolower($item['itemtype']) . "_" . $item["items_id"]);
$tmp['##typology.itemuser##'] = getUserName($itemtype->fields["users_id"]);
$tmp['##typology.itemlocation##'] = Dropdown::getDropdownName("glpi_locations", $itemtype->fields['locations_id']);
$this->datas['typologyitems'][] = $tmp;
}
}
}
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:notificationtargettypology.class.php
示例16: __construct
/**
* Constructor
*
**/
function __construct()
{
global $CFG_GLPI;
$this->WordWrap = 80;
$this->CharSet = "utf-8";
// Comes from config
$this->SetLanguage("en", GLPI_PHPMAILER_DIR . "/language/");
if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
$this->Mailer = "smtp";
$this->Host = $CFG_GLPI['smtp_host'] . ':' . $CFG_GLPI['smtp_port'];
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
$this->SMTPSecure = "ssl";
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
$this->SMTPSecure = "tls";
}
}
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$this->do_debug = 3;
}
}
开发者ID:kipman,项目名称:glpi,代码行数:30,代码来源:glpimailer.class.php
示例17: showForm
public function showForm($ID, $options = array())
{
if (!$this->isNewID($ID)) {
$this->check($ID, READ);
} else {
$this->check(-1, UPDATE);
}
$options['colspan'] = 2;
$options['target'] = Toolbox::getItemTypeFormURL(__CLASS__);
$this->showFormHeader($options);
echo '<table class="tab_cadre_fixe">';
echo "<tr class='line0'><td>" . __('Name') . " <span class='red'>*</span></td>";
echo "<td>";
//Html::autocompletionTextField($this, "name");
echo '<input type="text" name="name" value="' . $this->fields['name'] . '" size="40" required>';
echo "</td>";
echo "</tr>";
echo "<tr class='line1'><td>" . __('Description') . "</td>";
echo "<td>";
echo "<textarea name='comment' id ='comment' cols='45' rows='2'>" . $this->fields['comment'] . "</textarea>";
//Html::initEditorSystem('comment');
echo "</td>";
echo "</tr>";
echo "<tr class='line1'><td>" . __('HTML color', 'tag') . "</td>";
echo "<td>";
Html::showColorField('color', array('value' => $this->fields['color']));
echo "</td>";
echo "</tr>";
$this->showFormButtons($options);
return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:tag.class.php
示例18: getTabNameForItem
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
return;
if ($item->getType() == 'PluginCustomTab' && $item->canView()) {
return Toolbox::ucfirst(_n("Profile", "Profiles", 1));
}
return '';
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:8,代码来源:tabprofile.class.php
示例19: 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 ()[email protected]', '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
示例20: 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
注:本文中的Toolbox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论