diff --git a/plugins/admin/fai/class_faiScriptEntry.inc b/plugins/admin/fai/class_faiScriptEntry.inc
index e2148014f10384477609556c510980887142ac0d..f7152fce741510c84ee46cebb3506fe0c266b8e2 100644 (file)
class faiScriptEntry extends plugin
{
/* CLI vars */
class faiScriptEntry extends plugin
{
/* CLI vars */
- var $cli_summary = "Manage server basic objects";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes = array("cn","description","FAIpriority","FAIscript");
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes = array("cn","description","FAIpriority","FAIscript");
- var $objectclasses= array("FAIscriptEntry");
+ var $objectclasses= array();
- var $orig_cn = "";
- var $dn = "";
- var $cn = "";
- var $FAIpriority = "";
- var $FAIscript = "";
- var $description = "";
- var $status = "new";
- var $parent = false;
- var $is_parent_saved = false;
+ var $orig_cn = "";
+
+ var $dn = "";
+ var $cn = "";
+ var $FAIpriority = "0";
+ var $FAIscript = "";
+ var $description = "";
+ var $status = "new";
- function faiScriptEntry ($config, $dn)
+ function faiScriptEntry ($config, $dn= NULL,$object=false)
{
{
- /* Dn is dn currently assigned to this object
- 'new' if object wasn't saved yet
- */
plugin::plugin ($config, $dn);
if($dn != "new"){
plugin::plugin ($config, $dn);
if($dn != "new"){
- $this->orig_cn = $this->cn;
+ $this->orig_cn= $object['cn'];
+ $this->dn=$object['dn'];
+ foreach($object as $name=>$value){
+ $oname = $name;
+ $this->$oname=$value;
+ }
}else{
}else{
- $this->status = "new";
- $this->orig_cn = false;
+ $this->status = "new";
+ $this->orig_cn = false;
}
}
}
}
$this->FAIscript = $str;
}
}
$this->FAIscript = $str;
}
}
+
foreach($this->attributes as $attrs){
if(get_magic_quotes_gpc()){
foreach($this->attributes as $attrs){
if(get_magic_quotes_gpc()){
return($display);
}
return($display);
}
- /* Delete me, and all my subtrees
- */
- function remove_from_parent()
- {
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->dn);
- $ldap->rmdir_recursive($this->dn);
- show_ldap_error($ldap->get_error());
- $this->handle_post_events("remove");
- }
-
-
/* Save data to object */
function save_object()
{
/* Save data to object */
function save_object()
{
$this->$attrs = "";
}
}
$this->$attrs = "";
}
}
+ $this->FAIscript= recode("DOS..LATIN1", $this->FAIscript);
}
}
}
}
$message[] = _("Please enter a name.");
}
$message[] = _("Please enter a name.");
}
- if(preg_match("/[^0-9a-z]/i",$this->cn)){
- $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
+ if(empty($this->FAIscript)){
+ $message[]=_("Please enter a script.");
}
}
-
+
return ($message);
}
function save()
{
return ($message);
}
function save()
{
- plugin::save();
-
- /* Get ldap connection */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->config->current['BASE']);
-
- /* First : Check if parent was already saved ... */
- $ldap->cd($this->parent->dn);
- $ldap->cat($this->parent->dn);
-
- /* no entry was found. So save our base object first */
- if($ldap->count()==0){
- $this->parent->save();
- }
-
- /* Generate this->dn */
- /* if !orig_dn -> This is a new object */
- if($this->orig_cn == false){
- $this->dn = "cn=".$this->cn.",".$this->parent->dn;
- $mode = "add";
- }else{
- /* This is an already existing entry, check if cn was changed */
- if($this->orig_cn != $this->cn ){
- /* rename */
- $ldap->cd($this->dn);
- $ldap->rmdir($this->dn);
- $this->dn = "cn=".$this->cn.",".$this->parent->dn;
- $mode = "add";
- }else{
- /* modify */
- $mode = "modify";
- }
+ $tmp=array();
+ foreach($this->attributes as $attrs){
+ $tmp[$attrs] = $this->$attrs;
}
}
- $ldap->cd($this->config->current['BASE']);
- $ldap->create_missing_trees($this->parent->dn);
- $ldap->cd ($this->dn);
- $ldap->$mode($this->attrs);
- show_ldap_error($ldap->get_error());
+ if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
+ $tmp['remove']['from'] = $this->orig_cn;
+ $tmp['remove']['to'] = $tmp['cn'];
+ }
+
+ $tmp['dn'] = $this->dn;
+ $tmp['status'] = $this->status;
+ return($tmp);
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: