/**
  * Get allowed maximum quota for a mailbox
  *
  * @param String $domain
  * @param Integer $current_user_quota (in bytes)
  * @return Integer allowed maximum quota (in MB)
  */
 protected function allowed_quota($domain, $current_user_quota)
 {
     if (!Config::bool('quota')) {
         return 0;
         # quota disabled means no limits - no need for more checks
     }
     $domain_properties = get_domain_properties($domain);
     $tMaxquota = $domain_properties['maxquota'];
     if (Config::bool('domain_quota') && $domain_properties['quota']) {
         $dquota = $domain_properties['quota'] - $domain_properties['total_quota'] + divide_quota($current_user_quota);
         if ($dquota < $tMaxquota) {
             $tMaxquota = $dquota;
         }
         if ($tMaxquota == 0) {
             $tMaxquota = $dquota;
         }
     }
     return $tMaxquota;
 }
Example #2
0
}
$smarty = new PFASmarty();
if (!isset($rel_path)) {
    $rel_path = '';
}
# users/* sets this to '../'
$CONF['theme_css'] = $rel_path . htmlentities($CONF['theme_css']);
if (!empty($CONF['theme_custom_css'])) {
    $CONF['theme_custom_css'] = $rel_path . htmlentities($CONF['theme_custom_css']);
}
$CONF['theme_logo'] = $rel_path . htmlentities($CONF['theme_logo']);
$smarty->assign('CONF', $CONF);
$smarty->assign('PALANG', $PALANG);
$smarty->assign('url_domain', '');
//*** footer.tpl
$smarty->assign('version', $version);
//*** menu.tpl
$smarty->assign('boolconf_alias_domain', Config::bool('alias_domain'));
$smarty->assign('authentication_has_role', array('global_admin' => authentication_has_role('global-admin'), 'admin' => authentication_has_role('admin'), 'user' => authentication_has_role('user')));
function eval_size($aSize)
{
    if ($aSize == 0) {
        $ret_val = Config::Lang('pOverview_unlimited');
    } elseif ($aSize < 0) {
        $ret_val = Config::Lang('pOverview_disabled');
    } else {
        $ret_val = $aSize;
    }
    return $ret_val;
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
Example #3
0
 /**
  * @return boolean true indicates this server supports vacation messages, and users are able to change their own.
  */
 function vacation_supported()
 {
     return Config::bool('vacation') && Config::bool('vacation_control');
 }
Example #4
0
 /**
  * Used to read Config::$var, converted to bool, returned as integer (0 or 1)
  * @see bool()
  */
 public static function intbool($var)
 {
     return Config::bool($var) ? 1 : 0;
 }
Example #5
0
$smarty->assign('fDomain', $fDomain, false);
$smarty->assign('search', $search);
$smarty->assign('list_domains', $list_domains);
$smarty->assign('limit', $limit);
$smarty->assign('tDisplay_back_show', $tDisplay_back_show);
$smarty->assign('tDisplay_back', $tDisplay_back);
$smarty->assign('tDisplay_up_show', $tDisplay_up_show);
$smarty->assign('tDisplay_next_show', $tDisplay_next_show);
$smarty->assign('tDisplay_next', $tDisplay_next);
$smarty->assign('tAliasDomains', $tAliasDomains);
$smarty->assign('aliasdomain_data', $aliasdomain_data);
$smarty->assign('tAlias', $tAlias);
$smarty->assign('alias_data', $alias_data);
$smarty->assign('tMailbox', $tMailbox);
$smarty->assign('gen_show_status_mailbox', $gen_show_status_mailbox, false);
$smarty->assign('boolconf_used_quotas', Config::bool('used_quotas'));
$smarty->assign('divide_quota', $divide_quota);
$smarty->assign('tCanAddMailbox', $tCanAddMailbox);
$smarty->assign('display_mailbox_aliases', $display_mailbox_aliases);
if (isset($_GET['tab'])) {
    $_SESSION['tab'] = $_GET['tab'];
}
//if (empty ($_GET ['tab']))
// unset ($_SESSION ['tab']);
if (!isset($_SESSION['tab'])) {
    $_SESSION['tab'] = 'all';
}
$smarty->assign('tab', $_SESSION['tab']);
$smarty->assign('smarty_template', 'list-virtual');
$smarty->display('index.tpl');
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
Example #6
0
 protected function read_from_db_postprocess($db_result)
 {
     foreach ($db_result as $key => $value) {
         # split comma-separated 'goto' into an array
         $db_result[$key]['goto'] = explode(',', $db_result[$key]['goto']);
         # Vacation enabled?
         list($db_result[$key]['on_vacation'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $this->getVacationAlias());
         # if it is a mailbox, does the alias point to the mailbox?
         if ($db_result[$key]['is_mailbox']) {
             # this intentionally does not match mailbox targets with recipient delimiter.
             # if it would, we would have to make goto_mailbox a text instead of a bool (which would annoy 99% of the users)
             list($db_result[$key]['goto_mailbox'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $key);
         } else {
             # not a mailbox
             $db_result[$key]['goto_mailbox'] = 0;
         }
         # editing a default alias (postmaster@ etc.) is only allowed if special_alias_control is allowed or if the user is a superadmin
         $tmp = preg_split('/\\@/', $db_result[$key]['address']);
         if (!$this->is_superadmin && !Config::bool('special_alias_control') && array_key_exists($tmp[0], Config::Read('default_aliases'))) {
             $db_result[$key]['_can_edit'] = 0;
             $db_result[$key]['_can_delete'] = 0;
         }
         if ($this->struct['status']['display_in_list'] && Config::Bool('show_status')) {
             $db_result[$key]['status'] = gen_show_status($db_result[$key]['address']);
         }
     }
     return $db_result;
 }
Example #7
0
/**
 * db_log
 * Action: Logs actions from admin
 * Call: db_log (string domain, string action, string data)
 * Possible actions are defined in $LANG["pViewlog_action_$action"]
 */
function db_log($domain, $action, $data)
{
    $REMOTE_ADDR = getRemoteAddr();
    $username = authentication_get_username();
    if (Config::Lang("pViewlog_action_{$action}") == '') {
        die("Invalid log action : {$action}");
        // could do with something better?
    }
    if (Config::bool('logging')) {
        $logdata = array('username' => "{$username} ({$REMOTE_ADDR})", 'domain' => $domain, 'action' => $action, 'data' => $data);
        $result = db_insert('log', $logdata, array('timestamp'));
        if ($result != 1) {
            return false;
        } else {
            return true;
        }
    }
}
 /**
  *  @return true on success false on failure
  */
 public function delete()
 {
     # TODO: check for _can_delete instead
     if (!$this->is_superadmin) {
         $this->errormsg[] = Config::Lang_f('no_delete_permissions', $this->id);
         return false;
     }
     if (!$this->view()) {
         $this->errormsg[] = Config::Lang('domain_does_not_exist');
         # TODO: can users hit this message at all? init() should already fail...
         return false;
     }
     if (Config::bool('alias_domain')) {
         # check if this domain is an alias domain target - if yes, do not allow to delete it
         $handler = new AliasdomainHandler(0, $this->admin_username);
         $handler->getList("target_domain = '" . escape_string($this->id) . "'");
         $aliasdomains = $handler->result();
         if (count($aliasdomains) > 0) {
             $this->errormsg[] = Config::Lang_f('delete_domain_aliasdomain_target', $this->id);
             return false;
         }
     }
     # the correct way would be to recursively delete mailboxes, aliases, alias_domains, fetchmail entries
     # with *Handler before deleting the domain, but this would be terribly slow on domains with many aliases etc.,
     # so we do it the fast way on the database level
     # cleaning up all tables doesn't hurt, even if vacation or displaying the quota is disabled
     # some tables don't have a domain field, so we need a workaround
     $like_domain = "LIKE '" . escape_string('%@' . $this->id) . "'";
     db_delete('domain_admins', 'domain', $this->id);
     db_delete('alias', 'domain', $this->id);
     db_delete('mailbox', 'domain', $this->id);
     db_delete('alias_domain', 'alias_domain', $this->id);
     db_delete('vacation', 'domain', $this->id);
     db_delete('vacation_notification', 'on_vacation', $this->id, "OR on_vacation {$like_domain}");
     db_delete('quota', 'username', $this->id, "OR username    {$like_domain}");
     db_delete('quota2', 'username', $this->id, "OR username    {$like_domain}");
     db_delete('fetchmail', 'mailbox', $this->id, "OR mailbox     {$like_domain}");
     db_delete('log', 'domain', $this->id);
     # TODO: should we really delete the log?
     # finally delete the domain
     db_delete($this->db_table, $this->id_field, $this->id);
     if (!$this->domain_postdeletion()) {
         $this->error_msg[] = $PALANG['domain_postdel_failed'];
     }
     db_log($this->id, 'delete_domain', $this->id);
     # TODO delete_domain is not a valid db_log keyword yet
     $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id);
     return true;
 }