Exemple #1
0
require "modules/base/users/localSidebar.php";
require "graph/header.inc.php";
require "graph/navbar.inc.php";
$uid = $_SESSION["login"];
if (isset($_POST['bssh'])) {
    $sshkeys = getAllSshKey($uid);
    $newSshkeys = $_POST['sshuserkeys'];
    $showSshkeys = $_POST['showusersshkey'];
    if ($showSshkeys && $newSshkeys != $sshkeys) {
        updateSshKeys($uid, $newSshkeys);
        if (!isXMLRPCError()) {
            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();
Exemple #2
0
/**
 * 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;
}