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(),
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 %s: %s at line %d"),
72 CONFIG_FILE,
73 xml_error_string(xml_get_error_code($this->parser)),
74 xml_get_current_line_number($this->parser)));
75 echo $_SESSION['errors'];
76 exit;
77 }
78 }
80 function tag_open($parser, $tag, $attrs)
81 {
82 /* Save last and current tag for reference */
83 $this->tags[$this->level]= $tag;
84 $this->level++;
86 /* Trigger on CONF section */
87 if ($tag == 'CONF'){
88 $this->config_found= TRUE;
89 }
91 /* Return if we're not in config section */
92 if (!$this->config_found){
93 return;
94 }
96 /* yes/no to true/false and upper case TRUE to true and so on*/
97 foreach($attrs as $name => $value){
98 if(preg_match("/^(true|yes)$/i",$value)){
99 $attrs[$name] = "true";
100 }elseif(preg_match("/^(false|no)$/i",$value)){
101 $attrs[$name] = "false";
102 }
103 }
105 /* Look through attributes */
106 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 /* Load main parameters */
147 case 'MAIN':
148 $this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs);
149 break;
151 /* Load menu */
152 case 'SECTION':
153 if ($this->tags[$this->level-2] == 'MENU'){
154 $this->section= $attrs['NAME'];
155 $this->data['MENU'][$this->section]= array(); ;
156 }
157 break;
159 /* Inser plugins */
160 case 'PLUGIN':
161 if ($this->tags[$this->level-3] == 'MENU' &&
162 $this->tags[$this->level-2] == 'SECTION'){
164 $this->data['MENU'][$this->section][$this->gpc++]= $attrs;
165 }
166 if ($this->tags[$this->level-2] == 'SERVICEMENU'){
167 $this->data['SERVICE'][$attrs['CLASS']]= $attrs;
168 }
169 break;
170 }
171 }
173 function tag_close($parser, $tag)
174 {
175 /* Close config section */
176 if ($tag == 'CONF'){
177 $this->config_found= FALSE;
178 }
179 $this->level--;
180 }
182 function get_ldap_link($sizelimit= FALSE)
183 {
184 /* Build new connection */
185 $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
186 $this->current['ADMIN'], $this->current['PASSWORD']);
188 /* Check for connection */
189 if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
190 $smarty= get_smarty();
191 print_red (_("Can't bind to LDAP. Please contact the system administrator."));
192 $smarty->display (get_template_path('headers.tpl'));
193 echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
194 exit();
195 }
197 if (!isset($_SESSION['size_limit'])){
198 $_SESSION['size_limit']= $this->current['SIZELIMIT'];
199 $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
200 }
202 if ($sizelimit){
203 $this->ldap->set_size_limit($_SESSION['size_limit']);
204 } else {
205 $this->ldap->set_size_limit(0);
206 }
208 /* Move referrals */
209 if (!isset($this->current['REFERRAL'])){
210 $this->ldap->referrals= array();
211 } else {
212 $this->ldap->referrals= $this->current['REFERRAL'];
213 }
215 return ($this->ldap);
216 }
218 function set_current($name)
219 {
220 $this->current= $this->data['LOCATIONS'][$name];
221 if (!isset($this->current['PEOPLE'])){
222 $this->current['PEOPLE']= "ou=people";
223 }
224 if (!isset($this->current['GROUPS'])){
225 $this->current['GROUPS']= "ou=groups";
226 }
228 if (isset($this->current['INITIAL_BASE'])){
229 $_SESSION['CurrentMainBase']= $this->current['INITIAL_BASE'];
230 }
232 /* Remove possibly added ',' from end of group and people ou */
233 $this->current['GROUPS'] = preg_replace("/,*$/","",$this->current['GROUPS']);
234 $this->current['PEOPLE'] = preg_replace("/,*$/","",$this->current['PEOPLE']);
236 if (!isset($this->current['WINSTATIONS'])){
237 $this->current['WINSTATIONS']= "ou=winstations,ou=systems";
238 }
239 if (!isset($this->current['HASH'])){
240 $this->current['HASH']= "crypt";
241 }
242 if (!isset($this->current['DNMODE'])){
243 $this->current['DNMODE']= "cn";
244 }
245 if (!isset($this->current['MINID'])){
246 $this->current['MINID']= 100;
247 }
248 if (!isset($this->current['SIZELIMIT'])){
249 $this->current['SIZELIMIT']= 200;
250 }
251 if (!isset($this->current['SIZEINGORE'])){
252 $this->current['SIZEIGNORE']= TRUE;
253 } else {
254 if (preg_match("/true/i", $this->current['SIZEIGNORE'])){
255 $this->current['SIZEIGNORE']= TRUE;
256 } else {
257 $this->current['SIZEIGNORE']= FALSE;
258 }
259 }
261 /* Sort referrals, if present */
262 if (isset ($this->current['REFERRAL'])){
263 $bases= array();
264 $servers= array();
265 foreach ($this->current['REFERRAL'] as $ref){
266 $server= preg_replace('%^(.*)/[^/]+$%', '\\1', $ref['URL']);
267 $base= preg_replace('%^.*/([^/]+)$%', '\\1', $ref['URL']);
268 $bases[$base]= strlen($base);
269 $servers[$base]= $server;
270 }
271 asort($bases);
272 reset($bases);
273 }
275 /* SERVER not defined? Load the one with the shortest base */
276 if (!isset($this->current['SERVER'])){
277 $this->current['SERVER']= $servers[key($bases)];
278 }
280 /* BASE not defined? Load the one with the shortest base */
281 if (!isset($this->current['BASE'])){
282 $this->current['BASE']= key($bases);
283 }
285 /* Convert BASE to have escaped special characters */
286 $this->current['BASE']= @LDAP::convert($this->current['BASE']);
288 /* Parse LDAP referral informations */
289 if (!isset($this->current['ADMIN']) || !isset($this->current['PASSWORD'])){
290 $url= $this->current['SERVER'];
291 $referral= $this->current['REFERRAL'][$url];
292 $this->current['ADMIN']= $referral['ADMIN'];
293 $this->current['PASSWORD']= $referral['PASSWORD'];
294 }
296 /* Possibly load kerberos style */
297 if (isset($this->current['KRBSASL'])){
298 if (preg_match('/^(yes|true)$/i', $this->current['KRBSASL'])){
299 $this->current['KRBSASL']= "sasl";
300 } else {
301 $this->current['KRBSASL']= "kerberos";
302 }
303 } else {
304 $this->current['KRBSASL']= "kerberos";
305 }
307 /* Load server informations */
308 $this->load_servers();
309 }
311 function load_servers ()
312 {
313 /* Only perform actions if current is set */
314 if ($this->current == NULL){
315 return;
316 }
318 /* Fill imap servers */
319 $ldap= $this->get_ldap_link();
320 $ldap->cd ($this->current['BASE']);
321 if (!isset($this->current['MAILMETHOD'])){
322 $this->current['MAILMETHOD']= "";
323 }
324 if ($this->current['MAILMETHOD'] == ""){
325 $ldap->search ("(objectClass=goMailServer)", array('cn'));
326 $this->data['SERVERS']['IMAP']= array();
327 error_reporting(0);
328 while ($attrs= $ldap->fetch()){
329 $name= $attrs['cn'][0];
330 $this->data['SERVERS']['IMAP'][$name]= $name;
331 }
332 error_reporting(E_ALL);
333 } else {
334 $ldap->search ("(objectClass=goImapServer)", array('goImapName', 'goImapConnect', 'goImapAdmin', 'goImapPassword',
335 'goImapSieveServer', 'goImapSievePort'));
337 $this->data['SERVERS']['IMAP']= array();
338 error_reporting(0);
339 while ($attrs= $ldap->fetch()){
340 $name= $attrs['goImapName'][0];
341 $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
342 "admin" => $attrs['goImapAdmin'][0],
343 "password" => $attrs['goImapPassword'][0],
344 "sieve_server" => $attrs['goImapSieveServer'][0],
345 "sieve_port" => $attrs['goImapSievePort'][0]);
346 }
347 error_reporting(E_ALL);
348 }
350 /* Get kerberos server. FIXME: only one is supported currently */
351 $ldap->cd ($this->current['BASE']);
352 $ldap->search ("(objectClass=goKrbServer)");
353 if ($ldap->count()){
354 $attrs= $ldap->fetch();
355 $this->data['SERVERS']['KERBEROS']= array( 'SERVER' => $attrs['cn'][0],
356 'REALM' => $attrs['goKrbRealm'][0],
357 'ADMIN' => $attrs['goKrbAdmin'][0],
358 'PASSWORD' => $attrs['goKrbPassword'][0]);
359 }
361 /* Get cups server. FIXME: only one is supported currently */
362 $ldap->cd ($this->current['BASE']);
363 $ldap->search ("(objectClass=goCupsServer)");
364 if ($ldap->count()){
365 $attrs= $ldap->fetch();
366 $this->data['SERVERS']['CUPS']= $attrs['cn'][0];
367 }
369 /* Get fax server. FIXME: only one is supported currently */
370 $ldap->cd ($this->current['BASE']);
371 $ldap->search ("(objectClass=goFaxServer)");
372 if ($ldap->count()){
373 $attrs= $ldap->fetch();
374 $this->data['SERVERS']['FAX']= array( 'SERVER' => $attrs['cn'][0],
375 'LOGIN' => $attrs['goFaxAdmin'][0],
376 'PASSWORD' => $attrs['goFaxPassword'][0]);
377 }
379 /* Get asterisk servers */
380 $ldap->cd ($this->current['BASE']);
381 $ldap->search ("(objectClass=goFonServer)");
382 $this->data['SERVERS']['FON']= array();
383 if ($ldap->count()){
384 while ($attrs= $ldap->fetch()){
386 /* Add 0 entry for development */
387 if(count($this->data['SERVERS']['FON']) == 0){
388 $this->data['SERVERS']['FON'][0]= array(
389 'DN' => $attrs['dn'],
390 'SERVER' => $attrs['cn'][0],
391 'LOGIN' => $attrs['goFonAdmin'][0],
392 'PASSWORD' => $attrs['goFonPassword'][0],
393 'DB' => "gophone",
394 'SIP_TABLE' => "sip_users",
395 'EXT_TABLE' => "extensions",
396 'VOICE_TABLE' => "voicemail_users",
397 'QUEUE_TABLE' => "queues",
398 'QUEUE_MEMBER_TABLE' => "queue_members");
399 }
401 /* Add entry with 'dn' as index */
402 $this->data['SERVERS']['FON'][$attrs['dn']]= array(
403 'DN' => $attrs['dn'],
404 'SERVER' => $attrs['cn'][0],
405 'LOGIN' => $attrs['goFonAdmin'][0],
406 'PASSWORD' => $attrs['goFonPassword'][0],
407 'DB' => "gophone",
408 'SIP_TABLE' => "sip_users",
409 'EXT_TABLE' => "extensions",
410 'VOICE_TABLE' => "voicemail_users",
411 'QUEUE_TABLE' => "queues",
412 'QUEUE_MEMBER_TABLE' => "queue_members");
413 }
414 }
416 /* Get glpi servers */
417 $ldap->cd ($this->current['BASE']);
418 $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
419 if ($ldap->count()){
420 $attrs= $ldap->fetch();
421 if(!isset($attrs['goGlpiPassword'])){
422 $attrs['goGlpiPassword'][0] ="";
423 }
424 $this->data['SERVERS']['GLPI']= array(
425 'SERVER' => $attrs['cn'][0],
426 'LOGIN' => $attrs['goGlpiAdmin'][0],
427 'PASSWORD' => $attrs['goGlpiPassword'][0],
428 'DB' => $attrs['goGlpiDatabase'][0]);
429 }
430 /* Get logdb server */
431 $ldap->cd ($this->current['BASE']);
432 $ldap->search ("(objectClass=goLogDBServer)");
433 if ($ldap->count()){
434 $attrs= $ldap->fetch();
435 $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
436 'LOGIN' => $attrs['goLogAdmin'][0],
437 'PASSWORD' => $attrs['goLogPassword'][0]);
438 }
440 /* Get NFS server lists */
441 $tmp= array("default");
442 $ldap->cd ($this->current['BASE']);
443 $ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
444 while ($attrs= $ldap->fetch()){
445 for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
446 $path= preg_replace ("/\s.*$/", "", $attrs["goExportEntry"][$i]);
447 $tmp[]= $attrs["cn"][0].":$path";
448 }
449 }
450 $this->data['SERVERS']['NFS']= $tmp;
453 /* Load Terminalservers */
454 $ldap->cd ($this->current['BASE']);
455 $ldap->search ("(objectClass=goTerminalServer)");
456 $this->data['SERVERS']['TERMINAL']= array();
457 $this->data['SERVERS']['TERMINAL'][]= "default";
459 $this->data['SERVERS']['FONT']= array();
460 $this->data['SERVERS']['FONT'][]= "default";
461 while ($attrs= $ldap->fetch()){
462 $this->data['SERVERS']['TERMINAL'][]= $attrs["cn"][0];
463 for ($i= 0; $i<$attrs["goFontPath"]["count"]; $i++){
464 $this->data['SERVERS']['FONT'][]= $attrs["goFontPath"][$i];
465 }
466 }
468 /* Ldap Server */
469 $this->data['SERVERS']['LDAP']= array();
470 $ldap->cd ($this->current['BASE']);
471 $ldap->search ("(objectClass=goLdapServer)");
472 while ($attrs= $ldap->fetch()){
473 if (isset($attrs["goLdapBase"])){
474 for ($i= 0; $i<$attrs["goLdapBase"]["count"]; $i++){
475 $this->data['SERVERS']['LDAP'][]= $attrs["cn"][0].":".$attrs["goLdapBase"][$i];
476 }
477 }
478 }
480 /* Get misc server lists */
481 $this->data['SERVERS']['SYSLOG']= array("default");
482 $this->data['SERVERS']['NTP']= array("default");
483 $ldap->cd ($this->current['BASE']);
484 $ldap->search ("(objectClass=goNtpServer)");
485 while ($attrs= $ldap->fetch()){
486 $this->data['SERVERS']['NTP'][]= $attrs["cn"][0];
487 }
488 $ldap->cd ($this->current['BASE']);
489 $ldap->search ("(objectClass=goSyslogServer)");
490 while ($attrs= $ldap->fetch()){
491 $this->data['SERVERS']['SYSLOG'][]= $attrs["cn"][0];
492 }
494 /* Get samba servers from LDAP, in case of samba3 */
495 if ($this->current['SAMBAVERSION'] == 3){
496 $this->data['SERVERS']['SAMBA']= array();
497 $ldap->cd ($this->current['BASE']);
498 $ldap->search ("(objectClass=sambaDomain)");
499 while ($attrs= $ldap->fetch()){
500 $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array(
501 "SID" => $attrs["sambaSID"][0],
502 "RIDBASE" => $attrs["sambaAlgorithmicRidBase"][0]);
503 }
505 /* If no samba servers are found, look for configured sid/ridbase */
506 if (count($this->data['SERVERS']['SAMBA']) == 0){
507 if (!isset($this->current["SID"]) || !isset($this->current["RIDBASE"])){
508 print_red(_("SID and/or RIDBASE missing in your configuration!"));
509 echo $_SESSION['errors'];
510 exit;
511 } else {
512 $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
513 "SID" => $this->current["SID"],
514 "RIDBASE" => $this->current["RIDBASE"]);
515 }
516 }
517 }
518 }
521 function get_departments($ignore_dn= "")
522 {
523 global $config;
525 /* Initialize result hash */
526 $result= array();
527 $administrative= array();
528 $result['/']= $this->current['BASE'];
529 $this->tdepartments= array();
531 /* Get list of department objects */
532 $ldap= $this->get_ldap_link();
533 $ldap->cd ($this->current['BASE']);
534 $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
535 while ($attrs= $ldap->fetch()){
536 $dn= $ldap->getDN();
537 $this->tdepartments[$dn]= "";
539 /* Save administrative departments */
540 if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
541 isset($attrs['gosaUnitTag'][0])){
542 $administrative[$dn]= $attrs['gosaUnitTag'][0];
543 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
544 }
546 if (in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass']) &&
547 isset($attrs['gosaUnitTag'][0])){
548 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
549 }
551 if ($dn == $ignore_dn){
552 continue;
553 }
555 /* Only assign non-root departments */
556 if ($dn != $result['/']){
557 $result[convert_department_dn($dn)]= $dn;
558 }
559 }
561 $this->adepartments= $administrative;
562 $this->departments= $result;
563 }
566 function make_idepartments($max_size= 28)
567 {
568 global $config;
569 $base = $config->current['BASE'];
571 $arr= array();
572 $ui= get_userinfo();
573 $this->idepartments= array();
575 /* Create multidimensional array, with all departments. */
576 foreach ($this->departments as $key => $val){
578 /* When using strict_units, filter non relevant parts */
579 if (isset($config->current['STRICT_UNITS']) && preg_match('/true/i', $config->current['STRICT_UNITS'])){
580 if ($ui->gosaUnitTag != "" && isset($this->tdepartments[$val]) &&
581 $this->tdepartments[$val] != $ui->gosaUnitTag){
582 continue;
583 }
584 }
586 /* remove base from dn */
587 $val2 = str_replace($base,"",$val);
589 /* Get every single ou */
590 $str = preg_replace("/ou=/","|ou=",$val2);
591 $elements = array_reverse(split("\|",$str));
593 /* Save last array position */
594 $last = &$arr;
596 /* Get array depth */
597 $cnt = count($elements);
599 /* Add last ou element of current dn to our array */
600 foreach($elements as $key => $ele){
602 /* skip enpty */
603 if(empty($ele)) continue;
605 /* Extract department name */
606 $elestr = preg_replace("/^ou=/","", $ele);
607 $elestr = preg_replace("/,$/","",$elestr);
609 /* Add to array */
610 if($key == ($cnt-2)){
611 $last[$elestr]['ENTRY'] = $val;
612 }
614 /* Set next array appending position */
615 $last = &$last[$elestr]['SUB'];
616 }
617 }
619 /* Add base entry */
620 $ret["/"]["ENTRY"] = $base;
621 $ret["/"]["SUB"] = $arr;
623 $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size);
624 }
627 /* Creates display friendly output from make_idepartments */
628 function generateDepartmentArray($arr,$depth = -1,$max_size){
629 $ret = array();
630 $depth ++;
632 /* Walk through array */
633 ksort($arr);
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 ?>