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


PHP getItemTypeForTable函数代码示例

本文整理汇总了PHP中getItemTypeForTable函数的典型用法代码示例。如果您正苦于以下问题:PHP getItemTypeForTable函数的具体用法?PHP getItemTypeForTable怎么用?PHP getItemTypeForTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: executeActions

 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "assign":
                     $output[$action->fields["field"]] = $action->fields["value"];
                     break;
                 case "regex_result":
                     //Regex result : assign value from the regex
                     $res = "";
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     if ($res != '' && ($action->fields["field"] != 'user' && $action->fields["field"] != 'otherserial' && $action->fields["field"] != 'software' && $action->fields["field"] != 'softwareversion')) {
                         $res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res);
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
                 default:
                     //plugins actions
                     $executeaction = clone $this;
                     $ouput = $executeaction->executePluginsActions($action, $output, $params);
                     break;
             }
         }
     }
     return $output;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:collectrule.class.php

示例2: plugin_racks_install

function plugin_racks_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
    $migration = new Migration("1.5.0");
    $update = false;
    if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.2.sql");
    } elseif (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql");
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
    } elseif (!TableExists("glpi_plugin_racks_profiles")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
    }
    //from 1.1 version
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql");
    }
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql");
    }
    if (!TableExists("glpi_plugin_racks_racktypes")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql");
    }
    if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql");
    }
    if (TableExists("glpi_plugin_racks_profiles") && !FieldExists("glpi_plugin_racks_profiles", "open_ticket")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.2.sql");
    }
    if ($update) {
        foreach ($DB->request('glpi_plugin_racks_profiles') as $data) {
            $query = "UPDATE `glpi_plugin_racks_profiles`\n                    SET `profiles_id` = '" . $data["id"] . "'\n                    WHERE `id` = '" . $data["id"] . "';";
            $result = $DB->query($query);
        }
        $migration->dropField('glpi_plugin_racks_profiles', 'name');
        Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications"));
    }
    $notepad_tables = array('glpi_plugin_racks_racks');
    foreach ($notepad_tables as $t) {
        // Migrate data
        if (FieldExists($t, 'notepad')) {
            $query = "SELECT id, notepad\n                      FROM `{$t}`\n                      WHERE notepad IS NOT NULL\n                            AND notepad <>'';";
            foreach ($DB->request($query) as $data) {
                $iq = "INSERT INTO `glpi_notepads`\n                             (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\n                      VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\n                              '" . addslashes($data['notepad']) . "', NOW(), NOW())";
                $DB->queryOrDie($iq, "0.85 migrate notepad data");
            }
            $query = "ALTER TABLE `glpi_plugin_racks_racks` DROP COLUMN `notepad`;";
            $DB->query($query);
        }
    }
    //Migrate profiles to the system introduced in 0.85
    PluginRacksProfile::initProfile();
    PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    //Drop old profile table : not used anymore
    $migration->dropTable('glpi_plugin_racks_profiles');
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:60,代码来源:hook.php

示例3: showForm

 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     $obj = $options['obj'];
     //Html::printCleanArray($obj);
     $itemtype = getItemTypeForTable($obj->getTable());
     $list_ip = array();
     $total_ip = 0;
     if ($itemtype == 'NetworkEquipment') {
         $query = "SELECT `ip`\n                   FROM `glpi_networkequipments`\n                   WHERE `id` = '" . $obj->fields['id'] . "'";
         $res = $DB->query($query);
         while ($row = $DB->fetch_array($res)) {
             if ($row['ip'] != '') {
                 $list_ip[$row['ip']] = $row['ip'];
             }
         }
     }
     $tmp = array_values($list_ip);
     if (count($tmp) > 0 && $tmp[0] == '') {
         array_pop($list_ip);
     }
     $query = "SELECT `glpi_networknames`.`name`, `glpi_ipaddresses`.`name` as ip, `glpi_networkports`.`items_id`\n               FROM `glpi_networkports` \n               LEFT JOIN `" . $obj->getTable() . "` ON (`glpi_networkports`.`items_id` = `" . $obj->getTable() . "`.`id`\n                              AND `glpi_networkports`.`itemtype` = '" . $itemtype . "')\n               LEFT JOIN `glpi_networknames` ON (`glpi_networkports`.`id` =  `glpi_networknames`.`items_id`)\n               LEFT JOIN `glpi_ipaddresses` ON (`glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`)\n                WHERE `" . $obj->getTable() . "`.`id` = '" . $obj->fields['id'] . "'";
     $res = $DB->query($query);
     while ($row = $DB->fetch_array($res)) {
         if ($row['ip'] != '') {
             $port = $row['ip'];
             if ($row['name'] != '') {
                 $port = $row['name'] . " ({$port})";
             }
             $list_ip[$row['ip']] = $port;
         }
     }
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 left'>";
     echo "<tr><th colspan='4'>" . __('IP ping', 'addressing') . "</th></tr>";
     if (count($list_ip) > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('IP') . " : </td>";
         echo "<td colspan='3'>";
         echo "<select id='ip'>";
         echo "<option>" . Dropdown::EMPTY_VALUE . "</option>";
         foreach ($list_ip as $ip => $name) {
             echo "<option value='{$ip}'>{$name}</option>";
         }
         echo "</select>";
         echo "&nbsp;<input class='submit' type='button' value='" . __s('Ping', 'addressing') . "' onclick='pingIp();'>";
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Result', 'addressing') . " : </td>";
         echo "<td colspan='3'>";
         echo "<div id='ping_response' class='plugin_addressing_ping_equipment'></div>";
         echo "</td></tr>";
     }
     echo "</table>";
     echo "\n         <script type='text/javascript'>\n            function pingIp() {\n               var ip = Ext.get('ip').dom.options[Ext.get('ip').dom.selectedIndex].value;\n               var ping_response = Ext.get('ping_response');\n\n               Ext.Ajax.request({\n                  url : '" . $CFG_GLPI["root_doc"] . "/plugins/addressing/ajax/ping.php' ,\n                  params : { ip : ip },\n                  method: 'POST',\n                  success: function ( result, request ) {\n                     ping_response.insertHtml('afterBegin', '<hr>'+result.responseText);\n                  }\n               });\n            }\n         </script>\n      ";
     if (count($list_ip) == 0) {
         echo __('No IP for this equipment', 'addressing');
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:59,代码来源:ping_equipment.class.php

示例4: plugin_genericobject_getDropdown

function plugin_genericobject_getDropdown()
{
    $dropdowns = array();
    $plugin = new Plugin();
    if ($plugin->isActivated("genericobject")) {
        foreach (getAllDatasFromTable(getTableForItemType('PluginGenericobjectType'), "`is_active`='1'") as $itemtype) {
            foreach (PluginGenericobjectType::getDropdownForItemtype($itemtype['itemtype']) as $table) {
                $dropdown_itemtype = getItemTypeForTable($table);
                $dropdowns[$dropdown_itemtype] = $dropdown_itemtype::getTypeName();
            }
        }
    }
    return $dropdowns;
}
开发者ID:rambeau,项目名称:genericobject,代码行数:14,代码来源:hook.php

示例5: plugin_genericobject_getDropdown

function plugin_genericobject_getDropdown()
{
    $dropdowns = array();
    $plugin = new Plugin();
    if ($plugin->isActivated("genericobject")) {
        foreach (PluginGenericobjectType::getTypes(true) as $idx => $type) {
            _log($idx, var_export($type, true));
            $itemtype = $type['itemtype'];
            foreach (PluginGenericobjectType::getDropdownForItemtype($itemtype) as $table) {
                $dropdown_itemtype = getItemTypeForTable($table);
                if (class_exists($dropdown_itemtype)) {
                    $dropdowns[$dropdown_itemtype] = $dropdown_itemtype::getTypeName();
                }
            }
        }
    }
    return $dropdowns;
}
开发者ID:drTr0jan,项目名称:genericobject,代码行数:18,代码来源:hook.php

示例6: switch

    // Security
    if (!TableExists($_POST['table'])) {
        exit;
    }
    switch ($_POST["table"]) {
        case "glpi_users":
            if ($_POST['value'] == 0) {
                $tmpname['link'] = $CFG_GLPI['root_doc'] . "/front/user.php";
                $tmpname['comment'] = "";
            } else {
                $tmpname = getUserName($_POST["value"], 2);
            }
            echo $tmpname["comment"];
            if (isset($_POST['withlink'])) {
                echo "<script type='text/javascript' >\n";
                echo Html::jsGetElementbyID($_POST['withlink']) . ".attr('href', '" . $tmpname['link'] . "');";
                echo "</script>\n";
            }
            break;
        default:
            if ($_POST["value"] > 0) {
                $tmpname = Dropdown::getDropdownName($_POST["table"], $_POST["value"], 1);
                echo $tmpname["comment"];
                if (isset($_POST['withlink'])) {
                    echo "<script type='text/javascript' >\n";
                    echo Html::jsGetElementbyID($_POST['withlink']) . ".\n                    attr('href', '" . Toolbox::getItemTypeFormURL(getItemTypeForTable($_POST["table"])) . "?id=" . $_POST["value"] . "');";
                    echo "</script>\n";
                }
            }
    }
}
开发者ID:jose-martins,项目名称:glpi,代码行数:31,代码来源:comments.php

示例7: _sx

$submitname = _sx('button', 'Post');
if (isset($_POST['submitname']) && $_POST['submitname']) {
    $submitname = stripslashes($_POST['submitname']);
}
if (isset($_POST["itemtype"]) && isset($_POST["id_field"]) && $_POST["id_field"]) {
    $search = Search::getOptions($_POST["itemtype"]);
    if (!isset($search[$_POST["id_field"]])) {
        exit;
    }
    $search = $search[$_POST["id_field"]];
    $FIELDNAME_PRINTED = false;
    $USE_TABLE = false;
    echo "<table class='tab_glpi' width='100%'><tr><td>";
    $plugdisplay = false;
    // Specific plugin Type case
    if (($plug = isPluginItemType($_POST["itemtype"])) || ($plug = isPluginItemType(getItemTypeForTable($search['table'])))) {
        $plugdisplay = Plugin::doOneHook($plug['plugin'], 'MassiveActionsFieldsDisplay', array('itemtype' => $_POST["itemtype"], 'options' => $search));
    }
    $fieldname = '';
    if (empty($search["linkfield"]) || $search['table'] == 'glpi_infocoms') {
        $fieldname = $search["field"];
    } else {
        $fieldname = $search["linkfield"];
    }
    if (!$plugdisplay) {
        $options = array();
        $values = array();
        // For ticket template or aditional options of massive actions
        if (isset($_POST['options'])) {
            $options = $_POST['options'];
        }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:dropdownMassiveActionField.php

示例8: plugin_badges_install


//.........这里部分代码省略.........
            plugin_badges_configure15();
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
        } else {
            if (TableExists("glpi_plugin_badges_profiles") && FieldExists("glpi_plugin_badges_profiles", "interface")) {
                $update78 = true;
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql");
                plugin_badges_configure15();
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
            } else {
                if (TableExists("glpi_plugin_badges") && !FieldExists("glpi_plugin_badges", "date_mod")) {
                    $update78 = true;
                    $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
                    $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
                } else {
                    if (!TableExists("glpi_plugin_badges_badgetypes")) {
                        $update78 = true;
                        $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
                    } else {
                        if (TableExists("glpi_plugin_badges_profiles")) {
                            $update85 = true;
                        }
                    }
                }
            }
        }
    }
    if (!TableExists("glpi_plugin_badges_requests")) {
        $update201 = true;
        $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-2.0.1.sql");
    }
    if ($install || $update201) {
        // Badge request notification
        $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'";
        $result = $DB->query($query_id) or die($DB->error());
        $itemtype = $DB->result($result, 0, 'id');
        if (empty($itemtype)) {
            $query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Request','PluginBadgesBadge', NOW(),'','');";
            $result = $DB->query($query_id) or die($DB->error());
            $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'";
            $result = $DB->query($query_id) or die($DB->error());
            $itemtype = $DB->result($result, 0, 'id');
        }
        $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n                                 VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n                        '##lang.badge.entity## :##badge.entity##\r\n                        ##FOREACHbadgerequest## \r\n                        ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n                        ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n                        ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n                        ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n                        ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n                        ##ENDFOREACHbadgerequest##',\r\n                        '&lt;p&gt;##lang.badge.entity## :##badge.entity##&lt;br /&gt; &lt;br /&gt;\r\n                        ##FOREACHbadgerequest##&lt;br /&gt;\r\n                        ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##&lt;br /&gt;\t\r\n                        ##lang.badgerequest.requester## : ##badgerequest.requester##&lt;br /&gt;\r\n                        ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##&lt;br /&gt;\r\n                        ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##&lt;br /&gt;\r\n                        ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##&lt;br /&gt;\r\n                        ##ENDFOREACHbadgerequest##&lt;/p&gt;');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\r\n                                   VALUES (NULL, 'Access badge request', 0, 'PluginBadgesBadge', 'AccessBadgeRequest',\r\n                                          'mail','" . $itemtype . "',\r\n                                          '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
        $result = $DB->query($query);
    }
    // Badge expiration alert notification
    $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'";
    $result = $DB->query($query_id) or die($DB->error());
    $itemtype = $DB->result($result, 0, 'id');
    if (empty($itemtype)) {
        $query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Return','PluginBadgesBadge', NOW(),'','');";
        $result = $DB->query($query_id) or die($DB->error());
        $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'";
        $result = $DB->query($query_id) or die($DB->error());
        $itemtype = $DB->result($result, 0, 'id');
    }
    $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n                              VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n                     '##lang.badge.entity## :##badge.entity##\r\n                     ##FOREACHbadgerequest## \r\n                     ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n                     ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n                     ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n                     ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n                     ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n                     ##ENDFOREACHbadgerequest##',\r\n                     '&lt;p&gt;##lang.badge.entity## :##badge.entity##&lt;br /&gt; &lt;br /&gt;\r\n                     ##FOREACHbadgerequest##&lt;br /&gt;\r\n                     ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##&lt;br /&gt;\t\r\n                     ##lang.badgerequest.requester## : ##badgerequest.requester##&lt;br /&gt;\r\n                     ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##&lt;br /&gt;\r\n                     ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##&lt;br /&gt;\r\n                     ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##&lt;br /&gt;\r\n                     ##ENDFOREACHbadgerequest##&lt;/p&gt;');";
    $result = $DB->query($query);
    $query = "INSERT INTO `glpi_notifications`\r\n                                VALUES (NULL, 'Access badge return', 0, 'PluginBadgesBadge', 'BadgesReturn',\r\n                                       'mail','" . $itemtype . "',\r\n                                       '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
    $result = $DB->query($query);
    if ($update78) {
        $query_ = "SELECT *\r\n            FROM `glpi_plugin_badges_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_badges_profiles`\r\n                  SET `profiles_id` = '" . $data["id"] . "'\r\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_badges_profiles`\r\n               DROP `name` ;";
        $result = $DB->query($query);
        Plugin::migrateItemType(array(1600 => 'PluginBadgesBadge'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"));
    }
    if ($update85) {
        $notepad_tables = array('glpi_plugin_badges_badges');
        foreach ($notepad_tables as $t) {
            // Migrate data
            if (FieldExists($t, 'notepad')) {
                $query = "SELECT id, notepad\r\n                      FROM `{$t}`\r\n                      WHERE notepad IS NOT NULL\r\n                            AND notepad <>'';";
                foreach ($DB->request($query) as $data) {
                    $iq = "INSERT INTO `glpi_notepads`\r\n                             (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\r\n                      VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\r\n                              '" . addslashes($data['notepad']) . "', NOW(), NOW())";
                    $DB->queryOrDie($iq, "0.85 migrate notepad data");
                }
                $query = "ALTER TABLE `glpi_plugin_badges_badges` DROP COLUMN `notepad`;";
                $DB->query($query);
            }
        }
    }
    CronTask::Register('PluginBadgesBadge', 'BadgesAlert', DAY_TIMESTAMP);
    CronTask::Register('PluginBadgesReturn', 'BadgesReturnAlert', DAY_TIMESTAMP);
    PluginBadgesProfile::initProfile();
    PluginBadgesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("2.0.0");
    $migration->dropTable('glpi_plugin_badges_profiles');
    return true;
}
开发者ID:AssAB,项目名称:badges,代码行数:101,代码来源:hook.php

示例9: replayRulesOnExistingDBForModel

 /**
  * Replay collection rules on an existing DB for model dropdowns
  *
  * @param $offset    offset used to begin (default 0)
  * @param $maxtime   maximum time of process (reload at the end) (default 0)
  *
  * @return -1 on completion else current offset
  **/
 function replayRulesOnExistingDBForModel($offset = 0, $maxtime = 0)
 {
     global $DB;
     if (isCommandLine()) {
         printf(__('Replay rules on existing database started on %s') . "\n", date("r"));
     }
     // Model check : need to check using manufacturer extra data
     if (strpos($this->item_table, 'models') === false) {
         _e('Error replaying rules');
         return false;
     }
     $model_table = getPlural(str_replace('models', '', $this->item_table));
     $model_field = getForeignKeyFieldForTable($this->item_table);
     // Need to give manufacturer from item table
     $Sql = "SELECT DISTINCT `glpi_manufacturers`.`id` AS idmanu,\n                     `glpi_manufacturers`.`name` AS manufacturer,\n                     `" . $this->item_table . "`.`id`,\n                     `" . $this->item_table . "`.`name` AS name,\n                     `" . $this->item_table . "`.`comment`\n              FROM `" . $this->item_table . "`,\n                   `{$model_table}`\n              LEFT JOIN `glpi_manufacturers`\n                  ON (`{$model_table}`.`manufacturers_id` = `glpi_manufacturers`.`id`)\n              WHERE `{$model_table}`.`{$model_field}` = `" . $this->item_table . "`.`id`";
     if ($offset) {
         $Sql .= " LIMIT " . intval($offset) . ",999999999";
     }
     $result = $DB->query($Sql);
     $nb = $DB->numrows($result) + $offset;
     $i = $offset;
     if ($result && $nb > $offset) {
         // Step to refresh progressbar
         $step = $nb > 20 ? floor($nb / 20) : 1;
         $tocheck = array();
         while ($data = $DB->fetch_assoc($result)) {
             if (!($i % $step)) {
                 if (isCommandLine()) {
                     printf(__('Replay rules on existing database: %1$s/%2$s') . "\r", $i, $nb);
                 } else {
                     Html::changeProgressBarPosition($i, $nb, "{$i} / {$nb}");
                 }
             }
             // Model case
             if (isset($data["manufacturer"])) {
                 $data["manufacturer"] = Manufacturer::processName(addslashes($data["manufacturer"]));
             }
             //Replay Type dictionnary
             $ID = Dropdown::importExternal(getItemTypeForTable($this->item_table), addslashes($data["name"]), -1, $data, addslashes($data["comment"]));
             if ($data['id'] != $ID) {
                 $tocheck[$data["id"]][] = $ID;
                 $sql = "UPDATE `{$model_table}`\n                                          SET `{$model_field}` = '{$ID}'\n                                          WHERE `{$model_field}` = '" . $data['id'] . "'";
                 if (empty($data['idmanu'])) {
                     $sql .= " AND (`manufacturers_id` IS NULL\n                                 OR `manufacturers_id` = '0')";
                 } else {
                     $sql .= " AND `manufacturers_id` = '" . $data['idmanu'] . "'";
                 }
                 $DB->query($sql);
             }
             $i++;
             if ($maxtime) {
                 $crt = explode(" ", microtime());
                 if ($crt[0] + $crt[1] > $maxtime) {
                     break;
                 }
             }
         }
         foreach ($tocheck as $ID => $tab) {
             $sql = "SELECT COUNT(*)\n                                 FROM `{$model_table}`\n                                 WHERE `{$model_field}` = '{$ID}'";
             $result = $DB->query($sql);
             $deletecartmodel = false;
             // No item left : delete old item
             if ($result && $DB->result($result, 0, 0) == 0) {
                 $Sql = "DELETE\n                                    FROM `" . $this->item_table . "`\n                                    WHERE `id` = '{$ID}'";
                 $resdel = $DB->query($Sql);
                 $deletecartmodel = true;
             }
             // Manage cartridge assoc Update items
             if ($this->getRuleClassName() == 'RuleDictionnaryPrinterModel') {
                 $sql = "SELECT *\n                       FROM `glpi_cartridgeitems_printermodels`\n                       WHERE `printermodels_id` = '{$ID}'";
                 if ($result = $DB->query($sql)) {
                     if ($DB->numrows($result)) {
                         // Get compatible cartridge type
                         $carttype = array();
                         while ($data = $DB->fetch_assoc($result)) {
                             $carttype[] = $data['cartridgeitems_id'];
                         }
                         // Delete cartrodges_assoc
                         if ($deletecartmodel) {
                             $sql = "DELETE\n                                FROM `glpi_cartridgeitems_printermodels`\n                                WHERE `printermodels_id` = 'id'";
                             $DB->query($sql);
                         }
                         // Add new assoc
                         $ct = new CartridgeItem();
                         foreach ($carttype as $cartID) {
                             foreach ($tab as $model) {
                                 $ct->addCompatibleType($cartID, $model);
                             }
                         }
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:ruledictionnarydropdowncollection.class.php

示例10: transfer

 function transfer($new_entity)
 {
     global $DB;
     if ($this->fields['id'] > 0 && $this->fields['entities_id'] != $new_entity) {
         //Update entity for this object
         $tmp['id'] = $this->fields['id'];
         $tmp['entities_id'] = $new_entity;
         $this->update($tmp);
         $toupdate = array('id' => $this->fields['id']);
         foreach (PluginGenericobjectSingletonObjectField::getInstance(get_called_class()) as $field => $data) {
             $table = getTableNameForForeignKeyField($field);
             //It is a dropdown table !
             if ($field != 'entities_id' && $table != '' && isset($this->fields[$field]) && $this->fields[$field] > 0) {
                 //Instanciate a new dropdown object
                 $dropdown_itemtype = getItemTypeForTable($table);
                 $dropdown = new $dropdown_itemtype();
                 $dropdown->getFromDB($this->fields[$field]);
                 //If dropdown is only accessible in the other entity
                 //do not go further
                 if (!$dropdown->isEntityAssign() || in_array($new_entity, getAncestorsOf('glpi_entities', $dropdown->getEntityID()))) {
                     continue;
                 } else {
                     $tmp = array();
                     $where = "";
                     if ($dropdown instanceof CommonTreeDropdown) {
                         $tmp['completename'] = $dropdown->fields['completename'];
                         $where = "`completename`='" . addslashes_deep($tmp['completename']) . "'";
                     } else {
                         $tmp['name'] = $dropdown->fields['name'];
                         $where = "`name`='" . addslashes_deep($tmp['name']) . "'";
                     }
                     $tmp['entities_id'] = $new_entity;
                     $where .= " AND `entities_id`='" . $tmp['entities_id'] . "'";
                     //There's a dropdown value in the target entity
                     if ($found = $this->find($where)) {
                         $myfound = array_pop($found);
                         if ($myfound['id'] != $this->fields[$field]) {
                             $toupdate[$field] = $myfound['id'];
                         }
                     } else {
                         $clone = $dropdown->fields;
                         if ($dropdown instanceof CommonTreeDropdown) {
                             unset($clone['completename']);
                         }
                         unset($clone['id']);
                         $clone['entities_id'] = $new_entity;
                         $new_id = $dropdown->import($clone);
                         $toupdate[$field] = $new_id;
                     }
                 }
             }
         }
         $this->update($toupdate);
     }
     return true;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:56,代码来源:object.class.php

示例11: showForm

 /**
  * Print the network alias form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     // Show only simple form to add / edit
     $showsimple = false;
     if (isset($options['parent'])) {
         $showsimple = true;
         $options['networknames_id'] = $options['parent']->getID();
     }
     $this->initForm($ID, $options);
     $recursiveItems = $this->recursivelyGetItems();
     if (count($recursiveItems) == 0) {
         return false;
     }
     $lastItem = $recursiveItems[count($recursiveItems) - 1];
     if (!$showsimple) {
         $this->showTabs();
     }
     $options['entities_id'] = $lastItem->getField('entities_id');
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>";
     $this->displayRecursiveItems($recursiveItems, 'Type');
     echo "&nbsp;:</td>\n<td>";
     if (!($ID > 0)) {
         echo "<input type='hidden' name='networknames_id' value='" . $this->fields["networknames_id"] . "'>\n";
     }
     $this->displayRecursiveItems($recursiveItems, isset($options['popup']) ? "Name" : "Link");
     echo "</td><td>" . __('Name') . "</td><td>\n";
     Html::autocompletionTextField($this, "name");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . FQDN::getTypeName() . "</td><td>";
     Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField("fqdns_id")), array('value' => $this->fields["fqdns_id"], 'name' => 'fqdns_id', 'entity' => $this->getEntityID(), 'displaywith' => array('view')));
     echo "</td>";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td><textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td>\n";
     echo "</tr>\n";
     $this->showFormButtons($options);
     if (!$showsimple) {
         $this->addDivForTabs();
     }
     return true;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:53,代码来源:networkalias.class.php

示例12: showFormForNetworkPort

 /**
  * @param $networkPortID
  **/
 static function showFormForNetworkPort($networkPortID)
 {
     global $DB, $CFG_GLPI;
     $name = new self();
     $number_names = 0;
     if ($networkPortID > 0) {
         $query = "SELECT `id`\n                   FROM `" . $name->getTable() . "`\n                   WHERE `itemtype` = 'NetworkPort'\n                   AND `items_id` = '{$networkPortID}'\n                   AND `is_deleted` = '0'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 1) {
             echo "<tr class='tab_bg_1'><th colspan='4'>" . __("Several network names available! Go to the tab 'Network Name' to manage them.") . "</th></tr>\n";
             return;
         }
         switch ($DB->numrows($result)) {
             case 1:
                 $nameID = $DB->fetch_assoc($result);
                 $name->getFromDB($nameID['id']);
                 break;
             case 0:
                 $name->getEmpty();
                 break;
         }
     } else {
         $name->getEmpty();
     }
     echo "<tr class='tab_bg_1'><th colspan='4'>";
     // If the networkname is defined, we must be able to edit it. So we make a link
     if ($name->getID() > 0) {
         echo "<a href='" . $name->getLinkURL() . "'>" . self::getTypeName(1) . "</a>";
         echo "<input type='hidden' name='NetworkName_id' value='" . $name->getID() . "'>&nbsp;\n";
         Html::showSimpleForm($name->getFormURL(), 'unaffect', _sx('button', 'Dissociate'), array('id' => $name->getID()), $CFG_GLPI["root_doc"] . '/pics/sub_dropdown.png');
     } else {
         echo self::getTypeName(1);
     }
     echo "</th>\n";
     echo "</tr><tr class='tab_bg_1'>";
     echo "<td>" . self::getTypeName(1) . "</td><td>\n";
     Html::autocompletionTextField($name, "name", array('name' => 'NetworkName_name'));
     echo "</td>\n";
     echo "<td>" . FQDN::getTypeName(1) . "</td><td>";
     Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField("fqdns_id")), array('value' => $name->fields["fqdns_id"], 'name' => 'NetworkName_fqdns_id', 'entity' => $name->getEntityID(), 'displaywith' => array('view')));
     echo "</td>\n";
     echo "</tr><tr class='tab_bg_1'>\n";
     echo "<td>" . IPAddress::getTypeName(Session::getPluralNumber());
     IPAddress::showAddChildButtonForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     echo "<td>";
     IPAddress::showChildsForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     // MoYo : really need to display it here ?
     // make confure because not updatable
     //       echo "<td>".IPNetwork::getTypeName(Session::getPluralNumber())."&nbsp;";
     //       Html::showToolTip(__('IP network is not included in the database. However, you can see current available networks.'));
     //       echo "</td><td>";
     //       IPNetwork::showIPNetworkProperties($name->getEntityID());
     //       echo "</td>\n";
     echo "<td colspan='2'>&nbsp;</td>";
     echo "</tr>\n";
 }
开发者ID:kipman,项目名称:glpi,代码行数:61,代码来源:networkname.class.php

示例13: updateGLPIDevice

 /**
  * Update devices with values get by SNMP
  *
  * @param $ID_Device : ID of device
  * @param $type : type of device (NETWORKING_TYPE, PRINTER_TYPE ...)
  * @param $oidsModel : oid list from model SNMP
  * @param $oidvalues : list of values from agent query
  * @param $Array_Object_TypeNameConstant : array with oid => constant in relation with fields to update
  *
  * @return $oidList : array with ports object name and oid
  *
  **/
 static function updateGLPIDevice($ID_Device, $type, $oidsModel, $oidvalues, $Array_Object_TypeNameConstant)
 {
     global $DB, $LANG, $CFG_GLPI, $FUSIONINVENTORY_MAPPING;
     if ($_SESSION['fusioninventory_logs'] == "1") {
         $logs = new PluginFusioninventoryLogs();
     }
     if ($_SESSION['fusioninventory_logs'] == "1") {
         $logs->write("fusioninventory_fullsync", ">>>>>>>>>> Update devices values <<<<<<<<<<", $type, $ID_Device, 1);
     }
     // Update 'last_fusioninventory_update' field
     $query = "UPDATE ";
     if ($type == NETWORKING_TYPE) {
         $query .= "`glpi_plugin_fusioninventory_networking`\n             SET `last_fusioninventory_update`='" . date("Y-m-d H:i:s") . "',\n                 `last_PID_update`='" . $_SESSION['FK_process'] . "'\n             WHERE `FK_networking`='" . $ID_Device . "';";
     }
     if ($type == PRINTER_TYPE) {
         $query .= "`glpi_plugin_fusioninventory_printers`\n             SET `last_fusioninventory_update`='" . date("Y-m-d H:i:s") . "'\n             WHERE `FK_printers`='" . $ID_Device . "';";
     }
     $DB->query($query);
     foreach ($Array_Object_TypeNameConstant as $oid => $link) {
         if (!preg_match("/\\.\$/", $oid)) {
             // SNMPGet ONLY
             if (isset($oidvalues[$oid][""])) {
                 if (isset($FUSIONINVENTORY_MAPPING[$type][$link]['dropdown']) and !empty($FUSIONINVENTORY_MAPPING[$type][$link]['dropdown'])) {
                     $oidvalues[$oid][""] = PluginFusioninventorySNMP::hex_to_string($oidvalues[$oid][""]);
                     if ($FUSIONINVENTORY_MAPPING[$type][$link]['dropdown'] == "glpi_dropdown_model_networking") {
                         $oidvalues[$oid][""] = Dropdown::importExternal("NetworkEquipmentModel", $oidvalues[$oid][""], 0, array("manufacturer" => $oidvalues[$oid][""]));
                     } else {
                         $oidvalues[$oid][""] = Dropdown::importExternal(getItemTypeForTable($FUSIONINVENTORY_MAPPING[$type][$link]['dropdown']), $oidvalues[$oid][""], 0);
                     }
                 }
                 switch ($type) {
                     case NETWORKING_TYPE:
                         $Field = "FK_networking";
                         if ($FUSIONINVENTORY_MAPPING[$type][$link]['table'] == "glpi_networking") {
                             $Field = "ID";
                         }
                         break;
                     case PRINTER_TYPE:
                         $Field = "FK_printers";
                         if ($FUSIONINVENTORY_MAPPING[$type][$link]['table'] == "glpi_printers") {
                             $Field = "ID";
                         }
                         break;
                 }
                 if ($_SESSION['fusioninventory_logs'] == "1") {
                     $logs->write("fusioninventory_fullsync", $link . " = " . $oidvalues[$oid][""], $type, $ID_Device, 1);
                 }
                 // * Memory
                 if ($link == "ram" or $link == "memory") {
                     $oidvalues[$oid][""] = ceil($oidvalues[$oid][""] / 1024 / 1024);
                     if ($type == PRINTER_TYPE) {
                         $oidvalues[$oid][""] .= " MB";
                     }
                 }
                 if ($link == 'macaddr') {
                     $MacAddress = PluginFusioninventoryIfmac::ifmacwalk_ifmacaddress($oidvalues[$oid][""]);
                     $oidvalues[$oid][""] = $MacAddress;
                 }
                 // Convert hexa in string
                 $oidvalues[$oid][""] = PluginFusioninventorySNMP::hex_to_string($oidvalues[$oid][""]);
                 if (strstr($oidvalues[$oid][""], "noSuchName")) {
                     // NO Update field in GLPI
                 } else {
                     if ($FUSIONINVENTORY_MAPPING[$type][$link]['table'] == "glpi_plugin_fusioninventory_printers_cartridges") {
                         // * Printers cartridges
                         $object_name_clean = str_replace("MAX", "", $link);
                         $object_name_clean = str_replace("REMAIN", "", $object_name_clean);
                         if (strstr($link, "MAX")) {
                             $printer_cartridges_max_remain[$object_name_clean]["MAX"] = $oidvalues[$oid][""];
                         }
                         if (strstr($link, "REMAIN")) {
                             $printer_cartridges_max_remain[$object_name_clean]["REMAIN"] = $oidvalues[$oid][""];
                         }
                         if (isset($printer_cartridges_max_remain[$object_name_clean]["MAX"]) and isset($printer_cartridges_max_remain[$object_name_clean]["REMAIN"])) {
                             $pourcentage = ceil(100 * $printer_cartridges_max_remain[$object_name_clean]["REMAIN"] / $printer_cartridges_max_remain[$object_name_clean]["MAX"]);
                             // Test existance of row in MySQl
                             $query_sel = "SELECT *\n                                FROM " . $FUSIONINVENTORY_MAPPING[$type][$link]['table'] . "\n                                WHERE " . $Field . "='" . $ID_Device . "'\n                                      AND `object_name`='" . $object_name_clean . "';";
                             $result_sel = $DB->query($query_sel);
                             if ($DB->numrows($result_sel) == "0") {
                                 $queryInsert = "INSERT INTO " . $FUSIONINVENTORY_MAPPING[$type][$link]['table'] . "\n                                                 (" . $Field . ",object_name)\n                                     VALUES('" . $ID_Device . "', '" . $object_name_clean . "');";
                                 $DB->query($queryInsert);
                             }
                             $queryUpdate = "UPDATE " . $FUSIONINVENTORY_MAPPING[$type][$link]['table'] . "\n                                  SET " . $FUSIONINVENTORY_MAPPING[$type][$link]['field'] . "='" . $pourcentage . "'\n                                  WHERE " . $Field . "='" . $ID_Device . "'\n                                        AND `object_name`='" . $object_name_clean . "';";
                             $DB->query($queryUpdate);
                             unset($printer_cartridges_max_remain[$object_name_clean]["MAX"]);
                             unset($printer_cartridges_max_remain[$object_name_clean]["REMAIN"]);
                         } else {
                             // Test existance of row in MySQl
//.........这里部分代码省略.........
开发者ID:Hawke,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:snmp.class.php

示例14: plugin_certificates_install

function plugin_certificates_install() {
   global $DB;
   
   include_once (GLPI_ROOT."/plugins/certificates/inc/profile.class.php");
   
   $install=false;
   $update78=false;
   $update80=false;
   
   if (!TableExists("glpi_plugin_certificates") && !TableExists("glpi_plugin_certificates_certificatetypes")) {
      
      $install=true;
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/empty-2.0.0.sql");

   } else if (TableExists("glpi_plugin_certificates_mailing") && !FieldExists("glpi_plugin_certificates","recursive")) {
      
      $update78=true;
      $update80=true;
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.4.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.0.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql");

   } else if (TableExists("glpi_plugin_certificates_profiles") && FieldExists("glpi_plugin_certificates_profiles","interface")) {
      
      $update78=true;
      $update80=true;
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.0.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql");

   } else if (TableExists("glpi_plugin_certificates") && !FieldExists("glpi_plugin_certificates","date_mod")) {
      
      $update78=true;
      $update80=true;
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql");
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql");

   } else if (!TableExists("glpi_plugin_certificates_certificatetypes")) {
      
      $update78=true;
      $update80=true;
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql");
      
   }
   //from 1.6 version
   if (TableExists("glpi_plugin_certificates_certificates") 
      && !FieldExists("glpi_plugin_certificates_certificates","users_id_tech")) {
      $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.8.0.sql");
   }
   
   if (TableExists("glpi_plugin_certificates_profiles")) {
   
      $notepad_tables = array('glpi_plugin_certificates_certificates');

      foreach ($notepad_tables as $t) {
         // Migrate data
         if (FieldExists($t, 'notepad')) {
            $query = "SELECT id, notepad
                      FROM `$t`
                      WHERE notepad IS NOT NULL
                            AND notepad <>'';";
            foreach ($DB->request($query) as $data) {
               $iq = "INSERT INTO `glpi_notepads`
                             (`itemtype`, `items_id`, `content`, `date`, `date_mod`)
                      VALUES ('".getItemTypeForTable($t)."', '".$data['id']."',
                              '".addslashes($data['notepad'])."', NOW(), NOW())";
               $DB->queryOrDie($iq, "0.85 migrate notepad data");
            }
            $query = "ALTER TABLE `glpi_plugin_certificates_certificates` DROP COLUMN `notepad`;";
            $DB->query($query);
         }
      }
   }
   
   if ($install || $update78) {

      //Do One time on 0.78
      $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginCertificatesCertificate' AND `name` = 'Alert Certificates'";
      $result = $DB->query($query_id) or die ($DB->error());
      $itemtype = $DB->result($result,0,'id');
      
      $query="INSERT INTO `glpi_notificationtemplatetranslations`
                                 VALUES(NULL, ".$itemtype.", '','##certificate.action## : ##certificate.entity##',
                        '##lang.certificate.entity## :##certificate.entity##
   ##FOREACHcertificates##
   ##lang.certificate.name## : ##certificate.name## - ##lang.certificate.dateexpiration## : ##certificate.dateexpiration##
   ##ENDFOREACHcertificates##',
                        '&lt;p&gt;##lang.certificate.entity## :##certificate.entity##&lt;br /&gt; &lt;br /&gt;
                        ##FOREACHcertificates##&lt;br /&gt;
                        ##lang.certificate.name##  : ##certificate.name## - ##lang.certificate.dateexpiration## :  ##certificate.dateexpiration##&lt;br /&gt; 
                        ##ENDFOREACHcertificates##&lt;/p&gt;');";
      $result=$DB->query($query);
      
      $query = "INSERT INTO `glpi_notifications`
                                   VALUES (NULL, 'Alert Expired Certificates', 0, 'PluginCertificatesCertificate', 'ExpiredCertificates',
                                          'mail',".$itemtype.",
                                          '', 1, 1, '2010-02-17 22:36:46');";
      
      $result=$DB->query($query);
//.........这里部分代码省略.........
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:hook.php

示例15: checkClassAndFilesForOneItemType

 /**
  *
  * Create or overwrite files for an itemtype
  * @since 2.2.0
  * @param $itemtype the itemtype to check
  * @param $name type's short name
  * @param $overwrite force to overwrite existing files
  * @return nothing
  */
 static function checkClassAndFilesForOneItemType($itemtype, $name, $overwrite = false, $overwrite_locales = true)
 {
     global $DB;
     $table = getTableForItemType($itemtype);
     //If class doesn't exist but table exists, create class
     if (TableExists($table) && ($overwrite || !class_exists($itemtype))) {
         self::addNewObject($name, $itemtype, array('add_table' => false, 'create_default_profile' => false, 'add_injection_file' => false, 'add_language_file' => false, 'overwrite_locales' => $overwrite_locales));
     }
     foreach ($DB->list_fields($table) as $field => $options) {
         if (preg_match("/s_id\$/", $field)) {
             $dropdowntable = getTableNameForForeignKeyField($field);
             $dropdownclass = getItemTypeForTable($dropdowntable);
             if (TableExists($dropdowntable) && !class_exists($dropdownclass)) {
                 $name = str_replace("glpi_plugin_genericobject_", "", $dropdowntable);
                 $name = getSingular($name);
                 $params = PluginGenericobjectField::getFieldOptions($field, $dropdownclass);
                 if (isset($params['dropdown_type']) and $params['dropdown_type'] === 'isolated') {
                     $params['linked_itemtype'] = $itemtype;
                 }
                 self::addNewDropdown($name, 'PluginGenericobject' . ucfirst($name), $params);
             }
         }
     }
 }
开发者ID:btry,项目名称:genericobject,代码行数:33,代码来源:type.class.php


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