Esempio n. 1
0
/**
 * Form on user edit page
 * @param $FH FormHandler of the page
 * @param $mode add or edit mode
 */
function _sshlpk_baseEdit($FH, $mode)
{
    // default value
    $show = false;
    if ($mode == 'edit' && hasSshKeyObjectClass($FH->getArrayOrPostValue("uid"))) {
        $show = true;
    } else {
        if ($FH->getValue("showsshkey") == "on") {
            $show = true;
        }
    }
    $f = new DivForModule(_T("Public SSH keys management", "sshlpk"), "#DDF");
    $f->push(new Table());
    $f->add(new TrFormElement(_T("Enable SSH keys management", "sshlpk"), new CheckboxTpl("showsshkey")), array("value" => $show ? "checked" : "", "extraArg" => 'onclick="toggleVisibility(\'sshkeydiv\');"'));
    $f->pop();
    $sshkeydiv = new Div(array("id" => "sshkeydiv"));
    $sshkeydiv->setVisibility($show);
    $f->push($sshkeydiv);
    $sshkeylist = array();
    if ($FH->getArrayOrPostValue("uid")) {
        if ($show && $mode == "edit") {
            $sshkeylist = getAllSshKey($FH->getArrayOrPostValue("uid"));
        }
    }
    if (count($sshkeylist) == 0) {
        $sshkeylist = array("0" => "");
    }
    $f->add(new TrFormElement('', new MultipleInputTpl("sshkeylist", _T("Public SSH Key", "sshlpk"))), $sshkeylist);
    $f->pop();
    return $f;
}
Esempio n. 2
0
File: edit.php Progetto: psyray/mmc
            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();