From: cajus Date: Thu, 17 Jan 2008 08:08:33 +0000 (+0000) Subject: Moved fax plugins X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6eea4c9b2887f641ec7591f17d3396876fb227d3;p=gosa.git Moved fax plugins git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8421 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc b/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc deleted file mode 100644 index a6dab5936..000000000 --- a/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc +++ /dev/null @@ -1,371 +0,0 @@ -type = BLOCK_LIST_SEND; - - /* Load defined numbers */ - if($dn != "new"){ - - /* We will not be able to rename edited blocklists */ - $this->readonly = TRUE; - - /* Get blocklist type and defined numbers */ - if (in_array("goFaxSBlock",$this->attrs['objectClass'])){ - if(isset($this->attrs["goFaxSBlocklist"])){ - for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_SEND; - } elseif (in_array("goFaxRBlock",$this->attrs['objectClass'])){ - if(isset($this->attrs["goFaxRBlocklist"])){ - for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_RECEIVE; - } - } - - /* Set base */ - if ($this->dn == "new"){ - if(session::is_set('CurrentMainBase')){ - $this->base = session::get('CurrentMainBase'); - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); - } - } - - public function execute() - { - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","blocklist/".get_class($this),$this->dn); - } - - - /************** - * Base select dialog - **************/ - - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - - }else{ - return($this->dialog->execute()); - } - } - - - /*************** - Add numer to blocklist - ***************/ - - - /* Handle interactions: add */ - if (isset($_POST['add_number']) && $_POST['number'] != ""){ - if (tests::is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ - $this->addNumber ($_POST['number']); - } else { - print_red (_("Please specify a valid phone number.")); - } - } - - - /*************** - Delete number from list - ***************/ - - /* Handle interactions: delete */ - if (isset($_POST['delete_number']) && isset($_POST['numbers']) && count($_POST['numbers']) > 0){ - $this->delNumber ($_POST['numbers']); - } - - - /*************** - Template output - ***************/ - - $smarty = get_smarty(); - foreach($this->attributes as $name){ - $smarty->assign($name,$this->$name); - } - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - $smarty->assign("goFaxBlocklist",$this->goFaxBlocklist); - $smarty->assign("cnACL",$this->getacl("cn",$this->readonly)); - $smarty->assign("typeACL",$this->getacl("type",$this->readonly)); - $smarty->assign("base",$this->base); - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("types", array(BLOCK_LIST_SEND => _("send"), BLOCK_LIST_RECEIVE => _("receive"))); - $smarty->assign("type", $this->type); - return($smarty->fetch(get_template_path('generic.tpl', TRUE))); - } - - - public function save_object() - { - if(isset($_POST['blocklist_posted'])){ - $tmp_cn = $this->cn; - plugin::save_object(); - $this->cn = $tmp_cn; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - $tmp = $this->attributes; - $tmp[] = "type"; - foreach($tmp as $attr){ - if(in_array($attr,array("cn","type")) && $this->readonly){ - continue; - }elseif(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ - $this->$attr = $_POST[$attr]; - } - } - } - } - - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $ldap->rmDir($this->dn); - new log("remove","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of blocklist with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* check syntax: must cn */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not set."); - } else { - if (!tests::is_uid($this->cn)){ - $message[]= _("Required field 'Name' contains invalid characters"); - } - if ($this->dn == 'new'){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd (get_ou('blocklistou').$this->config->current["BASE"]); - $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn")); - if ($ldap->count() != 0){ - $message[]= _("Specified name is already used."); - } - } - } - return $message; - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Type selection */ - if ($this->type == BLOCK_LIST_SEND){ - $type= "goFaxSBlocklist"; - $this->attrs['objectClass']= "goFaxSBlock"; - } else { - $type= "goFaxRBlocklist"; - $this->attrs['objectClass']= "goFaxRBlock"; - } - - /* Add list */ - if (count($this->goFaxBlocklist)){ - $this->attrs[$type]= $this->goFaxBlocklist; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->base); - $ldap->cat($this->dn, array('dn')); - if ($ldap->count()){ - if (!isset($this->attrs[$type])){ - $this->attrs[$type]= array(); - } - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - new log("modify","faxblocklist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify"); - } else { - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of blocklist with dn '%s' failed."),$this->dn)); - } - - - /* Add number */ - function addNumber($number) - { - if (!in_array($number, $this->goFaxBlocklist)){ - $this->goFaxBlocklist[]= $number; - sort($this->goFaxBlocklist); - } - } - - - /* Remove number from list */ - function delNumber($numbers) - { - $tmp= array(); - foreach ($this->goFaxBlocklist as $val){ - if (!in_array($val, $numbers)){ - $tmp[]= $val; - } - } - $this->goFaxBlocklist= $tmp; - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn",$this->cn); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = get_post('cn'); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* We will not be able to rename edited blocklists */ - $this->readonly = TRUE; - - /* Get blocklist type and defined numbers */ - if (in_array("goFaxSBlock",$source['objectClass'])){ - if(isset($source["goFaxSBlocklist"])){ - for ($i= 0; $i<$source["goFaxSBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $source["goFaxSBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_SEND; - } elseif (in_array("goFaxRBlock",$source['objectClass'])){ - if(isset($source["goFaxRBlocklist"])){ - for ($i= 0; $i<$source["goFaxRBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $source["goFaxRBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_RECEIVE; - } - - /* Set base */ - if ($this->dn == "new"){ - if(session::is_set('CurrentMainBase')){ - $this->base = session::get('CurrentMainBase'); - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Fax"), - "plDescription" => _("Fax blocklists"), - "plSelfModify" => FALSE, - "plDepends" => array(), - - "plPriority" => 0, - "plSection" => array("administration" => _("FAX Blocklists")), - "plCategory" => array("gofaxlist" => array("description" => _("Fax blocklists"), - "objectClass" => array("goFaxRBlock","goFaxSBlock"))), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "base" => _("Base"), - "goFaxBlocklist" => _("Blocklist"), - "type" => _("Blocklist type")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc b/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc deleted file mode 100644 index 8c68cc421..000000000 --- a/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc +++ /dev/null @@ -1,477 +0,0 @@ -ui = $ui; - $this->dn = ""; - $this->config = &$config; - $this->base = session::get('CurrentMainBase'); - $this->DivListBlocklist = new divListBlocklist($this->config,$this); - - /* Initialize copy&paste queue */ - if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ - $this->CopyPasteHandler= new CopyPasteHandler($this->config); - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - session::set('LOCK_VARS_TO_USE',array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/")); - - /*************** - Init vars - ***************/ - - /* Get global smarty instance */ - $smarty = get_smarty(); - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - - /*************** - Fetch posts - ***************/ - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^goFaxBlocklist_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^goFaxBlocklist_del_/i","",$key); - // Post for edit - }elseif(preg_match("/^goFaxBlocklist_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/^goFaxBlocklist_edit_/i","",$key); - // Post for new - }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_blocklists/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^copy/",$key)){ - $s_action = "copy"; - $s_entry= preg_replace("/^copy_/i", "", $key); - }elseif(preg_match("/^cut/",$key)){ - $s_action = "cut"; - $s_entry= preg_replace("/^cut_/i", "", $key); - } - - } - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFaxBlocklist_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /*************** - Handle copy & paste - ***************/ - - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /*************** - Cancel some dialogs - ***************/ - - /* Cancel dialog */ - if (isset($_POST['edit_cancel']) || - isset($_POST['delete_blocklist_cancel']) || - isset($_POST['delete_lock'])){ - - del_lock ($this->dn); - $this->dialog = NULL; - session::un_set('objectinfo'); - } - - - /*************** - Save blocklist - ***************/ - - /* What about finish? */ - if (isset($_POST['edit_finish']) || isset($_POST['edit_apply'])){ - - /* No errors, save object */ - $this->dialog->save_object(); - $message= $this->check(); - if (count ($message) == 0){ - - $this->dialog->save (); - - if (!isset($_POST['edit_apply'])){ - del_lock ($this->dn); - $this->dn= ""; - $this->dialog = NULL; - session::un_set('objectinfo'); - } - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - - /*************** - Create a new blocklist (dialog) - ***************/ - - /* Create new blocklist? */ - if ($s_action=="new"){ - $this->dn= "new"; - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->base); - } - - - /*************** - Edit blocklist - ***************/ - - if ($s_action=="edit" && !is_object($this->dialog)){ - - $this->dn=$this->blocklists[$s_entry]['dn']; - - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message($user, $this->dn)); - }else{ - add_lock ($this->dn, $this->ui->dn); - } - session::set('objectinfo',trim($this->dn)); - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->dn); - } - - - /*************** - Display dialog - ***************/ - - if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - - $this->dns = array(); - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - foreach($ids as $id){ - $dn = $this->blocklists[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("info", sprintf(_("You're about to delete the following blocklists(s) %s"), @LDAP::fix($dns_names))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. */ - if (isset($_POST['delete_multiple_blocklist_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ - $this->dn = $dn; - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->delete(); - $this->dialog = NULL; - } else { - print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn)); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - $this->reload(); - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_blocklist_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /*************** - Remove blocklist - ***************/ - - /* Delete blocklist requested */ - if ($s_action=="del"){ - $this->dn=$this->blocklists[$s_entry]['dn']; - - /* Check locking */ - if (($user= get_lock($this->dn)) != ""){ - session::set('dn',$this->dn); - return(gen_locked_message($user, $this->dn)); - } else { - - // Lock this dn for editing - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn)); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /*************** - Remove blocklist confirmed - ***************/ - - /* Finally delete blocklist */ - if (isset($_POST['delete_blocklist_confirm'])){ - if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->delete(); - $this->dialog = NULL; - del_lock ($this->dn); - } else { - print_red (_("You have no permission to remove this blocklist.")); - } - } - - /*************** - Divlist dialog - ***************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListBlocklist->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListBlocklist->parent = $this; - $this->DivListBlocklist->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListBlocklist->SubSearch){ - $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); - } - $this->reload(); - $this->DivListBlocklist->setEntries($this->blocklists); - return($this->DivListBlocklist->Draw()); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array(get_ou('blocklistou').$this->DivListBlocklist->selectedBase)); - } - - - /* Reload the list of known blocklists */ - function reload() - { - /* Init some vars */ - $filter = $filter2 = ""; - $base = $this->DivListBlocklist->selectedBase; - $Regex = $this->DivListBlocklist->Regex; - $SubSearch = $this->DivListBlocklist->SubSearch; - $ShowSendBocklists = $this->DivListBlocklist->ShowSendBocklists; - $ShowReceiveBlocklists = $this->DivListBlocklist->ShowReceiveBlocklists; - $Flags = GL_SIZELIMIT; - $res = $res2 = array(); - - /* Append subsearch to Flags */ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base = get_ou('blocklistou').$base; - } - - /* Create filter */ - if ($ShowSendBocklists){ - $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))"; - $res= get_list($filter, "gofaxlist", $base,array("*"), $Flags); - } - if ($ShowReceiveBlocklists){ - $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))"; - $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags); - } - - $this->blocklists = array_merge($res,$res2); - - /* appen && sort */ - $tmp=array(); - foreach($this->blocklists as $tkey => $val ){ - - $acl = $this->ui ->get_permissions($base,"gofaxlist/blocklist"); - if(preg_match("/r/",$acl)){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - ksort($tmp); - $this->blocklists=array(); - foreach($tmp as $val){ - $this->blocklists[]=$val; - } - reset ($this->blocklists); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListBlocklist->save_object(); - } - - - - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->blocklists[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->blocklists[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListBlocklist->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc b/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc deleted file mode 100644 index 8b8a505a6..000000000 --- a/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc +++ /dev/null @@ -1,291 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of blocklists")); - $this->SetSummary(_("List of blocklists")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); - - /* Add Checkboxes / SubSearch checkbox */ - $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true); - $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true); - - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("gofaxlist"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Append department selector */ - $listhead .= " "._("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Blocklist")."|goFaxBlocklist_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - // User and Template Images - $blockimg = "User"; - $editlink = "%s"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Append to list */ - $ui = get_userinfo(); - foreach($list as $key => $val){ - - $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist"); - if(!preg_match("/r/",$acl)){ - continue; - } - - /* Edit link ; requires read access */ - $action= ""; - - - /* Create snapshot ; requires write access && create access */ - if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){ - $action.= $this->GetSnapShotActions($val['dn']); - } - - /* Add copy & cut icons */ - if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){ - $action .= " "; - $action.= " "; - } - - - /* Delete entry ; requires remove access */ - if(preg_match("/d/",$acl)){ - $action.= ""; - } - - // Generate Array to Add - if(isset($val["description"][0])){ - $display= $val["cn"][0]." [".$val["description"][0]."]"; - }else{ - $display= $val["cn"][0]; - } - - /* Cutted objects should be displayed in light grey */ - if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); - $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement( array($field0,$field1,$field2,$field3)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed blocklists"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/blocklists/generic.tpl b/gosa-core/plugins/gofax/blocklists/generic.tpl deleted file mode 100644 index df9f84a6b..000000000 --- a/gosa-core/plugins/gofax/blocklists/generic.tpl +++ /dev/null @@ -1,109 +0,0 @@ -

{t}Generic{/t}

- - - - - - - - - -
- - - - - - - - - -
{$must} - -{render acl=$cnACL} - -{/render} -
{$must} -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
-   - - - - - - - - - - -
-{render acl=$typeACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -
-
- -

 

- - - - - - - -
-

{t}Blocked numbers{/t}

-{render acl=$goFaxBlocklistACL} - -{/render} -
-{render acl=$goFaxBlocklistACL} -   -{/render} -{render acl=$goFaxBlocklistACL} -   -{/render} -{render acl=$goFaxBlocklistACL} - -{/render} -
-   - -

{t}Information{/t}

-

- {t}Numbers can also contain wild cards.{/t} -

-
- -

- - - -

- - - diff --git a/gosa-core/plugins/gofax/blocklists/main.inc b/gosa-core/plugins/gofax/blocklists/main.inc deleted file mode 100644 index 4a0f3c561..000000000 --- a/gosa-core/plugins/gofax/blocklists/main.inc +++ /dev/null @@ -1,35 +0,0 @@ -dn); - session::un_set ('blocklist'); - } -} else { - /* Create blocklist object on demand */ - if (!session::is_set('blocklist') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $blocklist= new blocklist($config, $ui); - $blocklist->set_acl_category("gofaxlist"); - session::set('blocklist',$blocklist); - } - $blocklist = session::get('blocklist'); - $blocklist->save_object(); - $output= $blocklist->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - session::un_set ('blocklist'); - } - - /* Page header*/ - if (session::is_set('objectinfo')){ - $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management"), "\"\"align=\"middle\" ".@LDAP::fix(session::get('objectinfo'))); - } else { - $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management")); - } - $display.= $output; - - session::set('blocklist',$blocklist); -} -?> diff --git a/gosa-core/plugins/gofax/blocklists/paste_generic.tpl b/gosa-core/plugins/gofax/blocklists/paste_generic.tpl deleted file mode 100644 index ac4cef972..000000000 --- a/gosa-core/plugins/gofax/blocklists/paste_generic.tpl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
- -
diff --git a/gosa-core/plugins/gofax/blocklists/remove.tpl b/gosa-core/plugins/gofax/blocklists/remove.tpl deleted file mode 100644 index ebea1e3ca..000000000 --- a/gosa-core/plugins/gofax/blocklists/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc b/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc deleted file mode 100644 index 32a674705..000000000 --- a/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc +++ /dev/null @@ -1,38 +0,0 @@ -addSpecialTabs(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['blocklistGeneric']; - - /* Check for new 'dn', in order to propagate the 'dn' to all plugins */ - $new_dn= "cn=".$baseobject->cn.",".get_ou('blocklistou').$baseobject->base; - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['blocklistGeneric']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc b/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc deleted file mode 100644 index 63f22cee6..000000000 --- a/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc +++ /dev/null @@ -1,981 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - - /* Department list shown in the divSelectList*/ - var $departments; - - /* Fax attributes */ - var $goFaxDeliveryMode= ""; - var $facsimileTelephoneNumber= ""; - var $goFaxIsEnabled= 1; - var $goFaxPrinter= ""; - var $goFaxDivertNumber= ""; - var $goFaxLanguage= ""; - var $goFaxFormat= ""; - var $goFaxRBlocklist = array(); - var $goFaxRBlockgroups= array(); - var $goFaxSBlocklist= array(); - var $goFaxSBlockgroups= array(); - var $mail= ""; - var $facsimileAlternateTelephoneNumber= array(); - var $fax_formats = array("pdf","ps","png","mtiff","tiff"); - - /* Internal variables */ - var $printerList= array(); - var $has_mailAccount= FALSE; - var $locals_dialog= FALSE; - 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","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber"); - - var $uid =""; - - var $objectclasses= array("goFaxAccount"); - - /* Enable multiple edit support */ - var $multiple_support = TRUE; - - 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(!session::is_set("Fax_Filter")){ - $Fax_Filter = array(); - $Fax_Filter['depselect'] = $this->config->current['BASE']; - session::set('Fax_Filter',$Fax_Filter); - } - - if ($dn != "new"){ - /* Get arrays */ - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ - $this->$val =array(); - if (isset($this->attrs["$val"]["count"])){ - for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){ - array_push($this->$val, $this->attrs["$val"][$i]); - } - } - } - - /* Set up has_mailAccount */ - if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ - $this->has_mailAccount= TRUE; - } - } - - /* Load printer list */ - $this->printerList=get_printer_list(); - - /* 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 (!session::is_set("faxfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $faxfilter= array( "depselect" => $base, - "fuser" => "*", - "regex" => ""); - session::set("faxfilter", $faxfilter); - } - } - - function execute() - { - /* 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 - */ - if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ - - $Fax_Filter = session::get('Fax_Filter'); - if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ - $Fax_Filter['depselect']= base64_decode($_GET['dep_id']); - }else{ - $Fax_Filter['depselect']= $this->config->current['BASE']; - } - session::set('Fax_Filter',$Fax_Filter); - } - - /* Edit mode specifies if we are editing from my accout */ - $edit_mode = (!is_object($this->parent) && !session::is_set('edit')); - - /* Load smarty stuff */ - $smarty= get_smarty(); - - /* Check if mail account is active. We'll display an additional - mail address field if this is not the case. Some people may - want goFax, but have a mailserver which is not managed with - GOsa */ - if (!@isset($this->parent->by_object['mailAccount'])) { - $smarty->assign("has_mailaccount", $this->has_mailAccount?"true":"false"); - } elseif ( !$this->parent->by_object['mailAccount']->is_account){ - $smarty->assign("has_mailaccount", "false"); - $this->has_mailAccount= false; - } else { - $smarty->assign("has_mailaccount", "true"); - } - - - $display = ""; - if(!$this->multiple_support_active){ - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no fax extensions.").""; - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - $display= ""; - 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.")); - } else { - $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'])){ - 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",$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']) && tests::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']) && 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'])){ - 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; - } - } - - /* Edit outgoing blocklists */ - if (isset($_POST['edit_outgoing'])){ - $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups); - sort($this->current_blocklist); - reset($this->current_blocklist); - - $this->out_blocklist_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Add number to blocklist (dialog) */ - if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){ - if (!tests::is_phone_nr($_POST['block_number'])){ - print_red (_("You're trying to add an invalid phone number.")); - } else { - array_push($this->current_blocklist, $_POST['block_number']); - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - } - - /* Hickert : 11.11.05 - * Add selection from divSelelect to our Blocklist - */ - /* Add list to blocklist */ - if (isset($_POST['add_blocklist'])){ - foreach($_POST as $name => $value){ - if(preg_match("/ADDLIST_/i",$name)){ - $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value))); - - } - } - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - - /* Add list to blocklist */ - if (isset($_GET['add'])){ - if(!is_array($this->current_blocklist)) $this->current_blocklist=array(); - $this->current_blocklist= array_merge($this->current_blocklist, array( base64_decode($_GET['add']))); - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - - /* Delete from blocklist */ - if (isset($_POST['delete_blocklist_number']) && isset($_POST['block_list'])){ - $tmp= array(); - foreach($this->current_blocklist as $val){ - if (!in_array($val, $_POST['block_list'])){ - $tmp[]= $val; - } - } - $this->current_blocklist= $tmp; - } - - - /* Blocklist edit finished */ - if (isset($_POST['edit_blocklists_finish'])){ - - /* Incoming or outgoing? */ - if ($this->in_blocklist_dialog){ - $this->goFaxRBlocklist = array(); - $this->goFaxRBlockgroups = array(); - - foreach ($this->current_blocklist as $val){ - if (tests::is_phone_nr($val)){ - $this->goFaxRBlocklist[]=$val; - } else { - $this->goFaxRBlockgroups[]= $val; - } - } - } else { - $this->goFaxSBlocklist = array(); - $this->goFaxSBlockgroups = array(); - - /* Transfer values to ourself */ - foreach ($this->current_blocklist as $val){ - if (tests::is_phone_nr($val)){ - $this->goFaxSBlocklist[]=$val; - } else { - $this->goFaxSBlockgroups[]= $val; - } - } - } - $this->is_modified= TRUE; - } - - - /* Set departments */ - if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){ - - $list= array (); - $ldap= $this->config->get_ldap_link(); - if (isset ($_POST['department'])){ - $ldap->cd ($_POST['department']); - } else { - $ldap->cd ($this->config->current['BASE']); - } - } - - /* Cancel dialogs */ - if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) || - isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){ - - $this->locals_dialog= FALSE; - $this->in_blocklist_dialog= FALSE; - $this->out_blocklist_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Manage locals dialog */ - if ($this->locals_dialog){ - - /* Save data */ - $faxfilter= session::get("faxfilter"); - foreach( array("depselect", "fuser", "regex") as $type){ - if (isset($_POST[$type])){ - $faxfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $faxfilter['fuser']= $s; - } - - if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){ - $regex= $faxfilter['regex']; - $filter= "(facimileTelephoneNumber=$regex)"; - } else { - $filter= ""; - } - if ($faxfilter['fuser'] != ""){ - $user= $faxfilter['fuser']; - $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; - } - - $base= $faxfilter['depselect']; - $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base, - array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH); - - foreach ($res as $attrs){ - $list[$attrs['facsimileTelephoneNumber'][0]]= - $attrs['sn'][0].", ". - $attrs['givenName'][0]." [". - $attrs['facsimileTelephoneNumber'][0]."]"; - } - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("usearch_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("list", $list); - if (isset($_POST['depselect'])){ - $smarty->assign("depselect", $_POST['depselect']); - } - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("hint", print_sizelimit_warning()); - foreach( array("depselect", "fuser", "regex") as $type){ - $smarty->assign("$type", $faxfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - - $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* Manage incoming blocklists */ - if ($this->in_blocklist_dialog){ - - /* This handles the divSelectBox */ - - /* The base specifies the current position in the ldap tree - * The current base was specified by $_GET['dep_id'] before. Or contains the default value. - */ - $Fax_Filter = session::get('Fax_Filter'); - $base = $Fax_Filter['depselect']; - $ldap->cd($base); - - /* Ge all Blocklists */ - $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description")); - while ($attrs= $ldap->fetch()){ - - /* Generate list depending on description */ - if(isset($attrs['description'][0])){ - $list[$attrs['cn'][0]]= - $attrs['description'][0]. - " [".$attrs['cn'][0]."]"; - }else{ - $list[$attrs['cn'][0]]= $attrs['cn'][0]; - } - } - - /* Create our divselect box */ - $divSel = new divSelectBox("divSelectPredefined"); - $divSel->setHeight(296); - - /* NEW LIST MANAGMENT - * We also need to search for the departments - * So we are able to navigate like in konquerer - */ - $this->departments= array(); - - /* Get all departments within the current department */ - $Fax_Filter = session::get('Fax_Filter'); - $base = $Fax_Filter['depselect']; - $ldap->ls("(objectClass=gosaDepartment)",$base); - - /* Base back is used to go one department up in our ldap tree */ - $base_back = preg_replace("/^[^,]+,/","",$base); - - /* Only show base_back if it is needed */ - if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ - $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; - } - - /* Fetch all returned departments an add them to our divlist */ - while($value = $ldap->fetch()){ - if($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]; - } - } - /* END NEW LIST MANAGMENT - */ - - // This links specifies the department open link - $linkopen = "%s"; - - /* Insert departments in divsel */ - foreach($this->departments as $key=> $val){ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); - $divSel->AddEntry(array($field1,$field2)); - } - - /* Append predefined Blocklists */ - foreach($list as $entry => $value){ - $divSel->AddEntry(array( - array("string"=>""), - array("string"=>$value,"attach"=>"style='border:0px;'") - )); - } - - /* Show dialog */ - $smarty->assign("cblocklist", $this->current_blocklist); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("divSelectPredefined", $divSel->DrawList()); - $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Manage outgoing blocklists */ - - if ($this->out_blocklist_dialog){ - - /* This handles the divSelectBox */ - - /* The base specifies the current position in the ldap tree - * The current base was specified by $_GET['dep_id'] before. Or contains the default value. - */ - $Fax_Filter = session::get('Fax_Filter'); - $base = $Fax_Filter['depselect']; - $ldap->cd($base); - - /* Ge all Blocklists */ - $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description")); - while ($attrs= $ldap->fetch()){ - if(isset($attrs['description'][0])){ - $list[$attrs['cn'][0]]= - $attrs['description'][0]. - " [".$attrs['cn'][0]."]"; - }else{ - $list[$attrs['cn'][0]]= $attrs['cn'][0]; - } - } - - /*Create DivSel*/ - $divSel = new divSelectBox("divSelectPredefined"); - $divSel->setHeight(296); - - /* NEW LIST MANAGMENT - * We also need to search for the departments - * So we are able to navigate like in konquerer - */ - $this->departments= array(); - $ldap->ls("(objectClass=gosaDepartment)",$base); - - /* Generate Back url, and append if it is needed */ - $base_back = preg_replace("/^[^,]+,/","",$base); - if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ - $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; - } - - /* Get all departments */ - while($value = $ldap->fetch()){ - if(isset($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]; - } - } - /* END NEW LIST MANAGMENT - */ - - // Defining Links - $linkopen = "%s"; - - /* Insert departments in divlist*/ - foreach($this->departments as $key=> $val){ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); - $divSel->AddEntry(array($field1,$field2)); - } - - /* Append Blocklits */ - foreach($list as $entry => $value){ - $divSel->AddEntry(array( - array("string"=>""), - array("string"=>$value,"attach"=>"style='border:0px;'") - )); - } - - /* Show dialog */ - $smarty->assign("cblocklist", $this->current_blocklist); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("divSelectPredefined", $divSel->DrawList()); - $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* Show main page */ - $smarty->assign("languages", get_languages(TRUE)); - - $smarty->assign("formats", $this->fax_formats); - $smarty->assign("printers", $this->printerList); - - /* Load attributes */ - foreach(array("goFaxIsEnabled", "goFaxDeliveryMode", "facsimileTelephoneNumber", - "goFaxPrinter", "goFaxLanguage", "goFaxFormat", - "facsimileAlternateTelephoneNumber", "mail") as $val){ - - $smarty->assign("$val", $this->$val); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $desc){ - $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode)); - } - - /* Load checkboxes */ - if ($this->goFaxIsEnabled == "1"){ - $smarty->assign("goFaxIsEnabled", ""); - } else { - $smarty->assign("goFaxIsEnabled", "checked"); - } - /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */ - if ($this->goFaxDeliveryMode & 32) { - $smarty->assign("faxtomail", "checked"); - } else { - $smarty->assign("faxtomail", ""); - } - if ($this->goFaxDeliveryMode & 64) { - $smarty->assign("faxtoprinter", "checked"); - } else { - $smarty->assign("faxtoprinter", ""); - } - - foreach($this->attributes as $attr){ - if(in_array($attr,$this->multi_boxes)) { - $smarty->assign("use_".$attr,TRUE); - }else{ - $smarty->assign("use_".$attr,FALSE); - } - } - foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){ - if(in_array($attr,$this->multi_boxes)) { - $smarty->assign("use_".$attr,TRUE); - }else{ - $smarty->assign("use_".$attr,FALSE); - } - } - - $smarty->assign("multiple_support",$this->multiple_support_active); - $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - - /* 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); - - 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',array("uid"=> $this->uid)); - } - - - /* Check formular input */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* must: facsimileTelephoneNumber */ - if ($this->facsimileTelephoneNumber == ""){ - $message[]= _("The required field 'Fax' is not set."); - } - - if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ - $message[]= _("Please enter a valid telephone number in the 'Fax' field."); - } - - /* 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){ - if ($this->mail == ""){ - $message[]= _("Mail delivery is checked, but no address has been specified."); - } elseif (!tests::is_email($this->mail)){ - $message[]= _("The mail address you've entered is invalid."); - } - } - - // IE Fix, IE lets you choose disabled option, stupid browser ... - if((empty($this->goFaxPrinter))&&($this->goFaxDeliveryMode & 64)){ - $message[]= _("Deliver fax to printer, is only possible if valid printer is given. Please correct your choice."); - } - - return ($message); - } - - /* Save data to object */ - function save_object() - { - $edit_mode = (!is_object($this->parent) && !session::is_set('edit')); - if (isset($_POST['faxTab'])){ - plugin::save_object(); - - - $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($this->acl_is_writeable("faxtoprinter",$edit_mode)){ - if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ - $tmp |= 64; - }elseif($tmp & 64){ - $tmp &= !64; - } - } - $this->goFaxDeliveryMode = $tmp; - - if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){ - if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ - $this->goFaxIsEnabled= "0"; - } else { - $this->goFaxIsEnabled= "1"; - } - } - - - 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)){ - if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){ - $this->has_mailAccount= TRUE; - } - } - } - - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Save arrays */ - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ - - $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 */ - 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); - - /* 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("mofidy",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ - - if (isset($this->attrs[$val])){ - $this->$val= $this->attrs[$val]; - } - } - } - - - - /* Add alternate fax recipient */ - function addAlternate($number) - { - $this->facsimileAlternateTelephoneNumber[]= "$number"; - $this->facsimileAlternateTelephoneNumber= - array_unique ($this->facsimileAlternateTelephoneNumber); - - sort ($this->facsimileAlternateTelephoneNumber); - reset ($this->facsimileAlternateTelephoneNumber); - } - - function delAlternate($numbers) - { - $this->facsimileAlternateTelephoneNumber= array_remove_entries ($numbers, - $this->facsimileAlternateTelephoneNumber); - } - - function getCopyDialog() - { - $str = ""; - $smarty = get_smarty(); - $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber); - $str['string'] = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $str['status'] =""; - return($str); - } - - function SaveCopyDialog() - { - if(isset($_POST['facsimileTelephoneNumber'])){ - $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber']; - } - } - - - /* 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")) - )); - } - - /* Multiple edit support - */ - - /* Execute */ - function multiple_execute() - { - return($this->execute()); - } - - function multiple_save_object() - { - if (isset($_POST['faxTab'])){ - plugin::multiple_save_object(); - foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){ - if(isset($_POST["use_".$attr])){ - $this->multi_boxes[] = $attr; - } - } - - $tmp = 0+$this->goFaxDeliveryMode; - if(in_array("faxtomail",$this->multi_boxes)){ - if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){ - $tmp |= 32; - }elseif($tmp & 32){ - $tmp &= (!32); - } - } - if(in_array("faxtoprinter",$this->multi_boxes)){ - if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ - $tmp |= 64; - }elseif($tmp & 64){ - $tmp &= !64; - } - } - $this->goFaxDeliveryMode = $tmp; - - if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ - $this->goFaxIsEnabled= "0"; - } else { - $this->goFaxIsEnabled= "1"; - } - if (isset($_POST['mail']) && in_array("mail",$this->multi_boxes)){ - $this->mail= $_POST['mail']; - } - } - } - - function get_multi_edit_values() - { - $ret = plugin::get_multi_edit_values(); - if(in_array("goFaxIsEnabled",$this->multi_boxes)){ - $ret['goFaxIsEnabled'] = $this->goFaxIsEnabled; - } - if(in_array("faxtoprinter",$this->multi_boxes)){ - $ret['faxtoprinter'] = $this->goFaxDeliveryMode & 64; - } - if(in_array("faxtomail",$this->multi_boxes)){ - $ret['faxtomail'] = $this->goFaxDeliveryMode & 32; - } - - if(in_array("edit_incoming",$this->multi_boxes)){ - $ret['goFaxRBlocklist'] = $this->goFaxRBlocklist; - $ret['goFaxRBlockgroups'] = $this->goFaxRBlockgroups; - } - if(in_array("edit_outgoing",$this->multi_boxes)){ - $ret['goFaxSBlocklist'] = $this->goFaxSBlocklist; - $ret['goFaxSBlockgroups'] = $this->goFaxSBlockgroups; - } - return($ret); - } - - function multiple_check() - { - $message = plugin::multiple_check(); - return($message); - } - - function set_multi_edit_values($values) - { - plugin::set_multi_edit_values($values); - - if(isset($values['faxtoprinter'])){ - if($values['faxtoprinter']){ - $this->goFaxDeliveryMode |= 64; - }else{ - $this->goFaxDeliveryMode &= !64; - } - } - if(isset($values['faxtomail'])){ - if($values['faxtomail']){ - $this->goFaxDeliveryMode |= 32; - }else{ - $this->goFaxDeliveryMode &= !32; - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/faxaccount/generic.tpl b/gosa-core/plugins/gofax/faxaccount/generic.tpl deleted file mode 100644 index eb98dbbee..000000000 --- a/gosa-core/plugins/gofax/faxaccount/generic.tpl +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - - - - - - -
{$must} -{if $multiple_support} - -{else} -{render acl=$facsimileTelephoneNumberACL} - -{/render} -{/if} - -
- -{render acl=$goFaxLanguageACL checkbox=$multiple_support checked=$use_goFaxLanguage} - -{/render} - -
- -{render acl=$goFaxFormatACL checkbox=$multiple_support checked=$use_goFaxFormat} - -{/render} -
- -
-   - -

 {t}Delivery methods{/t}

- -{render acl=$goFaxIsEnabledACL checkbox=$multiple_support checked=$use_goFaxIsEnabled} - -{/render} - {t}Temporary disable fax usage{/t}
- - {if $has_mailaccount eq "false"} -{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail} - -{/render} -   -{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_mail} - -{/render} - {else} -{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail} - -{/render} - {t}Deliver fax as mail{/t} - {/if} -
- -{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_faxtoprinter} - -{/render} - {t}Deliver fax to printer{/t}  -{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_goFaxPrinter} - -{/render} -
- -

 

- - - - - - -
- - {if !$multiple_support} - -

 {t}Alternate fax numbers{/t}

-{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} -
-{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} -   -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} -   -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} - {/if} -
-

 {t}Blocklists{/t}

- - - - - - - - - -
{t}Blocklists for incoming fax{/t} -{render acl=$goFaxRBlocklistACL checkbox=$multiple_support checked=$use_edit_incoming} - -{/render} -
{t}Blocklists for outgoing fax{/t} -{render acl=$goFaxSBlocklistACL checkbox=$multiple_support checked=$use_edit_outgoing} - -{/render} -
-
- - - - - diff --git a/gosa-core/plugins/gofax/faxaccount/lists.tpl b/gosa-core/plugins/gofax/faxaccount/lists.tpl deleted file mode 100644 index 5817e6c7d..000000000 --- a/gosa-core/plugins/gofax/faxaccount/lists.tpl +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - -
- {t}Blocked numbers/lists{/t} -
- -
- -   - -
- {t}List of predefined blocklists{/t}
- - - - -
- {$divSelectPredefined} -
-
-
- -

- -   - -

- diff --git a/gosa-core/plugins/gofax/faxaccount/locals.tpl b/gosa-core/plugins/gofax/faxaccount/locals.tpl deleted file mode 100644 index ebf9a894f..000000000 --- a/gosa-core/plugins/gofax/faxaccount/locals.tpl +++ /dev/null @@ -1,64 +0,0 @@ - - - - - -
-
-

- {t}Select numbers to add{/t} {$hint}
-

-
-
-

- -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
-   - -
- - - - - -
- - -
- - - - - -
- - -
- {$apply} -
-
- -

- -   - -

- diff --git a/gosa-core/plugins/gofax/faxaccount/main.inc b/gosa-core/plugins/gofax/faxaccount/main.inc deleted file mode 100644 index 54a7bda92..000000000 --- a/gosa-core/plugins/gofax/faxaccount/main.inc +++ /dev/null @@ -1,112 +0,0 @@ -dn); - session::un_set ('edit'); - session::un_set ('gofaxAccount'); - } - - /* Create gofaxAccount object on demand */ - if (!session::is_set('gofaxAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $gofaxAccount= new gofaxAccount ($config, $ui->dn); - $gofaxAccount->set_acl_base($ui->dn); - $gofaxAccount->set_acl_category("users"); - session::set('gofaxAccount',$gofaxAccount); - } - $gofaxAccount = session::get('gofaxAccount'); - - /* save changes back to object */ - if (session::is_set('edit')){ - $gofaxAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - session::set('back_plugin',$plug); - session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/")); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - session::set('dn',$ui->dn); - session::set('edit',TRUE); - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $gofaxAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $gofaxAccount->save (); - del_lock ($ui->dn); - session::un_set ('edit'); - - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $gofaxAccount->execute (); - } - - $info= ""; - - /* Store changes in session */ - if (session::is_set('edit')){ - session::set('gofaxAccount',$gofaxAccount); - } - - /* Show page footer depending on the mode */ - if (!$gofaxAccount->locals_dialog && - !$gofaxAccount->out_blocklist_dialog && - !$gofaxAccount->in_blocklist_dialog && - $gofaxAccount->is_account && - empty($lock_msg)){ - - $display.= "

\n"; - - /* Are we in edit mode? */ - if (session::is_set('edit')){ - $display.= "\n"; - $display.= " \n"; - $display.= "\n"; - $info= " ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){ - $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); - $display.= ""; - } - $display.= "\n"; - } - $display.= "

"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display; - -} -?> diff --git a/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl b/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl deleted file mode 100644 index 6efca1d5b..000000000 --- a/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl +++ /dev/null @@ -1,31 +0,0 @@ - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {$must} - - -
- {t}Alternate fax numbers will not be copied{/t} -
-
- - diff --git a/gosa-core/plugins/gofax/faxreports/class_faxreport.inc b/gosa-core/plugins/gofax/faxreports/class_faxreport.inc deleted file mode 100644 index 1292b1aba..000000000 --- a/gosa-core/plugins/gofax/faxreports/class_faxreport.inc +++ /dev/null @@ -1,507 +0,0 @@ -config = $config; - $this->ui = &$ui; - $this->search_base = get_base_from_people($ui->dn); - $this->year = date("Y"); - $this->month = date("m"); - - /* Get global filter config and set class vars , - or create a filter */ - if (!session::is_set("faxreportfilter")){ - $faxreportfilter = array(); - foreach($this->attributes_SO as $name){ - $faxreportfilter[$name] = $this->$name; - } - session::set("faxreportfilter",$faxreportfilter); - }else{ - $faxreportfilter = session::get("faxreportfilter"); - foreach($this->attributes_SO as $name){ - $this->$name = $faxreportfilter[$name]; - } - } - } - - - /* Create Filter & Search & Display results */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /************ - Variable initialisation - ************/ - - /* Create months */ - $months= array(); - for($i = 1 ; $i <= 12 ; $i ++ ){ - $months[$i] = _(date("F",gmmktime(0,0,0,$i,1))); - } - - /* Create years */ - $current= date("Y"); - $years= array(); - for ($y= $current - 5; $y<=$current; $y++){ - $years[]= $y; - } - - - /************ - Set smarty defaults - ************/ - - $smarty= get_smarty(); - $smarty->assign("launchimage" , get_template_path('images/launch.png')); - $smarty->assign("search_image" , get_template_path('images/search.png')); - $smarty->assign("search_for" , $this->search_for); - $smarty->assign("bases" , $this->config->idepartments); - $smarty->assign("base_select" , $this->search_base); - $smarty->assign("months" , $months); - $smarty->assign("month_select" , $this->month); - $smarty->assign("years" , $years); - $smarty->assign("year_select" , $this->year); - $smarty->assign("search_result" , ""); - - - /************ - Check database accessibility - ************/ - - /* Some checks */ - if(!isset($this->config->data['SERVERS']['FAX'])){ - print_red(_("No fax extension defined in your server configuration, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }elseif(!is_callable("mysql_connect")){ - print_red(_("There is no mysql extension available, please check your php setup.")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }else{ - /* Connecting, selecting database */ - $cfg = $this->config->data['SERVERS']['FAX']; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - if ($link === FALSE){ - print_red(_("Can't connect to fax database, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - if (! @mysql_select_db("gofax")){ - print_red(_("Can't select fax database for report generation!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - if (! mysql_query("SELECT * FROM faxlog;")){ - print_red(_("Can't query fax table 'faxlog' for report generation!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - } - - - /************ - Perform a deatil view - ************/ - - /* Do detail view? */ - if (isset($_GET['detail'])){ - - /* Create query */ - $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,". - "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id=".$_GET['detail'].";"; - - /* Connecting, selecting database */ - $cfg= $this->config->data['SERVERS']['FAX']; - - /* Check if everything went ok*/ - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for fax database failed!")); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query failed"); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $line = mysql_fetch_array($result, MYSQL_ASSOC); - mysql_close($link); - - if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){ - print_red (_("You have no permission to retrieve informations about this fax id!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - /* Check acls */ - $fax_uids = array_flip($this->fax_users); - $uid = $line['uid']; - $dn = $fax_uids[$uid]; - $acls = $this->ui->get_permissions($dn,"faxreport/faxreport"); - if(!preg_match("/r/",$acls)){ - print_red (_("You have no permission to retrieve informations about this fax id!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn", - "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" ); - - foreach ($parts as $vname) { - - $final="fax_$vname"; - if($vname != "uid"){ - $v_acl = $this->ui->get_permissions($dn,"faxreport/faxreport",preg_replace("/_/","",$vname)); - }else{ - $v_acl = "r"; - } - - if ($line[$vname] != "" && preg_match("/r/",$v_acl)){ - $smarty->assign("$final", $line[$vname]); - } else { - $smarty->assign("$final", "-"); - } - } - $queuing_time= $line['queuing_time']; - - /* The user is allowed to download all fax images from those users - that are listed in session::get('fuserfilter') - Don't forget to check getfax.php if you change somthing here */ - session::set('fuserfilter',$this->userfilter); - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - $smarty->assign("detail", validate($_GET['detail'])); - - $format= _("Y-M-D"); - $date= preg_replace("/Y/", substr($queuing_time,0,4), $format); - $date= preg_replace("/M/", substr($queuing_time,4,2), $date); - $date= preg_replace("/D/", substr($queuing_time,6,2), $date); - $smarty->assign("date", $date); - $smarty->assign("time", substr($queuing_time,8,2).":". - substr($queuing_time,10,2).":". - substr($queuing_time,12,2)); - return($smarty->fetch(get_template_path('detail.tpl', TRUE))); - } - - - /************ - Search for uids matching the filter - ************/ - - /* Search button has been pressed */ - if ($this->search_for != ""){ - - if (is_integer (strpos($this->search_for, "*"))){ - $s= $this->search_for; - } else { - $s= "*".$this->search_for."*"; - } - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->search_base); - - /* Perform ldap search for potential users */ - $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". - "(objectClass=goFaxAccount)". - "(|(uid=$s)(l=$s)(homePhone=$s)". - "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". - "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)". - "(title=$s)))"; - - $res = get_list($filter, "users", $this->search_base, array("uid"), GL_SUBSEARCH ); - - /* Check if we are allowed to collect fax data */ - $fax_users= array(); - foreach($res as $attrs){ - $acl = $this->ui->get_permissions($attrs['dn'],"users/user","uid"); - if(preg_match("/r/",$acl)){ - $fax_users[ $attrs['dn']]= $attrs["uid"][0]; - } - } - - $this->fax_users = $fax_users; - - /* Prepare SQL query */ - $this->userfilter= ""; - foreach ($fax_users as $user){ - $this->userfilter.= "uid = '$user' OR "; - } - $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); - } - - /************ - Create filter - ************/ - - /* Perform SQL query */ - if ($this->userfilter){ - if ($this->sort_direction == "down"){ - $desc= "DESC"; - } else { - $desc= ""; - } - $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); - $end= date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year)); - $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ". - "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ". - "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;"; - - if(!is_callable("mysql_connect")){ - print_red("There is no mysql extension configured in your php setup."); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - - /************ - Create results - ************/ - - /* Connecting, selecting database */ - $cfg= $this->config->data['SERVERS']['FAX']; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for fax database failed!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $this->report_list= array(); - $user_ids = array_flip($fax_users); - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { - - /* Check permissions for each field */ - $dn = $user_ids[$line['uid']]; - - /* Hide restricted attributes */ - foreach(array("pages","receiverid","senderid","status","queuingtime","detailedView") as $attr){ - $var = $attr."ACL"; - $$var = $this->ui->get_permissions($dn,"faxreport/faxreport",$attr); - } - - /* Restricted attributes will not be displayed, this will be displayed instead */ - $no_acl = ""._("Insufficient permissions").""; - - /* Create date */ - if((!empty($line["queuing_time"])) && preg_match("/r/",$queuingtimeACL)){ - $hour= substr($line["queuing_time"], 8, 2); - $minute=substr($line["queuing_time"], 10, 2); - $format= _("Y-M-D"); - $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format); - $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date); - $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date); - $str_date = $date." ".$hour.":".$minute; - }else{ - $str_date = $no_acl; - } - - /* Create entry html str */ - - if(preg_match("/r/",$detailedViewACL)){ - $str = " - - \"\" -  ".$line["uid"]. - " - - $str_date"; - }else{ - $str = " - \"\" -  ".$line["uid"]." - $str_date"; - } - - /* Add Status td */ - if(preg_match("/r/",$statusACL)){ - $str.="".$this->status[$line["status"]].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add sender_id td */ - if(preg_match("/r/",$senderidACL)){ - $str.="".$line["sender_id"].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add receiver_id td */ - if(preg_match("/r/",$receiveridACL)){ - $str.="".$line["receiver_id"].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add receiver_id td */ - if(preg_match("/r/",$pagesACL)){ - $str.="".$line["pages"].""; - }else{ - $str.="".$no_acl.""; - } - $this->report_list[] = $str; - } - - mysql_close($link); - } - - /************ - Create output out of results - ************/ - - /* Generate output */ - $mod= 0; - $output= ""; - foreach ($this->report_list as $val){ - if ($mod < $this->start) { - $mod++; - continue; - } - if ($mod >= ($this->start + $this->range)){ - $mod++; - break; - } - if ( ($mod++) & 1){ - $col= "background-color: #ECECEC;"; - } else { - $col= "background-color: #F5F5F5;"; - } - $output.= "$val"; - } - - - /************ - Display results - ************/ - - if (isset($fax_users) && count($fax_users)){ - $smarty->assign("search_result", $output); - $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage")); - }else{ - $smarty->assign("search_result", ""); - } - - /* Show main page */ - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - for($i= 0; $i<7; $i++){ - $smarty->assign("mode$i", ""); - } - $smarty->assign("mode".$this->sort, "\"\"sort_direction. - ".png\" border=0 align=middle>"); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - - /* Save ui input, and store it in session::get() - to remember last search next time*/ - function save_object() - { - $faxreportfilter = session::get("faxreportfilter"); - if(isset($_POST['EntriesPerPage'])){ - $this->range = $_POST['EntriesPerPage']; - } - - if (isset($_GET['start'])){ - $this->start= (int)$_GET['start']; - } - - /* Adapt sorting */ - if (isset($_GET['sort'])){ - if ($this->sort == (int)$_GET['sort']){ - if ($this->sort_direction == "down"){ - $this->sort_direction= "up"; - } else { - $this->sort_direction= "down"; - } - } - $this->sort= (int)$_GET['sort']; - if ($this->sort < 0 || $this->sort > 5){ - $this->sort= 0; - } - } - foreach( array("year", "month", "search_for", "search_base") as $type){ - if (isset($_POST[$type])){ - $faxreportfilter[$type]= $_POST[$type]; - - /* reset start page, if filter has changed */ - if(!isset($_GET['start'])){ - $this->start = 0; - } - } - $this->$type= $faxreportfilter[$type]; - - } - foreach($this->attributes_SO as $name){ - $faxreportfilter[$name] = $this->$name; - } - session::set("faxreportfilter",$faxreportfilter); - } - - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - - return (array( - "plShortName" => _("Fax report"), - "plDescription" => _("Fax report")." "._("All entries are readonly")."", - "plSelfModify" => TRUE, - "plDepends" => array(), - "plPriority" => 1, // Position in tabs - "plSection" => array("administration"), // This belongs to personal - "plCategory" => array("faxreport" => array("description" => _("Fax reports"), - "objectClass" => array())), - "plOptions" => array(), - - "plProvidedAcls" => array( - "detailedView" => _("Detailed view"), - "id" => _("Fax ID"), - "queuingtime" => _("Date")." / "._("Time"), - "status" => _("Status"), - "senderid" => _("Sender ID"), - "sendermsn" => _("Sender MSN"), - "receiverid" => _("Receiver ID"), - "receivermsn" => _("Receiver MSN"), - "pages" => _("Number of pages"), - "statusmessage" => _("Status Message"), - "transfertime" => _("Transfer time")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/gofax/faxreports/contents.tpl b/gosa-core/plugins/gofax/faxreports/contents.tpl deleted file mode 100644 index 197c5b8c8..000000000 --- a/gosa-core/plugins/gofax/faxreports/contents.tpl +++ /dev/null @@ -1,59 +0,0 @@ -
-

[F]{t}Filter{/t}

-
-
-

-  {t}Search for{/t} - - {t}in{/t} - - {t}during{/t} - - {t}in{/t} - -   - -

-
- -
- -{if $search_result ne ""} - - - - - - - - - - {$search_result} -
{t}User{/t} {$mode0}{t}Date{/t} {$mode1}{t}Status{/t} {$mode2}{t}Sender{/t} {$mode3}{t}Receiver{/t} {$mode4}{t}# pages{/t} {$mode5}
- - - - - -
{$range_selector}
-

-   -

- -{else} - {t}Search returned no results...{/t} -{/if} - - - - diff --git a/gosa-core/plugins/gofax/faxreports/detail.tpl b/gosa-core/plugins/gofax/faxreports/detail.tpl deleted file mode 100644 index 20b6123b8..000000000 --- a/gosa-core/plugins/gofax/faxreports/detail.tpl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - -
- - {t}FAX preview - please wait{/t} - -

- {t}Click on fax to download{/t} -

-
-   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}FAX ID{/t}{$fax_id}
{t}User{/t}{$fax_uid}
{t}Date / Time{/t}{$date} / {$time}
{t}Sender MSN{/t}{$fax_sender_msn}
{t}Sender ID{/t}{$fax_sender_id}
{t}Receiver MSN{/t}{$fax_receiver_msn}
{t}Receiver ID{/t}{$fax_receiver_id}
{t}Status{/t}{$fax_status}
{t}Status message{/t}{$fax_status_message}
{t}Transfer time{/t}{$fax_transfer_time}
{t}# pages{/t}{$fax_pages}
- -
- -

- -

- diff --git a/gosa-core/plugins/gofax/faxreports/main.inc b/gosa-core/plugins/gofax/faxreports/main.inc deleted file mode 100644 index 03bf95b41..000000000 --- a/gosa-core/plugins/gofax/faxreports/main.inc +++ /dev/null @@ -1,19 +0,0 @@ -save_object(); - $display= $faxreport->execute (); - $display.= "\n"; - $display= print_header(get_template_path('images/reports.png'), _("FAX reports")).$display; - - /* Store changes in session */ - session::set('faxreport',$faxreport); -} -?> diff --git a/gosa-plugins/gofax/gofax/blocklists/class_blocklistGeneric.inc b/gosa-plugins/gofax/gofax/blocklists/class_blocklistGeneric.inc new file mode 100644 index 000000000..a6dab5936 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/class_blocklistGeneric.inc @@ -0,0 +1,371 @@ +type = BLOCK_LIST_SEND; + + /* Load defined numbers */ + if($dn != "new"){ + + /* We will not be able to rename edited blocklists */ + $this->readonly = TRUE; + + /* Get blocklist type and defined numbers */ + if (in_array("goFaxSBlock",$this->attrs['objectClass'])){ + if(isset($this->attrs["goFaxSBlocklist"])){ + for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_SEND; + } elseif (in_array("goFaxRBlock",$this->attrs['objectClass'])){ + if(isset($this->attrs["goFaxRBlocklist"])){ + for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_RECEIVE; + } + } + + /* Set base */ + if ($this->dn == "new"){ + if(session::is_set('CurrentMainBase')){ + $this->base = session::get('CurrentMainBase'); + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); + } + } + + public function execute() + { + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","blocklist/".get_class($this),$this->dn); + } + + + /************** + * Base select dialog + **************/ + + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + + }else{ + return($this->dialog->execute()); + } + } + + + /*************** + Add numer to blocklist + ***************/ + + + /* Handle interactions: add */ + if (isset($_POST['add_number']) && $_POST['number'] != ""){ + if (tests::is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ + $this->addNumber ($_POST['number']); + } else { + print_red (_("Please specify a valid phone number.")); + } + } + + + /*************** + Delete number from list + ***************/ + + /* Handle interactions: delete */ + if (isset($_POST['delete_number']) && isset($_POST['numbers']) && count($_POST['numbers']) > 0){ + $this->delNumber ($_POST['numbers']); + } + + + /*************** + Template output + ***************/ + + $smarty = get_smarty(); + foreach($this->attributes as $name){ + $smarty->assign($name,$this->$name); + } + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + $smarty->assign("goFaxBlocklist",$this->goFaxBlocklist); + $smarty->assign("cnACL",$this->getacl("cn",$this->readonly)); + $smarty->assign("typeACL",$this->getacl("type",$this->readonly)); + $smarty->assign("base",$this->base); + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("types", array(BLOCK_LIST_SEND => _("send"), BLOCK_LIST_RECEIVE => _("receive"))); + $smarty->assign("type", $this->type); + return($smarty->fetch(get_template_path('generic.tpl', TRUE))); + } + + + public function save_object() + { + if(isset($_POST['blocklist_posted'])){ + $tmp_cn = $this->cn; + plugin::save_object(); + $this->cn = $tmp_cn; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + $tmp = $this->attributes; + $tmp[] = "type"; + foreach($tmp as $attr){ + if(in_array($attr,array("cn","type")) && $this->readonly){ + continue; + }elseif(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ + $this->$attr = $_POST[$attr]; + } + } + } + } + + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->rmDir($this->dn); + new log("remove","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of blocklist with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove"); + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* check syntax: must cn */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not set."); + } else { + if (!tests::is_uid($this->cn)){ + $message[]= _("Required field 'Name' contains invalid characters"); + } + if ($this->dn == 'new'){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd (get_ou('blocklistou').$this->config->current["BASE"]); + $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn")); + if ($ldap->count() != 0){ + $message[]= _("Specified name is already used."); + } + } + } + return $message; + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Type selection */ + if ($this->type == BLOCK_LIST_SEND){ + $type= "goFaxSBlocklist"; + $this->attrs['objectClass']= "goFaxSBlock"; + } else { + $type= "goFaxRBlocklist"; + $this->attrs['objectClass']= "goFaxRBlock"; + } + + /* Add list */ + if (count($this->goFaxBlocklist)){ + $this->attrs[$type]= $this->goFaxBlocklist; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->base); + $ldap->cat($this->dn, array('dn')); + if ($ldap->count()){ + if (!isset($this->attrs[$type])){ + $this->attrs[$type]= array(); + } + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); + new log("modify","faxblocklist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify"); + } else { + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of blocklist with dn '%s' failed."),$this->dn)); + } + + + /* Add number */ + function addNumber($number) + { + if (!in_array($number, $this->goFaxBlocklist)){ + $this->goFaxBlocklist[]= $number; + sort($this->goFaxBlocklist); + } + } + + + /* Remove number from list */ + function delNumber($numbers) + { + $tmp= array(); + foreach ($this->goFaxBlocklist as $val){ + if (!in_array($val, $numbers)){ + $tmp[]= $val; + } + } + $this->goFaxBlocklist= $tmp; + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn",$this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = get_post('cn'); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* We will not be able to rename edited blocklists */ + $this->readonly = TRUE; + + /* Get blocklist type and defined numbers */ + if (in_array("goFaxSBlock",$source['objectClass'])){ + if(isset($source["goFaxSBlocklist"])){ + for ($i= 0; $i<$source["goFaxSBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $source["goFaxSBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_SEND; + } elseif (in_array("goFaxRBlock",$source['objectClass'])){ + if(isset($source["goFaxRBlocklist"])){ + for ($i= 0; $i<$source["goFaxRBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $source["goFaxRBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_RECEIVE; + } + + /* Set base */ + if ($this->dn == "new"){ + if(session::is_set('CurrentMainBase')){ + $this->base = session::get('CurrentMainBase'); + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Fax"), + "plDescription" => _("Fax blocklists"), + "plSelfModify" => FALSE, + "plDepends" => array(), + + "plPriority" => 0, + "plSection" => array("administration" => _("FAX Blocklists")), + "plCategory" => array("gofaxlist" => array("description" => _("Fax blocklists"), + "objectClass" => array("goFaxRBlock","goFaxSBlock"))), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "base" => _("Base"), + "goFaxBlocklist" => _("Blocklist"), + "type" => _("Blocklist type")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc b/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc new file mode 100644 index 000000000..8c68cc421 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc @@ -0,0 +1,477 @@ +ui = $ui; + $this->dn = ""; + $this->config = &$config; + $this->base = session::get('CurrentMainBase'); + $this->DivListBlocklist = new divListBlocklist($this->config,$this); + + /* Initialize copy&paste queue */ + if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ + $this->CopyPasteHandler= new CopyPasteHandler($this->config); + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + session::set('LOCK_VARS_TO_USE',array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/")); + + /*************** + Init vars + ***************/ + + /* Get global smarty instance */ + $smarty = get_smarty(); + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + + /*************** + Fetch posts + ***************/ + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/^goFaxBlocklist_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/^goFaxBlocklist_del_/i","",$key); + // Post for edit + }elseif(preg_match("/^goFaxBlocklist_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/^goFaxBlocklist_edit_/i","",$key); + // Post for new + }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_blocklists/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^copy/",$key)){ + $s_action = "copy"; + $s_entry= preg_replace("/^copy_/i", "", $key); + }elseif(preg_match("/^cut/",$key)){ + $s_action = "cut"; + $s_entry= preg_replace("/^cut_/i", "", $key); + } + + } + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFaxBlocklist_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /*************** + Handle copy & paste + ***************/ + + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /*************** + Cancel some dialogs + ***************/ + + /* Cancel dialog */ + if (isset($_POST['edit_cancel']) || + isset($_POST['delete_blocklist_cancel']) || + isset($_POST['delete_lock'])){ + + del_lock ($this->dn); + $this->dialog = NULL; + session::un_set('objectinfo'); + } + + + /*************** + Save blocklist + ***************/ + + /* What about finish? */ + if (isset($_POST['edit_finish']) || isset($_POST['edit_apply'])){ + + /* No errors, save object */ + $this->dialog->save_object(); + $message= $this->check(); + if (count ($message) == 0){ + + $this->dialog->save (); + + if (!isset($_POST['edit_apply'])){ + del_lock ($this->dn); + $this->dn= ""; + $this->dialog = NULL; + session::un_set('objectinfo'); + } + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + + /*************** + Create a new blocklist (dialog) + ***************/ + + /* Create new blocklist? */ + if ($s_action=="new"){ + $this->dn= "new"; + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->set_acl_base($this->base); + } + + + /*************** + Edit blocklist + ***************/ + + if ($s_action=="edit" && !is_object($this->dialog)){ + + $this->dn=$this->blocklists[$s_entry]['dn']; + + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message($user, $this->dn)); + }else{ + add_lock ($this->dn, $this->ui->dn); + } + session::set('objectinfo',trim($this->dn)); + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->set_acl_base($this->dn); + } + + + /*************** + Display dialog + ***************/ + + if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + + $this->dns = array(); + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + foreach($ids as $id){ + $dn = $this->blocklists[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("info", sprintf(_("You're about to delete the following blocklists(s) %s"), @LDAP::fix($dns_names))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. */ + if (isset($_POST['delete_multiple_blocklist_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ + $this->dn = $dn; + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->delete(); + $this->dialog = NULL; + } else { + print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn)); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + $this->reload(); + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_blocklist_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /*************** + Remove blocklist + ***************/ + + /* Delete blocklist requested */ + if ($s_action=="del"){ + $this->dn=$this->blocklists[$s_entry]['dn']; + + /* Check locking */ + if (($user= get_lock($this->dn)) != ""){ + session::set('dn',$this->dn); + return(gen_locked_message($user, $this->dn)); + } else { + + // Lock this dn for editing + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn)); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /*************** + Remove blocklist confirmed + ***************/ + + /* Finally delete blocklist */ + if (isset($_POST['delete_blocklist_confirm'])){ + if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->delete(); + $this->dialog = NULL; + del_lock ($this->dn); + } else { + print_red (_("You have no permission to remove this blocklist.")); + } + } + + /*************** + Divlist dialog + ***************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListBlocklist->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListBlocklist->parent = $this; + $this->DivListBlocklist->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListBlocklist->SubSearch){ + $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); + } + $this->reload(); + $this->DivListBlocklist->setEntries($this->blocklists); + return($this->DivListBlocklist->Draw()); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array(get_ou('blocklistou').$this->DivListBlocklist->selectedBase)); + } + + + /* Reload the list of known blocklists */ + function reload() + { + /* Init some vars */ + $filter = $filter2 = ""; + $base = $this->DivListBlocklist->selectedBase; + $Regex = $this->DivListBlocklist->Regex; + $SubSearch = $this->DivListBlocklist->SubSearch; + $ShowSendBocklists = $this->DivListBlocklist->ShowSendBocklists; + $ShowReceiveBlocklists = $this->DivListBlocklist->ShowReceiveBlocklists; + $Flags = GL_SIZELIMIT; + $res = $res2 = array(); + + /* Append subsearch to Flags */ + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + $base = get_ou('blocklistou').$base; + } + + /* Create filter */ + if ($ShowSendBocklists){ + $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))"; + $res= get_list($filter, "gofaxlist", $base,array("*"), $Flags); + } + if ($ShowReceiveBlocklists){ + $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))"; + $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags); + } + + $this->blocklists = array_merge($res,$res2); + + /* appen && sort */ + $tmp=array(); + foreach($this->blocklists as $tkey => $val ){ + + $acl = $this->ui ->get_permissions($base,"gofaxlist/blocklist"); + if(preg_match("/r/",$acl)){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + ksort($tmp); + $this->blocklists=array(); + foreach($tmp as $val){ + $this->blocklists[]=$val; + } + reset ($this->blocklists); + } + + + /* Save data to object */ + function save_object() + { + $this->DivListBlocklist->save_object(); + } + + + + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->blocklists[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->blocklists[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListBlocklist->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc new file mode 100644 index 000000000..8b8a505a6 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc @@ -0,0 +1,291 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of blocklists")); + $this->SetSummary(_("List of blocklists")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); + + /* Add Checkboxes / SubSearch checkbox */ + $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true); + $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true); + + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("gofaxlist"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Append department selector */ + $listhead .= " "._("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Blocklist")."|goFaxBlocklist_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + // User and Template Images + $blockimg = "User"; + $editlink = "%s"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Append to list */ + $ui = get_userinfo(); + foreach($list as $key => $val){ + + $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist"); + if(!preg_match("/r/",$acl)){ + continue; + } + + /* Edit link ; requires read access */ + $action= ""; + + + /* Create snapshot ; requires write access && create access */ + if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){ + $action.= $this->GetSnapShotActions($val['dn']); + } + + /* Add copy & cut icons */ + if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){ + $action .= " "; + $action.= " "; + } + + + /* Delete entry ; requires remove access */ + if(preg_match("/d/",$acl)){ + $action.= ""; + } + + // Generate Array to Add + if(isset($val["description"][0])){ + $display= $val["cn"][0]." [".$val["description"][0]."]"; + }else{ + $display= $val["cn"][0]; + } + + /* Cutted objects should be displayed in light grey */ + if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); + $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement( array($field0,$field1,$field2,$field3)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed blocklists"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/blocklists/generic.tpl b/gosa-plugins/gofax/gofax/blocklists/generic.tpl new file mode 100644 index 000000000..df9f84a6b --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/generic.tpl @@ -0,0 +1,109 @@ +

{t}Generic{/t}

+ + + + + + + + + +
+ + + + + + + + + +
{$must} + +{render acl=$cnACL} + +{/render} +
{$must} +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+   + + + + + + + + + + +
+{render acl=$typeACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
+
+ +

 

+ + + + + + + +
+

{t}Blocked numbers{/t}

+{render acl=$goFaxBlocklistACL} + +{/render} +
+{render acl=$goFaxBlocklistACL} +   +{/render} +{render acl=$goFaxBlocklistACL} +   +{/render} +{render acl=$goFaxBlocklistACL} + +{/render} +
+   + +

{t}Information{/t}

+

+ {t}Numbers can also contain wild cards.{/t} +

+
+ +

+ + + +

+ + + diff --git a/gosa-plugins/gofax/gofax/blocklists/main.inc b/gosa-plugins/gofax/gofax/blocklists/main.inc new file mode 100644 index 000000000..4a0f3c561 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/main.inc @@ -0,0 +1,35 @@ +dn); + session::un_set ('blocklist'); + } +} else { + /* Create blocklist object on demand */ + if (!session::is_set('blocklist') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $blocklist= new blocklist($config, $ui); + $blocklist->set_acl_category("gofaxlist"); + session::set('blocklist',$blocklist); + } + $blocklist = session::get('blocklist'); + $blocklist->save_object(); + $output= $blocklist->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + session::un_set ('blocklist'); + } + + /* Page header*/ + if (session::is_set('objectinfo')){ + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management"), "\"\"align=\"middle\" ".@LDAP::fix(session::get('objectinfo'))); + } else { + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management")); + } + $display.= $output; + + session::set('blocklist',$blocklist); +} +?> diff --git a/gosa-plugins/gofax/gofax/blocklists/paste_generic.tpl b/gosa-plugins/gofax/gofax/blocklists/paste_generic.tpl new file mode 100644 index 000000000..ac4cef972 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/paste_generic.tpl @@ -0,0 +1,8 @@ + + + + + +
+ +
diff --git a/gosa-plugins/gofax/gofax/blocklists/remove.tpl b/gosa-plugins/gofax/gofax/blocklists/remove.tpl new file mode 100644 index 000000000..ebea1e3ca --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/remove.tpl @@ -0,0 +1,24 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-plugins/gofax/gofax/blocklists/tabs_blocklist.inc b/gosa-plugins/gofax/gofax/blocklists/tabs_blocklist.inc new file mode 100644 index 000000000..32a674705 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/tabs_blocklist.inc @@ -0,0 +1,38 @@ +addSpecialTabs(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['blocklistGeneric']; + + /* Check for new 'dn', in order to propagate the 'dn' to all plugins */ + $new_dn= "cn=".$baseobject->cn.",".get_ou('blocklistou').$baseobject->base; + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['blocklistGeneric']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc b/gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc new file mode 100644 index 000000000..63f22cee6 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc @@ -0,0 +1,981 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + + /* Department list shown in the divSelectList*/ + var $departments; + + /* Fax attributes */ + var $goFaxDeliveryMode= ""; + var $facsimileTelephoneNumber= ""; + var $goFaxIsEnabled= 1; + var $goFaxPrinter= ""; + var $goFaxDivertNumber= ""; + var $goFaxLanguage= ""; + var $goFaxFormat= ""; + var $goFaxRBlocklist = array(); + var $goFaxRBlockgroups= array(); + var $goFaxSBlocklist= array(); + var $goFaxSBlockgroups= array(); + var $mail= ""; + var $facsimileAlternateTelephoneNumber= array(); + var $fax_formats = array("pdf","ps","png","mtiff","tiff"); + + /* Internal variables */ + var $printerList= array(); + var $has_mailAccount= FALSE; + var $locals_dialog= FALSE; + 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","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber"); + + var $uid =""; + + var $objectclasses= array("goFaxAccount"); + + /* Enable multiple edit support */ + var $multiple_support = TRUE; + + 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(!session::is_set("Fax_Filter")){ + $Fax_Filter = array(); + $Fax_Filter['depselect'] = $this->config->current['BASE']; + session::set('Fax_Filter',$Fax_Filter); + } + + if ($dn != "new"){ + /* Get arrays */ + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ + $this->$val =array(); + if (isset($this->attrs["$val"]["count"])){ + for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){ + array_push($this->$val, $this->attrs["$val"][$i]); + } + } + } + + /* Set up has_mailAccount */ + if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ + $this->has_mailAccount= TRUE; + } + } + + /* Load printer list */ + $this->printerList=get_printer_list(); + + /* 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 (!session::is_set("faxfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $faxfilter= array( "depselect" => $base, + "fuser" => "*", + "regex" => ""); + session::set("faxfilter", $faxfilter); + } + } + + function execute() + { + /* 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 + */ + if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ + + $Fax_Filter = session::get('Fax_Filter'); + if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ + $Fax_Filter['depselect']= base64_decode($_GET['dep_id']); + }else{ + $Fax_Filter['depselect']= $this->config->current['BASE']; + } + session::set('Fax_Filter',$Fax_Filter); + } + + /* Edit mode specifies if we are editing from my accout */ + $edit_mode = (!is_object($this->parent) && !session::is_set('edit')); + + /* Load smarty stuff */ + $smarty= get_smarty(); + + /* Check if mail account is active. We'll display an additional + mail address field if this is not the case. Some people may + want goFax, but have a mailserver which is not managed with + GOsa */ + if (!@isset($this->parent->by_object['mailAccount'])) { + $smarty->assign("has_mailaccount", $this->has_mailAccount?"true":"false"); + } elseif ( !$this->parent->by_object['mailAccount']->is_account){ + $smarty->assign("has_mailaccount", "false"); + $this->has_mailAccount= false; + } else { + $smarty->assign("has_mailaccount", "true"); + } + + + $display = ""; + if(!$this->multiple_support_active){ + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no fax extensions.").""; + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + $display= ""; + 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.")); + } else { + $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'])){ + 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",$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']) && tests::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']) && 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'])){ + 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; + } + } + + /* Edit outgoing blocklists */ + if (isset($_POST['edit_outgoing'])){ + $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups); + sort($this->current_blocklist); + reset($this->current_blocklist); + + $this->out_blocklist_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add number to blocklist (dialog) */ + if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){ + if (!tests::is_phone_nr($_POST['block_number'])){ + print_red (_("You're trying to add an invalid phone number.")); + } else { + array_push($this->current_blocklist, $_POST['block_number']); + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + } + + /* Hickert : 11.11.05 + * Add selection from divSelelect to our Blocklist + */ + /* Add list to blocklist */ + if (isset($_POST['add_blocklist'])){ + foreach($_POST as $name => $value){ + if(preg_match("/ADDLIST_/i",$name)){ + $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value))); + + } + } + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + + /* Add list to blocklist */ + if (isset($_GET['add'])){ + if(!is_array($this->current_blocklist)) $this->current_blocklist=array(); + $this->current_blocklist= array_merge($this->current_blocklist, array( base64_decode($_GET['add']))); + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + + /* Delete from blocklist */ + if (isset($_POST['delete_blocklist_number']) && isset($_POST['block_list'])){ + $tmp= array(); + foreach($this->current_blocklist as $val){ + if (!in_array($val, $_POST['block_list'])){ + $tmp[]= $val; + } + } + $this->current_blocklist= $tmp; + } + + + /* Blocklist edit finished */ + if (isset($_POST['edit_blocklists_finish'])){ + + /* Incoming or outgoing? */ + if ($this->in_blocklist_dialog){ + $this->goFaxRBlocklist = array(); + $this->goFaxRBlockgroups = array(); + + foreach ($this->current_blocklist as $val){ + if (tests::is_phone_nr($val)){ + $this->goFaxRBlocklist[]=$val; + } else { + $this->goFaxRBlockgroups[]= $val; + } + } + } else { + $this->goFaxSBlocklist = array(); + $this->goFaxSBlockgroups = array(); + + /* Transfer values to ourself */ + foreach ($this->current_blocklist as $val){ + if (tests::is_phone_nr($val)){ + $this->goFaxSBlocklist[]=$val; + } else { + $this->goFaxSBlockgroups[]= $val; + } + } + } + $this->is_modified= TRUE; + } + + + /* Set departments */ + if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){ + + $list= array (); + $ldap= $this->config->get_ldap_link(); + if (isset ($_POST['department'])){ + $ldap->cd ($_POST['department']); + } else { + $ldap->cd ($this->config->current['BASE']); + } + } + + /* Cancel dialogs */ + if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) || + isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){ + + $this->locals_dialog= FALSE; + $this->in_blocklist_dialog= FALSE; + $this->out_blocklist_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Manage locals dialog */ + if ($this->locals_dialog){ + + /* Save data */ + $faxfilter= session::get("faxfilter"); + foreach( array("depselect", "fuser", "regex") as $type){ + if (isset($_POST[$type])){ + $faxfilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $faxfilter['fuser']= $s; + } + + if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){ + $regex= $faxfilter['regex']; + $filter= "(facimileTelephoneNumber=$regex)"; + } else { + $filter= ""; + } + if ($faxfilter['fuser'] != ""){ + $user= $faxfilter['fuser']; + $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; + } + + $base= $faxfilter['depselect']; + $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base, + array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH); + + foreach ($res as $attrs){ + $list[$attrs['facsimileTelephoneNumber'][0]]= + $attrs['sn'][0].", ". + $attrs['givenName'][0]." [". + $attrs['facsimileTelephoneNumber'][0]."]"; + } + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("usearch_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("list", $list); + if (isset($_POST['depselect'])){ + $smarty->assign("depselect", $_POST['depselect']); + } + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("hint", print_sizelimit_warning()); + foreach( array("depselect", "fuser", "regex") as $type){ + $smarty->assign("$type", $faxfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + + $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* Manage incoming blocklists */ + if ($this->in_blocklist_dialog){ + + /* This handles the divSelectBox */ + + /* The base specifies the current position in the ldap tree + * The current base was specified by $_GET['dep_id'] before. Or contains the default value. + */ + $Fax_Filter = session::get('Fax_Filter'); + $base = $Fax_Filter['depselect']; + $ldap->cd($base); + + /* Ge all Blocklists */ + $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description")); + while ($attrs= $ldap->fetch()){ + + /* Generate list depending on description */ + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ + $list[$attrs['cn'][0]]= $attrs['cn'][0]; + } + } + + /* Create our divselect box */ + $divSel = new divSelectBox("divSelectPredefined"); + $divSel->setHeight(296); + + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + $this->departments= array(); + + /* Get all departments within the current department */ + $Fax_Filter = session::get('Fax_Filter'); + $base = $Fax_Filter['depselect']; + $ldap->ls("(objectClass=gosaDepartment)",$base); + + /* Base back is used to go one department up in our ldap tree */ + $base_back = preg_replace("/^[^,]+,/","",$base); + + /* Only show base_back if it is needed */ + if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + + /* Fetch all returned departments an add them to our divlist */ + while($value = $ldap->fetch()){ + if($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]; + } + } + /* END NEW LIST MANAGMENT + */ + + // This links specifies the department open link + $linkopen = "%s"; + + /* Insert departments in divsel */ + foreach($this->departments as $key=> $val){ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + + /* Append predefined Blocklists */ + foreach($list as $entry => $value){ + $divSel->AddEntry(array( + array("string"=>""), + array("string"=>$value,"attach"=>"style='border:0px;'") + )); + } + + /* Show dialog */ + $smarty->assign("cblocklist", $this->current_blocklist); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("divSelectPredefined", $divSel->DrawList()); + $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Manage outgoing blocklists */ + + if ($this->out_blocklist_dialog){ + + /* This handles the divSelectBox */ + + /* The base specifies the current position in the ldap tree + * The current base was specified by $_GET['dep_id'] before. Or contains the default value. + */ + $Fax_Filter = session::get('Fax_Filter'); + $base = $Fax_Filter['depselect']; + $ldap->cd($base); + + /* Ge all Blocklists */ + $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description")); + while ($attrs= $ldap->fetch()){ + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ + $list[$attrs['cn'][0]]= $attrs['cn'][0]; + } + } + + /*Create DivSel*/ + $divSel = new divSelectBox("divSelectPredefined"); + $divSel->setHeight(296); + + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + $this->departments= array(); + $ldap->ls("(objectClass=gosaDepartment)",$base); + + /* Generate Back url, and append if it is needed */ + $base_back = preg_replace("/^[^,]+,/","",$base); + if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + + /* Get all departments */ + while($value = $ldap->fetch()){ + if(isset($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]; + } + } + /* END NEW LIST MANAGMENT + */ + + // Defining Links + $linkopen = "%s"; + + /* Insert departments in divlist*/ + foreach($this->departments as $key=> $val){ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + + /* Append Blocklits */ + foreach($list as $entry => $value){ + $divSel->AddEntry(array( + array("string"=>""), + array("string"=>$value,"attach"=>"style='border:0px;'") + )); + } + + /* Show dialog */ + $smarty->assign("cblocklist", $this->current_blocklist); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("divSelectPredefined", $divSel->DrawList()); + $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* Show main page */ + $smarty->assign("languages", get_languages(TRUE)); + + $smarty->assign("formats", $this->fax_formats); + $smarty->assign("printers", $this->printerList); + + /* Load attributes */ + foreach(array("goFaxIsEnabled", "goFaxDeliveryMode", "facsimileTelephoneNumber", + "goFaxPrinter", "goFaxLanguage", "goFaxFormat", + "facsimileAlternateTelephoneNumber", "mail") as $val){ + + $smarty->assign("$val", $this->$val); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $desc){ + $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode)); + } + + /* Load checkboxes */ + if ($this->goFaxIsEnabled == "1"){ + $smarty->assign("goFaxIsEnabled", ""); + } else { + $smarty->assign("goFaxIsEnabled", "checked"); + } + /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */ + if ($this->goFaxDeliveryMode & 32) { + $smarty->assign("faxtomail", "checked"); + } else { + $smarty->assign("faxtomail", ""); + } + if ($this->goFaxDeliveryMode & 64) { + $smarty->assign("faxtoprinter", "checked"); + } else { + $smarty->assign("faxtoprinter", ""); + } + + foreach($this->attributes as $attr){ + if(in_array($attr,$this->multi_boxes)) { + $smarty->assign("use_".$attr,TRUE); + }else{ + $smarty->assign("use_".$attr,FALSE); + } + } + foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){ + if(in_array($attr,$this->multi_boxes)) { + $smarty->assign("use_".$attr,TRUE); + }else{ + $smarty->assign("use_".$attr,FALSE); + } + } + + $smarty->assign("multiple_support",$this->multiple_support_active); + $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + + /* 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); + + 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',array("uid"=> $this->uid)); + } + + + /* Check formular input */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* must: facsimileTelephoneNumber */ + if ($this->facsimileTelephoneNumber == ""){ + $message[]= _("The required field 'Fax' is not set."); + } + + if (!tests::is_phone_nr($this->facsimileTelephoneNumber)){ + $message[]= _("Please enter a valid telephone number in the 'Fax' field."); + } + + /* 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){ + if ($this->mail == ""){ + $message[]= _("Mail delivery is checked, but no address has been specified."); + } elseif (!tests::is_email($this->mail)){ + $message[]= _("The mail address you've entered is invalid."); + } + } + + // IE Fix, IE lets you choose disabled option, stupid browser ... + if((empty($this->goFaxPrinter))&&($this->goFaxDeliveryMode & 64)){ + $message[]= _("Deliver fax to printer, is only possible if valid printer is given. Please correct your choice."); + } + + return ($message); + } + + /* Save data to object */ + function save_object() + { + $edit_mode = (!is_object($this->parent) && !session::is_set('edit')); + if (isset($_POST['faxTab'])){ + plugin::save_object(); + + + $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($this->acl_is_writeable("faxtoprinter",$edit_mode)){ + if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ + $tmp |= 64; + }elseif($tmp & 64){ + $tmp &= !64; + } + } + $this->goFaxDeliveryMode = $tmp; + + if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){ + if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ + $this->goFaxIsEnabled= "0"; + } else { + $this->goFaxIsEnabled= "1"; + } + } + + + 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)){ + if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){ + $this->has_mailAccount= TRUE; + } + } + } + + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Save arrays */ + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ + + $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 */ + 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); + + /* 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("mofidy",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ + + if (isset($this->attrs[$val])){ + $this->$val= $this->attrs[$val]; + } + } + } + + + + /* Add alternate fax recipient */ + function addAlternate($number) + { + $this->facsimileAlternateTelephoneNumber[]= "$number"; + $this->facsimileAlternateTelephoneNumber= + array_unique ($this->facsimileAlternateTelephoneNumber); + + sort ($this->facsimileAlternateTelephoneNumber); + reset ($this->facsimileAlternateTelephoneNumber); + } + + function delAlternate($numbers) + { + $this->facsimileAlternateTelephoneNumber= array_remove_entries ($numbers, + $this->facsimileAlternateTelephoneNumber); + } + + function getCopyDialog() + { + $str = ""; + $smarty = get_smarty(); + $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber); + $str['string'] = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $str['status'] =""; + return($str); + } + + function SaveCopyDialog() + { + if(isset($_POST['facsimileTelephoneNumber'])){ + $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber']; + } + } + + + /* 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")) + )); + } + + /* Multiple edit support + */ + + /* Execute */ + function multiple_execute() + { + return($this->execute()); + } + + function multiple_save_object() + { + if (isset($_POST['faxTab'])){ + plugin::multiple_save_object(); + foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){ + if(isset($_POST["use_".$attr])){ + $this->multi_boxes[] = $attr; + } + } + + $tmp = 0+$this->goFaxDeliveryMode; + if(in_array("faxtomail",$this->multi_boxes)){ + if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){ + $tmp |= 32; + }elseif($tmp & 32){ + $tmp &= (!32); + } + } + if(in_array("faxtoprinter",$this->multi_boxes)){ + if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ + $tmp |= 64; + }elseif($tmp & 64){ + $tmp &= !64; + } + } + $this->goFaxDeliveryMode = $tmp; + + if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ + $this->goFaxIsEnabled= "0"; + } else { + $this->goFaxIsEnabled= "1"; + } + if (isset($_POST['mail']) && in_array("mail",$this->multi_boxes)){ + $this->mail= $_POST['mail']; + } + } + } + + function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + if(in_array("goFaxIsEnabled",$this->multi_boxes)){ + $ret['goFaxIsEnabled'] = $this->goFaxIsEnabled; + } + if(in_array("faxtoprinter",$this->multi_boxes)){ + $ret['faxtoprinter'] = $this->goFaxDeliveryMode & 64; + } + if(in_array("faxtomail",$this->multi_boxes)){ + $ret['faxtomail'] = $this->goFaxDeliveryMode & 32; + } + + if(in_array("edit_incoming",$this->multi_boxes)){ + $ret['goFaxRBlocklist'] = $this->goFaxRBlocklist; + $ret['goFaxRBlockgroups'] = $this->goFaxRBlockgroups; + } + if(in_array("edit_outgoing",$this->multi_boxes)){ + $ret['goFaxSBlocklist'] = $this->goFaxSBlocklist; + $ret['goFaxSBlockgroups'] = $this->goFaxSBlockgroups; + } + return($ret); + } + + function multiple_check() + { + $message = plugin::multiple_check(); + return($message); + } + + function set_multi_edit_values($values) + { + plugin::set_multi_edit_values($values); + + if(isset($values['faxtoprinter'])){ + if($values['faxtoprinter']){ + $this->goFaxDeliveryMode |= 64; + }else{ + $this->goFaxDeliveryMode &= !64; + } + } + if(isset($values['faxtomail'])){ + if($values['faxtomail']){ + $this->goFaxDeliveryMode |= 32; + }else{ + $this->goFaxDeliveryMode &= !32; + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/faxaccount/generic.tpl b/gosa-plugins/gofax/gofax/faxaccount/generic.tpl new file mode 100644 index 000000000..eb98dbbee --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/generic.tpl @@ -0,0 +1,152 @@ + + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + + + + + + +
{$must} +{if $multiple_support} + +{else} +{render acl=$facsimileTelephoneNumberACL} + +{/render} +{/if} + +
+ +{render acl=$goFaxLanguageACL checkbox=$multiple_support checked=$use_goFaxLanguage} + +{/render} + +
+ +{render acl=$goFaxFormatACL checkbox=$multiple_support checked=$use_goFaxFormat} + +{/render} +
+ +
+   + +

 {t}Delivery methods{/t}

+ +{render acl=$goFaxIsEnabledACL checkbox=$multiple_support checked=$use_goFaxIsEnabled} + +{/render} + {t}Temporary disable fax usage{/t}
+ + {if $has_mailaccount eq "false"} +{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail} + +{/render} +   +{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_mail} + +{/render} + {else} +{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail} + +{/render} + {t}Deliver fax as mail{/t} + {/if} +
+ +{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_faxtoprinter} + +{/render} + {t}Deliver fax to printer{/t}  +{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_goFaxPrinter} + +{/render} +
+ +

 

+ + + + + + +
+ + {if !$multiple_support} + +

 {t}Alternate fax numbers{/t}

+{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} +
+{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} +   +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} +   +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} + {/if} +
+

 {t}Blocklists{/t}

+ + + + + + + + + +
{t}Blocklists for incoming fax{/t} +{render acl=$goFaxRBlocklistACL checkbox=$multiple_support checked=$use_edit_incoming} + +{/render} +
{t}Blocklists for outgoing fax{/t} +{render acl=$goFaxSBlocklistACL checkbox=$multiple_support checked=$use_edit_outgoing} + +{/render} +
+
+ + + + + diff --git a/gosa-plugins/gofax/gofax/faxaccount/lists.tpl b/gosa-plugins/gofax/gofax/faxaccount/lists.tpl new file mode 100644 index 000000000..5817e6c7d --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/lists.tpl @@ -0,0 +1,35 @@ + + + + + + +
+ {t}Blocked numbers/lists{/t} +
+ +
+ +   + +
+ {t}List of predefined blocklists{/t}
+ + + + +
+ {$divSelectPredefined} +
+
+
+ +

+ +   + +

+ diff --git a/gosa-plugins/gofax/gofax/faxaccount/locals.tpl b/gosa-plugins/gofax/gofax/faxaccount/locals.tpl new file mode 100644 index 000000000..ebf9a894f --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/locals.tpl @@ -0,0 +1,64 @@ + + + + + +
+
+

+ {t}Select numbers to add{/t} {$hint}
+

+
+
+

+ +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+   + +
+ + + + + +
+ + +
+ + + + + +
+ + +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-plugins/gofax/gofax/faxaccount/main.inc b/gosa-plugins/gofax/gofax/faxaccount/main.inc new file mode 100644 index 000000000..54a7bda92 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/main.inc @@ -0,0 +1,112 @@ +dn); + session::un_set ('edit'); + session::un_set ('gofaxAccount'); + } + + /* Create gofaxAccount object on demand */ + if (!session::is_set('gofaxAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $gofaxAccount= new gofaxAccount ($config, $ui->dn); + $gofaxAccount->set_acl_base($ui->dn); + $gofaxAccount->set_acl_category("users"); + session::set('gofaxAccount',$gofaxAccount); + } + $gofaxAccount = session::get('gofaxAccount'); + + /* save changes back to object */ + if (session::is_set('edit')){ + $gofaxAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + session::set('back_plugin',$plug); + session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/")); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + session::set('dn',$ui->dn); + session::set('edit',TRUE); + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $gofaxAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $gofaxAccount->save (); + del_lock ($ui->dn); + session::un_set ('edit'); + + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $gofaxAccount->execute (); + } + + $info= ""; + + /* Store changes in session */ + if (session::is_set('edit')){ + session::set('gofaxAccount',$gofaxAccount); + } + + /* Show page footer depending on the mode */ + if (!$gofaxAccount->locals_dialog && + !$gofaxAccount->out_blocklist_dialog && + !$gofaxAccount->in_blocklist_dialog && + $gofaxAccount->is_account && + empty($lock_msg)){ + + $display.= "

\n"; + + /* Are we in edit mode? */ + if (session::is_set('edit')){ + $display.= "\n"; + $display.= " \n"; + $display.= "\n"; + $info= " ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){ + $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); + $display.= ""; + } + $display.= "\n"; + } + $display.= "

"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display; + +} +?> diff --git a/gosa-plugins/gofax/gofax/faxaccount/paste_generic.tpl b/gosa-plugins/gofax/gofax/faxaccount/paste_generic.tpl new file mode 100644 index 000000000..6efca1d5b --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/paste_generic.tpl @@ -0,0 +1,31 @@ + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {$must} + + +
+ {t}Alternate fax numbers will not be copied{/t} +
+
+ + diff --git a/gosa-plugins/gofax/gofax/faxreports/class_faxreport.inc b/gosa-plugins/gofax/gofax/faxreports/class_faxreport.inc new file mode 100644 index 000000000..1292b1aba --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxreports/class_faxreport.inc @@ -0,0 +1,507 @@ +config = $config; + $this->ui = &$ui; + $this->search_base = get_base_from_people($ui->dn); + $this->year = date("Y"); + $this->month = date("m"); + + /* Get global filter config and set class vars , + or create a filter */ + if (!session::is_set("faxreportfilter")){ + $faxreportfilter = array(); + foreach($this->attributes_SO as $name){ + $faxreportfilter[$name] = $this->$name; + } + session::set("faxreportfilter",$faxreportfilter); + }else{ + $faxreportfilter = session::get("faxreportfilter"); + foreach($this->attributes_SO as $name){ + $this->$name = $faxreportfilter[$name]; + } + } + } + + + /* Create Filter & Search & Display results */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /************ + Variable initialisation + ************/ + + /* Create months */ + $months= array(); + for($i = 1 ; $i <= 12 ; $i ++ ){ + $months[$i] = _(date("F",gmmktime(0,0,0,$i,1))); + } + + /* Create years */ + $current= date("Y"); + $years= array(); + for ($y= $current - 5; $y<=$current; $y++){ + $years[]= $y; + } + + + /************ + Set smarty defaults + ************/ + + $smarty= get_smarty(); + $smarty->assign("launchimage" , get_template_path('images/launch.png')); + $smarty->assign("search_image" , get_template_path('images/search.png')); + $smarty->assign("search_for" , $this->search_for); + $smarty->assign("bases" , $this->config->idepartments); + $smarty->assign("base_select" , $this->search_base); + $smarty->assign("months" , $months); + $smarty->assign("month_select" , $this->month); + $smarty->assign("years" , $years); + $smarty->assign("year_select" , $this->year); + $smarty->assign("search_result" , ""); + + + /************ + Check database accessibility + ************/ + + /* Some checks */ + if(!isset($this->config->data['SERVERS']['FAX'])){ + print_red(_("No fax extension defined in your server configuration, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }elseif(!is_callable("mysql_connect")){ + print_red(_("There is no mysql extension available, please check your php setup.")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }else{ + /* Connecting, selecting database */ + $cfg = $this->config->data['SERVERS']['FAX']; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + if ($link === FALSE){ + print_red(_("Can't connect to fax database, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + if (! @mysql_select_db("gofax")){ + print_red(_("Can't select fax database for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + if (! mysql_query("SELECT * FROM faxlog;")){ + print_red(_("Can't query fax table 'faxlog' for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + } + + + /************ + Perform a deatil view + ************/ + + /* Do detail view? */ + if (isset($_GET['detail'])){ + + /* Create query */ + $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,". + "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id=".$_GET['detail'].";"; + + /* Connecting, selecting database */ + $cfg= $this->config->data['SERVERS']['FAX']; + + /* Check if everything went ok*/ + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for fax database failed!")); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query failed"); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $line = mysql_fetch_array($result, MYSQL_ASSOC); + mysql_close($link); + + if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){ + print_red (_("You have no permission to retrieve informations about this fax id!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + /* Check acls */ + $fax_uids = array_flip($this->fax_users); + $uid = $line['uid']; + $dn = $fax_uids[$uid]; + $acls = $this->ui->get_permissions($dn,"faxreport/faxreport"); + if(!preg_match("/r/",$acls)){ + print_red (_("You have no permission to retrieve informations about this fax id!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn", + "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" ); + + foreach ($parts as $vname) { + + $final="fax_$vname"; + if($vname != "uid"){ + $v_acl = $this->ui->get_permissions($dn,"faxreport/faxreport",preg_replace("/_/","",$vname)); + }else{ + $v_acl = "r"; + } + + if ($line[$vname] != "" && preg_match("/r/",$v_acl)){ + $smarty->assign("$final", $line[$vname]); + } else { + $smarty->assign("$final", "-"); + } + } + $queuing_time= $line['queuing_time']; + + /* The user is allowed to download all fax images from those users + that are listed in session::get('fuserfilter') + Don't forget to check getfax.php if you change somthing here */ + session::set('fuserfilter',$this->userfilter); + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + $smarty->assign("detail", validate($_GET['detail'])); + + $format= _("Y-M-D"); + $date= preg_replace("/Y/", substr($queuing_time,0,4), $format); + $date= preg_replace("/M/", substr($queuing_time,4,2), $date); + $date= preg_replace("/D/", substr($queuing_time,6,2), $date); + $smarty->assign("date", $date); + $smarty->assign("time", substr($queuing_time,8,2).":". + substr($queuing_time,10,2).":". + substr($queuing_time,12,2)); + return($smarty->fetch(get_template_path('detail.tpl', TRUE))); + } + + + /************ + Search for uids matching the filter + ************/ + + /* Search button has been pressed */ + if ($this->search_for != ""){ + + if (is_integer (strpos($this->search_for, "*"))){ + $s= $this->search_for; + } else { + $s= "*".$this->search_for."*"; + } + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->search_base); + + /* Perform ldap search for potential users */ + $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". + "(objectClass=goFaxAccount)". + "(|(uid=$s)(l=$s)(homePhone=$s)". + "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". + "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)". + "(title=$s)))"; + + $res = get_list($filter, "users", $this->search_base, array("uid"), GL_SUBSEARCH ); + + /* Check if we are allowed to collect fax data */ + $fax_users= array(); + foreach($res as $attrs){ + $acl = $this->ui->get_permissions($attrs['dn'],"users/user","uid"); + if(preg_match("/r/",$acl)){ + $fax_users[ $attrs['dn']]= $attrs["uid"][0]; + } + } + + $this->fax_users = $fax_users; + + /* Prepare SQL query */ + $this->userfilter= ""; + foreach ($fax_users as $user){ + $this->userfilter.= "uid = '$user' OR "; + } + $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); + } + + /************ + Create filter + ************/ + + /* Perform SQL query */ + if ($this->userfilter){ + if ($this->sort_direction == "down"){ + $desc= "DESC"; + } else { + $desc= ""; + } + $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); + $end= date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year)); + $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ". + "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ". + "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;"; + + if(!is_callable("mysql_connect")){ + print_red("There is no mysql extension configured in your php setup."); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + + /************ + Create results + ************/ + + /* Connecting, selecting database */ + $cfg= $this->config->data['SERVERS']['FAX']; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for fax database failed!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $this->report_list= array(); + $user_ids = array_flip($fax_users); + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + + /* Check permissions for each field */ + $dn = $user_ids[$line['uid']]; + + /* Hide restricted attributes */ + foreach(array("pages","receiverid","senderid","status","queuingtime","detailedView") as $attr){ + $var = $attr."ACL"; + $$var = $this->ui->get_permissions($dn,"faxreport/faxreport",$attr); + } + + /* Restricted attributes will not be displayed, this will be displayed instead */ + $no_acl = ""._("Insufficient permissions").""; + + /* Create date */ + if((!empty($line["queuing_time"])) && preg_match("/r/",$queuingtimeACL)){ + $hour= substr($line["queuing_time"], 8, 2); + $minute=substr($line["queuing_time"], 10, 2); + $format= _("Y-M-D"); + $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format); + $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date); + $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date); + $str_date = $date." ".$hour.":".$minute; + }else{ + $str_date = $no_acl; + } + + /* Create entry html str */ + + if(preg_match("/r/",$detailedViewACL)){ + $str = " + + \"\" +  ".$line["uid"]. + " + + $str_date"; + }else{ + $str = " + \"\" +  ".$line["uid"]." + $str_date"; + } + + /* Add Status td */ + if(preg_match("/r/",$statusACL)){ + $str.="".$this->status[$line["status"]].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add sender_id td */ + if(preg_match("/r/",$senderidACL)){ + $str.="".$line["sender_id"].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add receiver_id td */ + if(preg_match("/r/",$receiveridACL)){ + $str.="".$line["receiver_id"].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add receiver_id td */ + if(preg_match("/r/",$pagesACL)){ + $str.="".$line["pages"].""; + }else{ + $str.="".$no_acl.""; + } + $this->report_list[] = $str; + } + + mysql_close($link); + } + + /************ + Create output out of results + ************/ + + /* Generate output */ + $mod= 0; + $output= ""; + foreach ($this->report_list as $val){ + if ($mod < $this->start) { + $mod++; + continue; + } + if ($mod >= ($this->start + $this->range)){ + $mod++; + break; + } + if ( ($mod++) & 1){ + $col= "background-color: #ECECEC;"; + } else { + $col= "background-color: #F5F5F5;"; + } + $output.= "$val"; + } + + + /************ + Display results + ************/ + + if (isset($fax_users) && count($fax_users)){ + $smarty->assign("search_result", $output); + $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage")); + }else{ + $smarty->assign("search_result", ""); + } + + /* Show main page */ + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + for($i= 0; $i<7; $i++){ + $smarty->assign("mode$i", ""); + } + $smarty->assign("mode".$this->sort, "\"\"sort_direction. + ".png\" border=0 align=middle>"); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + + /* Save ui input, and store it in session::get() + to remember last search next time*/ + function save_object() + { + $faxreportfilter = session::get("faxreportfilter"); + if(isset($_POST['EntriesPerPage'])){ + $this->range = $_POST['EntriesPerPage']; + } + + if (isset($_GET['start'])){ + $this->start= (int)$_GET['start']; + } + + /* Adapt sorting */ + if (isset($_GET['sort'])){ + if ($this->sort == (int)$_GET['sort']){ + if ($this->sort_direction == "down"){ + $this->sort_direction= "up"; + } else { + $this->sort_direction= "down"; + } + } + $this->sort= (int)$_GET['sort']; + if ($this->sort < 0 || $this->sort > 5){ + $this->sort= 0; + } + } + foreach( array("year", "month", "search_for", "search_base") as $type){ + if (isset($_POST[$type])){ + $faxreportfilter[$type]= $_POST[$type]; + + /* reset start page, if filter has changed */ + if(!isset($_GET['start'])){ + $this->start = 0; + } + } + $this->$type= $faxreportfilter[$type]; + + } + foreach($this->attributes_SO as $name){ + $faxreportfilter[$name] = $this->$name; + } + session::set("faxreportfilter",$faxreportfilter); + } + + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + + return (array( + "plShortName" => _("Fax report"), + "plDescription" => _("Fax report")." "._("All entries are readonly")."", + "plSelfModify" => TRUE, + "plDepends" => array(), + "plPriority" => 1, // Position in tabs + "plSection" => array("administration"), // This belongs to personal + "plCategory" => array("faxreport" => array("description" => _("Fax reports"), + "objectClass" => array())), + "plOptions" => array(), + + "plProvidedAcls" => array( + "detailedView" => _("Detailed view"), + "id" => _("Fax ID"), + "queuingtime" => _("Date")." / "._("Time"), + "status" => _("Status"), + "senderid" => _("Sender ID"), + "sendermsn" => _("Sender MSN"), + "receiverid" => _("Receiver ID"), + "receivermsn" => _("Receiver MSN"), + "pages" => _("Number of pages"), + "statusmessage" => _("Status Message"), + "transfertime" => _("Transfer time")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/gofax/faxreports/contents.tpl b/gosa-plugins/gofax/gofax/faxreports/contents.tpl new file mode 100644 index 000000000..197c5b8c8 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxreports/contents.tpl @@ -0,0 +1,59 @@ +
+

[F]{t}Filter{/t}

+
+
+

+  {t}Search for{/t} + + {t}in{/t} + + {t}during{/t} + + {t}in{/t} + +   + +

+
+ +
+ +{if $search_result ne ""} + + + + + + + + + + {$search_result} +
{t}User{/t} {$mode0}{t}Date{/t} {$mode1}{t}Status{/t} {$mode2}{t}Sender{/t} {$mode3}{t}Receiver{/t} {$mode4}{t}# pages{/t} {$mode5}
+ + + + + +
{$range_selector}
+

+   +

+ +{else} + {t}Search returned no results...{/t} +{/if} + + + + diff --git a/gosa-plugins/gofax/gofax/faxreports/detail.tpl b/gosa-plugins/gofax/gofax/faxreports/detail.tpl new file mode 100644 index 000000000..20b6123b8 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxreports/detail.tpl @@ -0,0 +1,69 @@ + + + + + + +
+ + {t}FAX preview - please wait{/t} + +

+ {t}Click on fax to download{/t} +

+
+   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}FAX ID{/t}{$fax_id}
{t}User{/t}{$fax_uid}
{t}Date / Time{/t}{$date} / {$time}
{t}Sender MSN{/t}{$fax_sender_msn}
{t}Sender ID{/t}{$fax_sender_id}
{t}Receiver MSN{/t}{$fax_receiver_msn}
{t}Receiver ID{/t}{$fax_receiver_id}
{t}Status{/t}{$fax_status}
{t}Status message{/t}{$fax_status_message}
{t}Transfer time{/t}{$fax_transfer_time}
{t}# pages{/t}{$fax_pages}
+ +
+ +

+ +

+ diff --git a/gosa-plugins/gofax/gofax/faxreports/main.inc b/gosa-plugins/gofax/gofax/faxreports/main.inc new file mode 100644 index 000000000..03bf95b41 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxreports/main.inc @@ -0,0 +1,19 @@ +save_object(); + $display= $faxreport->execute (); + $display.= "\n"; + $display= print_header(get_template_path('images/reports.png'), _("FAX reports")).$display; + + /* Store changes in session */ + session::set('faxreport',$faxreport); +} +?>