Code

Update posixAccount check hook.
[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 $orig_base= "";
27   var $cn= "";
28   var $new_dn= "";
29   var $personalTitle= "";
30   var $academicTitle= "";
31   var $homePostalAddress= "";
32   var $homePhone= "";
33   var $labeledURI= "";
34   var $o= "";
35   var $ou= "";
36   var $departmentNumber= "";
37   var $employeeNumber= "";
38   var $employeeType= "";
39   var $roomNumber= "";
40   var $telephoneNumber= "";
41   var $facsimileTelephoneNumber= "";
42   var $mobile= "";
43   var $pager= "";
44   var $l= "";
45   var $st= "";
46   var $postalAddress= "";
47   var $dateOfBirth;
48   var $use_dob= "0";
49   var $gender="0";
50   var $preferredLanguage="0";
52   var $jpegPhoto= "*removed*";
53   var $photoData= "";
54   var $old_jpegPhoto= "";
55   var $old_photoData= "";
56   var $cert_dialog= FALSE;
57   var $picture_dialog= FALSE;
59   var $userPKCS12= "";
60   var $userSMIMECertificate= "";
61   var $userCertificate= "";
62   var $certificateSerialNumber= "";
63   var $old_certificateSerialNumber= "";
64   var $old_userPKCS12= "";
65   var $old_userSMIMECertificate= "";
66   var $old_userCertificate= "";
68   var $gouvernmentOrganizationalUnit= "";
69   var $houseIdentifier= "";
70   var $street= "";
71   var $postalCode= "";
72   var $vocation= "";
73   var $ivbbLastDeliveryCollective= "";
74   var $gouvernmentOrganizationalPersonLocality= "";
75   var $gouvernmentOrganizationalUnitDescription= "";
76   var $gouvernmentOrganizationalUnitSubjectArea= "";
77   var $functionalTitle= "";
78   var $role= "";
79   var $publicVisible= "";
81   var $dialog;
83   /* variables to trigger password changes */
84   var $pw_storage= "crypt";
85   var $last_pw_storage= "unset";
86   var $had_userCertificate= FALSE;
88   var $view_logged = FALSE;
90   /* attribute list for save action */
91   var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
92       "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage",
93       "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto",
94       "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
95       "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
97   var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
98       "gosaAccount");
100   /* attributes that are part of the government mode */
101   var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation",
102       "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality",
103       "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
104       "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
105       "postalCode");
108   /* constructor, if 'dn' is set, the node loads the given
109      'dn' from LDAP */
110   function user ($config, $dn= NULL)
111   {
112     $this->config= $config;
113     /* Configuration is fine, allways */
114     if ($this->config->current['GOVERNMENTMODE']){
115       $this->attributes=array_merge($this->attributes,$this->govattrs);
116     }
118     /* Load base attributes */
119     plugin::plugin ($config, $dn);
121     if ($this->config->current['GOVERNMENTMODE']){
122       /* Fix public visible attribute if unset */
123       if (!isset($this->attrs['publicVisible'])){
124         $this->publicVisible == "nein";
125       }
126     }
128     /* Load government mode attributes */
129     if ($this->config->current['GOVERNMENTMODE']){
130       /* Copy all attributs */
131       foreach ($this->govattrs as $val){
132         if (isset($this->attrs["$val"][0])){
133           $this->$val= $this->attrs["$val"][0];
134         }
135       }
136     }
138     /* Create me for new accounts */
139     if ($dn == "new"){
140       $this->is_account= TRUE;
141     }
143     /* Make hash default to md5 if not set in config */
144     if (!isset($this->config->current['HASH'])){
145       $hash= "md5";
146     } else {
147       $hash= $this->config->current['HASH'];
148     }
150     /* Load data from LDAP? */
151     if ($dn != NULL){
153       /* Do base conversation */
154       if ($this->dn == "new"){
155         $ui= get_userinfo();
156         $this->base= dn2base($ui->dn);
157       } else {
158         $this->base= dn2base($dn);
159       }
161       /* get password storage type */
162       if (isset ($this->attrs['userPassword'][0])){
163         /* Initialize local array */
164         $matches= array();
165         if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
166           $this->pw_storage= strtolower($matches[1]);
167         } else {
168           if ($this->attrs['userPassword'][0] != ""){
169             $this->pw_storage= "clear";
170           } else {
171             $this->pw_storage= $hash;
172           }
173         }
174       } else {
175         /* Preset with vaule from configuration */
176         $this->pw_storage= $hash;
177       }
179       /* Load extra attributes: certificate and picture */
180       $this->load_cert();
181       $this->load_picture();
182       if ($this->userCertificate != ""){
183         $this->had_userCertificate= TRUE;
184       }
185     }
187     /* Reset password storage indicator, used by password_change_needed() */
188     if ($dn == "new"){
189       $this->last_pw_storage= "unset";
190     } else {
191       $this->last_pw_storage= $this->pw_storage;
192     }
194     /* Generate dateOfBirth entry */
195     if (isset ($this->attrs['dateOfBirth'])){
196       /* This entry is ISO 8601 conform */
197       list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
198     
199       $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
200       $this->use_dob= "1";
201     } else {
202       $this->use_dob= "0";
203     }
205     /* Put gender attribute to upper case */
206     if (isset ($this->attrs['gender'])){
207       $this->gender= strtoupper($this->attrs['gender'][0]);
208     }
209   
210     $this->orig_base = $this->base;
211   }
214   /* execute generates the html output for this node */
215   function execute()
216   {
217     /* Call parent execute */
218     plugin::execute();
220     /* Log view */
221     if($this->is_account && !$this->view_logged){
222       $this->view_logged = TRUE;
223       new log("view","users/".get_class($this),$this->dn);
224     }
226     $smarty= get_smarty();
228     /* Fill calendar */
229     if ($this->dateOfBirth == "0"){
230       $date= getdate();
231     } else {
232       if(is_array($this->dateOfBirth)){
233         $date = $this->dateOfBirth;
234   
235         // Trigger on dates like 1985-04-01, getdate only understands timestamps
236       } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){
237         $date= getdate(strtotime($this->dateOfBirth));
239       } else {
240         $date = getdate($this->dateOfBirth);
241       }
242     }
244     $days= array();
245     for($d= 1; $d<32; $d++){
246       $days[$d]= $d;
247     }
248     $years= array();
250     if(($date['year']-100)<1901){
251       $start = 1901;
252     }else{
253       $start = $date['year']-100;
254     }
256     $end = $start +100;
257     
258     for($y= $start; $y<=$end; $y++){
259       $years[]= $y;
260     }
261     $years['-']= "-&nbsp;";
262     $months= array(_("January"), _("February"), _("March"), _("April"),
263         _("May"), _("June"), _("July"), _("August"), _("September"),
264         _("October"), _("November"), _("December"), '-' => '-&nbsp;');
265     $smarty->assign("day", $date["mday"]);
266     $smarty->assign("days", $days);
267     $smarty->assign("months", $months);
268     $smarty->assign("month", $date["mon"]-1);
269     $smarty->assign("years", $years);
270     $smarty->assign("year", $date["year"]);
272     /* Assign sex */
273     $sex= array(0 => "&nbsp;", "F" => _("female"), "M" => _("male"));
274     $smarty->assign("gender_list", $sex);
276     /* Assign prefered langage */
277     $language= array(0 => "&nbsp;", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
278                                     "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
279                                     "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"),
280                                     "zh_CN" => ("zh_CN"));
281     $smarty->assign("preferredLanguage_list", $language);
283     /* Get random number for pictures */
284     srand((double)microtime()*1000000); 
285     $smarty->assign("rand", rand(0, 10000));
288     /* Do we represent a valid gosaAccount? */
289     if (!$this->is_account){
290       echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
291         _("This account has no valid GOsa extensions.")."</b>";
292       return;
293     }
295     /* Base select dialog */
296     $once = true;
297     foreach($_POST as $name => $value){
298       if(preg_match("/^chooseBase/",$name) && $once){
299         $once = false;
300         $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
301         $this->dialog->setCurrentBase($this->base);
302       }
303     }
305     /* Dialog handling */
306     if(is_object($this->dialog)){
307       /* Must be called before save_object */
308       $this->dialog->save_object();
309    
310       if($this->dialog->isClosed()){
311         $this->dialog = false;
312       }elseif($this->dialog->isSelected()){
314         /* check if selected base is allowed to move to / create a new object */
315         $tmp = $this->get_allowed_bases();
316         if(isset($tmp[$this->dialog->isSelected()])){
317           $this->base = $this->dialog->isSelected();
318         }
319         $this->dialog= false;
320       }else{
321         return($this->dialog->execute());
322       }
323     }
325     /* Want picture edit dialog? */
326     if($this->acl_is_writeable("userPicture")) {
327       if (isset($_POST['edit_picture'])){
328         /* Save values for later recovery, in case some presses
329            the cancel button. */
330         $this->old_jpegPhoto= $this->jpegPhoto;
331         $this->old_photoData= $this->photoData;
332         $this->picture_dialog= TRUE;
333         $this->dialog= TRUE;
334       }
335     }
337     /* Remove picture? */
338     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
339       if (isset($_POST['picture_remove'])){
340         $this->set_picture ();
341         $this->jpegPhoto= "*removed*";
342         $this->is_modified= TRUE;
343         return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
344       }
345     }
347     /* Save picture */
348     if (isset($_POST['picture_edit_finish'])){
350       /* Check for clean upload */
351       if ($_FILES['picture_file']['name'] != ""){
352         if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
353           print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
354         }else{
355           /* Activate new picture */
356           $this->set_picture($_FILES['picture_file']['tmp_name']);
357         }
358       }
359       $this->picture_dialog= FALSE;
360       $this->dialog= FALSE;
361       $this->is_modified= TRUE;
362     }
365     /* Cancel picture */
366     if (isset($_POST['picture_edit_cancel'])){
368       /* Restore values */
369       $this->jpegPhoto= $this->old_jpegPhoto;
370       $this->photoData= $this->old_photoData;
372       /* Update picture */
373       $_SESSION['binary']= $this->photoData;
374       $_SESSION['binarytype']= "image/jpeg";
375       $this->picture_dialog= FALSE;
376       $this->dialog= FALSE;
377     }
379     /* Toggle dateOfBirth information */
380     if (isset($_POST['set_dob'])){
381       $this->use_dob= ($this->use_dob == "0")?"1":"0";
382     }
385     /* Want certificate= */
386     if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
388       /* Save original values for later reconstruction */
389       foreach (array("certificateSerialNumber", "userCertificate",
390             "userSMIMECertificate", "userPKCS12") as $val){
392         $oval= "old_$val";
393         $this->$oval= $this->$val;
394       }
396       $this->cert_dialog= TRUE;
397       $this->dialog= TRUE;
398     }
401     /* Cancel certificate dialog */
402     if (isset($_POST['cert_edit_cancel'])){
404       /* Restore original values in case of 'cancel' */
405       foreach (array("certificateSerialNumber", "userCertificate",
406             "userSMIMECertificate", "userPKCS12") as $val){
408         $oval= "old_$val";
409         $this->$val= $this->$oval;
410       }
411       $this->cert_dialog= FALSE;
412       $this->dialog= FALSE;
413     }
416     /* Remove certificate? */
417     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
418       foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
419         if (isset($_POST["remove_$val"])){
421           /* Reset specified cert*/
422           $this->$val= "";
423           $this->is_modified= TRUE;
424         }
425       }
426     }
428     /* Upload new cert and close dialog? */     
429     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
430       if (isset($_POST['cert_edit_finish'])){
432         /* for all certificates do */
433         foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
434             as $val){
436           /* Check for clean upload */
437           if (array_key_exists($val."_file", $_FILES) &&
438               array_key_exists('name', $_FILES[$val."_file"]) &&
439               $_FILES[$val."_file"]['name'] != "" &&
440               is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
441             $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
442           }
443         }
445         /* Save serial number */
446         if (isset($_POST["certificateSerialNumber"]) &&
447             $_POST["certificateSerialNumber"] != ""){
449           if (!is_id($_POST["certificateSerialNumber"])){
450             print_red (_("Please enter a valid serial number"));
452             foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
453               if ($this->$cert != ""){
454                 $smarty->assign("$cert"."_state", "true");
455               } else {
456                 $smarty->assign("$cert"."_state", "");
457               }
458             }
459             return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
460           }
462           $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
463           $this->is_modified= TRUE;
464         }
466         $this->cert_dialog= FALSE;
467         $this->dialog= FALSE;
468       }
469     }
470     /* Display picture dialog */
471     if ($this->picture_dialog){
472       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
473     }
475     /* Display cert dialog */
476     if ($this->cert_dialog){
477       $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
478       $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
480       foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
481         if ($this->$cert != ""){
482           /* import certificate */
483           $certificate = new certificate;
484           $certificate->import($this->$cert);
485       
486           /* Read out data*/
487           $timeto   = $certificate->getvalidto_date();
488           $timefrom = $certificate->getvalidfrom_date();
489          
490           
491           /* Additional info if start end time is '0' */
492           $add_str_info = "";
493           if($timeto == 0 && $timefrom == 0){
494             $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
495           }
497           $str = "<table summary=\"\" border=0>
498                     <tr>
499                       <td style='vertical-align:top'>CN</td>
500                       <td>".preg_replace("/ /", "&nbsp;", $certificate->getname())."</td>
501                     </tr>
502                   </table><br>".
504                   sprintf(_("Certificate is valid from %s to %s and is currently %s."),
505                         "<b>".date('d M Y',$timefrom)."</b>",
506                         "<b>".date('d M Y',$timeto)."</b>",
507                         $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
508                                                 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
510           $smarty->assign($cert."info",$str);
511           $smarty->assign($cert."_state","true");
512         } else {
513           $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
514           $smarty->assign($cert."_state","");
515         }
516       }
517       $smarty->assign("governmentmode", "false");
518       return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
519     }
521     /* Prepare password hashes */
522     if ($this->pw_storage == ""){
523       $this->pw_storage= $this->config->current['HASH'];
524     }
526     $temp   = @passwordMethod::get_available_methods();
527     $hashes = $temp['name'];
528     
529     /* Load attributes and acl's */
530     $ui =get_userinfo();
531     foreach($this->attributes as $val){
532       $smarty->assign("$val", $this->$val);
533     }
535     /* Set acls */
536     $tmp = $this->plinfo();
537     foreach($tmp['plProvidedAcls'] as $val => $translation){
538       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
539     }
541     $smarty->assign("pwmode", $hashes);
542     $smarty->assign("pwmode_select", $this->pw_storage);
543     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
544     $smarty->assign("base_select",      $this->base);
545     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
546     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
547     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
549     /* Create base acls */
550     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
552     /* Save government mode attributes */
553     if (isset($this->config->current['GOVERNMENTMODE']) &&
554         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
555       $smarty->assign("governmentmode", "true");
556       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
557           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
558       $smarty->assign("ivbbmodes", $ivbbmodes);
559       foreach ($this->govattrs as $val){
560         $smarty->assign("$val", $this->$val);
561         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
562       }
563     } else {
564       $smarty->assign("governmentmode", "false");
565     }
567     /* Special mode for uid */
568     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
569     if (isset ($this->dn)){
570       if ($this->dn != "new"){
571         $uidACL= preg_replace("/w/","",$uidACL);
572       }
573     }  else {
574       $uidACL= preg_replace("/w/","",$uidACL);
575     }
576     
577     $smarty->assign("uidACL", $uidACL);
578     $smarty->assign("is_template", $this->is_template);
579     $smarty->assign("use_dob", $this->use_dob);
581     if (isset($this->parent)){
582       if (isset($this->parent->by_object['phoneAccount']) &&
583           $this->parent->by_object['phoneAccount']->is_account){
584         $smarty->assign("has_phoneaccount", "true");
585       } else {
586         $smarty->assign("has_phoneaccount", "false");
587       }
588     } else {
589       $smarty->assign("has_phoneaccount", "false");
590     }
591     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
592   }
595   /* remove object from parent */
596   function remove_from_parent()
597   {
598     $ldap= $this->config->get_ldap_link();
599     $ldap->rmdir ($this->dn);
600     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
601   
602     new log("remove","users/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
603   
604     /* Delete references to groups */
605     $ldap->cd ($this->config->current['BASE']);
606     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
607     while ($ldap->fetch()){
608       $g= new group($this->config, $ldap->getDN());
609       $g->removeUser($this->uid);
610       $g->save ();
611     }
613     /* Delete references to object groups */
614     $ldap->cd ($this->config->current['BASE']);
615     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
616     while ($ldap->fetch()){
617       $og= new ogroup($this->config, $ldap->getDN());
618       unset($og->member[$this->dn]);
619       $og->save ();
620     }
622     /* Kerberos server defined? */
623     if (isset($this->config->data['SERVERS']['KERBEROS'])){
624       $cfg= $this->config->data['SERVERS']['KERBEROS'];
625     }
626     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
628       /* Connect to the admin interface */
629       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
630           $cfg['ADMIN'], $cfg['PASSWORD']);
632       /* Errors? */             
633       if ($handle === FALSE){
634         print_red (_("Kerberos database communication failed"));
635         return (2);
636       }
638       /* Build user principal, get list of existsing principals */
639       $principal= $this->uid."@".$cfg['REALM'];
640       $principals = kadm5_get_principals($handle);
642       /* User exists in database? */
643       if (in_array($principal, $principals)){
645         /* Ok. User exists. Remove him/her */
646           $ret= kadm5_delete_principal ( $handle, $principal);
647           if ($ret === FALSE){
648             print_red (_("Can't remove user from kerberos database."));
649           }
650       }
652       /* Free kerberos admin handle */
653       kadm5_destroy($handle);
654     }
656     /* Remove ACL dependencies too, 
657      */
658     $ldap = $this->config->get_ldap_link();
659     $ldap->cd($this->config->current['BASE']);
660     $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($this->dn)."*))",array("gosaAclEntry","dn"));
661     while($attrs = $ldap->fetch()){
662       $acl = new acl($this->config,$this->parent,$attrs['dn']);
663       foreach($acl->gosaAclEntry as $id => $entry){
664         foreach($entry['members'] as $m_id => $member){
665           if($m_id == "U:".$this->dn){
666             unset($acl->gosaAclEntry[$id]['members'][$m_id]); 
667             gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for %s on object %s.",$this->dn,$attrs['dn'])); 
668           }
669         }
670       }  
671       $acl -> save();
672     }
674     /* Optionally execute a command after we're done */
675     $this->handle_post_events("remove",array("uid" => $this->uid));
676   }
679   /* Save data to object */
680   function save_object()
681   {
682     if (isset($_POST['generic'])){
684       /* Make a backup of the current selected base */
685       $base_tmp = $this->base;
687       /* Parents save function */
688       plugin::save_object ();
690       /* Save government mode attributes */
691       if ($this->config->current['GOVERNMENTMODE']){
692         foreach ($this->govattrs as $val){
693           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
694             $data= stripcslashes($_POST["$val"]);
695             if ($data != $this->$val){
696               $this->is_modified= TRUE;
697             }
698             $this->$val= $data;
699           }
700         }
701       }
703       /* In template mode, the uid is autogenerated... */
704       if ($this->is_template){
705         $this->uid= strtolower($this->sn);
706         $this->givenName= $this->sn;
707       }
709       /* Save base and pw_storage, since these are no LDAP attributes */
710       if (isset($_POST['base'])){
712         $tmp = $this->get_allowed_bases();
713         if(isset($tmp[$_POST['base']])){
714           $base= validate($_POST['base']);
715           if ($base != $this->base){
716             $this->is_modified= TRUE;
717           }
718           $this->base= $base;
719         }else{
720           $this->base = $base_tmp;
721           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
722           $this->set_acl_base('dummy,'.$this->base);
723         }
724       }
726       /* Get pw_storage mode */
727       if (isset($_POST['pw_storage'])){
728         foreach(array("pw_storage") as $val){
729           if(isset($_POST[$val])){
730             $data= validate($_POST[$val]);
731             if ($data != $this->$val){
732               $this->is_modified= TRUE;
733             }
734             $this->$val= $data;
735           }
736         }
737       }
739       $this->set_acl_base('dummy,'.$this->base);
740     }
741   }
743   function rebind($ldap, $referral)
744   {
745     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
746     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
747       $this->error = "Success";
748       $this->hascon=true;
749       $this->reconnect= true;
750       return (0);
751     } else {
752       $this->error = "Could not bind to " . $credentials['ADMIN'];
753       return NULL;
754     }
755   }
757   /* Save data to LDAP, depending on is_account we save or delete */
758   function save()
759   {
760     /* Only force save of changes .... 
761        If this attributes aren't changed, avoid saving.
762      */
763     if($this->gender=="0") $this->gender ="";
764     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
765     
766  
767     /* First use parents methods to do some basic fillup in $this->attrs */
768     plugin::save ();
770     if ($this->use_dob == "1"){
771       /* If it is an array, the generic page has never been loaded - so there's no difference. Using an array would cause an error btw. */
772       if(!is_array($this->attrs['dateOfBirth'])) {
773         $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
774       }
775     }
777     /* Remove additional objectClasses */
778     $tmp= array();
779     foreach ($this->attrs['objectClass'] as $key => $set){
780       $found= false;
781       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
782         if (preg_match ("/^$set$/i", $val)){
783           $found= true;
784           break;
785         }
786       }
787       if (!$found){
788         $tmp[]= $set;
789       }
790     }
792     /* Replace the objectClass array. This is done because of the
793        separation into government and normal mode. */
794     $this->attrs['objectClass']= $tmp;
796     /* Add objectClasss for template mode? */
797     if ($this->is_template){
798       $this->attrs['objectClass'][]= "gosaUserTemplate";
799     }
801     /* Hard coded government mode? */
802     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
803       $this->attrs['objectClass'][]= "ivbbentry";
805       /* Copy standard attributes */
806       foreach ($this->govattrs as $val){
807         if ($this->$val != ""){
808           $this->attrs["$val"]= $this->$val;
809         } elseif (!$this->is_new) {
810           $this->attrs["$val"]= array();
811         }
812       }
814       /* Remove attribute if set to "nein" */
815       if ($this->publicVisible == "nein"){
816         $this->attrs['publicVisible']= array();
817         if($this->is_new){
818           unset($this->attrs['publicVisible']);
819         }else{
820           $this->attrs['publicVisible']=array();
821         }
823       }
825     }
827     /* Special handling for attribute userCertificate needed */
828     if ($this->userCertificate != ""){
829       $this->attrs["userCertificate;binary"]= $this->userCertificate;
830       $remove_userCertificate= false;
831     } else {
832       $remove_userCertificate= true;
833     }
835     /* Special handling for dateOfBirth value */
836     if ($this->use_dob != "1"){
837       if ($this->is_new) {
838         unset($this->attrs["dateOfBirth"]);
839       } else {
840         $this->attrs["dateOfBirth"]= array();
841       }
842     }
843     if (!$this->gender){
844       if ($this->is_new) {
845         unset($this->attrs["gender"]);
846       } else {
847         $this->attrs["gender"]= array();
848       }
849     }
850     if (!$this->preferredLanguage){
851       if ($this->is_new) {
852         unset($this->attrs["preferredLanguage"]);
853       } else {
854         $this->attrs["preferredLanguage"]= array();
855       }
856     }
858     /* Special handling for attribute jpegPhote needed, scale image via
859        image magick to 147x200 pixels and inject resulting data. */
860     if ($this->jpegPhoto == "*removed*"){
861     
862       /* Reset attribute to avoid writing *removed* as value */    
863       $this->attrs["jpegPhoto"] = array();
865     } else {
867       /* Fallback if there's no image magick inside PHP */
868       if (!function_exists("imagick_blob2image")){
869         /* Get temporary file name for conversation */
870         $fname = tempnam ("/tmp", "GOsa");
872         /* Open file and write out photoData */
873         $fp = fopen ($fname, "w");
874         fwrite ($fp, $this->photoData);
875         fclose ($fp);
877         /* Build conversation query. Filename is generated automatically, so
878            we do not need any special security checks. Exec command and save
879            output. For PHP safe mode, you'll need a configuration which respects
880            image magick as executable... */
881         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
882         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
883             $query, "Execute");
885         /* Read data written by convert */
886         $output= "";
887         $sh= popen($query, 'r');
888         while (!feof($sh)){
889           $output.= fread($sh, 4096);
890         }
891         pclose($sh);
893         unlink($fname);
895         /* Save attribute */
896         $this->attrs["jpegPhoto"] = $output;
898       } else {
900         /* Load the new uploaded Photo */
901         if(!$handle  =  imagick_blob2image($this->photoData))  {
902           new log("debug","users/".get_class($this),"",array(),"Could not access uploaded image");
903         }
905         /* Resizing image to 147x200 and blur */
906         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
907           new log("debug","users/".get_class($this),"",array(),"Could not resize uploaded image");
908         }
910         /* Converting image to JPEG */
911         if(!imagick_convert($handle,"JPEG")) {
912           new log("debug","users/".get_class($this),"",array(),"Could not convert uploaded image to jepg");
913         }
915         /* Creating binary Code for the Image */
916         if(!$dump = imagick_image2blob($handle)){
917           new log("debug","users/".get_class($this),"",array(),"Could not create new user image");
918         }
920         /* Sending Image */
921         $output=  $dump;
923         /* Save attribute */
924         $this->attrs["jpegPhoto"] = $output;
925       }
927     }
929     /* This only gets called when user is renaming himself */
930     $ldap= $this->config->get_ldap_link();
931     if ($this->dn != $this->new_dn){
933       /* Write entry on new 'dn' */
934       $this->update_acls($this->dn,$this->new_dn);
935       $this->move($this->dn, $this->new_dn);
937       /* Happen to use the new one */
938       change_ui_dn($this->dn, $this->new_dn);
939       $this->dn= $this->new_dn;
940     }
943     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
944        new entries. So do a check first... */
945     $ldap->cat ($this->dn, array('dn'));
946     if ($ldap->fetch()){
947       $mode= "modify";
948     } else {
949       $mode= "add";
950       $ldap->cd($this->config->current['BASE']);
951       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
952     }
954     /* Set password to some junk stuff in case of templates */
955     if ($this->is_template){
956       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
957     }
959     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
960         $this->attributes, "Save via $mode");
962     /* Finally write data with selected 'mode' */
963     $this->cleanup();
964     $ldap->cd ($this->dn);
965     $ldap->$mode ($this->attrs);
966     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
967       return (1);
968     }
970     if($mode == "modify"){
971       new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
972     }else{
973       new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
974     }
976     /* Remove cert? 
977        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
978        to work around myself. */
979     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
981       /* Reset array, assemble new, this should be reworked */
982       $this->attrs= array();
983       $this->attrs['userCertificate;binary']= array();
985       /* Prepare connection */
986       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
987         die ("Could not connect to LDAP server");
988       }
989       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
990       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
991         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
992         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
993       }
994       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
995         ldap_start_tls($ds);
996       }
997       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
998               $this->config->current['PASSWORD']))) {
999         die ("Could not bind to LDAP");
1000       }
1002       /* Modify using attrs */
1003       ldap_mod_del($ds,$this->dn,$this->attrs);
1004       ldap_close($ds);
1005     }
1007     /* Kerberos server defined? */
1008     if (isset($this->config->data['SERVERS']['KERBEROS'])){
1009       $cfg= $this->config->data['SERVERS']['KERBEROS'];
1010     }
1011     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
1013       /* Connect to the admin interface */
1014       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
1015           $cfg['ADMIN'], $cfg['PASSWORD']);
1017       /* Errors? */             
1018       if ($handle === FALSE){
1019         print_red (_("Kerberos database communication failed"));
1020         return (2);
1021       }
1023       /* Build user principal, get list of existsing principals */
1024       $principal= $this->uid."@".$cfg['REALM'];
1025       $principals = kadm5_get_principals($handle);
1027       /* User exists in database? */
1028       if (in_array($principal, $principals)){
1030         /* Ok. User exists. Remove him/her when pw_storage has
1031            changed to be NOT kerberos. */
1032         if ($this->pw_storage != $this->config->current['KRBSASL']){
1033           $ret= kadm5_delete_principal ( $handle, $principal);
1035           if ($ret === FALSE){
1036             print_red (_("Can't remove user from kerberos database."));
1037           }
1038         }
1040       } else {
1042         /* User doesn't exists, create it when pw_storage is kerberos. */
1043         if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1044           $ret= kadm5_create_principal ( $handle, $principal);
1046           if ($ret === FALSE){
1047             print_red (_("Can't add user to kerberos database."));
1048           }
1049         }
1051       }
1053       /* Free kerberos admin handle */
1054       kadm5_destroy($handle);
1055     }
1057     /* Optionally execute a command after we're done */
1058     if ($mode == "add"){
1059       $this->handle_post_events("add", array("uid" => $this->uid));
1060     } elseif ($this->is_modified){
1061       $this->handle_post_events("modify", array("uid" => $this->uid));
1062     }
1064     /* Fix tagging if needed */
1065     $this->handle_object_tagging();
1067     return (0);
1068   }
1071   /* Check formular input */
1072   function check()
1073   {
1074     /* Call common method to give check the hook */
1075     $message= plugin::check();
1077     $pt= "";
1078     if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
1079       if(!empty($this->personalTitle)){
1080         $pt = $this->personalTitle." ";
1081       }
1082      }
1083     $this->cn= $pt.$this->givenName." ".$this->sn;
1085     /* Permissions for that base? */
1086     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1087       $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1088     } else {
1089       /* Don't touch dn, if cn hasn't changed */
1090       if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
1091           $this->orig_base == $this->base ){
1092         $this->new_dn= $this->dn;
1093       } else {
1094         $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
1095       }
1096     }
1098     /* Set the new acl base */
1099     if($this->dn == "new") {
1100       $this->set_acl_base($this->base);
1101     }
1103     /* must: sn, givenName, uid */
1104     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1105       $message[]= _("The required field 'Name' is not set.");
1106     }
1108     /* UID already used? */
1109     $ldap= $this->config->get_ldap_link();
1110     $ldap->cd($this->config->current['BASE']);
1111     $ldap->search("(uid=$this->uid)", array("uid"));
1112     $ldap->fetch();
1113     if ($ldap->count() != 0 && $this->dn == 'new'){
1114       $message[]= _("There's already a person with this 'Login' in the database.");
1115     }
1117     /* In template mode, the uid and givenName are autogenerated... */
1118     if (!$this->is_template){
1119       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1120         $message[]= _("The required field 'Given name' is not set.");
1121       }
1122       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1123         $message[]= _("The required field 'Login' is not set.");
1124       }
1125       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1126         $ldap->cat($this->new_dn);
1127         if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
1128           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1129         }
1130       }
1131     }
1133     /* Check for valid input */
1134     if ($this->is_modified && !is_uid($this->uid)){
1135       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1136     }
1137     if (!is_url($this->labeledURI)){
1138       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1139     }
1140     if (preg_match ("/[\\\\]/", $this->sn)){
1141       $message[]= _("The field 'Name' contains invalid characters.");
1142     }
1143     if (preg_match ("/[\\\\]/", $this->givenName)){
1144       $message[]= _("The field 'Given name' contains invalid characters.");
1145     }
1147     /* Check phone numbers */
1148     if (!is_phone_nr($this->telephoneNumber)){
1149       $message[]= _("The field 'Phone' contains an invalid phone number.");
1150     }
1151     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1152       $message[]= _("The field 'Fax' contains an invalid phone number.");
1153     }
1154     if (!is_phone_nr($this->mobile)){
1155       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1156     }
1157     if (!is_phone_nr($this->pager)){
1158       $message[]= _("The field 'Pager' contains an invalid phone number.");
1159     }
1161     /* Check for reserved characers */
1162     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1163       $message[]= _("The field 'Given name' contains invalid characters.");
1164     }
1165     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1166       $message[]= _("The field 'Name' contains invalid characters.");
1167     }
1169   return $message;
1170   }
1173   /* Indicate whether a password change is needed or not */
1174   function password_change_needed()
1175   {
1176     return ($this->pw_storage != $this->last_pw_storage);
1177   }
1180   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1181   function load_picture()
1182   {
1183     $ldap = $this->config->get_ldap_link();
1184     $ldap->cd ($this->dn);
1185     $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1186       
1187     if((!$data) || ($data == "*removed*")){ 
1189       /* In case we don't get an entry, load a default picture */
1190       $this->set_picture ();//"./images/default.jpg");
1191       $this->jpegPhoto= "*removed*";
1192     }else{
1194       /* Set picture */
1195       $this->photoData= $data;
1196       $_SESSION['binary']= $this->photoData;
1197       $_SESSION['binarytype']= "image/jpeg";
1198       $this->jpegPhoto= "";
1199     }
1200   }
1203   /* Load a certificate from LDAP, this is going to be simplified later on */
1204   function load_cert()
1205   {
1206     $ds= ldap_connect($this->config->current['SERVER']);
1207     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1208     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1209       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1210       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1211     }
1212     if(isset($this->config->current['TLS']) &&
1213         $this->config->current['TLS'] == "true"){
1215       ldap_start_tls($ds);
1216     }
1218     $r= ldap_bind($ds);
1219     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1221     if ($sr) {
1222       $ei= @ldap_first_entry($ds, $sr);
1223       
1224       if ($ei) {
1225         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1226           $this->userCertificate= "";
1227         } else {
1228           $this->userCertificate= $info[0];
1229         }
1230       }
1231     } else {
1232       $this->userCertificate= "";
1233     }
1235     ldap_unbind($ds);
1236   }
1239   /* Load picture from file to object */
1240   function set_picture($filename ="")
1241   {
1242     if (!is_file($filename) || $filename =="" ){
1243       $filename= "./images/default.jpg";
1244       $this->jpegPhoto= "*removed*";
1245     }
1247     $fd = fopen ($filename, "rb");
1248     $this->photoData= fread ($fd, filesize ($filename));
1249     $_SESSION['binary']= $this->photoData;
1250     $_SESSION['binarytype']= "image/jpeg";
1251     $this->jpegPhoto= "";
1253     fclose ($fd);
1254   }
1257   /* Load certificate from file to object */
1258   function set_cert($cert, $filename)
1259   {
1260     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1261     $fd = fopen ($filename, "rb");
1262     if (filesize($filename)>0) {
1263       $this->$cert= fread ($fd, filesize ($filename));
1264       fclose ($fd);
1265       $this->is_modified= TRUE;
1266     } else {
1267       print_red(_("Could not open specified certificate!"));
1268     }
1269   }
1271   /* Adapt from given 'dn' */
1272   function adapt_from_template($dn)
1273   {
1274     plugin::adapt_from_template($dn);
1276     /* Get base */
1277     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1279     if ($this->config->current['GOVERNMENTMODE']){
1281       /* Walk through govattrs */
1282       foreach ($this->govattrs as $val){
1284         if (isset($this->attrs["$val"][0])){
1286           /* If attribute is set, replace dynamic parts: 
1287              %sn, %givenName and %uid. Fill these in our local variables. */
1288           $value= $this->attrs["$val"][0];
1290           foreach (array("sn", "givenName", "uid") as $repl){
1291             if (preg_match("/%$repl/i", $value)){
1292               $value= preg_replace ("/%$repl/i",
1293                   $this->parent->$repl, $value);
1294             }
1295           }
1296           $this->$val= $value;
1297         }
1298       }
1299     }
1301     /* Get back uid/sn/givenName */
1302     if ($this->parent != NULL){
1303       $this->uid= $this->parent->uid;
1304       $this->sn= $this->parent->sn;
1305       $this->givenName= $this->parent->givenName;
1306     }
1307   }
1309  
1310   /* This avoids that users move themselves out of their rights. 
1311    */
1312   function allowedBasesToMoveTo()
1313   {
1314     /* Get bases */
1315     $bases  = $this->get_allowed_bases();
1316     return($bases);
1317   } 
1320   function getCopyDialog()
1321   {
1322     $str = "";
1324     $_SESSION['binary'] = $this->photoData; 
1325     $_SESSION['binarytype']= "image/jpeg";
1327     /* Get random number for pictures */
1328     srand((double)microtime()*1000000); 
1329     $rand = rand(0, 10000);
1331     $smarty = get_smarty();
1333     $smarty->assign("passwordTodo","clear");
1335     if(isset($_POST['passwordTodo'])){
1336       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1337     }
1339     $smarty->assign("sn",       $this->sn);
1340     $smarty->assign("givenName",$this->givenName);
1341     $smarty->assign("uid",      $this->uid);
1342     $smarty->assign("rand",     $rand);
1343     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1346     $ret = array();
1347     $ret['string'] = $str;
1348     $ret['status'] = "";  
1349     return($ret);
1350   }
1352   function saveCopyDialog()
1353   {
1354     /* Set_acl_base */
1355     $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1357     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1358       $this->set_picture($_FILES['picture_file']['tmp_name']);
1359     }
1361     /* Remove picture? */
1362     if (isset($_POST['picture_remove'])){
1363       $this->jpegPhoto= "*removed*";
1364       $this->set_picture ("./images/default.jpg");
1365       $this->is_modified= TRUE;
1366     }
1368     $attrs = array("uid","givenName","sn");
1369     foreach($attrs as $attr){
1370       if(isset($_POST[$attr])){
1371         $this->$attr = $_POST[$attr];
1372       }
1373     } 
1374   }
1377   function PrepareForCopyPaste($source)
1378   {
1379     plugin::PrepareForCopyPaste($source);
1381     /* Reset certificate information addepted from source user
1382        to avoid setting the same user certificate for the destination user. */
1383     $this->userPKCS12= "";
1384     $this->userSMIMECertificate= "";
1385     $this->userCertificate= "";
1386     $this->certificateSerialNumber= "";
1387     $this->old_certificateSerialNumber= "";
1388     $this->old_userPKCS12= "";
1389     $this->old_userSMIMECertificate= "";
1390     $this->old_userCertificate= "";
1391   }
1394   function plInfo()
1395   {
1396   
1397     $govattrs= array(
1398         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1399         "houseIdentifier"                           =>  _("House identifier"), 
1400         "vocation"                                  =>  _("Vocation"),
1401         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1402         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1403         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1404         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1405         "functionalTitle"                           =>  _("Functional title"),
1406         "certificateSerialNumber"                   =>  _("Certificate serial number"),
1407         "publicVisible"                             =>  _("Public visible"),
1408         "street"                                    =>  _("Street"),
1409         "role"                                      =>  _("Role"),
1410         "postalCode"                                =>  _("Postal code"));
1412     $ret = array(
1413         "plShortName" => _("Generic"),
1414         "plDescription" => _("Generic user settings"),
1415         "plSelfModify"  => TRUE,
1416         "plDepends"     => array(),
1417         "plPriority"    => 1,
1418         "plSection"     => array("personal" => _("My account")),
1419         "plCategory"    => array("users" => array("description" => _("Users"),
1420                                                   "objectClass" => "gosaAccount")),
1422         "plProvidedAcls" => array(
1423           "base"              => _("Base"), 
1424           "userPassword"      => _("User password"), 
1425           "sn"                => _("Surename"),
1426           "givenName"         => _("Given name"),
1427           "uid"               => _("User identification"),
1428           "personalTitle"     => _("Personal title"),
1429           "academicTitle"     => _("Academic title"),
1430           "homePostalAddress" => _("Home postal address"),
1431           "homePhone"         => _("Home phone number"),
1432           "labeledURI"        => _("Homepage"),
1433           "o"                 => _("Organization"),
1434           "ou"                => _("Department"),
1435           "dateOfBirth"       => _("Date of birth"),
1436           "gender"            => _("Gender"),
1437           "preferredLanguage" => _("Preferred language"),
1438           "departmentNumber"  => _("Department number"),
1439           "employeeNumber"    => _("Employee number"),
1440           "employeeType"      => _("Employee type"),
1441           "l"                 => _("Location"),
1442           "st"                => _("State"),
1443           "userPicture"       => _("User picture"),
1444           "roomNumber"        => _("Room number"),
1445           "telephoneNumber"   => _("Telefon number"),
1446           "mobile"            => _("Mobile number"),
1447           "pager"             => _("Pager number"),
1448           "Certificate"        => _("User certificates"),
1450           "postalAddress"                => _("Postal address"),
1451           "facsimileTelephoneNumber"     => _("Fax number"))
1452         );
1454     /* Append government attributes if required */
1455       global $config;
1456     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1457       foreach($govattrs as $attr => $desc){
1458         $ret["plProvidedAcls"][$attr] = $desc;
1459       }
1460     }
1462     return($ret);
1463   }
1466 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1467 ?>