See the enclosed file LICENSE for license information (BSD). If you did did not receive this file, see http://www.horde.org/licenses/bsd.
Author: Marko Djukic (marko@oblo.com)
Author: David Cummings (davidcummings@acm.org)
Esempio n. 1
0
 /**
  * Creates tabs to navigate the user manager area.
  *
  * @return Horde_Core_Ui_Tabs
  */
 public static function getUserMgrTabs(Variables $vars)
 {
     $url = Horde::url('users/index.php');
     $tabs = new Horde_Core_Ui_Tabs('section', $vars);
     foreach (Vilma::getUserMgrTypes() as $section => $desc) {
         $tabs->addTab($desc['plural'], $url, $section);
     }
     return $tabs;
 }
Esempio n. 2
0
 protected function _init()
 {
     $this->driver = Vilma_Driver::factory();
     // Get the currently active domain, possibly storing a change into the
     // session.
     // Domain is passed in by ID, which may or may not be the
     // the same as the actual DNS domain name.
     $domain_id = Horde_Util::getFormData('domain_id');
     if (strlen($domain_id)) {
         $domain = $this->driver->getDomain($domain_id);
         if (!empty($domain['domain_name'])) {
             $this->curdomain = $domain;
             Vilma::setCurDomain($domain);
         }
     } elseif ($domain = $GLOBALS['session']->get('vilma', 'domain')) {
         $this->curdomain = $domain;
     }
 }
Esempio n. 3
0
/**
 * Copyright 2003-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you did not
 * did not receive this file, see http://cvs.horde.org/co.php/vilma/LICENSE.
 *
 * @author Marko Djukic <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
$vilma = Horde_Registry::appInit('vilma');
/* Only admin should be using this. */
if (!Vilma::hasPermission()) {
    throw new Horde_Exception_AuthenticationFailure();
}
// Having a current domain doesn't make sense on this page
Vilma::setCurDomain();
try {
    $domains = $vilma->driver->getDomains();
} catch (Exception $e) {
    $notification->push($e, 'horde.error');
    $domains = array();
}
$editurl = Horde::url('domains/edit.php');
$deleteurl = Horde::url('domains/delete.php');
$userurl = Horde::url('users/index.php');
foreach ($domains as &$domain) {
    $domain['edit_url'] = $editurl->copy()->add('domain_id', $domain['domain_id']);
    $domain['del_url'] = $deleteurl->copy()->add('domain_id', $domain['domain_id']);
    $domain['view_url'] = $userurl->copy()->add('domain_id', $domain['domain_id']);
}
/* Set up the template fields. */
Esempio n. 4
0
 /**
  * Returns an array of information related to the address passed in.
  *
  * This method may be overridden by the backend driver if there is a more
  * efficient way to do this than a linear array search.
  *
  * @param string $address  Address for which information will be pulled.
  * @param string $type     Address type to request.
  *                         One of 'all', 'user', 'alias', 'forward' or
  *                         'group'.
  *
  * @return array  Array of user information on success or empty array
  *                if the user does not exist.
  * @throws Vilma_Exception if address of that type doesn't exist.
  */
 public function getAddressInfo($address, $type = 'all')
 {
     $domain = Vilma::stripDomain($address);
     $addresses = $this->getAddresses($domain, $type);
     foreach ($addresses as $addrinfo) {
         if ($addrinfo['id'] == $address || $addrinfo['address'] == $address) {
             return $addrinfo;
         }
     }
     throw new Vilma_Exception(sprintf(_("No such address %s of type %s found."), $address, $type));
 }
Esempio n. 5
0
<?php

/**
 * The Vilma script to add/edit aliases.
 *
 * Copyright 2003-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you did
 * did not receive this file, see http://cvs.horde.org/co.php/vilma/LICENSE.
 *
 * @author Daniel Collins <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
$vilma = Horde_Registry::appInit('vilma');
/* Only admin should be using this. */
if (!Vilma::hasPermission($domain)) {
    throw new Horde_Exception_AuthenticationFailure();
}
$vars = Variables::getDefaultVariables();
/* If the form is submitted, $vars['mode'] will be set. Catch this and process
 * the submission so that the displayed form accurately indicates the result of
 * the transaction. */
if (isset($vars->mode)) {
    $form = new Vilma_Form_EditAlias($vars);
    if ($form->validate($vars)) {
        $form->getInfo($vars, $info);
        try {
            $alias_id = $vilma->driver->saveAlias($info);
            $notification->push(_("Alias saved."), 'horde.success');
            Horde::url('users/index.php', true)->add('domain_id', $domain['id'])->redirect();
        } catch (Exception $e) {
Esempio n. 6
0
}
foreach ($virtuals as $id => $virtual) {
    $virtuals[$id]['edit_url'] = Horde::url('virtuals/edit.php')->add('virtual_id', $virtual['virtual_id']);
    $virtuals[$id]['del_url'] = Horde::url('virtuals/delete.php')->add('virtual_id', $virtual['virtual_id']);
}
$template = $injector->createInstance('Horde_Template');
$template->setOption('gettext', true);
$template->set('virtuals', $virtuals, true);
/* Set up the template action links. */
$actions = array();
$url = Horde::url('virtuals/edit.php');
if (!Vilma::isDomainAdmin()) {
    $url->add('domain', $domain);
}
$actions['new_url'] = $url;
$actions['new_text'] = _("New Virtual Email");
$url = Horde::url('users/index.php');
if (!Vilma::isDomainAdmin()) {
    $url->add('domain', $domain);
}
$actions['users_url'] = $url;
$actions['users_text'] = _("Users");
$template->set('actions', $actions);
/* Set up the field list. */
$images = array('delete' => Horde::img('delete.png', _("Delete User")), 'edit' => Horde::img('edit.png', _("Edit User")));
$template->set('images', $images);
/* Render the page. */
$page_output->header();
$notification->notify(array('listeners' => 'status'));
echo $template->fetch(VILMA_TEMPLATES . '/virtuals/index.html');
$page_output->footer();
Esempio n. 7
0
if (!$registry->isAdmin() && !Vilma::isDomainAdmin()) {
    throw new Horde_Exception_AuthenticationFailure();
}
$domain = Vilma::getDomain();
$vars = Horde_Variables::getDefaultVariables();
$virtual_id = $vars->virtual_id;
$user = $vars->user;
$formname = $vars->formname;
/* Check if a form is being edited. */
$editing = false;
if ($virtual_id && !$formname) {
    $vars = new Horde_Variables($vilma->driver->getVirtual($virtual_id));
    $editing = true;
}
if (empty($domain)) {
    $domain = Vilma::stripDomain($vars->virtual_destination);
}
$users = $vilma->driver->getUsers($domain);
$user_list = array();
foreach ($users as $user) {
    $virtual_destination = substr($user['user_name'], 0, strpos($user['user_name'], '@'));
    $user_list[$user['user_name']] = $virtual_destination;
}
$form = new Horde_Form($vars, $editing ? _("Edit Virtual Email Address") : _("New Virtual Email Address"));
/* Set up the form. */
$form->setButtons(true, true);
$form->addHidden('', 'virtual_id', 'int', false);
$form->addHidden('', 'domain', 'text', false);
$form->addVariable(_("Virtual Email"), 'stripped_email', 'text', true, false, sprintf(_("Enter a virtual email address @%s and then indicate below where mail sent to that address is to be delivered. The address must begin with an alphanumerical character, it must contain only alphanumerical and '._-' characters, and must end with an alphanumerical character."), $domain), array('~^[a-zA-Z0-9]{1,1}[a-zA-Z0-9._-]*[a-zA-Z0-9]$~'));
$var =& $form->addVariable(_("Destination type"), 'destination_type', 'enum', true, false, null, array(array('local' => _("Local user"), 'remote' => _("Remote address"))));
$var->setAction(Horde_Form_Action::factory('reload'));
Esempio n. 8
0
        $vars->domain = $domain;
        $vars->type = $address['type'];
        $vars->target = 'test';
        //$address['target']);
        $vars->mode = 'edit';
    } else {
        $vars->mode = 'new';
        $domain_info = $session->get('vilma', 'domain');
        $domain = $domain_info['domain_name'];
        $domain_id = $domain_info['domain_id'];
        $vars->domain = $domain;
        $vars->id = $domain_id;
        $vars->add('user_name', Horde_Util::getFormData('user_name', ''));
    }
}
$domain = Vilma::stripDomain($address['address']);
$tmp = $vars->domain;
if (!$tmp) {
    $vars->domain = $domain;
}
if (!isset($vars->id) && !$vilma->driver->isBelowMaxUsers($domain)) {
    $notification->push(sprintf(_("\"%s\" already has the maximum number of users allowed."), $domain), 'horde.error');
    Horde::url('users/index.php', true)->redirect();
}
$form = new Vilma_Form_EditUser($vars);
if ($form->validate($vars)) {
    $form->getInfo($vars, $info);
    $info['user_name'] = Horde_String::lower($info['user_name']) . '@' . $domain;
    try {
        $vilma->driver->saveUser($info);
        $notification->push(_("User details saved."), 'horde.success');
Esempio n. 9
0
 * @author David Cummings <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
$vilma = Horde_Registry::appInit('vilma');
/* Only admin should be using this. */
if (!Vilma::hasPermission($curdomain)) {
    throw new Horde_Exception_AuthenticationFailure();
}
// Input validation: make sure we have a valid section.
$vars = Horde_Variables::getDefaultVariables();
$section = $vars->section;
$types = Vilma::getUserMgrTypes();
if (!isset($types[$section])) {
    $vars->section = $section = 'all';
}
$tabs = Vilma::getUserMgrTabs($vars);
try {
    $addresses = $vilma->driver->getAddresses($curdomain['domain_name'], $section);
} catch (Exception $e) {
    $notification->push($e);
    Horde::url('index.php', true)->redirect();
}
// Page results
$perpage = $prefs->getValue('addresses_perpage');
$url = Horde::url('users/index.php')->add('section', $section);
$pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => count($addresses), 'url' => $url, 'page_count' => 10, 'perpage' => $perpage));
$addresses = array_slice($addresses, $vars->page * $perpage, $perpage);
foreach ($addresses as &$address) {
    $type = $address['type'];
    $id = $address['id'];
    switch ($type) {
Esempio n. 10
0
File: Sql.php Progetto: horde/horde
 /**
  * Returns information for a virtual id.
  *
  * @param integer $virtual_id  The virtual id for which to return
  *                             information.
  *
  * @return array  The virtual email information.
  */
 public function getVirtual($virtual_id)
 {
     $sql = 'SELECT ' . $this->_getTableFields('virtuals') . ' FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_id') . ' = ?';
     $virtual = $this->_db->selectOne($sql, array((int) $virtual_id));
     $virtual['stripped_email'] = Vilma::stripUser($virtual['virtual_email']);
     return $virtual;
 }
Esempio n. 11
0
}
$groups = $vilma->driver->_getGroupsAndForwards('groups', $domain);
$groupsCount = 0;
foreach ($groups as $entry) {
    foreach ($entry['targets'] as $target) {
        if ($user_id === $target) {
            $groupsCount++;
        }
    }
}
$user_name = $address['user_name'];
if (empty($user_name)) {
    $user_name = $address['address'];
}
$vars->user_name = Vilma::stripUser($user_name);
$domain = Vilma::stripDomain($address);
$domain = $vilma->driver->getDomainByName($domain);
$vars->domain = $domain;
$vars->mode = 'edit';
/* Set up the form. */
$form = new Horde_Form($vars, sprintf(_("Delete %s"), $type));
$form->setButtons(array(_("Delete"), _("Do not delete")));
//$form->addHidden($user_id, 'user_id', 'text', false);
$form->addHidden($address['address'], 'address', 'text', false);
$form->addHidden($section, 'section', 'text', false);
if ($aliasesCount + $groupsCount + $forwardsCount) {
    $desc = _("Delete %s \"%s\" and all dependencies?");
} else {
    $desc = _("Delete %s \"%s\"?");
}
$desc = sprintf($desc, $type, $user_name);
Esempio n. 12
0
 * See the enclosed file LICENSE for license information (BSD). If you did not
 * did not receive this file, see http://cvs.horde.org/co.php/vilma/LICENSE.
 *
 * @author Marko Djukic <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
$vilma = Horde_Registry::appInit('vilma');
/* Only admin should be using this. */
if (!$registry->isAdmin()) {
    throw new Horde_Exception_AuthenticationFailure();
}
$vars = Horde_Variables::getDefaultVariables();
$virtual_id = $vars->virtual_id;
$formname = $vars->formname;
$virtual = $vilma->driver->getVirtual($virtual_id);
$domain = Vilma::stripDomain($virtual['virtual_email']);
$domain = $vilma->driver->getDomainByName($domain);
if ($vars->submitbutton == _("Do not delete")) {
    $notification->push(_("Virtual email not deleted."), 'horde.message');
    Horde::url('virtuals/index.php')->add('domain_id', $domain['domain_id'])->redirect();
}
$form = new Horde_Form($vars, _("Delete Virtual Email Address"));
/* Set up the form. */
$form->setButtons(array(_("Delete"), _("Do not delete")));
$form->addHidden('', 'virtual_id', 'text', false);
$form->addVariable(sprintf(_("Delete the virtual email address \"%s\" => \"%s\"?"), $virtual['virtual_email'], $virtual['virtual_destination']), 'description', 'description', false);
if ($vars->submitbutton == _("Delete") && $form->validate($vars)) {
    $form->getInfo($vars, $info);
    try {
        $delete = $vilma->driver->deleteVirtual($info['virtual_id']);
        $notification->push(_("Virtual email deleted."), 'horde.success');
Esempio n. 13
0
 /**
  * Returns information for a virtual id.
  *
  * @param integer $virtual_id  The virtual id for which to return
  *                             information.
  *
  * @return array  The virtual email information.
  */
 public function getVirtual($virtual_id)
 {
     $sql = 'SELECT ' . $this->_getTableFields('virtuals') . ' FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_id') . ' = ?';
     Horde::log($sql, 'DEBUG');
     $virtual = $this->_db->getRow($sql, array((int) $virtual_id), DB_FETCHMODE_ASSOC);
     $virtual['stripped_email'] = Vilma::stripUser($virtual['virtual_email']);
     return $virtual;
 }