new NotifyWidgetSuccess(_T("SSH public keys updated.", "sshlpk")); } } else { if (!$showSshkeys && hasSshKeyObjectClass($uid)) { delSSHKeyObjectClass($uid); if (!isXMLRPCError()) { new NotifyWidgetSuccess(_T("SSH public keys attributes deleted.", "sshlpk")); } } } redirectTo(urlStrRedirect('base/users/sshkeys')); } $p = new PageGenerator(_T("Change your SSH keys", "sshlpk")); $p->setSideMenu($sidemenu); $p->display(); $show = hasSshKeyObjectClass($uid); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T("Enable SSH keys management", "sshlpk"), new CheckboxTpl("showusersshkey")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'sshkeydiv\');"')); $f->pop(); $sshkeydiv = new Div(array("id" => "sshkeydiv")); $sshkeydiv->setVisibility($show); $f->push($sshkeydiv); if ($show) { $sshkeys = getAllSshKey($uid); } else { $sshkeys = array("0" => ""); } $f->add(new TrFormElement('', new MultipleInputTpl("sshuserkeys", _T("Public SSH Key", "sshlpk"))), $sshkeys); $f->addValidateButton("bssh"); $f->display();
/** * Function called for changing user attributes * @param $FH FormHandler of the page * @param $mode add or edit mode */ function _sshlpk_changeUser($FH, $mode) { global $result; if ($FH->getPostValue("showsshkey")) { if ($FH->isUpdated('sshkeylist')) { updateSshKeys($FH->getPostValue('uid'), $FH->getValue('sshkeylist')); $result .= _T("SSH public keys updated.", "sshlpk") . "<br />"; } } else { if ($mode == 'edit' && hasSshKeyObjectClass($FH->getPostValue('uid'))) { delSSHKeyObjectClass($FH->getPostValue('uid')); $result .= _T("SSH public keys attributes deleted.", "sshlpk") . "<br />"; } } return 0; }