protected function beforestore() { if (isset($this->values['quota']) && $this->values['quota'] != -1) { $this->values['quota'] = $this->values['quota'] * Config::read('quota_multiplier'); # convert quota from MB to bytes } $ah = new AliasHandler($this->new, $this->admin_username); $ah->calledBy('MailboxHandler'); if (!$ah->init($this->id)) { $arraykeys = array_keys($ah->errormsg); $this->errormsg[] = $ah->errormsg[$arraykeys[0]]; # TODO: implement this as PFAHandler->firstErrormsg() return false; } $alias_data = array(); if (isset($this->values['active'])) { # might not be set in edit mode $alias_data['active'] = $this->values['active']; } if ($this->new) { $alias_data['goto'] = array($this->id); # 'goto_mailbox' = 1; # would be technically correct, but setting 'goto' is easier } if (!$ah->set($alias_data)) { $this->errormsg[] = $ah->errormsg[0]; return false; } if (!$ah->store()) { $this->errormsg[] = $ah->errormsg[0]; return false; } return true; # still here? good! }
/** * add/remove the vacation alias * @param int $vacationActive */ protected function updateAlias($vacationActive) { $handler = new AliasHandler(); if (!$handler->init($this->id)) { # print_r($handler->errormsg); # TODO: error handling return false; } $values = array('on_vacation' => $vacationActive); if (!$handler->set($values)) { # print_r($handler->errormsg); # TODO: error handling return false; } # TODO: supress logging in AliasHandler if called from VacationHandler (VacationHandler should log itsself) if (!$handler->store()) { print_r($handler->errormsg); # TODO: error handling return false; } # still here? then everything worked return true; }
protected function setmore($values) { if ($this->new) { if ($this->struct['address']['display_in_form'] == 1) { # default mode - split off 'domain' field from 'address' # TODO: do this unconditional? list(, $domain) = explode('@', $values['address']); $this->values['domain'] = $domain; } } if (!$this->new) { # edit mode - preserve vacation and mailbox alias if they were included before $old_ah = new AliasHandler(); if (!$old_ah->init($this->id)) { $this->errormsg[] = $old_ah->errormsg[0]; } elseif (!$old_ah->view()) { $this->errormsg[] = $old_ah->errormsg[0]; } else { $oldvalues = $old_ah->result(); if (!isset($values['goto'])) { # no new value given? $values['goto'] = $oldvalues['goto']; } if (!isset($values['on_vacation'])) { # no new value given? $values['on_vacation'] = $oldvalues['on_vacation']; } if ($values['on_vacation']) { $values['goto'][] = $this->getVacationAlias(); } if ($oldvalues['is_mailbox']) { # alias belongs to a mailbox - add/keep mailbox to/in goto if (!isset($values['goto_mailbox'])) { # no new value given? $values['goto_mailbox'] = $oldvalues['goto_mailbox']; } if ($values['goto_mailbox']) { $values['goto'][] = $this->id; # if the alias points to the mailbox, don't display the "empty goto" error message if (isset($this->errormsg['goto']) && $this->errormsg['goto'] == Config::lang('pEdit_alias_goto_text_error1')) { unset($this->errormsg['goto']); } } } } } $this->values['goto'] = join(',', $values['goto']); }
/** * @return boolean true if the user has 'store_and_forward' set. * (i.e. their email address is also in the alias table). IF it returns false, then it's 'remote_only' */ public function hasStoreAndForward() { $ah = new AliasHandler(); $ah->init($_SESSION['sessid']['username']); $ah->view(); $result = $ah->result; return $result['goto_mailbox'] == 1; }
* @version $Id$ * @license GNU GPL v2 or later. * * File: edit-alias.php * Users can use this to set forwards etc for their mailbox. * * Template File: users_edit-alias.tpl * */ $rel_path = '../'; require_once '../common.php'; $smarty->assign('smarty_template', 'users_edit-alias'); authentication_require_role('user'); $USERID_USERNAME = authentication_get_username(); $ah = new AliasHandler(); $ah->init($USERID_USERNAME); $smarty->assign('USERID_USERNAME', $USERID_USERNAME); if (!$ah->view()) { die("Can't get alias details. Invalid alias?"); } # this can only happen if a admin deleted the user since the user logged in $result = $ah->result(); $tGotoArray = $result['goto']; $tStoreAndForward = $result['goto_mailbox']; if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($tStoreAndForward) { $smarty->assign('forward_and_store', ' checked="checked"'); $smarty->assign('forward_only', ''); } else { $smarty->assign('forward_and_store', ''); $smarty->assign('forward_only', ' checked="checked"');