diff --git a/plugins/gofax/faxaccount/class_gofaxAccount.inc b/plugins/gofax/faxaccount/class_gofaxAccount.inc
index 961dc6dcd7beca10406a37d106506e8a631492d6..eca2228577a9cc7591826a1803e03327489faafd 100644 (file)
var $goFaxSBlockgroups= array();
var $mail= "";
var $facsimileAlternateTelephoneNumber= array();
+ var $fax_formats = array("pdf","ps","png","mtiff","tiff");
/* Internal variables */
var $printerList= array();
var $in_blocklist_dialog= FALSE;
var $out_blocklist_dialog= FALSE;
var $current_blocklist= array();
+ var $view_logged = FALSE;
+
+ /* Copy & paste variables */
+ var $CopyPasteVars=array("facsimileTelephoneNumber");//,"goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups");
/* attribute list for save action */
- var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber",
- "goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail");
+ var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber");
+
+ var $uid ="";
+
var $objectclasses= array("goFaxAccount");
- function gofaxAccount ($config, $dn= NULL)
+ function gofaxAccount (&$config, $dn= NULL)
{
/* General initialization */
plugin::plugin ($config, $dn);
+ /* Set uid, it is used in handle_post_events */
+ if(isset($this->attrs['uid'])){
+ $this->uid = $this->attrs['uid'][0];
+ }
/* Hickert : 11.11.05
* Added to be able to handle department selection in divSelelect
if (in_array("gosaMailAccount", $this->attrs['objectClass'])){
$this->has_mailAccount= TRUE;
}
- if (isset($this->attrs["facsimileTelephoneNumber"][0])){
- $this->facsimileTelephoneNumber= $this->attrs["facsimileTelephoneNumber"][0];
- }
}
/* Load printer list */
asort ($this->printerList);
}
+ /* Check if the currently selected printer is still available.
+ If not, append current printer to list of available.
+ It could be possible, that we are not allowed to view printers and so the list is empty ... */
+ if(!empty($this->goFaxPrinter) && !isset($this->printerList[$this->goFaxPrinter])) {
+ $this->printerList[$this->goFaxPrinter] = "[".$this->goFaxPrinter."]";
+ }
+
/* Get global filter config */
if (!is_global("faxfilter")){
$ui= get_userinfo();
{
/* Call parent execute */
plugin::execute();
+
+ /* Log view */
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","users/".get_class($this),$this->dn);
+ }
+
/* Hickert : 11.11.05
* Added to be able to handle department selection in divSelelect
*/
}
}
+ /* Edit mode specifies if we are editing from my accout */
+ $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit']));
+
/* Load smarty stuff */
$smarty= get_smarty();
}
/* Do we represent a valid account? */
- if (!$this->is_account && $this->parent == NULL){
+ if (!$this->is_account && $this->parent === NULL){
$display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
_("This account has no fax extensions.")."</b>";
$display.= back_to_main();
/* Show tab dialog headers */
$display= "";
- if ($this->parent != NULL){
+ if ($this->parent !== NULL){
if ($this->is_account){
- $display= $this->show_header(_("Remove fax account"),
+ $display= $this->show_disable_header(_("Remove fax account"),
_("This account has fax features enabled. You can disable them by clicking below."));
} else {
- $display= $this->show_header(_("Create fax account"),
+ $display= $this->show_enable_header(_("Create fax account"),
_("This account has fax features disabled. You can enable them by clicking below."));
return ($display);
}
/* Trigger Add local fax alternatives dialog */
if (isset($_POST['add_local_alternate'])){
- $this->locals_dialog= TRUE;
- $this->dialog= TRUE;
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
+ $this->locals_dialog= TRUE;
+ $this->dialog= TRUE;
+ }
}
/* Add alternatives from dialog */
- if (isset($_POST['add_locals_finish'])){
- if (isset($_POST['local_list']) &&
- chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+ if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
foreach ($_POST['local_list'] as $val){
$this->addAlternate($val);
$this->is_modified= TRUE;
}
/* Add alternatives */
- if (isset($_POST['add_alternate'])){
- if ($_POST['forward_address'] != "" &&
- is_phone_nr($_POST['forward_address']) &&
- chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+ if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
$this->addAlternate($_POST['forward_address']);
}
}
/* Delete alternate fax number */
- if (isset($_POST['delete_alternate'])){
- if (isset($_POST['alternate_list']) && count($_POST['alternate_list']) &&
- chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+ if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
$this->delAlternate ($_POST['alternate_list']);
}
}
/* Edit incoming blocklists */
if (isset($_POST['edit_incoming'])){
- $this->current_blocklist= array_merge($this->goFaxRBlocklist,
- $this->goFaxRBlockgroups);
- sort($this->current_blocklist);
- reset($this->current_blocklist);
+ if($this->acl_is_writeable("goFaxRBlocklist",$edit_mode)) {
+ $this->current_blocklist= array_merge($this->goFaxRBlocklist,$this->goFaxRBlockgroups);
+ sort($this->current_blocklist);
+ reset($this->current_blocklist);
- $this->in_blocklist_dialog= TRUE;
- $this->dialog= TRUE;
+ $this->in_blocklist_dialog= TRUE;
+ $this->dialog= TRUE;
+ }
}
/* Edit outgoing blocklists */
if (isset($_POST['edit_outgoing'])){
- $this->current_blocklist= array_merge($this->goFaxSBlocklist,
- $this->goFaxSBlockgroups);
+ $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups);
sort($this->current_blocklist);
reset($this->current_blocklist);
/* Set departments */
- if ($this->locals_dialog ||
- $this->in_blocklist_dialog ||
- $this->out_blocklist_dialog){
-
+ if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){
+
$list= array ();
$ldap= $this->config->get_ldap_link();
if (isset ($_POST['department'])){
}
$faxfilter['fuser']= $s;
}
- register_global("faxfilter", $faxfilter);
if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){
$regex= $faxfilter['regex'];
}
$base= $faxfilter['depselect'];
- $acl= array($this->config->current['BASE'] => ":all");
- print "(&(objectClass=goFaxAccount)$filter)";
- $res= get_list("(&(objectClass=goFaxAccount)$filter)", $acl, $base,
+ $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base,
array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH);
foreach ($res as $attrs){
/* Fetch all returned departments an add them to our divlist */
while($value = $ldap->fetch()){
if($value["description"][0]!=".."){
- $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
+ $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]");
}else{
$this->departments[$value['dn']]=$value["description"][0];
}
/* Show dialog */
$smarty->assign("cblocklist", $this->current_blocklist);
- $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
$smarty->assign("departments", $this->config->idepartments);
$smarty->assign("divSelectPredefined", $divSel->DrawList());
$display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
/* Get all departments */
while($value = $ldap->fetch()){
if(isset($value["description"][0])){
- $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
+ $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]");
}else{
$this->departments[$value['dn']]=$value["description"][0];
}
/* Show dialog */
$smarty->assign("cblocklist", $this->current_blocklist);
- $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
$smarty->assign("departments", $this->config->idepartments);
$smarty->assign("divSelectPredefined", $divSel->DrawList());
$display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
/* Show main page */
- $smarty->assign("languages", $this->config->data['MAIN']['LANGUAGES']);
- $smarty->assign("formats", $this->config->data['MAIN']['FAXFORMATS']);
+ $smarty->assign("languages", get_languages(TRUE));
+
+ $smarty->assign("formats", $this->fax_formats);
$smarty->assign("printers", $this->printerList);
/* Load attributes */
"facsimileAlternateTelephoneNumber", "mail") as $val){
$smarty->assign("$val", $this->$val);
- $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
}
- $smarty->assign("goFaxRBlockgroupsACL", chkacl($this->acl, "goFaxRBlockgroups"));
- $smarty->assign("goFaxSBlockgroupsACL", chkacl($this->acl, "goFaxSBlockgroups"));
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $acl => $desc){
+ $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode));
+ }
/* Load checkboxes */
if ($this->goFaxIsEnabled == "1"){
}
/* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */
if ($this->goFaxDeliveryMode & 32) {
- $smarty->assign("fax_to_mail", "checked");
+ $smarty->assign("faxtomail", "checked");
} else {
- $smarty->assign("fax_to_mail", "");
+ $smarty->assign("faxtomail", "");
}
if ($this->goFaxDeliveryMode & 64) {
- $smarty->assign("fax_to_printer", "checked");
+ $smarty->assign("faxtoprinter", "checked");
} else {
- $smarty->assign("fax_to_printer", "");
+ $smarty->assign("faxtoprinter", "");
}
plugin::remove_from_parent();
- /* Zero out arrays */
- foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
- "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
-
- $this->attrs[$val]= array();
- }
-
/* Adapt mail settings if needed */
if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
unset($this->attrs['mail']);
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$this->cleanup();
-$ldap->modify ($this->attrs);
+ $ldap->modify ($this->attrs);
- show_ldap_error($ldap->get_error());
+ new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/fax account with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
- $this->handle_post_events('remove');
+ $this->handle_post_events('remove',array("uid"=> $this->uid));
}
/* IF mail is specified (which is only the case if there's no mail account
present), check if it's valid.. */
if (@isset($this->parent->by_object['mailAccount']) &&
- $this->goFaxDeliveryMode && 32){
+ $this->goFaxDeliveryMode & 32){
if ($this->mail == ""){
$message[]= _("Mail delivery is checked, but no address has been specified.");
} elseif (!is_email($this->mail)){
/* Save data to object */
function save_object()
{
+ $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit']));
if (isset($_POST['faxTab'])){
plugin::save_object();
- /* Adapt combobox values */
- $tmp= 0;
- if (isset($_POST["fax_to_mail"]) && $_POST["fax_to_mail"] == 1){
- $tmp+= 32;
+
+ $tmp = 0+$this->goFaxDeliveryMode;
+
+ if($this->acl_is_writeable("faxtomail",$edit_mode)){
+ if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){
+ $tmp |= 32;
+ }elseif($tmp & 32){
+ $tmp &= (!32);
+ }
}
- if (isset($_POST["fax_to_printer"]) && $_POST["fax_to_printer"] == 1){
- $tmp+= 64;
+ if($this->acl_is_writeable("faxtoprinter",$edit_mode)){
+ if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){
+ $tmp |= 64;
+ }elseif($tmp & 64){
+ $tmp &= !64;
+ }
}
- if (chkacl ($this->acl, "goFaxIsEnabled") == ""){
+ $this->goFaxDeliveryMode = $tmp;
+
+ if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){
if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
$this->goFaxIsEnabled= "0";
} else {
}
}
- if (isset($_POST['facsimileTelephoneNumber'])){
- if ($_POST['facsimileTelephoneNumber'] != $this->facsimileTelephoneNumber){
- $this->is_modified= TRUE;
- }
- $this->facsimileTelephoneNumber= $_POST['facsimileTelephoneNumber'];
- }
-
- if (isset($_POST['mail'])){
- if ($this->mail != $_POST['mail']){
- $this->is_modified= TRUE;
- }
+
+ if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail",$edit_mode)){
$this->mail= $_POST['mail'];
}
- /* Write to object */
- if (chkacl ($this->acl, "goFaxDeliveryMode") == ""){
- if ($tmp != $this->goFaxDeliveryMode){
- $this->is_modified= TRUE;
- }
- $this->goFaxDeliveryMode= "$tmp";
- }
-
/* Check if mail account is active and correct the internal
reference to represent the current status. */
- if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
- $this->has_mailAccount= TRUE;
+ if(isset($this->parent)){
+ if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
+ $this->has_mailAccount= TRUE;
+ }
}
}
$this->attrs[$val]= $this->$val;
}
+ if(!$this->attrs['goFaxDeliveryMode']){
+ $this->attrs['goFaxDeliveryMode'] = 0;
+ }
+
+ /* Do not save mail address ... it was possibly changed by mail plugin */
/* Adapt mail settings if needed */
- unset($this->attrs['mail']);
- if (!$this->has_mailAccount && $this->goFaxDeliveryMode && 32){
- $this->attrs['mail']= $this->mail;
+ if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){
+ unset($this->attrs['mail']);
}
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$this->cleanup();
-$ldap->modify ($this->attrs);
+ $ldap->modify ($this->attrs);
+
+ /* Log last action */
+ if($this->initially_was_account){
+ new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
- show_ldap_error($ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/fax account with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
if ($this->is_modified){
- $this->handle_post_events("mofify");
+ $this->handle_post_events("mofidy",array("uid" => $this->uid));
}
} else {
- $this->handle_post_events("add");
+ $this->handle_post_events("add",array("uid" => $this->uid));
}
}
}
}
+
+ /* Return plugin informations for acl handling
+ #FIXME some attributes are still missing in this plugin acls */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Fax"),
+ "plDescription" => _("Fax account settings"),
+ "plSelfModify" => TRUE,
+ "plDepends" => array("user"),
+ "plPriority" => 6,
+ "plSection" => "personal",
+ "plCategory" => array("users"),
+ "plOptions" => array(),
+
+ "plProvidedAcls" => array(
+ "goFaxIsEnabled" => _("Enable/Disable fax"),
+ "goFaxRBlocklist" => _("Receive blocklist"),
+ "goFaxSBlocklist" => _("Send blocklist"),
+ "facsimileTelephoneNumber" => _("Fax number"), // goFaxDeliveryMode
+ "facsimileAlternateTelephoneNumber" => _("Alternate fax number"), // goFaxDeliveryMode
+ "faxtomail" => _("Deliver fax as mail"),
+ "faxtoprinter" => _("Deliver fax to printer"),
+ "goFaxFormat" => _("Delivery format"),
+ "goFaxLanguage" => _("Language"))
+ ));
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: