1 <?php
3 class goLdapServer extends goService{
5 var $cli_summary = "This plugin is used within the ServerService Pluign \nand indicates that this server has goLdapServer defined.";
6 var $cli_description = "Some longer text\nfor help";
7 var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9 /* This plugin only writes its objectClass */
10 var $objectclasses = array("goLdapServer");
11 var $attributes = array("goLdapBase");
12 var $StatusFlag = "goLdapServerStatus";
14 /* This class can't be assigned twice so it conflicts with itsself */
15 var $conflicts = array("goLdapServer");
17 var $DisplayName = "";
18 var $dn = NULL;
19 var $cn = "";
20 var $goLdapServerStatus = "";
21 var $goLdapBase = "";
22 var $view_logged =FALSE;
24 var $krb_service_prefix = "ldap/";
26 function goLdapServer(&$config,$dn)
27 {
28 goService::goService($config,$dn);
29 $this->DisplayName = _("LDAP service");
31 /* Suggest a default value */
32 if ($this->goLdapBase == ""){
33 if ($this->dn == ""){
34 $srv= _("fill-in-your-servers-dns-name");
35 } else {
36 $srv= preg_replace("/^cn=([^,]+),.*$/", "$1", $this->dn);
37 }
38 $this->goLdapBase= "ldap://$srv:389/".$config->current['BASE'];
39 }
40 }
43 function execute()
44 {
46 if($this->is_account && !$this->view_logged){
47 $this->view_logged = TRUE;
48 new log("view","server/".get_class($this),$this->dn);
49 }
51 $smarty = get_smarty();
52 foreach($this->attributes as $attr){
53 $smarty->assign($attr,$this->$attr);
54 }
55 $tmp = $this->plInfo();
56 foreach($tmp['plProvidedAcls'] as $name => $translated){
57 $smarty->assign($name."ACL",$this->getacl($name));
58 }
59 return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__))));
60 }
63 function getListEntry()
64 {
65 $fields = goService::getListEntry();
66 $fields['Message'] = _("LDAP service");
67 #$fields['AllowEdit'] = true;
68 return($fields);
69 }
73 function check()
74 {
75 $message = plugin::check();
76 if(empty($this->goLdapBase)){
77 $message[] = msgPool::required(_("Base"));
78 }
79 if(!preg_match("/^ldap[si]?:\/\/[^\/]+\/.+$/", $this->goLdapBase)){
80 $message[] = msgPool::invalid(_("Base"),"","","ldap[si]://base");
81 }
82 return($message);
83 }
86 function save_object()
87 {
88 if(isset($_POST['goLdapServerPosted'])){
89 plugin::save_object();
90 }
91 }
94 /* Return plugin informations for acl handling */
95 static function plInfo()
96 {
97 return (array(
98 "plShortName" => _("Ldap"),
99 "plDescription" => _("Ldap")." ("._("Services").")",
100 "plSelfModify" => FALSE,
101 "plDepends" => array(),
102 "plPriority" => 96,
103 "plSection" => array("administration"),
104 "plCategory" => array("server"),
106 "plProvidedAcls"=> array(
107 "goLdapBase" => _("Ldap base"))
108 ));
109 }
110 }
111 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
112 ?>