Code

Fixed spelling
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
1 <?php
3 class printgeneric extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary      = "Manage terminal base objects";
7   var $cli_description  = "Some longer text\nfor help";
8   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* Generic terminal attributes */
11   var $interfaces     = array();
12   var $ignore_account = FALSE;
14   /* Needed values and lists */
15   var $base             = "";
16   var $cn               = "";
17   var $l                = "";
18   var $description      = "";
19   var $labeledURI       = "";
20   var $gotoPrinterPPD   = "";
21   var $orig_dn          = "";
23   var $UserMember       ="";
24   var $UserMembers      =array();
25   var $UserMemberKeys   =array();
27   var $AdminMember      ="";
28   var $AdminMembers     =array();
29   var $AdminMemberKeys  =array();
31   var $gotoUserPrinter ;
32   var $PPDdialogToSave  = NULL;
33   var $BelongsTo        = "unknown"; //  Specifies if this is a standalone printer, or belongs to a terminal / WS
35   var $member           =array();
36   var $strings          = "";
37   var $dialog           =NULL;
39   var $netConfigDNS;
40   var $baseSelection    = false;
41   var $macAddress       = "";
43   /* attribute list for save action */
44   var $attributes     = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress");
45   var $objectclasses  = array("top", "gotoPrinter");
47   function printgeneric ($config, $dn= NULL,$parent = NULL)
48   {
49     $this->config = $config;
50     $this->dn = $dn; 
51     
52     /* If parent was posted(the tabs object) we can detect the printer type. */
53     if($parent){
54       $this->parent = $parent;
55       $this->getTypeOfPrinter();
56     }else{
57       $this->BelongsTo = "unknown";
58       return;
59     }
61     /* Update dn, to ensure storing as printer instead of WS / terminal */
62     if($this->BelongsTo == "Terminal"){
63       $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
64     }
66     if($this->BelongsTo == "Workstation"){
67       $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
68     }
70     $this->orig_dn = $this->dn;
72     /* Get printer settings, possibly dn has changed */
73     plugin::plugin ($config, $this->dn);
75     /* Get is_account initially_was_account status */
76     $this->getTypeOfPrinter(true);
78     /* set orig dn to new if object is new */
79     $ldap= $this->config->get_ldap_link();
80     $ldap->cat($this->dn);
81     if(!$ldap->count()){
82       $this->orig_dn = "new";
83     }
84     
85     /* create dns object */
86     $this->netConfigDNS = new termDNS($this->config, $this->dn,$this->objectclasses);
88     /* Set base */
89     if ($this->dn == "new"){
90       $ui= get_userinfo();
91       $this->base= dn2base($ui->dn);
92       $this->cn= "";
93     } else {
94     
95       /* Set base and check if the extracted base exists */
96       $this->base= preg_replace("/ou=printers,ou=systems,/","",dn2base($this->dn));
97       if(!isset($this->config->idepartments[$this->base])){
98         print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),$_SESSION['CurrentMainBase']);
99         $this->base = $_SESSION['CurrentMainBase'];
100       }
101     }
103     /* Extract selected ppd */
104     if(isset($this->gotoPrinterPPD)){
105       $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
106     }
108     /* Prepare different member types */ 
109     foreach(array("AddUser"       =>"gotoUserPrinter",
110           "AddGroup"      =>"gotoGroupPrinter",
111           "AddAdminUser"  =>"gotoUserAdminPrinter",
112           "AddAdminGroup" =>"gotoGroupAdminPrinter") as $type => $attr){
114       /* $this->members contains all members */
115       $this->member[$type]=array();
117       if (isset($this->attrs[$attr]['count'])) {
118         unset($this->attrs[$attr]['count']);
119       }
121       if(isset($this->attrs[$attr])){
122         foreach($this->attrs[$attr] as $mem){
123           if(preg_match("/Group/",$type)){
124             $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description"));
125             $entry = $ldap->fetch();
126             if(isset($entry['description'])){
127               $this->member[$type][$entry['cn'][0]]=$entry;
128             }
129           }else{
130             $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid"));
131             $entry = $ldap->fetch();
132             if(isset($entry['uid'])){
133               $this->member[$type][$entry['uid'][0]]=$entry;
134             }
135           }
136         }
137       }
138     }
139   }
142   /* Detect type of printer.
143    * Printer can be stand alone, belong to a workstation or belong to a terminal. 
144    * We can detect the type printer type when comparing the tabs objects
145    */
146   function getTypeOfPrinter($UpdateAccountStatus = false)
147   {
148     /* Disable account as default
149      */  
150     $this->is_account = $this->initially_was_account = false;
152     /* Detect type of printer via parent tabs.
153      */
154     if(isset($this->parent->by_object['workgeneric'])){
156       /* Exclude templates 
157        */
158       $this->cn = $this->parent->by_object['workgeneric']->cn;
159       if($this->parent->by_object['workgeneric']->cn == "wdefault"){
160         $this->BelongsTo = "WorkstationTemplate";
161       }else{
162         $this->BelongsTo = "Workstation";
163       }
164     }elseif(isset($this->parent->by_object['termgeneric'])){
166       /* Exclude templates 
167        */
168       $this->cn = $this->parent->by_object['termgeneric']->cn;
169       if($this->parent->by_object['termgeneric']->cn == "default"){
170         $this->BelongsTo = "TerminalTemplate";  
171       }else{
172         $this->BelongsTo = "Terminal";
173       }
174     }elseif(isset($this->parent->by_name['printgeneric'])){
175       $this->BelongsTo  = "Printer";
176     }
178     if($UpdateAccountStatus){
180       /* Set is_account / was account 
181        */
182       if($this->dn == "new"){
183         $this->initially_was_account = false;
184       }
186       /* If is printer it must be a true account.
187        */
188       if($this->BelongsTo == "Printer"){
189         $this->is_account = true;
190       }
192       /* Update dn, to ensure storing as printer instead of WS / terminal
193        */
194       if($this->BelongsTo == "Terminal"){
195         $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
196       }
198       if($this->BelongsTo == "Workstation"){
199         $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
200       }
202       /* Detect if this is a valid printer account;
203        */
204       $ldap = $this->config->get_ldap_link();
205       $ldap->cd($this->config->current['BASE']);
206       $ldap->cat($this->dn);
208       if($ldap->count()){
209         $attrs = $ldap->fetch();
210         if(in_array("gotoPrinter",$attrs['objectClass'])){
211           $this->initially_was_account = true;
212           $this->is_account             = true;
213         }else{
214           $this->is_account = false;
215         }
216       }
217     }
218   }
220   function execute()
221   {
222     /* Call parent execute */
223     plugin::execute();
225     /* If type of printer couldn't be detected (because of missing parent object in construction) 
226      * hide this tab.
227      */
228     if($this->BelongsTo == "unknown"){
229       $display= $this->show_header(_("Add printer extension"),
230           _("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
231       return($display);
232     }
234     /* Templates can't have printer extensions 
235      */
236     if($this->BelongsTo == "WorkstationTemplate"){
237       $display= $this->show_header(_("Add printer extension"),
238           _("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
239       return($display);
240     }
241     if($this->BelongsTo == "TerminalTemplate"){
242       $display= $this->show_header(_("Add printer extension"),
243           _("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
244       return($display);
245     }
247     /* Get cn from base object */
248     if($this->BelongsTo == "Workstation"){
249       $this->cn = $this->parent->by_object['workgeneric']->cn;
250     }
251     if($this->BelongsTo == "Terminal"){
252       $this->cn = $this->parent->by_object['termgeneric']->cn;
253     }
255     $smarty= get_smarty();
256     $display="";
258     /* Tell smarty if this is a standalone object or a terminal / WS depending printer */
259     if($this->BelongsTo == "Printer"){    
260       $smarty->assign("StandAlone",true);
261     }else{
262       $smarty->assign("StandAlone",false);
263     }
265     /* Do we need to flip is_account state? */
266     if (isset($_POST['modify_state'])){
267       $this->is_modified = true;
268       $this->is_account= !$this->is_account;
269     }
271     /* Do we represent a valid printer? */
272     if (!$this->is_account && $this->parent == NULL){
273       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
274         _("This 'dn' has no printer features.")."</b>";
275       return($display);
276     }
278     /* If this is a WS / Terminal depending printer, display account state button */
279     if($this->BelongsTo != "Printer"){
280       if((empty($this->cn)) && ($this->dn != "new")){
281         $display= $this->show_header(_("Add printer extension"),
282             _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
283         $this->is_account= false;
284         return $display;
285       }
287       if (($this->is_account)){
288         if($this->BelongsTo=="Workstation"){
289           $display= $this->show_header(_("Remove printer extension"),
290               _("This workstation has printer extension enabled.You can disable it by clicking below."));
291         }elseif($this->BelongsTo=="Terminal"){
292           $display= $this->show_header(_("Remove printer extension"),
293               _("This terminal has printer extension enabled. You can disable it by clicking below."));
294         }
295       }else{
296         if($this->BelongsTo=="Workstation"){
297           $display= $this->show_header(_("Add printer extension"),
298               _("This workstation has printer extension disabled. You can enable it by clicking below."));
299         }elseif($this->BelongsTo=="Terminal"){
300           $display= $this->show_header(_("Add printer extension"),
301               _("This terminal has printer extension disabled. You can enable it by clicking below."));
302         }  
303         return ($display);
304       }
305     }
307     /* Base select dialog */
308     $once = true;
309     foreach($_POST as $name => $value){
310       if(preg_match("/^chooseBase/",$name) && $once){
311         $once = false;
312         $this->dialog = new baseSelectDialog($this->config);
313         $this->dialog->setCurrentBase($this->base);
314         $this->baseSelection = true;
315       }
316     }
318     /* Dialog handling for base select dialog
319      * Check if base was selected, dialog aborted etc */
320     if(is_object($this->dialog)){
322       $this->dialog->save_object();
323       if($this->baseSelection){
324         if($this->dialog->isClosed()){
325           $this->dialog = false;
326           $this->baseSelection = false;
327         }elseif($this->dialog->isSelected()){
328           $this->base = $this->dialog->isSelected();
329           $this->dialog= false;
330           $this->baseSelection = false;
331         }else{
332           return($this->dialog->execute());
333         }
334       }
335     }
337     /* Fill templating stuff */
338     $smarty->assign("bases", $this->config->idepartments);
339     $smarty->assign("base_select", $this->base);
341     /* Assign attributes */
342     foreach ($this->attributes as $attr){
343       $smarty->assign($attr."ACL", chkacl($this->acl, $attr));
344       $smarty->assign("$attr", $this->$attr);
345     }
347     if(isset($_POST['AddUser'])){
348       $this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddUser");
349     }
350     if(isset($_POST['AddGroup'])){
351       $this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddGroup");
352     }
353     if(isset($_POST['AddAdminUser'])){
354       $this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddAdminUser");
355     }
356     if(isset($_POST['AddAdminGroup'])){
357       $this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddAdminGroup");
358     }
360     /* Display ppd configure/select dialog      */
361     if(isset($_POST['EditDriver'])){
362       if($this->PPDdialogToSave){
363         $this->dialog = $this->PPDdialogToSave;
364       }else{
365         $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
366       }
367     }
369     /* remove ppd */
370     if(isset($_POST['RemoveDriver'])){
371       $this->gotoPrinterPPD = array();
372       $this->PPDdialogToSave = NULL;
373     }
375     /* Close ppd dialog */
376     if(isset($_POST['ClosePPD'])){
377       unset($this->dialog);
378       $this->dialog=NULL;
379     }
381     /* Save selected ppd */
382     if(isset($_POST['SavePPD'])){
383       $this->dialog->save_object();
384       if(count($this->dialog->check())){
385         foreach($this->dialog->check() as $msg){
386           print_red($msg);
387         }
388       }else{
389         $this->gotoPrinterPPD = array();
390         $this->gotoPrinterPPD = $this->dialog->save();
391         $this->PPDdialogToSave = $this->dialog;
392         unset($this->dialog);
393         $this->dialog=NULL;
394       }
395     }
397     /* Member management, delete user / group / admin ..*/
398     if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
399       if(isset($this->member['AddUser'][$_POST['UserMember']])){
400         unset($this->member['AddUser'][$_POST['UserMember']]);
401       }
402     }
404     if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
405       if(isset($this->member['AddGroup'][$_POST['UserMember']])){
406         unset($this->member['AddGroup'][$_POST['UserMember']]);
407       }
408     }
410     if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
411       if(isset($this->member['AddAdminUser'][$_POST['AdminMember']])){
412         unset($this->member['AddAdminUser'][$_POST['AdminMember']]);
413       }
414     }
416     if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
417       if(isset($this->member['AddAdminGroup'][$_POST['AdminMember']])){
418         unset($this->member['AddAdminGroup'][$_POST['AdminMember']]);
419       }
420     }
422     /* Abort user / group adding dialog */
423     if(isset($_POST['PrinterCancel'])){
424       unset($this->dialog);
425       $this->dialog= NULL;
426     }
428     /* Save selected users / groups */
429     if(isset($_POST['PrinterSave'])){
430       $this->dialog->save_object();
431       if(count($this->dialog->check())){
432         foreach($this->dialog->check() as $msg){
433           print_red($msg);
434         }
435       }else{
436         $new = $this->dialog->save();
437         $data = $new;
438         unset($data['type']);
440         if(preg_match("/User/",$new['type'])){
441           $use = "uid";
442         }else{
443           $use = "cn";
444         }
446         foreach($data as $mem){
447           $this->member[$new['type']][$mem[$use][0]]=$mem;    
448         }
449         unset($this->dialog);
450         $this->dialog=NULL; 
451       }
452     }
454     /* Display dialog, if there is currently one open*/
455     if($this->dialog != NULL){
456       $this->dialog->save_object();
457       $display = $this->dialog->execute();
458       return $display;
459     }
461     /* Parse selected ppd file */
462     require_once ("class_ppdManager.inc");
463     if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){
465       $path = $_SESSION['config']->data['MAIN']['PPD_PATH'];
466       if(!preg_match("/\/$/",$path)){
467         $path = $path."/";
468       }
470       $ppdManager= new ppdManager($path);
471       if(!empty($this->gotoPrinterPPD)){
472         if((!file_exists($path.$this->gotoPrinterPPD))){
473           $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$this->gotoPrinterPPD))."</b>";
474         }else{
475           $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
476         }
477       }else{
478         $smarty->assign("driverInfo", _("not defined"));
479       }
480     }else{
481       $smarty->assign("driverInfo",_("can't get ppd informations."));
482     }
484     /* Create user & admin user list */
485     $list=$this->generateList();
486     $userlist   = array_merge($list['AddUser'],$list['AddGroup']);
487     $adminlist  = array_merge($list['AddAdminUser'],$list['AddAdminGroup']);
489     asort($userlist);
490     asort($adminlist);
492     if($this->BelongsTo != "Printer"){
493       if($this->BelongsTo == "Terminal"){
494         $smarty->assign("desc"    ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
495       }else{
496         $smarty->assign("desc"    ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
497       }
498       $smarty->assign("cnACL"    ," disabled ");
499     }else{
500       $smarty->assign("desc"    ,"");
501     }
502     $smarty->assign("UserMember"    ,$this->UserMember);
503     $smarty->assign("UserMembers"   ,$userlist);
504     $smarty->assign("UserMemberKeys",array_flip($userlist));
506     $smarty->assign("AdminMember"    ,$this->AdminMember);
507     $smarty->assign("AdminMembers"   ,$adminlist);
508     $smarty->assign("AdminMemberKeys",array_flip($adminlist));
509     $smarty->assign("netconfig", $this->netConfigDNS->execute());
511     return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
512   }
514   function remove_from_parent()
515   {
516     /* Only remove if there was initially an account */
517     if($this->initially_was_account){
519       /* Update dn, to ensure storing as printer instead of WS / terminal
520        */
521       if($this->BelongsTo == "Terminal"){
522         $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
523       }
525       if($this->BelongsTo == "Workstation"){
526         $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
527       }
529       /* Check if this dn points to a printer, to avoid deleting something else */
530       $ldap= $this->config->get_ldap_link();
531       $ldap->cat($this->dn);
532       if(!$ldap->count()){
533         print_red("Trying to remove printer obejct which isn't a printer. Aborted to avoid data loss.");
534         return;
535       }
537       /* Check if obejct is a printer */
538       $CheckPrinter = $ldap->fetch();
539       if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){
540         print_red("Trying to remove printer obejct which isn't a printer. Aborted to avoid data loss.");
541         return;
542       }
544       /* Remove account & dns extension */ 
545       $this->netConfigDNS->remove_from_parent();
546       $ldap->rmdir($this->dn);
547       show_ldap_error($ldap->get_error());
548       $this->handle_post_events("remove");
550       /* Delete references to object groups */
551       $ldap->cd ($this->config->current['BASE']);
552       $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
553       while ($ldap->fetch()){
554         $og= new ogroup($this->config, $ldap->getDN());
555         unset($og->member[$this->dn]);
556         $og->save ();
557       }
558     }
559   }
562   /* Save data to object */
563   function save_object()
564   {
565     plugin::save_object();
566     $this->netConfigDNS->save_object();
567     /* Save base, since this is no LDAP attribute */
568     if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
569       $this->base= $_POST['base'];
570     }
571   }
573   /* Check supplied data */
574   function check()
575   {
576     /* Call common method to give check the hook */
577     $message= plugin::check();
578     $message= array_merge($message, $this->netConfigDNS->check());
580     /* Don't display check messages if this is a template object */
581     if(isset($this->parent->by_object['workgeneric'])){
582       if($this->parent->by_object['workgeneric']->cn == "wdefault"){
583         return $message;
584       }
585     }elseif(isset($this->parent->by_object['termgeneric'])){
586       if($this->parent->by_object['termgeneric']->cn == "default"){
587         return $message;
588       }
589     }
591     $dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
593     /* must: cn */
594     if(($this->BelongsTo == "Printer") && (empty($this->cn))){
595       $message[]= "The required field 'Printer name' is not set.";
596     }
597     
598     /* Check if there is already an entry with this cn*/
599     if (($this->orig_dn != $dn)&&($this->BelongsTo == "Printer")){
600       $ldap= $this->config->get_ldap_link();
601       $ldap->cd ($this->base);
602       $ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
603       if ($ldap->count() != 0){
604         while ($attrs= $ldap->fetch()){
605           if ($attrs['dn'] != $this->orig_dn){
606             $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
607             break;
608           }
609         }
610       }
611     }
613     return ($message);
614   }
617   /* Save to LDAP */
618   function save()
619   {
620     /* Update dn, to ensure storing as printer instead of WS / terminal
621      */
622     if($this->BelongsTo == "Terminal"){
623       $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
624     }
626     if($this->BelongsTo == "Workstation"){
627       $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
628     }
629     
630     if(!$this->is_account) return;
631     if(isset($this->parent->by_object['workgeneric'])){
632       if($this->parent->by_object['workgeneric']->cn == "wdefault"){
633         return;
634       }
635     }elseif(isset($this->parent->by_object['termgeneric'])){
636       if($this->parent->by_object['termgeneric']->cn == "default"){
637         return;
638       }
639     }
641     /* If type is still unknown, the initialisation of this printer failed, abort. */
642     if($this->BelongsTo == "unknown"){
643       return;
644     }
646     /* save ppd configuration */
647     if($this->PPDdialogToSave){
648       $this->PPDdialogToSave->save_ppd();
649     }
651     $dn= $this->dn;
652     plugin::save();
653     $ldap= $this->config->get_ldap_link();
655     /* reduce objectClasses to minimun */
656     $this->attrs['objectClass']= $this->objectclasses;
658     /* Remove all empty values */
659     if ($this->orig_dn == 'new'){
660       $attrs= array();
661       foreach ($this->attrs as $key => $val){
662         if (is_array($val) && count($val) == 0){
663           continue;
664         }
665         $attrs[$key]= $val;
666       }
667       $this->attrs= $attrs;
668     }
670     if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
671       $method="https://";
672     }else{
673       $method="http://";
674     }
675   
676     $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
678     /* Append printer user 
679      */
680     if((isset($this->attrs['gotoUserPrinter'])) && (is_string($this->attrs['gotoUserPrinter']))){
681       $this->attrs['gotoUserPrinter']=array();
682     }
683     foreach($this->member['AddUser'] as $mem){
684       $this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
685     }
687     /* Append printer group 
688      */
689     foreach($this->member['AddGroup'] as $mem){
690       $this->attrs['gotoGroupPrinter'][]=$mem['cn'][0];
691     }
693     /* Append printer admin user 
694      */
695     foreach($this->member['AddAdminUser'] as $mem){
696       $this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0];
697     }
699     /* Append printer admin group 
700      */
701     foreach($this->member['AddAdminGroup'] as $mem){
702       $this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
703     }
705     /* Write back to ldap */
706     $ldap= $this->config->get_ldap_link();
707     if ($this->orig_dn == 'new'){
708       $ldap->cd($this->config->current['BASE']);
709       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
710       $ldap->cd($this->dn);
711       $ldap->add($this->attrs);
712       $this->handle_post_events("add");
713     } else {
714       if ($this->orig_dn != $this->dn){
715         $this->move($this->orig_dn, $this->dn);
716       }
718       $ldap->cd($this->dn);
719       $this->cleanup();
720       $ldap->modify ($this->attrs); 
722       $this->handle_post_events("modify");
723     }
724     show_ldap_error($ldap->get_error());
726     $this->netConfigDNS->cn = $this->cn;
727     $this->netConfigDNS->dn = $this->dn;
728     $this->netConfigDNS->save($this->dn);
730     /* Optionally execute a command after we're done */
731     $this->postcreate();
732   }
734   function generateList(){
735     $a_return=array();
736     foreach($this->member as $type => $values){
737       $a_return[$type]=array();
738       foreach($values as $value){
739         if((preg_match("/Group/i",$type))){
740           if(!isset($value['description'])){
741             $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0];
742           }else{
743             $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]." [".$value['description'][0]."]";
744           }
745         }else{
746           $a_return[$type][$value['uid'][0]]=_("User")." : ".$value['cn'][0];
747         }
748       }
749     }
750     return($a_return);
751   }
756 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
757 ?>