示例#1
0
function get_resource_name($permission, $id)
{
    $res = '-';
    if ($permission == 'Graph') {
        if (isset($id) && $id != 0) {
            if ($graph = get_graph_by_graphid($id)) {
                $res = $graph['name'];
            }
        } else {
            if (!isset($id) || $id == 0) {
                $res = 'All graphs';
            }
        }
    } else {
        if ($permission == 'Host') {
            if (isset($id) && $id != 0) {
                if ($host = get_host_by_hostid($id)) {
                    $res = $host['host'];
                }
            } else {
                if (!isset($id) || $id == 0) {
                    $res = 'All hosts';
                }
            }
        } else {
            if ($permission == 'Screen') {
                if (isset($id) && $id != 0) {
                    if ($screen = get_screen_by_screenid($id)) {
                        $res = $screen['name'];
                    }
                } else {
                    if (!isset($id) || $id == 0) {
                        $res = 'All screens';
                    }
                }
            } else {
                if ($permission == 'Item') {
                    if (isset($id) && $id != 0) {
                        if ($item = get_item_by_itemid($id)) {
                            if ($host = get_host_by_hostid($item['hostid'])) {
                                $res = $host['host'] . ':' . $item['description'];
                            }
                        }
                    } else {
                        if (!isset($id) || $id == 0) {
                            $res = 'All items';
                        }
                    }
                } else {
                    if ($permission == 'User') {
                        if (isset($id) && $id != 0) {
                            if ($user = get_user_by_userid($id)) {
                                $res = $user['alias'];
                            }
                        } else {
                            if (!isset($id) || $id == 0) {
                                $res = 'All users';
                            }
                        }
                    } else {
                        if ($permission == 'Network map') {
                            if (isset($id) && $id != 0) {
                                if ($user = get_sysmap_by_sysmapid($id)) {
                                    $res = $user['name'];
                                }
                            } else {
                                if (!isset($id) || $id == 0) {
                                    $res = 'All maps';
                                }
                            }
                        } else {
                            if ($permission == 'Application') {
                                if (isset($id) && $id > 0) {
                                    if ($app = get_application_by_applicationid($id)) {
                                        $res = $app['name'];
                                    }
                                } else {
                                    if (!isset($id) || $id == 0) {
                                        $res = 'All applications';
                                    }
                                }
                            } else {
                                if ($permission == 'Service') {
                                    if (isset($id) && $id > 0) {
                                        if ($service = get_service_by_serviceid($id)) {
                                            $res = $service['name'];
                                        }
                                    } else {
                                        if (!isset($id) || $id == 0) {
                                            $res = 'All services';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($res == '-' && isset($id) && $id > 0) {
        $res = $id;
    }
    return $res;
}
示例#2
0
function does_service_depend_on_the_service($serviceid, $serviceid2)
{
    $service = get_service_by_serviceid($serviceid);
    if ($service["status"] == 0) {
        return FALSE;
    }
    if (bccomp($serviceid, $serviceid2) == 0) {
        if ($service["status"] > 0) {
            return TRUE;
        }
    }
    $result = DBselect("SELECT serviceupid FROM services_links WHERE servicedownid={$serviceid2} and soft=0");
    while ($row = DBfetch($result)) {
        if (does_service_depend_on_the_service($serviceid, $row["serviceupid"]) == TRUE) {
            return TRUE;
        }
    }
    return FALSE;
}
示例#3
0
        $table->AddRow(array(array($prefix, $description), algorithm2str($db_service_data["algorithm"]), $trigger));
    }
    $cb = new CButton('cancel', S_CANCEL);
    $cb->SetType('button');
    $cb->SetAction('javascript: self.close();');
    $td = new CCol($cb);
    $td->setAttribute('style', 'text-align:right;');
    $table->SetFooter($td);
    $form->AddItem($table);
    $form->Show();
}
//--------------------------------------------	</PARENT SERVICES LIST>  --------------------------------------------
//---------------------------------------------- <CHILD SERVICES LIST> --------------------------------------------
if (isset($_REQUEST['cservices'])) {
    if (isset($service)) {
        $service = get_service_by_serviceid($service['serviceid']);
    }
    // update date after ACTIONS
    show_table_header(S_IT_SERVICES_BIG);
    $form = new CForm();
    $form->SetName("services");
    if (isset($service)) {
        $form->AddVar("serviceid", $service['serviceid']);
    }
    $table = new CTableInfo();
    $table->SetHeader(array(S_SERVICE, S_STATUS_CALCULATION, S_TRIGGER));
    if (isset($service)) {
        $childs = get_service_childs($service['serviceid'], 1);
        $childs_str = implode(',', $childs);
        !empty($childs_str) ? $childs_str .= ',' : '';
        $query = 'SELECT DISTINCT s.* ' . ' FROM services s ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (s.triggerid IS NULL OR ' . DBcondition('s.triggerid', $available_triggers) . ') ' . ' AND s.serviceid NOT IN (' . $childs_str . $service['serviceid'] . ') ' . ' ORDER BY s.sortorder,s.name';