summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 04203b7)
raw | patch | inline | side by side (parent: 04203b7)
author | hzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Sep 2010 12:27:09 +0000 (12:27 +0000) | ||
committer | hzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Sep 2010 12:27:09 +0000 (12:27 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19708 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/groupware/personal/groupware/class_FilterEditor.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/groupware/personal/groupware/class_FilterManager.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/groupware/personal/groupware/class_Groupware.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/groupware/personal/groupware/class_filterEditor.inc | [deleted file] | patch | blob | history |
gosa-plugins/groupware/personal/groupware/class_filterManager.inc | [deleted file] | patch | blob | history |
diff --git a/gosa-plugins/groupware/personal/groupware/class_FilterEditor.inc b/gosa-plugins/groupware/personal/groupware/class_FilterEditor.inc
--- /dev/null
@@ -0,0 +1,197 @@
+<?php
+
+class FilterEditor extends plugin
+{
+ function __construct($config, $parent, $filter)
+ {
+ $this->config = &$config;
+ $this->parent = &$parent;
+ $this->filter = $filter;
+
+ $this->types = array(
+ 'OR' => _("At least one of the following conditions has to match"),
+ 'AND' => _("All conditions have to match"));
+
+ $this->actions = array(
+ "MOVE" => _("move mail to"),
+ "COPY" => _("copy mail to"),
+ "FORWARD" => _("forward message to"),
+ "MARK" => _("mark mail as "),
+ "DROP" => _("remove mail"),
+ "REPLY" => _("reply"));
+
+ $this->fields = array(
+ 'subject' => _("Subject"),
+ 'from'=> _("From"),
+ 'body'=> _("Body"),
+ 'date'=> _("Date"),
+ 'priority'=> _("Priority"),
+ 'status'=> _("Status"),
+ 'to'=> _("To"),
+ 'cc'=> _("CC"),
+ 'age'=> _("Age"),
+ 'size'=> _("Size"));
+
+ $this->comparators = array(
+ "is" => _("is"),
+ "is not" => _("is not"),
+ "equal" => _("is equal"),
+ "not equal" => _("is not equal"),
+ "is empty" => _("is empty"),
+ "is not empty" => _("is not empty"),
+ "contains" => _("contains"),
+ "contains not" => _("does not contain"),
+ "is in addressbook" => _("is in the addressbook"),
+ "is not in addressbook" => _("is not in the addressbook"),
+ "greater than" => _("is greater than"),
+ "less than" => _("smaller than"));
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+ $smarty->assign('NAME',set_post($this->filter['NAME']));
+ $smarty->assign('DESC',set_post($this->filter['DESC']));
+ $smarty->assign('filterStr', $this->renderFilter());
+ $smarty->assign('acl', $this->parent->getacl('mailFilter'));
+
+ return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__))));
+ }
+
+
+
+ function check()
+ {
+ $msgs = array();
+ return($msgs);
+ }
+
+
+ function save()
+ {
+ // Just return the filter array we've modified
+ return($this->filter);
+ }
+
+
+ function renderFilter()
+ {
+ $filter = $this->filter;
+
+ $cnt = count($filter['CONDITIONS']);
+ $str = "<h3>"._("Filter conditions")."</h3>";
+ $str .= _("Condition type")." ";
+ $str .="\n<select size='1' name='cType' onChange='document.mainform.submit();'>";
+ foreach($this->types as $type => $desc){
+ $checked = ($type == $filter['TYPE'])? ' selected ' : '';
+ $str.= "\n<option {$checked} value=\"".set_post($type)."\">".set_post($desc)."</option>";
+ }
+ $str .= "\n</select>";
+ $str.= "<ul>";
+ foreach($filter['CONDITIONS'] as $id => $cond){
+ $str .= "<li>";
+# $str .= _("Check field")." ";
+ $str .= "\n<select size='1' style='width:100px;' name='cField_{$id}' onChange='document.mainform.submit();'>";
+ foreach($this->fields as $field => $desc){
+ $checked = ($field == $cond['FIELD'])? ' selected ' : '';
+ $str.= "\n<option {$checked} value=\"".set_post($field)."\">".set_post($desc)."</option>";
+ }
+ $str .= "\n</select>";
+# $str .= " "._("if it")." ";
+ $str .= "\n<select size='1' style='width:200px;' name='cComparator_{$id}' onChange='document.mainform.submit();'>";
+ foreach($this->comparators as $comparator => $desc){
+ $checked = ($comparator == $cond['COMPARATOR'])? ' selected ' : '';
+ $str.= "\n<option {$checked} value=\"".set_post($comparator)."\">".set_post($desc)."</option>";
+ }
+ $str .= "\n</select> ";
+ if(!in_array($cond['COMPARATOR'], array('is in addressbook','is not in addressbook','is empty','is not empty'))){
+ $str .= "<input style='width:400px;' type='text' name='cMatch_{$id}' value=\"".set_post($cond['MATCH'])."\">";
+ }
+ if(count($filter['CONDITIONS']) >= 2){
+ $str .= "<button name='removeCondition_{$id}'>".msgPool::delButton()."</button> ";
+ }
+ $cnt --;
+ $str .= "</li>";
+# if($cnt) $str .= $this->types[$filter['TYPE']];
+ }
+ $str .= "</ul>";
+ $str .= "<button style='margin-left:40px;' name='addCondition'>".msgPool::addButton()."</button> ";
+
+ $str .= "<hr>";
+ $str .= "<h3>"._("Filter actions")."</h3>";
+
+ $str.= "<ul>";
+ foreach($filter['ACTION'] as $id => $action){
+ $str .= "<li>";
+ $str .= "\n<select style='width:200px;' size='1' name='cAction_{$id}' onChange='document.mainform.submit();'>";
+ foreach($this->actions as $act => $desc){
+ $checked = ($act == $action['ACTION'])? ' selected ' : '';
+ $str.= "\n<option {$checked} value=\"".set_post($act)."\">".set_post($desc)."</option>";
+ }
+ $str .= "</select> ";
+ if(!in_array($action['ACTION'], array('DROP'))){
+ $str .= "<input style='width:500px;' type='text' name='cValue_{$id}' value=\"".set_post($action['VALUE'])."\">";
+ }
+
+ if(count($filter['ACTION']) >= 2){
+ $str .= "<button name='removeAction_{$id}'>".msgPool::delButton()."</button>";
+ }
+ $str .= "</li>";
+ }
+ $str.= "</ul>";
+ $str .= "<button style='margin-left:40px;' name='addAction'>".msgPool::addButton()."</button> ";
+
+ return($str);
+ }
+
+
+ function save_object()
+ {
+ // Do nothing if the dialog wasn't submitted yet
+ if(!isset($_POST['filterEditorPosted'])) return;
+
+ // Get the filter confition type if posted
+ $this->filter['TYPE'] = (isset($_POST['cType']))? get_post('cType'): $this->filter['TYPE'];
+
+ // Get condition modifications
+ foreach($this->filter['CONDITIONS'] as $id => $value){
+ foreach(array('cField_' => 'FIELD',
+ 'cComparator_'=>'COMPARATOR',
+ 'cMatch_'=>'MATCH') as $post => $name){
+ if(isset($_POST[$post.$id])){
+ $this->filter['CONDITIONS'][$id][$name] = get_post($post.$id);
+ }
+ }
+ if(isset($_POST['removeCondition_'.$id]) && count($this->filter['CONDITIONS']) >= 2){
+ unset($this->filter['CONDITIONS'][$id]);
+ }
+ }
+
+ // Get Action modifications
+ foreach($this->filter['ACTION'] as $id => $value){
+ foreach(array('cAction_' => 'ACTIOB','cValue_' => 'VALUE') as $post => $name){
+ if(isset($_POST[$post.$id])){
+ $this->filter['ACTION'][$id][$name] = get_post($post.$id);
+ }
+ }
+ if(isset($_POST['removeAction_'.$id]) && count($this->filter['ACTION']) >= 2){
+ unset($this->filter['ACTION'][$id]);
+ }
+ }
+
+ // Get NAME and DESC if posted
+ if(isset($_POST['NAME'])) $this->filter['NAME'] = get_post('NAME');
+ if(isset($_POST['DESC'])) $this->filter['DESC'] = get_post('DESC');
+
+ // Add conditions
+ if(isset($_POST['addCondition'])){
+ $this->filter['CONDITIONS'][] = array('FIELD' => key($this->fields),'COMPARATOR' => key($this->comparators), 'MATCH' => '');
+ }
+
+ // Add actions
+ if(isset($_POST['addAction'])){
+ $this->filter['ACTION'][] = array('ACTION' => 'MOVE', 'VALUE' => '');
+ }
+ }
+}
+?>
diff --git a/gosa-plugins/groupware/personal/groupware/class_FilterManager.inc b/gosa-plugins/groupware/personal/groupware/class_FilterManager.inc
--- /dev/null
@@ -0,0 +1,153 @@
+<?php
+
+class filterManager extends plugin{
+
+ var $filterListing = NULL;
+ var $filterEditor = NULL;
+
+ function __construct($config,$parent,$rules)
+ {
+ plugin::plugin($config);
+
+ $this->parent = &$parent;
+
+ $this->filter = $rules;
+
+ // If we've read permissions then allow to edit the entries
+ $acl = $this->parent->getacl('mailFilter');
+ $acl = preg_replace("/r/","rw", $acl);
+
+ $this->filterListing= new sortableListing();
+ $this->filterListing->setDeleteable(true);
+ $this->filterListing->setEditable(true);
+ $this->filterListing->setColspecs(array('*'));
+ $this->filterListing->setWidth("100%");
+ $this->filterListing->setHeight("150px;");
+ $this->filterListing->setAcl($acl);
+ $this->filterListing->setColspecs(array('30px','200px','*'));
+ $this->filterListing->setHeader(array('-',_("Name"),_("Description")));
+ $this->filterListing->setDefaultSortColumn(1);
+ }
+
+ function execute()
+ {
+ // If we've read permissions then allow to edit the entries
+ $acl = $this->parent->getacl('mailFilter');
+ $acl = preg_replace("/r/","rw", $acl);
+ $this->filterListing->setAcl($acl);
+ // Display filter editor while a filter rule is edited
+ if($this->filterEditor instanceOf FilterEditor){
+ $this->filterEditor->save_object();
+ return($this->filterEditor->execute());
+ }
+
+
+ $smarty = get_smarty();
+ $data = $lData = array();
+ foreach($this->filter as $key => $filter){
+ $data[$key] = $filter;
+
+ switch($filter['STATUS']){
+ case 'NEW' : $img = image('images/lists/edit.png[new]');break;
+ case 'MODIFIED' : $img = image('images/lists/edit.png');break;
+ case 'EXISTS' : $img = image('images/lists/edit.png');break;
+ default : $img = "";
+ }
+
+ $lData[$key] = array('data' => array($img,$filter['NAME'], $filter['DESC']));
+ }
+ $this->filterListing->setListData($data,$lData);
+ $this->filterListing->update();
+
+
+ $smarty->assign('acl', $this->parent->getacl('mailFilter'));
+ $smarty->assign('list', $this->filterListing->render());
+
+ return($smarty->fetch(get_template_path('filterManager.tpl',TRUE,dirname(__FILE__))));
+ }
+
+ function save_object()
+ {
+ $this->filterListing->save_object();
+ $action = $this->filterListing->getAction();
+
+ // Remove filter was requested.
+ if($action['action'] == 'delete'){
+ $key = $action['targets'][0];
+ $key = $this->filterListing->getKey($key);
+ if(isset($this->filter[$key])){
+ unset($this->filter[$key]);
+ $this->filter = array_values($this->filter);
+ }
+ }
+
+ // Edit filter was requested.
+ if($action['action'] == 'edit'){
+ $key = $action['targets'][0];
+ $key = $this->filterListing->getKey($key);
+ if(isset($this->filter[$key])){
+ $filter = $this->filter[$key];
+ $this->filterEditor = new FilterEditor($this->config,$this->parent, $filter);
+ $this->currentFilter = $key;
+ }
+ }
+
+ // Add new filter
+ if(isset($_POST['addFilter'])){
+ $filter = array (
+ 'STATUS' => 'NEW',
+ 'TYPE' => 'AND',
+ 'NAME' => _('name'),
+ 'DESC' => _('description'),
+ 'CONDITIONS' => array (
+ array('FIELD' => 'from',
+ 'COMPARATOR' => 'equals',
+ 'MATCH' => 'example@domain.com'),
+ array('FIELD' => 'subject',
+ 'COMPARATOR' => 'contains',
+ 'MATCH' => _('advertising')),
+ ),
+ 'ACTION' => array (
+ array('ACTION'=>'MARK',
+ 'VALUE' => 'SPAM'),
+ array('ACTION'=>'MOVE',
+ 'VALUE' => '')
+ )
+ );
+ $this->filterEditor = new FilterEditor($this->config,$this->parent, $filter);
+ }
+
+ // Close filter editor
+ if(isset($_POST['filterEditor_cancel']) && $this->filterEditor instanceOf FilterEditor){
+ $this->currentFilter = NULL;
+ $this->filterEditor = NULL;
+ }
+
+ // Save filter modifications and close the dialog
+ if(isset($_POST['filterEditor_ok']) && $this->filterEditor instanceOf FilterEditor){
+ $this->filterEditor->save_object();
+ $msgs = $this->filterEditor->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $filter = $this->filterEditor->save();
+ if($filter['STATUS'] == 'NEW'){
+ $this->filter[] = $filter;
+ }else{
+ if($filter['STATUS'] != 'NEW') $filter['STATUS'] = 'MODIFIED';
+ $this->filter[$this->currentFilter] = $filter;
+ }
+ $this->filterEditor = NULL;
+ $this->currentFilter = NULL;
+ }
+ }
+ }
+
+
+ function save()
+ {
+ return($this->filter);
+ }
+}
+
+?>
diff --git a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc
--- /dev/null
@@ -0,0 +1,856 @@
+<?php
+/*
+ * This code is part of GOsa (https://gosa.gonicus.de)
+ * Copyright (C) 2008 Cajus Pollmeier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+class Groupware extends plugin
+{
+ var $plHeadline = "Mail";
+ var $plDescription = "GOsa mail extension.";
+ var $view_logged = FALSE;
+
+ var $accountInitialized = FALSE;
+ var $rpcError = FALSE;
+ var $rpcErrorMessage = "";
+
+ var $attributes = array(
+ "mailAddress", "mailLocation", "quotaUsage", "quotaSize", "alternateAddresses",
+ "forwardingAddresses", "vacationEnabled", "vacationStart", "vacationStop",
+ "vacationMessage", "mailBoxWarnLimitEnabled", "mailBoxWarnLimitValue",
+ "mailBoxSendSizelimitEnabled", "mailBoxSendSizelimitValue", "mailBoxHardSizelimitEnabled",
+ "mailBoxHardSizelimitValue", "mailBoxAutomaticRemovalEnabled", "mailBoxAutomaticRemovalValue",
+ "localDeliveryOnly", "dropOwnMails");
+
+
+ var $enabledFeatures = array();
+
+ var $flagAttributes = array("vacationEnabled","mailBoxWarnLimitEnabled","mailBoxSendSizelimitEnabled",
+ "mailBoxHardSizelimitEnabled","mailBoxAutomaticRemovalEnabled","localDeliveryOnly","dropOwnMails");
+
+ var $mailAddressSelectDialog = NULL;
+ var $filterManager = NULL;
+ var $filterRules = array();
+ var $vacationTemplates = array();
+
+ //the dropdown
+ var $mailLocations = array();
+
+ var $mailAddress = "";
+ var $mailLocation = "";
+ var $quotaUsage = 0;
+ var $quotaSize = 0;
+ var $alternateAddresses = array();
+ var $forwardingAddresses = array();
+ var $vacationEnabled = FALSE;
+ var $vacationStart = 0;
+ var $vacationStop = 0;
+ var $vacationMessage = "";
+ var $mailBoxWarnLimitEnabled = FALSE;
+ var $mailBoxWarnLimitValue = 100;
+ var $mailBoxSendSizelimitEnabled = FALSE;
+ var $mailBoxSendSizelimitValue = 100;
+ var $mailBoxHardSizelimitEnabled = FALSE;
+ var $mailBoxHardSizelimitValue = 100;
+ var $mailBoxAutomaticRemovalEnabled = FALSE;
+ var $mailBoxAutomaticRemovalValue = 100;
+ var $localDeliveryOnly = FALSE;
+ var $dropOwnMails = FALSE;
+
+ var $groupwareDao = null;
+
+ /*! \brief
+ */
+ function __construct ($config, $dn= NULL)
+ {
+ plugin::plugin($config,$dn);
+
+ // Get attributes from parent object
+ foreach(array("uid","cn") as $attr){
+ if(isset($this->parent->by_object['group']) && isset($this->parent->by_object['group']->$attr)){
+ $this->$attr = &$this->parent->by_object['group']->$attr;
+ }elseif(isset($this->attrs[$attr])){
+ $this->$attr = $this->attrs[$attr][0];
+ }
+ }
+ // Initialize the plugin using rpc.
+ $this->init();
+ }
+
+
+ /*! \brief Try to execute a function on the gosa backend using json-rpc.
+ * This method also takes care about errors and sets the required
+ * class members, such as rpcError and rpcErrorMessage.
+ * @param String function The name of the function to call.
+ * @param Mixed args[0-n] The parameter to use.
+ * @return Mixed The result of the function call on success else NULL.
+ */
+ function rpcExec($function)
+ {
+ $params = func_get_args();
+ unset($params[0]);
+ echo "------<br>Calling function:".$function." Params".var_dump($params)."<br>";
+
+ $rpc = $this->config->getRpcHandle();
+
+ $res = call_user_func_array(array($rpc,$function),array_values($params));
+ $this->rpcError = !$rpc->success();
+ if($this->rpcError){
+ $this->rpcErrorMessage = $rpc->get_error();
+ return(NULL);
+ }
+ return($res);
+ }
+
+
+ /*! \brief TODO: comment
+ */
+ public function isFeatureEnabled($featureName)
+ {
+ if(isset($this->enabledFeatures[$featureName]) && $this->enabledFeatures[$featureName]){
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+
+ /*! \brief Try initialize the groupware account.
+ * This method fetches all required information to manage the
+ * account using the GOsa gui.
+ */
+ function init()
+ {
+ // Detect feature availability and enable/disable services correspondingly.
+ $this->groupwareDao = new GroupwareDao($this);
+
+ $features = array();
+ //feature names with a list of groupware function that must be availabele
+ //these groupware functions are not the rpc functions, because they are asked from the groupware server
+ $featureReq = array(
+ "primaryMail" => array(
+ 'acctGetPrimaryMailAddress'),
+ "quotaUsage" => array(
+ 'acctGetQuota'),
+ "quotaSize" => array(
+ 'acctSetQuota','acctGetQuota'),
+ "mailLocations" => array(
+ 'getMailboxLocations'),
+ "mailFilter" => array("_off",
+ 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'),
+ "alternateAddresses" => array(
+ 'acctDelAlternateMailAddress','acctSetAlternateMailAddresses',
+ 'acctAddAlternateMailAddress','acctGetAlternateMailAddresses'),
+ "forwardingAddresses" => array(
+ 'acctAddMailForwardAddress','acctDelMailForwardAddress',
+ 'acctGetMailForwardAddresses','acctSetMailForwardAddresses'),
+ "vacationMessage" => array("_off",
+ 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'),
+ "mailBoxWarnLimit" => array(
+ 'acctSetQuota','acctGetQuota'),
+ "mailBoxSendSizelimit" => array(
+ 'acctSetQuota','acctGetQuota'),
+ "mailBoxHardSizelimit" => array(
+ 'acctSetQuota','acctGetQuota'),
+ "mailBoxAutomaticRemoval" => array("_off",
+ 'acctSetQuota','acctGetQuota'),
+ "localDeliveryOnly" => array( "_off",
+ 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'),
+ "dropOwnMails" => array( "_off",
+ 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'));
+
+ // Check if all required methods cann be called!
+ foreach($featureReq as $name => $requires){
+ $active = TRUE;
+ foreach($requires as $methodName){
+ $active &= $this->groupwareDao->gwFeatureAvailable($methodName);
+ }
+ $this->enabledFeatures[$name] = $active;
+ }
+ // Get rpc handle to fetch account info and feature availability.
+ $status = $this->rpcExec('gwAcctExists', $this->uid);
+ if($status !== NULL){
+ $response = $this->groupwareDao->getComprehensiverUser($this->uid);
+
+ $this->mapComprehensiveUserData($response);
+ $this->initially_was_account = $this->is_account = $status;
+
+ $this->accountInitialized = TRUE;
+ }
+ // Set vacation start/stop if not set alreasy
+ $this->vacationStart = time();
+ $this->vacationStop = time() + (14 * 60*60*24);
+
+ // Prepare vacation start/stop time to be initially valid.
+ $this->vacationStart= date('d.m.Y', $this->vacationStart);
+ $this->vacationStop= date('d.m.Y', $this->vacationStop);
+ }
+
+
+ /*! \brief Generates the HTML user interface for the groupware plugin
+ * and take of several ui actions like adding or removing
+ * forward addresses, filters and the account itself.
+ */
+ function execute()
+ {
+ // Register plugin execution
+ $display = plugin::execute();
+
+ // Log plugin execution.
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","users/".get_class($this),$this->dn);
+ }
+
+ // Check if we were able to initialize the account already.
+ if(!$this->accountInitialized){
+ $this->init();
+ if(!$this->accountInitialized){
+ $smarty = get_smarty();
+ $smarty->assign("initFailed", !$this->accountInitialized);
+ return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+ }
+ }
+
+ // Check if we were able to initialize the account already.
+ if($this->rpcError){
+ $smarty = get_smarty();
+ $smarty->assign("initFailed", !$this->accountInitialized);
+ $smarty->assign("rpcError", $this->rpcError);
+ return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+ }
+
+ /****************
+ Filter editor
+ ****************/
+
+ if(isset($_POST['filterManager_cancel'])) $this->filterManager = NULL;
+ if(isset($_POST['filterManager_ok'])){
+ $this->filterManager->save_object();
+ $msgs = $this->filterManager->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $this->filterRules = $this->filterManager->save();
+ $this->filterManager = NULL;
+ }
+ }
+ if(isset($_POST['configureFilter'])){
+ $this->filterManager = new FilterManager($this->config, $this,$this->filterRules);
+ $this->filterManager->acl_base = $this->acl_base;
+ $this->filterManager->acl_category = $this->acl_category;
+ }
+ $this->dialog = FALSE;
+ if($this->filterManager instanceOf FilterManager){
+ $this->filterManager->save_object();
+ $this->dialog = TRUE;
+ return($this->filterManager->execute());
+ }
+
+ /****************
+ Account status
+ ****************/
+
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+ if(!$this->multiple_support_active){
+ if (!$this->is_account && $this->parent === NULL){
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
+ msgPool::noValidExtension(_("Mail"))."</b>";
+ $display.= back_to_main();
+ return ($display);
+ }
+ if ($this->parent !== NULL){
+ if ($this->is_account){
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
+ } else {
+ $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
+ return ($display);
+ }
+ }
+ }
+
+ /****************
+ Forward addresses
+ ****************/
+
+ // Display dialog to select a local fowarder
+ if (isset($_POST['addLocalForwardingAddress'])){
+ $this->mailAddressSelectDialog= new mailAddressSelect($this->config, get_userinfo());
+ $this->dialog= TRUE;
+ }
+
+ // Close dialogs, action was canceled
+ if (isset($_POST['mailAddressSelect_cancel'])){
+ $this->mailAddressSelectDialog= FALSE;
+ $this->dialog= FALSE;
+ }
+
+ // Append selected forwarding addresses now.
+ if (isset($_POST['mailAddressSelect_save']) && $this->mailAddressSelectDialog instanceOf mailAddressSelect){
+ if($this->acl_is_writeable("forwardingAddresses")){
+ $list = $this->mailAddressSelectDialog->save();
+ foreach ($list as $entry){
+ $val = $entry['mail'][0];
+ if (!in_array ($val, $this->alternateAddresses) && $val != $this->mailAddress){
+ $this->addForwarder($val);
+ $this->is_modified= TRUE;
+ }
+ }
+ $this->mailAddressSelectDialog= FALSE;
+ $this->dialog= FALSE;
+ } else {
+ msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
+ }
+ }
+
+ // Display the address selection dialog.
+ if($this->mailAddressSelectDialog instanceOf mailAddressSelect){
+ $used = array();
+ $used['mail'] = array_values($this->alternateAddresses);
+ $used['mail'] = array_merge($used['mail'], array_values($this->forwardingAddresses));
+ $used['mail'][] = $this->mailAddress;
+
+ // Build up blocklist
+ session::set('filterBlacklist', $used);
+ return($this->mailAddressSelectDialog->execute());
+ }
+
+ // Add manually inserted forwarding address.
+ if (isset($_POST['addForwardingAddress'])){
+ if ($_POST['forwardingAddressInput'] != ""){
+ $address= get_post('forwardingAddressInput');
+ $valid= FALSE;
+ if (!tests::is_email($address)){
+ if (!tests::is_email($address, TRUE)){
+ if ($this->is_template){
+ $valid= TRUE;
+ } else {
+ msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
+ "","","your-address@your-domain.com"),ERROR_DIALOG);
+ }
+ }
+ } elseif ($address == $this->mailAddress || in_array($address, $this->alternateAddresses)) {
+ msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
+ } else {
+ $valid= TRUE;
+ }
+ if ($valid){
+ if($this->acl_is_writeable("forwardingAddresses")){
+ $this->addForwarder ($address);
+ $this->is_modified= TRUE;
+ }
+ }
+ }
+ }
+ if (isset($_POST['deleteForwardingAddress'])){
+ $this->delForwarder ($_POST['forwardingAddressList']);
+ }
+
+ /****************
+ Alternate addresses
+ ****************/
+ // Add manually inserted alternate mail address.
+ if (isset($_POST['addAlternateAddress'])){
+ $valid= FALSE;
+ if (!tests::is_email($_POST['alternateAddressInput'])){
+ if ($this->is_template){
+ if (!(tests::is_email($_POST['alternateAddressInput'], TRUE))){
+ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),
+ "","","your-domain@your-domain.com"),ERROR_DIALOG);
+ } else {
+ $valid= TRUE;
+ }
+ } else {
+ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),
+ "","","your-domain@your-domain.com"),ERROR_DIALOG);
+ }
+ } else {
+ $valid= TRUE;
+ }
+ if ($valid && ($user= $this->addAlternate (get_post('alternateAddressInput'))) != ""){
+ $ui= get_userinfo();
+ $addon= "";
+ if ($user[0] == "!") {
+ $addon= sprintf(_("Address is already in use by group '%s'."), mb_substr($user, 1));
+ } else {
+ $addon= sprintf(_("Address is already in use by user '%s'."), $user);
+ }
+ msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))."<br><br><i>".
+ "$addon</i>", ERROR_DIALOG);
+ }
+ }
+
+ // Remove alternate mail address.
+ if (isset($_POST['deleteAlternateAddress']) && isset($_POST['alternateAddressList'])){
+ $this->delAlternate ($_POST['alternateAddressList']);
+ }
+
+
+ /****************
+ SMARTY- Assign smarty variables
+ ****************/
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+
+ $smarty->assign($attr, $this->$attr);
+ }
+
+ $plInfo = $this->plInfo();
+ foreach($plInfo['plProvidedAcls'] as $acl => $name){
+ $smarty->assign($acl."ACL", $this->getacl($acl));
+ }
+ foreach($this->enabledFeatures as $feature => $state){
+ $smarty->assign($feature."_isActive", $state);
+ }
+
+ $smarty->assign("mailLocations", $this->mailLocations);
+ if (count($this->vacationTemplates)){
+ $smarty->assign("displayTemplateSelector", "true");
+ $smarty->assign("vacationTemplate", set_post($this->vacationTemplate));
+ $smarty->assign("vacationTemplates", set_post($this->vacationTemplates));
+ $smarty->assign("template", set_post(get_post('vacation_template')));
+ } else {
+ $smarty->assign("displayTemplateSelector", "false");
+ }
+
+ $smarty->assign("initFailed", !$this->accountInitialized);
+ $smarty->assign("rpcError", $this->rpcError);
+ $smarty->assign("rpcErrorMessage", $this->rpcErrorMessage);
+
+ return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /*! \brief This method handles potential _POST and _GET values.
+ * It captures modifcations from the ui, like changing
+ * the mailAddress.
+ * This method respects the attribute permissions.
+ */
+ function save_object()
+ {
+ if(isset($_POST['groupwarePluginPosted'])){
+
+ // We ran into a communication error with the backend.
+ // Try a simple communication operation with the backend
+ // again and let us see if it works.
+ if(isset($_POST['retry'])){
+ $this->rpcExec('gwGetCapabilities');
+ }
+
+ // Get ui modifications and store them in the class.
+ $testAttrs = array("mailAddress","mailLocation","quotaUsage","quotaSize",
+ "alternateAddresses","forwardingAddresses","vacationEnabled","vacationStart",
+ "vacationStop","vacationMessage");
+ foreach($testAttrs as $attr){
+ if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
+ $this->$attr = get_post($attr);
+ }
+ }
+
+ // Detect checkbox states
+ $checkAttrs = array("mailBoxWarnLimit","mailBoxSendSizelimit",
+ "mailBoxHardSizelimit","mailBoxAutomaticRemoval");
+ foreach($checkAttrs as $boxname){
+ if($this->acl_is_writeable($boxname)){
+ $v = $boxname."Value";
+ $e = $boxname."Enabled";
+ $this->$e = isset($_POST[$e]);
+ if($this->$e){
+ $this->$v = get_post($v);
+ }
+ }
+ }
+
+ // Get posted flag changes
+ $flagAttrs = array("localDeliveryOnly","dropOwnMails");
+ foreach($flagAttrs as $attr){
+ $this->$attr = isset($_POST[$attr]);
+ }
+ }
+ }
+
+
+ /*! \brief Parse vacation templates and build up an array
+ * containing 'filename' => 'description'.
+ * Used to fill vacation dropdown box.
+ * @return Array All useable vacation templates.
+ */
+ function get_vacation_templates()
+ {
+ $vct = array();
+ if ($this->config->get_cfg_value("core","vacationTemplateDirectory") != ""){
+ $dir= $this->config->get_cfg_value("core","vacationTemplateDirectory");
+ if (is_dir($dir) && is_readable($dir)){
+ $dh = opendir($dir);
+ while($file = readdir($dh)){
+ $description= "";
+ if (is_file($dir."/".$file)){
+ $fh = fopen($dir."/".$file, "r");
+ $line= fgets($fh, 256);
+ if (!preg_match('/^DESC:/', $line)){
+ msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG);
+ }else{
+ $description= trim(preg_replace('/^DESC:\s*/', '', $line));
+ }
+ fclose ($fh);
+ }
+ if ($description != ""){
+ $vct["$dir/$file"]= $description;
+ }
+ }
+ closedir($dh);
+ }
+ }
+ return($vct);
+ }
+
+
+ /*! \brief Adds the given mail address to the list of mail forwarders
+ */
+ function addForwarder($address)
+ {
+ if(empty($address)) return;
+ if($this->acl_is_writeable("forwardingAddresses")){
+ $this->forwardingAddresses[]= $address;
+ $this->forwardingAddresses= array_unique ($this->forwardingAddresses);
+ sort ($this->forwardingAddresses);
+ reset ($this->forwardingAddresses);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
+ }
+ }
+
+
+ /*! \brief Removes the given mail address from the list of mail forwarders
+ */
+ function delForwarder($addresses)
+ {
+ if($this->acl_is_writeable("forwardingAddresses")){
+ $this->forwardingAddresses= array_remove_entries ($addresses, $this->forwardingAddresses);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
+ }
+ }
+
+
+ /*! \brief Add given mail address to the list of alternate adresses ,
+ * check if this mal address is used, skip adding in this case
+ */
+ function addAlternate($address)
+ {
+ if(empty($address)) return;
+ if($this->acl_is_writeable("alternateAddresses")){
+ $ldap= $this->config->get_ldap_link();
+ $address= strtolower($address);
+
+ /* Is this address already assigned in LDAP? */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
+ "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid", "cn"));
+ if ($ldap->count() > 0){
+ $attrs= $ldap->fetch ();
+ if (!isset($attrs["uid"])) {
+ return ("!".$attrs["cn"][0]);
+ }
+ return ($attrs["uid"][0]);
+ }
+ if (!in_array($address, $this->alternateAddresses)){
+ $this->alternateAddresses[]= $address;
+ $this->is_modified= TRUE;
+ }
+ sort ($this->alternateAddresses);
+ reset ($this->alternateAddresses);
+ return ("");
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
+ }
+ }
+
+
+ /*! \brief Removes the given mail address from the alternate addresses list
+ */
+ function delAlternate($addresses)
+ {
+ if($this->acl_is_writeable("alternateAddresses")){
+ $this->alternateAddresses= array_remove_entries ($addresses,$this->alternateAddresses);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
+ }
+ }
+
+
+ /*! \brief Prepare importet vacation string. \
+ * Replace placeholder like %givenName a.s.o.
+ * @param string Vacation string
+ * @return string Completed vacation string
+ */
+ private function prepare_vacation_template($contents)
+ {
+ /* Replace attributes */
+ $attrs = array();
+ $obj = NULL;
+ if(isset($this->parent->by_object['user'])){
+ $attrs = $this->parent->by_object['user']->attributes;
+ $obj = $this->parent->by_object['user'];
+ }else{
+ $obj = new user($this->config,$this->dn);
+ $attrs = $obj->attributes;
+ }
+ if($obj){
+
+ /* Replace vacation start and end time */
+ if($this->enabledFeatures['vacationMessage']){
+ if(preg_match("/%start/",$contents)){
+ $contents = preg_replace("/%start/",$this->vacationStart,$contents);
+ }
+ if(preg_match("/%end/",$contents)){
+ $contents = preg_replace("/%end/",$this->vacationStop,$contents);
+ }
+ }else{
+ if(preg_match("/%start/",$contents)){
+ $contents = preg_replace("/%start/", _("unknown"),$contents);
+ }
+ if(preg_match("/%end/",$contents)){
+ $contents = preg_replace("/%end/", _("unknown"), $contents);
+ }
+ }
+
+ foreach ($attrs as $val){
+
+ // We can only replace strings here
+ if(!is_string($obj->$val)) continue;
+
+ if(preg_match("/dateOfBirth/",$val)){
+ if($obj->use_dob){
+ $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
+ }
+ }else {
+ $contents= preg_replace("/%$val/",
+ $obj->$val, $contents);
+ }
+
+ }
+ }
+ $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n ");
+ return($contents);
+ }
+
+
+ /*! \brief Remove the account form the groupware server completely.
+ */
+ function remove_from_parent()
+ {
+ // Get rpc handle to remove the account
+ if($this->initially_was_account){
+ if($this->rpcExec('gwAcctDel', $this->uid) === NULL){
+ msg_dialog::display(_("Error"), _("Groupware account removal failed!"), ERROR_DIALOG);
+ }
+ }
+ }
+
+
+ /* \brief Persists the values of this plugin to the groupware server.
+ * Save method is called on "apply" and "ok" in the Gosa Frontend.
+ * All other actions will update values in the form or
+ * cancel and therefore discard the changes so far.
+ */
+ function save()
+ {
+ // Get rpc handle to create or update the account
+ if(!$this->initially_was_account){
+ if($this->rpcExec('gwAcctAdd', $this->uid, $this->mailAddress) === NULL){
+ msg_dialog::display(_("Error"), _("Groupware account creation failed!"), ERROR_DIALOG);
+ }
+ }
+
+ // Save the primary Email Address.
+ if(!empty($this->mailAddress)){
+ $this->groupwareDao->save("primaryMail", $this->uid, $this->mailAddress);
+ }\r
+
+ // Save alternateAddresses and forwarding.
+\r
+\r
+ if(!empty($this->forwardingAddresses)
+ && isset($this->alternateAddresses)
+ && is_array($this->alternateAddresses)){
+ $this->groupwareDao->save("alternateAddresses", $this->uid, array($this->alternateAddresses));
+\r
+ }\r
+ if(!empty($this->forwardingAddresses)
+ && isset($this->forwardingAddresses)
+ && is_array($this->forwardingAddresses)){
+ $this->groupwareDao->save("forwardingAddresses", $this->uid, array($this->forwardingAddresses));
+\r
+ }
+ // Save the quota
+ if(true){
+\r
+ $quota = array( "warn_limit" => $this->mailBoxWarnLimitValue,
+ "send_limit" => $this->mailBoxSendSizelimitValue,
+ "hard_limit" => $this->mailBoxHardSizelimitValue,
+ "hold" => $this->quotaSize,
+ "usage" => $this->quotaUsage);
+ $this->groupwareDao->save("quotaSize", $this->uid, $quota);
+ }
+
+ // TODO: save Mailbox location
+\r
+ }
+
+
+ /*! \brief Check given values
+ */
+ function check()
+ {
+ // TODO: Remove all echo Messages
+ $messages = plugin::check();
+
+ //Check the dates
+
+ // TODO: check only if features are enabled.
+
+ //required vacationEnabled
+ if($this->vacationEnabled){
+ if(!tests::is_date($this->vacationStart)){
+ $messages[] = msgPool::invalid(_("Vacation start date"),$this->vacationStart , "", "01.03.2010");
+ }
+ if(!tests::is_date($this->vacationStop)){
+ $messages[] = msgPool::invalid(_("Vacation stop date"),$this->vacationStop , "", "01.03.2010");
+ }
+ $diff = tests::compareDate($this->vacationStart, $this->vacationStop);
+
+ if($diff>=0){
+ $messages[] = msgPool::invalid(_("Vacation dates"));
+ }
+ }
+ if(!tests::is_email ($this->mailAddress)){
+ $messages[] = msgPool::invalid(_("Mail address"),$this->mailAddress , "", "user@excom.intranet.gonicus.de");
+ }
+
+ if(isset($this->forwardingAddresses) && is_array($this->forwardingAddresses)){
+ foreach($this->forwardingAddresses as $fAddress){
+ if(!tests::is_email ($fAddress)){
+ $messages[] = msgPool::invalid(_("Alternate address"),$fAddress, "",
+ "user@excom.intranet.gonicus.de");
+ }
+ if($fAddress == $this->mailAddress){
+ $messages[] = _("The primary address cannot be used as alternative address!");
+ }
+ }
+ }
+ if(isset($this->alternateAddresses) && is_array($this->alternateAddresses)){
+ foreach($this->alternateAddresses as $fAddress){
+ if(!tests::is_email ($fAddress)){
+ $messages[] = msgPool::invalid(_("Forward address"),$fAddress, "", "user@excom.intranet.gonicus.de");
+ }
+ if($fAddress == $this->mailAddress){
+ $messages[] = _("The primary address cannot be used as forward address!");
+ }
+ }
+ }
+
+ // TODO: Checks for quota and Locations?
+ return($messages);
+ }
+
+
+ /*! \brief ACL settings
+ */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Groupware"),
+ "plDescription" => _("Groupware settings"),
+ "plSelfModify" => TRUE,
+ "plDepends" => array("user"), // This plugin depends on
+ "plPriority" => 4, // Position in tabs
+ "plSection" => array("personal" => _("My account")),
+ "plCategory" => array("users"),
+ "plOptions" => array(),
+ "plProvidedAcls" => array(
+ "mailAddress" => _("Mail address"),
+ "mailLocation" => _("Mail location"),
+ "quotaUsage" => _("Quota usage"),
+ "mailFilter" => _("Mail filter"),
+ "quotaSize" => _("Quota size"),
+ "alternateAddresses" => _("Alternate mail addresses"),
+ "forwardingAddresses" => _("Forwarding mail addresses"),
+ "vacationEnabled" => _("Vaction switch"),
+ "vacationStart" => _("Vacation start time"),
+ "vacationStop" => _("Vacation stop time"),
+ "vacationMessage" => _("Vacation message"),
+ "mailBoxWarnLimit" => _("Warn sizelimit"),
+ "mailBoxSendSizelimit" => _("Send sizelimit"),
+ "mailBoxHardSizelimit" => _("Hard sizelimit"),
+ "mailBoxAutomaticRemoval" => _("Automatic mail removal"),
+ "localDeliveryOnly" => _("Local delivery only"),
+ "dropOwnMails" => _("Drop own mails")
+ )
+ ));
+ }
+
+
+ /*! \brief Maps the resultset fetched from the Dao to the class variables
+ * of the plugin.
+ */
+ function mapComprehensiveUserData($callBackMap)
+ {
+ $map = array(
+ "mailLocations" => "mailLocations",
+ "mailAddress" => "primaryMail",
+ "mailLocation" => "mailLocation",
+ "quotaUsage" => "quotaUsage",
+ "quotaSize" => "quotaSize",
+ "alternateAddresses" => "alternateAddresses",
+ "forwardingAddresses" => "forwardingAddresses",
+ "vacationEnabled" => "vacationEnabled",
+ "vacationStart" => "vacationStart",
+ "vacationStop" => "vacationStop",
+ "vacationMessage" => "vacationMessage",
+ "mailBoxWarnLimitEnabled" => "mailBoxWarnLimitEnabled",
+ "mailBoxWarnLimitValue" => "mailBoxWarnLimitValue",
+ "mailBoxSendSizelimitEnabled" => "mailBoxSendSizelimitEnabled",
+ "mailBoxSendSizelimitValue" => "mailBoxSendSizelimitValue",
+ "mailBoxHardSizelimitEnabled" => "mailBoxHardSizelimitEnabled",
+ "mailBoxHardSizelimitValue" => "mailBoxHardSizelimitValue",
+ "mailBoxAutomaticRemovalEnabled" => "mailBoxAutomaticRemovalEnabled",
+ "mailBoxAutomaticRemovalValue" => "mailBoxAutomaticRemovalValue",
+ "localDeliveryOnly" => "localDeliveryOnly",
+ "dropOwnMails" => "dropOwnMails");
+
+ // Map values from source array to class members
+ foreach($map as $target => $source){
+ if(isset($callBackMap[$source])){
+ $this->$target = $callBackMap[$source];
+ }
+ }
+ }
+}
+
+
+?>
diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc
--- /dev/null
@@ -0,0 +1,262 @@
+<?php\r
+ \r
+/*! \brief Data Access Object for groupwares \r
+ */\r
+class GroupwareDao{\r
+\r
+ /* TODO: Remove the debug \r
+ * use the debug functions fo the Gosa installation instead.\r
+ * function_debug\r
+ * (got ot remove the following variable, the function debug and all calls to it)\r
+ */\r
+ private $debug = true;\r
+\r
+ private $availableMethods;\r
+ private $availableProperties;\r
+ private $accountLocations;\r
+\r
+ private $groupwarePluginRef = False;\r
+\r
+ private static $gwFeatures = array(\r
+ "primaryMail" => array( "get"=>"gwAcctGetPrimaryMailAddress", \r
+ "save"=>"gwAcctSetPrimaryMailAddress"),\r
+ "mailLocations" => array("get"=>"gwGetMailboxLocations"),\r
+ "quotaSize" =>array( "get"=>"gwAcctGetQuota", \r
+ "save"=>"gwAcctSetQuota",\r
+ "delete"=>"gwAcctSetQuota"),\r
+ "mailFilter" =>array( "get"=>"gwAcctGetFilters", \r
+ "save"=>"gwAcctSetFilters",\r
+ "delete"=>"gwAcctDelFilter"),\r
+ "alternateAddresses" =>array( "get"=>"gwAcctGetAlternateMailAddresses", \r
+ "save"=>"gwAcctSetAlternateMailAddresses",\r
+ "delete"=>"gwAcctDelAlternateMailAddress"),\r
+ "forwardingAddresses" =>array( "get"=>"gwAcctGetMailForwardAddresses", \r
+ "save"=>"gwAcctSetMailForwardAddresses",\r
+ "delete"=>"gwAcctDelMailForwardAddress"),\r
+ "vacationMessage" =>array( "get"=>"gwAcctGetOutOfOfficeReply", \r
+ "save"=>"gwAcctSetOutOfOfficeReply",\r
+ "delete"=>"gwAcctDelOutOfOfficeReply"),\r
+ "mailBoxWarnLimit" =>array( "get"=>"", \r
+ "save"=>"",\r
+ "delete"=>""),\r
+ "mailBoxSendSizelimit" =>array( "get"=>"gwAcctGetQuota", \r
+ "save"=>"gwAcctSetQuota",\r
+ "delete"=>"gwAcctDelQuota"),\r
+ "mailBoxHardSizelimit" =>array( "get"=>"gwAcctGetMailLimit", \r
+ "save"=>"gwAcctSetMailLimit",\r
+ "delete"=>"gwAcctDelMailLimit"),\r
+ "mailBoxAutomaticRemoval" =>array( "get"=>"", \r
+ "save"=>"",\r
+ "delete"=>""),\r
+ "localDeliveryOnly" =>array( "get"=>"", \r
+ "save"=>"",\r
+ "delete"=>""),\r
+ "dropOwnMails" =>array( "get"=>"",\r
+ "save"=>"",\r
+ "delete"=>""),\r
+ "accountProperties" => array("get"=>"gwAcctGetProperties",\r
+ "save"=>"gwAcctSetProperties",\r
+ "delete"=>"gwAcctDelProperties")\r
+\r
+ );\r
+\r
+\r
+ /*! \brief Constructor sets the connection to the rpc service \r
+ * initializes the class\r
+ */\r
+ function __construct(&$pluginRef)\r
+ {\r
+ $this->groupwarePluginRef = &$pluginRef;\r
+ \r
+ // TODO: Remove all echos \r
+\r
+ $this->init();\r
+ }\r
+\r
+\r
+ /*! \brief Gets the capabilities of the server\r
+ * builds an array with availbale features and knows how to call get, save, delete functions of \r
+ * groupware rpc. \r
+ */\r
+ public function init()\r
+ {\r
+ $this->availableMethods = $this->groupwarePluginRef->rpcExec('gwGetCapabilities');\r
+ //$this->availableProperties = $this->groupwarePluginRef->rpcExec('gwGetSupportedProperties');\r
+ //$this->debug("availableProperties on init:", $this->availableProperties);\r
+ }\r
+\r
+\r
+ /*! \brief Generic saving method for all features defined in $gwFeatures\r
+ * which are the available features.\r
+ */\r
+ public function save($feature, $uid, $valueArray)\r
+ {\r
+ $function = GroupwareDao::$gwFeatures[$feature]["save"];\r
+ if(is_array($valueArray)){\r
+ $valueArray = array_merge(array($function, $uid), $valueArray);\r
+ }else{\r
+ $valueArray = array($function, $uid, $valueArray);\r
+ }\r
+ $this->debug("SAVING (feature, value)", $valueArray);\r
+ $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
+ return $result;\r
+ }\r
+\r
+\r
+ /*! \brief generic get method for all features defined in $gwFeatures\r
+ * which are the available features.\r
+ */\r
+ public function get($feature, $valueArray)\r
+ {\r
+ // TODO: Check if feture available ? get and return the result.\r
+ $function = GroupwareDao::$gwFeatures[$feature]["get"];\r
+ if(is_array($valueArray)){\r
+ $valueArray = array_merge(array($function), $valueArray);\r
+ }else{\r
+ $valueArray = array($function, $valueArray);\r
+ }\r
+\r
+ $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
+ return $result;\r
+ }\r
+\r
+\r
+ /*! \brief generic delete function for all features defined in $gwFeatures\r
+ * which are the available features.\r
+ * \r
+ * NOT YET IMPLEMENTED\r
+ */\r
+ public function del($feature, $valueArray)\r
+ {\r
+ // TODO: check if feture available del and return the result.\r
+ \r
+ echo "deletion of values is not implemented yet";\r
+ /*\r
+ $function = GroupwareDao::$gwFeatures[$feature]["delete"];\r
+ $valueArray = array_merge(array($function), $valueArray);\r
+ $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
+ return $result;\r
+ */\r
+ }\r
+\r
+\r
+ /*! \brief determine availability of features.\r
+ * \r
+ * @param methodName\r
+ * @return boolean\r
+ */\r
+ public function gwFeatureAvailable($methodName)\r
+ {\r
+ return(isset($this->availableMethods[$methodName]) && ($this->availableMethods[$methodName]));\r
+ }\r
+\r
+\r
+ /*! \brief comprehensive user info will dessolve into one groupware call later\r
+ * right now it will get all data of the features that are available in the plugin.\r
+ * @param int $uid\r
+ * @return assoc array "feature" => "gwValue"; \r
+ */\r
+ public function getComprehensiverUser( $uid)\r
+ {\r
+ //$hi = $this->groupwarePluginRef->rpcExec('gwGetCapabilities');\r
+ $resultArr = array();\r
+\r
+ if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){\r
+ $resultArr["primaryMail"] = $this->get("primaryMail", array($uid));\r
+ }\r
+\r
+ if($this->groupwarePluginRef->isFeatureEnabled("alternateAddresses")){\r
+ $resultArr["alternateAddresses"] = $this->get("alternateAddresses", array($uid));\r
+ }\r
+\r
+ if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){\r
+ $resultArr["forwardingAddresses"] = $this->get("forwardingAddresses", array($uid));\r
+ }\r
+\r
+ if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){\r
+ $resultArr["forwardingAddresses"] = $this->get("forwardingAddresses", array($uid));\r
+ }\r
+\r
+ // Location dropdownlist - only readable\r
+ if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){\r
+ $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations');\r
+ $resultArr["mailLocation"] = $this->groupwarePluginRef->rpcExec('gwAcctGetLocation',$uid);\r
+ }\r
+\r
+ \r
+ //TODO: getLocation muss ebenfalls geholt werden \r
+\r
+ // Quota quotaUsage, quotaSize\r
+ if($this->groupwarePluginRef->isFeatureEnabled("quotaSize") || \r
+ $this->groupwarePluginRef->isFeatureEnabled("quotaUsage") || \r
+ $this->groupwarePluginRef->isFeatureEnabled("mailBoxWarnLimit") || \r
+ $this->groupwarePluginRef->isFeatureEnabled("mailBoxSendSizelimit") || \r
+ $this->groupwarePluginRef->isFeatureEnabled("mailBoxHardSizelimit")){\r
+\r
+ // Usage is a Mapi function which is not yet \r
+ \r
+ // TODO: Remove the following dummy and enable the qota fetch from groupware\r
+ \r
+ echo "Quota function not yet implemented on server side!!";\r
+ //$quota = $this->get("quotaSize", array($uid));\r
+ $quota = array( "warn_limit" => 1008,\r
+ "send_limit" => 108,\r
+ "hard_limit" => 1108,\r
+ "hold" => 508,\r
+ "usage" => 1108);\r
+ $resultArr["quotaSize"] = $quota["usage"];\r
+ $resultArr["quotaSize"] = $quota["hold"];\r
+ if($quota["warn_limit"] > 0){\r
+ $resultArr["mailBoxWarnLimitEnabled"] = true;\r
+ $resultArr["mailBoxWarnLimitValue"] = $quota["warn_limit"];\r
+ }else{\r
+ $resultArr["mailBoxWarnLimitEnabled"] = false;\r
+ $resultArr["mailBoxWarnLimitValue"] = 0;\r
+ }\r
+ if($quota["send_limit"] > 0){\r
+ $resultArr["mailBoxSendSizelimitEnabled"] = True;\r
+ $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"];\r
+ }else{\r
+ $resultArr["mailBoxSendSizelimitEnabled"] = FALSE;\r
+ $resultArr["mailBoxSendSizelimitValue"] = 0; \r
+ }\r
+ if($quota["hard_limit"] > 0){\r
+ $resultArr["mailBoxHardSizelimitEnabled"] = True;\r
+ $resultArr["mailBoxHardSizelimitValue"] = $quota["hard_limit"]; \r
+ }else{\r
+ $resultArr["mailBoxHardSizelimitEnabled"] = FALSE;\r
+ $resultArr["mailBoxHardSizelimitValue"] = 0;\r
+ }\r
+ }\r
+\r
+ //this function seems to be broken on the server.\r
+ //addding dummy\r
+\r
+ if($this->groupwarePluginRef->isFeatureEnabled("vacationMessage")){\r
+\r
+ $vacMessage = $this->get("vacationMessage", array($uid));\r
+ //$resultArr["vacationMessage"] = "dummy Vacation message - (getOutOfOfficeReply currently throws errors )";\r
+ }\r
+\r
+ $this->debug("getComprehensiverUser:", $resultArr);\r
+ return $resultArr;\r
+ }\r
+\r
+\r
+ /*! \brief TODO: remove all debug functions. Remove them also in the class_Groupware.inc\r
+ */\r
+ public function debug($name, $message)\r
+ {\r
+ if($this->debug){\r
+ echo"<b>".$name."</b>";\r
+ if(is_array($message)){\r
+ echo "<pre>";\r
+ print_r($message);\r
+ echo "</pre>";\r
+ }else{\r
+ echo "$message";\r
+ }\r
+ }\r
+ }\r
+} \r
+?>
\ No newline at end of file
diff --git a/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc b/gosa-plugins/groupware/personal/groupware/class_filterEditor.inc
+++ /dev/null
@@ -1,197 +0,0 @@
-<?php
-
-class filterEditor extends plugin
-{
- function __construct($config, $parent, $filter)
- {
- $this->config = &$config;
- $this->parent = &$parent;
- $this->filter = $filter;
-
- $this->types = array(
- 'OR' => _("At least one of the following conditions has to match"),
- 'AND' => _("All conditions have to match"));
-
- $this->actions = array(
- "MOVE" => _("move mail to"),
- "COPY" => _("copy mail to"),
- "FORWARD" => _("forward message to"),
- "MARK" => _("mark mail as "),
- "DROP" => _("remove mail"),
- "REPLY" => _("reply"));
-
- $this->fields = array(
- 'subject' => _("Subject"),
- 'from'=> _("From"),
- 'body'=> _("Body"),
- 'date'=> _("Date"),
- 'priority'=> _("Priority"),
- 'status'=> _("Status"),
- 'to'=> _("To"),
- 'cc'=> _("CC"),
- 'age'=> _("Age"),
- 'size'=> _("Size"));
-
- $this->comparators = array(
- "is" => _("is"),
- "is not" => _("is not"),
- "equal" => _("is equal"),
- "not equal" => _("is not equal"),
- "is empty" => _("is empty"),
- "is not empty" => _("is not empty"),
- "contains" => _("contains"),
- "contains not" => _("does not contain"),
- "is in addressbook" => _("is in the addressbook"),
- "is not in addressbook" => _("is not in the addressbook"),
- "greater than" => _("is greater than"),
- "less than" => _("smaller than"));
- }
-
- function execute()
- {
- $smarty = get_smarty();
- $smarty->assign('NAME',set_post($this->filter['NAME']));
- $smarty->assign('DESC',set_post($this->filter['DESC']));
- $smarty->assign('filterStr', $this->renderFilter());
- $smarty->assign('acl', $this->parent->getacl('mailFilter'));
-
- return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__))));
- }
-
-
-
- function check()
- {
- $msgs = array();
- return($msgs);
- }
-
-
- function save()
- {
- // Just return the filter array we've modified
- return($this->filter);
- }
-
-
- function renderFilter()
- {
- $filter = $this->filter;
-
- $cnt = count($filter['CONDITIONS']);
- $str = "<h3>"._("Filter conditions")."</h3>";
- $str .= _("Condition type")." ";
- $str .="\n<select size='1' name='cType' onChange='document.mainform.submit();'>";
- foreach($this->types as $type => $desc){
- $checked = ($type == $filter['TYPE'])? ' selected ' : '';
- $str.= "\n<option {$checked} value=\"".set_post($type)."\">".set_post($desc)."</option>";
- }
- $str .= "\n</select>";
- $str.= "<ul>";
- foreach($filter['CONDITIONS'] as $id => $cond){
- $str .= "<li>";
-# $str .= _("Check field")." ";
- $str .= "\n<select size='1' style='width:100px;' name='cField_{$id}' onChange='document.mainform.submit();'>";
- foreach($this->fields as $field => $desc){
- $checked = ($field == $cond['FIELD'])? ' selected ' : '';
- $str.= "\n<option {$checked} value=\"".set_post($field)."\">".set_post($desc)."</option>";
- }
- $str .= "\n</select>";
-# $str .= " "._("if it")." ";
- $str .= "\n<select size='1' style='width:200px;' name='cComparator_{$id}' onChange='document.mainform.submit();'>";
- foreach($this->comparators as $comparator => $desc){
- $checked = ($comparator == $cond['COMPARATOR'])? ' selected ' : '';
- $str.= "\n<option {$checked} value=\"".set_post($comparator)."\">".set_post($desc)."</option>";
- }
- $str .= "\n</select> ";
- if(!in_array($cond['COMPARATOR'], array('is in addressbook','is not in addressbook','is empty','is not empty'))){
- $str .= "<input style='width:400px;' type='text' name='cMatch_{$id}' value=\"".set_post($cond['MATCH'])."\">";
- }
- if(count($filter['CONDITIONS']) >= 2){
- $str .= "<button name='removeCondition_{$id}'>".msgPool::delButton()."</button> ";
- }
- $cnt --;
- $str .= "</li>";
-# if($cnt) $str .= $this->types[$filter['TYPE']];
- }
- $str .= "</ul>";
- $str .= "<button style='margin-left:40px;' name='addCondition'>".msgPool::addButton()."</button> ";
-
- $str .= "<hr>";
- $str .= "<h3>"._("Filter actions")."</h3>";
-
- $str.= "<ul>";
- foreach($filter['ACTION'] as $id => $action){
- $str .= "<li>";
- $str .= "\n<select style='width:200px;' size='1' name='cAction_{$id}' onChange='document.mainform.submit();'>";
- foreach($this->actions as $act => $desc){
- $checked = ($act == $action['ACTION'])? ' selected ' : '';
- $str.= "\n<option {$checked} value=\"".set_post($act)."\">".set_post($desc)."</option>";
- }
- $str .= "</select> ";
- if(!in_array($action['ACTION'], array('DROP'))){
- $str .= "<input style='width:500px;' type='text' name='cValue_{$id}' value=\"".set_post($action['VALUE'])."\">";
- }
-
- if(count($filter['ACTION']) >= 2){
- $str .= "<button name='removeAction_{$id}'>".msgPool::delButton()."</button>";
- }
- $str .= "</li>";
- }
- $str.= "</ul>";
- $str .= "<button style='margin-left:40px;' name='addAction'>".msgPool::addButton()."</button> ";
-
- return($str);
- }
-
-
- function save_object()
- {
- // Do nothing if the dialog wasn't submitted yet
- if(!isset($_POST['filterEditorPosted'])) return;
-
- // Get the filter confition type if posted
- $this->filter['TYPE'] = (isset($_POST['cType']))? get_post('cType'): $this->filter['TYPE'];
-
- // Get condition modifications
- foreach($this->filter['CONDITIONS'] as $id => $value){
- foreach(array('cField_' => 'FIELD',
- 'cComparator_'=>'COMPARATOR',
- 'cMatch_'=>'MATCH') as $post => $name){
- if(isset($_POST[$post.$id])){
- $this->filter['CONDITIONS'][$id][$name] = get_post($post.$id);
- }
- }
- if(isset($_POST['removeCondition_'.$id]) && count($this->filter['CONDITIONS']) >= 2){
- unset($this->filter['CONDITIONS'][$id]);
- }
- }
-
- // Get Action modifications
- foreach($this->filter['ACTION'] as $id => $value){
- foreach(array('cAction_' => 'ACTIOB','cValue_' => 'VALUE') as $post => $name){
- if(isset($_POST[$post.$id])){
- $this->filter['ACTION'][$id][$name] = get_post($post.$id);
- }
- }
- if(isset($_POST['removeAction_'.$id]) && count($this->filter['ACTION']) >= 2){
- unset($this->filter['ACTION'][$id]);
- }
- }
-
- // Get NAME and DESC if posted
- if(isset($_POST['NAME'])) $this->filter['NAME'] = get_post('NAME');
- if(isset($_POST['DESC'])) $this->filter['DESC'] = get_post('DESC');
-
- // Add conditions
- if(isset($_POST['addCondition'])){
- $this->filter['CONDITIONS'][] = array('FIELD' => key($this->fields),'COMPARATOR' => key($this->comparators), 'MATCH' => '');
- }
-
- // Add actions
- if(isset($_POST['addAction'])){
- $this->filter['ACTION'][] = array('ACTION' => 'MOVE', 'VALUE' => '');
- }
- }
-}
-?>
diff --git a/gosa-plugins/groupware/personal/groupware/class_filterManager.inc b/gosa-plugins/groupware/personal/groupware/class_filterManager.inc
+++ /dev/null
@@ -1,153 +0,0 @@
-<?php
-
-class filterManager extends plugin{
-
- var $filterListing = NULL;
- var $filterEditor = NULL;
-
- function __construct($config,$parent,$rules)
- {
- plugin::plugin($config);
-
- $this->parent = &$parent;
-
- $this->filter = $rules;
-
- // If we've read permissions then allow to edit the entries
- $acl = $this->parent->getacl('mailFilter');
- $acl = preg_replace("/r/","rw", $acl);
-
- $this->filterListing= new sortableListing();
- $this->filterListing->setDeleteable(true);
- $this->filterListing->setEditable(true);
- $this->filterListing->setColspecs(array('*'));
- $this->filterListing->setWidth("100%");
- $this->filterListing->setHeight("150px;");
- $this->filterListing->setAcl($acl);
- $this->filterListing->setColspecs(array('30px','200px','*'));
- $this->filterListing->setHeader(array('-',_("Name"),_("Description")));
- $this->filterListing->setDefaultSortColumn(1);
- }
-
- function execute()
- {
- // If we've read permissions then allow to edit the entries
- $acl = $this->parent->getacl('mailFilter');
- $acl = preg_replace("/r/","rw", $acl);
- $this->filterListing->setAcl($acl);
- // Display filter editor while a filter rule is edited
- if($this->filterEditor instanceOf filterEditor){
- $this->filterEditor->save_object();
- return($this->filterEditor->execute());
- }
-
-
- $smarty = get_smarty();
- $data = $lData = array();
- foreach($this->filter as $key => $filter){
- $data[$key] = $filter;
-
- switch($filter['STATUS']){
- case 'NEW' : $img = image('images/lists/edit.png[new]');break;
- case 'MODIFIED' : $img = image('images/lists/edit.png');break;
- case 'EXISTS' : $img = image('images/lists/edit.png');break;
- default : $img = "";
- }
-
- $lData[$key] = array('data' => array($img,$filter['NAME'], $filter['DESC']));
- }
- $this->filterListing->setListData($data,$lData);
- $this->filterListing->update();
-
-
- $smarty->assign('acl', $this->parent->getacl('mailFilter'));
- $smarty->assign('list', $this->filterListing->render());
-
- return($smarty->fetch(get_template_path('filterManager.tpl',TRUE,dirname(__FILE__))));
- }
-
- function save_object()
- {
- $this->filterListing->save_object();
- $action = $this->filterListing->getAction();
-
- // Remove filter was requested.
- if($action['action'] == 'delete'){
- $key = $action['targets'][0];
- $key = $this->filterListing->getKey($key);
- if(isset($this->filter[$key])){
- unset($this->filter[$key]);
- $this->filter = array_values($this->filter);
- }
- }
-
- // Edit filter was requested.
- if($action['action'] == 'edit'){
- $key = $action['targets'][0];
- $key = $this->filterListing->getKey($key);
- if(isset($this->filter[$key])){
- $filter = $this->filter[$key];
- $this->filterEditor = new filterEditor($this->config,$this->parent, $filter);
- $this->currentFilter = $key;
- }
- }
-
- // Add new filter
- if(isset($_POST['addFilter'])){
- $filter = array (
- 'STATUS' => 'NEW',
- 'TYPE' => 'AND',
- 'NAME' => _('name'),
- 'DESC' => _('description'),
- 'CONDITIONS' => array (
- array('FIELD' => 'from',
- 'COMPARATOR' => 'equals',
- 'MATCH' => 'example@domain.com'),
- array('FIELD' => 'subject',
- 'COMPARATOR' => 'contains',
- 'MATCH' => _('advertising')),
- ),
- 'ACTION' => array (
- array('ACTION'=>'MARK',
- 'VALUE' => 'SPAM'),
- array('ACTION'=>'MOVE',
- 'VALUE' => '')
- )
- );
- $this->filterEditor = new filterEditor($this->config,$this->parent, $filter);
- }
-
- // Close filter editor
- if(isset($_POST['filterEditor_cancel']) && $this->filterEditor instanceOf filterEditor){
- $this->currentFilter = NULL;
- $this->filterEditor = NULL;
- }
-
- // Save filter modifications and close the dialog
- if(isset($_POST['filterEditor_ok']) && $this->filterEditor instanceOf filterEditor){
- $this->filterEditor->save_object();
- $msgs = $this->filterEditor->check();
- if(count($msgs)){
- msg_dialog::displayChecks($msgs);
- }else{
- $filter = $this->filterEditor->save();
- if($filter['STATUS'] == 'NEW'){
- $this->filter[] = $filter;
- }else{
- if($filter['STATUS'] != 'NEW') $filter['STATUS'] = 'MODIFIED';
- $this->filter[$this->currentFilter] = $filter;
- }
- $this->filterEditor = NULL;
- $this->currentFilter = NULL;
- }
- }
- }
-
-
- function save()
- {
- return($this->filter);
- }
-}
-
-?>