summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6001a4c)
raw | patch | inline | side by side (parent: 6001a4c)
author | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Aug 2007 17:14:55 +0000 (17:14 +0000) | ||
committer | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Aug 2007 17:14:55 +0000 (17:14 +0000) |
- some more cleanup to come
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7116 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7116 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_servSsh.inc | patch | blob | history | |
plugins/admin/systems/servssh.tpl | patch | blob | history |
index a3c03c05388e4dd1e77b0f0b75cd2d511881f7a0..7b9edeca79811b986e1b1c1ec899fa443f097544 100644 (file)
var $plHeadline= "SSH systems keys";
var $plDescription= "This plugin store ssh public keys for systems";
- var $sshPublickey = "";
- var $ignore_account= TRUE;
+ var $sshPublicKey = "";
+ var $ignore_account= FALSE;
/* attribute list for save action */
- var $attributes= array("sshPublickey");
- var $objectclasses= array("HostldapPublicKey");
+ var $attributes = array("sshPublicKey");
+ var $objectclasses = array("HostldapPublicKey");
var $uid ="";
+ /* Used to remember if this was an account (simply: is this an edited entry) */
+ var $initialy_was_account = false;
+
function servssh ($config, $dn= NULL, $parent= NULL)
{
plugin::plugin ($config, $dn, $parent);
- /* Always is account... */
- $this->is_account= TRUE;
+ /* Copy needed attributes */
+ foreach($this->attributes as $val) {
+ $name = preg_replace('/_/', '-', $val);
+ if (isset($this->attrs["$name"][0])) {
+ $this->$val = $this->attrs["$name"][0];
+ }
+ }
+
+ $this->is_account = false;
+ $this->initially_was_account = false;
+
+ if(isset($this->attrs['sshPublicKey'])) {
+ $this->is_account = true;
+ $this->initially_was_account = true;
+ }
+
+
}
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
- /* Show main page */
+ /* Fill templating stuff
+ */
$smarty= get_smarty();
-
- /* Load attributes */
- foreach($this->attributes as $attr){
- $smarty->assign("$attr", $this->$attr);
- $smarty->assign($attr."ACL", chkacl($this->acl, "$attr"));
+ $display= "";
+
+ /* Do we need to flip is_account state?
+ */
+ if (isset($_POST['modify_state'])){
+
+ /* Only change account state if allowed */
+ if($this->is_account && $this->acl == "#all#"){
+ $this->is_account= !$this->is_account;
+ $this->is_modified = true;
+ }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+ $this->is_account= !$this->is_account;
+ $this->is_modified = true;
+ }
}
- $smarty->assign("sstate", "");
if ($this->is_account){
- $smarty->assign("sshState", "checked");
- $smarty->assign("sstate", "");
+ $display= $this->show_header(_("Remove SSH keys"),
+ _("This server has SSH features enabled. You can disable them by clicking below."));
} else {
- $smarty->assign("sshState", "");
- if($_SESSION['js']==1){
- if($this->acl!="#none#")
- $smarty->assign("sstate", "disabled");
- }else{
- $smarty->assign("sstate", "");
- }
- }
-
- /* Allow account status toogle? */
- $smarty->assign("sshACL", "disabled");
- if(!$this->is_account && chkacl($this->acl,"create") == ""){
- $smarty->assign("sshACL", "");
- }elseif($this->is_account && $this->acl == "#all#" ){
- $smarty->assign("sshACL", "");
+ $display= $this->show_header(_("Add SSH keys"),
+ _("This server has SSH features disabled. You can enable them by clicking below."));
+ return ($display);
}
- $changeState = "";
+ /* Load attributes */
foreach($this->attributes as $attr){
- $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
- if(chkacl($this->acl,$attr)==""){
- $changeState .= "changeState('".$attr."');\n";
- }
+ $smarty->assign("$attr", $this->$attr);
+ $smarty->assign($attr."ACL", chkacl($this->acl, "$attr"));
}
- $smarty->assign("changeState",$changeState);
- return($smarty->fetch (get_template_path('servssh.tpl', TRUE)));
+
+ $smarty->assign("sshPublicKeyACL",chkacl($this->acl,"sshPublicKey"));
+
+ /* Display tempalte
+ */
+ //$smarty->assign("ZoneList",$ZoneList->DrawList());
+ $display.= $smarty->fetch(get_template_path('servssh.tpl', TRUE));
+ return($display);
}
}
plugin::remove_from_parent();
+
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
- $this->attributes, "Save");
$this->cleanup();
- $ldap->modify ($this->attrs);
+
+// $this->attrs['sshPublicKey']="";
+
+ $ldap->modify ($this->attrs);
show_ldap_error($ldap->get_error(), _("Removing SSH account failed"));
/* Optionally execute a command after we're done */
- $this->handle_post_events('remove',array("uid" => $this->uid));
+// $this->handle_post_events('remove',array("uid" => $this->uid));
}
/* Save data to object */
function save_object()
{
- /* Do we need to flip is_account state? */
- if (isset($_POST['connectivityTab'])){
-
- /* Change state if needed */
- if(!$this->is_account && isset($_POST["ssh"]) && chkacl($this->acl,"create") == ""){
- $this->is_account = true;
- }elseif($this->is_account && !isset($_POST["ssh"]) && $this->acl == "#all#"){
- $this->is_account = false;
- }
- }
-
- plugin::save_object();
-
- #FIXME seams to be unused code !
- #if (isset($_POST["sshStatus"])){
- # $this->sshStatus = "disabled";
- #} else {
- # $this->sshStatus = "enabled";
- #}
- }
-
- /* Check values */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- /* Check for positive integer values */
- /* if ($this->is_account){
- if ((!is_id($this->sshPublickey))&&(chkacl($this->acl,"sshPublickey")=="")){
- $message[]= _("Value specified as 'SSH Key' is not valid.");
- }
- }*/
-
- return $message;
- }
+ plugin::save_object();
+ }
/* Save to LDAP */
function save()
{
- plugin::save();
+ plugin::save();
+
foreach($this->attributes as $attr){
if(chkacl($this->acl,$attr)!=""){
}
}
+
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
- show_ldap_error($ldap->get_error(), _("Saving SSH account failed"));
+ show_ldap_error($ldap->get_error(), _("Saving SSH key failed"));
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
}
+
+ /* Check values */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ /* Check for positive integer values */
+ /* if ($this->is_account){
+ if ((!is_id($this->sshPublickey))&&(chkacl($this->acl,"sshPublickey")=="")){
+ $message[]= _("Value specified as 'SSH Key' is not valid.");
+ }
+ }*/
+
+ return $message;
+ }
+
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index a8c14a6e3d79747975a91cdf5ba2e557493b799e..fed48d2aa4d62a4ac7c5b2066952258ba6bcec85 100644 (file)
-<h2>
- <input type="checkbox" name="ssh" value="B" {$sshState} {$sshACL}
- onclick="{$changeState}" >
- {t}SSH account{/t}
-</h2>
-
<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
<!-- Headline container -->
<table summary="" style="margin-left:4px;width:100%">
<tr>
<td style="vertical-align:top;">
- <td><textarea name="sshPublickey" id="sshPublickey" rows="4" style="width:80%" {$sshPublickeyACL} {$sstate}>{$sshPublickey}</textarea></td>
+ <textarea name="sshPublicKey" id="sshPublicKey" rows="4" style="width:80%" {$sshPublicKeyACL} >{$sshPublicKey}</textarea>
</tr>
</table>
</td>
</tr>
</table>
+
<!-- Place cursor -->
<script language="JavaScript" type="text/javascript">
<!-- // First input field on page
- focus_field('sshPublickey');
+ focus_field('sshPublicKey');
-->
</script>
+