Code

Added scheduleit account acls
[gosa.git] / plugins / personal / generic / class_user.inc
1 <?php
2 /*!
3   \brief   user plugin
4   \author  Cajus Pollmeier <pollmeier@gonicus.de>
5   \version 2.00
6   \date    24.07.2003
8   This class provides the functionality to read and write all attributes
9   relevant for person, organizationalPerson, inetOrgPerson and gosaAccount
10   from/to the LDAP. It does syntax checking and displays the formulars required.
11  */
13 class user extends plugin
14 {
15   /* Definitions */
16   var $plHeadline= "Generic";
17   var $plDescription= "This does something";
19   /* CLI vars */
20   var $cli_summary= "Handling of GOsa's user base object";
21   var $cli_description= "Some longer text\nfor help";
22   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
24   /* Plugin specific values */
25   var $base= "";
26   var $cn= "";
27   var $personalTitle= "";
28   var $academicTitle= "";
29   var $homePostalAddress= "";
30   var $homePhone= "";
31   var $labeledURI= "";
32   var $o= "";
33   var $ou= "";
34   var $departmentNumber= "";
35   var $employeeNumber= "";
36   var $employeeType= "";
37   var $roomNumber= "";
38   var $telephoneNumber= "";
39   var $facsimileTelephoneNumber= "";
40   var $mobile= "";
41   var $pager= "";
42   var $l= "";
43   var $st= "";
44   var $postalAddress= "";
45   var $dateOfBirth;
46   var $use_dob= "0";
47   var $gender="0";
48   var $preferredLanguage="0";
50   var $jpegPhoto= "*removed*";
51   var $photoData= "";
52   var $old_jpegPhoto= "";
53   var $old_photoData= "";
54   var $cert_dialog= FALSE;
55   var $picture_dialog= FALSE;
57   var $userPKCS12= "";
58   var $userSMIMECertificate= "";
59   var $userCertificate= "";
60   var $certificateSerialNumber= "";
61   var $old_certificateSerialNumber= "";
62   var $old_userPKCS12= "";
63   var $old_userSMIMECertificate= "";
64   var $old_userCertificate= "";
66   var $gouvernmentOrganizationalUnit= "";
67   var $houseIdentifier= "";
68   var $street= "";
69   var $postalCode= "";
70   var $vocation= "";
71   var $ivbbLastDeliveryCollective= "";
72   var $gouvernmentOrganizationalPersonLocality= "";
73   var $gouvernmentOrganizationalUnitDescription= "";
74   var $gouvernmentOrganizationalUnitSubjectArea= "";
75   var $functionalTitle= "";
76   var $role= "";
77   var $publicVisible= "";
79   var $dialog;
81   /* variables to trigger password changes */
82   var $pw_storage= "crypt";
83   var $last_pw_storage= "unset";
84   var $had_userCertificate= FALSE;
86   /* attribute list for save action */
87   var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
88       "homePostalAddress", "homePhone", "labeledURI", "o", "ou", "dateOfBirth", "gender","preferredLanguage",
89       "departmentNumber", "employeeNumber", "employeeType", "l", "st",
90       "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
91       "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
93   var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
94       "gosaAccount");
96   /* attributes that are part of the government mode */
97   var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation",
98       "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality",
99       "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
100       "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
101       "postalCode");
104   /* constructor, if 'dn' is set, the node loads the given
105      'dn' from LDAP */
106   function user ($config, $dn= NULL)
107   {
108     $this->config= $config;
109     /* Configuration is fine, allways */
110     if ($this->config->current['GOVERNMENTMODE']){
111       $this->attributes=array_merge($this->attributes,$this->govattrs);
112     }
114     /* Load base attributes */
115     plugin::plugin ($config, $dn);
117     if ($this->config->current['GOVERNMENTMODE']){
118       /* Fix public visible attribute if unset */
119       if (!isset($this->attrs['publicVisible'])){
120         $this->publicVisible == "nein";
121       }
122     }
124     /* Load government mode attributes */
125     if ($this->config->current['GOVERNMENTMODE']){
126       /* Copy all attributs */
127       foreach ($this->govattrs as $val){
128         if (isset($this->attrs["$val"][0])){
129           $this->$val= $this->attrs["$val"][0];
130         }
131       }
132     }
134     /* Create me for new accounts */
135     if ($dn == "new"){
136       $this->is_account= TRUE;
137     }
139     /* Make hash default to md5 if not set in config */
140     if (!isset($this->config->current['HASH'])){
141       $hash= "md5";
142     } else {
143       $hash= $this->config->current['HASH'];
144     }
146     /* Load data from LDAP? */
147     if ($dn != NULL){
149       /* Do base conversation */
150       if ($this->dn == "new"){
151         $ui= get_userinfo();
152         $this->base= dn2base($ui->dn);
153       } else {
154         $this->base= dn2base($dn);
155       }
157       /* get password storage type */
158       if (isset ($this->attrs['userPassword'][0])){
159         /* Initialize local array */
160         $matches= array();
161         if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
162           $this->pw_storage= strtolower($matches[1]);
163         } else {
164           if ($this->attrs['userPassword'][0] != ""){
165             $this->pw_storage= "clear";
166           } else {
167             $this->pw_storage= $hash;
168           }
169         }
170       } else {
171         /* Preset with vaule from configuration */
172         $this->pw_storage= $hash;
173       }
175       /* Load extra attributes: certificate and picture */
176       $this->load_cert();
177       $this->load_picture();
178       if ($this->userCertificate != ""){
179         $this->had_userCertificate= TRUE;
180       }
181     }
183     /* Reset password storage indicator, used by password_change_needed() */
184     if ($dn == "new"){
185       $this->last_pw_storage= "unset";
186     } else {
187       $this->last_pw_storage= $this->pw_storage;
188     }
190     /* Generate dateOfBirth entry */
191     if (isset ($this->attrs['dateOfBirth'])){
192       /* This entry is ISO 8601 conform */
193       list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
194     
195       $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
196       $this->use_dob= "1";
197     } else {
198       $this->use_dob= "0";
199     }
201     /* Put gender attribute to upper case */
202     if (isset ($this->attrs['gender'])){
203       $this->gender= strtoupper($this->attrs['gender'][0]);
204     }
205   }
208   /* execute generates the html output for this node */
209   function execute()
210   {
211     /* Call parent execute */
212     plugin::execute();
214     $smarty= get_smarty();
216     /* Fill calendar */
217     if ($this->dateOfBirth == "0"){
218       $date= getdate();
219     } else {
220       if(is_array($this->dateOfBirth)){
221         $date = $this->dateOfBirth;
222       }else{
223         $date = getdate($this->dateOfBirth);
224       } 
225     }
227     $days= array();
228     for($d= 1; $d<32; $d++){
229       $days[$d]= $d;
230     }
231     $years= array();
233     if(($date['year']-100)<1901){
234       $start = 1901;
235     }else{
236       $start = $date['year']-100;
237     }
239     $end = $start +100;
240     
241     for($y= $start; $y<=$end; $y++){
242       $years[]= $y;
243     }
244     $years['-']= "-&nbsp;";
245     $months= array(_("January"), _("February"), _("March"), _("April"),
246         _("May"), _("June"), _("July"), _("August"), _("September"),
247         _("October"), _("November"), _("December"), '-' => '-&nbsp;');
248     $smarty->assign("day", $date["mday"]);
249     $smarty->assign("days", $days);
250     $smarty->assign("months", $months);
251     $smarty->assign("month", $date["mon"]-1);
252     $smarty->assign("years", $years);
253     $smarty->assign("year", $date["year"]);
255     /* Assign sex */
256     $sex= array(0 => "&nbsp;", "F" => _("female"), "M" => _("male"));
257     $smarty->assign("gender_list", $sex);
259     /* Assign prefered langage */
260     $language= array(0 => "&nbsp;", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
261                                     "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
262                                     "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"));
263     $smarty->assign("preferredLanguage_list", $language);
265     /* Get random number for pictures */
266     srand((double)microtime()*1000000); 
267     $smarty->assign("rand", rand(0, 10000));
269     /* Do we represent a valid gosaAccount? */
270     if (!$this->is_account){
271       echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
272         _("This account has no valid GOsa extensions.")."</b>";
273       return;
274     }
276     /* Base select dialog */
277     $once = true;
278     foreach($_POST as $name => $value){
279       if(preg_match("/^chooseBase/",$name) && $once){
280         $once = false;
281         $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
282         $this->dialog->setCurrentBase($this->base);
283       }
284     }
286     /* Dialog handling */
287     if(is_object($this->dialog)){
288       /* Must be called before save_object */
289       $this->dialog->save_object();
290    
291       if($this->dialog->isClosed()){
292         $this->dialog = false;
293       }elseif($this->dialog->isSelected()){
294         $this->base = $this->dialog->isSelected();
295         $this->dialog= false;
296       }else{
297         return($this->dialog->execute());
298       }
299     }
301     /* Want picture edit dialog? */
302     if($this->acl_is_readable("userPicture")) {
303       if (isset($_POST['edit_picture'])){
304         /* Save values for later recovery, in case some presses
305            the cancel button. */
306         $this->old_jpegPhoto= $this->jpegPhoto;
307         $this->old_photoData= $this->photoData;
308         $this->picture_dialog= TRUE;
309         $this->dialog= TRUE;
310       }
311     }
313     /* Remove picture? */
314     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
315       if (isset($_POST['picture_remove'])){
316         $this->jpegPhoto= "*removed*";
317         $this->set_picture ("./images/default.jpg");
318         $this->is_modified= TRUE;
320         return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
321       }
322     }
324     /* Save picture */
325     if (isset($_POST['picture_edit_finish'])){
327       /* Check for clean upload */
328       if ($_FILES['picture_file']['name'] != ""){
329         if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
330           print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
331           exit;
332         }
334         /* Activate new picture */
335         $this->set_picture($_FILES['picture_file']['tmp_name']);
336       }
337       $this->picture_dialog= FALSE;
338       $this->dialog= FALSE;
339       $this->is_modified= TRUE;
340     }
343     /* Cancel picture */
344     if (isset($_POST['picture_edit_cancel'])){
346       /* Restore values */
347       $this->jpegPhoto= $this->old_jpegPhoto;
348       $this->photoData= $this->old_photoData;
350       /* Update picture */
351       $_SESSION['binary']= $this->photoData;
352       $_SESSION['binarytype']= "image/jpeg";
353       $this->picture_dialog= FALSE;
354       $this->dialog= FALSE;
355     }
357     /* Toggle dateOfBirth information */
358     if (isset($_POST['set_dob'])){
359       $this->use_dob= ($this->use_dob == "0")?"1":"0";
360     }
363     /* Want certificate= */
364     if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
366       /* Save original values for later reconstruction */
367       foreach (array("certificateSerialNumber", "userCertificate",
368             "userSMIMECertificate", "userPKCS12") as $val){
370         $oval= "old_$val";
371         $this->$oval= $this->$val;
372       }
374       $this->cert_dialog= TRUE;
375       $this->dialog= TRUE;
376     }
379     /* Cancel certificate dialog */
380     if (isset($_POST['cert_edit_cancel'])){
382       /* Restore original values in case of 'cancel' */
383       foreach (array("certificateSerialNumber", "userCertificate",
384             "userSMIMECertificate", "userPKCS12") as $val){
386         $oval= "old_$val";
387         $this->$val= $this->$oval;
388       }
389       $this->cert_dialog= FALSE;
390       $this->dialog= FALSE;
391     }
394     /* Remove certificate? */
395     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
396       foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
397         if (isset($_POST["remove_$val"])){
399           /* Reset specified cert*/
400           $this->$val= "";
401           $this->is_modified= TRUE;
402         }
403       }
404     }
406     /* Upload new cert and close dialog? */     
407     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
408       if (isset($_POST['cert_edit_finish'])){
410         /* for all certificates do */
411         foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
412             as $val){
414           /* Check for clean upload */
415           if (array_key_exists($val."_file", $_FILES) &&
416               array_key_exists('name', $_FILES[$val."_file"]) &&
417               $_FILES[$val."_file"]['name'] != "" &&
418               is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
419             $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
420           }
421         }
423         /* Save serial number */
424         if (isset($_POST["certificateSerialNumber"]) &&
425             $_POST["certificateSerialNumber"] != ""){
427           if (!is_id($_POST["certificateSerialNumber"])){
428             print_red (_("Please enter a valid serial number"));
430             foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
431               if ($this->$cert != ""){
432                 $smarty->assign("$cert"."_state", "true");
433               } else {
434                 $smarty->assign("$cert"."_state", "");
435               }
436             }
437             return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
438           }
440           $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
441           $this->is_modified= TRUE;
442         }
444         $this->cert_dialog= FALSE;
445         $this->dialog= FALSE;
446       }
447     }
448     /* Display picture dialog */
449     if ($this->picture_dialog){
450       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
451     }
453     /* Display cert dialog */
454     if ($this->cert_dialog){
455       $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
456       $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
458       foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
459         if ($this->$cert != ""){
460           /* import certificate */
461           $certificate = new certificate;
462           $certificate->import($this->$cert);
463       
464           /* Read out data*/
465           $timeto   = $certificate->getvalidto_date();
466           $timefrom = $certificate->getvalidfrom_date();
467           $str = "<table summary=\"\" border=0><tr><td style='vertical-align:top'>CN</td><td>".preg_replace("/ /", "&nbsp;", $certificate->getname())."</td></tr></table><br>".
468                   sprintf(_("Certificate is valid from %s to %s and is currently %s."), "<b>".date('d M Y',$timefrom)."</b>","<b>".date('d M Y',$timeto)."</b>", $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":"<b><font style='color:red'>"._("invalid")."</font></b>");
469           $smarty->assign($cert."info",$str);
470           $smarty->assign($cert."_state","true");
471         } else {
472           $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
473           $smarty->assign($cert."_state","");
474         }
475       }
476       $smarty->assign("governmentmode", "false");
477       return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
478     }
480     /* Prepare password hashes */
481     if ($this->pw_storage == ""){
482       $this->pw_storage= $this->config->current['HASH'];
483     }
485     $temp   = @passwordMethod::get_available_methods();
486     $hashes = $temp['name'];
487     
488     /* Load attributes and acl's */
489     $ui =get_userinfo();
490     foreach($this->attributes as $val){
491       $smarty->assign("$val", $this->$val);
492       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
493     }
495     $smarty->assign("pwmode", $hashes);
496     $smarty->assign("pwmode_select", $this->pw_storage);
497     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
498     $smarty->assign("base_select",      $this->base);
499     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
500     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
501     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
503     /* Create base acls */
504     $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
505     if(!$this->acl_is_moveable()) {
506       $baseACL = preg_replace("/w/","",$baseACL);
507     }
508     $smarty->assign("baseACL",          $baseACL);
510     /* Show us the edit screen */
511     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
512    #  $smarty->assign("bases", $this->config->idepartments);
515     /* Save government mode attributes */
516     if (isset($this->config->current['GOVERNMENTMODE']) &&
517         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
518       $smarty->assign("governmentmode", "true");
519       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
520           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
521       $smarty->assign("ivbbmodes", $ivbbmodes);
522       foreach ($this->govattrs as $val){
523         $smarty->assign("$val", $this->$val);
524         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
525       }
526     } else {
527       $smarty->assign("governmentmode", "false");
528     }
530     /* Special mode for uid */
531     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
532     if (isset ($this->dn)){
533       if ($this->dn != "new"){
534         $uidACL= preg_replace("/w/","",$uidACL);
535       }
536     }  else {
537       $uidACL= preg_replace("/w/","",$uidACL);
538     }
539     
540     $smarty->assign("uidACL", $uidACL);
541     $smarty->assign("is_template", $this->is_template);
542     $smarty->assign("use_dob", $this->use_dob);
544     if (isset($this->parent)){
545       if (isset($this->parent->by_object['phoneAccount']) &&
546           $this->parent->by_object['phoneAccount']->is_account){
547         $smarty->assign("has_phoneaccount", "true");
548       } else {
549         $smarty->assign("has_phoneaccount", "false");
550       }
551     } else {
552       $smarty->assign("has_phoneaccount", "false");
553     }
554     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
555   }
558   /* remove object from parent */
559   function remove_from_parent()
560   {
561     $ldap= $this->config->get_ldap_link();
562     $ldap->rmdir ($this->dn);
563     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
565     /* Delete references to groups */
566     $ldap->cd ($this->config->current['BASE']);
567     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
568     while ($ldap->fetch()){
569       $g= new group($this->config, $ldap->getDN());
570       $g->removeUser($this->uid);
571       $g->save ();
572     }
574     /* Delete references to object groups */
575     $ldap->cd ($this->config->current['BASE']);
576     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
577     while ($ldap->fetch()){
578       $og= new ogroup($this->config, $ldap->getDN());
579       unset($og->member[$this->dn]);
580       $og->save ();
581     }
583     /* Optionally execute a command after we're done */
584     $this->handle_post_events("remove");
585   }
588   /* Save data to object */
589   function save_object()
590   {
591     if (isset($_POST['generic'])){
593       /* Parents save function */
594       plugin::save_object ();
596       /* Save government mode attributes */
597       if ($this->config->current['GOVERNMENTMODE']){
598         foreach ($this->govattrs as $val){
599           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
600             $data= stripcslashes($_POST["$val"]);
601             if ($data != $this->$val){
602               $this->is_modified= TRUE;
603             }
604             $this->$val= $data;
605           }
606         }
607       }
609       /* In template mode, the uid is autogenerated... */
610       if ($this->is_template){
611         $this->uid= strtolower($this->sn);
612         $this->givenName= $this->sn;
613       }
615       /* Save base and pw_storage, since these are no LDAP attributes */
616       if (isset($_POST['base'])){
618         $this->set_acl_base('dummy,'.$_POST['base']);
619         if($this->acl_is_moveable("base")){
621           foreach(array("base") as $val){
622             if(isset($_POST[$val])){
623               $data= validate($_POST[$val]);
624               if ($data != $this->$val){
625                 $this->is_modified= TRUE;
626               }
627               $this->$val= $data;
628             }
629           }
630         }else{
631           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
632         }
633       }
635       /* Get pw_storage mode */
636       if (isset($_POST['pw_storage'])){
637         foreach(array("pw_storage") as $val){
638           if(isset($_POST[$val])){
639             $data= validate($_POST[$val]);
640             if ($data != $this->$val){
641               $this->is_modified= TRUE;
642             }
643             $this->$val= $data;
644           }
645         }
646       }
648       $this->set_acl_base('dummy,'.$this->base);
649     }
650   }
652   function rebind($ldap, $referral)
653   {
654     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
655     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
656       $this->error = "Success";
657       $this->hascon=true;
658       $this->reconnect= true;
659       return (0);
660     } else {
661       $this->error = "Could not bind to " . $credentials['ADMIN'];
662       return NULL;
663     }
664   }
666   /* Save data to LDAP, depending on is_account we save or delete */
667   function save()
668   {
669     /* Only force save of changes .... 
670        If this attributes aren't changed, avoid saving.
671      */
672     if ($this->use_dob == "1"){
673       $this->dateOfBirth= date("Y-m-d", $this->dateOfBirth);
674     }
675     if($this->gender=="0") $this->gender ="";
676     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
677     
678  
679     /* First use parents methods to do some basic fillup in $this->attrs */
680     plugin::save ();
682     /* Remove additional objectClasses */
683     $tmp= array();
684     foreach ($this->attrs['objectClass'] as $key => $set){
685       $found= false;
686       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
687         if (preg_match ("/^$set$/i", $val)){
688           $found= true;
689           break;
690         }
691       }
692       if (!$found){
693         $tmp[]= $set;
694       }
695     }
697     /* Replace the objectClass array. This is done because of the
698        separation into government and normal mode. */
699     $this->attrs['objectClass']= $tmp;
701     /* Add objectClasss for template mode? */
702     if ($this->is_template){
703       $this->attrs['objectClass'][]= "gosaUserTemplate";
704     }
706     /* Hard coded government mode? */
707     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
708       $this->attrs['objectClass'][]= "ivbbentry";
710       /* Copy standard attributes */
711       foreach ($this->govattrs as $val){
712         if ($this->$val != ""){
713           $this->attrs["$val"]= $this->$val;
714         } elseif (!$this->is_new) {
715           $this->attrs["$val"]= array();
716         }
717       }
719       /* Remove attribute if set to "nein" */
720       if ($this->publicVisible == "nein"){
721         $this->attrs['publicVisible']= array();
722         if($this->is_new){
723           unset($this->attrs['publicVisible']);
724         }else{
725           $this->attrs['publicVisible']=array();
726         }
728       }
730     }
732     /* Special handling for attribute userCertificate needed */
733     if ($this->userCertificate != ""){
734       $this->attrs["userCertificate;binary"]= $this->userCertificate;
735       $remove_userCertificate= false;
736     } else {
737       $remove_userCertificate= true;
738     }
740     /* Special handling for dateOfBirth value */
741     if ($this->use_dob != "1"){
742       if ($this->is_new) {
743         unset($this->attrs["dateOfBirth"]);
744       } else {
745         $this->attrs["dateOfBirth"]= array();
746       }
747     }
748     if (!$this->gender){
749       if ($this->is_new) {
750         unset($this->attrs["gender"]);
751       } else {
752         $this->attrs["gender"]= array();
753       }
754     }
755     if (!$this->preferredLanguage){
756       if ($this->is_new) {
757         unset($this->attrs["preferredLanguage"]);
758       } else {
759         $this->attrs["preferredLanguage"]= array();
760       }
761     }
763     /* Special handling for attribute jpegPhote needed, scale image via
764        image magick to 147x200 pixels and inject resulting data. */
765     if ($this->jpegPhoto != "*removed*"){
767       /* Fallback if there's no image magick inside PHP */
768       if (!function_exists("imagick_blob2image")){
769         /* Get temporary file name for conversation */
770         $fname = tempnam ("/tmp", "GOsa");
772         /* Open file and write out photoData */
773         $fp = fopen ($fname, "w");
774         fwrite ($fp, $this->photoData);
775         fclose ($fp);
777         /* Build conversation query. Filename is generated automatically, so
778            we do not need any special security checks. Exec command and save
779            output. For PHP safe mode, you'll need a configuration which respects
780            image magick as executable... */
781         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
782         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
783             $query, "Execute");
785         /* Read data written by convert */
786         $output= "";
787         $sh= popen($query, 'r');
788         while (!feof($sh)){
789           $output.= fread($sh, 4096);
790         }
791         pclose($sh);
793         unlink($fname);
795         /* Save attribute */
796         $this->attrs["jpegPhoto"] = $output;
798       } else {
800         /* Load the new uploaded Photo */
801         if(!$handle  =  imagick_blob2image($this->photoData))  {
802           gosa_log("Can't Load image");
803         }
805         /* Resizing image to 147x200 and blur */
806         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
807           gosa_log("imagick_resize failed");
808         }
810         /* Converting image to JPEG */
811         if(!imagick_convert($handle,"JPEG")) {
812           gosa_log("Can't Convert to JPEG");
813         }
815         /* Creating binary Code for the Image */
816         if(!$dump = imagick_image2blob($handle)){
817           gosa_log("Can't create blob for image");
818         }
820         /* Sending Image */
821         $output=  $dump;
823         /* Save attribute */
824         $this->attrs["jpegPhoto"] = $output;
825       }
827     } elseif(!$this->is_new) {
828       $this->attrs["jpegPhoto"] = array();
829     }
831     /* Build new dn */
832     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
833       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
834     } else {
835       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
836     }
838     /* This only gets called when user is renaming himself */
839     $ldap= $this->config->get_ldap_link();
840     if ($this->dn != $new_dn){
842       /* Write entry on new 'dn' */
843       $this->move($this->dn, $new_dn);
845       /* Happen to use the new one */
846       change_ui_dn($this->dn, $new_dn);
847       $this->dn= $new_dn;
848     }
851     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
852        new entries. So do a check first... */
853     $ldap->cat ($this->dn, array('dn'));
854     if ($ldap->fetch()){
855       $mode= "modify";
856     } else {
857       $mode= "add";
858       $ldap->cd($this->config->current['BASE']);
859       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
860     }
862     /* Set password to some junk stuff in case of templates */
863     if ($this->is_template){
864       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
865     }
867     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
868         $this->attributes, "Save via $mode");
870     /* Finally write data with selected 'mode' */
871     $this->cleanup();
872     $ldap->cd ($this->dn);
873     $ldap->$mode ($this->attrs);
874     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
875       return (1);
876     }
878     /* Remove cert? 
879        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
880        to work around myself. */
881     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
883       /* Reset array, assemble new, this should be reworked */
884       $this->attrs= array();
885       $this->attrs['userCertificate;binary']= array();
887       /* Prepare connection */
888       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
889         die ("Could not connect to LDAP server");
890       }
891       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
892       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
893         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
894         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
895       }
896       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
897         ldap_start_tls($ds);
898       }
899       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
900               $this->config->current['PASSWORD']))) {
901         die ("Could not bind to LDAP");
902       }
904       /* Modify using attrs */
905       ldap_mod_del($ds,$this->dn,$this->attrs);
906       ldap_close($ds);
907     }
909     /* Kerberos server defined? */
910     if (isset($this->config->data['SERVERS']['KERBEROS'])){
911       $cfg= $this->config->data['SERVERS']['KERBEROS'];
912     }
913     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
915       /* Connect to the admin interface */
916       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
917           $cfg['ADMIN'], $cfg['PASSWORD']);
919       /* Errors? */             
920       if ($handle === FALSE){
921         print_red (_("Kerberos database communication failed"));
922         return (2);
923       }
925       /* Build user principal, get list of existsing principals */
926       $principal= $this->uid."@".$cfg['REALM'];
927       $principals = kadm5_get_principals($handle);
929       /* User exists in database? */
930       if (in_array($principal, $principals)){
932         /* Ok. User exists. Remove him/her when pw_storage has
933            changed to be NOT kerberos. */
934         if ($this->pw_storage != "kerberos"){
935           $ret= kadm5_delete_principal ( $handle, $principal);
937           if ($ret === FALSE){
938             print_red (_("Can't remove user from kerberos database."));
939           }
940         }
942       } else {
944         /* User doesn't exists, create it when pw_storage is kerberos. */
945         if ($this->pw_storage == "kerberos"){
946           $ret= kadm5_create_principal ( $handle, $principal);
948           if ($ret === FALSE){
949             print_red (_("Can't add user to kerberos database."));
950           }
951         }
953       }
955       /* Free kerberos admin handle */
956       kadm5_destroy($handle);
957     }
959     /* Optionally execute a command after we're done */
960     if ($mode == "add"){
961       $this->handle_post_events("add");
962     } elseif ($this->is_modified){
963       $this->handle_post_events("modify");
964     }
966     /* Fix tagging if needed */
967     $this->handle_object_tagging();
969     return (0);
970   }
973   /* Check formular input */
974   function check()
975   {
976     /* Call common method to give check the hook */
977     $message= plugin::check();
979     /* Assemble cn */
980     $this->cn= $this->givenName." ".$this->sn;
982     /* Permissions for that base? */
983     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
984       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
985     } else {
986       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
987     }
989     if ($this->dn == "new" &&  !$this->acl_is_createable()){
990       $message[]= _("You have no permissions to create a user on this 'Base'.");
991     } elseif ($this->dn != $new_dn && $this->dn != "new"){
992       if (!$this->acl_is_writeable($this->dn, "user","create",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
993         $message[]= _("You have no permissions to move a user from the original 'Base'.");
994       }
995     }
997     /* must: sn, givenName, uid */
998     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
999       $message[]= _("The required field 'Name' is not set.");
1000     }
1002     /* UID already used? */
1003     $ldap= $this->config->get_ldap_link();
1004     $ldap->cd($this->config->current['BASE']);
1005     $ldap->search("(uid=$this->uid)", array("uid"));
1006     $ldap->fetch();
1007     if ($ldap->count() != 0 && $this->dn == 'new'){
1008       $message[]= _("There's already a person with this 'Login' in the database.");
1009     }
1011     /* In template mode, the uid and givenName are autogenerated... */
1012     if (!$this->is_template){
1013       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1014         $message[]= _("The required field 'Given name' is not set.");
1015       }
1016       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1017         $message[]= _("The required field 'Login' is not set.");
1018       }
1019       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1020         $ldap->cd($this->config->current['BASE']);
1021         $ldap->search("(cn=".$this->cn.")", array("uid"));
1022         $ldap->fetch();
1023         if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
1024           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1025         }
1026       }
1027     }
1029     /* Check for valid input */
1030     if ($this->is_modified && !is_uid($this->uid)){
1031       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1032     }
1033     if (!is_url($this->labeledURI)){
1034       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1035     }
1036     if (preg_match ("/[\\\\]/", $this->sn)){
1037       $message[]= _("The field 'Name' contains invalid characters.");
1038     }
1039     if (preg_match ("/[\\\\]/", $this->givenName)){
1040       $message[]= _("The field 'Given name' contains invalid characters.");
1041     }
1043     /* Check phone numbers */
1044     if (!is_phone_nr($this->telephoneNumber)){
1045       $message[]= _("The field 'Phone' contains an invalid phone number.");
1046     }
1047     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1048       $message[]= _("The field 'Fax' contains an invalid phone number.");
1049     }
1050     if (!is_phone_nr($this->mobile)){
1051       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1052     }
1053     if (!is_phone_nr($this->pager)){
1054       $message[]= _("The field 'Pager' contains an invalid phone number.");
1055     }
1057     /* Check for reserved characers */
1058     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1059       $message[]= _("The field 'Given name' contains invalid characters.");
1060     }
1061     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1062       $message[]= _("The field 'Name' contains invalid characters.");
1063     }
1065   return $message;
1066   }
1069   /* Indicate whether a password change is needed or not */
1070   function password_change_needed()
1071   {
1072     return ($this->pw_storage != $this->last_pw_storage);
1073   }
1076   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1077   function load_picture()
1078   {
1079     /* make connection and read jpegPhoto */
1080     $ds= ldap_connect($this->config->current['SERVER']);
1081     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1082     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1083       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1084       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1085     }
1087     if(isset($this->config->current['TLS']) &&
1088         $this->config->current['TLS'] == "true"){
1090       ldap_start_tls($ds);
1091     }
1093     $r= ldap_bind($ds);
1094     $sr= @ldap_read($ds, $this->dn, "jpegPhoto=*", array("jpegPhoto"));
1096     /* in case we don't get an entry, load a default picture */
1097     $this->set_picture ("./images/default.jpg");
1098     $this->jpegPhoto= "*removed*";
1100     /* fill data from LDAP */
1101     if ($sr) {
1102       $ei=ldap_first_entry($ds, $sr);
1103       if ($ei) {
1104         if ($info = ldap_get_values_len($ds, $ei, "jpegPhoto")){
1105           $this->photoData= $info[0];
1106           $_SESSION['binary']= $this->photoData;
1107           $_SESSION['binarytype']= "image/jpeg";
1108           $this->jpegPhoto= "";
1109         }
1110       }
1111     }
1113     /* close conncetion */
1114     ldap_unbind($ds);
1115   }
1118   /* Load a certificate from LDAP, this is going to be simplified later on */
1119   function load_cert()
1120   {
1121     $ds= ldap_connect($this->config->current['SERVER']);
1122     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1123     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1124       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1125       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1126     }
1127     if(isset($this->config->current['TLS']) &&
1128         $this->config->current['TLS'] == "true"){
1130       ldap_start_tls($ds);
1131     }
1133     $r= ldap_bind($ds);
1134     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1136     if ($sr) {
1137       $ei= @ldap_first_entry($ds, $sr);
1138       
1139       if ($ei) {
1140         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1141           $this->userCertificate= "";
1142         } else {
1143           $this->userCertificate= $info[0];
1144         }
1145       }
1146     } else {
1147       $this->userCertificate= "";
1148     }
1150     ldap_unbind($ds);
1151   }
1154   /* Load picture from file to object */
1155   function set_picture($filename)
1156   {
1157     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1158       if (!is_file($filename)){
1159         $filename= "./images/default.jpg";
1160         $this->jpegPhoto= "*removed*";
1161       }
1163       $fd = fopen ($filename, "rb");
1164       $this->photoData= fread ($fd, filesize ($filename));
1165       $_SESSION['binary']= $this->photoData;
1166       $_SESSION['binarytype']= "image/jpeg";
1167       $this->jpegPhoto= "";
1169       fclose ($fd);
1170     }
1171   }
1174   /* Load certificate from file to object */
1175   function set_cert($cert, $filename)
1176   {
1177     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1178     $fd = fopen ($filename, "rb");
1179     if (filesize($filename)>0) {
1180       $this->$cert= fread ($fd, filesize ($filename));
1181       fclose ($fd);
1182       $this->is_modified= TRUE;
1183     } else {
1184       print_red(_("Could not open specified certificate!"));
1185     }
1186   }
1188   /* Adapt from given 'dn' */
1189   function adapt_from_template($dn)
1190   {
1191     plugin::adapt_from_template($dn);
1193     /* Get base */
1194     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1196     if ($this->config->current['GOVERNMENTMODE']){
1198       /* Walk through govattrs */
1199       foreach ($this->govattrs as $val){
1201         if (isset($this->attrs["$val"][0])){
1203           /* If attribute is set, replace dynamic parts: 
1204              %sn, %givenName and %uid. Fill these in our local variables. */
1205           $value= $this->attrs["$val"][0];
1207           foreach (array("sn", "givenName", "uid") as $repl){
1208             if (preg_match("/%$repl/i", $value)){
1209               $value= preg_replace ("/%$repl/i",
1210                   $this->parent->$repl, $value);
1211             }
1212           }
1213           $this->$val= $value;
1214         }
1215       }
1216     }
1218     /* Get back uid/sn/givenName */
1219     if ($this->parent != NULL){
1220       $this->uid= $this->parent->uid;
1221       $this->sn= $this->parent->sn;
1222       $this->givenName= $this->parent->givenName;
1223     }
1224   }
1226  
1227   /* This avoids that users move themselves out of their rights. 
1228    */
1229   function allowedBasesToMoveTo()
1230   {
1231     $allowed = array();
1232     $ret_all = false;
1233     if($this->uid == $_SESSION['ui']->username){
1234       $ldap= $this->config->get_ldap_link(); 
1235       $ldap->cd($this->config->current['BASE']); 
1236       $ldap->search("(&(objectClass=posixGroup)(memberUid=".$_SESSION['ui']->username."))",array("gosaSubtreeACL"));
1237        
1238       while($attrs = $ldap->fetch()){
1239     
1240         if(isset($attrs['gosaSubtreeACL'])){
1241         
1242           foreach($attrs['gosaSubtreeACL'] as $attr){
1243             if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){
1244               $s =  preg_replace("/^.*ou=groups,/","",$attrs['dn']);
1246               foreach($this->config->idepartments as $key => $dep) {
1247                 if(preg_match("/".$s."/i",$key)){
1248                   $allowed[$key] = $dep;
1249                 }
1250               }
1251             }
1252           }
1253         }
1254       }
1255       if(count($allowed) == 0){
1256         foreach($this->config->idepartments as $key => $dep) {
1257           if($this->base==$key){
1258             $allowed[$key] = $dep;
1259           }
1260         }
1261       }  
1262   
1263       return($allowed);
1264       
1265     }else{
1266       return($this->config->idepartments);
1267     }
1268   } 
1271   function getCopyDialog()
1272   {
1273     $str = "";
1275     $_SESSION['binary'] = $this->photoData; 
1276     $_SESSION['binarytype']= "image/jpeg";
1278     /* Get random number for pictures */
1279     srand((double)microtime()*1000000); 
1280     $rand = rand(0, 10000);
1282     $smarty = get_smarty();
1284     $smarty->assign("passwordTodo","clear");
1286     if(isset($_POST['passwordTodo'])){
1287       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1288     }
1290     $smarty->assign("sn",       $this->sn);
1291     $smarty->assign("givenName",$this->givenName);
1292     $smarty->assign("uid",      $this->uid);
1293     $smarty->assign("rand",     $rand);
1294     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1297     $ret = array();
1298     $ret['string'] = $str;
1299     $ret['status'] = "";  
1300     return($ret);
1301   }
1303   function saveCopyDialog()
1304   {
1306     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1307       $this->set_picture($_FILES['picture_file']['tmp_name']);
1308     }
1310     /* Remove picture? */
1311     if (isset($_POST['picture_remove'])){
1312       $this->jpegPhoto= "*removed*";
1313       $this->set_picture ("./images/default.jpg");
1314       $this->is_modified= TRUE;
1315     }
1317     $attrs = array("uid","givenName","sn");
1318     foreach($attrs as $attr){
1319       if(isset($_POST[$attr])){
1320         $this->$attr = $_POST[$attr];
1321       }
1322     } 
1323   }
1326   function plInfo()
1327   {
1328   
1329     $govattrs= array(
1330         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1331         "houseIdentifier"                           =>  _("House identifier"), 
1332         "vocation"                                  =>  _("Vocation"),
1333         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1334         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1335         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1336         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1337         "functionalTitle"                           =>  _("Functional title"),
1338         "certificateSerialNumber"                   =>  _(""),
1339         "publicVisible"                             =>  _("Public visible"),
1340         "street"                                    =>  _("Street"),
1341         "role"                                      =>  _("Role"),
1342         "postalCode"                                =>  _("Postal code"));
1344     $ret = array(
1345         "plShortName" => _("Generic"),
1346         "plDescription" => _("Generic user settings"),
1347         "plSelfModify"  => TRUE,
1348         "plDepends"     => array(),
1349         "plPriority"    => 0,
1350         "plSection"     => array("personal" => _("My account")),
1351         "plCategory"    => array("users" => array("description" => _("Users"),
1352                                                   "objectClass" => "gosaAccount")),
1354         "plProvidedAcls" => array(
1355           "base"              => _("Base"), 
1356           "userPassword"      => _("User password"), 
1357           "sn"                => _("Surename"),
1358           "givenName"         => _("Given name"),
1359           "uid"               => _("User identification"),
1360           "personalTitle"     => _("Personal title"),
1361           "academicTitle"     => _("Academic title"),
1362           "homePostalAddress" => _("Home postal address"),
1363           "homePhone"         => _("Home phone number"),
1364           "labeledURI"        => _("Homepage"),
1365           "o"                 => _("Organization"),
1366           "ou"                => _("Department"),
1367           "dateOfBirth"       => _("Date of birth"),
1368           "gender"            => _("Gender"),
1369           "preferredLanguage" => _("Preferred language"),
1370           "departmentNumber"  => _("Department number"),
1371           "employeeNumber"    => _("Employee number"),
1372           "employeeType"      => _("Employee type"),
1373           "l"                 => _("Location"),
1374           "st"                => _("State"),
1375           "userPicture"       => _("User picture"),
1376           "roomNumber"        => _("Room number"),
1377           "telephoneNumber"   => _("Telefon number"),
1378           "mobile"            => _("Mobile number"),
1379           "pager"             => _("Pager number"),
1380           "Certificate"        => _("User certificates"),
1382           "postalAddress"                => _("Postal address"),
1383           "facsimileTelephoneNumber"     => _("Fax number"))
1384         );
1386     /* Append government attributes if required */
1387       global $config;
1388     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1389       foreach($govattrs as $attr => $desc){
1390         $ret["plProvidedAcls"][$attr] = $desc;
1391       }
1392     }
1394     return($ret);
1395   }
1398 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1399 ?>