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


PHP GetDeviceGroups函数代码示例

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


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

示例1: foreach

<?php

require_once 'includes/modal/new_device_group.inc.php';
require_once 'includes/modal/delete_device_group.inc.php';
$no_refresh = TRUE;
echo '<div class="row"><div class="col-sm-12"><span id="message"></span></div></div>';
echo '<div class="table-responsive">';
echo '<table class="table table-condensed table-hover"><thead><tr>';
echo '<th>Name</th><th>Description</th><th>Pattern</th><th>Actions</th>';
echo '</tr></thead><tbody>';
foreach (GetDeviceGroups() as $group) {
    echo '<tr id="row_' . $group['id'] . '">';
    echo '<td>' . $group['name'] . '</td>';
    echo '<td>' . $group['desc'] . '</td>';
    echo '<td>' . $group['pattern'] . '</td>';
    echo '<td>';
    echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-group' data-group_id='" . $group['id'] . "' name='edit-device-group'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> ";
    echo "<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-group_id='" . $group['id'] . "' name='delete-device-group'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>";
    echo '</td>';
    echo '</tr>';
}
echo '</tbody></table></div>';
echo "<button type='button' class='btn btn-primary btn-sm' aria-label='Add' data-toggle='modal' data-target='#create-group' data-group_id='' name='create-device-group'>Create new Group</button> ";
开发者ID:REAP720801,项目名称:librenms,代码行数:23,代码来源:device-groups.inc.php

示例2: get_device_groups

function get_device_groups()
{
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $status = 'error';
    $code = 404;
    $hostname = $router['hostname'];
    // use hostname as device_id if it's all digits
    $device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
    if (is_numeric($device_id)) {
        $groups = GetGroupsFromDevice($device_id, 1);
    } else {
        $groups = GetDeviceGroups();
    }
    if (empty($groups)) {
        $message = 'No device groups found';
    } else {
        $status = 'ok';
        $code = 200;
        $message = 'Found ' . count($groups) . ' device groups';
    }
    $output = array('status' => $status, 'message' => $message, 'count' => count($groups), 'groups' => $groups);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
开发者ID:wiad,项目名称:librenms,代码行数:26,代码来源:api_functions.inc.php

示例3: GetGroupsFromDevice

/**
 * Get all groups of Device
 * @param integer $device Device-ID
 * @return array
 */
function GetGroupsFromDevice($device)
{
    $ret = array();
    foreach (GetDeviceGroups() as $group) {
        if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?') . ' LIMIT 1', array($device)) == $device) {
            $ret[] = $group['id'];
        }
    }
    return $ret;
}
开发者ID:rkojedzinszky,项目名称:librenms,代码行数:15,代码来源:device-groups.inc.php

示例4: QueryGroupsFromDevice

/**
 * Run the group queries again to get fresh list of groups for this device
 * @param integer $device_id Device-ID
 * @param int $extra Return extra info about the groups (name, desc, pattern)
 * @return array
 */
function QueryGroupsFromDevice($device_id, $extra = 0)
{
    $ret = array();
    foreach (GetDeviceGroups() as $group) {
        if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra) . ' LIMIT 1', array($device_id)) == $device_id) {
            if ($extra === 0) {
                $ret[] = $group['id'];
            } else {
                $ret[] = $group;
            }
        }
    }
    return $ret;
}
开发者ID:wiad,项目名称:librenms,代码行数:20,代码来源:device-groups.inc.php

示例5: foreach

    $common_output[] = '<option value=""' . ($current_state == '' ? ' selected' : '') . '>any state</option>';
    foreach ($alert_states as $name => $val) {
        $common_output[] = "<option value=\"{$val}\"" . ($current_state == $name || is_numeric($current_state) && $current_state == $val ? ' selected' : '') . ">{$name}</option>";
    }
    $common_output[] = '
      </select>
    </div>
  </div>
  <div class="form-group row">
    <div class="col-sm-4">
      <label for="group" class="control-label">Device Group:</label>
    </div>
    <div class="col-sm-8">
      <select class="form-control" name="group">';
    $common_output[] = '<option value=""' . ($current_group == '' ? ' selected' : '') . '>any group</option>';
    $device_groups = GetDeviceGroups();
    $common_output[] = "<!-- " . print_r($device_groups, true) . " -->";
    foreach ($device_groups as $group) {
        $group_id = $group['id'];
        $common_output[] = "<option value=\"{$group_id}\"" . (is_numeric($current_group) && $current_group == $group_id ? ' selected' : '') . ">" . $group['name'] . " - " . $group['description'] . "</option>";
    }
    $common_output[] = '
      </select>
    </div>
  </div>

  <div class="form-group">
    <div class="col-sm-12">
      <button type="submit" class="btn btn-default">Set</button>
    </div>
  </div>
开发者ID:JamesonFinney,项目名称:librenms,代码行数:31,代码来源:alerts.inc.php

示例6: QueryGroupsFromDevice

/**
 * Run the group queries again to get fresh list of groups for this device
 * @param integer $device_id Device-ID
 * @param int $extra Return extra info about the groups (name, desc, pattern)
 * @return array
 */
function QueryGroupsFromDevice($device_id, $extra = 0)
{
    $ret = array();
    foreach (GetDeviceGroups() as $group) {
        $params = (array) json_decode($group['params']);
        array_unshift($params, $device_id);
        if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?', $extra) . ' LIMIT 1', $params) == $device_id) {
            if ($extra === 0) {
                $ret[] = $group['id'];
            } else {
                $ret[] = $group;
            }
        }
    }
    return $ret;
}
开发者ID:awlx,项目名称:librenms,代码行数:22,代码来源:device-groups.inc.php


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