diff --git a/plugins/gofax/faxaccount/class_gofaxAccount.inc b/plugins/gofax/faxaccount/class_gofaxAccount.inc
index 5aa2b8bc282030d22270c80986fc195a35e6a03e..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","facsimileTelephoneNumber",
- "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 ($dn != "new"){
/* Get arrays */
- foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist","facsimileTelephoneNumber",
+ foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
"goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
$this->$val =array();
if (isset($this->attrs["$val"]["count"])){
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_disable_header(_("Remove fax account"),
_("This account has fax features enabled. You can disable them by clicking below."));
/* Trigger Add local fax alternatives dialog */
if (isset($_POST['add_local_alternate'])){
- if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+ 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']) && isset($_POST['local_list'])){
- if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+ 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']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){
- if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
$this->addAlternate($_POST['forward_address']);
}
}
/* Delete alternate fax number */
if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){
- if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+ if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
$this->delAlternate ($_POST['alternate_list']);
}
}
/* Edit incoming blocklists */
if (isset($_POST['edit_incoming'])){
- if($this->acl_is_writeable("goFaxRBlocklist")) {
+ 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);
/* 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 */
$tmp = $this->plInfo();
foreach($tmp['plProvidedAcls'] as $acl => $desc){
- $smarty->assign($acl."ACL",$this->getacl($acl));
+ $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode));
}
/* Load checkboxes */
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']);
$this->cleanup();
$ldap->modify ($this->attrs);
+ 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();
$tmp = 0+$this->goFaxDeliveryMode;
- if($this->acl_is_writeable("faxtomail")){
+ if($this->acl_is_writeable("faxtomail",$edit_mode)){
if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){
$tmp |= 32;
}elseif($tmp & 32){
$tmp &= (!32);
}
}
- if($this->acl_is_writeable("faxtoprinter")){
+ if($this->acl_is_writeable("faxtoprinter",$edit_mode)){
if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){
$tmp |= 64;
}elseif($tmp & 64){
}
$this->goFaxDeliveryMode = $tmp;
- if($this->acl_is_writeable("goFaxIsEnabled")){
+ if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){
if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
$this->goFaxIsEnabled= "0";
} else {
}
- if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail")){
+ if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail",$edit_mode)){
$this->mail= $_POST['mail'];
}
/* 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['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 */
$this->cleanup();
$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(), 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 */
- function plInfo()
+ static function plInfo()
{
return (array(
"plShortName" => _("Fax"),
"plOptions" => array(),
"plProvidedAcls" => array(
- "goFaxIsEnabled" => "!!! FIXME "._("Enable/Disable fax"),
+ "goFaxIsEnabled" => _("Enable/Disable fax"),
"goFaxRBlocklist" => _("Receive blocklist"),
"goFaxSBlocklist" => _("Send blocklist"),
"facsimileTelephoneNumber" => _("Fax number"), // goFaxDeliveryMode