Example #1
0
     }
     $table->setHeader($header);
     $options = array('nodeids' => $nodeid, 'output' => API_OUTPUT_EXTEND);
     $screens = CScreen::get($options);
     order_result($screens, 'name');
     foreach ($screens as $snum => $row) {
         $name = new CSpan($row["name"], 'link');
         if ($multiselect) {
             $js_action = "javascript: addValue(" . zbx_jsvalue($reference) . ", " . zbx_jsvalue($row[$srcfld1]) . ");";
         } else {
             $values = array($dstfld1 => $row[$srcfld1], $dstfld2 => $row[$srcfld2]);
             $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ',' . zbx_jsvalue($values) . '); close_window(); return false;';
         }
         $name->setAttribute('onclick', $js_action);
         if ($multiselect) {
             $name = new CCol(array(new CCheckBox('screens[' . zbx_jsValue($row[$srcfld1]) . ']', NULL, NULL, $row['screenid']), $name));
         }
         $table->addRow($name);
     }
     if ($multiselect) {
         $button = new CButton('select', S_SELECT, "javascript: addSelectedValues('screens', " . zbx_jsvalue($reference) . ");");
         $button->setType('button');
         $table->setFooter(new CCol($button, 'right'));
     }
     $form->addItem($table);
     $form->show();
 } else {
     if ($srctbl == 'screens2') {
         require_once 'include/screens.inc.php';
         $table = new CTableInfo(S_NO_NODES_DEFINED);
         $table->setHeader(S_NAME);
Example #2
0
 if (!is_null($writeonly)) {
     $options['editable'] = true;
 }
 $scripts = API::Script()->get($options);
 order_result($scripts, 'name');
 foreach ($scripts as $script) {
     $description = new CLink($script['name'], '#');
     if ($multiselect) {
         $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($script['scriptid']) . ');';
     } else {
         $values = array($dstfld1 => $script[$srcfld1], $dstfld2 => $script[$srcfld2]);
         $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;';
     }
     $description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
     if ($multiselect) {
         $description = new CCol(array(new CCheckBox('scripts[' . zbx_jsValue($script[$srcfld1]) . ']', null, null, $script['scriptid']), $description));
     }
     if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) {
         switch ($script['execute_on']) {
             case ZBX_SCRIPT_EXECUTE_ON_AGENT:
                 $scriptExecuteOn = _('Agent');
                 break;
             case ZBX_SCRIPT_EXECUTE_ON_SERVER:
                 $scriptExecuteOn = _('Server');
                 break;
         }
     } else {
         $scriptExecuteOn = '';
     }
     $table->addRow(array($description, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8'))));
 }
Example #3
0
    foreach ($scripts as $script) {
        $description = new CLink($script['name'], 'javascript:void(0);');
        if ($multiselect) {
            $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($script['scriptid']) . ');';
        } else {
            $values = [$dstfld1 => $script[$srcfld1], $dstfld2 => $script[$srcfld2]];
            $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;';
        }
        $description->onClick($js_action . ' jQuery(this).removeAttr("onclick");');
        if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) {
            switch ($script['execute_on']) {
                case ZBX_SCRIPT_EXECUTE_ON_AGENT:
                    $scriptExecuteOn = _('Agent');
                    break;
                case ZBX_SCRIPT_EXECUTE_ON_SERVER:
                    $scriptExecuteOn = _('Server');
                    break;
            }
        } else {
            $scriptExecuteOn = '';
        }
        $table->addRow([$multiselect ? new CCheckBox('scripts[' . zbx_jsValue($script[$srcfld1]) . ']', $script['scriptid']) : null, $description, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8'))]);
    }
    if ($multiselect) {
        $table->setFooter(new CCol((new CButton('select', _('Select')))->onClick("javascript: addSelectedValues('scripts', " . zbx_jsvalue($reference) . ');')));
        insert_js('var popupReference = ' . zbx_jsvalue($scripts, true) . ';');
    }
    $form->addItem($table);
    $widget->addItem($form)->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';