From f3cfcb66f359a89b142a33b924cc10658d459759 Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 12 Dec 2007 17:15:01 +0000 Subject: [PATCH] Added first plugin seperation test git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8116 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-plugins/dh-make-gosa | 175 ++++ .../services/gofax/class_goFaxServer.inc | 103 +++ .../systems/services/gofax/goFaxServer.tpl | 27 + .../blocklists/class_blocklistGeneric.inc | 371 ++++++++ .../blocklists/class_blocklistManagement.inc | 477 ++++++++++ .../blocklists/class_divListBlocklists.inc | 291 ++++++ .../gofax/gofax/blocklists/generic.tpl | 109 +++ gosa-plugins/gofax/gofax/blocklists/main.inc | 34 + .../gofax/gofax/blocklists/paste_generic.tpl | 8 + .../gofax/gofax/blocklists/remove.tpl | 24 + .../gofax/gofax/blocklists/tabs_blocklist.inc | 38 + .../gofax/faxaccount/class_gofaxAccount.inc | 857 ++++++++++++++++++ .../gofax/gofax/faxaccount/generic.tpl | 145 +++ gosa-plugins/gofax/gofax/faxaccount/lists.tpl | 35 + .../gofax/gofax/faxaccount/locals.tpl | 64 ++ gosa-plugins/gofax/gofax/faxaccount/main.inc | 112 +++ .../gofax/gofax/faxaccount/paste_generic.tpl | 31 + .../gofax/faxreports/class_faxreport.inc | 507 +++++++++++ .../gofax/gofax/faxreports/contents.tpl | 59 ++ .../gofax/gofax/faxreports/detail.tpl | 69 ++ gosa-plugins/gofax/gofax/faxreports/main.inc | 19 + gosa-plugins/gofax/manifest | 6 + 22 files changed, 3561 insertions(+) create mode 100755 gosa-plugins/dh-make-gosa create mode 100644 gosa-plugins/gofax/admin/systems/services/gofax/class_goFaxServer.inc create mode 100644 gosa-plugins/gofax/admin/systems/services/gofax/goFaxServer.tpl create mode 100644 gosa-plugins/gofax/gofax/blocklists/class_blocklistGeneric.inc create mode 100644 gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc create mode 100755 gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc create mode 100644 gosa-plugins/gofax/gofax/blocklists/generic.tpl create mode 100644 gosa-plugins/gofax/gofax/blocklists/main.inc create mode 100644 gosa-plugins/gofax/gofax/blocklists/paste_generic.tpl create mode 100644 gosa-plugins/gofax/gofax/blocklists/remove.tpl create mode 100644 gosa-plugins/gofax/gofax/blocklists/tabs_blocklist.inc create mode 100644 gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc create mode 100644 gosa-plugins/gofax/gofax/faxaccount/generic.tpl create mode 100644 gosa-plugins/gofax/gofax/faxaccount/lists.tpl create mode 100644 gosa-plugins/gofax/gofax/faxaccount/locals.tpl create mode 100644 gosa-plugins/gofax/gofax/faxaccount/main.inc create mode 100644 gosa-plugins/gofax/gofax/faxaccount/paste_generic.tpl create mode 100644 gosa-plugins/gofax/gofax/faxreports/class_faxreport.inc create mode 100644 gosa-plugins/gofax/gofax/faxreports/contents.tpl create mode 100644 gosa-plugins/gofax/gofax/faxreports/detail.tpl create mode 100644 gosa-plugins/gofax/gofax/faxreports/main.inc create mode 100644 gosa-plugins/gofax/manifest diff --git a/gosa-plugins/dh-make-gosa b/gosa-plugins/dh-make-gosa new file mode 100755 index 000000000..05153200b --- /dev/null +++ b/gosa-plugins/dh-make-gosa @@ -0,0 +1,175 @@ +#!/bin/sh + +plugin=$1 +TMPDIR=/tmp/dh-make-gosa.$$ + +check_plugin() { + [[ -r $1/manifest ]] +} + +parse_manifest() { + pl_name=gofax + pl_version=1.0 + pl_description="GOfax integration for GOsa" + pl_depends= + pl_author="Cajus Pollmeier " +} + + +############################################################################## +# M A I N # +############################################################################## + +# Sanity check +if ! check_plugin $plugin; then + echo "Failed" + exit 1 +fi +parse_manifest $plugin + +# Create temporary copy +echo "Creating temporary copy of plugin '$plugin'..." +mkdir -p $TMPDIR +cp -a $plugin/* $TMPDIR +rm $TMPDIR/manifest +find $TMPDIR -name '*.svn' -type d -exec rm -rf {} \; 2> /dev/null + +# Add debian infrastructure +mkdir $TMPDIR/debian +cat < $TMPDIR/debian/changelog +gosa-plugin-$pl_name ($pl_version-1) unstable; urgency=low + + * Initial release + + -- $pl_author $(822-date) +EOF + +echo 5 > $TMPDIR/debian/compat + +cat < $TMPDIR/debian/control +Source: gosa-plugin-$pl_name +Section: utils +Priority: optional +Maintainer: $pl_author +Standards-Version: 3.7.2.2 +Build-Depends: debhelper(>= 4.2.32) + +Package: gosa-plugin-$pl_name +Architecture: any +Depends: gosa-core $pl_depends +Suggests: gosa +Description: $pl_description + This package includes the $pl_name plugin for use with GOsa. + . + GOsa is a combination of system-administrator and end-user web + interface, designed to handle LDAP based setups. +EOF + +cat < $TMPDIR/debian/copyright +This package was debianized by $pl_author +on $(822-date) + +Copyright: GPL2 + +This code is released under the terms of the GPLv2 license. + +See /usr/share/common-licenses/GPL-2 for the full license. +EOF + +dirs=$(find $TMPDIR -maxdepth 1 -type d | grep -v debian) +for dir in $(echo $dirs); do + [[ $dir == $TMPDIR ]] && continue + dir=$(basename $dir) + echo usr/share/gosa/plugins/$dir >> $TMPDIR/debian/dirs + echo $dir usr/share/gosa/plugins >> $TMPDIR/debian/install +done + +cat < $TMPDIR/debian/README.Debian +README.Debian for $pl_name +-------------------------- + +You need a proper LDAP/GOsa setup to make this run. More +text will follow later. Sorry. + +---- +$pl_author $(822-date) +EOF + +cat < $TMPDIR/debian/rules +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: patch + #******************************************************** + #* Building plugin into a Debian/GNU Linux Package * + #* please stand by * + #******************************************************** + +clean: clean-patched unpatch +clean-patched: + dh_testdir + rm -f install-stamp + -rm -f debian/files + -rm -rf debian/tmp + -rm -f debian/substvars + dh_clean + +unpatch: + dpatch deapply-all + rm -rf patch-stamp debian/patched + +install: install-stamp +install-stamp: + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + touch install-stamp + +patch: patch-stamp +patch-stamp: + dpatch apply-all + dpatch cat-all >patch-stamp + +binary-indep: install + dh_testdir + dh_testroot + + dh_install + dh_installdocs + dh_installcron + dh_installexamples + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_perl + dh_installdeb + dh_shlibdeps + + dh_gencontrol + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep +.PHONY: build install clean binary-indep binary + +binary-arch: + +EOF + +chmod +x $TMPDIR/debian/rules + +(cd $TMPDIR && dpkg-buildpackage -uc -us -rfakeroot) + +# Cleanup +echo "Cleaning up..." +#rm -rf "$TMPDIR" diff --git a/gosa-plugins/gofax/admin/systems/services/gofax/class_goFaxServer.inc b/gosa-plugins/gofax/admin/systems/services/gofax/class_goFaxServer.inc new file mode 100644 index 000000000..1e5e04976 --- /dev/null +++ b/gosa-plugins/gofax/admin/systems/services/gofax/class_goFaxServer.inc @@ -0,0 +1,103 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goFaxServer"); + var $attributes = array("goFaxAdmin", "goFaxPassword"); + var $StatusFlag = "goFaxServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goFaxServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + + var $goFaxAdmin = ""; + var $goFaxPassword = ""; + var $goFaxServerStatus = ""; + var $cn = ""; + var $view_logged =FALSE; + + function goFaxServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("FAX database"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation ){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("FAX database configuration"); + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + if (empty($this->goFaxAdmin)){ + $message[]= _("The attribute user is empty or contains invalid characters."); + } + if (empty($this->goFaxPassword)){ + $message[]= _("The attribute password is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goFaxServerPosted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Fax database"), + "plDescription" => _("Fax database")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 99, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goFaxAdmin" => _("Login name"), + "goFaxPassword" => _("Password")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/gofax/admin/systems/services/gofax/goFaxServer.tpl b/gosa-plugins/gofax/admin/systems/services/gofax/goFaxServer.tpl new file mode 100644 index 000000000..27560b3f3 --- /dev/null +++ b/gosa-plugins/gofax/admin/systems/services/gofax/goFaxServer.tpl @@ -0,0 +1,27 @@ +

{t}FAX database information{/t}

+ + + + + + + + + +
{t}FAX DB user{/t}{$must} +{render acl=$goFaxAdminACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goFaxPasswordACL} + +{/render} +
+ +

 

+
+ +   + +
+ 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..19284661d --- /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(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['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 (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 (!is_uid($this->cn)){ + $message[]= _("Required field 'Name' contains invalid characters"); + } + if ($this->dn == 'new'){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ("ou=gofax,ou=systems,".$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(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['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..f9b19ea2a --- /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['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['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; + unset($_SESSION['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; + unset($_SESSION['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['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['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("ou=gofax,ou=systems,". $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 = "ou=gofax,ou=systems,".$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 100755 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..71c0b81a3 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/main.inc @@ -0,0 +1,34 @@ +dn); + sess_del ('blocklist'); + } +} else { + /* Create blocklist object on demand */ + if (!isset($_SESSION['blocklist']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['blocklist']= new blocklist($config, $ui); + $_SESSION['blocklist']->set_acl_category("gofaxlist"); + } + $blocklist= $_SESSION['blocklist']; + $blocklist->save_object(); + $output= $blocklist->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('blocklist'); + } + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management"), "\"\"align=\"middle\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management")); + } + $display.= $output; + + $_SESSION['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..9293903e1 --- /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.",ou=gofax,ou=systems,".$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..eca222857 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc @@ -0,0 +1,857 @@ + "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"); + + 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(!isset($_SESSION["Fax_Filter"])){ + $_SESSION['Fax_Filter']['depselect'] = $this->config->current['BASE']; + } + + 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 */ + if (isset($this->config->data['SERVERS']['CUPS'])){ + $this->printerList= get_printer_list ($this->config->data['SERVERS']['CUPS']); + asort ($this->printerList); + } + + /* Check if the currently selected printer is still available. + If not, append current printer to list of available. + It could be possible, that we are not allowed to view printers and so the list is empty ... */ + if(!empty($this->goFaxPrinter) && !isset($this->printerList[$this->goFaxPrinter])) { + $this->printerList[$this->goFaxPrinter] = "[".$this->goFaxPrinter."]"; + } + + /* Get global filter config */ + if (!is_global("faxfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $faxfilter= array( "depselect" => $base, + "fuser" => "*", + "regex" => ""); + register_global("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")){ + + if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ + $_SESSION['Fax_Filter']['depselect']= base64_decode($_GET['dep_id']); + }else{ + $_SESSION['Fax_Filter']['depselect']= $this->config->current['BASE']; + } + } + + /* Edit mode specifies if we are editing from my accout */ + $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit'])); + + /* Load smarty stuff */ + $smarty= get_smarty(); + + /* 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"); + } + + /* 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']) && 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 (!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 (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 (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= get_global("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. + */ + $base = $_SESSION['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 */ + $base = $_SESSION['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. + */ + $base = $_SESSION['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", ""); + } + + + $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 (!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 (!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) && !isset($_SESSION['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")) + )); + } +} + +// 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..cb56a6c11 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/generic.tpl @@ -0,0 +1,145 @@ + + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + + + + + + +
{$must} + +{render acl=$facsimileTelephoneNumberACL} + +{/render} + +
+ +{render acl=$goFaxLanguageACL} + +{/render} + +
+ +{render acl=$goFaxFormatACL} + +{/render} +
+ +
+   + +

 {t}Delivery methods{/t}

+ +{render acl=$goFaxIsEnabledACL} + +{/render} + {t}Temporary disable fax usage{/t}
+ + {if $has_mailaccount eq "false"} +{render acl=$faxtomailACL} + +{/render} +   +{render acl=$faxtomailACL} + +{/render} + {else} +{render acl=$faxtomailACL} + +{/render} + {t}Deliver fax as mail{/t} + {/if} +
+ +{render acl=$faxtoprinterACL} + +{/render} + {t}Deliver fax to printer{/t}  +{render acl=$faxtoprinterACL} + +{/render} +
+ +

 

+ + + + + + +
+

 {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} +
+

 {t}Blocklists{/t}

+ + + + + + + + + +
{t}Blocklists for incoming fax{/t} +{render acl=$goFaxRBlocklistACL} + +{/render} +
{t}Blocklists for outgoing fax{/t} +{render acl=$goFaxSBlocklistACL} + +{/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..d2786d889 --- /dev/null +++ b/gosa-plugins/gofax/gofax/faxaccount/main.inc @@ -0,0 +1,112 @@ +dn); + sess_del ('edit'); + sess_del ('gofaxAccount'); + } + + /* Create gofaxAccount object on demand */ + if (!isset($_SESSION['gofaxAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['gofaxAccount']= new gofaxAccount ($config, $ui->dn); + $_SESSION['gofaxAccount']->set_acl_base($ui->dn); + $_SESSION['gofaxAccount']->set_acl_category("users"); + + } + $gofaxAccount= $_SESSION['gofaxAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $gofaxAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['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['dn']= $ui->dn; + $_SESSION['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); + sess_del ('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 (isset ($_SESSION['edit'])){ + $_SESSION['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 (isset($_SESSION['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..41e0fc471 --- /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 (!is_global("faxreportfilter")){ + $faxreportfilter = array(); + foreach($this->attributes_SO as $name){ + $faxreportfilter[$name] = $this->$name; + } + register_global("faxreportfilter",$faxreportfilter); + }else{ + $faxreportfilter = get_global("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['fuserfilter'] + Don't forget to check getfax.php if you change somthing here */ + $_SESSION['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 + to remember last search next time*/ + function save_object() + { + $faxreportfilter = get_global("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; + } + register_global("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..ac80ff340 --- /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['faxreport']= $faxreport; +} +?> diff --git a/gosa-plugins/gofax/manifest b/gosa-plugins/gofax/manifest new file mode 100644 index 000000000..e56354864 --- /dev/null +++ b/gosa-plugins/gofax/manifest @@ -0,0 +1,6 @@ +[manifest] +name = gofax +description = GOfax intetragion for GOsa. +author = Cajus Pollmeier +version = 1.0 +depends = gosa-core -- 2.30.2