mirror of
https://github.com/YunoHost-Apps/baikal_ynh.git
synced 2024-09-03 18:16:11 +02:00
commit
01846c7166
341 changed files with 795 additions and 35215 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*~
|
||||
*.sw[po]
|
|
@ -1,4 +0,0 @@
|
|||
How to install.
|
||||
|
||||
Run on yunohost system:
|
||||
> sudo yunohost app install https://github.com/aquaxp/baikal_ynh.git
|
|
@ -1,5 +1,5 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
|
@ -7,17 +7,15 @@
|
|||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
|
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
|
|||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
@ -72,7 +60,7 @@ modification follow.
|
|||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
|
|||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
|
@ -631,44 +629,33 @@ to attach them to the start of each source file to most effectively
|
|||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Baïkal Server, a lightweight CalDAV and CardDAV server.
|
||||
Copyright (C) 2012 Jérôme Schneider
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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.
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Baïkal Server Copyright (C) 2012 Jérôme Schneider
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
18
README.md
18
README.md
|
@ -1,5 +1,17 @@
|
|||
Baïkal for YunoHost
|
||||
----------------------
|
||||
Lightweight CalDAV+CardDAV server
|
||||
-------------------
|
||||
|
||||
http://baikal-server.com/
|
||||
[Baïkal](http://baikal-server.com/) is a Cal and CardDAV server, based on
|
||||
sabre/dav, that includes an administrative interface for easy management.
|
||||
|
||||
**Shipped version:** 0.4.4
|
||||
|
||||
## TODO
|
||||
|
||||
* Update `config.php` and `config.system.php` at upgrade
|
||||
|
||||
## Links ##
|
||||
|
||||
**Baïkal**: http://baikal-server.com/
|
||||
|
||||
**YunoHost**: https://yunohost.org/
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2014 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# (c) 2016 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
|
@ -32,7 +32,7 @@
|
|||
#
|
||||
|
||||
# Timezone of your users, if unsure, check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
define("PROJECT_TIMEZONE", 'YNH_TIMEZONE');
|
||||
define("PROJECT_TIMEZONE", '#TIMEZONE#');
|
||||
|
||||
# CardDAV ON/OFF switch; default TRUE
|
||||
define("BAIKAL_CARD_ENABLED", TRUE);
|
||||
|
@ -48,8 +48,8 @@ define("BAIKAL_DAV_LDAP_URI", 'ldap://127.0.0.1/');
|
|||
|
||||
# Auth Backend LDAP-UserBind; Template for userbind
|
||||
# %n => username
|
||||
# %u => user part of username when it is an email
|
||||
# %u => domain part of username when it is an email
|
||||
# %u => user part of username when it is an email
|
||||
# %u => domain part of username when it is an email
|
||||
define("BAIKAL_DAV_LDAP_DN_TEMPLATE", 'uid=%n,ou=users,dc=yunohost,dc=org');
|
||||
|
||||
# Auth Backend LDAP-UserBind; attribute for displayname
|
||||
|
@ -58,23 +58,5 @@ define("BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR", 'cn');
|
|||
# Auth Backend LDAP-UserBind; attribute for email
|
||||
define("BAIKAL_DAV_LDAP_EMAIL_ATTR", 'mail');
|
||||
|
||||
# Auth Backend Mail; protocol of service
|
||||
define("BAIKAL_DAV_MAIL_PROTOCOL", 'imap');
|
||||
|
||||
# Auth Backend Mail; server host:port
|
||||
define("BAIKAL_DAV_MAIL_SERVER", 'localhost:143');
|
||||
|
||||
# Auth Backend Mail; validate the ssl-certificate
|
||||
define("BAIKAL_DAV_MAIL_CHECK_CERT", TRUE);
|
||||
|
||||
# Auth Backends: automatic creation of users; default yes"
|
||||
define("BAIKAL_DAV_AUTO_CREATE_USER", TRUE);
|
||||
|
||||
# Baïkal Web Admin ON/OFF switch; default TRUE
|
||||
define("BAIKAL_ADMIN_ENABLED", TRUE);
|
||||
|
||||
# Baïkal Web Admin autolock ON/OFF switch; default FALSE
|
||||
define("BAIKAL_ADMIN_AUTOLOCKENABLED", FALSE);
|
||||
|
||||
# Baïkal Web admin password hash; Set via Baïkal Web Admin
|
||||
define("BAIKAL_ADMIN_PASSWORDHASH", 'YNH_ADMIN_PASSWORDHASH');
|
||||
define("BAIKAL_ADMIN_PASSWORDHASH", '#PASSWORDHASH#');
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2014 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# (c) 2016 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
|
@ -35,17 +35,17 @@
|
|||
# 1. All URIs *must* be suffixed by "/" if pointing to a folder
|
||||
#
|
||||
|
||||
# PATH to SabreDAV
|
||||
define("BAIKAL_PATH_SABREDAV", PROJECT_PATH_FRAMEWORKS . "SabreDAV/lib/Sabre/");
|
||||
|
||||
# If you change this value, you'll have to re-generate passwords for all your users
|
||||
define("BAIKAL_AUTH_REALM", 'BaikalDAV');
|
||||
|
||||
# Should begin and end with a "/"
|
||||
define("BAIKAL_CARD_BASEURI", "YNH_LOCATION/card.php/");
|
||||
define("BAIKAL_CARD_BASEURI", "#PATH#/card.php/");
|
||||
|
||||
# Should begin and end with a "/"
|
||||
define("BAIKAL_CAL_BASEURI", "YNH_LOCATION/cal.php/");
|
||||
define("BAIKAL_CAL_BASEURI", "#PATH#/cal.php/");
|
||||
|
||||
# Should begin and end with a "/"
|
||||
define("BAIKAL_DAV_BASEURI", "#PATH#/dav.php/");
|
||||
|
||||
# Define path to Baïkal Database SQLite file
|
||||
define("PROJECT_SQLITE_FILE", PROJECT_PATH_SPECIFIC . "db/db.sqlite");
|
||||
|
@ -57,16 +57,16 @@ define("PROJECT_DB_MYSQL", TRUE);
|
|||
define("PROJECT_DB_MYSQL_HOST", 'localhost');
|
||||
|
||||
# MySQL > Database name
|
||||
define("PROJECT_DB_MYSQL_DBNAME", 'YNH_DBNAME');
|
||||
define("PROJECT_DB_MYSQL_DBNAME", '#DBNAME#');
|
||||
|
||||
# MySQL > Username
|
||||
define("PROJECT_DB_MYSQL_USERNAME", 'YNH_DBUSER');
|
||||
define("PROJECT_DB_MYSQL_USERNAME", '#DBUSER#');
|
||||
|
||||
# MySQL > Password
|
||||
define("PROJECT_DB_MYSQL_PASSWORD", 'YNH_DBPWD');
|
||||
define("PROJECT_DB_MYSQL_PASSWORD", '#DBPASS#');
|
||||
|
||||
# A random 32 bytes key that will be used to encrypt data
|
||||
define("BAIKAL_ENCRYPTION_KEY", 'YNH_ENCRYPTKEY');
|
||||
define("BAIKAL_ENCRYPTION_KEY", '#DESKEY#');
|
||||
|
||||
# The currently configured Baïkal version
|
||||
define("BAIKAL_CONFIGURED_VERSION", '0.2.7');
|
||||
define("BAIKAL_CONFIGURED_VERSION", '0.4.4');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
location PATHTOCHANGE {
|
||||
alias ALIASTOCHANGE;
|
||||
location #LOCATION# {
|
||||
alias #DESTDIR#/html;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ location PATHTOCHANGE {
|
|||
}
|
||||
}
|
||||
|
||||
location /.well-known/carddav {
|
||||
rewrite ^(.*)$ PATHTOCHANGE/card.php redirect;
|
||||
}
|
||||
location /.well-known/caldav {
|
||||
rewrite ^(.*)$ PATHTOCHANGE/cal.php redirect;
|
||||
}
|
||||
|
||||
location ~ ^PATHTOCHANGE/(\.ht|Core|Specific) {
|
||||
deny all;
|
||||
location ~ ^#PATH#/(\.|Core|Specific) {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /.well-known/carddav {
|
||||
rewrite ^(.*)$ #PATH#/card.php redirect;
|
||||
}
|
||||
location /.well-known/caldav {
|
||||
rewrite ^(.*)$ #PATH#/cal.php redirect;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,35 @@
|
|||
{
|
||||
"name": "Baikal",
|
||||
"packaging_format": 1,
|
||||
"id": "baikal",
|
||||
"name": "Baikal",
|
||||
"description": {
|
||||
"en": "Lightweight CalDAV+CardDAV server",
|
||||
"fr": "Serveur CalDAV+CardDAV léger"
|
||||
},
|
||||
"url": "http://baikal-server.com/",
|
||||
"license": "GPL-3",
|
||||
"version": "0.4.4",
|
||||
"maintainer": {
|
||||
"name": "julien",
|
||||
"email": "julien.malik@paraiso.me"
|
||||
},
|
||||
"multi_instance": "true",
|
||||
"multi_instance": false,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.3.16"
|
||||
},
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for baikal"
|
||||
"en": "Choose a domain for Baïkal",
|
||||
"fr": "Choisissez un domaine pour Baïkal"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
|
@ -25,7 +37,8 @@
|
|||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for baikal"
|
||||
"en": "Choose a path for Baïkal",
|
||||
"fr": "Choisissez un chemin pour Baïkal"
|
||||
},
|
||||
"example": "/baikal",
|
||||
"default": "/baikal"
|
||||
|
@ -34,7 +47,8 @@
|
|||
"name": "password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Choose a password for baikal admin"
|
||||
"en": "Set the password for the administration",
|
||||
"fr": "Définissez le mot de passe pour l'administration"
|
||||
},
|
||||
"example": "mysecret"
|
||||
}
|
||||
|
|
317
patches/add-ldap-auth.patch
Normal file
317
patches/add-ldap-auth.patch
Normal file
|
@ -0,0 +1,317 @@
|
|||
--- /dev/null
|
||||
+++ b/Core/Frameworks/Baikal/Core/AbstractExternalAuth.php
|
||||
@@ -0,0 +1,130 @@
|
||||
+<?php
|
||||
+
|
||||
+namespace Baikal\Core;
|
||||
+
|
||||
+/**
|
||||
+ * This is an abstract authentication, that allows to create external
|
||||
+ * authentication backends. User are automatic created, when the does not exists
|
||||
+ * in baikal (can disabled).
|
||||
+ *
|
||||
+ * @author Sascha Kuehndel (InuSasha) <dev@inusasha.de>
|
||||
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
+ */
|
||||
+abstract class AbstractExternalAuth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
|
||||
+
|
||||
+ /**
|
||||
+ * enable autocreation of user
|
||||
+ *
|
||||
+ * @var PDO
|
||||
+ */
|
||||
+ protected $enableAutoCreation;
|
||||
+
|
||||
+ /**
|
||||
+ * Reference to PDO connection
|
||||
+ *
|
||||
+ * @var PDO
|
||||
+ */
|
||||
+ private $pdo;
|
||||
+
|
||||
+ /**
|
||||
+ * PDO table name we'll be using
|
||||
+ *
|
||||
+ * @var string
|
||||
+ */
|
||||
+ private $tableName;
|
||||
+
|
||||
+ /**
|
||||
+ * Creates the backend object.
|
||||
+ *
|
||||
+ * If the filename argument is passed in, it will parse out the specified file fist.
|
||||
+ *
|
||||
+ * @param PDO $pdo
|
||||
+ * @param string $realm
|
||||
+ * @param string $tableName The PDO table name to use
|
||||
+ */
|
||||
+ public function __construct(\PDO $pdo, $realm = 'BaikalDAV', $tableName = 'users') {
|
||||
+
|
||||
+ $this->pdo = $pdo;
|
||||
+ $this->tableName = $tableName;
|
||||
+ $this->enableAutoCreation = true;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Validates a username and password
|
||||
+ *
|
||||
+ * This method should return true or false depending on if login
|
||||
+ * succeeded.
|
||||
+ *
|
||||
+ * @param string $username
|
||||
+ * @param string $password
|
||||
+ * @return bool
|
||||
+ */
|
||||
+ public function validateUserPass($username, $password) {
|
||||
+
|
||||
+ if (!$this->validateUserPassExternal($username, $password))
|
||||
+ return false;
|
||||
+
|
||||
+ $this->currentUser = $username;
|
||||
+ if ($this->enableAutoCreation)
|
||||
+ $this->autoUserCreation($username);
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Validates a username and password agains external backend
|
||||
+ *
|
||||
+ * This method should return true or false depending on if login
|
||||
+ * succeeded.
|
||||
+ *
|
||||
+ * @param string $username
|
||||
+ * @param string $password
|
||||
+ * @return bool
|
||||
+ */
|
||||
+ public abstract function validateUserPassExternal($username, $password);
|
||||
+
|
||||
+ /**
|
||||
+ * return the displayname and email from the external Backend
|
||||
+ *
|
||||
+ * @param string $username
|
||||
+ * @return array ('displayname' => string, 'email' => string)
|
||||
+ */
|
||||
+ public function getAccountValues($username) {
|
||||
+
|
||||
+ return array();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * create an internal user, when user not exists
|
||||
+ *
|
||||
+ * @param string $username
|
||||
+ */
|
||||
+ private function autoUserCreation($username) {
|
||||
+
|
||||
+ /* search user in DB and do nothing, when user exists */
|
||||
+ $stmt = $this->pdo->prepare('SELECT username FROM '.$this->tableName.' WHERE username = ?');
|
||||
+ $stmt->execute(array($username));
|
||||
+ $result = $stmt->fetchAll();
|
||||
+ if (count($result) != 0)
|
||||
+ return;
|
||||
+
|
||||
+ /* get account values from backend */
|
||||
+ $values = $this->getAccountValues($username);
|
||||
+ if (!isset($values['displayname']) OR strlen($values['displayname']) === 0)
|
||||
+ $values['displayname'] = $username;
|
||||
+ if (!isset($values['email']) OR strlen($values['email']) === 0) {
|
||||
+ if(filter_var($username, FILTER_VALIDATE_EMAIL))
|
||||
+ $values['email'] = $username;
|
||||
+ else
|
||||
+ $values['email'] = 'unset-mail';
|
||||
+ }
|
||||
+
|
||||
+ /* create user */
|
||||
+ $user = new \Baikal\Model\User();
|
||||
+ $user->set('username', $username);
|
||||
+ $user->set('displayname', $values['displayname']);
|
||||
+ $user->set('email', $values['email']);
|
||||
+ $user->persist();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/Core/Frameworks/Baikal/Core/LDAPUserBindAuth.php
|
||||
@@ -0,0 +1,75 @@
|
||||
+<?php
|
||||
+
|
||||
+namespace Baikal\Core;
|
||||
+
|
||||
+/**
|
||||
+ * This is an authentication backend that uses a ldap backend to authenticate user.
|
||||
+ *
|
||||
+ * @author Sascha Kuehndel (InuSasha) <dev@inusasha.de>
|
||||
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
+ */
|
||||
+class LDAPUserBindAuth extends AbstractExternalAuth {
|
||||
+
|
||||
+ /**
|
||||
+ * AccountValues for getAccountValues
|
||||
+ *
|
||||
+ * @var array ('displayname' => string, 'email' => string)
|
||||
+ */
|
||||
+ private $accountValues;
|
||||
+
|
||||
+ /**
|
||||
+ * Validates a username and password over ldap
|
||||
+ *
|
||||
+ * @param string $username
|
||||
+ * @param string $password
|
||||
+ * @return bool
|
||||
+ */
|
||||
+ public function validateUserPassExternal($username, $password) {
|
||||
+
|
||||
+ /* create ldap connection */
|
||||
+ $conn = ldap_connect(BAIKAL_DAV_LDAP_URI);
|
||||
+ if (!$conn)
|
||||
+ return false;
|
||||
+ if (!ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3))
|
||||
+ return false;
|
||||
+
|
||||
+ /* bind with user
|
||||
+ * error_handler have to change, because a failed bind raises an error
|
||||
+ * this raise a secuity issue because in the stack trace is the password of user readable
|
||||
+ */
|
||||
+ $arr = explode('@', $username, 2);
|
||||
+ $dn = str_replace('%n', $username, BAIKAL_DAV_LDAP_DN_TEMPLATE);
|
||||
+ $dn = str_replace('%u', $arr[0], $dn);
|
||||
+ if(isset($arr[1])) $dn = str_replace('%d', $arr[1], $dn);
|
||||
+
|
||||
+ set_error_handler("\Baikal\Core\LDAPUserBindAuth::exception_error_handler");
|
||||
+ $bind = ldap_bind($conn, $dn, $password);
|
||||
+ restore_error_handler();
|
||||
+ if (!$bind) {
|
||||
+ ldap_close($conn);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ /* read displayname and email from user */
|
||||
+ $this->accountValues = array();
|
||||
+ $sr = ldap_read($conn, $dn, '(objectclass=*)', array(BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR, BAIKAL_DAV_LDAP_EMAIL_ATTR));
|
||||
+ $entry = ldap_get_entries($conn, $sr);
|
||||
+ if (isset($entry[0][BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR][0]))
|
||||
+ $this->accountValues['displayname'] = $entry[0][BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR][0];
|
||||
+ if (isset($entry[0][BAIKAL_DAV_LDAP_EMAIL_ATTR][0]))
|
||||
+ $this->accountValues['email'] = $entry[0][BAIKAL_DAV_LDAP_EMAIL_ATTR][0];
|
||||
+
|
||||
+ /* close */
|
||||
+ ldap_close($conn);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ public function getAccountValues($username) {
|
||||
+
|
||||
+ return $this->accountValues;
|
||||
+ }
|
||||
+
|
||||
+ # WorkAround error_handler in failed bind of LDAP
|
||||
+ public static function exception_error_handler($errno, $errstr, $errfile, $errline) {
|
||||
+ }
|
||||
+}
|
||||
diff --git a/Core/Frameworks/Baikal/Core/Server.php b/Core/Frameworks/Baikal/Core/Server.php
|
||||
index 8026854..8d306fe 100644
|
||||
--- a/Core/Frameworks/Baikal/Core/Server.php
|
||||
+++ b/Core/Frameworks/Baikal/Core/Server.php
|
||||
@@ -133,6 +133,8 @@ class Server {
|
||||
|
||||
if ($this->authType === 'Basic') {
|
||||
$authBackend = new \Baikal\Core\PDOBasicAuth($this->pdo, $this->authRealm);
|
||||
+ } elseif ($this->authType === 'LDAP-UserBind') {
|
||||
+ $authBackend = new \Baikal\Core\LDAPUserBindAuth($this->pdo, $this->authRealm);
|
||||
} else {
|
||||
$authBackend = new \Sabre\DAV\Auth\Backend\PDO($this->pdo);
|
||||
$authBackend->setRealm($this->authRealm);
|
||||
diff --git a/Core/Frameworks/Baikal/Model/Config/Standard.php b/Core/Frameworks/Baikal/Model/Config/Standard.php
|
||||
index 6107377..39f90bd 100644
|
||||
--- a/Core/Frameworks/Baikal/Model/Config/Standard.php
|
||||
+++ b/Core/Frameworks/Baikal/Model/Config/Standard.php
|
||||
@@ -46,6 +46,22 @@ class Standard extends \Baikal\Model\Config {
|
||||
"type" => "string",
|
||||
"comment" => "HTTP authentication type for WebDAV; default Digest"
|
||||
],
|
||||
+ "BAIKAL_DAV_LDAP_URI" => [
|
||||
+ "type" => "string",
|
||||
+ "comment" => "URI to LDAP Server (for ldap-userbind auth); default ldapi:///"
|
||||
+ ],
|
||||
+ "BAIKAL_DAV_LDAP_DN_TEMPLATE" => [
|
||||
+ "type" => "string",
|
||||
+ "comment" => "User DN for bind; with replacments %n => username, %u => user part, %d => domain part of username"
|
||||
+ ],
|
||||
+ "BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR" => [
|
||||
+ "type" => "string",
|
||||
+ "comment" => "LDAP-attribute for displayname; default cn"
|
||||
+ ],
|
||||
+ "BAIKAL_DAV_LDAP_EMAIL_ATTR" => [
|
||||
+ "type" => "string",
|
||||
+ "comment" => "LDAP-attribute for email; default mail"
|
||||
+ ],
|
||||
"BAIKAL_ADMIN_PASSWORDHASH" => [
|
||||
"type" => "string",
|
||||
"comment" => "Baïkal Web admin password hash; Set via Baïkal Web Admin",
|
||||
@@ -58,6 +74,10 @@ class Standard extends \Baikal\Model\Config {
|
||||
"BAIKAL_CARD_ENABLED" => true,
|
||||
"BAIKAL_CAL_ENABLED" => true,
|
||||
"BAIKAL_DAV_AUTH_TYPE" => "Digest",
|
||||
+ "BAIKAL_DAV_LDAP_URI" => "ldapi:///",
|
||||
+ "BAIKAL_DAV_LDAP_DN_TEMPLATE" => "uid=%n,dc=example,dc=com",
|
||||
+ "BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR" => "cn",
|
||||
+ "BAIKAL_DAV_LDAP_EMAIL_ATTR" => "mail",
|
||||
"BAIKAL_ADMIN_PASSWORDHASH" => ""
|
||||
];
|
||||
|
||||
@@ -85,7 +105,31 @@ class Standard extends \Baikal\Model\Config {
|
||||
$oMorpho->add(new \Formal\Element\Listbox([
|
||||
"prop" => "BAIKAL_DAV_AUTH_TYPE",
|
||||
"label" => "WebDAV authentication type",
|
||||
- "options" => [ "Digest", "Basic" ]
|
||||
+ "options" => [ "Digest", "Basic", "LDAP-UserBind" ]
|
||||
+ ]));
|
||||
+
|
||||
+ $oMorpho->add(new \Formal\Element\Text([
|
||||
+ "prop" => "BAIKAL_DAV_LDAP_URI",
|
||||
+ "label" => "LDAP URI"
|
||||
+ ]));
|
||||
+
|
||||
+ $oMorpho->add(new \Formal\Element\Text([
|
||||
+ "prop" => "BAIKAL_DAV_LDAP_DN_TEMPLATE",
|
||||
+ "label" => "LDAP DN template",
|
||||
+ "popover" => [
|
||||
+ "title" => "posible placeholder",
|
||||
+ "content" => "<strong>%n</strong> - username<br /><strong>%u</strong> - user part of username , when it is an email address)<br /><strong>%d</strong> - domain part",
|
||||
+ ]
|
||||
+ ]));
|
||||
+
|
||||
+ $oMorpho->add(new \Formal\Element\Text([
|
||||
+ "prop" => "BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR",
|
||||
+ "label" => "LDAP attribute for DisplayName"
|
||||
+ ]));
|
||||
+
|
||||
+ $oMorpho->add(new \Formal\Element\Text([
|
||||
+ "prop" => "BAIKAL_DAV_LDAP_EMAIL_ATTR",
|
||||
+ "label" => "LDAP attribute for eMail"
|
||||
]));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password([
|
||||
@@ -180,6 +224,21 @@ define("BAIKAL_CAL_ENABLED", TRUE);
|
||||
# WebDAV authentication type; default Digest
|
||||
define("BAIKAL_DAV_AUTH_TYPE", "Digest");
|
||||
|
||||
+# Auth Backend LDAP-UserBind; LDAP URI
|
||||
+define("BAIKAL_DAV_LDAP_URI", 'ldapi:///');
|
||||
+
|
||||
+# Auth Backend LDAP-UserBind; Template for userbind
|
||||
+# %n => username
|
||||
+# %u => user part of username when it is an email
|
||||
+# %u => domain part of username when it is an email
|
||||
+define("BAIKAL_DAV_LDAP_DN_TEMPLATE", 'cn=%u,dc=%d,ou=domains,o=server');
|
||||
+
|
||||
+# Auth Backend LDAP-UserBind; attribute for displayname
|
||||
+define("BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR", 'cn');
|
||||
+
|
||||
+# Auth Backend LDAP-UserBind; attribute for email
|
||||
+define("BAIKAL_DAV_LDAP_EMAIL_ATTR", 'mail');
|
||||
+
|
||||
# Baïkal Web admin password hash; Set via Baïkal Web Admin
|
||||
define("BAIKAL_ADMIN_PASSWORDHASH", "");
|
||||
CODE;
|
43
scripts/_common.sh
Normal file
43
scripts/_common.sh
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# Common variables
|
||||
#
|
||||
|
||||
# Baikal version
|
||||
VERSION=0.4.4
|
||||
|
||||
# Baikal source archive checksum
|
||||
BAIKAL_SOURCE_SHA256="cced612353862bce532ed458eda0675b5e1e5790f92969bf13992c6567943efc"
|
||||
|
||||
# Remote URL to fetch Baikal source archive
|
||||
BAIKAL_SOURCE_URL="https://github.com/fruux/Baikal/releases/download/${VERSION}/baikal-${VERSION}.zip"
|
||||
|
||||
# App package root directory should be the parent folder
|
||||
PKGDIR=$(cd ../; pwd)
|
||||
|
||||
#
|
||||
# Common helpers
|
||||
#
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Download and extract Baikal sources to the given directory
|
||||
# usage: extract_baikal DESTDIR
|
||||
extract_baikal() {
|
||||
local DESTDIR=$1
|
||||
local bk_archive="${DESTDIR}/baikal.zip"
|
||||
|
||||
wget -q -O "$bk_archive" "$BAIKAL_SOURCE_URL" \
|
||||
|| ynh_die "Unable to download Baikal archive"
|
||||
echo "$BAIKAL_SOURCE_SHA256 $bk_archive" | sha256sum -c >/dev/null \
|
||||
|| ynh_die "Invalid checksum of downloaded archive"
|
||||
unzip -q "$bk_archive" -d "$DESTDIR" \
|
||||
|| ynh_die "Unable to extract Baikal archive"
|
||||
mv "${DESTDIR}/baikal/"* "$DESTDIR"
|
||||
rm -rf "$bk_archive" "${DESTDIR}/baikal"
|
||||
|
||||
# apply patches
|
||||
(cd "$DESTDIR" \
|
||||
&& for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \
|
||||
|| die "Unable to apply patches to Baikal"
|
||||
}
|
27
scripts/backup
Normal file
27
scripts/backup
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
backup_dir=$1
|
||||
app=$2
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
# Copy the app files
|
||||
DESTDIR="/var/www/$app"
|
||||
ynh_backup "$DESTDIR" "sources"
|
||||
|
||||
# Copy the conf files
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||
|
||||
# Dump the database
|
||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
113
scripts/install
113
scripts/install
|
@ -1,65 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
path=${2%/}
|
||||
password=$3
|
||||
app=${!#}
|
||||
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a baikal
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
|
||||
# Install PHP dependency
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y php5-cli
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/${app}"
|
||||
[[ -d "$DESTDIR" ]] && ynh_die \
|
||||
"The destination directory '${DESTDIR}' already exists.\
|
||||
You should safely delete it before installing this app."
|
||||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/baikal
|
||||
# Create tmp directory and fetch app inside
|
||||
TMPDIR=$(ynh_mkdir_tmp)
|
||||
extract_baikal "$TMPDIR"
|
||||
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -a ../sources/* $final_path
|
||||
sudo chown -R www-data: $final_path
|
||||
sudo su -c "curl -sS https://getcomposer.org/installer | php -- --install-dir=$final_path" www-data
|
||||
sudo su -c "cd $final_path && php composer.phar install" www-data
|
||||
sudo rm $final_path/composer*
|
||||
# Generate random DES key & password
|
||||
deskey=$(ynh_string_random 24)
|
||||
dbpass=$(ynh_string_random)
|
||||
|
||||
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||
db_user=baikal
|
||||
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/Core/Resources/Db/MySQL/db.sql)
|
||||
sudo yunohost app setting baikal mysqlpwd -v $db_pwd
|
||||
sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
sed -i "s@YNH_ADMIN_PASSWORDHASH@$(echo -n admin:BaikalDAV:$password | md5sum | cut -d ' ' -f 1)@g" ../conf/config.php
|
||||
sudo yunohost app setting baikal password -v $password
|
||||
# Initialize database
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
|
||||
< "${TMPDIR}/Core/Resources/Db/MySQL/db.sql"
|
||||
|
||||
sed -i "s@YNH_LOCATION@$path@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBNAME@$db_user@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBUSER@$db_user@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBPWD@$db_pwd@g" ../conf/config.system.php
|
||||
encrypt_key=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{32\}\).*/\1/p')
|
||||
sudo yunohost app setting baikal encrypt_key -v $encrypt_key
|
||||
sed -i "s@YNH_ENCRYPTKEY@$encrypt_key@g" ../conf/config.system.php
|
||||
# Create admin password hash
|
||||
password_hash=$(echo -n admin:BaikalDAV:$password | md5sum | cut -d ' ' -f 1)
|
||||
|
||||
sudo cp ../conf/config.php $final_path/Specific
|
||||
sudo cp ../conf/config.system.php $final_path/Specific
|
||||
# Copy and set Baikal configuration
|
||||
bk_conf="${TMPDIR}/Specific/config.php"
|
||||
cp ../conf/config.php "$bk_conf"
|
||||
sed -i "s@#TIMEZONE#@$(cat /etc/timezone)@g" "$bk_conf"
|
||||
sed -i "s@#PASSWORDHASH#@${password_hash}@g" "$bk_conf"
|
||||
|
||||
sudo chown -R root: $final_path
|
||||
sudo chown -R www-data: $final_path/Specific
|
||||
sudo find $final_path -type f | xargs sudo chmod 644
|
||||
sudo find $final_path -type d | xargs sudo chmod 755
|
||||
bk_conf="${TMPDIR}/Specific/config.system.php"
|
||||
cp ../conf/config.system.php "$bk_conf"
|
||||
sed -i "s@#PATH#@${path}@g" "$bk_conf"
|
||||
sed -i "s@#DBNAME#@${dbname}@g" "$bk_conf"
|
||||
sed -i "s@#DBUSER#@${dbuser}@g" "$bk_conf"
|
||||
sed -i "s@#DBPASS#@${dbpass}@g" "$bk_conf"
|
||||
sed -i "s@#DESKEY#@${deskey}@g" "$bk_conf"
|
||||
|
||||
# Change variables in Baikal configuration
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$final_path/html@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
sudo chown root: /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
sudo chmod 600 /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
# Disable installation
|
||||
touch "${TMPDIR}/Specific/INSTALL_DISABLED"
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app setting baikal skipped_uris -v "/"
|
||||
sudo yunohost app ssowatconf
|
||||
# Install files and set permissions
|
||||
sudo mv "$TMPDIR" "$DESTDIR"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
|
||||
# Remove ENABLE_INSTALL for more Security
|
||||
sudo rm $final_path/Specific/ENABLE_INSTALL
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
|
||||
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
|
||||
# Save app settings
|
||||
ynh_app_setting_set "$app" password "$password"
|
||||
ynh_app_setting_set "$app" encrypt_key "$deskey"
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
|
||||
# Set SSOwat rules
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
ynh_app_setting_set "$app" protected_uris "/admin/"
|
||||
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
db_user=baikal
|
||||
db_name=baikal
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
||||
# Retrieve arguments
|
||||
app=${!#}
|
||||
|
||||
# Removing executable files
|
||||
sudo rm -rf /var/www/baikal
|
||||
domain=$(sudo yunohost app setting baikal domain)
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
|
||||
# Restarting services
|
||||
sudo service nginx reload
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Drop MySQL database and user
|
||||
ynh_mysql_drop_db $dbname || true
|
||||
ynh_mysql_drop_user $dbuser || true
|
||||
|
||||
# Retrieve domain from app settings
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
|
|
47
scripts/restore
Normal file
47
scripts/restore
Normal file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
backup_dir=$1
|
||||
app=$2
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' already exists.\
|
||||
You should safely delete it before restoring this app."
|
||||
|
||||
# Check configuration files
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
[[ -f $nginx_conf ]] && ynh_die \
|
||||
"The NGINX configuration already exists at '${nginx_conf}'.
|
||||
You should safely delete it before restoring this app."
|
||||
|
||||
# Restore the app files and set permissions
|
||||
sudo cp -a ./sources "$DESTDIR"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
|
||||
# Create and restore the database
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
|
||||
|
||||
# Restore configuration files
|
||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
||||
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
124
scripts/upgrade
124
scripts/upgrade
|
@ -1,90 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting baikal domain)
|
||||
path=$(sudo yunohost app setting baikal path)
|
||||
password=$(sudo yunohost app setting baikal password)
|
||||
set -u
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
# Load common variables and helpers
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
app=${!#}
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
path=${path%/}
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ ! -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' does not exist.\
|
||||
The app is not correctly installed, you should remove it first."
|
||||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/baikal
|
||||
# Create tmp directory and fetch new app inside
|
||||
TMPDIR=$(ynh_mkdir_tmp)
|
||||
extract_baikal "$TMPDIR"
|
||||
|
||||
# let's not use a bash variable for this one...
|
||||
sudo rm -rf /var/www/baikal
|
||||
# Get Specific folder from current installation
|
||||
# FIXME: config.php and config.system.php are not updated with possible
|
||||
# new or changed configurations
|
||||
rm -rf "${TMPDIR}/Specific"
|
||||
sudo cp -r "${DESTDIR}/Specific" "$TMPDIR"
|
||||
sudo chown -hR "${USER}" "${TMPDIR}/Specific"
|
||||
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -a ../sources/* $final_path
|
||||
sudo chown -R www-data: $final_path
|
||||
sudo su -c "curl -sS https://getcomposer.org/installer | php -- --install-dir=$final_path" www-data
|
||||
sudo su -c "cd $final_path && php composer.phar install" www-data
|
||||
sudo rm $final_path/composer*
|
||||
# Run Baikal upgrade from tmp directory
|
||||
cp -r ../sources/bin "$TMPDIR"
|
||||
php "${TMPDIR}/bin/upgrade.sh" \
|
||||
|| echo "The Baïkal upgrade failed, you should try to go to " \
|
||||
"https://${domain}${path}/admin/install"
|
||||
|
||||
db_pwd=$(sudo yunohost app setting baikal mysqlpwd)
|
||||
db_user=baikal
|
||||
sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.php
|
||||
sed -i "s@YNH_ADMIN_PASSWORDHASH@$(echo -n admin:BaikalDAV:$password | md5sum | cut -d ' ' -f 1)@g" ../conf/config.php
|
||||
# Install new app and set permissions
|
||||
sudo rm -rf "$DESTDIR"
|
||||
sudo mv "$TMPDIR" "$DESTDIR"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
|
||||
sed -i "s@YNH_LOCATION@$path@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBNAME@$db_user@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBUSER@$db_user@g" ../conf/config.system.php
|
||||
sed -i "s@YNH_DBPWD@$db_pwd@g" ../conf/config.system.php
|
||||
encrypt_key=$(sudo yunohost app setting baikal encrypt_key)
|
||||
sed -i "s@YNH_ENCRYPTKEY@$encrypt_key@g" ../conf/config.system.php
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
|
||||
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
|
||||
sudo cp ../conf/config.php $final_path/Specific
|
||||
sudo cp ../conf/config.system.php $final_path/Specific
|
||||
# Set SSOwat rules
|
||||
ynh_app_setting_set "$app" skipped_uris "/"
|
||||
ynh_app_setting_set "$app" protected_uris "/admin/"
|
||||
|
||||
sudo chown -R root: $final_path
|
||||
sudo chown -R www-data: $final_path/Specific
|
||||
sudo find $final_path -type f | xargs sudo chmod 644
|
||||
sudo find $final_path -type d | xargs sudo chmod 755
|
||||
|
||||
# Change variables in Baikal configuration
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@ALIASTOCHANGE@$final_path/html@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
sudo chown root: /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
sudo chmod 600 /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app setting baikal skipped_uris -v "/"
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
|
||||
#
|
||||
# # Backuping db
|
||||
# backup_path=/var/cache/yunohost/backups/baikal
|
||||
# final_path=/var/www/baikal/
|
||||
#
|
||||
# mkdir -p $backup_path
|
||||
# sudo cp -a $final_path/Specific/* $backup_path
|
||||
#
|
||||
# # Copy files to the right place
|
||||
# sudo mkdir -p $final_path
|
||||
# sudo cp -a ../sources/* $final_path
|
||||
# sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
# sudo chown -R www-data:www-data $final_path
|
||||
# sudo find $final_path -type d -exec chmod 755 {} \;
|
||||
# sudo touch $final_path/Specific/ENABLE_INSTALL
|
||||
# #sudo chmod 755 $final_path/Specific
|
||||
# #sudo chmod 755 $final_path/Specific/db
|
||||
# #sudo chmod 755 $final_path/Specific/db/db.sqlite
|
||||
#
|
||||
# # Change variables in Baikal configuration
|
||||
# sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
# sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/baikal.conf
|
||||
#
|
||||
# sudo sed -i "s@PROJECT_BASEURI_@\"$path/\"@g" $final_path/Core/Frameworks/Baikal/Model/Config/System.php
|
||||
#
|
||||
# # Restoring backup
|
||||
# sudo cp -a $backup_path/* $final_path/Specific
|
||||
#
|
||||
# # Reload Nginx and regenerate SSOwat conf
|
||||
# sudo service php5-fpm restart
|
||||
# sudo service nginx reload
|
||||
# sudo yunohost app setting baikal skipped_uris -v "/"
|
||||
# sudo yunohost app ssowatconf
|
||||
# Reload services
|
||||
sudo service nginx reload || true
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# 0.2.5
|
||||
|
||||
Upgraded SabreDAV from 1.8.0 to 1.8.6
|
||||
Baïkal releases are now based on composer thanks to @evert
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
define("BAIKAL_VERSION", "0.2.7");
|
||||
define("BAIKAL_HOMEPAGE", "http://baikal-server.com");
|
||||
define("PROJECT_PACKAGE", "regular");
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Baikal\Core;
|
||||
|
||||
/**
|
||||
* This is an abstract authentication, that allows to create external
|
||||
* authentication backends. User are automatic created, when the does not exists
|
||||
* in baikal (can disabled).
|
||||
*
|
||||
* @author Sascha Kuehndel (InuSasha) <dev@inusasha.de>
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class AbstractExternalAuth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
|
||||
|
||||
/**
|
||||
* enable autocreation of user
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $enableAutoCreation;
|
||||
|
||||
/**
|
||||
* Reference to PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
private $pdo;
|
||||
|
||||
/**
|
||||
* PDO table name we'll be using
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tableName;
|
||||
|
||||
/**
|
||||
* Creates the backend object.
|
||||
*
|
||||
* If the filename argument is passed in, it will parse out the specified file fist.
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* @param string $realm
|
||||
* @param string $tableName The PDO table name to use
|
||||
*/
|
||||
public function __construct(\PDO $pdo, $realm = 'BaikalDAV', $tableName = 'users') {
|
||||
|
||||
$this->pdo = $pdo;
|
||||
$this->tableName = $tableName;
|
||||
$this->enableAutoCreation = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a username and password
|
||||
*
|
||||
* This method should return true or false depending on if login
|
||||
* succeeded.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUserPass($username, $password) {
|
||||
|
||||
/* auth user agains backend */
|
||||
if (!$this->validateUserPassExternal($username, $password))
|
||||
return false;
|
||||
|
||||
/* check user exists already */
|
||||
$stmt = $this->pdo->prepare('SELECT username FROM '.$this->tableName.' WHERE username = ?');
|
||||
$stmt->execute(array($username));
|
||||
$result = $stmt->fetchAll();
|
||||
if( count($result) == 1) {
|
||||
$this->currentUser = $username;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* failed login, when new user should not create */
|
||||
if( !BAIKAL_DAV_AUTO_CREATE_USER || !$this->enableAutoCreation)
|
||||
return false;
|
||||
|
||||
/* create user */
|
||||
$this->autoUserCreation($username);
|
||||
$this->currentUser = $username;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a username and password agains external backend
|
||||
*
|
||||
* This method should return true or false depending on if login
|
||||
* succeeded.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public abstract function validateUserPassExternal($username, $password);
|
||||
|
||||
/**
|
||||
* return the displayname and email from the external Backend
|
||||
*
|
||||
* @param string $username
|
||||
* @return array ('displayname' => string, 'email' => string)
|
||||
*/
|
||||
public function getAccountValues($username) {
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* create an internal user, when user not exists
|
||||
*
|
||||
* @param string $username
|
||||
*/
|
||||
private function autoUserCreation($username) {
|
||||
|
||||
/* get account values from backend */
|
||||
$values = $this->getAccountValues($username);
|
||||
if (!isset($values['displayname']) OR strlen($values['displayname']) === 0)
|
||||
$values['displayname'] = $username;
|
||||
if (!isset($values['email']) OR strlen($values['email']) === 0) {
|
||||
if(filter_var($username, FILTER_VALIDATE_EMAIL))
|
||||
$values['email'] = $username;
|
||||
else
|
||||
$values['email'] = 'unset-mail';
|
||||
}
|
||||
|
||||
/* create user */
|
||||
$user = new \Baikal\Model\User();
|
||||
$user->set('username', $username);
|
||||
$user->set('displayname', $values['displayname']);
|
||||
$user->set('email', $values['email']);
|
||||
$user->persist();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Baikal\Core;
|
||||
|
||||
/**
|
||||
* This is an authentication backend that uses a ldap backend to authenticate user.
|
||||
*
|
||||
* @author Sascha Kuehndel (InuSasha) <dev@inusasha.de>
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class LDAPUserBindAuth extends AbstractExternalAuth {
|
||||
|
||||
/**
|
||||
* AccountValues for getAccountValues
|
||||
*
|
||||
* @var array ('displayname' => string, 'email' => string)
|
||||
*/
|
||||
private $accountValues;
|
||||
|
||||
/**
|
||||
* Validates a username and password over ldap
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUserPassExternal($username, $password) {
|
||||
|
||||
/* create ldap connection */
|
||||
$conn = ldap_connect(BAIKAL_DAV_LDAP_URI);
|
||||
if (!$conn)
|
||||
return false;
|
||||
if (!ldap_set_option($conn,LDAP_OPT_PROTOCOL_VERSION,3))
|
||||
return false;
|
||||
|
||||
/* bind with user
|
||||
* error_handler have to change, because a failed bind raises an error
|
||||
* this raise a secuity issue because in the stack trace is the password of user readable
|
||||
*/
|
||||
$arr = explode('@', $username, 2);
|
||||
$dn = str_replace('%n', $username, BAIKAL_DAV_LDAP_DN_TEMPLATE);
|
||||
$dn = str_replace('%u', $arr[0], $dn);
|
||||
if(isset($arr[1])) $dn = str_replace('%d', $arr[1], $dn);
|
||||
|
||||
set_error_handler("\Baikal\Core\LDAPUserBindAuth::exception_error_handler");
|
||||
$bind = ldap_bind($conn, $dn, $password);
|
||||
restore_error_handler();
|
||||
if (!$bind) {
|
||||
ldap_close($conn);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* read displayname and email from user */
|
||||
$this->accountValues = array();
|
||||
$sr = ldap_read($conn, $dn, '(objectclass=*)', array(BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR,BAIKAL_DAV_LDAP_EMAIL_ATTR));
|
||||
$entry = ldap_get_entries($conn, $sr);
|
||||
if (isset($entry[0][BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR][0]))
|
||||
$this->accountValues['displayname'] = $entry[0][BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR][0];
|
||||
if (isset($entry[0][BAIKAL_DAV_LDAP_EMAIL_ATTR][0]))
|
||||
$this->accountValues['email'] = $entry[0][BAIKAL_DAV_LDAP_EMAIL_ATTR][0];
|
||||
|
||||
/* close */
|
||||
ldap_close($conn);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getAccountValues($username) {
|
||||
|
||||
return $this->accountValues;
|
||||
}
|
||||
|
||||
# WorkAround error_handler in failed bind of LDAP
|
||||
public static function exception_error_handler($errno, $errstr, $errfile, $errline) {
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Baikal\Core;
|
||||
|
||||
/**
|
||||
* This is an authentication backend that uses a pop3, imap or smtp backend to authenticate user.
|
||||
*
|
||||
* @author Sascha Kuehndel (InuSasha) <dev@inusasha.de>
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class MailAuth extends AbstractExternalAuth {
|
||||
|
||||
/**
|
||||
* Validates a username and password over ldap
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUserPassExternal($username, $password) {
|
||||
|
||||
/* build connection string */
|
||||
$cert = BAIKAL_DAV_MAIL_CHECK_CERT ? "/validate-cert" : "/novalidate-cert";
|
||||
$url = "";
|
||||
switch(BAIKAL_DAV_MAIL_PROTOCOL) {
|
||||
case "imap": $url = "{".BAIKAL_DAV_MAIL_SERVER."/imap/notls}INBOX"; break;
|
||||
case "imaps": $url = "{".BAIKAL_DAV_MAIL_SERVER."/imap/ssl${cert}}INBOX"; break;
|
||||
case "imaptls": $url = "{".BAIKAL_DAV_MAIL_SERVER."/imap/tls${cert}}INBOX"; break;
|
||||
case "pop3": $url = "{".BAIKAL_DAV_MAIL_SERVER."/pop3/notls}"; break;
|
||||
case "pop3s": $url = "{".BAIKAL_DAV_MAIL_SERVER."/pop3/ssl${cert}}"; break;
|
||||
case "pop3tls": $url = "{".BAIKAL_DAV_MAIL_SERVER."/pop3/tls${cert}}"; break;
|
||||
case "smtp": $url = "{".BAIKAL_DAV_MAIL_SERVER."/smtp/notls}"; break;
|
||||
case "smtps": $url = "{".BAIKAL_DAV_MAIL_SERVER."/smtp/ssl${cert}}"; break;
|
||||
case "smtptls": $url = "{".BAIKAL_DAV_MAIL_SERVER."/smtp/tls${cert}}"; break;
|
||||
}
|
||||
|
||||
/* connect to mail server (only one try) */
|
||||
set_error_handler("\Baikal\Core\MailAuth::exception_error_handler");
|
||||
$conn = imap_open($url, $username, $password, NULL, 0);
|
||||
restore_error_handler();
|
||||
if (!$conn)
|
||||
return false;
|
||||
|
||||
/* skip notices, warnings and errors */
|
||||
imap_errors();
|
||||
|
||||
/* close */
|
||||
imap_close($conn);
|
||||
return true;
|
||||
}
|
||||
|
||||
# WorkAround error_handler in failed login in imap_open
|
||||
public static function exception_error_handler($errno, $errstr, $errfile, $errline) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Baikal\Core;
|
||||
|
||||
/**
|
||||
* This is an authentication backend that uses a database to manage passwords.
|
||||
*
|
||||
* Format of the database tables must match to the one of \Sabre\DAV\Auth\Backend\PDO
|
||||
*
|
||||
* @copyright Copyright (C) 2013 Lukasz Janyst. All rights reserved.
|
||||
* @author Lukasz Janyst <ljanyst@buggybrain.net>
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class PDOBasicAuth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
|
||||
|
||||
/**
|
||||
* Reference to PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* PDO table name we'll be using
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tableName;
|
||||
|
||||
/**
|
||||
* Authentication realm
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $authRealm;
|
||||
|
||||
/**
|
||||
* Creates the backend object.
|
||||
*
|
||||
* If the filename argument is passed in, it will parse out the specified file fist.
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* @param string $tableName The PDO table name to use
|
||||
*/
|
||||
public function __construct(\PDO $pdo, $authRealm, $tableName = 'users') {
|
||||
|
||||
$this->pdo = $pdo;
|
||||
$this->tableName = $tableName;
|
||||
$this->authRealm = $authRealm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a username and password
|
||||
*
|
||||
* This method should return true or false depending on if login
|
||||
* succeeded.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUserPass($username, $password) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT username, digesta1 FROM '.$this->tableName.' WHERE username = ?');
|
||||
$stmt->execute(array($username));
|
||||
$result = $stmt->fetchAll();
|
||||
|
||||
|
||||
if (!count($result)) return false;
|
||||
|
||||
$hash = md5( $username . ':' . $this->authRealm . ':' . $password );
|
||||
if( $result[0]['digesta1'] == $hash )
|
||||
{
|
||||
$this->currentUser = $username;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Core;
|
||||
|
||||
class Tools {
|
||||
public static function &db() {
|
||||
return $GLOBALS["pdo"];
|
||||
}
|
||||
|
||||
public static function assertEnvironmentIsOk() {
|
||||
# Asserting Baikal Context
|
||||
if(!defined("BAIKAL_CONTEXT") || BAIKAL_CONTEXT !== TRUE) {
|
||||
die("Bootstrap.php may not be included outside the Baikal context");
|
||||
}
|
||||
|
||||
# Asserting PDO
|
||||
if(!defined('PDO::ATTR_DRIVER_NAME')) {
|
||||
die('Baikal Fatal Error: PDO is unavailable. It\'s required by Baikal.');
|
||||
}
|
||||
|
||||
# Asserting PDO::SQLite or PDO::MySQL
|
||||
$aPDODrivers = \PDO::getAvailableDrivers();
|
||||
if(!in_array('sqlite', $aPDODrivers) && !in_array('mysql', $aPDODrivers)) {
|
||||
die('<strong>Baikal Fatal Error</strong>: Both <strong>PDO::sqlite</strong> and <strong>PDO::mysql</strong> are unavailable. One of them at least is required by Baikal.');
|
||||
}
|
||||
}
|
||||
|
||||
public static function configureEnvironment() {
|
||||
set_exception_handler('\Baikal\Core\Tools::handleException');
|
||||
ini_set("error_reporting", E_ALL);
|
||||
}
|
||||
|
||||
public static function handleException($exception) {
|
||||
echo "<pre>" . $exception . "<pre>";
|
||||
}
|
||||
|
||||
public static function assertBaikalIsOk() {
|
||||
|
||||
# DB connexion has not been asserted earlier by Flake, to give us a chance to trigger the install tool
|
||||
# We assert it right now
|
||||
if(!\Flake\Framework::isDBInitialized() && (!defined("BAIKAL_CONTEXT_INSTALL") || BAIKAL_CONTEXT_INSTALL === FALSE)) {
|
||||
throw new \Exception("<strong>Fatal error</strong>: no connection to a database is available.");
|
||||
}
|
||||
|
||||
# Asserting that the database is structurally complete
|
||||
#if(($aMissingTables = self::isDBStructurallyComplete($GLOBALS["DB"])) !== TRUE) {
|
||||
# throw new \Exception("<strong>Fatal error</strong>: Database is not structurally complete; missing tables are: <strong>" . implode("</strong>, <strong>", $aMissingTables) . "</strong>");
|
||||
#}
|
||||
|
||||
# Asserting config file exists
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
|
||||
throw new \Exception("Specific/config.php does not exist. Please use the Install tool to create it.");
|
||||
}
|
||||
|
||||
# Asserting config file is readable
|
||||
if(!is_readable(PROJECT_PATH_SPECIFIC . "config.php")) {
|
||||
throw new \Exception("Specific/config.php is not readable. Please give read permissions to httpd user on file 'Specific/config.php'.");
|
||||
}
|
||||
|
||||
# Asserting config file is writable
|
||||
if(!is_writable(PROJECT_PATH_SPECIFIC . "config.php")) {
|
||||
throw new \Exception("Specific/config.php is not writable. Please give write permissions to httpd user on file 'Specific/config.php'.");
|
||||
}
|
||||
|
||||
# Asserting system config file exists
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
|
||||
throw new \Exception("Specific/config.system.php does not exist. Please use the Install tool to create it.");
|
||||
}
|
||||
|
||||
# Asserting system config file is readable
|
||||
if(!is_readable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
|
||||
throw new \Exception("Specific/config.system.php is not readable. Please give read permissions to httpd user on file 'Specific/config.system.php'.");
|
||||
}
|
||||
|
||||
# Asserting system config file is writable
|
||||
if(!is_writable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
|
||||
throw new \Exception("Specific/config.system.php is not writable. Please give write permissions to httpd user on file 'Specific/config.system.php'.");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getRequiredTablesList() {
|
||||
return array(
|
||||
"addressbooks",
|
||||
"calendarobjects",
|
||||
"calendars",
|
||||
"cards",
|
||||
"groupmembers",
|
||||
"locks",
|
||||
"principals",
|
||||
"users",
|
||||
);
|
||||
}
|
||||
|
||||
public static function isDBStructurallyComplete(\Flake\Core\Database $oDB) {
|
||||
|
||||
$aRequiredTables = self::getRequiredTablesList();
|
||||
$aPresentTables = $oDB->tables();
|
||||
|
||||
$aIntersect = array_intersect($aRequiredTables, $aPresentTables);
|
||||
if(count($aIntersect) !== count($aRequiredTables)) {
|
||||
return array_diff($aRequiredTables, $aIntersect);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public static function bashPrompt($prompt) {
|
||||
print $prompt;
|
||||
@flush();
|
||||
@ob_flush();
|
||||
$confirmation = @trim(fgets(STDIN));
|
||||
return $confirmation;
|
||||
}
|
||||
|
||||
public static function bashPromptSilent($prompt = "Enter Password:") {
|
||||
$command = "/usr/bin/env bash -c 'echo OK'";
|
||||
|
||||
if(rtrim(shell_exec($command)) !== 'OK') {
|
||||
trigger_error("Can't invoke bash");
|
||||
return;
|
||||
}
|
||||
|
||||
$command = "/usr/bin/env bash -c 'read -s -p \""
|
||||
. addslashes($prompt)
|
||||
. "\" mypassword && echo \$mypassword'";
|
||||
|
||||
$password = rtrim(shell_exec($command));
|
||||
echo "\n";
|
||||
return $password;
|
||||
}
|
||||
|
||||
public static function getCopyrightNotice($sLinePrefixChar = "#", $sLineSuffixChar = "", $sOpening = FALSE, $sClosing = FALSE) {
|
||||
|
||||
if($sOpening === FALSE) {
|
||||
$sOpening = str_repeat("#", 78);
|
||||
}
|
||||
|
||||
if($sClosing === FALSE) {
|
||||
$sClosing = str_repeat("#", 78);
|
||||
}
|
||||
|
||||
$iYear = date("Y");
|
||||
|
||||
$sCode =<<<CODE
|
||||
Copyright notice
|
||||
|
||||
(c) {$iYear} Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
All rights reserved
|
||||
|
||||
http://baikal-server.com
|
||||
|
||||
This script is part of the Baïkal Server project. The Baïkal
|
||||
Server project 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.
|
||||
|
||||
The GNU General Public License can be found at
|
||||
http://www.gnu.org/copyleft/gpl.html.
|
||||
|
||||
This script 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.
|
||||
|
||||
This copyright notice MUST APPEAR in all copies of the script!
|
||||
CODE;
|
||||
$sCode = "\n" . trim($sCode) . "\n";
|
||||
$aCode = explode("\n", $sCode);
|
||||
foreach(array_keys($aCode) as $iLineNum) {
|
||||
$aCode[$iLineNum] = trim($sLinePrefixChar . "\t" . $aCode[$iLineNum]);
|
||||
}
|
||||
|
||||
if(trim($sOpening) !== "") {
|
||||
array_unshift($aCode, $sOpening);
|
||||
}
|
||||
|
||||
if(trim($sClosing) !== "") {
|
||||
$aCode[] = $sClosing;
|
||||
}
|
||||
|
||||
return implode("\n", $aCode);
|
||||
}
|
||||
|
||||
public static function timezones() {
|
||||
$aZones = \DateTimeZone::listIdentifiers();
|
||||
|
||||
reset($aZones);
|
||||
return $aZones;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal;
|
||||
|
||||
class Framework extends \Flake\Core\Framework {
|
||||
|
||||
public static function installTool() {
|
||||
if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
|
||||
# Install tool has been launched and we're already on the install page
|
||||
return;
|
||||
} else {
|
||||
# Install tool has been launched; redirecting user
|
||||
$sInstallToolUrl = PROJECT_URI . "admin/install/";
|
||||
header("Location: " . $sInstallToolUrl);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static function bootstrap() {
|
||||
|
||||
# Registering Baikal classloader
|
||||
define("BAIKAL_PATH_FRAMEWORKROOT", dirname(__FILE__) . "/");
|
||||
|
||||
\Baikal\Core\Tools::assertEnvironmentIsOk();
|
||||
\Baikal\Core\Tools::configureEnvironment();
|
||||
|
||||
# Check that a config file exists
|
||||
if(
|
||||
!file_exists(PROJECT_PATH_SPECIFIC . "config.php") ||
|
||||
!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")
|
||||
) {
|
||||
self::installTool();
|
||||
} else {
|
||||
require_once(PROJECT_PATH_SPECIFIC . "config.php");
|
||||
require_once(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
date_default_timezone_set(PROJECT_TIMEZONE);
|
||||
|
||||
# Check that Baïkal is already configured
|
||||
if(!defined("BAIKAL_CONFIGURED_VERSION")) {
|
||||
self::installTool();
|
||||
|
||||
} else {
|
||||
|
||||
# Check that running version matches configured version
|
||||
if(version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
|
||||
self::installTool();
|
||||
|
||||
} else {
|
||||
|
||||
# Check that admin password is set
|
||||
if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
|
||||
self::installTool();
|
||||
}
|
||||
|
||||
\Baikal\Core\Tools::assertBaikalIsOk();
|
||||
|
||||
set_error_handler("\Baikal\Framework::exception_error_handler");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Mapping PHP errors to exceptions; needed by SabreDAV
|
||||
public static function exception_error_handler($errno, $errstr, $errfile, $errline) {
|
||||
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model;
|
||||
|
||||
class AddressBook extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "addressbooks";
|
||||
const PRIMARYKEY = "id";
|
||||
const LABELFIELD = "displayname";
|
||||
|
||||
protected $aData = array(
|
||||
"principaluri" => "",
|
||||
"displayname" => "",
|
||||
"uri" => "",
|
||||
"description" => "",
|
||||
"ctag" => 1,
|
||||
);
|
||||
|
||||
public static function humanName() {
|
||||
return "Address Book";
|
||||
}
|
||||
|
||||
public static function icon() {
|
||||
return "icon-book";
|
||||
}
|
||||
|
||||
public static function mediumicon() {
|
||||
return "glyph-adress-book";
|
||||
}
|
||||
|
||||
public static function bigicon() {
|
||||
return "glyph2x-adress-book";
|
||||
}
|
||||
|
||||
public function getContactsBaseRequester() {
|
||||
$oBaseRequester = \Baikal\Model\AddressBook\Contact::getBaseRequester();
|
||||
$oBaseRequester->addClauseEquals(
|
||||
"addressbookid",
|
||||
$this->get("id")
|
||||
);
|
||||
|
||||
return $oBaseRequester;
|
||||
}
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "uri",
|
||||
"label" => "Address Book token ID",
|
||||
"validation" => "required,tokenid",
|
||||
"popover" => array(
|
||||
"title" => "Address Book token ID",
|
||||
"content" => "The unique identifier for this address book.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "displayname",
|
||||
"label" => "Display name",
|
||||
"validation" => "required",
|
||||
"popover" => array(
|
||||
"title" => "Display name",
|
||||
"content" => "This is the name that will be displayed in your CardDAV client.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "description",
|
||||
"label" => "Description",
|
||||
"validation" => "required"
|
||||
)));
|
||||
|
||||
if($this->floating()) {
|
||||
$oMorpho->element("uri")->setOption(
|
||||
"help",
|
||||
"Allowed characters are digits, lowercase letters and the dash symbol '-'."
|
||||
);
|
||||
} else {
|
||||
$oMorpho->element("uri")->setOption("readonly", TRUE);
|
||||
}
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
|
||||
$oContacts = $this->getContactsBaseRequester()->execute();
|
||||
foreach($oContacts as $contact) {
|
||||
$contact->destroy();
|
||||
}
|
||||
|
||||
parent::destroy();
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\AddressBook;
|
||||
|
||||
class Contact extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "cards";
|
||||
const PRIMARYKEY = "id";
|
||||
const LABELFIELD = "uri";
|
||||
|
||||
protected $aData = array(
|
||||
"carddata" => "",
|
||||
"uri" => "",
|
||||
"addressbookid" => "",
|
||||
"lastmodified" => "",
|
||||
);
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model;
|
||||
|
||||
class Calendar extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "calendars";
|
||||
const PRIMARYKEY = "id";
|
||||
const LABELFIELD = "displayname";
|
||||
|
||||
protected $aData = array(
|
||||
"principaluri" => "",
|
||||
"displayname" => "",
|
||||
"uri" => "",
|
||||
"ctag" => 0,
|
||||
"description" => "",
|
||||
"calendarorder" => 0,
|
||||
"calendarcolor" => "",
|
||||
"timezone" => "",
|
||||
"components" => "",
|
||||
);
|
||||
|
||||
public static function icon() {
|
||||
return "icon-calendar";
|
||||
}
|
||||
|
||||
public static function mediumicon() {
|
||||
return "glyph-calendar";
|
||||
}
|
||||
|
||||
public static function bigicon() {
|
||||
return "glyph2x-calendar";
|
||||
}
|
||||
|
||||
public function getEventsBaseRequester() {
|
||||
$oBaseRequester = \Baikal\Model\Calendar\Event::getBaseRequester();
|
||||
$oBaseRequester->addClauseEquals(
|
||||
"calendarid",
|
||||
$this->get("id")
|
||||
);
|
||||
|
||||
return $oBaseRequester;
|
||||
}
|
||||
|
||||
public function get($sPropName) {
|
||||
|
||||
if($sPropName === "todos") {
|
||||
# TRUE if components contains VTODO, FALSE otherwise
|
||||
if(($sComponents = $this->get("components")) !== "") {
|
||||
$aComponents = explode(",", $sComponents);
|
||||
} else {
|
||||
$aComponents = array();
|
||||
}
|
||||
|
||||
return in_array("VTODO", $aComponents);
|
||||
}
|
||||
|
||||
if($sPropName === "notes") {
|
||||
# TRUE if components contains VJOURNAL, FALSE otherwise
|
||||
if(($sComponents = $this->get("components")) !== "") {
|
||||
$aComponents = explode(",", $sComponents);
|
||||
} else {
|
||||
$aComponents = array();
|
||||
}
|
||||
|
||||
return in_array("VJOURNAL", $aComponents);
|
||||
}
|
||||
|
||||
return parent::get($sPropName);
|
||||
}
|
||||
|
||||
public function set($sPropName, $sValue) {
|
||||
|
||||
if($sPropName === "todos") {
|
||||
|
||||
if(($sComponents = $this->get("components")) !== "") {
|
||||
$aComponents = explode(",", $sComponents);
|
||||
} else {
|
||||
$aComponents = array();
|
||||
}
|
||||
|
||||
if($sValue === TRUE) {
|
||||
if(!in_array("VTODO", $aComponents)) {
|
||||
$aComponents[] = "VTODO";
|
||||
}
|
||||
} else {
|
||||
if(in_array("VTODO", $aComponents)) {
|
||||
unset($aComponents[array_search("VTODO", $aComponents)]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::set("components", implode(",", $aComponents));
|
||||
}
|
||||
|
||||
if($sPropName === "notes") {
|
||||
|
||||
if(($sComponents = $this->get("components")) !== "") {
|
||||
$aComponents = explode(",", $sComponents);
|
||||
} else {
|
||||
$aComponents = array();
|
||||
}
|
||||
|
||||
if($sValue === TRUE) {
|
||||
if(!in_array("VJOURNAL", $aComponents)) {
|
||||
$aComponents[] = "VJOURNAL";
|
||||
}
|
||||
} else {
|
||||
if(in_array("VJOURNAL", $aComponents)) {
|
||||
unset($aComponents[array_search("VJOURNAL", $aComponents)]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::set("components", implode(",", $aComponents));
|
||||
}
|
||||
|
||||
return parent::set($sPropName, $sValue);
|
||||
}
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "uri",
|
||||
"label" => "Calendar token ID",
|
||||
"validation" => "required,tokenid",
|
||||
"popover" => array(
|
||||
"title" => "Calendar token ID",
|
||||
"content" => "The unique identifier for this calendar.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "displayname",
|
||||
"label" => "Display name",
|
||||
"validation" => "required",
|
||||
"popover" => array(
|
||||
"title" => "Display name",
|
||||
"content" => "This is the name that will be displayed in your CalDAV client.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "description",
|
||||
"label" => "Description"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "todos",
|
||||
"label" => "Todos",
|
||||
"help" => "If checked, todos will be enabled on this calendar.",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "notes",
|
||||
"label" => "Notes",
|
||||
"help" => "If checked, notes will be enabled on this calendar.",
|
||||
)));
|
||||
|
||||
|
||||
if($this->floating()) {
|
||||
$oMorpho->element("uri")->setOption(
|
||||
"help",
|
||||
"Allowed characters are digits, lowercase letters and the dash symbol '-'."
|
||||
);
|
||||
} else {
|
||||
$oMorpho->element("uri")->setOption("readonly", TRUE);
|
||||
}
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function isDefault() {
|
||||
return $this->get("uri") === "default";
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
$oEvents = $this->getEventsBaseRequester()->execute();
|
||||
foreach($oEvents as $event) {
|
||||
$event->destroy();
|
||||
}
|
||||
|
||||
parent::destroy();
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\Calendar;
|
||||
|
||||
class Event extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "calendarobjects";
|
||||
const PRIMARYKEY = "id";
|
||||
const LABELFIELD = "uri";
|
||||
|
||||
protected $aData = array(
|
||||
"calendardata" => "",
|
||||
"uri" => "",
|
||||
"calendarid" => "",
|
||||
"lastmodified" => "",
|
||||
);
|
||||
}
|
|
@ -1,240 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model;
|
||||
|
||||
abstract class Config extends \Flake\Core\Model\NoDb {
|
||||
|
||||
protected $sConfigFilePath = "";
|
||||
protected $aConstants = array();
|
||||
protected $aData = array();
|
||||
|
||||
public function __construct($sConfigFilePath) {
|
||||
# Note: no call to parent::__construct() to avoid erasing $this->aData
|
||||
$this->sConfigFilePath = $sConfigFilePath;
|
||||
$aConfig = $this->parseConfig(
|
||||
$this->getConfigAsString()
|
||||
);
|
||||
|
||||
foreach(array_keys($this->aData) as $sProp) {
|
||||
if(array_key_exists($sProp, $aConfig)) {
|
||||
$this->aData[$sProp] = $aConfig[$sProp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getConfigAsString() {
|
||||
if(file_exists($this->sConfigFilePath)) {
|
||||
$sContent = file_get_contents($this->sConfigFilePath);
|
||||
return str_replace(LF . CR, LF, $sContent);
|
||||
} else {
|
||||
|
||||
$sConfig = "<?php\n" . \Baikal\Core\Tools::getCopyrightNotice() . "\n\n";
|
||||
$sConfig .= static::getDefaultConfig();
|
||||
|
||||
return $sConfig;
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseConfig($sString) {
|
||||
|
||||
$aRes = array();
|
||||
|
||||
foreach(array_keys($this->aConstants) as $sConstant) {
|
||||
$aConstant = $this->aConstants[$sConstant];
|
||||
|
||||
$aMatches = array();
|
||||
$sPattern = '/\s*define\(\s*["|\']' . $sConstant . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
|
||||
|
||||
$iNbRes = preg_match_all(
|
||||
$sPattern,
|
||||
$sString,
|
||||
$aMatches
|
||||
);
|
||||
|
||||
if($iNbRes === 1) {
|
||||
# Exactly one match
|
||||
# O would be not enough, and > 1, to much to handle properly
|
||||
|
||||
$sValue = $aMatches[1][0]; # first capture (.*?), first occurence (anyway, we asserted that there's only one)
|
||||
switch($aConstant["type"]) {
|
||||
case "string": {
|
||||
$sValue = substr($sValue, 1, -1); # Strip quotes
|
||||
break;
|
||||
}
|
||||
case "integer": {
|
||||
$sValue = intval($sValue); # Integer
|
||||
break;
|
||||
}
|
||||
case "boolean": {
|
||||
if(in_array(strtoupper(trim($sValue)), array("1", "TRUE"))) {
|
||||
$sValue = TRUE;
|
||||
} else {
|
||||
$sValue = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "litteral": {
|
||||
$sValue = trim($sValue);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
# nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$aRes[$sConstant] = $sValue;
|
||||
|
||||
} elseif($iNbRes > 1) {
|
||||
throw new \Exception("Baikal\Model\Config->parseConfig(): constant '" . $sConstant . "' has been found multiple times in the config file; stopping execution");
|
||||
} else {
|
||||
# $iNbRes === 0
|
||||
# We do nothing, to keep the default value (the one already set in $aData)
|
||||
}
|
||||
}
|
||||
|
||||
reset($aRes);
|
||||
return $aRes;
|
||||
}
|
||||
|
||||
public function writable() {
|
||||
return (
|
||||
@file_exists($this->sConfigFilePath) &&
|
||||
@is_file($this->sConfigFilePath) &&
|
||||
@is_writable($this->sConfigFilePath)
|
||||
);
|
||||
}
|
||||
|
||||
public static function icon() {
|
||||
return "icon-cog";
|
||||
}
|
||||
|
||||
public static function mediumicon() {
|
||||
return "glyph-cogwheel";
|
||||
}
|
||||
|
||||
public static function bigicon() {
|
||||
return "glyph2x-cogwheel";
|
||||
}
|
||||
|
||||
public function floating() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function persist() {
|
||||
$aLines = explode(LF, $this->getConfigAsString());
|
||||
$iLines = count($aLines);
|
||||
|
||||
foreach(array_keys($this->aData) as $prop) {
|
||||
$sPattern = '/\s*define\(\s*["|\']' . $prop . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
|
||||
$sValue = $this->aData[$prop];
|
||||
|
||||
|
||||
# We replace value by it's native PHP notation
|
||||
switch($this->aConstants[$prop]["type"]) {
|
||||
case "string": {
|
||||
$sValue = var_export($sValue, TRUE); # Add quotes, and escape " and all string-termination chars
|
||||
break;
|
||||
}
|
||||
case "integer": {
|
||||
$sValue = intval($sValue); # Cast as integer
|
||||
break;
|
||||
}
|
||||
case "boolean": {
|
||||
|
||||
if(intval($sValue) === 1) { # Note as a BOOLEAN PHP constant
|
||||
$sValue = "TRUE";
|
||||
} else {
|
||||
$sValue = "FALSE";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "litteral": {
|
||||
$sValue = trim($sValue);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$sValue = "''";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$mFound = FALSE;
|
||||
for($k = ($iLines - 1); $k >= 0; $k--) {
|
||||
if(preg_match($sPattern, $aLines[$k])) {
|
||||
|
||||
# Found the last matching line
|
||||
$mFound = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($mFound === FALSE) {
|
||||
# Adding line at the end of the file
|
||||
$aLines[] = "\n" . "# " . $this->aConstants[$prop]["comment"] . "\ndefine(\"" . $prop . "\", " . $sValue . ");";
|
||||
} else {
|
||||
$aLines[$mFound] = "define(\"" . $prop . "\", " . $sValue . ");";
|
||||
}
|
||||
}
|
||||
|
||||
$sLines = implode("\n", $aLines);
|
||||
$sSandboxedCode = str_replace(array("<?php", "<?", "?>"), "", $sLines);
|
||||
$sRand = (string)rand();
|
||||
$sCode = "if(0) {" . $sSandboxedCode . "}; echo '" . $sRand . "';";
|
||||
ob_start();
|
||||
eval($sCode);
|
||||
$sRes = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if($sRes !== $sRand) {
|
||||
echo "<pre>" . htmlspecialchars($sLines) . "</pre>";
|
||||
throw new \Exception("Parse error in new config file. Aborting, nothing has been changed.");
|
||||
}
|
||||
|
||||
# We asserted that the syntax is OK;
|
||||
# We now check that all the constants are present, and with the right value
|
||||
$aNewConfig = $this->parseConfig($sLines);
|
||||
$aWrittenConfig = $this->aData;
|
||||
|
||||
asort($aNewConfig);
|
||||
asort($aWrittenConfig);
|
||||
|
||||
if($aNewConfig != $aWrittenConfig) {
|
||||
throw new \Exception("New config does not correspond to expected config. Aborting, nothing has been changed.");
|
||||
}
|
||||
|
||||
file_put_contents($this->sConfigFilePath, $sLines);
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
|
||||
}
|
||||
|
||||
protected static function getDefaultConfig() {
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\Config;
|
||||
|
||||
class Database extends \Baikal\Model\Config {
|
||||
|
||||
protected $aConstants = array(
|
||||
"PROJECT_SQLITE_FILE" => array(
|
||||
"type" => "litteral",
|
||||
"comment" => "Define path to Baïkal Database SQLite file",
|
||||
),
|
||||
"PROJECT_DB_MYSQL" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "MySQL > Use MySQL instead of SQLite ?",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_HOST" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Host, including ':portnumber' if port is not the default one (3306)",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_DBNAME" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Database name",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_USERNAME" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Username",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_PASSWORD" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Password",
|
||||
),
|
||||
);
|
||||
|
||||
# Default values
|
||||
protected $aData = array(
|
||||
"PROJECT_SQLITE_FILE" => 'PROJECT_PATH_SPECIFIC . "db/db.sqlite"',
|
||||
"PROJECT_DB_MYSQL" => FALSE,
|
||||
"PROJECT_DB_MYSQL_HOST" => "",
|
||||
"PROJECT_DB_MYSQL_DBNAME" => "",
|
||||
"PROJECT_DB_MYSQL_USERNAME" => "",
|
||||
"PROJECT_DB_MYSQL_PASSWORD" => "",
|
||||
);
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_SQLITE_FILE",
|
||||
"label" => "SQLite file path",
|
||||
"validation" => "required",
|
||||
"inputclass" => "input-xxlarge",
|
||||
"help" => "The absolute server path to the SQLite file",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "PROJECT_DB_MYSQL",
|
||||
"label" => "Use MySQL",
|
||||
"help" => "If checked, Baïkal will use MySQL instead of SQLite.",
|
||||
"refreshonchange" => TRUE,
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_HOST",
|
||||
"label" => "MySQL host",
|
||||
"help" => "Host ip or name, including <strong>':portnumber'</strong> if port is not the default one (3306)"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_DBNAME",
|
||||
"label" => "MySQL database name",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_USERNAME",
|
||||
"label" => "MySQL username",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_PASSWORD",
|
||||
"label" => "MySQL password",
|
||||
)));
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function label() {
|
||||
return "Baïkal Database Settings";
|
||||
}
|
||||
|
||||
protected static function getDefaultConfig() {
|
||||
throw new \Exception("Should never reach getDefaultConfig() on \Baikal\Model\Config\Database");
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\Config;
|
||||
|
||||
class Distrib extends \Baikal\Model\Config {
|
||||
|
||||
protected $aConstants = array(
|
||||
"BAIKAL_VERSION" => array(
|
||||
"type" => "string",
|
||||
"comment" => "The version of the packaged system"
|
||||
),
|
||||
"BAIKAL_HOMEPAGE" => array(
|
||||
"type" => "string",
|
||||
"comment" => "The URL to the project homepage",
|
||||
),
|
||||
"PROJECT_PACKAGE" => array(
|
||||
"type" => "string",
|
||||
"comment" => "The type of the current package (one of 'flat', 'regular')"
|
||||
),
|
||||
);
|
||||
|
||||
# Default values
|
||||
protected $aData = array(
|
||||
"BAIKAL_VERSION" => "",
|
||||
"BAIKAL_HOMEPAGE" => "",
|
||||
"PROJECT_PACKAGE" => "",
|
||||
);
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function label() {
|
||||
return "Baïkal distribution info";
|
||||
}
|
||||
}
|
|
@ -1,360 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\Config;
|
||||
|
||||
class Standard extends \Baikal\Model\Config {
|
||||
|
||||
protected $aConstants = array(
|
||||
"PROJECT_TIMEZONE" => array(
|
||||
"type" => "string",
|
||||
"comment" => "Timezone of the server; if unsure, check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones",
|
||||
),
|
||||
"BAIKAL_CARD_ENABLED" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "CardDAV ON/OFF switch; default TRUE",
|
||||
),
|
||||
"BAIKAL_CAL_ENABLED" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "CalDAV ON/OFF switch; default TRUE",
|
||||
),
|
||||
"BAIKAL_DAV_AUTH_TYPE" => array(
|
||||
"type" => "string",
|
||||
"comment" => "HTTP authentication type for WebDAV; default Digest"
|
||||
),
|
||||
"BAIKAL_DAV_LDAP_URI" => array(
|
||||
"type" => "string",
|
||||
"comment" => "URI to LDAP Server (for ldap-userbind auth); default ldapi:///"
|
||||
),
|
||||
"BAIKAL_DAV_LDAP_DN_TEMPLATE" => array(
|
||||
"type" => "string",
|
||||
"comment" => "User DN for bind; with replacments %n => username, %u => user part, %d => domain part of username"
|
||||
),
|
||||
"BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR" => array(
|
||||
"type" => "string",
|
||||
"comment" => "LDAP-attribute for displayname; default cn"
|
||||
),
|
||||
"BAIKAL_DAV_LDAP_EMAIL_ATTR" => array(
|
||||
"type" => "string",
|
||||
"comment" => "LDAP-attribute for email; default mail"
|
||||
),
|
||||
"BAIKAL_DAV_MAIL_PROTOCOL" => array(
|
||||
"type" => "string",
|
||||
"comment" => "used protocol; default 'imap (TLS/StartTLS)'"
|
||||
),
|
||||
"BAIKAL_DAV_MAIL_SERVER" => array(
|
||||
"type" => "string",
|
||||
"comment" => "host:port of mail server; default localhost:143"
|
||||
),
|
||||
"BAIKAL_DAV_MAIL_CHECK_CERT" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "validate ssl-certificate; default yes"
|
||||
),
|
||||
"BAIKAL_DAV_AUTO_CREATE_USER" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "automatic creation of users; default yes"
|
||||
),
|
||||
"BAIKAL_ADMIN_ENABLED" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "Baïkal Web Admin ON/OFF switch; default TRUE",
|
||||
),
|
||||
"BAIKAL_ADMIN_AUTOLOCKENABLED" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "Baïkal Web Admin autolock ON/OFF switch; default FALSE",
|
||||
),
|
||||
"BAIKAL_ADMIN_PASSWORDHASH" => array(
|
||||
"type" => "string",
|
||||
"comment" => "Baïkal Web admin password hash; Set via Baïkal Web Admin",
|
||||
)
|
||||
);
|
||||
|
||||
# Default values
|
||||
protected $aData = array(
|
||||
"PROJECT_TIMEZONE" => "Europe/Paris",
|
||||
"BAIKAL_CARD_ENABLED" => TRUE,
|
||||
"BAIKAL_CAL_ENABLED" => TRUE,
|
||||
"BAIKAL_DAV_AUTH_TYPE" => "Digest",
|
||||
"BAIKAL_DAV_LDAP_URI" => "ldapi:///",
|
||||
"BAIKAL_DAV_LDAP_DN_TEMPLATE" => "uid=%n,dc=example,dc=com",
|
||||
"BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR" => "cn",
|
||||
"BAIKAL_DAV_LDAP_EMAIL_ATTR" => "mail",
|
||||
"BAIKAL_DAV_MAIL_PROTOCOL" => "imap (unencrypted)",
|
||||
"BAIKAL_DAV_MAIL_SERVER" => "localhost:143",
|
||||
"BAIKAL_DAV_MAIL_CHECK_CERT" => TRUE,
|
||||
"BAIKAL_DAV_AUTO_CREATE_USER" => TRUE,
|
||||
"BAIKAL_ADMIN_ENABLED" => TRUE,
|
||||
"BAIKAL_ADMIN_AUTOLOCKENABLED" => FALSE,
|
||||
"BAIKAL_ADMIN_PASSWORDHASH" => ""
|
||||
);
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Listbox(array(
|
||||
"prop" => "PROJECT_TIMEZONE",
|
||||
"label" => "Server Time zone",
|
||||
"validation" => "required",
|
||||
"options" => \Baikal\Core\Tools::timezones(),
|
||||
)));
|
||||
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_CAL_ENABLED",
|
||||
"label" => "Enable CalDAV"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_CARD_ENABLED",
|
||||
"label" => "Enable CardDAV"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Listbox(array(
|
||||
"prop" => "BAIKAL_DAV_AUTH_TYPE",
|
||||
"label" => "WebDAV authentication type",
|
||||
"options" => array( "Digest", "Basic", "LDAP-UserBind", "Mail" )
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_DAV_LDAP_URI",
|
||||
"label" => "LDAP URI",
|
||||
"class" => "auth_ldap-userbind"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_DAV_LDAP_DN_TEMPLATE",
|
||||
"label" => "LDAP DN template",
|
||||
"class" => "auth_ldap-userbind",
|
||||
"popover" => array(
|
||||
"title" => "posible placeholder",
|
||||
"content" => "<strong>%n</strong> - username<br /><strong>%u</strong> - user part of username , when it is an email address)<br /><strong>%d</strong> - domain part",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR",
|
||||
"label" => "LDAP attribute for DisplayName",
|
||||
"class" => "auth_ldap-userbind"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_DAV_LDAP_EMAIL_ATTR",
|
||||
"label" => "LDAP attribute for eMail",
|
||||
"class" => "auth_ldap-userbind"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Listbox(array(
|
||||
"prop" => "BAIKAL_DAV_MAIL_PROTOCOL",
|
||||
"label" => "MailAuth Protocol",
|
||||
"class" => "auth_mail",
|
||||
"options" => array(
|
||||
"imap" => "imap (unencrypted)",
|
||||
"imaps" => "imaps (SSL)",
|
||||
"imaptls" => "imap (StartTLS)",
|
||||
"pop3" => "pop3 (unencrypted)",
|
||||
"pop3s" => "pop3s (SSL)",
|
||||
"pop3tls" => "pop3 (StartTLS)",
|
||||
"smtp" => "smtp (unencrypted)",
|
||||
"smtps" => "smtps (SSL)",
|
||||
"smtptls" => "smtp (StartTLS)"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_DAV_MAIL_SERVER",
|
||||
"label" => "MailAuth Server",
|
||||
"class" => "auth_mail",
|
||||
"popover" => array(
|
||||
"title" => "Format",
|
||||
"content" => "host:port"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_DAV_MAIL_CHECK_CERT",
|
||||
"label" => "MailAuth Check SSL-Certificate",
|
||||
"class" => "auth_mail auth_mail_ssl",
|
||||
"popover" => array(
|
||||
"title" => "Security",
|
||||
"content" => "validate the server certificate"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_DAV_AUTO_CREATE_USER",
|
||||
"label" => "Automatic create users",
|
||||
"class" => "auth_mail auth_ldap-userbind"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "BAIKAL_ADMIN_PASSWORDHASH",
|
||||
"label" => "Admin password",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM",
|
||||
"label" => "Admin password, confirmation",
|
||||
"validation" => "sameas:BAIKAL_ADMIN_PASSWORDHASH",
|
||||
)));
|
||||
|
||||
if(!defined("BAIKAL_ADMIN_PASSWORDHASH") || trim(BAIKAL_ADMIN_PASSWORDHASH) === "") {
|
||||
|
||||
# No password set (Form is used in install tool), so password is required as it has to be defined
|
||||
$oMorpho->element("BAIKAL_ADMIN_PASSWORDHASH")->setOption("validation", "required");
|
||||
} else {
|
||||
$sNotice = "-- Leave empty to keep current password --";
|
||||
$oMorpho->element("BAIKAL_ADMIN_PASSWORDHASH")->setOption("placeholder", $sNotice);
|
||||
$oMorpho->element("BAIKAL_ADMIN_PASSWORDHASH_CONFIRM")->setOption("placeholder", $sNotice);
|
||||
}
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_ADMIN_ENABLED",
|
||||
"label" => "Enable Web interface (recommended)",
|
||||
"popover" => array(
|
||||
"title" => "Warning !",
|
||||
"content" => "If disabled, you'll lose access to this very admin interface !",
|
||||
),
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "BAIKAL_ADMIN_AUTOLOCKENABLED",
|
||||
"label" => "Web interface autolock",
|
||||
"popover" => array(
|
||||
"title" => "Web admin autolock",
|
||||
"content" => "If enabled, you'll have to create a file named <strong>ENABLE_ADMIN</strong> in the folder <strong>Specific/</strong> prior to every admin use.<br /><br />This enforces security, but might be uncomfortable if you use the admin frequently."
|
||||
)
|
||||
)));
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function label() {
|
||||
return "Baïkal Settings";
|
||||
}
|
||||
|
||||
public function set($sProp, $sValue) {
|
||||
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
|
||||
# Special handling for password and passwordconfirm
|
||||
|
||||
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" && $sValue !== "") {
|
||||
parent::set(
|
||||
"BAIKAL_ADMIN_PASSWORDHASH",
|
||||
\BaikalAdmin\Core\Auth::hashAdminPassword($sValue)
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
parent::set($sProp, $sValue);
|
||||
}
|
||||
|
||||
public function get($sProp) {
|
||||
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return parent::get($sProp);
|
||||
}
|
||||
|
||||
protected function createDefaultConfigFilesIfNeeded() {
|
||||
|
||||
# Create empty config.php if needed
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
|
||||
@touch(PROJECT_PATH_SPECIFIC . "config.php");
|
||||
$sContent = "<?php\n" . \Baikal\Core\Tools::getCopyrightNotice() . "\n\n";
|
||||
$sContent .= $this->getDefaultConfig();
|
||||
file_put_contents(PROJECT_PATH_SPECIFIC . "config.php", $sContent);
|
||||
}
|
||||
|
||||
# Create empty config.system.php if needed
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
|
||||
@touch(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
$sContent = "<?php\n" . \Baikal\Core\Tools::getCopyrightNotice() . "\n\n";
|
||||
$sContent .= $this->getDefaultSystemConfig();
|
||||
file_put_contents(PROJECT_PATH_SPECIFIC . "config.system.php", $sContent);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getDefaultConfig() {
|
||||
|
||||
$sCode =<<<CODE
|
||||
##############################################################################
|
||||
# Required configuration
|
||||
# You *have* to review these settings for Baïkal to run properly
|
||||
#
|
||||
|
||||
# Timezone of your users, if unsure, check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
define("PROJECT_TIMEZONE", "Europe/Paris");
|
||||
|
||||
# CardDAV ON/OFF switch; default TRUE
|
||||
define("BAIKAL_CARD_ENABLED", TRUE);
|
||||
|
||||
# CalDAV ON/OFF switch; default TRUE
|
||||
define("BAIKAL_CAL_ENABLED", TRUE);
|
||||
|
||||
# WebDAV authentication type; default Digest
|
||||
define("BAIKAL_DAV_AUTH_TYPE", "Digest");
|
||||
|
||||
# Auth Backend LDAP-UserBind; LDAP URI
|
||||
define("BAIKAL_DAV_LDAP_URI", 'ldapi:///');
|
||||
|
||||
# Auth Backend LDAP-UserBind; Template for userbind
|
||||
# %n => username
|
||||
# %u => user part of username when it is an email
|
||||
# %u => domain part of username when it is an email
|
||||
define("BAIKAL_DAV_LDAP_DN_TEMPLATE", 'cn=%u,dc=%d,ou=domains,o=server');
|
||||
|
||||
# Auth Backend LDAP-UserBind; attribute for displayname
|
||||
define("BAIKAL_DAV_LDAP_DISPLAYNAME_ATTR", 'cn');
|
||||
|
||||
# Auth Backend LDAP-UserBind; attribute for email
|
||||
define("BAIKAL_DAV_LDAP_EMAIL_ATTR", 'mail');
|
||||
|
||||
# Auth Backend Mail; protocol of service
|
||||
define("BAIKAL_DAV_MAIL_PROTOCOL", 'imap');
|
||||
|
||||
# Auth Backend Mail; server host:port
|
||||
define("BAIKAL_DAV_MAIL_SERVER", 'localhost:143');
|
||||
|
||||
# Auth Backend Mail; validate the ssl-certificate
|
||||
define("BAIKAL_DAV_MAIL_CHECK_CERT", TRUE);
|
||||
|
||||
# Auth Backends: automatic creation of users; default yes"
|
||||
define("BAIKAL_DAV_AUTO_CREATE_USER", TRUE);
|
||||
|
||||
# Baïkal Web Admin ON/OFF switch; default TRUE
|
||||
define("BAIKAL_ADMIN_ENABLED", TRUE);
|
||||
|
||||
# Baïkal Web Admin autolock ON/OFF switch; default FALSE
|
||||
define("BAIKAL_ADMIN_AUTOLOCKENABLED", FALSE);
|
||||
|
||||
# Baïkal Web admin password hash; Set via Baïkal Web Admin
|
||||
define("BAIKAL_ADMIN_PASSWORDHASH", "");
|
||||
CODE;
|
||||
$sCode = trim($sCode);
|
||||
return $sCode;
|
||||
}
|
||||
}
|
|
@ -1,244 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model\Config;
|
||||
|
||||
class System extends \Baikal\Model\Config {
|
||||
|
||||
protected $aConstants = array(
|
||||
"BAIKAL_PATH_SABREDAV" => array(
|
||||
"type" => "litteral",
|
||||
"comment" => "PATH to SabreDAV",
|
||||
),
|
||||
"BAIKAL_AUTH_REALM" => array(
|
||||
"type" => "string",
|
||||
"comment" => "If you change this value, you'll have to re-generate passwords for all your users",
|
||||
),
|
||||
"BAIKAL_CARD_BASEURI" => array(
|
||||
"type" => "litteral",
|
||||
"comment" => 'Should begin and end with a "/"',
|
||||
),
|
||||
"BAIKAL_CAL_BASEURI" => array(
|
||||
"type" => "litteral",
|
||||
"comment" => 'Should begin and end with a "/"',
|
||||
),
|
||||
"PROJECT_SQLITE_FILE" => array(
|
||||
"type" => "litteral",
|
||||
"comment" => "Define path to Baïkal Database SQLite file",
|
||||
),
|
||||
"PROJECT_DB_MYSQL" => array(
|
||||
"type" => "boolean",
|
||||
"comment" => "MySQL > Use MySQL instead of SQLite ?",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_HOST" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Host, including ':portnumber' if port is not the default one (3306)",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_DBNAME" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Database name",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_USERNAME" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Username",
|
||||
),
|
||||
"PROJECT_DB_MYSQL_PASSWORD" => array(
|
||||
"type" => "string",
|
||||
"comment" => "MySQL > Password",
|
||||
),
|
||||
"BAIKAL_ENCRYPTION_KEY" => array(
|
||||
"type" => "string",
|
||||
"comment" => "A random 32 bytes key that will be used to encrypt data",
|
||||
),
|
||||
"BAIKAL_CONFIGURED_VERSION" => array(
|
||||
"type" => "string",
|
||||
"comment" => "The currently configured Baïkal version",
|
||||
),
|
||||
);
|
||||
|
||||
# Default values
|
||||
protected $aData = array(
|
||||
"BAIKAL_PATH_SABREDAV" => 'PROJECT_PATH_FRAMEWORKS . "SabreDAV/lib/Sabre/"',
|
||||
"BAIKAL_AUTH_REALM" => "BaikalDAV",
|
||||
"BAIKAL_CARD_BASEURI" => 'PROJECT_BASEURI . "card.php/"',
|
||||
"BAIKAL_CAL_BASEURI" => 'PROJECT_BASEURI . "cal.php/"',
|
||||
"PROJECT_SQLITE_FILE" => 'PROJECT_PATH_SPECIFIC . "db/db.sqlite"',
|
||||
"PROJECT_DB_MYSQL" => FALSE,
|
||||
"PROJECT_DB_MYSQL_HOST" => "",
|
||||
"PROJECT_DB_MYSQL_DBNAME" => "",
|
||||
"PROJECT_DB_MYSQL_USERNAME" => "",
|
||||
"PROJECT_DB_MYSQL_PASSWORD" => "",
|
||||
"BAIKAL_ENCRYPTION_KEY" => "",
|
||||
"BAIKAL_CONFIGURED_VERSION" => "",
|
||||
);
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_CAL_BASEURI",
|
||||
"label" => "CalDAV base URI",
|
||||
"validation" => "required",
|
||||
"help" => "The absolute web path to cal.php",
|
||||
"popover" => array(
|
||||
"title" => "CalDAV base URI",
|
||||
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_CARD_BASEURI",
|
||||
"label" => "CardDAV base URI",
|
||||
"validation" => "required",
|
||||
"help" => "The absolute web path to card.php",
|
||||
"popover" => array(
|
||||
"title" => "CardDAV base URI",
|
||||
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_AUTH_REALM",
|
||||
"label" => "Auth realm",
|
||||
"validation" => "required",
|
||||
"help" => "Token used in authentication process.<br />If you change this, you'll have to reset all your users passwords.<br />You'll also loose access to this admin interface.",
|
||||
"popover" => array(
|
||||
"title" => "Auth realm",
|
||||
"content" => "If you change this, you'll loose your access to this interface.<br />In other words: <strong>you should not change this, unless YKWYD.</strong>"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "BAIKAL_PATH_SABREDAV",
|
||||
"label" => "Path to SabreDAV",
|
||||
"validation" => "required",
|
||||
"inputclass" => "input-xxlarge",
|
||||
"help" => "The absolute server path to SabreDAV API",
|
||||
"popover" => array(
|
||||
"title" => "Path to SabreDAV",
|
||||
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>",
|
||||
"position" => "top"
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_SQLITE_FILE",
|
||||
"label" => "SQLite file path",
|
||||
"validation" => "required",
|
||||
"inputclass" => "input-xxlarge",
|
||||
"help" => "The absolute server path to the SQLite file",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Checkbox(array(
|
||||
"prop" => "PROJECT_DB_MYSQL",
|
||||
"label" => "Use MySQL",
|
||||
"help" => "If checked, Baïkal will use MySQL instead of SQLite.",
|
||||
"refreshonchange" => TRUE,
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_HOST",
|
||||
"label" => "MySQL host",
|
||||
"help" => "Host ip or name, including ':portnumber' if port is not the default one (3306)"
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_DBNAME",
|
||||
"label" => "MySQL database name",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_USERNAME",
|
||||
"label" => "MySQL username",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "PROJECT_DB_MYSQL_PASSWORD",
|
||||
"label" => "MySQL password",
|
||||
)));
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public function label() {
|
||||
return "Baïkal Settings";
|
||||
}
|
||||
|
||||
protected static function getDefaultConfig() {
|
||||
|
||||
$sBaikalVersion = BAIKAL_VERSION;
|
||||
|
||||
$sCode =<<<CODE
|
||||
##############################################################################
|
||||
# System configuration
|
||||
# Should not be changed, unless YNWYD
|
||||
#
|
||||
# RULES
|
||||
# 0. All folder pathes *must* be suffixed by "/"
|
||||
# 1. All URIs *must* be suffixed by "/" if pointing to a folder
|
||||
#
|
||||
|
||||
# PATH to SabreDAV
|
||||
define("BAIKAL_PATH_SABREDAV", PROJECT_PATH_FRAMEWORKS . "SabreDAV/lib/Sabre/");
|
||||
|
||||
# If you change this value, you'll have to re-generate passwords for all your users
|
||||
define("BAIKAL_AUTH_REALM", "BaikalDAV");
|
||||
|
||||
# Should begin and end with a "/"
|
||||
define("BAIKAL_CARD_BASEURI", PROJECT_BASEURI . "card.php/");
|
||||
|
||||
# Should begin and end with a "/"
|
||||
define("BAIKAL_CAL_BASEURI", PROJECT_BASEURI . "cal.php/");
|
||||
|
||||
# Define path to Baïkal Database SQLite file
|
||||
define("PROJECT_SQLITE_FILE", PROJECT_PATH_SPECIFIC . "db/db.sqlite");
|
||||
|
||||
# MySQL > Use MySQL instead of SQLite ?
|
||||
define("PROJECT_DB_MYSQL", FALSE);
|
||||
|
||||
# MySQL > Host, including ':portnumber' if port is not the default one (3306)
|
||||
define("PROJECT_DB_MYSQL_HOST", "");
|
||||
|
||||
# MySQL > Database name
|
||||
define("PROJECT_DB_MYSQL_DBNAME", "");
|
||||
|
||||
# MySQL > Username
|
||||
define("PROJECT_DB_MYSQL_USERNAME", "");
|
||||
|
||||
# MySQL > Password
|
||||
define("PROJECT_DB_MYSQL_PASSWORD", "");
|
||||
|
||||
# A random 32 bytes key that will be used to encrypt data
|
||||
define("BAIKAL_ENCRYPTION_KEY", "");
|
||||
|
||||
# The currently configured Baïkal version
|
||||
define("BAIKAL_CONFIGURED_VERSION", "{$sBaikalVersion}");
|
||||
|
||||
CODE;
|
||||
$sCode = trim($sCode);
|
||||
return $sCode;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model;
|
||||
|
||||
class Principal extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "principals";
|
||||
const PRIMARYKEY = "id";
|
||||
protected $aData = array(
|
||||
"uri" => "",
|
||||
"displayname" => "",
|
||||
"email" => "",
|
||||
);
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace Baikal\Model;
|
||||
|
||||
class User extends \Flake\Core\Model\Db {
|
||||
const DATATABLE = "users";
|
||||
const PRIMARYKEY = "id";
|
||||
const LABELFIELD = "username";
|
||||
|
||||
protected $aData = array(
|
||||
"username" => "",
|
||||
"digesta1" => "",
|
||||
);
|
||||
|
||||
protected $oIdentityPrincipal = null;
|
||||
|
||||
public function initByPrimary($sPrimary) {
|
||||
parent::initByPrimary($sPrimary);
|
||||
|
||||
# Initializing principals
|
||||
$this->oIdentityPrincipal = \Baikal\Model\Principal::getBaseRequester()
|
||||
->addClauseEquals("uri", "principals/" . $this->get("username"))
|
||||
->execute()
|
||||
->first();
|
||||
}
|
||||
|
||||
public function getAddressBooksBaseRequester() {
|
||||
$oBaseRequester = \Baikal\Model\AddressBook::getBaseRequester();
|
||||
$oBaseRequester->addClauseEquals(
|
||||
"principaluri",
|
||||
"principals/" . $this->get("username")
|
||||
);
|
||||
|
||||
return $oBaseRequester;
|
||||
}
|
||||
|
||||
public function getCalendarsBaseRequester() {
|
||||
$oBaseRequester = \Baikal\Model\Calendar::getBaseRequester();
|
||||
$oBaseRequester->addClauseEquals(
|
||||
"principaluri",
|
||||
"principals/" . $this->get("username")
|
||||
);
|
||||
|
||||
return $oBaseRequester;
|
||||
}
|
||||
|
||||
public function initFloating() {
|
||||
parent::initFloating();
|
||||
|
||||
# Initializing principals
|
||||
$this->oIdentityPrincipal = new \Baikal\Model\Principal();
|
||||
}
|
||||
|
||||
public function get($sPropName) {
|
||||
|
||||
if($sPropName === "password" || $sPropName === "passwordconfirm") {
|
||||
# Special handling for password and passwordconfirm
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
# does the property exist on the model object ?
|
||||
$sRes = parent::get($sPropName);
|
||||
} catch(\Exception $e) {
|
||||
# no, it may belong to the oIdentityPrincipal model object
|
||||
$sRes = $this->oIdentityPrincipal->get($sPropName);
|
||||
}
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
public function set($sPropName, $sPropValue) {
|
||||
|
||||
if($sPropName === "password" || $sPropName === "passwordconfirm") {
|
||||
# Special handling for password and passwordconfirm
|
||||
|
||||
if($sPropName === "password" && $sPropValue !== "") {
|
||||
parent::set(
|
||||
"digesta1",
|
||||
$this->getPasswordHashForPassword($sPropValue)
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
try {
|
||||
# does the property exist on the model object ?
|
||||
parent::set($sPropName, $sPropValue);
|
||||
} catch(\Exception $e) {
|
||||
# no, it may belong to the oIdentityPrincipal model object
|
||||
$this->oIdentityPrincipal->set($sPropName, $sPropValue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function persist() {
|
||||
|
||||
$bFloating = $this->floating();
|
||||
|
||||
# Persisted first, as Model users loads this data
|
||||
$this->oIdentityPrincipal->set("uri", "principals/" . $this->get("username"));
|
||||
$this->oIdentityPrincipal->persist();
|
||||
|
||||
parent::persist();
|
||||
|
||||
if($bFloating) {
|
||||
|
||||
# Creating default calendar for user
|
||||
$oDefaultCalendar = new \Baikal\Model\Calendar();
|
||||
$oDefaultCalendar->set(
|
||||
"principaluri",
|
||||
"principals/" . $this->get("username")
|
||||
)->set(
|
||||
"displayname",
|
||||
"Default calendar"
|
||||
)->set(
|
||||
"uri",
|
||||
"default"
|
||||
)->set(
|
||||
"ctag",
|
||||
1
|
||||
)->set(
|
||||
"description",
|
||||
"Default calendar"
|
||||
)->set(
|
||||
"components",
|
||||
"VEVENT,VTODO"
|
||||
);
|
||||
|
||||
$oDefaultCalendar->persist();
|
||||
|
||||
# Creating default address book for user
|
||||
$oDefaultAddressBook = new \Baikal\Model\AddressBook();
|
||||
$oDefaultAddressBook->set(
|
||||
"principaluri",
|
||||
"principals/" . $this->get("username")
|
||||
)->set(
|
||||
"displayname",
|
||||
"Default Address Book"
|
||||
)->set(
|
||||
"uri",
|
||||
"default"
|
||||
)->set(
|
||||
"description",
|
||||
"Default Address Book for " . $this->get("displayname")
|
||||
);
|
||||
|
||||
$oDefaultAddressBook->persist();
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
# TODO: delete all related resources (principals, calendars, calendar events, contact books and contacts)
|
||||
|
||||
# Destroying identity principal
|
||||
$this->oIdentityPrincipal->destroy();
|
||||
|
||||
$oCalendars = $this->getCalendarsBaseRequester()->execute();
|
||||
foreach($oCalendars as $calendar) {
|
||||
$calendar->destroy();
|
||||
}
|
||||
|
||||
$oAddressBooks = $this->getAddressBooksBaseRequester()->execute();
|
||||
foreach($oAddressBooks as $addressbook) {
|
||||
$addressbook->destroy();
|
||||
}
|
||||
|
||||
parent::destroy();
|
||||
}
|
||||
|
||||
public function getMailtoURI() {
|
||||
return "mailto:" . rawurlencode($this->get("displayname") . " <" . $this->get("email") . ">");
|
||||
}
|
||||
|
||||
public function formMorphologyForThisModelInstance() {
|
||||
$oMorpho = new \Formal\Form\Morphology();
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "username",
|
||||
"label" => "Username",
|
||||
"validation" => "required,unique",
|
||||
"popover" => array(
|
||||
"title" => "Username",
|
||||
"content" => "The login for this user account.<br />It has to be unique.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "displayname",
|
||||
"label" => "Display name",
|
||||
"validation" => "required",
|
||||
"popover" => array(
|
||||
"title" => "Display name",
|
||||
"content" => "This is the name that will be displayed in your CalDAV/CardDAV clients.",
|
||||
)
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Text(array(
|
||||
"prop" => "email",
|
||||
"label" => "Email",
|
||||
"validation" => "required,email"
|
||||
)));
|
||||
|
||||
if($this->floating()) {
|
||||
$oMorpho->element("username")->setOption("help", "May be an email, but not forcibly.");
|
||||
} else {
|
||||
$oMorpho->element("username")->setOption("readonly", true);
|
||||
}
|
||||
|
||||
if( BAIKAL_DAV_AUTH_TYPE == "Digest" || BAIKAL_DAV_AUTH_TYPE == "Basic") {
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "password",
|
||||
"label" => "Password",
|
||||
)));
|
||||
|
||||
$oMorpho->add(new \Formal\Element\Password(array(
|
||||
"prop" => "passwordconfirm",
|
||||
"label" => "Confirm password",
|
||||
"validation" => "sameas:password",
|
||||
)));
|
||||
|
||||
if($this->floating()) {
|
||||
$oMorpho->element("password")->setOption("validation", "required");
|
||||
} else {
|
||||
$sNotice = "-- Leave empty to keep current password --";
|
||||
|
||||
$oMorpho->element("password")->setOption("popover", array(
|
||||
"title" => "Password",
|
||||
"content" => "Write something here only if you want to change the user password."
|
||||
));
|
||||
|
||||
$oMorpho->element("passwordconfirm")->setOption("popover", array(
|
||||
"title" => "Confirm password",
|
||||
"content" => "Write something here only if you want to change the user password."
|
||||
));
|
||||
|
||||
$oMorpho->element("password")->setOption("placeholder", $sNotice);
|
||||
$oMorpho->element("passwordconfirm")->setOption("placeholder", $sNotice);
|
||||
}
|
||||
}
|
||||
|
||||
return $oMorpho;
|
||||
}
|
||||
|
||||
public static function icon() {
|
||||
return "icon-user";
|
||||
}
|
||||
|
||||
public static function mediumicon() {
|
||||
return "glyph-user";
|
||||
}
|
||||
|
||||
public static function bigicon() {
|
||||
return "glyph2x-user";
|
||||
}
|
||||
|
||||
public function getPasswordHashForPassword($sPassword) {
|
||||
return md5($this->get("username") . ':' . BAIKAL_AUTH_REALM . ':' . $sPassword);
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
TEMPDATE="`date +%Y-%m-%d-%H-%M-%S`"
|
||||
TEMPDIR="/tmp/baikal-flat-$TEMPDATE-temp"
|
||||
TEMPARCHIVE="$TEMPDIR/temparchive.tgz"
|
||||
TEMPDIRDEREFERENCE="/tmp/baikal-flat-$TEMPDATE"
|
||||
|
||||
echo "########################################################################"
|
||||
echo "#"
|
||||
echo "# Baïkal Packaging script"
|
||||
echo "#"
|
||||
echo "# Packaging project for flat distribution (replacing symlinks"
|
||||
echo "# by their target). Useful for FTP deployment"
|
||||
echo "#"
|
||||
echo "# TEMPDIR: $TEMPDIR"
|
||||
|
||||
rm -rf /tmp/baikal-flat
|
||||
|
||||
# Export Project
|
||||
# Requires the git-archive-all script by https://github.com/Kentzo (https://github.com/Kentzo/git-archive-all)
|
||||
|
||||
mkdir $TEMPDIR && \
|
||||
git-archive-all --force-submodules $TEMPARCHIVE && \
|
||||
cd $TEMPDIR && tar -xzf $TEMPARCHIVE && rm $TEMPARCHIVE && \
|
||||
|
||||
# Dereferencig symlinks
|
||||
cp -RfL $TEMPDIR $TEMPDIRDEREFERENCE && \
|
||||
rm -Rf $TEMPDIR && \
|
||||
|
||||
TEMPDIR=$TEMPDIRDEREFERENCE/temparchive && \
|
||||
|
||||
# Jump to tempdir
|
||||
cd $TEMPDIR && \
|
||||
|
||||
# Cleaning Resources
|
||||
rm -f Core/Resources/Web/README.md && \
|
||||
rm -Rf Core/Resources/Web/TwitterBootstrap && \
|
||||
|
||||
# Cleaning Scripts
|
||||
rm -Rf Core/Scripts && \
|
||||
rm -Rf Core/Frameworks/Baikal/Scripts && \
|
||||
|
||||
# Cleaning WWWRoot
|
||||
rm -Rf Core/Frameworks/Baikal/WWWRoot && \
|
||||
rm -Rf Core/Frameworks/BaikalAdmin/WWWRoot && \
|
||||
|
||||
# Cleaning Specific/Virtualhosts
|
||||
rm -Rf Specific/virtualhosts && \
|
||||
|
||||
# Installing dependencies (composer)
|
||||
composer install && \
|
||||
|
||||
# Removing composer stuff
|
||||
rm -f composer.* && \
|
||||
|
||||
# Moving HTML roots
|
||||
mv html/* . && \
|
||||
mv html/.htaccess . && \
|
||||
rm -Rf html && \
|
||||
|
||||
# Tagging Distrib
|
||||
cat Core/Distrib.php | sed -e "s/\"regular\"/\"flat\"/g" > Core/Distrib2.php && \
|
||||
rm -f Core/Distrib.php && \
|
||||
mv Core/Distrib2.php Core/Distrib.php && \
|
||||
|
||||
# Deploy empty DB
|
||||
mkdir -p Specific/db && \
|
||||
cp Core/Resources/Db/SQLite/db.sqlite Specific/db && \
|
||||
|
||||
# Add ENABLE_INSTALL
|
||||
|
||||
touch Specific/ENABLE_INSTALL && \
|
||||
|
||||
# Zipping package
|
||||
cd .. && \
|
||||
mv $TEMPDIR baikal-flat && \
|
||||
zip -r baikal-flat.zip baikal-flat && \
|
||||
mv baikal-flat.zip ~/Desktop/ && \
|
||||
|
||||
# Displaying result
|
||||
echo "# Success: ~/Desktop/baikal-flat.zip"
|
|
@ -1,53 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
TEMPDATE="`date +%Y-%m-%d-%H-%M-%S`"
|
||||
TEMPDIR="/tmp/baikal-regular-$TEMPDATE"
|
||||
TEMPARCHIVE="$TEMPDIR/temparchive.tgz"
|
||||
|
||||
echo "########################################################################"
|
||||
echo "#"
|
||||
echo "# Baïkal Packaging script"
|
||||
echo "#"
|
||||
echo "# Packaging project for regular distribution"
|
||||
echo "#"
|
||||
echo "# TEMPDIR: $TEMPDIR"
|
||||
|
||||
rm -rf /tmp/baikal-regular
|
||||
|
||||
# Export Project
|
||||
# Requires the git-archive-all script by https://github.com/Kentzo (https://github.com/Kentzo/git-archive-all)
|
||||
|
||||
mkdir -p $TEMPDIR && \
|
||||
git-archive-all --force-submodules $TEMPARCHIVE && \
|
||||
cd $TEMPDIR && tar -xzf $TEMPARCHIVE && rm $TEMPARCHIVE && \
|
||||
|
||||
TEMPDIR=$TEMPDIR/temparchive && \
|
||||
|
||||
# Jump to tempdir
|
||||
cd $TEMPDIR && \
|
||||
|
||||
# Cleaning Scripts
|
||||
rm -Rf Core/Scripts && \
|
||||
rm -Rf Core/Frameworks/Baikal/Scripts && \
|
||||
|
||||
# Deploy empty DB
|
||||
mkdir -p Specific/db && \
|
||||
cp Core/Resources/Db/SQLite/db.sqlite Specific/db && \
|
||||
|
||||
# Add ENABLE_INSTALL
|
||||
|
||||
touch Specific/ENABLE_INSTALL && \
|
||||
|
||||
# Installing dependencies (composer)
|
||||
composer install && \
|
||||
|
||||
# Removing composer stuff
|
||||
rm -f composer.* && \
|
||||
|
||||
# GZipping package
|
||||
cd .. && \
|
||||
mv $TEMPDIR baikal-regular && \
|
||||
tar -cvzf baikal-regular.tgz baikal-regular && \
|
||||
mv baikal-regular.tgz ~/Desktop/ && \
|
||||
|
||||
# Displaying result
|
||||
echo "# Success: ~/Desktop/baikal-regular.tgz"
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
* All rights reserved
|
||||
*
|
||||
* http://baikal-server.com
|
||||
*
|
||||
* This script is part of the Baïkal Server project. The Baïkal
|
||||
* Server project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
ini_set("session.cookie_httponly", 1);
|
||||
ini_set("display_errors", 0);
|
||||
ini_set("log_errors", 1);
|
||||
|
||||
define("BAIKAL_CONTEXT", TRUE);
|
||||
define("PROJECT_CONTEXT_BASEURI", "/");
|
||||
|
||||
if(file_exists(getcwd() . "/Core")) {
|
||||
# Flat FTP mode
|
||||
define("PROJECT_PATH_ROOT", getcwd() . "/"); #./
|
||||
} else {
|
||||
# Dedicated server mode
|
||||
define("PROJECT_PATH_ROOT", dirname(getcwd()) . "/"); #../
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
|
||||
die('<h1>Incomplete installation</h1><p>Baïkal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Baïkal.');
|
||||
}
|
||||
|
||||
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
|
||||
|
||||
# Bootstraping Flake
|
||||
\Flake\Framework::bootstrap();
|
||||
# Bootstrapping Baïkal
|
||||
\Baikal\Framework::bootstrap();
|
||||
|
||||
if(!defined("BAIKAL_CAL_ENABLED") || BAIKAL_CAL_ENABLED !== TRUE) {
|
||||
throw new ErrorException("Baikal CalDAV is disabled.", 0, 255, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
# Backends
|
||||
if( BAIKAL_DAV_AUTH_TYPE == "Digest" && !preg_match('/Windows-Phone-WebDAV-Client/i', $_SERVER['HTTP_USER_AGENT']))
|
||||
$authBackend = new \Sabre\DAV\Auth\Backend\PDO($GLOBALS["DB"]->getPDO());
|
||||
else {
|
||||
switch (strtoupper(BAIKAL_DAV_AUTH_TYPE)) {
|
||||
case "MAIL":
|
||||
$authBackend = new \Baikal\Core\MailAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
break;
|
||||
case "LDAP-USERBIND":
|
||||
$authBackend = new \Baikal\Core\LDAPUserBindAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
break;
|
||||
default:
|
||||
$authBackend = new \Baikal\Core\PDOBasicAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
}
|
||||
}
|
||||
|
||||
$principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($GLOBALS["DB"]->getPDO());
|
||||
$calendarBackend = new \Sabre\CalDAV\Backend\PDO($GLOBALS["DB"]->getPDO());
|
||||
|
||||
# Directory structure
|
||||
$nodes = array(
|
||||
new \Sabre\CalDAV\Principal\Collection($principalBackend),
|
||||
new \Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend),
|
||||
);
|
||||
|
||||
# Initializing server
|
||||
$server = new \Sabre\DAV\Server($nodes);
|
||||
$server->setBaseUri(BAIKAL_CAL_BASEURI);
|
||||
|
||||
# Server Plugins
|
||||
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, BAIKAL_AUTH_REALM));
|
||||
$server->addPlugin(new \Sabre\DAVACL\Plugin());
|
||||
$server->addPlugin(new \Sabre\CalDAV\Plugin());
|
||||
|
||||
# And off we go!
|
||||
$server->exec();
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
* All rights reserved
|
||||
*
|
||||
* http://baikal-server.com
|
||||
*
|
||||
* This script is part of the Baïkal Server project. The Baïkal
|
||||
* Server project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
define("BAIKAL_CONTEXT", TRUE);
|
||||
define("PROJECT_CONTEXT_BASEURI", "/");
|
||||
|
||||
if(file_exists(getcwd() . "/Core")) {
|
||||
# Flat FTP mode
|
||||
define("PROJECT_PATH_ROOT", getcwd() . "/"); #./
|
||||
} else {
|
||||
# Dedicated server mode
|
||||
define("PROJECT_PATH_ROOT", dirname(getcwd()) . "/"); #../
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
|
||||
die('<h1>Incomplete installation</h1><p>Baïkal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Baïkal.');
|
||||
}
|
||||
|
||||
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
|
||||
|
||||
# Bootstraping Flake
|
||||
\Flake\Framework::bootstrap();
|
||||
|
||||
# Bootstrapping Baïkal
|
||||
\Baikal\Framework::bootstrap();
|
||||
|
||||
if(!defined("BAIKAL_CARD_ENABLED") || BAIKAL_CARD_ENABLED !== TRUE) {
|
||||
throw new ErrorException("Baikal CardDAV is disabled.", 0, 255, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
# Backends
|
||||
if( BAIKAL_DAV_AUTH_TYPE == "Digest" && !preg_match('/Windows-Phone-WebDAV-Client/i', $_SERVER['HTTP_USER_AGENT']))
|
||||
$authBackend = new \Sabre\DAV\Auth\Backend\PDO($GLOBALS["DB"]->getPDO());
|
||||
else {
|
||||
switch (strtoupper(BAIKAL_DAV_AUTH_TYPE)) {
|
||||
case "MAIL":
|
||||
$authBackend = new \Baikal\Core\MailAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
break;
|
||||
case "LDAP-USERBIND":
|
||||
$authBackend = new \Baikal\Core\LDAPUserBindAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
break;
|
||||
default:
|
||||
$authBackend = new \Baikal\Core\PDOBasicAuth($GLOBALS["DB"]->getPDO(), BAIKAL_AUTH_REALM);
|
||||
}
|
||||
}
|
||||
|
||||
$principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($GLOBALS["DB"]->getPDO());
|
||||
$carddavBackend = new \Sabre\CardDAV\Backend\PDO($GLOBALS["DB"]->getPDO());
|
||||
|
||||
# Setting up the directory tree
|
||||
$nodes = array(
|
||||
new \Sabre\DAVACL\PrincipalCollection($principalBackend),
|
||||
new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend),
|
||||
);
|
||||
|
||||
# The object tree needs in turn to be passed to the server class
|
||||
$server = new \Sabre\DAV\Server($nodes);
|
||||
$server->setBaseUri(BAIKAL_CARD_BASEURI);
|
||||
|
||||
# Plugins
|
||||
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, BAIKAL_AUTH_REALM));
|
||||
$server->addPlugin(new \Sabre\CardDAV\Plugin());
|
||||
$server->addPlugin(new \Sabre\DAVACL\Plugin());
|
||||
|
||||
# And off we go!
|
||||
$server->exec();
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
* All rights reserved
|
||||
*
|
||||
* http://baikal-server.com
|
||||
*
|
||||
* This script is part of the Baïkal Server project. The Baïkal
|
||||
* Server project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
ini_set("session.cookie_httponly", 1);
|
||||
ini_set("display_errors", 0);
|
||||
ini_set("log_errors", 1);
|
||||
|
||||
define("BAIKAL_CONTEXT", TRUE);
|
||||
define("PROJECT_CONTEXT_BASEURI", "/");
|
||||
|
||||
if(file_exists(getcwd() . "/Core")) {
|
||||
# Flat FTP mode
|
||||
define("PROJECT_PATH_ROOT", getcwd() . "/"); #./
|
||||
} else {
|
||||
# Dedicated server mode
|
||||
define("PROJECT_PATH_ROOT", dirname(getcwd()) . "/"); #../
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
|
||||
die('<h1>Incomplete installation</h1><p>Baïkal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Baïkal.');
|
||||
}
|
||||
|
||||
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
|
||||
|
||||
# Bootstraping Flake
|
||||
\Flake\Framework::bootstrap();
|
||||
|
||||
# Bootstrapping Baïkal
|
||||
\Baikal\Framework::bootstrap();
|
||||
|
||||
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Baïkal Server</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Baïkal is running allright.</h2>
|
||||
</body>
|
||||
</html>
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Dashboard extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$oView = new \BaikalAdmin\View\Dashboard();
|
||||
$oView->setData("BAIKAL_VERSION", BAIKAL_VERSION);
|
||||
$oView->setData("PROJECT_PACKAGE", PROJECT_PACKAGE);
|
||||
|
||||
# Services status
|
||||
$oView->setData("BAIKAL_CAL_ENABLED", BAIKAL_CAL_ENABLED);
|
||||
$oView->setData("BAIKAL_CARD_ENABLED", BAIKAL_CARD_ENABLED);
|
||||
|
||||
# Statistics: Users
|
||||
$iNbUsers = \Baikal\Model\User::getBaseRequester()->count();
|
||||
$oView->setData("nbusers", $iNbUsers);
|
||||
|
||||
# Statistics: CalDAV
|
||||
$iNbCalendars = \Baikal\Model\Calendar::getBaseRequester()->count();
|
||||
$oView->setData("nbcalendars", $iNbCalendars);
|
||||
|
||||
$iNbEvents = \Baikal\Model\Calendar\Event::getBaseRequester()->count();
|
||||
$oView->setData("nbevents", $iNbEvents);
|
||||
|
||||
# Statistics: CardDAV
|
||||
$iNbBooks = \Baikal\Model\AddressBook::getBaseRequester()->count();
|
||||
$oView->setData("nbbooks", $iNbBooks);
|
||||
|
||||
$iNbContacts = \Baikal\Model\AddressBook\Contact::getBaseRequester()->count();
|
||||
$oView->setData("nbcontacts", $iNbContacts);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Install;
|
||||
|
||||
class Database extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
protected $oModel;
|
||||
protected $oForm; # \Formal\Form
|
||||
|
||||
public function execute() {
|
||||
$this->oModel = new \Baikal\Model\Config\Database(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance(array(
|
||||
"close" => FALSE,
|
||||
"hook.validation" => array($this, "validateMySQLConnection"),
|
||||
"hook.morphology" => array($this, "hideMySQLFieldWhenNeeded"),
|
||||
));
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
|
||||
# nothing here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$sBigIcon = "glyph2x-magic";
|
||||
$sBaikalVersion = BAIKAL_VERSION;
|
||||
|
||||
$oView = new \BaikalAdmin\View\Install\Database();
|
||||
$oView->setData("baikalversion", BAIKAL_VERSION);
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
|
||||
\BaikalAdmin\Core\Auth::lockInstall();
|
||||
|
||||
$sMessage = "<p>Baïkal is now installed, and it's database properly configured. <strong>For security reasons, this installation wizard is now disabled.</strong></p>";
|
||||
$sMessage . "<p> </p>";
|
||||
$sMessage .= "<p><a class='btn btn-success' href='" . PROJECT_URI . "admin/'>Start using Baïkal</a></p>";
|
||||
$sForm = "";
|
||||
} else {
|
||||
$sMessage = "";
|
||||
$sForm = $this->oForm->render();
|
||||
}
|
||||
|
||||
$oView->setData("message", $sMessage);
|
||||
$oView->setData("form", $sForm);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
public function validateMySQLConnection($oForm, $oMorpho) {
|
||||
|
||||
$bMySQLEnabled = $oMorpho->element("PROJECT_DB_MYSQL")->value();
|
||||
|
||||
if($bMySQLEnabled) {
|
||||
|
||||
$sHost = $oMorpho->element("PROJECT_DB_MYSQL_HOST")->value();
|
||||
$sDbname = $oMorpho->element("PROJECT_DB_MYSQL_DBNAME")->value();
|
||||
$sUsername = $oMorpho->element("PROJECT_DB_MYSQL_USERNAME")->value();
|
||||
$sPassword = $oMorpho->element("PROJECT_DB_MYSQL_PASSWORD")->value();
|
||||
|
||||
try {
|
||||
$oDb = new \Flake\Core\Database\Mysql(
|
||||
$sHost,
|
||||
$sDbname,
|
||||
$sUsername,
|
||||
$sPassword
|
||||
);
|
||||
|
||||
if(($aMissingTables = \Baikal\Core\Tools::isDBStructurallyComplete($oDb)) !== TRUE) {
|
||||
|
||||
# Checking if all tables are missing
|
||||
$aRequiredTables = \Baikal\Core\Tools::getRequiredTablesList();
|
||||
if(count($aRequiredTables) !== count($aMissingTables)) {
|
||||
$sMessage = "<br /><p><strong>Database is not structurally complete.</strong></p>";
|
||||
$sMessage .= "<p>Missing tables are: <strong>" . implode("</strong>, <strong>", $aMissingTables) . "</strong></p>";
|
||||
$sMessage .= "<p>You will find the SQL definition of Baïkal tables in this file: <strong>Core/Resources/Db/MySQL/db.sql</strong></p>";
|
||||
$sMessage .= "<br /><p>Nothing has been saved. <strong>Please, add these tables to the database before pursuing Baïkal initialization.</strong></p>";
|
||||
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL"),
|
||||
$sMessage
|
||||
);
|
||||
} else {
|
||||
# All tables are missing
|
||||
# We add these tables ourselves to the database, to initialize Baïkal
|
||||
$sSqlDefinition = file_get_contents(PROJECT_PATH_CORERESOURCES . "Db/MySQL/db.sql");
|
||||
$oDb->query($sSqlDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} catch(\Exception $e) {
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL"),
|
||||
"Baïkal was not able to establish a connexion to the MySQL database as configured.<br />MySQL says: " . $e->getMessage()
|
||||
);
|
||||
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL_HOST")
|
||||
);
|
||||
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL_DBNAME")
|
||||
);
|
||||
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL_USERNAME")
|
||||
);
|
||||
|
||||
$oForm->declareError(
|
||||
$oMorpho->element("PROJECT_DB_MYSQL_PASSWORD")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideMySQLFieldWhenNeeded(\Formal\Form $oForm, \Formal\Form\Morphology $oMorpho) {
|
||||
|
||||
if($oForm->submitted()) {
|
||||
$bMySQL = (intval($oForm->postValue("PROJECT_DB_MYSQL")) === 1);
|
||||
} else {
|
||||
$bMySQL = PROJECT_DB_MYSQL;
|
||||
}
|
||||
|
||||
if($bMySQL === TRUE) {
|
||||
$oMorpho->remove("PROJECT_SQLITE_FILE");
|
||||
} else {
|
||||
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_HOST");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_DBNAME");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_USERNAME");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_PASSWORD");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Install;
|
||||
|
||||
class Initialize extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
protected $oModel;
|
||||
protected $oForm; # \Formal\Form
|
||||
|
||||
public function execute() {
|
||||
# Assert that /Specific is writable
|
||||
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC) || !is_dir(PROJECT_PATH_SPECIFIC) || !is_writable(PROJECT_PATH_SPECIFIC)) {
|
||||
$message = "<h1>Error - Insufficient permissions on the <span style='background-color: yellow;'>Specific/</span> folder</h1><p>";
|
||||
$message .= "<p>In order to work properly, Baïkal needs to have write permissions in the <strong>Specific/</strong> folder.</p>";
|
||||
|
||||
die($message);
|
||||
}
|
||||
|
||||
$this->createHtaccessFilesIfNeeded();
|
||||
|
||||
$this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php");
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance(array(
|
||||
"close" => FALSE
|
||||
));
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
|
||||
# Creating system config, and initializing BAIKAL_ENCRYPTION_KEY
|
||||
$oSystemConfig = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
$oSystemConfig->set("BAIKAL_ENCRYPTION_KEY", md5(microtime() . rand()));
|
||||
|
||||
# Default: PDO::SQLite or PDO::MySQL ?
|
||||
$aPDODrivers = \PDO::getAvailableDrivers();
|
||||
if(!in_array('sqlite', $aPDODrivers)) { # PDO::MySQL is already asserted in \Baikal\Core\Tools::assertEnvironmentIsOk()
|
||||
$oSystemConfig->set("PROJECT_DB_MYSQL", TRUE);
|
||||
}
|
||||
|
||||
$oSystemConfig->persist();
|
||||
|
||||
# Using default PROJECT_SQLITE_FILE
|
||||
$PROJECT_SQLITE_FILE = PROJECT_PATH_SPECIFIC . "db/db.sqlite";
|
||||
|
||||
if(!file_exists($PROJECT_SQLITE_FILE)) {
|
||||
# Installing default sqlite database
|
||||
@copy(PROJECT_PATH_CORERESOURCES . "Db/SQLite/db.sqlite", $PROJECT_SQLITE_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$sBigIcon = "glyph2x-magic";
|
||||
$sBaikalVersion = BAIKAL_VERSION;
|
||||
|
||||
$oView = new \BaikalAdmin\View\Install\Initialize();
|
||||
$oView->setData("baikalversion", BAIKAL_VERSION);
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
$sLink = PROJECT_URI . "admin/install/?/database";
|
||||
\Flake\Util\Tools::redirect($sLink);
|
||||
exit(0);
|
||||
|
||||
#$sMessage = "<p>Baïkal is now configured. You may <a class='btn btn-success' href='" . PROJECT_URI . "admin/'>Access the Baïkal admin</a></p>";
|
||||
#$sForm = "";
|
||||
} else {
|
||||
$sMessage = "";
|
||||
$sForm = $this->oForm->render();
|
||||
}
|
||||
|
||||
$oView->setData("message", $sMessage);
|
||||
$oView->setData("form", $sForm);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
protected function createHtaccessFilesIfNeeded() {
|
||||
|
||||
if(!file_exists(PROJECT_PATH_DOCUMENTROOT . ".htaccess")) {
|
||||
@copy(PROJECT_PATH_CORERESOURCES . "System/htaccess-documentroot", PROJECT_PATH_DOCUMENTROOT . ".htaccess");
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_DOCUMENTROOT . ".htaccess")) {
|
||||
throw new \Exception("Unable to create " . PROJECT_PATH_DOCUMENTROOT . ".htaccess; you may try to create it manually by copying " . PROJECT_PATH_CORERESOURCES . "System/htaccess-documentroot");
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . ".htaccess")) {
|
||||
@copy(PROJECT_PATH_CORERESOURCES . "System/htaccess-specific", PROJECT_PATH_SPECIFIC . ".htaccess");
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_SPECIFIC . ".htaccess")) {
|
||||
throw new \Exception("Unable to create " . PROJECT_PATH_SPECIFIC . ".htaccess; you may try to create it manually by copying " . PROJECT_PATH_CORERESOURCES . "System/htaccess-specific");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Install;
|
||||
|
||||
class VersionUpgrade extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
protected $oModel;
|
||||
protected $oForm; # \Formal\Form
|
||||
|
||||
protected $aErrors = array();
|
||||
protected $aSuccess = array();
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$sBigIcon = "glyph2x-magic";
|
||||
$sBaikalVersion = BAIKAL_VERSION;
|
||||
$sBaikalConfiguredVersion = BAIKAL_CONFIGURED_VERSION;
|
||||
|
||||
if(BAIKAL_CONFIGURED_VERSION === BAIKAL_VERSION) {
|
||||
$sMessage = "Your system is configured to use version <strong>" . $sBaikalConfiguredVersion . "</strong>.<br />There's no upgrade to be done.";
|
||||
} else {
|
||||
$sMessage = "Upgrading Baïkal from version <strong>" . $sBaikalConfiguredVersion . "</strong> to version <strong>" . $sBaikalVersion . "</strong>";
|
||||
}
|
||||
|
||||
$sHtml = <<<HTML
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="{$sBigIcon}"></i>Baïkal upgrade wizard</h1>
|
||||
<p class="lead">{$sMessage}</p>
|
||||
</header>
|
||||
HTML;
|
||||
|
||||
$bSuccess = $this->upgrade(BAIKAL_CONFIGURED_VERSION, BAIKAL_VERSION);
|
||||
|
||||
if(!empty($this->aErrors)) {
|
||||
$sHtml .= "<h3>Errors</h3>" . implode("<br />\n", $this->aErrors);
|
||||
}
|
||||
|
||||
if(!empty($this->aSuccess)) {
|
||||
$sHtml .= "<h3>Successful operations</h3>" . implode("<br />\n", $this->aSuccess);
|
||||
}
|
||||
|
||||
if($bSuccess === FALSE) {
|
||||
$sHtml .= "<p> </p><p><span class='label label-important'>Error</span> Baïkal has not been upgraded. See the section 'Errors' for details.</p>";
|
||||
} else {
|
||||
$sHtml .= "<p> </p><p>Baïkal has been successfully upgraded. You may now <a class='btn btn-success' href='" . PROJECT_URI . "admin/'>Access the Baïkal admin</a></p>";
|
||||
}
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
protected function upgrade($sVersionFrom, $sVersionTo) {
|
||||
|
||||
if($sVersionFrom === "0.2.0") {
|
||||
|
||||
$sOldDbFilePath = PROJECT_PATH_SPECIFIC . "Db/.ht.db.sqlite";
|
||||
|
||||
if(PROJECT_SQLITE_FILE === $sOldDbFilePath) {
|
||||
$sNewDbFilePath = PROJECT_PATH_SPECIFIC . "Db/db.sqlite";
|
||||
|
||||
# Move old db from Specific/Db/.ht.db.sqlite to Specific/Db/db.sqlite
|
||||
if(!file_exists($sNewDbFilePath)) {
|
||||
if(!is_writable(dirname($sNewDbFilePath))) {
|
||||
$this->aErrors[] = "DB file path '" . dirname($sNewDbFilePath) . "' is not writable";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!@copy($sOldDbFilePath, $sNewDbFilePath)) {
|
||||
$this->aErrors[] = "DB could not be copied from '" . $sOldDbFilePath . "' to '" . $sNewDbFilePath . "'.";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->aSuccess[] = "SQLite database has been renamed from '" . $sOldDbFilePath . "' to '" . $sNewDbFilePath . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($sVersionFrom, '0.2.3', '<=')) {
|
||||
# Upgrading DB
|
||||
|
||||
# etag VARCHAR(32),
|
||||
# size INT(11) UNSIGNED NOT NULL,
|
||||
# componenttype VARCHAR(8),
|
||||
# firstoccurence INT(11) UNSIGNED,
|
||||
# lastoccurence INT(11) UNSIGNED,
|
||||
|
||||
if(defined("PROJECT_DB_MYSQL") && PROJECT_DB_MYSQL === TRUE) {
|
||||
$aSql = array(
|
||||
"ALTER TABLE calendarobjects ADD COLUMN etag VARCHAR(32)",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN size INT(11) UNSIGNED NOT NULL",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN componenttype VARCHAR(8)",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN firstoccurence INT(11) UNSIGNED",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN lastoccurence INT(11) UNSIGNED",
|
||||
"ALTER TABLE calendars ADD COLUMN transparent TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
);
|
||||
|
||||
$this->aSuccess[] = "MySQL database has been successfuly upgraded.";
|
||||
} else {
|
||||
$aSql = array(
|
||||
"ALTER TABLE calendarobjects ADD COLUMN etag text",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN size integer",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN componenttype text",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN firstoccurence integer",
|
||||
"ALTER TABLE calendarobjects ADD COLUMN lastoccurence integer",
|
||||
"ALTER TABLE calendars ADD COLUMN transparent bool",
|
||||
"ALTER TABLE principals ADD COLUMN vcardurl text", # This one is added in SQLite but not MySQL, because it is already there since the beginning in MySQL
|
||||
);
|
||||
|
||||
$this->aSuccess[] = "SQLite database has been successfuly upgraded.'";
|
||||
}
|
||||
|
||||
try{
|
||||
foreach($aSql as $sAlterTableSql) {
|
||||
$GLOBALS["DB"]->query($sAlterTableSql);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
$this->aSuccess = array();
|
||||
$this->aErrors[] = "<p>Database cannot be upgraded.<br />Caught exception: " . $e->getMessage() . "</p>";
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($sVersionFrom, '0.2.4', '<=')) {
|
||||
# Nothing to do :)
|
||||
}
|
||||
|
||||
$this->updateConfiguredVersion($sVersionTo);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
protected function updateConfiguredVersion($sVersionTo) {
|
||||
|
||||
# Create new settings
|
||||
$oConfig = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php");
|
||||
$oConfig->persist();
|
||||
|
||||
# Update BAIKAL_CONFIGURED_VERSION
|
||||
$oConfig = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
$oConfig->set("BAIKAL_CONFIGURED_VERSION", $sVersionTo);
|
||||
$oConfig->persist();
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Login extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$sActionUrl = \Flake\Util\Tools::getCurrentUrl();
|
||||
$sSubmittedFlagName = "auth";
|
||||
$sMessage = "";
|
||||
|
||||
if(self::isSubmitted() && !\BaikalAdmin\Core\Auth::isAuthenticated()) {
|
||||
$sMessage = \Formal\Core\Message::error(
|
||||
"The login/password you provided is invalid. Please retry.",
|
||||
"Authentication error"
|
||||
);
|
||||
} elseif(self::justLoggedOut()) {
|
||||
$sMessage = \Formal\Core\Message::notice(
|
||||
"You have been disconnected from your session.",
|
||||
"Session ended",
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
$sLogin = htmlspecialchars(\Flake\Util\Tools::POST("login"));
|
||||
$sPassword = htmlspecialchars(\Flake\Util\Tools::POST("password"));
|
||||
|
||||
if(trim($sLogin) === "") {
|
||||
$sLogin = "admin";
|
||||
}
|
||||
|
||||
$oView = new \BaikalAdmin\View\Login();
|
||||
$oView->setData("message", $sMessage);
|
||||
$oView->setData("actionurl", $sActionUrl);
|
||||
$oView->setData("submittedflagname", $sSubmittedFlagName);
|
||||
$oView->setData("login", $sLogin);
|
||||
$oView->setData("password", $sPassword);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
protected static function isSubmitted() {
|
||||
return (intval(\Flake\Util\Tools::POST("auth")) === 1);
|
||||
}
|
||||
|
||||
protected static function justLoggedOut() {
|
||||
$aParams = $GLOBALS["ROUTER"]::getURLParams();
|
||||
return (!empty($aParams) && $aParams[0] === "loggedout");
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Logout extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
\BaikalAdmin\Core\Auth::unAuthenticate();
|
||||
|
||||
$sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
|
||||
$sLink = $GLOBALS["ROUTER"]::buildRouteForController($sControllerForDefaultRoute, "loggedout");
|
||||
\Flake\Util\Tools::redirect($sLink);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Navigation;
|
||||
|
||||
class Topbar extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\Navigation\Topbar();
|
||||
|
||||
$sCurrentRoute = $GLOBALS["ROUTER"]::getCurrentRoute();
|
||||
$sActiveHome = $sActiveUsers = $sActiveSettingsStandard = $sActiveSettingsSystem = "";
|
||||
|
||||
$sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
|
||||
$sHomeLink = $sControllerForDefaultRoute::link();
|
||||
$sUsersLink = \BaikalAdmin\Controller\Users::link();
|
||||
$sSettingsStandardLink = \BaikalAdmin\Controller\Settings\Standard::link();
|
||||
$sSettingsSystemLink = \BaikalAdmin\Controller\Settings\System::link();
|
||||
$sLogoutLink = \BaikalAdmin\Controller\Logout::link();
|
||||
|
||||
if($sCurrentRoute === "default") {
|
||||
$sActiveHome = "active";
|
||||
}
|
||||
if(
|
||||
$sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Users") ||
|
||||
$sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\User\Calendars") ||
|
||||
$sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\User\AddressBooks")
|
||||
) {
|
||||
$sActiveUsers = "active";
|
||||
}
|
||||
|
||||
if($sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Settings\Standard")) {
|
||||
$sActiveSettingsStandard = "active";
|
||||
}
|
||||
|
||||
if($sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Settings\System")) {
|
||||
$sActiveSettingsSystem = "active";
|
||||
}
|
||||
|
||||
$oView->setData("activehome", $sActiveHome);
|
||||
$oView->setData("activeusers", $sActiveUsers);
|
||||
$oView->setData("activesettingsstandard", $sActiveSettingsStandard);
|
||||
$oView->setData("activesettingssystem", $sActiveSettingsSystem);
|
||||
$oView->setData("homelink", $sHomeLink);
|
||||
$oView->setData("userslink", $sUsersLink);
|
||||
$oView->setData("settingsstandardlink", $sSettingsStandardLink);
|
||||
$oView->setData("settingssystemlink", $sSettingsSystemLink);
|
||||
$oView->setData("logoutlink", $sLogoutLink);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Navigation\Topbar;
|
||||
|
||||
class Anonymous extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$oView = new \BaikalAdmin\View\Navigation\Topbar\Anonymous();
|
||||
return $oView->render();
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Navigation\Topbar;
|
||||
|
||||
class Install extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$oView = new \BaikalAdmin\View\Navigation\Topbar\Install();
|
||||
return $oView->render();
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Settings;
|
||||
|
||||
class Standard extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
$this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php");
|
||||
|
||||
# Assert that config file is writable
|
||||
if(!$this->oModel->writable()) {
|
||||
throw new \Exception("Config file is not writable;" . __FILE__ . " > " . __LINE__);
|
||||
}
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance(array(
|
||||
"close" => FALSE
|
||||
));
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\Settings\Standard();
|
||||
$oView->setData("form", $this->oForm->render());
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\Settings;
|
||||
|
||||
class System extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
$this->oModel = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php");
|
||||
|
||||
# Assert that config file is writable
|
||||
if(!$this->oModel->writable()) {
|
||||
throw new \Exception("System config file is not writable;" . __FILE__ . " > " . __LINE__);
|
||||
}
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance(array(
|
||||
"close" => FALSE,
|
||||
"hook.morphology" => array($this, "morphologyHook"),
|
||||
"hook.validation" => array($this, "validationHook"),
|
||||
));
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\Settings\System();
|
||||
$oView->setData("message", \Formal\Core\Message::notice(
|
||||
"Do not change anything on this page unless you really know what you are doing.<br />You might break Baïkal if you misconfigure something here.",
|
||||
"Warning !",
|
||||
FALSE
|
||||
));
|
||||
|
||||
$oView->setData("form", $this->oForm->render());
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
public function morphologyHook(\Formal\Form $oForm, \Formal\Form\Morphology $oMorpho) {
|
||||
if($oForm->submitted()) {
|
||||
$bMySQL = (intval($oForm->postValue("PROJECT_DB_MYSQL")) === 1);
|
||||
} else {
|
||||
$bMySQL = PROJECT_DB_MYSQL;
|
||||
}
|
||||
|
||||
if($bMySQL === TRUE) {
|
||||
$oMorpho->remove("PROJECT_SQLITE_FILE");
|
||||
} else {
|
||||
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_HOST");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_DBNAME");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_USERNAME");
|
||||
$oMorpho->remove("PROJECT_DB_MYSQL_PASSWORD");
|
||||
}
|
||||
}
|
||||
|
||||
public function validationHook(\Formal\Form $oForm, \Formal\Form\Morphology $oMorpho) {
|
||||
if(intval($oForm->modelInstance()->get("PROJECT_DB_MYSQL")) === 1) {
|
||||
|
||||
# We have to check the MySQL connection
|
||||
$sHost = $oForm->modelInstance()->get("PROJECT_DB_MYSQL_HOST");
|
||||
$sDbName = $oForm->modelInstance()->get("PROJECT_DB_MYSQL_DBNAME");
|
||||
$sUsername = $oForm->modelInstance()->get("PROJECT_DB_MYSQL_USERNAME");
|
||||
$sPassword = $oForm->modelInstance()->get("PROJECT_DB_MYSQL_PASSWORD");
|
||||
|
||||
try {
|
||||
$oDB = new \Flake\Core\Database\Mysql(
|
||||
$sHost,
|
||||
$sDbName,
|
||||
$sUsername,
|
||||
$sPassword
|
||||
);
|
||||
} catch(\Exception $e) {
|
||||
$sMessage = "<strong>MySQL error:</strong> " . $e->getMessage();
|
||||
$sMessage .= "<br /><strong>Nothing has been saved</strong>";
|
||||
$oForm->declareError($oMorpho->element("PROJECT_DB_MYSQL_HOST"), $sMessage);
|
||||
$oForm->declareError($oMorpho->element("PROJECT_DB_MYSQL_DBNAME"));
|
||||
$oForm->declareError($oMorpho->element("PROJECT_DB_MYSQL_USERNAME"));
|
||||
$oForm->declareError($oMorpho->element("PROJECT_DB_MYSQL_PASSWORD"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(($aMissingTables = \Baikal\Core\Tools::isDBStructurallyComplete($oDB)) !== TRUE) {
|
||||
$sMessage = "<strong>MySQL error:</strong> These tables, required by Baïkal, are missing: <strong>" . implode(", ", $aMissingTables) . "</strong><br />";
|
||||
$sMessage .= "You may want create these tables using the file <strong>Core/Resources/Db/MySQL/db.sql</strong>";
|
||||
$sMessage .= "<br /><br /><strong>Nothing has been saved</strong>";
|
||||
|
||||
$oForm->declareError($oMorpho->element("PROJECT_DB_MYSQL"), $sMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,278 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\User;
|
||||
|
||||
class AddressBooks extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
protected $oModel; # \Baikal\Model\Contact
|
||||
protected $oUser; # \Baikal\Model\User
|
||||
protected $oForm; # \Formal\Form
|
||||
|
||||
public function execute() {
|
||||
|
||||
if(($iUser = $this->currentUserId()) === FALSE) {
|
||||
throw new \Exception("BaikalAdmin\Controller\User\Contacts::render(): User get-parameter not found.");
|
||||
}
|
||||
|
||||
$this->oUser = new \Baikal\Model\User($iUser);
|
||||
|
||||
if($this->actionNewRequested()) {
|
||||
$this->actionNew();
|
||||
}
|
||||
|
||||
if($this->actionEditRequested()) {
|
||||
$this->actionEdit();
|
||||
}
|
||||
|
||||
if($this->actionDeleteRequested()) {
|
||||
$this->actionDelete();
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\User\AddressBooks();
|
||||
|
||||
# User
|
||||
$oView->setData("user", $this->oUser);
|
||||
|
||||
# Render list of address books
|
||||
$aAddressBooks = array();
|
||||
$oAddressBooks = $this->oUser->getAddressBooksBaseRequester()->execute();
|
||||
|
||||
reset($oAddressBooks);
|
||||
foreach($oAddressBooks as $addressbook) {
|
||||
$aAddressBooks[] = array(
|
||||
"linkedit" => $this->linkEdit($addressbook),
|
||||
"linkdelete" => $this->linkDelete($addressbook),
|
||||
"icon" => $addressbook->icon(),
|
||||
"label" => $addressbook->label(),
|
||||
"description" => $addressbook->get("description"),
|
||||
);
|
||||
}
|
||||
|
||||
$oView->setData("addressbooks", $aAddressBooks);
|
||||
|
||||
# Messages
|
||||
$sMessages = implode("\n", $this->aMessages);
|
||||
$oView->setData("messages", $sMessages);
|
||||
|
||||
if($this->actionNewRequested() || $this->actionEditRequested()) {
|
||||
$sForm = $this->oForm->render();
|
||||
} else {
|
||||
$sForm = "";
|
||||
}
|
||||
|
||||
$oView->setData("form", $sForm);
|
||||
$oView->setData("titleicon", \Baikal\Model\AddressBook::bigicon());
|
||||
$oView->setData("modelicon", $this->oUser->mediumIcon());
|
||||
$oView->setData("modellabel", $this->oUser->label());
|
||||
$oView->setData("linkback", \BaikalAdmin\Controller\Users::link());
|
||||
$oView->setData("linknew", $this->linkNew());
|
||||
$oView->setData("addressbookicon", \Baikal\Model\AddressBook::icon());
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
protected function initForm() {
|
||||
if($this->actionEditRequested() || $this->actionNewRequested()) {
|
||||
$aOptions = array(
|
||||
"closeurl" => $this->linkHome()
|
||||
);
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance($aOptions);
|
||||
}
|
||||
}
|
||||
|
||||
protected function currentUserId() {
|
||||
$aParams = $this->getParams();
|
||||
if(($iUser = intval($aParams["user"])) === 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $iUser;
|
||||
}
|
||||
|
||||
# Action new
|
||||
|
||||
public function linkNew() {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"new" => 1
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
protected function actionNewRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("new", $aParams) && intval($aParams["new"]) === 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionNew() {
|
||||
|
||||
# Building floating model object
|
||||
$this->oModel = new \Baikal\Model\AddressBook();
|
||||
$this->oModel->set(
|
||||
"principaluri",
|
||||
$this->oUser->get("uri")
|
||||
);
|
||||
|
||||
$this->oModel->set(
|
||||
"ctag",
|
||||
"1"
|
||||
);
|
||||
|
||||
$this->initForm();
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
$this->oForm->setOption(
|
||||
"action",
|
||||
$this->linkEdit(
|
||||
$this->oForm->modelInstance()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Action edit
|
||||
|
||||
public function linkEdit(\Baikal\Model\AddressBook $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"edit" => $oModel->get("id")
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
protected function actionEditRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("edit", $aParams) && intval($aParams["edit"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionEdit() {
|
||||
# Building anchored model object
|
||||
$aParams = $this->getParams();
|
||||
$this->oModel = new \Baikal\Model\AddressBook(intval($aParams["edit"]));
|
||||
|
||||
# Initialize corresponding form
|
||||
$this->initForm();
|
||||
|
||||
# Process form
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
}
|
||||
}
|
||||
|
||||
# Action delete + confirm
|
||||
|
||||
public function linkDelete(\Baikal\Model\AddressBook $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"delete" => $oModel->get("id")
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
public function linkDeleteConfirm(\Baikal\Model\AddressBook $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"delete" => $oModel->get("id"),
|
||||
"confirm" => 1
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
protected function actionDeleteRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("delete", $aParams) && intval($aParams["delete"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDeleteConfirmed() {
|
||||
if(($iPrimary = $this->actionDeleteRequested()) === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("confirm", $aParams) && intval($aParams["confirm"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDelete() {
|
||||
|
||||
$aParams = $this->getParams();
|
||||
$iModel = intval($aParams["delete"]);
|
||||
|
||||
if($this->actionDeleteConfirmed() !== FALSE) {
|
||||
|
||||
# catching Exception thrown when model already destroyed
|
||||
# happens when user refreshes page on delete-URL, for instance
|
||||
|
||||
try {
|
||||
$oModel = new \Baikal\Model\AddressBook($iModel);
|
||||
$oModel->destroy();
|
||||
} catch(\Exception $e) {
|
||||
# already deleted; silently discarding
|
||||
}
|
||||
|
||||
# Redirecting to admin home
|
||||
\Flake\Util\Tools::redirectUsingMeta($this->linkHome());
|
||||
} else {
|
||||
|
||||
$oModel = new \Baikal\Model\AddressBook($iModel);
|
||||
$this->aMessages[] = \Formal\Core\Message::warningConfirmMessage(
|
||||
"Check twice, you're about to delete " . $oModel->label() . "</strong> from the database !",
|
||||
"<p>You are about to delete a contact book and all it's visiting cards. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>",
|
||||
$this->linkDeleteConfirm($oModel),
|
||||
"Delete <strong><i class='" . $oModel->icon() . " icon-white'></i> " . $oModel->label() . "</strong>",
|
||||
$this->linkHome()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# Link to home
|
||||
public function linkHome() {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller\User;
|
||||
|
||||
class Calendars extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
protected $oModel; # \Baikal\Model\Calendar
|
||||
protected $oUser; # \Baikal\Model\User
|
||||
protected $oForm; # \Formal\Form
|
||||
|
||||
public function execute() {
|
||||
|
||||
if(($iUser = $this->currentUserId()) === FALSE) {
|
||||
throw new \Exception("BaikalAdmin\Controller\User\Calendars::render(): User get-parameter not found.");
|
||||
}
|
||||
|
||||
$this->oUser = new \Baikal\Model\User($iUser);
|
||||
|
||||
if($this->actionNewRequested()) {
|
||||
$this->actionNew();
|
||||
} elseif($this->actionEditRequested()) {
|
||||
$this->actionEdit();
|
||||
} elseif($this->actionDeleteRequested()) {
|
||||
$this->actionDelete();
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\User\Calendars();
|
||||
|
||||
# User
|
||||
$oView->setData("user", $this->oUser);
|
||||
|
||||
# List of calendars
|
||||
$oCalendars = $this->oUser->getCalendarsBaseRequester()->execute();
|
||||
$aCalendars = array();
|
||||
|
||||
foreach($oCalendars as $calendar) {
|
||||
$aCalendars[] = array(
|
||||
"linkedit" => $this->linkEdit($calendar),
|
||||
"linkdelete" => $this->linkDelete($calendar),
|
||||
"icon" => $calendar->icon(),
|
||||
"label" => $calendar->label(),
|
||||
"description" => $calendar->get("description"),
|
||||
);
|
||||
}
|
||||
|
||||
$oView->setData("calendars", $aCalendars);
|
||||
|
||||
# Messages
|
||||
$sMessages = implode("\n", $this->aMessages);
|
||||
$oView->setData("messages", $sMessages);
|
||||
|
||||
if($this->actionNewRequested() || $this->actionEditRequested()) {
|
||||
$sForm = $this->oForm->render();
|
||||
} else {
|
||||
$sForm = "";
|
||||
}
|
||||
|
||||
$oView->setData("form", $sForm);
|
||||
$oView->setData("titleicon", \Baikal\Model\Calendar::bigicon());
|
||||
$oView->setData("modelicon", $this->oUser->mediumicon());
|
||||
$oView->setData("modellabel", $this->oUser->label());
|
||||
$oView->setData("linkback", \BaikalAdmin\Controller\Users::link());
|
||||
$oView->setData("linknew", $this->linkNew());
|
||||
$oView->setData("calendaricon", \Baikal\Model\Calendar::icon());
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
protected function initForm() {
|
||||
if($this->actionEditRequested() || $this->actionNewRequested()) {
|
||||
$aOptions = array(
|
||||
"closeurl" => $this->linkHome()
|
||||
);
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance($aOptions);
|
||||
}
|
||||
}
|
||||
|
||||
protected function currentUserId() {
|
||||
$aParams = $this->getParams();
|
||||
if(($iUser = intval($aParams["user"])) === 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $iUser;
|
||||
}
|
||||
|
||||
# Action new
|
||||
|
||||
public function linkNew() {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"new" => 1
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
protected function actionNewRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("new", $aParams) && intval($aParams["new"]) === 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionNew() {
|
||||
|
||||
# Building floating model object
|
||||
$this->oModel = new \Baikal\Model\Calendar();
|
||||
$this->oModel->set(
|
||||
"principaluri",
|
||||
$this->oUser->get("uri")
|
||||
);
|
||||
|
||||
$this->oModel->set(
|
||||
"components",
|
||||
"VEVENT"
|
||||
);
|
||||
|
||||
$this->oModel->set(
|
||||
"ctag",
|
||||
"1"
|
||||
);
|
||||
|
||||
# Initialize corresponding form
|
||||
$this->initForm();
|
||||
|
||||
# Process form
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
$this->oForm->setOption(
|
||||
"action",
|
||||
$this->linkEdit(
|
||||
$this->oForm->modelInstance()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Action edit
|
||||
|
||||
public function linkEdit(\Baikal\Model\Calendar $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"edit" => $oModel->get("id")
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
protected function actionEditRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("edit", $aParams) && intval($aParams["edit"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionEdit() {
|
||||
# Building anchored model object
|
||||
$aParams = $this->getParams();
|
||||
$this->oModel = new \Baikal\Model\Calendar(intval($aParams["edit"]));
|
||||
|
||||
# Initialize corresponding form
|
||||
$this->initForm();
|
||||
|
||||
# Process form
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
}
|
||||
}
|
||||
|
||||
# Action delete + confirm
|
||||
|
||||
public function linkDelete(\Baikal\Model\Calendar $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"delete" => $oModel->get("id")
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
public function linkDeleteConfirm(\Baikal\Model\Calendar $oModel) {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
"delete" => $oModel->get("id"),
|
||||
"confirm" => 1
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
protected function actionDeleteRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("delete", $aParams) && intval($aParams["delete"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDeleteConfirmed() {
|
||||
if($this->actionDeleteRequested() === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("confirm", $aParams) && intval($aParams["confirm"]) === 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDelete() {
|
||||
|
||||
$aParams = $this->getParams();
|
||||
$iCalendar = intval($aParams["delete"]);
|
||||
|
||||
if($this->actionDeleteConfirmed() !== FALSE) {
|
||||
|
||||
# catching Exception thrown when model already destroyed
|
||||
# happens when user refreshes page on delete-URL, for instance
|
||||
|
||||
try {
|
||||
$oModel = new \Baikal\Model\Calendar($iCalendar);
|
||||
$oModel->destroy();
|
||||
} catch(\Exception $e) {
|
||||
# already deleted; silently discarding
|
||||
}
|
||||
|
||||
# Redirecting to admin home
|
||||
\Flake\Util\Tools::redirectUsingMeta($this->linkHome());
|
||||
} else {
|
||||
|
||||
$oModel = new \Baikal\Model\Calendar($iCalendar);
|
||||
$this->aMessages[] = \Formal\Core\Message::warningConfirmMessage(
|
||||
"Check twice, you're about to delete " . $oModel->label() . "</strong> from the database !",
|
||||
"<p>You are about to delete a calendar and all it's scheduled events. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>",
|
||||
$this->linkDeleteConfirm($oModel),
|
||||
"Delete <strong><i class='" . $oModel->icon() . " icon-white'></i> " . $oModel->label() . "</strong>",
|
||||
$this->linkHome()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# Link to home
|
||||
|
||||
public function linkHome() {
|
||||
return self::buildRoute(array(
|
||||
"user" => $this->currentUserId(),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,241 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Users extends \Flake\Core\Controller {
|
||||
|
||||
protected $aMessages = array();
|
||||
|
||||
public function execute() {
|
||||
if($this->actionEditRequested()) {
|
||||
$this->actionEdit();
|
||||
}
|
||||
|
||||
if($this->actionNewRequested()) {
|
||||
$this->actionNew();
|
||||
}
|
||||
|
||||
if($this->actionDeleteRequested()) {
|
||||
$this->actionDelete();
|
||||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$oView = new \BaikalAdmin\View\Users();
|
||||
|
||||
# List of users
|
||||
$aUsers = array();
|
||||
$oUsers = \Baikal\Model\User::getBaseRequester()->execute();
|
||||
|
||||
reset($oUsers);
|
||||
foreach($oUsers as $user) {
|
||||
$aUsers[] = array(
|
||||
"linkcalendars" => \BaikalAdmin\Controller\Users::linkCalendars($user),
|
||||
"linkaddressbooks" => \BaikalAdmin\Controller\Users::linkAddressBooks($user),
|
||||
"linkedit" => \BaikalAdmin\Controller\Users::linkEdit($user),
|
||||
"linkdelete" => \BaikalAdmin\Controller\Users::linkDelete($user),
|
||||
"mailtouri" => $user->getMailtoURI(),
|
||||
"username" => $user->get("username"),
|
||||
"displayname" => $user->get("displayname"),
|
||||
"email" => $user->get("email"),
|
||||
);
|
||||
}
|
||||
|
||||
$oView->setData("users", $aUsers);
|
||||
$oView->setData("calendaricon", \Baikal\Model\Calendar::icon());
|
||||
$oView->setData("usericon", \Baikal\Model\User::icon());
|
||||
|
||||
# Messages
|
||||
$sMessages = implode("\n", $this->aMessages);
|
||||
$oView->setData("messages", $sMessages);
|
||||
|
||||
# Form
|
||||
if($this->actionNewRequested() || $this->actionEditRequested()) {
|
||||
$sForm = $this->oForm->render();
|
||||
} else {
|
||||
$sForm = "";
|
||||
}
|
||||
|
||||
$oView->setData("form", $sForm);
|
||||
$oView->setData("usericon", \Baikal\Model\User::icon());
|
||||
$oView->setData("controller", $this);
|
||||
|
||||
return $oView->render();
|
||||
}
|
||||
|
||||
protected function initForm() {
|
||||
if($this->actionEditRequested() || $this->actionNewRequested()) {
|
||||
$aOptions = array(
|
||||
"closeurl" => self::link()
|
||||
);
|
||||
|
||||
$this->oForm = $this->oModel->formForThisModelInstance($aOptions);
|
||||
}
|
||||
}
|
||||
|
||||
# Action edit
|
||||
protected function actionEditRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("edit", $aParams) && intval($aParams["edit"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionEdit() {
|
||||
$aParams = $this->getParams();
|
||||
$this->oModel = new \Baikal\Model\User(intval($aParams["edit"]));
|
||||
$this->initForm();
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
}
|
||||
}
|
||||
|
||||
# Action delete
|
||||
|
||||
protected function actionDeleteRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("delete", $aParams) && intval($aParams["delete"]) > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDeleteConfirmed() {
|
||||
if($this->actionDeleteRequested() === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$aParams = $this->getParams();
|
||||
|
||||
if(array_key_exists("confirm", $aParams) && intval($aParams["confirm"]) === 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionDelete() {
|
||||
$aParams = $this->getParams();
|
||||
$iUser = intval($aParams["delete"]);
|
||||
|
||||
if($this->actionDeleteConfirmed() !== FALSE) {
|
||||
|
||||
# catching Exception thrown when model already destroyed
|
||||
# happens when user refreshes delete-page, for instance
|
||||
|
||||
try {
|
||||
$oUser = new \Baikal\Model\User($iUser);
|
||||
$oUser->destroy();
|
||||
} catch(\Exception $e) {
|
||||
# user is already deleted; silently discarding
|
||||
}
|
||||
|
||||
# Redirecting to admin home
|
||||
\Flake\Util\Tools::redirectUsingMeta($this->link());
|
||||
} else {
|
||||
|
||||
$oUser = new \Baikal\Model\User($iUser);
|
||||
$this->aMessages[] = \Formal\Core\Message::warningConfirmMessage(
|
||||
"Check twice, you're about to delete " . $oUser->label() . "</strong> from the database !",
|
||||
"<p>You are about to delete a user and all it's calendars / contacts. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>",
|
||||
$this->linkDeleteConfirm($oUser),
|
||||
"Delete <strong><i class='" . $oUser->icon() . " icon-white'></i> " . $oUser->label() . "</strong>",
|
||||
$this->link()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# Action new
|
||||
protected function actionNewRequested() {
|
||||
$aParams = $this->getParams();
|
||||
if(array_key_exists("new", $aParams) && intval($aParams["new"]) === 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected function actionNew() {
|
||||
$this->oModel = new \Baikal\Model\User();
|
||||
$this->initForm();
|
||||
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
||||
if($this->oForm->persisted()) {
|
||||
$this->oForm->setOption(
|
||||
"action",
|
||||
$this->linkEdit(
|
||||
$this->oForm->modelInstance()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function linkNew() {
|
||||
return self::buildRoute(array(
|
||||
"new" => 1
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
public static function linkEdit(\Baikal\Model\User $user) {
|
||||
return self::buildRoute(array(
|
||||
"edit" => $user->get("id")
|
||||
)) . "#form";
|
||||
}
|
||||
|
||||
public static function linkDelete(\Baikal\Model\User $user) {
|
||||
return self::buildRoute(array(
|
||||
"delete" => $user->get("id")
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
public static function linkDeleteConfirm(\Baikal\Model\User $user) {
|
||||
return self::buildRoute(array(
|
||||
"delete" => $user->get("id"),
|
||||
"confirm" => 1
|
||||
)) . "#message";
|
||||
}
|
||||
|
||||
public static function linkCalendars(\Baikal\Model\User $user) {
|
||||
return \BaikalAdmin\Controller\User\Calendars::buildRoute(array(
|
||||
"user" => $user->get("id"),
|
||||
));
|
||||
}
|
||||
|
||||
public static function linkAddressBooks(\Baikal\Model\User $user) {
|
||||
return \BaikalAdmin\Controller\User\AddressBooks::buildRoute(array(
|
||||
"user" => $user->get("id"),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Core;
|
||||
|
||||
class Auth {
|
||||
public static function assertEnabled() {
|
||||
if(!defined("BAIKAL_ADMIN_ENABLED") || BAIKAL_ADMIN_ENABLED !== TRUE) {
|
||||
die("<h1>Baïkal Admin is disabled.</h1>To enable it, set BAIKAL_ADMIN_ENABLED to TRUE in <b>Specific/config.php</b>");
|
||||
}
|
||||
|
||||
self::assertUnlocked();
|
||||
}
|
||||
|
||||
public static function assertUnlocked() {
|
||||
|
||||
if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
|
||||
$sToolName = "Baïkal Install Tool";
|
||||
$sFileName = "ENABLE_INSTALL";
|
||||
} else {
|
||||
if(!defined("BAIKAL_ADMIN_AUTOLOCKENABLED") || BAIKAL_ADMIN_AUTOLOCKENABLED === FALSE) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$sToolName = "Baïkal Admin";
|
||||
$sFileName = "ENABLE_ADMIN";
|
||||
}
|
||||
|
||||
$sEnableFile = PROJECT_PATH_SPECIFIC . $sFileName;
|
||||
|
||||
$bLocked = TRUE;
|
||||
if(file_exists($sEnableFile)) {
|
||||
|
||||
clearstatcache();
|
||||
$iTime = intval(filemtime($sEnableFile));
|
||||
if((time() - $iTime) < 3600) {
|
||||
# file has been created/updated less than an hour ago; update it's mtime
|
||||
if(is_writable($sEnableFile)) {
|
||||
@file_put_contents($sEnableFile, '');
|
||||
}
|
||||
$bLocked = FALSE;
|
||||
} else {
|
||||
// file has been created more than an hour ago
|
||||
// delete and declare locked
|
||||
if(!@unlink($sEnableFile)) {
|
||||
die("<h1>" . $sToolName . " is locked.</h1>To unlock it, create (or re-create if it exists already) an empty file named <strong>" . $sFileName . "</strong> (uppercase, no file extension) in the <b>Specific/</b> folder of Baïkal.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($bLocked) {
|
||||
die("<h1>" . $sToolName . " is locked.</h1>To unlock it, create (or re-create if it exists already) an empty file named <strong>" . $sFileName . "</strong> (uppercase, no file extension) in the <b>Specific/</b> folder of Baïkal.");
|
||||
}
|
||||
}
|
||||
|
||||
public static function isAuthenticated() {
|
||||
if(isset($_SESSION["baikaladminauth"]) && $_SESSION["baikaladminauth"] === md5(BAIKAL_ADMIN_PASSWORDHASH)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public static function authenticate() {
|
||||
|
||||
if(intval(\Flake\Util\Tools::POST("auth")) !== 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$sUser = \Flake\Util\Tools::POST("login");
|
||||
$sPass = \Flake\Util\Tools::POST("password");
|
||||
|
||||
$sPassHash = self::hashAdminPassword($sPass);
|
||||
|
||||
if($sUser === "admin" && $sPassHash === BAIKAL_ADMIN_PASSWORDHASH) {
|
||||
$_SESSION["baikaladminauth"] = md5(BAIKAL_ADMIN_PASSWORDHASH);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
public static function unAuthenticate() {
|
||||
unset($_SESSION["baikaladminauth"]);
|
||||
}
|
||||
|
||||
public static function hashAdminPassword($sPassword) {
|
||||
if(defined("BAIKAL_AUTH_REALM")) {
|
||||
$sAuthRealm = BAIKAL_AUTH_REALM;
|
||||
} else {
|
||||
$sAuthRealm = "BaikalDAV"; # Fallback to default value; useful when initializing App, as all constants are not set yet
|
||||
}
|
||||
|
||||
return md5('admin:' . $sAuthRealm . ':' . $sPassword);
|
||||
}
|
||||
|
||||
public static function lockAdmin() {
|
||||
@unlink(PROJECT_PATH_SPECIFIC . "ENABLE_ADMIN");
|
||||
}
|
||||
|
||||
public static function lockInstall() {
|
||||
@unlink(PROJECT_PATH_SPECIFIC . "ENABLE_INSTALL");
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Core;
|
||||
|
||||
class View extends \Flake\Core\View {
|
||||
public function templatesPath() {
|
||||
$sViewName = get_class($this);
|
||||
$sTemplate = str_replace("\\", "/", substr($sViewName, strlen("BaikalAdmin\\View\\"))) . ".html";
|
||||
return BAIKALADMIN_PATH_TEMPLATES . $sTemplate;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin;
|
||||
|
||||
class Framework extends \Flake\Core\Framework {
|
||||
|
||||
public static function bootstrap() {
|
||||
define("BAIKALADMIN_PATH_ROOT", PROJECT_PATH_ROOT . "Core/Frameworks/BaikalAdmin/"); # ./
|
||||
|
||||
\Baikal\Framework::bootstrap();
|
||||
\Formal\Framework::bootstrap();
|
||||
|
||||
$GLOBALS["ROUTER"]::setURIPath("admin/");
|
||||
|
||||
# Include BaikalAdmin Framework config
|
||||
require_once(BAIKALADMIN_PATH_ROOT . "config.php");
|
||||
}
|
||||
}
|
|
@ -1,461 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define("COLUMNS", 10);
|
||||
define("ROWS", 35);
|
||||
define("MATRIXWIDTH", 400);
|
||||
define("MATRIXHEIGHT", 1400);
|
||||
|
||||
echo generateSprite(getSymbols(), COLUMNS, ROWS, MATRIXWIDTH, MATRIXHEIGHT, "glyph-");
|
||||
|
||||
function getSymbols() {
|
||||
# Glyphicons Png names, without extension
|
||||
return array(
|
||||
"000_glass",
|
||||
"001_leaf",
|
||||
"002_dog",
|
||||
"003_user",
|
||||
"004_girl",
|
||||
"005_car",
|
||||
"006_user_add",
|
||||
"007_user_remove",
|
||||
"008_film",
|
||||
"009_magic",
|
||||
"010_envelope",
|
||||
"011_camera",
|
||||
"012_heart",
|
||||
"013_beach_umbrella",
|
||||
"014_train",
|
||||
"015_print",
|
||||
"016_bin",
|
||||
"017_music",
|
||||
"018_note",
|
||||
"019_cogwheel",
|
||||
"020_home",
|
||||
"021_snowflake",
|
||||
"022_fire",
|
||||
"023_cogwheels",
|
||||
"024_parents",
|
||||
"025_binoculars",
|
||||
"026_road",
|
||||
"027_search",
|
||||
"028_cars",
|
||||
"029_notes_2",
|
||||
"030_pencil",
|
||||
"031_bus",
|
||||
"032_wifi_alt",
|
||||
"033_luggage",
|
||||
"034_old_man",
|
||||
"035_woman",
|
||||
"036_file",
|
||||
"037_credit",
|
||||
"038_airplane",
|
||||
"039_notes",
|
||||
"040_stats",
|
||||
"041_charts",
|
||||
"042_pie_chart",
|
||||
"043_group",
|
||||
"044_keys",
|
||||
"045_calendar",
|
||||
"046_router",
|
||||
"047_camera_small",
|
||||
"048_dislikes",
|
||||
"049_star",
|
||||
"050_link",
|
||||
"051_eye_open",
|
||||
"052_eye_close",
|
||||
"053_alarm",
|
||||
"054_clock",
|
||||
"055_stopwatch",
|
||||
"056_projector",
|
||||
"057_history",
|
||||
"058_truck",
|
||||
"059_cargo",
|
||||
"060_compass",
|
||||
"061_keynote",
|
||||
"062_attach",
|
||||
"063_power",
|
||||
"064_lightbulb",
|
||||
"065_tag",
|
||||
"066_tags",
|
||||
"067_cleaning",
|
||||
"068_ruller",
|
||||
"069_gift",
|
||||
"070_umbrella",
|
||||
"071_book",
|
||||
"072_bookmark",
|
||||
"073_signal",
|
||||
"074_cup",
|
||||
"075_stroller",
|
||||
"076_headphones",
|
||||
"077_headset",
|
||||
"078_warning_sign",
|
||||
"079_signal",
|
||||
"080_retweet",
|
||||
"081_refresh",
|
||||
"082_roundabout",
|
||||
"083_random",
|
||||
"084_heat",
|
||||
"085_repeat",
|
||||
"086_display",
|
||||
"087_log_book",
|
||||
"088_adress_book",
|
||||
"089_magnet",
|
||||
"090_table",
|
||||
"091_adjust",
|
||||
"092_tint",
|
||||
"093_crop",
|
||||
"094_vector_path_square",
|
||||
"095_vector_path_circle",
|
||||
"096_vector_path_polygon",
|
||||
"097_vector_path_line",
|
||||
"098_vector_path_curve",
|
||||
"099_vector_path_all",
|
||||
"100_font",
|
||||
"101_italic",
|
||||
"102_bold",
|
||||
"103_text_underline",
|
||||
"104_text_strike",
|
||||
"105_text_height",
|
||||
"106_text_width",
|
||||
"107_text_resize",
|
||||
"108_left_indent",
|
||||
"109_right_indent",
|
||||
"110_align_left",
|
||||
"111_align_center",
|
||||
"112_align_right",
|
||||
"113_justify",
|
||||
"114_list",
|
||||
"115_text_smaller",
|
||||
"116_text_bigger",
|
||||
"117_embed",
|
||||
"118_embed_close",
|
||||
"119_adjust",
|
||||
"120_message_full",
|
||||
"121_message_empty",
|
||||
"122_message_in",
|
||||
"123_message_out",
|
||||
"124_message_plus",
|
||||
"125_message_minus",
|
||||
"126_message_ban",
|
||||
"127_message_flag",
|
||||
"128_message_lock",
|
||||
"129_message_new",
|
||||
"130_inbox",
|
||||
"131_inbox_plus",
|
||||
"132_inbox_minus",
|
||||
"133_inbox_lock",
|
||||
"134_inbox_in",
|
||||
"135_inbox_out",
|
||||
"136_computer_locked",
|
||||
"137_computer_service",
|
||||
"138_computer_proces",
|
||||
"139_phone",
|
||||
"140_database_lock",
|
||||
"141_database_plus",
|
||||
"142_database_minus",
|
||||
"143_database_ban",
|
||||
"144_folder_open",
|
||||
"145_folder_plus",
|
||||
"146_folder_minus",
|
||||
"147_folder_lock",
|
||||
"148_folder_flag",
|
||||
"149_folder_new",
|
||||
"150_check",
|
||||
"151_edit",
|
||||
"152_new_window",
|
||||
"153_more_windows",
|
||||
"154_show_big_thumbnails",
|
||||
"155_show_thumbnails",
|
||||
"156_show_thumbnails_with_lines",
|
||||
"157_show_lines",
|
||||
"158_playlist",
|
||||
"159_picture",
|
||||
"160_imac",
|
||||
"161_macbook",
|
||||
"162_ipad",
|
||||
"163_iphone",
|
||||
"164_iphone_transfer",
|
||||
"165_iphone_exchange",
|
||||
"166_ipod",
|
||||
"167_ipod_shuffle",
|
||||
"168_ear_plugs",
|
||||
"169_albums",
|
||||
"170_step_backward",
|
||||
"171_fast_backward",
|
||||
"172_rewind",
|
||||
"173_play",
|
||||
"174_pause",
|
||||
"175_stop",
|
||||
"176_forward",
|
||||
"177_fast_forward",
|
||||
"178_step_forward",
|
||||
"179_eject",
|
||||
"180_facetime_video",
|
||||
"181_download_alt",
|
||||
"182_mute",
|
||||
"183_volume_down",
|
||||
"184_volume_up",
|
||||
"185_screenshot",
|
||||
"186_move",
|
||||
"187_more",
|
||||
"188_brightness_reduce",
|
||||
"189_brightness_increase",
|
||||
"190_circle_plus",
|
||||
"191_circle_minus",
|
||||
"192_circle_remove",
|
||||
"193_circle_ok",
|
||||
"194_circle_question_mark",
|
||||
"195_circle_info",
|
||||
"196_circle_exclamation_mark",
|
||||
"197_remove",
|
||||
"198_ok",
|
||||
"199_ban",
|
||||
"200_download",
|
||||
"201_upload",
|
||||
"202_shopping_cart",
|
||||
"203_lock",
|
||||
"204_unlock",
|
||||
"205_electricity",
|
||||
"206_ok_2",
|
||||
"207_remove_2",
|
||||
"208_cart_out",
|
||||
"209_cart_in",
|
||||
"210_left_arrow",
|
||||
"211_right_arrow",
|
||||
"212_down_arrow",
|
||||
"213_up_arrow",
|
||||
"214_resize_small",
|
||||
"215_resize_full",
|
||||
"216_circle_arrow_left",
|
||||
"217_circle_arrow_right",
|
||||
"218_circle_arrow_right",
|
||||
"219_circle_arrow_right",
|
||||
"220_play_button",
|
||||
"221_unshare",
|
||||
"222_share",
|
||||
"223_thin_right_arrow",
|
||||
"224_thin_arrow_left",
|
||||
"225_bluetooth",
|
||||
"226_euro",
|
||||
"227_usd",
|
||||
"228_bp",
|
||||
"229_retweet_2",
|
||||
"230_moon",
|
||||
"231_sun",
|
||||
"232_cloud",
|
||||
"233_direction",
|
||||
"234_brush",
|
||||
"235_pen",
|
||||
"236_zoom_in",
|
||||
"237_zoom_out",
|
||||
"238_pin",
|
||||
"239_riflescope",
|
||||
"240_rotation_lock",
|
||||
"241_flash",
|
||||
"242_google_maps",
|
||||
"243_anchor",
|
||||
"244_conversation",
|
||||
"245_chat",
|
||||
"246_male",
|
||||
"247_female",
|
||||
"248_asterisk",
|
||||
"249_divide",
|
||||
"250_snorkel_diving",
|
||||
"251_scuba_diving",
|
||||
"252_oxygen_bottle",
|
||||
"253_fins",
|
||||
"254_fishes",
|
||||
"255_boat",
|
||||
"256_delete_point",
|
||||
"257_sheriffs_-star",
|
||||
"258_qrcode",
|
||||
"259_barcode",
|
||||
"260_pool",
|
||||
"261_buoy",
|
||||
"262_spade",
|
||||
"263_bank",
|
||||
"264_vcard",
|
||||
"265_electrical_plug",
|
||||
"266_flag",
|
||||
"267_credit_card",
|
||||
"268_keyboard_wireless",
|
||||
"269_keyboard_wired",
|
||||
"270_shield",
|
||||
"271_ring",
|
||||
"272_cake",
|
||||
"273_drink",
|
||||
"274_beer",
|
||||
"275_fast_food",
|
||||
"276_cutlery",
|
||||
"277_pizza",
|
||||
"278_birthday_cake",
|
||||
"279_tablet",
|
||||
"280_settings",
|
||||
"281_bullets",
|
||||
"282_cardio",
|
||||
"283_t-shirt",
|
||||
"284_pants",
|
||||
"285_sweater",
|
||||
"286_fabric",
|
||||
"287_leather",
|
||||
"288_scissors",
|
||||
"289_podium",
|
||||
"290_skull",
|
||||
"291_celebration",
|
||||
"292_tea_kettle",
|
||||
"293_french_press",
|
||||
"294_coffe_cup",
|
||||
"295_pot",
|
||||
"296_grater",
|
||||
"297_kettle",
|
||||
"298_hospital",
|
||||
"299_hospital_h",
|
||||
"300_microphone",
|
||||
"301_webcam",
|
||||
"302_temple_christianity_church",
|
||||
"303_temple_islam",
|
||||
"304_temple_hindu",
|
||||
"305_temple_buddhist",
|
||||
"306_electrical_socket_eu",
|
||||
"307_electrical_socket_us",
|
||||
"308_bomb",
|
||||
"309_comments",
|
||||
"310_flower",
|
||||
"311_baseball",
|
||||
"312_rugby",
|
||||
"313_ax",
|
||||
"314_table_tennis",
|
||||
"315_bowling",
|
||||
"316_tree_conifer",
|
||||
"317_tree_deciduous",
|
||||
"318_more-items",
|
||||
"319_sort",
|
||||
"320_facebook",
|
||||
"321_twitter_t",
|
||||
"322_twitter",
|
||||
"323_buzz",
|
||||
"324_vimeo",
|
||||
"325_flickr",
|
||||
"326_last_fm",
|
||||
"327_rss",
|
||||
"328_skype",
|
||||
"329_e-mail",
|
||||
"330_instapaper",
|
||||
"331_evernote",
|
||||
"332_xing",
|
||||
"333_zootool",
|
||||
"334_dribbble",
|
||||
"335_deviantart",
|
||||
"336_read_it_later",
|
||||
"337_linked_in",
|
||||
"338_forrst",
|
||||
"339_pinboard",
|
||||
"340_behance",
|
||||
"341_github",
|
||||
"342_youtube",
|
||||
"343_skitch",
|
||||
"344_4square",
|
||||
"345_quora",
|
||||
"346_google_plus",
|
||||
"347_spootify",
|
||||
"348_stumbleupon",
|
||||
"349_readability",
|
||||
);
|
||||
}
|
||||
|
||||
function generateSprite($aSymbols, $iCols, $iRows, $iPngWidth, $iPngHeight, $sClassPrefix) {
|
||||
$iKey = 0;
|
||||
|
||||
$aSprites = array();
|
||||
$iSymbolWidth = $iPngWidth / $iCols;
|
||||
$iSymbolHeight = $iPngHeight / $iRows;
|
||||
|
||||
foreach($aSymbols as $sSymbol) {
|
||||
$aParts = explode("_", strtolower($sSymbol));
|
||||
array_shift($aParts);
|
||||
$sClass = $sClassPrefix . implode("-", $aParts);
|
||||
|
||||
$iRowNum = intval($iKey / $iCols);
|
||||
$iColNum = $iKey % $iCols;
|
||||
|
||||
$iX = $iColNum * $iSymbolWidth;
|
||||
$iY = $iRowNum * $iSymbolHeight;
|
||||
|
||||
$aSprites[] = array(
|
||||
"class" => $sClass,
|
||||
"x" => round($iX),
|
||||
"y" => round($iY),
|
||||
"width" => ceil($iSymbolWidth),
|
||||
"height" => ceil($iSymbolHeight)
|
||||
);
|
||||
|
||||
$iKey++;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Generate CSS
|
||||
|
||||
$iSpriteWidth = ceil($iSymbolWidth);
|
||||
$iSpriteHeight = ceil($iSymbolHeight);
|
||||
|
||||
$sCss =<<<CSS
|
||||
.btn-large [class^="{$sClassPrefix}"] {
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.btn-small [class^="{$sClassPrefix}"] {
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.nav-list [class^="{$sClassPrefix}"] {
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
[class^="{$sClassPrefix}"],
|
||||
[class*=" {$sClassPrefix}"] {
|
||||
display: inline-block;
|
||||
width: {$iSpriteWidth}px;
|
||||
height: {$iSpriteHeight}px;
|
||||
line-height: {$iSpriteHeight}px;
|
||||
vertical-align: text-top;
|
||||
background-image: url("{$sClassPrefix}dark.png");
|
||||
background-position: {$iSpriteWidth}px {$iSpriteHeight}px;
|
||||
background-repeat: no-repeat;
|
||||
*margin-right: .3em;
|
||||
}
|
||||
[class^="{$sClassPrefix}"]:last-child,
|
||||
[class*=" {$sClassPrefix}"]:last-child {
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.{$sClassPrefix}white {
|
||||
background-image: url("{$sClassPrefix}white.png");
|
||||
}
|
||||
|
||||
CSS;
|
||||
|
||||
reset($aSprites);
|
||||
foreach($aSprites as $iKey => $aSprite) {
|
||||
$iX = (-1 * intval($aSprite["x"]));
|
||||
$iY = (-1 * intval($aSprite["y"]));
|
||||
|
||||
if($iX < 0) {
|
||||
$iX .= "px";
|
||||
}
|
||||
|
||||
if($iY < 0) {
|
||||
$iY .= "px";
|
||||
}
|
||||
|
||||
$sCss .= <<<CSS
|
||||
.{$aSprite["class"]} {
|
||||
background-position: {$iX} {$iY};
|
||||
}
|
||||
|
||||
CSS;
|
||||
}
|
||||
|
||||
$sCss = "\n" . "/* " . count($aSprites) . " glyphs, generated on " . strftime("%Y-%m-%d %H:%M:%S") . "; C=" . $iCols . "; R=" . $iRows . "; W=" . $iPngWidth . "; H=" . $iPngHeight . "; PREFIX=" . $sClassPrefix . " */\n" . $sCss;
|
||||
return $sCss;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 104 KiB |
Binary file not shown.
Before Width: | Height: | Size: 227 KiB |
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
{% autoescape false %}
|
||||
{% set url = 'http://baikal-server.com' %}
|
||||
<style>
|
||||
.label-intext { vertical-align: top;}
|
||||
</style>
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-circle-info"></i>Dashboard</h1>
|
||||
</header>
|
||||
|
||||
<section id="about">
|
||||
<div class="page-header">
|
||||
<h1>About this system</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3">
|
||||
<h2>Version</h2>
|
||||
<p>This systems runs<br />
|
||||
Baïkal <span class="label label-info label-intext">{{ BAIKAL_VERSION }}</span>, <em>{{ PROJECT_PACKAGE }}</em> package<br />
|
||||
<small><a href="{{ url }}">{{ url }}</a></small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<h2>Services</h2>
|
||||
{% if BAIKAL_CAL_ENABLED %}
|
||||
{% set caldavclass = 'label-success' %}
|
||||
{% set caldavtext = 'On' %}
|
||||
{% else %}
|
||||
{% set caldavclass = 'label-important' %}
|
||||
{% set caldavtext = 'Off' %}
|
||||
{% endif %}
|
||||
|
||||
{% if BAIKAL_CARD_ENABLED %}
|
||||
{% set carddavclass = 'label-success' %}
|
||||
{% set carddavtext = 'On' %}
|
||||
{% else %}
|
||||
{% set carddavclass = 'label-important' %}
|
||||
{% set carddavtext = 'Off' %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Web admin</td>
|
||||
<td><span class="label label-success label-intext">On</span></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CalDAV</td>
|
||||
<td><span class="label {{ caldavclass }} label-intext">{{ caldavtext }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CardDAV</td>
|
||||
<td><span class="label {{ carddavclass }} label-intext">{{ carddavtext }}</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<h2>License and credits</h2>
|
||||
<p>Baïkal is open source software licensed under the terms of the GNU GPL v3.</p>
|
||||
<p>Baïkal is based upon other open source projects.<br />Read the <a href="https://github.com/jeromeschneider/Baikal/blob/master/README.md" target="_blank">README.md</a> file to learn about that.</p>
|
||||
<p>Baïkal is developed by <a href="https://github.com/jeromeschneider" target="_blank">Jérôme Schneider</a>.
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="statistics">
|
||||
<div class="page-header">
|
||||
<h1>Statistics</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<h2>Users</h2>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Registered users</td>
|
||||
<td><span class="badge">{{ nbusers }}</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<h2>CalDAV</h2>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Number of calendars</td>
|
||||
<td><span class="badge">{{ nbcalendars }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Number of events</td>
|
||||
<td><span class="badge">{{ nbevents }}</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<h2>CardDAV</h2>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Number of address books</td>
|
||||
<td><span class="badge">{{ nbbooks }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Number of contacts</td>
|
||||
<td><span class="badge">{{ nbcontacts }}</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endautoescape %}
|
|
@ -1,11 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-magic"></i>Baïkal Database setup</h1>
|
||||
<p class="lead">Configure Baïkal Database.</p>
|
||||
</header>
|
||||
|
||||
<a id="formid"></a>
|
||||
{{ message }}
|
||||
{{ form }}
|
||||
|
||||
{% endautoescape %}
|
|
@ -1,11 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-magic"></i>Baïkal initialization wizard</h1>
|
||||
<p class="lead">Configure your new Baïkal <strong>{{ baikalversion }}</strong> installation.</p>
|
||||
</header>
|
||||
|
||||
<a id="formid"></a>
|
||||
{{ message }}
|
||||
{{ form }}
|
||||
|
||||
{% endautoescape %}
|
|
@ -1,27 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-lock"></i>Authentication</h1>
|
||||
<p class="lead">Please authenticate to access Baïkal Web Admin.</p>
|
||||
</header>
|
||||
|
||||
{{ message }}
|
||||
|
||||
<form class="form-horizontal" action="{{ actionurl }}" method="post" enctype="multipart/formdata">
|
||||
<input type="hidden" name="{{ submittedflagname }}" value="1" />
|
||||
<fieldset>
|
||||
<p>
|
||||
<label for="login">Login</label>
|
||||
<input type="text" name="login" value="{{ login }}" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password" value="{{ password }}" />
|
||||
</p>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Authenticate</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endautoescape %}
|
|
@ -1,23 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="{{ homelink }}"><img style="vertical-align: text-top; line-height: 20px;" src="res/core/BaikalAdmin/Templates/Page/baikal-text-20.png" /> Web Admin</a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="{{ activehome }}"> <a href="{{ homelink }}">Dashboard</a></li>
|
||||
<li class="{{ activeusers }}"> <a href="{{ userslink }}">Users and resources</a></li>
|
||||
<li class="{{ activesettingsstandard }}"> <a href="{{ settingsstandardlink }}">Settings</a></li>
|
||||
<li class="{{ activesettingssystem }}"> <a href="{{ settingssystemlink }}">System settings</a></li>
|
||||
<li> <a href="{{ logoutlink }}"><i class="icon-eject icon-white"></i> Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endautoescape %}
|
|
@ -1,7 +0,0 @@
|
|||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand"><img style="vertical-align: text-top; line-height: 20px;" src="res/core/BaikalAdmin/Templates/Page/baikal-text-20.png" /> Web Admin</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +0,0 @@
|
|||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand"><img style="vertical-align: text-top; line-height: 20px;" src="res/core/BaikalAdmin/Templates/Page/baikal-text-20.png" /> Install Tool</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
|
@ -1,74 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{{ pagetitle }}</title>
|
||||
<base href="{{ baseurl }}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap.css" rel="stylesheet" />
|
||||
<link href="res/core/BaikalAdmin/GlyphiconsPro/glyphpro.css" rel="stylesheet" />
|
||||
<link href="res/core/BaikalAdmin/GlyphiconsPro/glyphpro-2x.css" rel="stylesheet" />
|
||||
<link href="res/core/BaikalAdmin/Templates/Page/style.css" rel="stylesheet" />
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap-responsive.css" rel="stylesheet" />
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="res/core/BaikalAdmin/html5.js"></script>
|
||||
<![endif]-->
|
||||
{{ head }}
|
||||
</head>
|
||||
<body>
|
||||
{{ navbar }}
|
||||
|
||||
<div class="container">
|
||||
{{ Payload }}
|
||||
</div> <!-- /container -->
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="res/core/TwitterBootstrap/js/jquery-1.7.1.min.js"></script>
|
||||
<script src="res/core/TwitterBootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="res/core/TwitterBootstrap/js/bootstrap-tooltip.js"></script>
|
||||
<script src="res/core/TwitterBootstrap/js/bootstrap-popover.js"></script>
|
||||
<script type="text/javascript">
|
||||
$("[rel=tooltip]").tooltip();
|
||||
$(".popover-hover").popover();
|
||||
$(".popover-focus").popover({
|
||||
trigger: 'focus'
|
||||
});
|
||||
$(".popover-focus-top").popover({
|
||||
trigger: 'focus',
|
||||
placement: 'top'
|
||||
});
|
||||
$(".popover-focus-bottom").popover({
|
||||
trigger: 'focus',
|
||||
placement: 'bottom'
|
||||
});
|
||||
|
||||
function toggleStandardAuthParameter() {
|
||||
$(".auth_ldap-userbind").hide();
|
||||
$(".auth_mail").hide();
|
||||
var type = ".auth_" + $("#BAIKAL_DAV_AUTH_TYPE").val().toLowerCase();
|
||||
$(type).show();
|
||||
toggleStandardAuthMailSSL();
|
||||
}
|
||||
function toggleStandardAuthMailSSL() {
|
||||
var val = $("#BAIKAL_DAV_MAIL_PROTOCOL").val();
|
||||
if ( val == "pop3" || val == "imap" || val == "smtp" ) {
|
||||
$(".auth_mail_ssl").hide();
|
||||
} else {
|
||||
$(".auth_mail_ssl").show();
|
||||
}
|
||||
}
|
||||
$("#BAIKAL_DAV_AUTH_TYPE").change(function() {toggleStandardAuthParameter();});
|
||||
$("#BAIKAL_DAV_MAIL_PROTOCOL").change(function() {toggleStandardAuthMailSSL();});
|
||||
toggleStandardAuthParameter();
|
||||
</script>
|
||||
{{ javascript }}
|
||||
</body>
|
||||
</html>
|
||||
{% endautoescape %}
|
|
@ -1,83 +0,0 @@
|
|||
/* generics */
|
||||
|
||||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.table-striped tbody tr:nth-child(even) td, .table-striped tbody tr:nth-child(even) th {
|
||||
background-color: rgb(240, 240, 240);
|
||||
}
|
||||
|
||||
table .no-border-left { border-left: none !important;}
|
||||
table p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p.lead { line-height: 40px;}
|
||||
|
||||
|
||||
/* Jumbotrons
|
||||
-------------------------------------------------- */
|
||||
.jumbotron {
|
||||
position: relative;
|
||||
}
|
||||
.jumbotron h1 {
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
letter-spacing: -1px;
|
||||
line-height: 90px;
|
||||
}
|
||||
.jumbotron p {
|
||||
margin-bottom: 18px;
|
||||
font-weight: 300;
|
||||
}
|
||||
.jumbotron .btn-large {
|
||||
font-size: 20px;
|
||||
font-weight: normal;
|
||||
padding: 14px 24px;
|
||||
margin-right: 10px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.jumbotron .btn-large small {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 550px) {
|
||||
.jumbotron h1 {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
letter-spacing: -1px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
p.lead {
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
[class^="glyph2x-"],
|
||||
[class*=" glyph2x-"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Address books */
|
||||
table.addressbooks .col-displayname { width: 20%;}
|
||||
table.addressbooks .col-description { width: 55%;}
|
||||
table.addressbooks .col-actions { width: 25%;}
|
||||
|
||||
/* Calendars */
|
||||
table.calendars .col-displayname { width: 20%;}
|
||||
table.calendars .col-description { width: 55%;}
|
||||
table.calendars .col-actions { width: 25%;}
|
||||
|
||||
/* Users */
|
||||
table.users .col-id { width: 2%;}
|
||||
table.users .col-username { width: 45%;}
|
|
@ -1,7 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-adjust"></i>Baïkal settings</h1>
|
||||
</header>
|
||||
|
||||
{{ form }}
|
||||
{% endautoescape %}
|
|
@ -1,9 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-adjust"></i>Baïkal system settings</h1>
|
||||
</header>
|
||||
|
||||
{{ message }}
|
||||
{{ form }}
|
||||
|
||||
{% endautoescape %}
|
|
@ -1,36 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="{{ titleicon }}"></i>Address Books</h1>
|
||||
<p class="lead">Manage Address Books for<i class="{{ modelicon }}"></i><strong>{{ modellabel }}</strong>.</p>
|
||||
<p class="pull-left"><a href="{{ linkback }}" class="btn"><i class="icon-chevron-left"></i> Back to users list</a></p>
|
||||
<p class="pull-right"><a class="btn btn btn-inverse" href="{{ linknew }}"><i class="icon-white {{ addressbookicon }}"></i> + Add address book</a></p>
|
||||
</header>
|
||||
|
||||
<table class="table table-bordered table-striped addressbooks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Display name</th>
|
||||
<th>Description</th>
|
||||
<th class="no-border-left"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for addressbook in addressbooks %}
|
||||
<tr>
|
||||
<td class="col-displayname"><i class="{{ addressbook.icon }}"></i>{{ addressbook.label|escape }}</td>
|
||||
<td class="col-description">{{ addressbook.description|escape }}</td>
|
||||
<td class="col-actions no-border-left">
|
||||
<p class="pull-right">
|
||||
<nobr><a class="btn btn-primary" href="{{ addressbook.linkedit }}"><i class="icon-edit icon-white"></i> Edit</a></nobr>
|
||||
<nobr><a class="btn btn-danger" href="{{ addressbook.linkdelete }}"><i class="icon-remove icon-white"></i> Delete</a></nobr>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a id='form'></a>
|
||||
{{ messages }}
|
||||
{{ form }}
|
||||
{% endautoescape %}
|
|
@ -1,36 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="{{ titleicon }}"></i>Calendars</h1>
|
||||
<p class="lead">Manage Calendars for<i class="{{ modelicon }}"></i><strong>{{ modellabel }}</strong>.</p>
|
||||
<p class="pull-left"><a href="{{ linkback }}" class="btn"><i class="icon-chevron-left"></i> Back to users list</a></p>
|
||||
<p class="pull-right"><a class="btn btn btn-inverse" href="{{ linknew }}"><i class="icon-white {{ calendaricon }}"></i> + Add calendar</a></p>
|
||||
</header>
|
||||
|
||||
<table class="table table-bordered table-striped calendars">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Display name</th>
|
||||
<th>Description</th>
|
||||
<th class="no-border-left"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for calendar in calendars %}
|
||||
<tr>
|
||||
<td class="col-displayname"><i class="{{ calendar.icon }}"></i>{{ calendar.label|escape }}</td>
|
||||
<td class="col-description">{{ calendar.description|escape }}</td>
|
||||
<td class="col-actions no-border-left">
|
||||
<p class="pull-right">
|
||||
<nobr><a class="btn btn-primary" href="{{ calendar.linkedit }}"><i class="icon-edit icon-white"></i> Edit</a></nobr>
|
||||
<nobr><a class="btn btn-danger" href="{{ calendar.linkdelete }}"><i class="icon-remove icon-white"></i> Delete</a></nobr>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a id='form'></a>
|
||||
{{ messages }}
|
||||
{{ form }}
|
||||
{% endautoescape %}
|
|
@ -1,30 +0,0 @@
|
|||
{% autoescape false %}
|
||||
<header class="jumbotron subhead" id="overview">
|
||||
<h1><i class="glyph2x-group"></i>Users</h1>
|
||||
<p class="lead pull-left">Manage Baïkal user accounts, and associated resources.</p>
|
||||
<p class="lead pull-right"><a class="btn btn btn-inverse" href="{{ controller.linkNew() }}"><i class="icon-white {{ usericon }}"></i> + Add user</a></p>
|
||||
</header>
|
||||
|
||||
<table class="table table-bordered table-striped users">
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td class="col-username">
|
||||
<i class="{{ usericon }}"></i> <strong>{{ user.username|escape }}</strong><br />
|
||||
{{ user.displayname|escape }} <a href="{{ user.mailtouri|escape }}"><{{ user.email|escape }}></a>
|
||||
</td>
|
||||
<td class="col-actions no-border-left">
|
||||
<p class="pull-right">
|
||||
<nobr><a class="btn" href="{{ user.linkcalendars }}"><i class="{{ calendaricon }}"></i> Calendars</a></nobr>
|
||||
<nobr><a class="btn" href="{{ user.linkaddressbooks }}"><i class="icon-book"></i> Address Books</a></nobr>
|
||||
<nobr><a class="btn btn-primary" href="{{ user.linkedit }}"><i class="icon-edit icon-white"></i> Edit</a></nobr>
|
||||
<nobr><a class="btn btn-danger" href="{{ user.linkdelete }}"><i class="icon-remove icon-white"></i> Delete</a></nobr>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<a id='form'></a>
|
||||
{{ messages }}
|
||||
{{ form }}
|
||||
{% endautoescape %}
|
|
@ -1,8 +0,0 @@
|
|||
/*
|
||||
HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
*/
|
||||
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
|
||||
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>";
|
||||
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
|
||||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);
|
||||
if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route;
|
||||
|
||||
class Dashboard extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Dashboard());
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route;
|
||||
|
||||
class Logout extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Logout());
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route\Settings;
|
||||
|
||||
class Standard extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Settings\Standard());
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route\Settings;
|
||||
|
||||
class System extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Settings\System());
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route\User;
|
||||
|
||||
class AddressBooks extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\User\AddressBooks(
|
||||
self::getParams()
|
||||
));
|
||||
}
|
||||
|
||||
public static function parametersMap() {
|
||||
return array(
|
||||
"user" => array(
|
||||
"required" => TRUE,
|
||||
),
|
||||
"new" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"edit" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"delete" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"confirm" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route\User;
|
||||
|
||||
class Calendars extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$aParams = self::getParams();
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\User\Calendars($aParams));
|
||||
}
|
||||
|
||||
public static function parametersMap() {
|
||||
return array(
|
||||
"user" => array(
|
||||
"required" => TRUE,
|
||||
),
|
||||
"new" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"edit" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"delete" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"confirm" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\Route;
|
||||
|
||||
class Users extends \Flake\Core\Route {
|
||||
|
||||
public static function layout(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$aParams = self::getParams();
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Users($aParams));
|
||||
}
|
||||
|
||||
public static function parametersMap() {
|
||||
return array(
|
||||
"new" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"edit" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"delete" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
"confirm" => array(
|
||||
"required" => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View;
|
||||
|
||||
class Dashboard extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Install;
|
||||
|
||||
class Database extends \BaikalAdmin\Core\View {
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Install;
|
||||
|
||||
class Initialize extends \BaikalAdmin\Core\View {
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View;
|
||||
|
||||
class Login extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Navigation;
|
||||
|
||||
class Topbar extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Navigation\Topbar;
|
||||
|
||||
class Anonymous extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Navigation\Topbar;
|
||||
|
||||
class Install extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Settings;
|
||||
|
||||
class Standard extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\Settings;
|
||||
|
||||
class System extends \BaikalAdmin\Core\View {
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\User;
|
||||
|
||||
class AddressBooks extends \BaikalAdmin\Core\View {
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View\User;
|
||||
|
||||
class Calendars extends \BaikalAdmin\Core\View {
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
#################################################################
|
||||
# Copyright notice
|
||||
#
|
||||
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
# All rights reserved
|
||||
#
|
||||
# http://baikal-server.com
|
||||
#
|
||||
# This script is part of the Baïkal Server project. The Baïkal
|
||||
# Server project 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.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
#
|
||||
# This script 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
#################################################################
|
||||
|
||||
namespace BaikalAdmin\View;
|
||||
|
||||
class Users extends \BaikalAdmin\Core\View {
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
* All rights reserved
|
||||
*
|
||||
* http://baikal-server.com
|
||||
*
|
||||
* This script is part of the Baïkal Server project. The Baïkal
|
||||
* Server project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
ini_set("session.cookie_httponly", 1);
|
||||
ini_set("display_errors", 0);
|
||||
ini_set("log_errors", 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
define("BAIKAL_CONTEXT", TRUE);
|
||||
define("BAIKAL_CONTEXT_ADMIN", TRUE);
|
||||
define("PROJECT_CONTEXT_BASEURI", "/admin/");
|
||||
|
||||
if(file_exists(dirname(getcwd()). "/Core")) {
|
||||
# Flat FTP mode
|
||||
define("PROJECT_PATH_ROOT", dirname(getcwd()) . "/"); #../
|
||||
} else {
|
||||
# Dedicated server mode
|
||||
define("PROJECT_PATH_ROOT", dirname(dirname(getcwd())) . "/"); #../../
|
||||
}
|
||||
|
||||
if(!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
|
||||
die('<h1>Incomplete installation</h1><p>Baïkal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Baïkal.');
|
||||
}
|
||||
|
||||
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
|
||||
|
||||
# Bootstraping Flake
|
||||
\Flake\Framework::bootstrap();
|
||||
|
||||
# Bootstrap BaikalAdmin
|
||||
\BaikalAdmin\Framework::bootstrap();
|
||||
|
||||
# Assert that BaikalAdmin is enabled
|
||||
\BaikalAdmin\Core\Auth::assertEnabled();
|
||||
|
||||
# Create and setup a page object
|
||||
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
|
||||
$oPage->injectHTTPHeaders();
|
||||
|
||||
$oPage->setTitle("Baïkal " . BAIKAL_VERSION . " Web Admin");
|
||||
$oPage->setBaseUrl(PROJECT_URI);
|
||||
|
||||
# Authentication
|
||||
if(
|
||||
\BaikalAdmin\Core\Auth::isAuthenticated() === FALSE &&
|
||||
\BaikalAdmin\Core\Auth::authenticate() === FALSE
|
||||
) {
|
||||
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Anonymous());
|
||||
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Login());
|
||||
} else {
|
||||
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar());
|
||||
|
||||
# Route the request
|
||||
$GLOBALS["ROUTER"]::route($oPage);
|
||||
}
|
||||
|
||||
# Render the page
|
||||
echo $oPage->render();
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue