Example #1
0
function get_screen_plaintext($itemid, $elements, $style = 0)
{
    if ($itemid == 0) {
        $table = new CTableInfo(S_ITEM_DOES_NOT_EXIST);
        $table->setHeader(array(S_TIMESTAMP, S_ITEM));
        return $table;
    }
    $item = get_item_by_itemid($itemid);
    switch ($item['value_type']) {
        case ITEM_VALUE_TYPE_TEXT:
        case ITEM_VALUE_TYPE_LOG:
            $order_field = 'id';
            break;
        case ITEM_VALUE_TYPE_FLOAT:
        case ITEM_VALUE_TYPE_UINT64:
        default:
            $order_field = 'clock';
    }
    $host = get_host_by_itemid($itemid);
    $table = new CTableInfo();
    $table->setHeader(array(S_TIMESTAMP, $host['host'] . ': ' . item_description($item)));
    $options = array('history' => $item['value_type'], 'itemids' => $itemid, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $order_field, 'limit' => $elements);
    $hData = CHistory::get($options);
    foreach ($hData as $hnum => $data) {
        switch ($item['value_type']) {
            case ITEM_VALUE_TYPE_TEXT:
                /* do not use break */
            /* do not use break */
            case ITEM_VALUE_TYPE_STR:
                if ($style) {
                    $value = new CJSscript($data['value']);
                } else {
                    $value = $data['value'];
                }
                break;
            case ITEM_VALUE_TYPE_LOG:
                if ($style) {
                    $value = new CJSscript($data['value']);
                } else {
                    $value = $data['value'];
                }
                break;
            default:
                $value = $data['value'];
                break;
        }
        if ($item['valuemapid'] > 0) {
            $value = replace_value_by_map($value, $item['valuemapid']);
        }
        $table->addRow(array(zbx_date2str(S_SCREENS_PLAIN_TEXT_DATE_FORMAT, $data['clock']), new CCol($value, 'pre')));
    }
    return $table;
}
Example #2
0
    if (!$q->exec()) {
        $AppUI->setMsg(db_error());
    } else {
        $AppUI->setMsg($okMsg);
        if ($action == 'add') {
            $q->clear();
        }
        $q->addTable('history');
        $q->addUpdate('history_item = history_id');
        $q->addWhere('history_table = \'history\'');
        $okMsg = 'History deleted';
    }
    $q->clear();
    $AppUI->redirect();
}
$history = new CHistory();
$history->load($history_id);
$titleBlock = new w2p_Theme_TitleBlock($history_id ? 'Edit history' : 'New history', 'stock_book_blue_48.png', 'history', 'history.' . $a);
if ($canDelete) {
    $titleBlock->addCrumbDelete('delete history', $canDelete, $msg);
}
$titleBlock->show();
?>

<script language="javascript" type="text/javascript">
	function delIt() {
		document.AddEdit.action.value = 'del';
		document.AddEdit.submit();
	}

    function cancel() {
Example #3
0
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
// @todo    convert to template
global $AppUI, $filter_param;
$filter_param = 'projects' == $m ? 'projects' : $filter_param;
$page = (int) w2PgetParam($_GET, 'page', 1);
$history = new CHistory();
$where = -1 == $filter_param ? '' : "history_table = '" . $filter_param . "'";
$histories = $history->loadAll('history_date DESC', $where);
$items = array_values($histories);
$display = array();
$perms = $AppUI->acl();
foreach ($items as $item) {
    if (!$perms->checkModuleItem($item['history_table'], 'view', $item['history_item'])) {
        continue;
    }
    // @note this next line is a little hack so our templating can resolve which history_user is which user
    $item['user_id'] = $item['history_user'];
    $display[] = $item;
}
$items = $display;
$module = new w2p_System_Module();
$fields = $module->loadSettings('history', 'index_list');
if (0 == count($fields)) {
    $fieldList = array('history_date', 'history_description', 'history_user');
    $fieldNames = array('Date', 'Description', 'Owner');
    $module->storeSettings('history', 'index_list', $fieldList, $fieldNames);
    $fields = array_combine($fieldList, $fieldNames);
Example #4
0
             }
         }
         $table->addRow($crow);
         // Plain Text
         if (!isset($_REQUEST['plaintext'])) {
             continue;
         }
         $ptData['body'][] = zbx_date2str(S_HISTORY_LOG_ITEM_PLAINTEXT, $data['clock']);
         $ptData['body'][] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n";
     }
 } else {
     // NUMERIC, FLOAT
     $table = new CTableInfo();
     $table->setHeader(array(S_TIMESTAMP, S_VALUE));
     $options['sortfield'] = 'clock';
     $hData = CHistory::get($options);
     foreach ($hData as $hnum => $data) {
         $item = $items[$data['itemid']];
         $host = reset($item['hosts']);
         if (!isset($data['value'])) {
             $data['value'] = '';
         }
         if ($item['valuemapid'] > 0) {
             $value = replace_value_by_map($data['value'], $item['valuemapid']);
             $value_mapped = true;
         } else {
             $value = $data['value'];
             $value_mapped = false;
         }
         if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT && !$value_mapped) {
             sscanf($data['value'], '%f', $value);
 private static function history($action, $params)
 {
     CHistory::$error = array();
     switch ($action) {
         default:
             $result = call_user_func(array('CHistory', $action), $params);
     }
     self::$result = $result;
 }
Example #6
0
echo $AppUI->_('Description');
?>
</th>
	<th nowrap="nowrap"><?php 
echo $AppUI->_('User');
?>
&nbsp;&nbsp;</th>
</tr>
<?php 
// Checking permissions.
// TODO: Enable the lines below to activate new permissions.
$perms =& $AppUI->acl();
//The next line makes no sense and takes loads of time
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$historyItem = new CHistory();
foreach ($history as $row) {
    $module = $row['history_table'] == 'task_log' ? 'tasks' : $row['history_table'];
    $hd = new Date($row['history_date']);
    ?>
    <tr>
        <td align="center"><a href='<?php 
    echo '?m=history&a=addedit&history_id=' . $row['history_id'];
    ?>
'><img src="<?php 
    echo w2PfindImage('icons/pencil.gif');
    ?>
" alt="<?php 
    echo $AppUI->_('Edit History');
    ?>
" border="0" width="12" height="12" /></a></td>