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]){
107 /* Handle tab section */
108 case 'TAB': $name= $this->tags[$this->level-2];
110 /* Create new array? */
111 if (!isset($this->data['TABS'][$name])){
112 $this->data['TABS'][$name]= array();
113 }
115 /* Add elements */
116 $this->data['TABS'][$name][]= $attrs;
117 break;
119 /* Handle location */
120 case 'LOCATION':
121 if ($this->tags[$this->level-2] == 'MAIN'){
122 $name= $attrs['NAME'];
123 $this->currentLocation= $name;
125 /* Add location elements */
126 $this->data['LOCATIONS'][$name]= $attrs;
127 }
128 break;
130 /* Handle referral tags */
131 case 'REFERRAL':
132 if ($this->tags[$this->level-2] == 'LOCATION'){
133 $url= $attrs['URL'];
134 $server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
136 /* Add location elements */
137 if (!isset($this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'])){
138 $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL']= array();
139 }
141 $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'][$server]= $attrs;
142 }
143 break;
145 /* Handle language */
146 case 'LANGUAGE':
147 if ($this->tags[$this->level-2] == 'MAIN'){
148 /* Add languages */
149 $this->data['MAIN']['LANGUAGES'][$attrs['NAME']]=
150 $attrs['TAG'];
151 }
152 break;
154 /* Handle faxformat */
155 case 'FAXFORMAT':
156 if ($this->tags[$this->level-2] == 'MAIN'){
157 /* Add fax formats */
158 $this->data['MAIN']['FAXFORMATS'][]= $attrs['TYPE'];
159 }
160 break;
162 /* Load main parameters */
163 case 'MAIN':
164 $this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs);
165 break;
167 /* Load menu */
168 case 'SECTION':
169 if ($this->tags[$this->level-2] == 'MENU'){
170 $this->section= $attrs['NAME'];
171 $this->data['MENU'][$this->section]= array(); ;
172 }
173 break;
175 /* Inser plugins */
176 case 'PLUGIN':
177 if ($this->tags[$this->level-3] == 'MENU' &&
178 $this->tags[$this->level-2] == 'SECTION'){
180 $this->data['MENU'][$this->section][$this->gpc++]= $attrs;
181 }
182 if ($this->tags[$this->level-2] == 'SERVICEMENU'){
183 $this->data['SERVICE'][$attrs['CLASS']]= $attrs;
184 }
185 break;
186 }
187 }
189 function tag_close($parser, $tag)
190 {
191 /* Close config section */
192 if ($tag == 'CONF'){
193 $this->config_found= FALSE;
194 }
195 $this->level--;
196 }
198 function get_ldap_link($sizelimit= FALSE)
199 {
200 /* Build new connection */
201 $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
202 $this->current['ADMIN'], $this->current['PASSWORD']);
204 /* Check for connection */
205 if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
206 $smarty= get_smarty();
207 print_red (_("Can't bind to LDAP. Please contact the system administrator."));
208 $smarty->display (get_template_path('headers.tpl'));
209 echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
210 exit();
211 }
213 if (!isset($_SESSION['size_limit'])){
214 $_SESSION['size_limit']= $this->current['SIZELIMIT'];
215 $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
216 }
218 if ($sizelimit){
219 $this->ldap->set_size_limit($_SESSION['size_limit']);
220 } else {
221 $this->ldap->set_size_limit(0);
222 }
224 /* Move referrals */
225 if (!isset($this->current['REFERRAL'])){
226 $this->ldap->referrals= array();
227 } else {
228 $this->ldap->referrals= $this->current['REFERRAL'];
229 }
231 return ($this->ldap);
232 }
234 function set_current($name)
235 {
236 $this->current= $this->data['LOCATIONS'][$name];
237 if (!isset($this->current['PEOPLE'])){
238 $this->current['PEOPLE']= "ou=people";
239 }
240 if (!isset($this->current['GROUPS'])){
241 $this->current['GROUPS']= "ou=groups";
242 }
244 if (isset($this->current['INITIAL_BASE'])){
245 $_SESSION['CurrentMainBase']= $this->current['INITIAL_BASE'];
246 }
248 /* Remove possibly added ',' from end of group and people ou */
249 $this->current['GROUPS'] = preg_replace("/,*$/","",$this->current['GROUPS']);
250 $this->current['PEOPLE'] = preg_replace("/,*$/","",$this->current['PEOPLE']);
252 if (!isset($this->current['WINSTATIONS'])){
253 $this->current['WINSTATIONS']= "ou=winstations,ou=systems";
254 }
255 if (!isset($this->current['HASH'])){
256 $this->current['HASH']= "crypt";
257 }
258 if (!isset($this->current['DNMODE'])){
259 $this->current['DNMODE']= "cn";
260 }
261 if (!isset($this->current['MINID'])){
262 $this->current['MINID']= 100;
263 }
264 if (!isset($this->current['SIZELIMIT'])){
265 $this->current['SIZELIMIT']= 200;
266 }
267 if (!isset($this->current['SIZEINGORE'])){
268 $this->current['SIZEIGNORE']= TRUE;
269 } else {
270 if (preg_match("/true/i", $this->current['SIZEIGNORE'])){
271 $this->current['SIZEIGNORE']= TRUE;
272 } else {
273 $this->current['SIZEIGNORE']= FALSE;
274 }
275 }
277 /* Sort referrals, if present */
278 if (isset ($this->current['REFERRAL'])){
279 $bases= array();
280 $servers= array();
281 foreach ($this->current['REFERRAL'] as $ref){
282 $server= preg_replace('%^(.*)/[^/]+$%', '\\1', $ref['URL']);
283 $base= preg_replace('%^.*/([^/]+)$%', '\\1', $ref['URL']);
284 $bases[$base]= strlen($base);
285 $servers[$base]= $server;
286 }
287 asort($bases);
288 reset($bases);
289 }
291 /* SERVER not defined? Load the one with the shortest base */
292 if (!isset($this->current['SERVER'])){
293 $this->current['SERVER']= $servers[key($bases)];
294 }
296 /* BASE not defined? Load the one with the shortest base */
297 if (!isset($this->current['BASE'])){
298 $this->current['BASE']= key($bases);
299 }
301 /* Convert BASE to have escaped special characters */
302 $this->current['BASE']= @LDAP::convert($this->current['BASE']);
304 /* Parse LDAP referral informations */
305 if (!isset($this->current['ADMIN']) || !isset($this->current['PASSWORD'])){
306 $url= $this->current['SERVER'];
307 $referral= $this->current['REFERRAL'][$url];
308 $this->current['ADMIN']= $referral['ADMIN'];
309 $this->current['PASSWORD']= $referral['PASSWORD'];
310 }
312 /* Possibly load kerberos style */
313 if (isset($this->current['KRBSASL'])){
314 if (preg_match('/^(yes|true)$/i', $this->current['KRBSASL'])){
315 $this->current['KRBSASL']= "sasl";
316 } else {
317 $this->current['KRBSASL']= "kerberos";
318 }
319 } else {
320 $this->current['KRBSASL']= "kerberos";
321 }
323 /* Load server informations */
324 $this->load_servers();
325 }
327 function load_servers ()
328 {
329 /* Only perform actions if current is set */
330 if ($this->current == NULL){
331 return;
332 }
334 /* Fill imap servers */
335 $ldap= $this->get_ldap_link();
336 $ldap->cd ($this->current['BASE']);
337 $ldap->search ("(objectClass=goImapServer)");
339 $this->data['SERVERS']['IMAP']= array();
340 error_reporting(0);
341 while ($attrs= $ldap->fetch()){
342 $name= $attrs['goImapName'][0];
343 $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
344 "admin" => $attrs['goImapAdmin'][0],
345 "password" => $attrs['goImapPassword'][0],
346 "sieve_server" => $attrs['goImapSieveServer'][0],
347 "sieve_port" => $attrs['goImapSievePort'][0]);
348 }
349 error_reporting(E_ALL);
351 /* Get kerberos server. FIXME: only one is supported currently */
352 $ldap->cd ($this->current['BASE']);
353 $ldap->search ("(objectClass=goKrbServer)");
354 if ($ldap->count()){
355 $attrs= $ldap->fetch();
356 $this->data['SERVERS']['KERBEROS']= array( 'SERVER' => $attrs['cn'][0],
357 'REALM' => $attrs['goKrbRealm'][0],
358 'ADMIN' => $attrs['goKrbAdmin'][0],
359 'PASSWORD' => $attrs['goKrbPassword'][0]);
360 }
362 /* Get cups server. FIXME: only one is supported currently */
363 $ldap->cd ($this->current['BASE']);
364 $ldap->search ("(objectClass=goCupsServer)");
365 if ($ldap->count()){
366 $attrs= $ldap->fetch();
367 $this->data['SERVERS']['CUPS']= $attrs['cn'][0];
368 }
370 /* Get fax server. FIXME: only one is supported currently */
371 $ldap->cd ($this->current['BASE']);
372 $ldap->search ("(objectClass=goFaxServer)");
373 if ($ldap->count()){
374 $attrs= $ldap->fetch();
375 $this->data['SERVERS']['FAX']= array( 'SERVER' => $attrs['cn'][0],
376 'LOGIN' => $attrs['goFaxAdmin'][0],
377 'PASSWORD' => $attrs['goFaxPassword'][0]);
378 }
380 /* Get asterisk servers */
381 $ldap->cd ($this->current['BASE']);
382 $ldap->search ("(objectClass=goFonServer)");
383 $this->data['SERVERS']['FON']= array();
384 if ($ldap->count()){
385 while ($attrs= $ldap->fetch()){
387 /* Add 0 entry for development */
388 if(count($this->data['SERVERS']['FON']) == 0){
389 $this->data['SERVERS']['FON'][0]= array(
390 'DN' => $attrs['dn'],
391 'SERVER' => $attrs['cn'][0],
392 'LOGIN' => $attrs['goFonAdmin'][0],
393 'PASSWORD' => $attrs['goFonPassword'][0],
394 'DB' => "gophone",
395 'SIP_TABLE' => "sip_users",
396 'EXT_TABLE' => "extensions",
397 'VOICE_TABLE' => "voicemail_users",
398 'QUEUE_TABLE' => "queues",
399 'QUEUE_MEMBER_TABLE' => "queue_members");
400 }
402 /* Add entry with 'dn' as index */
403 $this->data['SERVERS']['FON'][$attrs['dn']]= array(
404 'DN' => $attrs['dn'],
405 'SERVER' => $attrs['cn'][0],
406 'LOGIN' => $attrs['goFonAdmin'][0],
407 'PASSWORD' => $attrs['goFonPassword'][0],
408 'DB' => "gophone",
409 'SIP_TABLE' => "sip_users",
410 'EXT_TABLE' => "extensions",
411 'VOICE_TABLE' => "voicemail_users",
412 'QUEUE_TABLE' => "queues",
413 'QUEUE_MEMBER_TABLE' => "queue_members");
414 }
415 }
417 /* Get glpi servers */
418 $ldap->cd ($this->current['BASE']);
419 $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
420 if ($ldap->count()){
421 $attrs= $ldap->fetch();
422 if(!isset($attrs['goGlpiPassword'])){
423 $attrs['goGlpiPassword'][0] ="";
424 }
425 $this->data['SERVERS']['GLPI']= array(
426 'SERVER' => $attrs['cn'][0],
427 'LOGIN' => $attrs['goGlpiAdmin'][0],
428 'PASSWORD' => $attrs['goGlpiPassword'][0],
429 'DB' => $attrs['goGlpiDatabase'][0]);
430 }
431 /* Get logdb server */
432 $ldap->cd ($this->current['BASE']);
433 $ldap->search ("(objectClass=goLogDBServer)");
434 if ($ldap->count()){
435 $attrs= $ldap->fetch();
436 $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
437 'LOGIN' => $attrs['goLogAdmin'][0],
438 'PASSWORD' => $attrs['goLogPassword'][0]);
439 }
441 /* Get NFS server lists */
442 $tmp= array("default");
443 $ldap->cd ($this->current['BASE']);
444 $ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
445 while ($attrs= $ldap->fetch()){
446 for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
447 $path= preg_replace ("/\s.*$/", "", $attrs["goExportEntry"][$i]);
448 $tmp[]= $attrs["cn"][0].":$path";
449 }
450 }
451 $this->data['SERVERS']['NFS']= $tmp;
454 /* Load Terminalservers */
455 $ldap->cd ($this->current['BASE']);
456 $ldap->search ("(objectClass=goTerminalServer)");
457 $this->data['SERVERS']['TERMINAL']= array();
458 $this->data['SERVERS']['TERMINAL'][]= "default";
460 $this->data['SERVERS']['FONT']= array();
461 $this->data['SERVERS']['FONT'][]= "default";
462 while ($attrs= $ldap->fetch()){
463 $this->data['SERVERS']['TERMINAL'][]= $attrs["cn"][0];
464 for ($i= 0; $i<$attrs["goFontPath"]["count"]; $i++){
465 $this->data['SERVERS']['FONT'][]= $attrs["goFontPath"][$i];
466 }
467 }
469 /* Ldap Server */
470 $this->data['SERVERS']['LDAP']= array();
471 $ldap->cd ($this->current['BASE']);
472 $ldap->search ("(objectClass=goLdapServer)");
473 while ($attrs= $ldap->fetch()){
474 if (isset($attrs["goLdapBase"])){
475 for ($i= 0; $i<$attrs["goLdapBase"]["count"]; $i++){
476 $this->data['SERVERS']['LDAP'][]= $attrs["cn"][0].":".$attrs["goLdapBase"][$i];
477 }
478 }
479 }
481 /* Get misc server lists */
482 $this->data['SERVERS']['SYSLOG']= array("default");
483 $this->data['SERVERS']['NTP']= array("default");
484 $ldap->cd ($this->current['BASE']);
485 $ldap->search ("(objectClass=goNtpServer)");
486 while ($attrs= $ldap->fetch()){
487 $this->data['SERVERS']['NTP'][]= $attrs["cn"][0];
488 }
489 $ldap->cd ($this->current['BASE']);
490 $ldap->search ("(objectClass=goSyslogServer)");
491 while ($attrs= $ldap->fetch()){
492 $this->data['SERVERS']['SYSLOG'][]= $attrs["cn"][0];
493 }
495 /* Get samba servers from LDAP, in case of samba3 */
496 if ($this->current['SAMBAVERSION'] == 3){
497 $this->data['SERVERS']['SAMBA']= array();
498 $ldap->cd ($this->current['BASE']);
499 $ldap->search ("(objectClass=sambaDomain)");
500 while ($attrs= $ldap->fetch()){
501 $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array(
502 "SID" => $attrs["sambaSID"][0],
503 "RIDBASE" => $attrs["sambaAlgorithmicRidBase"][0]);
504 }
506 /* If no samba servers are found, look for configured sid/ridbase */
507 if (count($this->data['SERVERS']['SAMBA']) == 0){
508 if (!isset($this->current["SID"]) || !isset($this->current["RIDBASE"])){
509 print_red(_("SID and/or RIDBASE missing in your configuration!"));
510 echo $_SESSION['errors'];
511 exit;
512 } else {
513 $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
514 "SID" => $this->current["SID"],
515 "RIDBASE" => $this->current["RIDBASE"]);
516 }
517 }
518 }
519 }
522 function get_departments($ignore_dn= "")
523 {
524 global $config;
526 /* Initialize result hash */
527 $result= array();
528 $administrative= array();
529 $result['/']= $this->current['BASE'];
530 $this->tdepartments= array();
532 /* Get list of department objects */
533 $ldap= $this->get_ldap_link();
534 $ldap->cd ($this->current['BASE']);
535 $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
536 while ($attrs= $ldap->fetch()){
537 $dn= $ldap->getDN();
538 $this->tdepartments[$dn]= "";
540 /* Save administrative departments */
541 if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
542 isset($attrs['gosaUnitTag'][0])){
543 $administrative[$dn]= $attrs['gosaUnitTag'][0];
544 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
545 }
547 if (in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass']) &&
548 isset($attrs['gosaUnitTag'][0])){
549 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
550 }
552 if ($dn == $ignore_dn){
553 continue;
554 }
556 /* Only assign non-root departments */
557 if ($dn != $result['/']){
558 $result[convert_department_dn($dn)]= $dn;
559 }
560 }
562 $this->adepartments= $administrative;
563 $this->departments= $result;
564 }
567 function make_idepartments($max_size= 28)
568 {
569 global $config;
570 $base = $config->current['BASE'];
572 $arr= array();
573 $ui= get_userinfo();
574 $this->idepartments= array();
576 /* Create multidimensional array, with all departments. */
577 foreach ($this->departments as $key => $val){
579 /* When using strict_units, filter non relevant parts */
580 if (isset($config->current['STRICT_UNITS']) && preg_match('/true/i', $config->current['STRICT_UNITS'])){
581 if ($ui->gosaUnitTag != "" && isset($this->tdepartments[$val]) &&
582 $this->tdepartments[$val] != $ui->gosaUnitTag){
583 continue;
584 }
585 }
587 /* remove base from dn */
588 $val2 = str_replace($base,"",$val);
590 /* Get every single ou */
591 $str = preg_replace("/ou=/","|ou=",$val2);
592 $elements = array_reverse(split("\|",$str));
594 /* Save last array position */
595 $last = &$arr;
597 /* Get array depth */
598 $cnt = count($elements);
600 /* Add last ou element of current dn to our array */
601 foreach($elements as $key => $ele){
603 /* skip enpty */
604 if(empty($ele)) continue;
606 /* Extract department name */
607 $elestr = preg_replace("/^ou=/","", $ele);
608 $elestr = preg_replace("/,$/","",$elestr);
610 /* Add to array */
611 if($key == ($cnt-2)){
612 $last[$elestr]['ENTRY'] = $val;
613 }
615 /* Set next array appending position */
616 $last = &$last[$elestr]['SUB'];
617 }
618 }
620 /* Add base entry */
621 $ret["/"]["ENTRY"] = $base;
622 $ret["/"]["SUB"] = $arr;
624 $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size);
625 }
628 /* Creates display friendly output from make_idepartments */
629 function generateDepartmentArray($arr,$depth = -1,$max_size){
630 $ret = array();
631 $depth ++;
633 /* Walk through array */
634 foreach($arr as $name => $entries){
636 /* If this department is the last in the current tree position
637 * remove it, to avoid generating output for it */
638 if(count($entries['SUB'])==0){
639 unset($entries['SUB']);
640 }
642 /* Fix name, if it contains a replace tag */
643 $name= @LDAP::fix($name);
645 /* Check if current name is too long, then cut it */
646 if(mb_strlen($name, 'UTF-8')> $max_size){
647 $name = mb_substr($name,0,($max_size-3), 'UTF-8')." ...";
648 }
650 /* Append the name to the list */
651 if(isset($entries['ENTRY'])){
652 $a = "";
653 for($i = 0 ; $i < $depth ; $i ++){
654 $a.=" ";
655 }
656 $ret[$entries['ENTRY']]=$a." ".$name;
657 }
659 /* recursive add of subdepartments */
660 if(isset($entries['SUB'])){
661 $ret = array_merge($ret,$this->generateDepartmentArray($entries['SUB'],$depth,$max_size));
662 }
663 }
665 return($ret);
666 }
668 /* This function returns all available Shares defined in this ldap
669 * There are two ways to call this function, if listboxEntry is true
670 * only name and path are attached to the array, in it is false, the whole
671 * entry will be parsed an atached to the result.
672 */
673 function getShareList($listboxEntry = false)
674 {
675 $ldap= $this->get_ldap_link();
677 /* Set tag attribute if we've tagging activated */
678 $tag= "";
679 $ui= get_userinfo();
680 if ($ui->gosaUnitTag != "" && isset($this->current['STRICT_UNITS']) &&
681 preg_match('/TRUE/i', $this->current['STRICT_UNITS'])){
682 $tag= "(gosaUnitTag=".$ui->gosaUnitTag.")";
683 }
685 $a_res = $ldap->search("(&(objectClass=goShareServer)$tag(objectClass=goServer))",array("goExportEntry","cn"));
686 $return= array();
687 while($entry = $ldap->fetch($a_res)){
688 if(isset($entry['goExportEntry']['count'])){
689 unset($entry['goExportEntry']['count']);
690 }
691 if(isset($entry['goExportEntry'])){
692 foreach($entry['goExportEntry'] as $export){
693 $shareAttrs = split("\|",$export);
694 if($listboxEntry) {
695 $return[$shareAttrs[0]."|".$entry['cn'][0]] = $shareAttrs[0]." - ".$entry['cn'][0];
696 }else{
697 $return[$shareAttrs[0]."|".$entry['cn'][0]]['server'] = $entry['cn'][0];
698 $return[$shareAttrs[0]."|".$entry['cn'][0]]['name'] = $shareAttrs[0];
699 $return[$shareAttrs[0]."|".$entry['cn'][0]]['description'] = $shareAttrs[1];
700 $return[$shareAttrs[0]."|".$entry['cn'][0]]['type'] = $shareAttrs[2];
701 $return[$shareAttrs[0]."|".$entry['cn'][0]]['charset'] = $shareAttrs[3];
702 $return[$shareAttrs[0]."|".$entry['cn'][0]]['path'] = $shareAttrs[4];
703 $return[$shareAttrs[0]."|".$entry['cn'][0]]['option'] = $shareAttrs[5];
704 }
705 }
706 }
707 }
708 return($return);
709 }
711 /* This function returns all available ShareServer */
712 function getShareServerList()
713 {
714 global $config;
715 $return = array();
716 $ui = get_userinfo();
717 $base = $config->current['BASE'];
718 $res = get_list("(&(objectClass=goShareServer)(goExportEntry=*))",$ui->subtreeACL,$base,array("goExportEntry","cn"),GL_SUBSEARCH);
719 foreach($res as $entry){
720 if(isset($entry['goExportEntry']['count'])){
721 unset($entry['goExportEntry']['count']);
722 }
723 foreach($entry['goExportEntry'] as $share){
724 $a_share = split("\|",$share);
725 $sharename = $a_share[0];
726 $return[$entry['cn'][0]."|".$sharename] = $entry['cn'][0]." [".$sharename."]";
727 }
729 }
730 return($return);
731 }
733 /* Check if there's the specified bool value set in the configuration */
734 function boolValueIsTrue($section, $value)
735 {
736 $section= strtoupper($section);
737 $value= strtoupper($value);
738 if (isset($this->data[$section][$value])){
740 $data= $this->data[$section][$value];
741 if (preg_match("/^true$/i", $data) || preg_match("/yes/i", $data)){
742 return TRUE;
743 }
745 }
747 return FALSE;
748 }
750 }
752 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
753 ?>