summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 632ddd2)
raw | patch | inline | side by side (parent: 632ddd2)
author | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 27 Mar 2008 21:34:35 +0000 (21:34 +0000) | ||
committer | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 27 Mar 2008 21:34:35 +0000 (21:34 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5-plugins@10039 594d385d-05f5-0310-b6e9-bd551577e9d8
sudo-ldap/src/class_sudoldap.inc | [deleted file] | patch | blob | history |
sudo-ldap/src/class_sudoldapEditRole.inc | [deleted file] | patch | blob | history |
sudo-ldap/src/main.inc | [deleted file] | patch | blob | history |
sudo-ldap/src/sudoldap.tpl | [deleted file] | patch | blob | history |
sudo-ldap/src/sudoldapeditrole.tpl | [deleted file] | patch | blob | history |
diff --git a/sudo-ldap/src/class_sudoldap.inc b/sudo-ldap/src/class_sudoldap.inc
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-/*!
- \brief sudo-ldap plugin
- \author Guido Serra <gserra@guidoserra.it>
- \version 1.00
- \date 22.03.2008
-
- This class provides the functionality to read and write all attributes
- relevant for sudo-ldap from/to the LDAP.
- */
-
-class sudoldap extends plugin
-{
- /* Definitions */
- var $plHeadline = "sudo-ldap";
- var $plDescription = "This does something";
-
- /* Plugin specific values */
- var $attributes = array( "cn",
- "description",
- "sudoUser",
- "sudoHost",
- "sudoCommand",
- "sudoRunAs",
- "sudoOption");
-
- var $objectclasses = array("sudoRole");
- var $Roles = array();
- var $dialog = NULL;
-
- /* constructor, if 'dn' is set, the node loads the given
- 'dn' from LDAP */
- function sudoldap ($config, $dn= NULL, $parent= NULL){
- /* Configuration is fine, allways */
- $this->config= $config;
- /* Load bases attributes */
- plugin::plugin($config, $dn, $parent);
- $ldap= $this->config->get_ldap_link();
- } // function
-
- /* execute generates the html output for this node */
- function execute($isCopyPaste = false){
- /* Call parent execute */
- plugin::execute();
- $display= "";
- $smarty= get_smarty();
- $this->Roles = $this->getRoles();
-
- /* Edited or Added zone
- */
- if((isset($_POST['SaveRoleChanges'])) && is_object($this->dialog)){
- $this->dialog->save_object();
-
- /* Check for errors
- */
- if(count($this->dialog->check())){
- foreach($this->dialog->check() as $msgs){
- print_red($msgs);
- }
- }else{
- /* add new/edited zone
- */
- $ret = $this->dialog->save();
- //if(!$this->dialog->isNew){
- // unset($this->Roles[$this->dialog->OldRoleName]);
- //}
- $this->Roles[$ret['cn']] = $ret;
- $this->dialog = NULL;
- }
- }
-
- /* Cancel zone edit / new
- */
- if(isset($_POST['CancelRoleChanges'])){
- $this->dialog = NULL;
- }
-
- /* Add empty new zone
- */
- //if(isset($_POST['AddRole']) && chkacl($this->acl,"sudoldap") == ""){
- if(isset($_POST['AddRole'])){
- $this->dialog = new sudoldapEditRole($this->config);
- }
-
- /* Check for edit role request
- */
- $once = false;
- foreach( $_POST as $name => $value){
-
- /* check all post for edit request
- */
-
- //if(preg_match("/^editRole_/",$name)&&!$once
- // && chkacl($this->acl,"sudoldap") == ""){
- if(preg_match("/^editRole_/",$name)&&!$once){
- $once =true;
- $tmp = preg_replace("/^editRole_/","",$name);
- $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
- $this->dialog= new sudoldapeditRole($this->config,
- $this->dn,
- $this->Roles[$tmp]);
- } // if ()
-
- /* check posts for delete zone
- */
-
- //if(preg_match("/^delRole_/",$name)&&!$once
- // && chkacl($this->acl,"sudoldap") == ""){
- if(preg_match("/^delRole_/",$name)&&!$once){
- $once =true;
- $tmp = preg_replace("/^delRole_/","",$name);
- $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
-
- /* Initiate deletion
- */
-
- $this->RemoveRole($tmp);
- } // if ()
-
- } // foreach()
-
- /* Show dialog
- */
- if($this->dialog!= NULL){
- $this->dialog->save_object();
- $this->dialog->parent = $this;
- return($this->dialog->execute());
- }
-
- $RoleList = new divSelectBox("sudoRoles");
- $RoleList->SetHeight(300);
- $editImg = "<input type='image' src='images/edit.png' name='editRole_%s'>
- <input type='image' src='images/edittrash.png' name='delRole_%s'>";
-
- foreach($this->Roles as $role => $values ){
- $link = "<a href='?plug=".$_GET['plug']."&act=edit&id=%s'>%s</a>";
- $RoleList->AddEntry(
- array(
- array("string" => sprintf($link,base64_encode($role),$role)),
- array("string" => str_replace("%s",base64_encode($role),$editImg))
- )
- );
- } // foreach()
-
- $smarty->assign("sudoldapACL",chkacl($this->acl,"sudoldap"));
- $smarty->assign("RoleList",$RoleList->DrawList());
-
- $display.= $smarty->fetch(get_template_path('sudoldap.tpl', TRUE));
-
- return($display);
- } // function
-
- function getRoles(){
- $ret = array();
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(objectClass=sudoRole)",$this->attributes);
- while ($attrs= $ldap->fetch()){
- $cn= $attrs['cn'][0];
- foreach($this->attributes as $value){
- if(isset($attrs[$value])){
- $ret[$cn][$value] = $attrs[$value][0];
- } // if()
- } // foreach()
- } // while()
- return($ret);
- }
-
- function RemoveRole($cn){
- if($cn!=""){
- $ldap= $this->config->get_ldap_link();
- $dn = "cn=".$cn.",ou=SUDOers,".$this->config->current['BASE'];
- $ldap->cd($dn);
- $ldap->rmdir_recursive($dn);
- show_ldap_error($ldap->get_error(), _("Removing DNS entries failed"));
- unset($this->Roles[$cn]);
- } // if()
- } // function
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/sudo-ldap/src/class_sudoldapEditRole.inc b/sudo-ldap/src/class_sudoldapEditRole.inc
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-class sudoldapEditRole extends plugin
-{
- /* Plugin specific values */
- var $attributes = array("cn",
- "description",
- "sudoUser",
- "sudoHost",
- "sudoCommand",
- "sudoRunAs",
- "sudoOption");
-
- var $objectclasses = array("sudoRole");
-
- var $cn = "";
- var $description = "";
- var $sudoUser = "";
- var $sudoHost = "";
- var $sudoCommand = "";
- var $sudoRunAs = "";
- var $sudoOption = "";
-
- var $isNew = true;
-
- function sudoldapEditRole ($config, $dn= NULL, $attrs = array())
- {
- plugin::plugin ($config, $dn);
-
- if(!count($attrs)){
- $this->isNew = true;
- }else{
- $this->isNew = false;
- foreach($this->attributes as $value){
- if(isset($attrs[$value])){
- $this->$value = $attrs[$value];
- }
- }
- }
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $smarty->assign("cn", $this->cn);
- $smarty->assign("description", $this->description);
- $smarty->assign("sudoUser", $this->sudoUser);
- $smarty->assign("sudoHost", $this->sudoHost);
- $smarty->assign("sudoCommand", $this->sudoCommand);
- $smarty->assign("sudoRunAs", $this->sudoRunAs);
- $smarty->assign("sudoOption", $this->sudoOption);
-
- /* Display template */
- $display.= $smarty->fetch(
- get_template_path('sudoldapeditrole.tpl', TRUE));
- return($display);
- }
-
- /* Save data to object */
- function save_object()
- {
- //plugin::save_object();
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
- }
-
-
- /* Check supplied data */
- function check()
- {
- }
-
-
- /* Save to LDAP */
- function save()
- {
- plugin::save();
- $ldap= $this->config->get_ldap_link();
-
- $this->dn = "cn=".$this->cn.",ou=SUDOers,".$this->config->current['BASE'];
- $this->attrs['objectClass'] = array("sudoRole");
-
- $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
-
- /* Display errors
- */
- if($ldap->get_error() != "Success"){
- show_ldap_error("Record:".$ldap->get_error(), _("Saving failed!"));
- }
- }
-
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/sudo-ldap/src/main.inc b/sudo-ldap/src/main.inc
--- a/sudo-ldap/src/main.inc
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2008 Guido Serra <gserra@guidoserra.it>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Clear display */
-$display= "";
-
-if (!$remove_lock){
-
- /* Reset requested? */
- if (isset($_POST['edit_cancel']) ||
- (isset($_GET['reset']) && $_GET['reset'] == 1)){
-
- del_lock ($ui->dn);
- sess_del ('edit');
- sess_del ('sudoldap');
- }
-
- /* Create sudoldap object on demand */
- if (!isset($_SESSION['sudoldap']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
- $_SESSION['sudoldap']= new sudoldap ($config, $ui->dn);
- }
- $sudoldap= $_SESSION['sudoldap'];
-
- /* save changes back to object */
- if (isset ($_SESSION['edit'])){
- $sudoldap->save_object ();
- }
-
- /* Enter edit mode? */
- if ((isset($_POST['edit'])) && (!isset( $_SESSION['edit']))){
-
- /* Check locking */
- if (($username= get_lock($ui->dn)) != ""){
- $_SESSION['back_plugin']= $plug;
- gen_locked_message ($username, $ui->dn);
- exit ();
- }
-
- /* Lock the current entry */
- add_lock ($ui->dn, $ui->dn);
- $_SESSION['dn']= $ui->dn;
- $_SESSION['edit']= TRUE;
- }
-
- /* Adjust acl's to mode */
- if (isset($_SESSION['edit'])){
- $acl= get_permissions ($ui->dn, $ui->subtreeACL);
- $sudoldap->acl= get_module_permission($acl, "sudoldap", $ui->dn);
- } else {
- $acl= get_permissions ($ui->dn, $ui->subtreeACL);
- $editacl= get_module_permission($acl, "sudoldap", $ui->dn);
- $sudoldap->acl= "#none#";
- }
-
- /* save changes to LDAP and disable edit mode */
- $info= "";
- if (isset($_POST['edit_finish'])){
-
- /* Perform checks */
- $message= $sudoldap->check ();
-
- /* No errors, save object */
- if (count ($message) == 0){
- $sudoldap->save ();
- gosa_log ("SUDO/ldap object'".$ui->dn."' has been saved");
- $sudoldap->acl= "#none#";
- $editacl= get_module_permission($acl, "sudoldap", $ui->dn);
- del_lock ($ui->dn);
- sess_del ('edit');
-
- /* Remove from session */
- sess_del ('sudoldap');
- } else {
- /* Errors found, show message */
- show_errors ($message);
- }
- }
-
- /* Execute formular */
- $display.= $sudoldap->execute ();
-
- /* Store changes in session */
- if (isset ($_SESSION['edit'])){
- $_SESSION['sudoldap']= $sudoldap;
- }
-
- /* Page header*/
- $display= print_header(get_template_path('images/posix.png'),
- _("sudo-ldap"), $info).$display;
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/sudo-ldap/src/sudoldap.tpl b/sudo-ldap/src/sudoldap.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-<table summary="" width="100%">
-<tr>
- <td style="width:100%;vertical-align:top;">
- <h2>{t}Sudo Roles{/t}</h2>
- {$RoleList}
- <input type="submit" name="AddRole" value="{t}Add{/t}">
- <!--
- <input type="submit" name="AddRole" value="{t}Add{/t}" {$sudoldapACL}>
- -->
- </td>
-</tr>
-</table>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('AddRole');
- -->
-</script>
diff --git a/sudo-ldap/src/sudoldapeditrole.tpl b/sudo-ldap/src/sudoldapeditrole.tpl
+++ /dev/null
@@ -1,42 +0,0 @@
-<h2>{t}sudo-ldap role{/t}</h2>
-<table summary="" width="100%">
- <tr>
- <td> {t}cn{/t}{$must} </td>
- <td> <input type="text" name="cn" value="{$cn}"> </td>
- </tr>
- <tr>
- <td> {t}description{/t}{$must} </td>
- <td> <input type="text" name="description" value="{$description}"> </td>
- </tr>
- <tr>
- <td> {t}sudoUser{/t}{$must} </td>
- <td> <input type="text" name="sudoUser" value="{$sudoUser}"> </td>
- </tr>
- <tr>
- <td> {t}sudoHost{/t}{$must} </td>
- <td> <input type="text" name="sudoHost" value="{$sudoHost}"> </td>
- </tr>
- <tr>
- <td> {t}sudoCommand{/t}{$must} </td>
- <td> <input type="text" name="sudoCommand" value="{$sudoCommand}"> </td>
- </tr>
- <tr>
- <td> {t}sudoRunAs{/t}{$must} </td>
- <td> <input type="text" name="sudoRunAs" value="{$sudoRunAs}"> </td>
- </tr>
- <tr>
- <td> {t}sudoOption{/t}{$must} </td>
- <td> <input type="text" name="sudoOption" value="{$sudoOption}"> </td>
- </tr>
-</table>
-<div style="text-align:right;" align="right">
- <p>
- <input type="submit" name="SaveRoleChanges" value="{t}Save{/t}">
- <input type="submit" name="CancelRoleChanges" value="{t}Cancel{/t}">
- </p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('roleName');
- -->
-</script>