Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory
Commits
95ce0118
Unverified
Commit
95ce0118
authored
4 years ago
by
Côme Chilliet
Browse files
Options
Download
Patches
Plain Diff
feat(core) Add subscription page
issue
#6152
parent
a4f3ae00
dev
6342-update-the-locales-for-1-5
6344-template-issue-when-creating-a-template-with-empty-password-error-message-should-not-be-seen
6365-core-locking-mechanism-is-not-changing-the-mail-ressource-it-does-lock-the-mail-account
6365-core-when-lock-mechanism-is-trigger-the-user-should-not-be-editable-if-not-unlock
6378-orcid-test-method-is-wrong-and-break-orcid-saving
core-php8
master
fusiondirectory-1.5
fusiondirectory-1.4
fusiondirectory-1.3.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/addons/subscriptions/class_subscriptionInfo.inc
+135
-0
plugins/addons/subscriptions/class_subscriptionInfo.inc
with
135 additions
and
0 deletions
+135
-0
plugins/addons/subscriptions/class_subscriptionInfo.inc
0 → 100644
+
135
−
0
View file @
95ce0118
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2020-2021 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
subscriptionInfo
extends
simplePlugin
{
public
static
$subscriptionAttributes
=
[
'fdSubscriptionType'
,
'fdSubscriptionContractId'
,
'fdSubscriptionStartDate'
,
'fdSubscriptionEndDate'
];
public
static
function
plInfo
():
array
{
return
[
'plShortName'
=>
_
(
'Subscription'
),
'plTitle'
=>
_
(
'Subscription information'
),
'plDescription'
=>
_
(
'Information about your subscription to FusionDirectory, if any'
),
'plIcon'
=>
'geticon.php?context=applications&icon=fusiondirectory&size=48'
,
'plObjectClass'
=>
[
'fdSubscriptionInfo'
],
'plObjectType'
=>
[
'subscriptionInfo'
=>
[
'name'
=>
_
(
'Subscription information'
),
]
],
'plSection'
=>
'conf'
,
'plPriority'
=>
1
,
'plProvidedAcls'
=>
parent
::
generatePlProvidedAcls
(
static
::
getAttributesInfo
()),
];
}
public
static
function
getAttributesInfo
():
array
{
return
[
'stats'
=>
[
'name'
=>
_
(
'Subscription information'
),
'attrs'
=>
[
new
HiddenAttribute
(
'cn'
,
TRUE
,
'subscription'
),
new
DisplayLDAPAttribute
(
_
(
'Type'
),
_
(
'Subscription type'
),
'fdSubscriptionType'
,
TRUE
),
new
DisplayLDAPAttribute
(
_
(
'Contract'
),
_
(
'Contract identifier from Dolibarr'
),
'fdSubscriptionContractId'
,
TRUE
),
new
GeneralizedTimeDisplayAttribute
(
_
(
'Start date'
),
_
(
'Start date of this subscription'
),
'fdSubscriptionStartDate'
,
TRUE
,
''
),
new
GeneralizedTimeDisplayAttribute
(
_
(
'End date'
),
_
(
'End date of this subscription'
),
'fdSubscriptionEndDate'
,
TRUE
,
''
),
new
FileAttribute
(
_
(
'Import'
),
_
(
'Import subscription'
),
'import_file'
,
FALSE
),
new
ButtonAttribute
(
''
,
''
,
'import'
,
_
(
'Import'
),
NULL
,
''
,
'import_file'
),
],
],
];
}
public
function
__construct
(
$dn
=
NULL
,
$object
=
NULL
,
$parent
=
NULL
,
$mainTab
=
FALSE
)
{
parent
::
__construct
(
$dn
,
$object
,
$parent
,
$mainTab
);
$this
->
attributesAccess
[
'import_file'
]
->
setInLdap
(
FALSE
);
$this
->
attributesAccess
[
'import'
]
->
setInLdap
(
FALSE
);
}
public
function
handle_import
()
{
$data
=
$this
->
import_file
;
if
(
empty
(
$data
))
{
/* No file or empty file */
$error
=
new
SimplePluginError
(
$this
->
attributesAccess
[
'import_file'
],
htmlescape
(
_
(
'No data. Did you forgot to upload a file?'
))
);
$error
->
display
();
}
elseif
((
$data
=
parse_ini_string
(
$data
))
===
FALSE
)
{
/* Import of INI failed */
$error
=
new
SimplePluginError
(
$this
->
attributesAccess
[
'import_file'
],
htmlescape
(
_
(
'Failed to parse imported file'
))
);
$error
->
display
();
}
else
{
/* Import data and save it to the LDAP */
foreach
(
static
::
$subscriptionAttributes
as
$attr
)
{
$this
->
attributesAccess
[
$attr
]
->
setValue
(
$data
[
$attr
]
??
''
);
}
$errors
=
$this
->
parent
->
save
();
msg_dialog
::
displayChecks
(
$errors
);
}
/* Avoid double import */
$this
->
import_file
=
''
;
}
public
static
function
mainInc
(
$classname
=
NULL
,
$entry_dn
=
NULL
,
$tabs
=
FALSE
,
$edit_mode
=
FALSE
,
$objectType
=
FALSE
)
{
global
$config
;
if
(
$entry_dn
===
NULL
)
{
$entry_dn
=
'cn=subscription,'
.
get_ou
(
'fusiondirectoryRDN'
)
.
$config
->
current
[
'BASE'
];
}
parent
::
mainInc
(
$classname
,
$entry_dn
,
$tabs
,
$edit_mode
,
$objectType
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets