Code

W3c ......
[gosa.git] / include / class_config.inc
1 <?php
2 /*
3  * This code is part of GOsa (https://gosa.gonicus.de)
4  * Copyright (C) 2003-2006 - Cajus Pollmeier <pollmeier@gonicus.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 class config  {
23   /* XML parser */
24   var $parser;
25   var $config_found= FALSE;
26   var $tags= array();
27   var $level= 0;
28   var $gpc= 0;
29   var $section= "";
30   var $currentLocation= "";
32   /* Selected connection */
33   var $current= array();
35   /* Link to LDAP-server */
36   var $ldap= NULL;
37   var $referrals= array();
39   /* Configuration data */
40   var $data= array( 'TABS' => array(), 'LOCATIONS' => array(), 'SERVERS' => array(),
41       'MAIN' => array( 'LANGUAGES' => array(), 'FAXFORMATS' => array() ),
42       'MENU' => array(), 'SERVICE' => array());
43   var $basedir= "";
45   /* Keep a copy of the current deparment list */
46   var $departments= array();
47   var $idepartments= array();
48   var $adepartments= array();
49   var $tdepartments= array();
51   function config($filename, $basedir= "")
52   {
53     $this->parser = xml_parser_create();
54     $this->basedir= $basedir;
56     xml_set_object($this->parser, $this);
57     xml_set_element_handler($this->parser, "tag_open", "tag_close");
59     /* Parse config file directly? */
60     if ($filename != ""){
61       $this->parse($filename);
62     }
63   }
65   function parse($filename)
66   { 
67     $fh= fopen($filename, "r"); 
68     $xmldata= fread($fh, 100000);
69     fclose($fh); 
70     if(!xml_parse($this->parser, chop($xmldata))){
71       print_red(sprintf(_("XML error in gosa.conf: %s at line %d"),
72             xml_error_string(xml_get_error_code($this->parser)),
73             xml_get_current_line_number($this->parser)));
74       echo $_SESSION['errors'];
75       exit;
76     }
77   }
79   function tag_open($parser, $tag, $attrs)
80   { 
81     /* Save last and current tag for reference */
82     $this->tags[$this->level]= $tag;
83     $this->level++;
85     /* Trigger on CONF section */
86     if ($tag == 'CONF'){
87       $this->config_found= TRUE;
88     }
90     /* Return if we're not in config section */
91     if (!$this->config_found){
92       return;
93     }
95     /* yes/no to true/false and upper case TRUE to true and so on*/
96     foreach($attrs as $name => $value){
97       if(preg_match("/^(true|yes)$/i",$value)){
98         $attrs[$name] = "true";
99       }elseif(preg_match("/^(false|no)$/i",$value)){
100         $attrs[$name] = "false";
101       } 
102     }
104     /* Look through attributes */
105     switch ($this->tags[$this->level-1]){
108       /* Handle tab section */
109       case 'TAB':       $name= $this->tags[$this->level-2];
111                   /* Create new array? */
112                   if (!isset($this->data['TABS'][$name])){
113                     $this->data['TABS'][$name]= array();
114                   }
116                   /* Add elements */
117                   $this->data['TABS'][$name][]= $attrs;
118                   break;
120                   /* Handle location */
121       case 'LOCATION':
122                   if ($this->tags[$this->level-2] == 'MAIN'){
123                     $name= $attrs['NAME'];
124                     $this->currentLocation= $name;
126                     /* Add location elements */
127                       $this->data['LOCATIONS'][$name]= $attrs;
128                     }
129                   break;
131                   /* Handle referral tags */
132       case 'REFERRAL':
133                   if ($this->tags[$this->level-2] == 'LOCATION'){
134                     $url= $attrs['URL'];
135                     $server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
137                     /* Add location elements */
138                     if (!isset($this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'])){
139                       $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL']= array();
140                     }
142                     $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'][$server]= $attrs;
143                   }
144                   break;
146                   /* Handle language */
147       case 'LANGUAGE':
148                   if ($this->tags[$this->level-2] == 'MAIN'){
149                     /* Add languages */
150                     $this->data['MAIN']['LANGUAGES'][$attrs['NAME']]= 
151                       $attrs['TAG'];
152                   }
153                   break;
155                   /* Handle faxformat */
156       case 'FAXFORMAT': 
157                   if ($this->tags[$this->level-2] == 'MAIN'){
158                     /* Add fax formats */
159                     $this->data['MAIN']['FAXFORMATS'][]= $attrs['TYPE'];
160                   }
161                   break;
163                   /* Load main parameters */
164       case 'MAIN':
165                   $this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs);
166                   break;
168                   /* Load menu */
169       case 'SECTION':
170                   if ($this->tags[$this->level-2] == 'MENU'){
171                     $this->section= $attrs['NAME'];
172                     $this->data['MENU'][$this->section]= array(); ;
173                   }
174                   break;
176                   /* Inser plugins */
177       case 'PLUGIN':
178                   if ($this->tags[$this->level-3] == 'MENU' &&
179                       $this->tags[$this->level-2] == 'SECTION'){
181                     $this->data['MENU'][$this->section][$this->gpc++]= $attrs;
182                   }
183                   if ($this->tags[$this->level-2] == 'SERVICEMENU'){
184                     $this->data['SERVICE'][$attrs['CLASS']]= $attrs;
185                   }
186                   break;
187     }
188   }
190   function tag_close($parser, $tag)
191   {
192     /* Close config section */
193     if ($tag == 'CONF'){
194       $this->config_found= FALSE;
195     }
196     $this->level--;
197   }
199   function get_ldap_link($sizelimit= FALSE)
200   {
201     /* Build new connection */
202     $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
203         $this->current['ADMIN'], $this->current['PASSWORD']);
205     /* Check for connection */
206     if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
207       $smarty= get_smarty();
208       print_red (_("Can't bind to LDAP. Please contact the system administrator."));
209       $smarty->display (get_template_path('headers.tpl'));
210       echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
211       exit();
212     }
214     if (!isset($_SESSION['size_limit'])){
215       $_SESSION['size_limit']= $this->current['SIZELIMIT'];
216       $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
217     }
219     if ($sizelimit){
220       $this->ldap->set_size_limit($_SESSION['size_limit']);
221     } else {
222       $this->ldap->set_size_limit(0);
223     }
225     /* Move referrals */
226     if (!isset($this->current['REFERRAL'])){
227       $this->ldap->referrals= array();
228     } else {
229       $this->ldap->referrals= $this->current['REFERRAL'];
230     }
232     return ($this->ldap);
233   }
235   function set_current($name)
236   {
237     $this->current= $this->data['LOCATIONS'][$name];
238     if (!isset($this->current['PEOPLE'])){
239       $this->current['PEOPLE']= "ou=people";
240     }
241     if (!isset($this->current['GROUPS'])){
242       $this->current['GROUPS']= "ou=groups";
243     }
244     if (!isset($this->current['WINSTATIONS'])){
245       $this->current['WINSTATIONS']= "ou=winstations,ou=systems";
246     }
247     if (!isset($this->current['HASH'])){
248       $this->current['HASH']= "crypt";
249     }
250     if (!isset($this->current['DNMODE'])){
251       $this->current['DNMODE']= "cn";
252     }
253     if (!isset($this->current['MINID'])){
254       $this->current['MINID']= 100;
255     }
256     if (!isset($this->current['SIZELIMIT'])){
257       $this->current['SIZELIMIT']= 200;
258     }
259     if (!isset($this->current['SIZEINGORE'])){
260       $this->current['SIZEIGNORE']= TRUE;
261     } else {
262       if (preg_match("/true/i", $this->current['SIZEIGNORE'])){
263         $this->current['SIZEIGNORE']= TRUE;
264       } else {
265         $this->current['SIZEIGNORE']= FALSE;
266       }
267     }
269     /* Sort referrals, if present */
270     if (isset ($this->current['REFERRAL'])){
271       $bases= array();
272       $servers= array();
273       foreach ($this->current['REFERRAL'] as $ref){
274         $server= preg_replace('%^(.*)/[^/]+$%', '\\1', $ref['URL']);
275         $base= preg_replace('%^.*/([^/]+)$%', '\\1', $ref['URL']);
276         $bases[$base]= strlen($base);
277         $servers[$base]= $server;
278       }
279       asort($bases);
280       reset($bases);
281     }
283     /* SERVER not defined? Load the one with the shortest base */
284     if (!isset($this->current['SERVER'])){
285       $this->current['SERVER']= $servers[key($bases)];
286     }
288     /* BASE not defined? Load the one with the shortest base */
289     if (!isset($this->current['BASE'])){
290       $this->current['BASE']= key($bases);
291     }
293     /* Convert BASE to have escaped special characters */
294     $this->current['BASE']= @LDAP::convert($this->current['BASE']);
296     /* Parse LDAP referral informations */
297     if (!isset($this->current['ADMIN']) || !isset($this->current['PASSWORD'])){
298       $url= $this->current['SERVER'];
299       $referral= $this->current['REFERRAL'][$url];
300       $this->current['ADMIN']= $referral['ADMIN'];
301       $this->current['PASSWORD']= $referral['PASSWORD'];
302     }
304     /* Load server informations */
305     $this->load_servers();
306   }
308   function load_servers ()
309   {
310     /* Only perform actions if current is set */
311     if ($this->current == NULL){
312       return;
313     }
315     /* Fill imap servers */
316     $ldap= $this->get_ldap_link();
317     $ldap->cd ($this->current['BASE']);
318     $ldap->search ("(objectClass=goImapServer)");
320     $this->data['SERVERS']['IMAP']= array();
321     error_reporting(0);
322     while ($attrs= $ldap->fetch()){
323       $name= $attrs['goImapName'][0];
324       $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
325           "admin" => $attrs['goImapAdmin'][0],
326           "password" => $attrs['goImapPassword'][0],
327           "sieve_server" => $attrs['goImapSieveServer'][0],
328           "sieve_port" => $attrs['goImapSievePort'][0]);
329     }
330     error_reporting(E_ALL);
332     /* Get kerberos server. FIXME: only one is supported currently */
333     $ldap->cd ($this->current['BASE']);
334     $ldap->search ("(objectClass=goKrbServer)");
335     if ($ldap->count()){
336       $attrs= $ldap->fetch();
337       $this->data['SERVERS']['KERBEROS']= array( 'SERVER' => $attrs['cn'][0],
338           'REALM' => $attrs['goKrbRealm'][0],
339           'ADMIN' => $attrs['goKrbAdmin'][0],
340           'PASSWORD' => $attrs['goKrbPassword'][0]);
341     }
343     /* Get cups server. FIXME: only one is supported currently */
344     $ldap->cd ($this->current['BASE']);
345     $ldap->search ("(objectClass=goCupsServer)");
346     if ($ldap->count()){
347       $attrs= $ldap->fetch();
348       $this->data['SERVERS']['CUPS']= $attrs['cn'][0];  
349     }
351     /* Get fax server. FIXME: only one is supported currently */
352     $ldap->cd ($this->current['BASE']);
353     $ldap->search ("(objectClass=goFaxServer)");
354     if ($ldap->count()){
355       $attrs= $ldap->fetch();
356       $this->data['SERVERS']['FAX']= array( 'SERVER' => $attrs['cn'][0],
357           'LOGIN' => $attrs['goFaxAdmin'][0],
358           'PASSWORD' => $attrs['goFaxPassword'][0]);
359     }
361     /* Get asterisk servers */
362     $ldap->cd ($this->current['BASE']);
363     $ldap->search ("(objectClass=goFonServer)");
364     if ($ldap->count()){
365       $attrs= $ldap->fetch();
366       $this->data['SERVERS']['FON']= array( 
367           'SERVER'      => $attrs['cn'][0],
368           'LOGIN'       => $attrs['goFonAdmin'][0],
369           'PASSWORD'    => $attrs['goFonPassword'][0],
370           'DB'          => "gophone",
371           'SIP_TABLE'           => "sip_users",
372           'EXT_TABLE'   => "extensions",
373           'VOICE_TABLE' => "voicemail_users",
374           'QUEUE_TABLE' => "queues",
375           'QUEUE_MEMBER_TABLE'  => "queue_members");
376     }
378     /* Get asterisk servers */
379     $ldap->cd ($this->current['BASE']);
380     $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
381     if ($ldap->count()){
382       $attrs= $ldap->fetch();
383       if(!isset($attrs['goGlpiPassword'])){
384         $attrs['goGlpiPassword'][0] ="";
385       }
386       $this->data['SERVERS']['GLPI']= array( 
387           'SERVER'      => $attrs['cn'][0],
388           'LOGIN'       => $attrs['goGlpiAdmin'][0],
389           'PASSWORD'    => $attrs['goGlpiPassword'][0],
390           'DB'          => $attrs['goGlpiDatabase'][0]);
391     }
392     /* Get logdb server */
393     $ldap->cd ($this->current['BASE']);
394     $ldap->search ("(objectClass=goLogDBServer)");
395     if ($ldap->count()){
396       $attrs= $ldap->fetch();
397       $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
398           'LOGIN' => $attrs['goLogAdmin'][0],
399           'PASSWORD' => $attrs['goLogPassword'][0]);
400     }
402     /* Get NFS server lists */
403     $tmp= array("default");
404     $ldap->cd ($this->current['BASE']);
405     $ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
406     while ($attrs= $ldap->fetch()){
407       for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
408         if(!preg_match('/^[^|]+\|[^|]+\|NFS\|.*$/', $attrs["goExportEntry"][$i])){
409           continue;
410         }
411         $path= preg_replace ("/^[^|]+\|[^|]+\|[^|]+\|[^|]+\|([^|]+).*$/", '\1', $attrs["goExportEntry"][$i]);
412         $tmp[]= $attrs["cn"][0].":$path";
413       }
414     }
415     $this->data['SERVERS']['NFS']= $tmp;
417     /* Load Terminalservers */
418     $ldap->cd ($this->current['BASE']);
419     $ldap->search ("(objectClass=goTerminalServer)");
420     $this->data['SERVERS']['TERMINAL']= array();
421     $this->data['SERVERS']['TERMINAL'][]= "default";
423     $this->data['SERVERS']['FONT']= array();
424     $this->data['SERVERS']['FONT'][]= "default";
425     while ($attrs= $ldap->fetch()){
426       $this->data['SERVERS']['TERMINAL'][]= $attrs["cn"][0];
427       for ($i= 0; $i<$attrs["goFontPath"]["count"]; $i++){
428         $this->data['SERVERS']['FONT'][]= $attrs["goFontPath"][$i];
429       }
430     }
432     /* Ldap Server */
433     $this->data['SERVERS']['LDAP']= array();
434     $ldap->cd ($this->current['BASE']);
435     $ldap->search ("(objectClass=goLdapServer)");
436     while ($attrs= $ldap->fetch()){
437       if (isset($attrs["goLdapBase"])){
438         for ($i= 0; $i<$attrs["goLdapBase"]["count"]; $i++){
439           $this->data['SERVERS']['LDAP'][]= $attrs["cn"][0].":".$attrs["goLdapBase"][$i];
440         }
441       }
442     }
444     /* Get misc server lists */
445     $this->data['SERVERS']['SYSLOG']= array("default");
446     $this->data['SERVERS']['NTP']= array("default");
447     $ldap->cd ($this->current['BASE']);
448     $ldap->search ("(objectClass=goNtpServer)");
449     while ($attrs= $ldap->fetch()){
450       $this->data['SERVERS']['NTP'][]= $attrs["cn"][0];
451     }
452     $ldap->cd ($this->current['BASE']);
453     $ldap->search ("(objectClass=goSyslogServer)");
454     while ($attrs= $ldap->fetch()){
455       $this->data['SERVERS']['SYSLOG'][]= $attrs["cn"][0];
456     }
458     /* Get samba servers from LDAP, in case of samba3 */
459     if ($this->current['SAMBAVERSION'] == 3){
460       $this->data['SERVERS']['SAMBA']= array();
461       $ldap->cd ($this->current['BASE']);
462       $ldap->search ("(objectClass=sambaDomain)");
463       while ($attrs= $ldap->fetch()){
464         $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array(
465             "SID" => $attrs["sambaSID"][0],
466             "RIDBASE" => $attrs["sambaAlgorithmicRidBase"][0]);
467       }
469       /* If no samba servers are found, look for configured sid/ridbase */
470       if (count($this->data['SERVERS']['SAMBA']) == 0){
471         if (!isset($this->current["SID"]) || !isset($this->current["RIDBASE"])){
472           print_red(_("SID and/or RIDBASE missing in your configuration!"));
473           echo $_SESSION['errors'];
474           exit;
475         } else {
476           $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
477               "SID" => $this->current["SID"],
478               "RIDBASE" => $this->current["RIDBASE"]);
479         }
480       }
481     }
482   }
485   function get_departments($ignore_dn= "")
486   {
487     global $config;
489     /* Initialize result hash */
490     $result= array();
491     $administrative= array();
492     $result['/']= $this->current['BASE'];
493     $this->tdepartments= array();
495     /* Get list of department objects */
496     $ldap= $this->get_ldap_link();
497     $ldap->cd ($this->current['BASE']);
498     $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
499     while ($attrs= $ldap->fetch()){
500       $dn= $ldap->getDN();
501       $this->tdepartments[$dn]= "";
503       /* Save administrative departments */
504       if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
505           isset($attrs['gosaUnitTag'][0])){
506         $administrative[$dn]= $attrs['gosaUnitTag'][0];
507         $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
508       }
509     
510       if (in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass']) &&
511           isset($attrs['gosaUnitTag'][0])){
512         $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
513       }
514     
515       if ($dn == $ignore_dn){
516         continue;
517       }
519       /* Only assign non-root departments */
520       if ($dn != $result['/']){
521         $result[convert_department_dn($dn)]= $dn;
522       }
523     }
525     $this->adepartments= $administrative;
526     $this->departments= $result;
527   }
530   function make_idepartments($max_size= 28)
531   {
532     global $config;
533     $base = $config->current['BASE'];
535     $arr = array();
536     $ui= get_userinfo();
538     $this->idepartments= array();
540     /* Create multidimensional array, with all departments. */
541     foreach ($this->departments as $key => $val){
543       /* When using strict_units, filter non relevant parts */
544       if (isset($config->current['STRICT_UNITS']) && preg_match('/true/i', $config->current['STRICT_UNITS'])){
545         if ($ui->gosaUnitTag != "" && isset($this->tdepartments[$val]) &&
546             $this->tdepartments[$val] != $ui->gosaUnitTag){
547           continue;
548         }
549       }
551       /* remove base from dn */
552       $val2 = str_replace($base,"",$val);
554       /* Get every single ou */
555       $str = preg_replace("/ou=/","|ou=",$val2);        
556       $elements = array_reverse(split("\|",$str));              
558       /* Save last array position */
559       $last = &$arr;
561       /* Get array depth  */
562       $cnt = count($elements);
564       /* Add last ou element of current dn to our array */
565       foreach($elements as $key => $ele){
567         /* skip enpty */
568         if(empty($ele)) continue;
570         /* Extract department name */           
571         $elestr = preg_replace("/^ou=/","", $ele);
572         $elestr = preg_replace("/,$/","",$elestr);      
574         /* Add to array */      
575         if($key == ($cnt-2)){
576           $last[$elestr]['ENTRY'] = $val;
577         }
579         /* Set next array appending position */
580         $last = &$last[$elestr]['SUB'];
581       }
582     }
584     /* Add base entry */
585     $ret["/"]["ENTRY"]  = $base;
586     $ret["/"]["SUB"]    = $arr;
588     $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size);
589   }
592   /* Creates display friendly output from make_idepartments */
593   function generateDepartmentArray($arr,$depth = -1,$max_size){
594     $ret = array();
595     $depth ++;
597     /* Walk through array */    
598     foreach($arr as $name => $entries){
600       /* If this department is the last in the current tree position 
601        * remove it, to avoid generating output for it */
602       if(count($entries['SUB'])==0){
603         unset($entries['SUB']);
604       }
606       /* Fix name, if it contains a replace tag */
607       $name= @LDAP::fix($name);
609       /* Check if current name is too long, then cut it */
610       if(mb_strlen($name, 'UTF-8')> $max_size){
611         $name = mb_substr($name,0,($max_size-3), 'UTF-8')." ...";
612       }
614       /* Append the name to the list */ 
615       if(isset($entries['ENTRY'])){
616         $a = "";
617         for($i = 0 ; $i < $depth ; $i ++){
618           $a.="&nbsp;";
619         }
620         $ret[$entries['ENTRY']]=$a."&nbsp;".$name;
621       } 
623       /* recursive add of subdepartments */
624       if(isset($entries['SUB'])){
625         $ret = array_merge($ret,$this->generateDepartmentArray($entries['SUB'],$depth,$max_size));
626       }
627     }
629     return($ret);
630   }
632   /* This function returns all available Shares defined in this ldap
633    * There are two ways to call this function, if listboxEntry is true
634    *  only name and path are attached to the array, in it is false, the whole
635    *  entry will be parsed an atached to the result.
636    */
637   function getShareList($listboxEntry = false)
638   {
639     $ldap= $this->get_ldap_link();
640     $base =  $this->current['BASE'];
641     $res= get_list("(&(objectClass=goShareServer)(goExportEntry=*))","server",$base,array("goExportEntry","cn"),GL_SUBSEARCH);
642     $return = array();
644     foreach($res as $entry){
645       if(obj_is_readable($entry['dn'], "server/goShareServer","goExportEntry")){
647         if(isset($entry['goExportEntry']['count'])){
648           unset($entry['goExportEntry']['count']);
649         }
650         if(isset($entry['goExportEntry'])){
651           foreach($entry['goExportEntry'] as $export){
652             $shareAttrs = split("\|",$export);
653             if($listboxEntry) {
654               $return[$shareAttrs[0]."|".$entry['cn'][0]] = $shareAttrs[0]." - ".$entry['cn'][0];
655             }else{
656               $return[$shareAttrs[0]."|".$entry['cn'][0]]['server']       = $entry['cn'][0];
657               $return[$shareAttrs[0]."|".$entry['cn'][0]]['name']         = $shareAttrs[0];
658               $return[$shareAttrs[0]."|".$entry['cn'][0]]['description']  = $shareAttrs[1];
659               $return[$shareAttrs[0]."|".$entry['cn'][0]]['type']         = $shareAttrs[2];
660               $return[$shareAttrs[0]."|".$entry['cn'][0]]['charset']      = $shareAttrs[3];
661               $return[$shareAttrs[0]."|".$entry['cn'][0]]['path']         = $shareAttrs[4];
662               $return[$shareAttrs[0]."|".$entry['cn'][0]]['option']       = $shareAttrs[5];
663             }
664           }
665         }
666       } 
667     }
669     return($return);
670   }
672   /* This function returns all available ShareServer */
673   function getShareServerList()
674   {
675     global $config;
676     $return = array();
677     $ui = get_userinfo();
678     $base = $config->current['BASE'];
680     $res= get_list("(&(objectClass=goShareServer)(goExportEntry=*))", "server", $base,array("goExportEntry","cn"),GL_SUBSEARCH);
681     foreach($res as $entry){
682       if(obj_is_readable($entry['dn'], "server/goShareServer","goExportEntry")){
683         if(isset($entry['goExportEntry']['count'])){
684           unset($entry['goExportEntry']['count']);
685         }
686         foreach($entry['goExportEntry'] as $share){
687           $a_share = split("\|",$share);
688           $sharename = $a_share[0];
689           $return[$entry['cn'][0]."|".$sharename] = $entry['cn'][0]." [".$sharename."]";
690         }
691       }
692     }
693     return($return);
694   }
696   /* Check if there's the specified bool value set in the configuration */
697   function boolValueIsTrue($section, $value)
698   {
699     $section= strtoupper($section);
700     $value= strtoupper($value);
701     if (isset($this->data[$section][$value])){
702     
703       $data= $this->data[$section][$value];
704       if (preg_match("/^true$/i", $data) || preg_match("/yes/i", $data)){
705         return TRUE;
706       }
708     }
710     return FALSE;
711   }
715 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
716 ?>