Ad Widget

Collapse

PATCH: Edit item from template and save it to a single host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sarek
    Junior Member
    • Aug 2006
    • 24

    #1

    PATCH: Edit item from template and save it to a single host

    I had a small problem where I have a few routers and wanted to make the interface names descriptive. Saying like "Sprint Uplink" or "Verizon Uplink"

    This patch let's you view the items for a host and instead of a link to the template it creates

    Template Link: Item Template Link - Item Host Link

    So you can goto the item page for that template.
    Edit the item in the template.
    Edit the item in the host. (Item will then show up without the template link)

    Dunno if it's useful to anyone else. But here ya go.


    Code:
    diff -ur php-old/include/items.inc.php php/include/items.inc.php
    --- php-old/include/items.inc.php       2006-05-23 10:14:26.000000000 -0400
    +++ php/include/items.inc.php   2006-08-23 09:36:12.000000000 -0400
    @@ -519,6 +519,15 @@
     
                    return $descr;
            }
    +
    +       function        get_realitem_by_itemid($itemid)
    +        {
    +                $itme = get_item_by_itemid($itemid);
    +                if($itme["templateid"] <> 0)
    +                        return get_realitem_by_itemid($itme["templateid"]);
    +
    +                return $itme["itemid"];
    +       }
     
            function        get_realhost_by_itemid($itemid)
            {
    diff -ur php-old/items.php php/items.php
    --- php-old/items.php   2006-05-25 12:02:17.000000000 -0400
    +++ php/items.php       2006-08-23 09:36:01.000000000 -0400
    @@ -409,7 +409,18 @@
                                                    "hostid=".$template_host["hostid"],
                                                    'action'),
                                            ":",
    -                                       item_description($db_item["description"],$db_item["key_"]),
    +                                       new CLink(
    +                                                item_description($db_item["description"],$db_item["key_"]),
    +                                                "items.php?form=update&itemid=".
    +                                                get_realitem_by_itemid($db_item["itemid"]).
    +                                               "&hostid=".$template_host["hostid"].url_param("groupid"),
    +                                                'action'),
    +                                       " - ",
    +                                       new CLink(
    +                                                "Local",
    +                                                "items.php?form=update&itemid=".
    +                                                $db_item["itemid"].url_param("hostid").url_param("groupid"),
    +                                                'action')
                                            );
                            }
Working...