Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
New interface SqlTableProvider and use it for first install
Browse files Browse the repository at this point in the history
Detect session handler via conf
Rest.php: there should be no reason to start the session here (to recheck)
  • Loading branch information
cdujeu committed Jul 16, 2015
1 parent c000777 commit d05dd78
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 19 deletions.
40 changes: 40 additions & 0 deletions core/src/core/classes/interface.SqlTableProvider.php
@@ -0,0 +1,40 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* 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.
*
* Pydio 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
defined('AJXP_EXEC') or die( 'Access not allowed');

/**
* Interface SqlTableProvider
* Plugins that need to have their SQL tables installed at startup
* must implement this interface.
* @package Pydio
* @subpackage Core
* @interface SqlTableProvider
*/
interface SqlTableProvider{

/**
* Install SQL table using a dibi driver data
* @param $param array("SQL_DRIVER" => $dibiDriverData)
* @return mixed
*/
public function installSQLTables($param);

}
10 changes: 9 additions & 1 deletion core/src/index.php
Expand Up @@ -59,7 +59,15 @@

$confStorageDriver = ConfService::getConfStorageImpl();
require_once($confStorageDriver->getUserClassFileName());
//new AjxpSessionHandler();

// Custom Session Handler
if(defined("AJXP_SESSION_HANDLER_PATH") && defined("AJXP_SESSION_HANDLER_CLASSNAME") && file_exists(AJXP_SESSION_HANDLER_PATH)){
require_once(AJXP_SESSION_HANDLER_PATH);
$sessionHandlerClass = AJXP_SESSION_HANDLER_CLASSNAME;
$sessionHandler = new $sessionHandlerClass();
session_set_save_handler($sessionHandler, false);
}

if (!isSet($OVERRIDE_SESSION)) {
session_name("AjaXplorer");
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/auth.sql/class.sqlAuthDriver.php
Expand Up @@ -25,7 +25,7 @@
* @package AjaXplorer_Plugins
* @subpackage Auth
*/
class sqlAuthDriver extends AbstractAuthDriver
class sqlAuthDriver extends AbstractAuthDriver implements SqlTableProvider
{
public $sqlDriver;
public $driverName = "sql";
Expand Down
14 changes: 9 additions & 5 deletions core/src/plugins/boot.conf/class.BootConfLoader.php
Expand Up @@ -166,11 +166,15 @@ public function applyInstallerForm($action, $httpVars, $fileVars)
"SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")
));

// INSTALL ALL SQL TABLES
$sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "meta.syncable");
foreach ($sqlPlugs as $plugId) {
$plug = AJXP_PluginsService::findPluginById($plugId);
$plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]));
// DETECT REQUIRED SQL TABLES AND INSTALL THEM
$registry = AJXP_PluginsService::getInstance()->getDetectedPlugins();
$driverData = array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]);
foreach($registry as $type => $plugins){
foreach($plugins as $plugObject){
if($plugObject instanceof SqlTableProvider){
$plugObject->installSQLTables($driverData);
}
}
}

} else {
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -26,7 +26,7 @@
* @package AjaXplorer_Plugins
* @subpackage Conf
*/
class sqlConfDriver extends AbstractConfDriver
class sqlConfDriver extends AbstractConfDriver implements SqlTableProvider
{
public $sqlDriver = array();

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php
Expand Up @@ -25,7 +25,7 @@
* @package AjaXplorer_Plugins
* @subpackage Feed
*/
class AJXP_SqlFeedStore extends AJXP_Plugin implements AJXP_FeedStore
class AJXP_SqlFeedStore extends AJXP_Plugin implements AJXP_FeedStore, SqlTableProvider
{

private $sqlDriver;
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/log.sql/class.sqlLogDriver.php
Expand Up @@ -27,7 +27,7 @@
* @package AjaXplorer_Plugins
* @subpackage Log
*/
class sqlLogDriver extends AbstractLogDriver
class sqlLogDriver extends AbstractLogDriver implements SqlTableProvider
{
/**
* @var Array
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/meta.syncable/class.ChangesTracker.php
Expand Up @@ -26,7 +26,7 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class ChangesTracker extends AJXP_AbstractMetaSource
class ChangesTracker extends AJXP_AbstractMetaSource implements SqlTableProvider
{
private $sqlDriver;

Expand Down
6 changes: 0 additions & 6 deletions core/src/plugins/mq.sql/class.AJXP_SqlMessageExchanger.php
Expand Up @@ -273,10 +273,4 @@ public function publishInstantMessage($channel, $message)
$this->channels[$channel]["MESSAGES"][] = $message;
}

public function installSQLTables($param)
{
$p = AJXP_Utils::cleanDibiDriverParameters($param["SQL_DRIVER"]);
return AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir()."/create.sql");
}

}
4 changes: 2 additions & 2 deletions core/src/rest.php
Expand Up @@ -32,8 +32,8 @@
ConfService::start();
$confStorageDriver = ConfService::getConfStorageImpl();
require_once($confStorageDriver->getUserClassFileName());
session_name("AjaXplorer");
session_start();
//session_name("AjaXplorer");
//session_start();
AuthService::$useSession = false;

AJXP_PluginsService::getInstance()->initActivePlugins();
Expand Down

0 comments on commit d05dd78

Please sign in to comment.