From: hickert Date: Fri, 11 Apr 2008 09:12:41 +0000 (+0000) Subject: Allow copy & paste for profiles X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=62749c66a77826037776fb0ee2f40602d264fd5d;p=gosa.git Allow copy & paste for profiles git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10350 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_faiProfile.inc b/gosa-plugins/fai/admin/fai/class_faiProfile.inc index c6c4c2f53..212ea1dde 100644 --- a/gosa-plugins/fai/admin/fai/class_faiProfile.inc +++ b/gosa-plugins/fai/admin/fai/class_faiProfile.inc @@ -398,23 +398,18 @@ class faiProfile extends plugin $message[]= msgPool::invalid(_("Name")); } - $ldap = $this->config->get_ldap_link(); - $faifilter = session::get('faifilter'); - $base = $faifilter['branch']; - if($base == "main"){ - $base = session::get('CurrentMainBase'); - } - $base = get_ou('faiprofileou').$base; - - $ldap->cd($base); - if ($this->old_cn == ""){ - $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn."))",$base,array("*")); - } else { - $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",$base,array("*")); - } - - if($ldap->count() || isset($this->FAIAllclasses[$this->cn])){ - $message[]= msgPool::duplicated(_("Name")); + /* Ensure that we do not overwrite an allready existing entry + */ + if($this->dn == "new" || $this->cn != $this->old_cn){ + $new_dn= 'cn='.$this->cn.",".get_ou('faiprofileou').get_ou('faiou').session::get('CurrentMainBase'); + $faifilter = session::get('faifilter'); + if($faifilter['branch']!="main"){ + $new_dn ='cn='.$this->cn.",".get_ou('faiprofileou').$faifilter['branch']; + } + $res = faiManagement::check_class_name("FAIprofile",$this->cn,$new_dn); + if(isset($res[$this->cn])){ + $message[] = msgPool::duplicated(_("Name")); + } } return ($message); @@ -484,6 +479,34 @@ class faiProfile extends plugin "FAIclass" => _("FAI classes")) )); } + + + /*! \brief Used for copy & paste. + Returns a HTML input mask, which allows to change the cn of this entry. + @param Array Array containing current status && a HTML template. + */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn", htmlentities($this->cn)); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + /*! \brief Used for copy & paste. + Some entries must be renamed to avaoid duplicate entries. + */ + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = get_post('cn'); + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: