stripDomain() 공개 정적인 메소드

Strip the user name from an email address (leaving the domain).
public static stripDomain ( string $email ) : string
$email string Email address to strip.
리턴 string Domain portion of the email address.
예제 #1
0
파일: Driver.php 프로젝트: raz0rsdge/horde
 /**
  * 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));
 }
예제 #2
0
파일: edit.php 프로젝트: jubinpatel/horde
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'));
예제 #3
0
파일: index.php 프로젝트: horde/horde
 * See the enclosed file LICENSE for license information (BSD). If you did not
 * did not receive this file, see http://www.horde.org/licenses/bsd.
 *
 * @author Marko Djukic <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
$vilma = Horde_Registry::appInit('vilma');
/* Only admin should be using this. */
if (!$registry->isAdmin() && !Vilma::isDomainAdmin()) {
    throw new Horde_Exception_AuthenticationFailure();
}
$user = Horde_Util::getFormData('user');
try {
    if (!empty($user)) {
        $virtuals = $vilma->driver->getVirtuals($user);
        $domain = Vilma::stripDomain($user);
    } else {
        $domain = Vilma::getDomain();
        $virtuals = $vilma->driver->getVirtuals($domain);
    }
} catch (Exception $e) {
    $notification->push($e);
    Horde::url('index.php', true)->redirect();
}
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);
예제 #4
0
파일: edit.php 프로젝트: jubinpatel/horde
        $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');
예제 #5
0
파일: Sql.php 프로젝트: horde/horde
 /**
  * Deletes a user.
  *
  * @param integer $user_id  The id of the user to delete.
  *
  * @throws Vilma_Exception
  */
 public function deleteUser($user_id)
 {
     $user = $this->getUser($user_id);
     try {
         $this->_db->beginDbTransaction();
         /* Delete all virtual emails for this user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?';
         $values = array($user['user_name']);
         $this->_db->delete($sql, $values);
         /* Delete the actual user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_id') . ' = ?';
         $values = array((int) $user_id);
         $this->_db->delete($sql, $values);
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         throw new Vilma_Exception($e);
     }
     Vilma_MailboxDriver::factory()->deleteMailbox(Vilma::stripUser($user['user_name']), Vilma::stripDomain($user['user_name']));
 }
예제 #6
0
파일: delete.php 프로젝트: jubinpatel/horde
}
$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);
예제 #7
0
파일: delete.php 프로젝트: raz0rsdge/horde
 * 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');
예제 #8
0
파일: Sql.php 프로젝트: raz0rsdge/horde
 /**
  * Deletes a user.
  *
  * @param integer $user_id  The id of the user to delete.
  *
  * @throws Vilma_Exception
  */
 public function deleteUser($user_id)
 {
     Horde_Exception_Pear::catchError($user = $this->getUser($user_id));
     /* Delete all virtual emails for this user. */
     $sql = 'DELETE FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?';
     $values = array($user['user_name']);
     Horde::log($sql, 'DEBUG');
     Horde_Exception_Pear::catchError($this->_db->query($sql, $values));
     /* Delete the actual user. */
     $sql = 'DELETE FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_id') . ' = ?';
     $values = array((int) $user_id);
     Horde::log($sql, 'DEBUG');
     Horde_Exception_Pear::catchError($this->_db->query($sql, $values));
     Vilma_MailboxDriver::factory()->deleteMailbox(Vilma::stripUser($user['user_name']), Vilma::stripDomain($user['user_name']));
 }