Ejemplo n.º 1
0
 public function setAction($value = null)
 {
     if (!is_null($value)) {
         parent::onClick($value);
         return $this;
     }
     global $page;
     $confirmation = "Confirm('" . $this->msg . "')";
     if (isset($this->vars)) {
         $link = $page['file'] . '?' . $this->name . '=1' . $this->vars;
         $action = "redirect('" . (new CUrl($link))->getUrl() . "')";
     } else {
         $action = 'true';
     }
     parent::onClick('if (' . $confirmation . ') { return ' . $action . '; } else { return false; }');
     return $this;
 }
    if (isset($this->data['change_bind_password']) || zbx_empty($this->data['config']['ldap_bind_password'])) {
        $authenticationForm->addVar('change_bind_password', 1);
        $authenticationFormList->addRow(_('Bind password'), (new CPassBox('ldap_bind_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH));
    } else {
        $authenticationFormList->addRow(_('Bind password'), (new CSubmit('change_bind_password', _('Change password')))->addClass(ZBX_STYLE_BTN_GREY));
    }
    $authenticationFormList->addRow(_('Test authentication'), ' [' . _('must be a valid LDAP user') . ']');
    $authenticationFormList->addRow(_('Login'), $userComboBox);
    $authenticationFormList->addRow(_('User password'), (new CPassBox('user_password'))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH));
}
// append form list to tab
$authenticationTab = new CTabView();
$authenticationTab->addTab('authenticationTab', $this->data['title'], $authenticationFormList);
// create save button
$saveButton = new CSubmit('update', _('Update'));
if ($this->data['is_authentication_type_changed']) {
    $saveButton->onClick('javascript: if (confirm(' . CJs::encodeJson(_('Switching authentication method will reset all except this session! Continue?')) . ')) {' . 'jQuery("#authenticationForm").submit(); return true; } else { return false; }');
} elseif ($this->data['config']['authentication_type'] != ZBX_AUTH_LDAP) {
    $saveButton->setAttribute('disabled', 'true');
}
// append buttons to form
if ($this->data['config']['authentication_type'] == ZBX_AUTH_LDAP) {
    $authenticationTab->setFooter(makeFormFooter($saveButton, [new CSubmit('test', _('Test'))]));
} else {
    $authenticationTab->setFooter(makeFormFooter($saveButton));
}
// append tab to form
$authenticationForm->addItem($authenticationTab);
// append form to widget
$widget->addItem($authenticationForm);
return $widget;