Commit aa3a8190 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5333 Deleting kolab2 plugin

parent 1d5b8b45
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2016 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class RelayHostKolabAttribute extends CompositeAttribute
{
function __construct ($description, $ldapName, $acl = '', $label = 'Composite attribute')
{
$attributes = array(
new BooleanAttribute (
_('Enable MX lookup for relayhost'), '', 'RelayMxSupport', FALSE, FALSE,
'', TRUE, FALSE
),
new StringAttribute (_('Relay host'), _('Host used to relay mails'), 'relayhost')
);
parent::__construct ($description, $ldapName, $attributes, '', '', $acl, $label);
}
function readValues($value)
{
$values = array();
$values[0] = preg_match('/^\[/', $value);
$values[1] = preg_replace("/[\[\]]/", "", $value);
return $values;
}
function writeValues($values)
{
/* Adapt relayhost */
$value = preg_replace('/[\[\]]/', '', $values[1]);
if ($values[0] && ($value != '')) {
$value = '['.$value.']';
}
return $value;
}
}
class serviceKolab extends simpleService
{
var $objectclasses = array('top', 'kolab');
var $displayHeader = FALSE;
var $mainTab = TRUE;
var $conflicts = array('fdPostfixServer');
static function plInfo()
{
return array(
'plShortName' => _('Kolab 2 mail'),
'plDescription' => _('Kolab 2 mail service'),
'plIcon' => 'geticon.php?context=applications&icon=kolab2&size=16',
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
}
/*!
* \brief The main function : information about attributes
*/
static function getAttributesInfo ()
{
return array (
'section1' => array (
'name' => _('Information'),
'attrs' => array (
new StringAttribute('', '', 'k', FALSE, 'kolab'),
new SetAttribute(new StringAttribute('', '', 'kolabHost')),
new StringAttribute(
_('Postfix mydomain'), _('Postfix domain name'),
'postfix-mydomain'
),
new StringAttribute(
_('Cyrus admins'), _('Cyrus admins for kolab server'),
'cyrus-admins'
),
new SetAttribute(
new StringAttribute(
_('Mail domains').', '._('Postfix mydestination'), _('Mail domains'),
'postfix-mydestination', FALSE
)
)
)
),
'section2' => array (
'name' => _('Services'),
'attrs' => array (
new BooleanAttribute (
_('POP3 service'), _('Enable POP3 service'),
'cyrus-pop3', FALSE, FALSE
),
new BooleanAttribute (
_('POP3/SSL service'), _('Enable POP3/SSL service'),
'cyrus-pop3s', FALSE, TRUE
),
new BooleanAttribute (
_('IMAP service'), _('Enable IMAP service'),
'cyrus-imap', FALSE, TRUE
),
new BooleanAttribute (
_('IMAP/SSL service'), _('Enable IMAP/SSL service'),
'cyrus-imaps', FALSE, TRUE
),
new BooleanAttribute (
_('Sieve service'), _('Enable Sieve service'),
'cyrus-sieve', FALSE, TRUE
),
new BooleanAttribute (
_('FTP FreeBusy service (legacy)'),
_('FTP FreeBusy service (legacy, not interoperable with Kolab2 FreeBusy)'),
'proftpd-ftp', FALSE, FALSE
),
new BooleanAttribute (
_('HTTP FreeBusy service (legacy)'), '',
'apache-http', FALSE, TRUE
),
new BooleanAttribute (
_('Amavis email scanning'), _('Amavis email scanning (virus/spam)'),
'postfix-enable-virus-scan', FALSE, TRUE
),
)
),
'section3' => array (
'name' => _('Quota settings'),
'attrs' => array (
new IntAttribute (
_('Quota occupation limit before warning users (%)'),
_('Warn users when using more than X% of their mail quota'),
'cyrus-quotawarn', FALSE,
FALSE, FALSE,
80
)
)
),
'section4' => array (
'name' => _('Free/Busy settings'),
'attrs' => array (
new BooleanAttribute (
_('Allow unauthenticated downloading of Free/Busy information'),
_('Allow unauthenticated downloading of Free/Busy information'),
'apache-allow-unauthenticated-fb', FALSE, TRUE
),
new IntAttribute (
_('Number of days to include when creating free/busy lists'),
_('Include data from X days in the past when creating free/busy lists'),
'kolabFreeBusyFuture', FALSE,
FALSE, FALSE,
1
)
)
),
'section5' => array (
'name' => _('SMTP privileged networks'),
'attrs' => array (
new StringAttribute (
_('Hosts/networks allowed to relay'),
_('Hosts/networks allowed to relay (multiple values comma-seperated)'),
'postfix-mynetworks',
FALSE,
'127.0.0.1/8'
)
)
),
'section6' => array (
'name' => _('SMTP smarthost/relayhost'),
'attrs' => array (
new RelayHostKolabAttribute (
_('Host used to relay mails'), 'postfix-relayhost'
)
)
),
'section7' => array (
'name' => _('Accept Internet Mail'),
'attrs' => array (
new BooleanAttribute (
_('Accept mail from other domains over non-authenticated SMTP'),
_('Accept mail from other domains over non-authenticated SMTP'),
'postfix-allow-unauthenticated'
)
)
)
);
}
function __construct ($dn = NULL, $parent = NULL)
{
global $config;
$this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
$this->dn = 'k=kolab,'.$config->current['BASE'];
parent::__construct($this->dn, $parent);
$this->attributesAccess['k']->setVisible(FALSE);
$this->attributesAccess['kolabHost']->setVisible(FALSE);
$this->is_account = in_array($this->hostname, $this->attributesAccess['kolabHost']->getValue());
$this->initially_was_account = $this->is_account;
}
function save ()
{
global $config;
$this->dn = 'k=kolab,'.$config->current['BASE'];
/* Check if this server was renamed, in this case we have to remove old cn first*/
$kolabHost = $this->attributesAccess['kolabHost']->getValue();
if ($this->hostname != $this->cn) {
$key = array_search($this->hostname, $kolabHost);
if ($key !== FALSE) {
unset($kolabHost[$key]);
}
}
if (!in_array($this->cn, $kolabHost)) {
$kolabHost[] = $this->cn;
}
$this->attributesAccess['kolabHost']->setValue($kolabHost);
return parent::save();
}
function remove_from_parent()
{
global $config;
/* Only walk through following code, if this host was a member of the kolab hosts, else skip this */
if (!$this->initially_was_account) {
return;
}
/* !!! Don't use "cn" in this function
hostname -> the initial name of the host
cn -> is the new name of the host, in case that it was renamed.
*/
$ldap = $config->get_ldap_link();
$this->dn = 'k=kolab,'.$config->current['BASE'];
/* We can't simply remove the whole entry, it is possible that there are
some other hosts assigned to this object.
So, first of all check if we are the last host entry within the host
: Remove k=kolab entry
if we aren't alone, only remove host name from hosts entry and save */
/* Are we alone? Remove complete entry... */
$kolabHost = $this->attributesAccess['kolabHost']->getValue();
/* Check if we are definitly in kolabHosts */
if (!in_array_ics($this->hostname, $kolabHost)) {
return;
}
/* Integration check, not translated because they can't pop up at all, only for debug */
if (count($kolabHost) == 0) {
msg_dialog::display(_('Internal error'), _('Kolab account does not exist!'), ERROR_DIALOG);
return;
}
if (!isset($this->hostname) || (empty($this->hostname))) {
msg_dialog::display(_('Error'), msgPool::required(_('hostname')), ERROR_DIALOG);
}
/* Our hostname is in kolabHosts and there is a only one entry
= we are the last host entry, delete k=kolab entry */
if (count($this->kolabHost) == 1) {
/* Remove complete entry */
$ldap->rmdir ($this->dn);
if (!$ldap->success()) {
return msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class());
}
} else {
/* Only modify kolabHost */
$key = array_search($this->hostname, $kolabHost);
unset($kolabHost[$key]);
$attrs = array('kolabHost' => array_values($kolabHost));
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify($attrs);
if (!$ldap->success()) {
return msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class());
}
}
logging::log('remove', 'service/'.get_class($this), $this->dn, array_keys($this->attrs), $ldap->get_error());
/* Optionally execute a command after we're done */
$this->handle_post_events('remove');
}
}
?>
This diff is collapsed.
# (c) 2004 Martin Konold <martin.konold@erfrakon.de>
# This schema is derived from RFC 2739 and may act as a substitute
# when used with OpenLDAP as the original schema from RFC 2739
# is syntactically not accepted by OpenLDAP 2.2.14
#
# Copyright (C) The Internet Society (2000). All Rights Reserved.
#
# This document and translations of it may be copied and furnished to
# others, and derivative works that comment on or otherwise explain it
# or assist in its implementation may be prepared, copied, published
# and distributed, in whole or in part, without restriction of any
# kind, provided that the above copyright notice and this paragraph are
# included on all such copies and derivative works. However, this
# document itself may not be modified in any way, such as by removing
# the copyright notice or references to the Internet Society or other
# Internet organizations, except as needed for the purpose of
# developing Internet standards in which case the procedures for
# copyrights defined in the Internet Standards process must be
# followed, or as required to translate it into languages other than
# English.
#
# The limited permissions granted above are perpetual and will not be
# revoked by the Internet Society or its successors or assigns.
#
# This document and the information contained herein is provided on an
# "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
# TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
# HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
# slapd.conf then looks like
# include /kolab/etc/openldap/schema/core.schema
# include /kolab/etc/openldap/schema/cosine.schema
# include /kolab/local/etc/openldap/schema/inetorgperson.schema
# include /kolab/local/etc/openldap/schema/rfc2739.schema
# include /kolab/local/etc/openldap/schema/kolab2.schema
#
################################
# rfc 2739 calendar attributes #
################################
# contains the URI to a snapshot of the user's entire
# default calendar
attributetype ( 1.2.840.113556.1.4.478
NAME 'calCalURI'
DESC 'RFC2739: URI of entire default calendar'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# contains the URI to the user's default
# busy time data
attributetype (1.2.840.113556.1.4.479
NAME 'calFBURL'
DESC 'RFC2739: URI to the users default freebusy data'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# contains a URI that can be used to communicate with
# the user's calendar
attributetype (1.2.840.113556.1.4.480
NAME 'calCAPURI'
DESC 'RFC2739: URI used to communicate with the users calendar'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# contains a URI that points to the location to which event
# requests should be sent for that user
attributetype (1.2.840.113556.1.4.481
NAME 'calCalAdrURI'
DESC 'RFC2739: URI for event equests destination'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# multi-valued property containing URIs to snapshots of
# other calendars that the user may have
attributetype (1.2.840.113556.1.4.482
NAME 'calOtherCalURIs'
DESC 'RFC2739: multi-value URI for snapshots of other calendars'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# multi-valued property containing URIs to snapshots of other
# free/busy data that the user may have
attributetype (1.2.840.113556.1.4.483
NAME 'calOtherFBURLs'
DESC 'RFC2739: multi-value URI for other free/busy data'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# multi-valued property containing URI to other calendars that
# the user may have
attributetype (1.2.840.113556.1.4.484
NAME 'calOtherCAPURIs'
DESC 'RFC2739: multi-value URI to other calendars'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
# URIs to other locations that a user may want
# event requests sent to
attributetype (1.2.840.113556.1.4.485
NAME 'calOtherCalAdrURIs'
DESC 'RFC2739: multi-value URI to other request destinations'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
USAGE userApplications )
objectclass (1.2.840.113556.1.5.87
NAME 'calEntry'
DESC 'RFC2739: Calendar Entry'
SUP top AUXILIARY
MAY ( calCalURI $
calFBURL $
calOtherCalURIs $
calOtherFBURLs $
calCAPURI $
calOtherCAPURIs ) )
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
id="svg3049"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="kolab2.svg"
inkscape:export-filename="kolab2.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
viewBox="0 0 16 16">
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
.ColorScheme-Background {
color:#eff0f1;
}
.ColorScheme-Highlight {
color:#3daee9;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground {
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#93cee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground {
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#93cee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}
</style>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.313709"
inkscape:cx="1.9855908"
inkscape:cy="6.3456936"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1880"
inkscape:window-height="1051"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:showpageshadow="false"
borderlayer="true"
inkscape:snap-bbox="true"
inkscape:snap-global="true">
<inkscape:grid
type="xygrid"
id="grid4085" />
<sodipodi:guide
position="2.0000044,14.00003"
orientation="12,0"
id="guide4075" />
<sodipodi:guide
position="2.0000044,2.0000296"
orientation="0,12"
id="guide4077" />
<sodipodi:guide
position="14.000004,2.0000296"
orientation="-12,0"
id="guide4079" />
<sodipodi:guide
position="14.000004,14.00003"
orientation="0,-12"
id="guide4081" />
</sodipodi:namedview>
<metadata
id="metadata3054">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Capa 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-421.71429,-531.79074)">
<rect
style="fill:currentColor;fill-opacity:1;stroke:none"
id="rect4035"
width="0"
height="10.999983"
x="-464.55804"
y="546.66571"
transform="scale(-1,1)"
class="ColorScheme-Text" />
<rect
style="fill:currentColor;fill-opacity:1;stroke:none"
id="rect4035-5"
width="0"
height="10.999983"
x="-446.51727"
y="544.61438"
transform="scale(-1,1)"
class="ColorScheme-Text" />
<rect
style="fill:currentColor;fill-opacity:1;stroke:none"
id="rect4035-8"
width="0"
height="10.999983"
x="-464.55804"
y="546.66571"
transform="scale(-1,1)"
class="ColorScheme-Text" />
<rect
style="fill:currentColor;fill-opacity:1;stroke:none"
id="rect4035-59"
width="0"
height="10.999983"
x="-464.55804"
y="546.66571"
transform="scale(-1,1)"
class="ColorScheme-Text" />
<text