config= $config; print $dn; #FIXME: ACL is set to default for testing $this->acl= "#all#"; /* Get global filter config */ if (!is_global("phonefilter")){ $ui= get_userinfo(); $base= get_base_from_people($ui->dn); $phonefilter= array("search_base" => $base, "organizational" => "checked", "global" => "checked", "search_for" => "*", "object_type" => "*"); register_global("phonefilter", $phonefilter); } } function execute() { $smarty= get_smarty(); #! Hickert /*prevent empty variables for smarty*/ foreach($this->attributes as $atr) $smarty->assign($atr,""); /* Save formular information */ $phonefilter= get_global("phonefilter"); foreach( array("search_for", "search_base", "object_type") as $type){ if (isset($_POST[$type])){ $phonefilter[$type]= $_POST[$type]; } $this->$type= $phonefilter[$type]; } if (isset($_POST['search_base'])){ foreach( array("organizational", "global") as $type){ if (isset($_POST[$type])){ $phonefilter[$type]= "checked"; } else { $phonefilter[$type]= ""; } } } /* Search string */ $s= $phonefilter['search_for']; if ($s == "") { $s= "*"; } if (isset($_GET['search'])){ $s= validate(mb_substr($_GET['search'], 0, 1, "UTF8"))."*"; if ($s == "**"){ $s= "*"; } $this->search_for= $s; $phonefilter['search_for']= $s; } register_global("phonefilter", $phonefilter); /* Perform actions with CTI hook */ if (isset($_GET['target']) && isset($_GET['dial']) && isset($this->config->current['CTIHOOK'])){ $dialmode= $_GET['dial']; if ($dialmode == "telephoneNumber" || $dialmode == "mobile" || $dialmode == "homePhone"){ /* Get target */ $ldap= $this->config->get_ldap_link(); $ldap->cat(base64_decode($_GET['target'])); $attrs= $ldap->fetch(); if (isset($attrs["$dialmode"])){ $target= $attrs[$dialmode][0]; } else { $target= ""; } /* Get source */ $ui= get_userinfo(); $ldap->cat($ui->dn); $attrs= $ldap->fetch(); if (isset($attrs["telephoneNumber"])){ $source= $attrs['telephoneNumber'][0]; } else { $source= ""; } /* Save to session */ $_SESSION['source']= $source; $_SESSION['target']= $target; /* Perform call */ if ($target != "" && $source != ""){ $smarty->assign("phone_image", get_template_path('images/phone.png')); $smarty->assign("dial_info", sprintf(_("Dial from %s to %s now?"), "".$source."", "".$target."")); return($smarty->fetch(get_template_path('dial.tpl', TRUE))); return; } else { print_red (_("You have no personal phone number set. Please change that in order to perform direct dials.")); } } } /* Finally dial */ if (isset($_POST['dial']) && isset($_SESSION['source']) && isset($_SESSION['target'])){ exec ($this->config->current['CTIHOOK']." '".$_SESSION['source']."' '".$_SESSION['target']."'", $dummy, $retval); unset($_SESSION['source']); unset($_SESSION['target']); } /* Delete entry? */ if (isset($_POST['delete_entry_confirm'])){ /* Some nice guy may send this as POST, so we've to check for the permissions again. */ if (chkacl($this->acl, "delete") == ""){ /* Delete request is permitted, perform LDAP action */ $ldap= $this->config->get_ldap_link(); $ldap->rmdir ($this->dn); gosa_log ("Address book object'".$this->dn."' has been removed"); } else { /* Normally this shouldn't be reached, send some extra logs to notify the administrator */ print_red (_("You are not allowed to delete this entry!")); gosa_log ("Warning: '".$this->ui->uid."' tried to trick address book deletion."); } /* Remove lock file after successfull deletion */ del_lock ($this->dn); /* Clean up */ if (isset($_SESSION['saved_start'])){ $_GET['start']= $_SESSION['saved_start']; } unset($_SESSION['show_info']); unset($_SESSION['saved_start']); } /* Delete entry? */ if (isset($_POST['delete_cancel'])){ del_lock ($this->dn); } /* Save address entry? */ if (isset($_POST['save'])){ $this->save_object(); $this->storage_base= $_POST['storage_base']; /* Perform checks */ $message= $this->check (); /* No errors, save object */ if (count ($message) == 0){ $this->save(); gosa_log ("Addressbook object '".$this->dn."' has been saved"); /* Clean up */ if (isset($_SESSION['saved_start'])){ $_GET['start']= $_SESSION['saved_start']; } $_SESSION['show_info']= $this->dn; unset($_SESSION['saved_start']); } else { /* Errors found, show message */ show_errors ($message); } } /* Close info window */ if (isset($_GET['close']) || isset($_POST['cancel'])){ if (isset($_SESSION['saved_start'])){ $_GET['start']= $_SESSION['saved_start']; } unset($_SESSION['show_info']); unset($_SESSION['saved_start']); } /* Start address book edit mode? */ if (isset($_GET['global'])){ if (!isset($_SESSION['saved_start']) && isset($_GET['start'])){ $_SESSION['saved_start']= $_GET['start']; } switch ($_GET['global']){ case "add": $this->dn= "new"; $this->orig_cn= ""; /* Clean values */ foreach ($this->attributes as $name){ $this->$name= ""; } $this->storage_base= $this->config->current["BASE"]; break; case "edit": /* Clean values */ foreach ($this->attributes as $name){ $this->$name= ""; } $this->dn= $_SESSION['show_info']; $this->load(); $this->orig_cn= $this->cn; break; case "remove": $this->dn= $_SESSION['show_info']; $this->load(); /* Load permissions for selected 'dn' and check if we're allowed to remove this 'dn' */ $ui= get_userinfo(); $dn= preg_replace("/,dc=addressbook,/", "", $this->dn); $acl= get_permissions ($dn, $ui->subtreeACL); $this->acl= get_module_permission($acl, "global-addressbook", $dn); if (chkacl($this->acl, "delete") == ""){ /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ if (($user= get_lock($this->dn)) != ""){ return(gen_locked_message ($user, $this->dn)); } /* Lock the current entry, so nobody will edit it during deletion */ add_lock ($this->dn, $ui->dn); $smarty->assign("info", sprintf(_("You're about to delete the entry %s."), $this->dn)); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } else { /* Obviously the user isn't allowed to delete. Show message and clean session. */ print_red (_("You are not allowed to delete this entry!")); } } $_SESSION['show_info']= "ADD"; } /* Open info window */ if (isset($_GET['show'])){ if (!isset($_SESSION['saved_start'])){ $_SESSION['saved_start']= $_GET['start']; } $_SESSION['show_info']= base64_decode($_GET['show']); } /* Get ldap link / build filter */ $ldap= $this->config->get_ldap_link(); $this->telephone_list= array (); /* Assemble bases */ $bases= array(); $filter= ""; if ($phonefilter['global'] == "checked"){ $bases[]= preg_replace("/".$this->config->current['BASE']."/", "dc=addressbook,".$this->config->current['BASE'], $this->search_base); } else { $filter= '(objectClass=gosaAccount)'; } if ($phonefilter['organizational'] == "checked"){ $bases[]= $this->search_base; } foreach ($bases as $base){ $ldap->cd ($base); if ($phonefilter['object_type'] == '*'){ $ldap->search ("(&(objectClass=person)$filter(!(objectClass=gosaUserTemplate))". "(|(uid=$s)(homePhone=$s)(telephoneNumber=$s)". "(facsimileTelephoneNumber=$s)(mobile=$s)(givenName=$s)(sn=$s)))", array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn")); } else { $ldap->search ("(&$filter(!(objectClass=gosaUserTemplate))". "(".$phonefilter['object_type']."=$s))", array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn")); } /* Build current list, error reporting is off, because many of the objects may not be defined after LDAP queries. Asking for presence first is too much overhead. */ error_reporting(0); /* Walk through LDAP results */ while ($attrs= $ldap->fetch()){ #! hickert /* prevent empty vaiables */ foreach($this->attributes as $atr) { if(!isset($attrs[$atr][0])) { $attrs[$atr][0] = ""; } } if(!isset($_GET['start'])) $_GET['start']=""; /* Only show lines that have set any mail or phone informations */ if (isset($attrs['telephoneNumber'][0]) || isset($attrs['facsimileTelephoneNumber'][0]) || isset($attrs['mobile'][0]) || isset($attrs['homePhone'][0]) || isset($attrs['mail'][0])){ $this->telephone_list[$attrs['sn'][0].$attrs['dn']]= "