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;
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, array('dn'));
81 if(!$ldap->count()){
82 $this->orig_dn = "new";
83 }
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 {
95 /* Set base and check if the extracted base exists */
96 if(preg_match("/ou=incoming,/",$this->dn)){
97 $this->base= preg_replace("/ou=incoming,/","",dn2base($this->dn));
98 }else{
99 $this->base= preg_replace("/ou=printers,ou=systems,/","",dn2base($this->dn));
100 }
102 if(!isset($this->config->idepartments[$this->base])){
103 print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),$_SESSION['CurrentMainBase']);
104 $this->base = $_SESSION['CurrentMainBase'];
105 }
106 }
108 /* Extract selected ppd */
109 if(isset($this->gotoPrinterPPD)){
110 $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
111 }
113 /* Prepare different member types */
114 foreach(array("AddUser" =>"gotoUserPrinter",
115 "AddGroup" =>"gotoGroupPrinter",
116 "AddAdminUser" =>"gotoUserAdminPrinter",
117 "AddAdminGroup" =>"gotoGroupAdminPrinter") as $type => $attr){
119 /* $this->members contains all members */
120 $this->member[$type]=array();
122 if (isset($this->attrs[$attr]['count'])) {
123 unset($this->attrs[$attr]['count']);
124 }
126 if(isset($this->attrs[$attr])){
127 foreach($this->attrs[$attr] as $mem){
128 if(preg_match("/Group/",$type)){
129 $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description"));
130 $entry = $ldap->fetch();
131 $this->member[$type][$entry['cn'][0]]=$entry;
132 }else{
133 $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid"));
134 $entry = $ldap->fetch();
135 if(isset($entry['uid'])){
136 $this->member[$type][$entry['uid'][0]]=$entry;
137 }
138 }
139 }
140 }
141 }
142 }
145 /* Detect type of printer.
146 * Printer can be stand alone, belong to a workstation or belong to a terminal.
147 * We can detect the type printer type when comparing the tabs objects
148 */
149 function getTypeOfPrinter($UpdateAccountStatus = false)
150 {
151 /* Disable account as default
152 */
153 $this->is_account = $this->initially_was_account = false;
155 /* Detect type of printer via parent tabs.
156 */
157 if(isset($this->parent->by_object['workgeneric'])){
159 /* Exclude templates
160 */
161 $this->cn = $this->parent->by_object['workgeneric']->cn;
162 if($this->parent->by_object['workgeneric']->cn == "wdefault"){
163 $this->BelongsTo = "WorkstationTemplate";
164 }else{
165 $this->BelongsTo = "Workstation";
166 }
167 }elseif(isset($this->parent->by_object['termgeneric'])){
169 /* Exclude templates
170 */
171 $this->cn = $this->parent->by_object['termgeneric']->cn;
172 if($this->parent->by_object['termgeneric']->cn == "default"){
173 $this->BelongsTo = "TerminalTemplate";
174 }else{
175 $this->BelongsTo = "Terminal";
176 }
177 }elseif(isset($this->parent->by_name['printgeneric'])){
178 $this->BelongsTo = "Printer";
179 }
181 if($UpdateAccountStatus){
183 /* Set is_account / was account
184 */
185 if($this->dn == "new"){
186 $this->initially_was_account = false;
187 }
189 /* If is printer it must be a true account.
190 */
191 if($this->BelongsTo == "Printer"){
192 $this->is_account = true;
193 }
195 /* Update dn, to ensure storing as printer instead of WS / terminal
196 */
197 if($this->BelongsTo == "Terminal"){
198 $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
199 }
201 if($this->BelongsTo == "Workstation"){
202 $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
203 }
205 /* Detect if this is a valid printer account;
206 */
207 //FIXME: do we need to do this? we've already everything we need in $this->attrs...
208 $ldap = $this->config->get_ldap_link();
209 $ldap->cat($this->dn, array('objectClass'));
211 if($ldap->count()){
212 $attrs = $ldap->fetch();
213 if(in_array("gotoPrinter",$attrs['objectClass'])){
214 $this->initially_was_account = true;
215 $this->is_account = true;
216 }else{
217 $this->is_account = false;
218 }
219 }
220 }
221 }
223 function execute()
224 {
225 /* Call parent execute */
226 plugin::execute();
228 /* If type of printer couldn't be detected (because of missing parent object in construction)
229 * hide this tab.
230 */
231 if($this->BelongsTo == "unknown"){
232 $display= $this->show_header(_("Add printer extension"),
233 _("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
234 return($display);
235 }
237 /* Templates can't have printer extensions
238 */
239 if($this->BelongsTo == "WorkstationTemplate"){
240 $display= $this->show_header(_("Add printer extension"),
241 _("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
242 return($display);
243 }
244 if($this->BelongsTo == "TerminalTemplate"){
245 $display= $this->show_header(_("Add printer extension"),
246 _("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
247 return($display);
248 }
250 /* Get cn from base object */
251 if($this->BelongsTo == "Workstation"){
252 $this->cn = $this->parent->by_object['workgeneric']->cn;
253 }
254 if($this->BelongsTo == "Terminal"){
255 $this->cn = $this->parent->by_object['termgeneric']->cn;
256 }
258 $smarty= get_smarty();
259 $display="";
261 /* Tell smarty if this is a standalone object or a terminal / WS depending printer */
262 if($this->BelongsTo == "Printer"){
263 $smarty->assign("StandAlone",true);
264 }else{
265 $smarty->assign("StandAlone",false);
266 }
268 /* Do we need to flip is_account state? */
269 if (isset($_POST['modify_state'])){
270 $this->is_modified = true;
271 $this->is_account= !$this->is_account;
272 }
274 /* Do we represent a valid printer? */
275 if (!$this->is_account && $this->parent == NULL){
276 $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
277 _("This 'dn' has no printer features.")."</b>";
278 return($display);
279 }
281 /* If this is a WS / Terminal depending printer, display account state button */
282 if($this->BelongsTo != "Printer"){
283 if((empty($this->cn)) && ($this->dn != "new")){
284 $display= $this->show_header(_("Add printer extension"),
285 _("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);
286 $this->is_account= false;
287 return $display;
288 }
290 if (($this->is_account)){
291 if($this->BelongsTo=="Workstation"){
292 $display= $this->show_header(_("Remove printer extension"),
293 _("This workstation has printer extension enabled.You can disable it by clicking below."));
294 }elseif($this->BelongsTo=="Terminal"){
295 $display= $this->show_header(_("Remove printer extension"),
296 _("This terminal has printer extension enabled. You can disable it by clicking below."));
297 }
298 }else{
299 if($this->BelongsTo=="Workstation"){
300 $display= $this->show_header(_("Add printer extension"),
301 _("This workstation has printer extension disabled. You can enable it by clicking below."));
302 }elseif($this->BelongsTo=="Terminal"){
303 $display= $this->show_header(_("Add printer extension"),
304 _("This terminal has printer extension disabled. You can enable it by clicking below."));
305 }
306 return ($display);
307 }
308 }
310 /* Base select dialog */
311 $once = true;
312 foreach($_POST as $name => $value){
313 if(preg_match("/^chooseBase/",$name) && $once){
314 $once = false;
315 $this->dialog = new baseSelectDialog($this->config,$this);
316 $this->dialog->setCurrentBase($this->base);
317 $this->baseSelection = true;
318 }
319 }
321 /* Dialog handling for base select dialog
322 * Check if base was selected, dialog aborted etc */
323 if(is_object($this->dialog)){
325 $this->dialog->save_object();
326 if($this->baseSelection){
327 if($this->dialog->isClosed()){
328 $this->dialog = false;
329 $this->baseSelection = false;
330 }elseif($this->dialog->isSelected()){
331 $this->base = $this->dialog->isSelected();
332 $this->dialog= false;
333 $this->baseSelection = false;
334 }else{
335 return($this->dialog->execute());
336 }
337 }
338 }
340 /* Fill templating stuff */
341 $smarty->assign("bases", $this->config->idepartments);
342 $smarty->assign("base_select", $this->base);
344 /* Assign attributes */
345 foreach ($this->attributes as $attr){
346 $smarty->assign($attr."ACL", chkacl($this->acl, $attr));
347 $smarty->assign("$attr", $this->$attr);
348 }
350 $smarty->assign("baseACL", chkacl($this->acl,"base"));
352 if(isset($_POST['AddUser'])){
353 $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser");
354 }
355 if(isset($_POST['AddGroup'])){
356 $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup");
357 }
358 if(isset($_POST['AddAdminUser'])){
359 $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser");
360 }
361 if(isset($_POST['AddAdminGroup'])){
362 $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup");
363 }
365 /* Display ppd configure/select dialog */
366 if(isset($_POST['EditDriver'])){
367 if($this->PPDdialogToSave){
368 $this->dialog = $this->PPDdialogToSave;
369 }else{
370 $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
371 }
372 }
374 /* remove ppd */
375 if(isset($_POST['RemoveDriver'])){
376 $this->gotoPrinterPPD = array();
377 $this->PPDdialogToSave = NULL;
378 }
380 /* Close ppd dialog */
381 if(isset($_POST['ClosePPD'])){
382 unset($this->dialog);
383 $this->dialog=NULL;
384 }
386 /* Save selected ppd */
387 if(isset($_POST['SavePPD'])){
388 $this->dialog->save_object();
389 if(count($this->dialog->check())){
390 foreach($this->dialog->check() as $msg){
391 print_red($msg);
392 }
393 }else{
394 $this->gotoPrinterPPD = array();
395 $this->gotoPrinterPPD = $this->dialog->save();
396 $this->PPDdialogToSave = $this->dialog;
397 unset($this->dialog);
398 $this->dialog=NULL;
399 }
400 }
402 /* Member management, delete user / group / admin ..*/
403 if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
404 if(isset($this->member['AddUser'][$_POST['UserMember']])){
405 unset($this->member['AddUser'][$_POST['UserMember']]);
406 }
407 }
409 if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
410 if(isset($this->member['AddGroup'][$_POST['UserMember']])){
411 unset($this->member['AddGroup'][$_POST['UserMember']]);
412 }
413 }
415 if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
416 if(isset($this->member['AddAdminUser'][$_POST['AdminMember']])){
417 unset($this->member['AddAdminUser'][$_POST['AdminMember']]);
418 }
419 }
421 if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
422 if(isset($this->member['AddAdminGroup'][$_POST['AdminMember']])){
423 unset($this->member['AddAdminGroup'][$_POST['AdminMember']]);
424 }
425 }
427 /* Abort user / group adding dialog */
428 if(isset($_POST['PrinterCancel'])){
429 unset($this->dialog);
430 $this->dialog= NULL;
431 }
433 /* Save selected users / groups */
434 if(isset($_POST['PrinterSave'])){
435 $this->dialog->save_object();
436 if(count($this->dialog->check())){
437 foreach($this->dialog->check() as $msg){
438 print_red($msg);
439 }
440 }else{
441 $new = $this->dialog->save();
442 $data = $new;
443 unset($data['type']);
445 if(preg_match("/User/",$new['type'])){
446 $use = "uid";
447 }else{
448 $use = "cn";
449 }
451 foreach($data as $mem){
452 $this->member[$new['type']][$mem[$use][0]]=$mem;
453 }
454 unset($this->dialog);
455 $this->dialog=NULL;
456 }
457 }
459 /* Display dialog, if there is currently one open*/
460 if($this->dialog != NULL){
461 $this->dialog->save_object();
462 $display = $this->dialog->execute();
463 return $display;
464 }
466 /* Parse selected ppd file */
467 require_once ("class_ppdManager.inc");
468 if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){
470 $path = $_SESSION['config']->data['MAIN']['PPD_PATH'];
471 if(!preg_match("/\/$/",$path)){
472 $path = $path."/";
473 }
475 $ppdManager= new ppdManager($path);
476 if(!empty($this->gotoPrinterPPD)){
477 if((!file_exists($path.$this->gotoPrinterPPD))){
478 $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD))."</b>";
479 }else{
480 $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
481 }
482 }else{
483 $smarty->assign("driverInfo", _("not defined"));
484 }
485 }else{
486 $smarty->assign("driverInfo",_("can't get ppd informations."));
487 }
489 /* Create user & admin user list */
490 $list=$this->generateList();
491 $userlist = array_merge($list['AddUser'],$list['AddGroup']);
492 $adminlist = array_merge($list['AddAdminUser'],$list['AddAdminGroup']);
494 asort($userlist);
495 asort($adminlist);
497 if($this->BelongsTo != "Printer"){
498 if($this->BelongsTo == "Terminal"){
499 $smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
500 }else{
501 $smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
502 }
503 $smarty->assign("cnACL" ," disabled ");
504 }else{
505 $smarty->assign("desc" ,"");
506 }
507 $smarty->assign("UserMember" ,$this->UserMember);
508 $smarty->assign("UserMembers" ,$userlist);
509 $smarty->assign("UserMemberKeys",array_flip($userlist));
511 $smarty->assign("AdminMember" ,$this->AdminMember);
512 $smarty->assign("AdminMembers" ,$adminlist);
513 $smarty->assign("AdminMemberKeys",array_flip($adminlist));
514 $smarty->assign("netconfig", $this->netConfigDNS->execute());
516 return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
517 }
519 function remove_from_parent()
520 {
521 /* Only remove if there was initially an account */
522 if($this->initially_was_account){
524 /* Update dn, to ensure storing as printer instead of WS / terminal
525 */
526 if($this->BelongsTo == "Terminal"){
527 $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
528 }
530 if($this->BelongsTo == "Workstation"){
531 $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
532 }
534 /* Check if this dn points to a printer, to avoid deleting something else */
535 $ldap= $this->config->get_ldap_link();
536 $ldap->cat($this->dn, array('dn',"objectClass"));
537 if(!$ldap->count()){
538 print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
539 return;
540 }
542 /* Check if obejct is a printer */
543 $CheckPrinter = $ldap->fetch();
544 if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){
545 print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
546 return;
547 }
549 /* Remove account & dns extension */
550 $this->netConfigDNS->remove_from_parent();
551 $ldap->rmdir($this->dn);
552 show_ldap_error($ldap->get_error(), sprintf(_("Removing of system print/generic with dn '%s' failed."),$this->dn));
553 $this->handle_post_events("remove");
555 /* Delete references to object groups */
556 $ldap->cd ($this->config->current['BASE']);
557 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
558 while ($ldap->fetch()){
559 $og= new ogroup($this->config, $ldap->getDN());
560 unset($og->member[$this->dn]);
561 $og->save ();
562 }
563 }
564 }
567 /* Save data to object */
568 function save_object()
569 {
570 plugin::save_object();
571 $this->netConfigDNS->save_object();
572 /* Save base, since this is no LDAP attribute */
573 if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
574 $this->base= $_POST['base'];
575 }
576 }
578 /* Check supplied data */
579 function check()
580 {
581 /* Call common method to give check the hook */
582 $message= plugin::check();
583 $message= array_merge($message, $this->netConfigDNS->check());
585 /* Don't display check messages if this is a template object */
586 if(isset($this->parent->by_object['workgeneric'])){
587 if($this->parent->by_object['workgeneric']->cn == "wdefault"){
588 return $message;
589 }
590 }elseif(isset($this->parent->by_object['termgeneric'])){
591 if($this->parent->by_object['termgeneric']->cn == "default"){
592 return $message;
593 }
594 }
596 $dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
598 /* must: cn */
599 if(($this->BelongsTo == "Printer") && (empty($this->cn))){
600 $message[]= "The required field 'Printer name' is not set.";
601 }
603 /* must: labeledURI */
604 if(empty($this->labeledURI)){
605 $message[]= "The required field 'Printer URL' is not set.";
606 }
608 /* Check if there is already an entry with this cn*/
609 if (($this->orig_dn != $dn)&&($this->BelongsTo == "Printer")){
610 $ldap= $this->config->get_ldap_link();
611 $ldap->cd ($this->base);
612 $ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
613 if ($ldap->count() != 0){
614 while ($attrs= $ldap->fetch()){
615 if ($attrs['dn'] != $this->orig_dn){
616 $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
617 break;
618 }
619 }
620 }
621 }
623 return ($message);
624 }
627 /* Save to LDAP */
628 function save()
629 {
630 /* Update dn, to ensure storing as printer instead of WS / terminal
631 */
632 if($this->BelongsTo == "Terminal"){
633 $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
634 }
636 if($this->BelongsTo == "Workstation"){
637 $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
638 }
640 if(!$this->is_account) return;
641 if(isset($this->parent->by_object['workgeneric'])){
642 if($this->parent->by_object['workgeneric']->cn == "wdefault"){
643 return;
644 }
645 }elseif(isset($this->parent->by_object['termgeneric'])){
646 if($this->parent->by_object['termgeneric']->cn == "default"){
647 return;
648 }
649 }
651 /* If type is still unknown, the initialisation of this printer failed, abort. */
652 if($this->BelongsTo == "unknown"){
653 return;
654 }
656 /* save ppd configuration */
657 if($this->PPDdialogToSave){
658 $this->PPDdialogToSave->save_ppd();
659 }
661 $dn= $this->dn;
662 plugin::save();
663 $ldap= $this->config->get_ldap_link();
665 /* reduce objectClasses to minimun */
666 $this->attrs['objectClass']= $this->objectclasses;
668 /* Remove all empty values */
669 if ($this->orig_dn == 'new'){
670 $attrs= array();
671 foreach ($this->attrs as $key => $val){
672 if (is_array($val) && count($val) == 0){
673 continue;
674 }
675 $attrs[$key]= $val;
676 }
677 $this->attrs= $attrs;
678 }
680 if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
681 $method="https://";
682 }else{
683 $method="http://";
684 }
686 $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
688 /* Append printer user
689 */
690 if((isset($this->attrs['gotoUserPrinter'])) && (is_string($this->attrs['gotoUserPrinter']))){
691 $this->attrs['gotoUserPrinter']=array();
692 }
693 foreach($this->member['AddUser'] as $mem){
694 $this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
695 }
697 /* Append printer group
698 */
699 foreach($this->member['AddGroup'] as $mem){
700 $this->attrs['gotoGroupPrinter'][]=$mem['cn'][0];
701 }
703 /* Append printer admin user
704 */
705 foreach($this->member['AddAdminUser'] as $mem){
706 $this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0];
707 }
709 /* Append printer admin group
710 */
711 foreach($this->member['AddAdminGroup'] as $mem){
712 $this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
713 }
715 if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
716 $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
717 }
719 /* Write back to ldap */
720 $ldap= $this->config->get_ldap_link();
721 if ($this->orig_dn == 'new'){
722 $ldap->cd($this->config->current['BASE']);
723 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
724 $ldap->cd($this->dn);
725 $ldap->add($this->attrs);
726 $this->handle_post_events("add");
727 } else {
728 if ($this->orig_dn != $this->dn){
729 $this->move($this->orig_dn, $this->dn);
730 }
732 $ldap->cd($this->dn);
733 $this->cleanup();
734 $ldap->modify ($this->attrs);
736 $this->handle_post_events("modify");
737 }
738 show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn));
740 $this->netConfigDNS->cn = $this->cn;
741 $this->netConfigDNS->dn = $this->dn;
742 $this->netConfigDNS->save($this->dn);
744 /* Optionally execute a command after we're done */
745 $this->postcreate();
746 }
748 function generateList(){
749 $a_return=array();
750 foreach($this->member as $type => $values){
751 $a_return[$type]=array();
752 foreach($values as $value){
753 if((preg_match("/Group/i",$type))){
754 if(!isset($value['description'])){
755 $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0];
756 }else{
757 $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]." [".$value['description'][0]."]";
758 }
759 }else{
760 $a_return[$type][$value['uid'][0]]=_("User")." : ".$value['cn'][0];
761 }
762 }
763 }
764 return($a_return);
765 }
766 }
770 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
771 ?>