コード例 #1
0
 $msgOk = $msgFail = '';
 if (isset($_REQUEST['save'])) {
     DBstart();
     $valueMap = array('name' => get_request('mapname'));
     $mappings = get_request('mappings', array());
     if (isset($_REQUEST['valuemapid'])) {
         $msgOk = _('Value map updated');
         $msgFail = _('Cannot update value map');
         $audit_action = AUDIT_ACTION_UPDATE;
         $valueMap['valuemapid'] = get_request('valuemapid');
         updateValueMap($valueMap, $mappings);
     } else {
         $msgOk = _('Value map added');
         $msgFail = _('Cannot add value map');
         $audit_action = AUDIT_ACTION_ADD;
         addValueMap($valueMap, $mappings);
     }
     add_audit($audit_action, AUDIT_RESOURCE_VALUE_MAP, _s('Value map "%1$s".', $valueMap['name']));
     show_messages(true, $msgOk);
     unset($_REQUEST['form']);
     DBend(true);
 } elseif (isset($_REQUEST['delete']) && isset($_REQUEST['valuemapid'])) {
     DBstart();
     $msgOk = _('Value map deleted');
     $msgFail = _('Cannot delete value map');
     $sql = 'SELECT v.name,v.valuemapid' . ' FROM valuemaps v' . ' WHERE v.valuemapid=' . zbx_dbstr($_REQUEST['valuemapid']) . andDbNode('v.valuemapid');
     if ($valueMapToDelete = DBfetch(DBselect($sql))) {
         deleteValueMap($_REQUEST['valuemapid']);
     } else {
         throw new Exception(_s('Value map with valuemapid "%1$s" does not exist.', $_REQUEST['valuemapid']));
     }
コード例 #2
0
try {
    if (hasRequest('add') || hasRequest('update')) {
        DBstart();
        $valueMap = array('name' => getRequest('mapname'));
        $mappings = getRequest('mappings', array());
        if (hasRequest('update')) {
            $messageSuccess = _('Value map updated');
            $messageFailed = _('Cannot update value map');
            $auditAction = AUDIT_ACTION_UPDATE;
            $valueMap['valuemapid'] = getRequest('valuemapid');
            $result = updateValueMap($valueMap, $mappings);
        } else {
            $messageSuccess = _('Value map added');
            $messageFailed = _('Cannot add value map');
            $auditAction = AUDIT_ACTION_ADD;
            $result = addValueMap($valueMap, $mappings);
        }
        if ($result) {
            add_audit($auditAction, AUDIT_RESOURCE_VALUE_MAP, _s('Value map "%1$s".', $valueMap['name']));
        }
        unset($_REQUEST['form']);
        $result = DBend($result);
        show_messages($result, $messageSuccess, $messageFailed);
    } elseif (isset($_REQUEST['delete']) && isset($_REQUEST['valuemapid'])) {
        $messageSuccess = _('Value map deleted');
        $messageFailed = _('Cannot delete value map');
        DBstart();
        $sql = 'SELECT v.name,v.valuemapid' . ' FROM valuemaps v' . ' WHERE v.valuemapid=' . zbx_dbstr($_REQUEST['valuemapid']);
        if ($valueMapToDelete = DBfetch(DBselect($sql))) {
            $result = deleteValueMap($_REQUEST['valuemapid']);
            if ($result) {