#! /usr/bin/php
<?php
- /*
- * Copyright (C) 2010 Olaf Lenz
- *
- * This file is part of FusionForge.
- *
- * FusionForge 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.
- *
- * FusionForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+/*
+ * Copyright (C) 2010 Olaf Lenz
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge 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.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
/** This script will automatically create mediawiki instances for
projects that do not yet have it.
-
+
It is intended to be started in a cronjob.
*/
# Loop over all projects that use the plugin
while ( $row = db_fetch_array($project_res) ) {
$project = $row['unix_group_name'];
- $project_dir = forge_get_config('projects_path', 'mediawiki')
+ $project_dir = forge_get_config('projects_path', 'mediawiki')
. "/$project";
cron_debug("Checking $project...");
+ $res = db_query_params("SET search_path=public", array());
$res = db_query_params('DELETE FROM plugin_mediawiki_interwiki WHERE iw_prefix=$1', array($project));
- $url = util_make_url("/plugins/mediawiki/wiki/$project/index.php");
+ $url = util_make_url('/plugins/mediawiki/wiki/' . $project . '/index.php/$1');
$res = db_query_params('INSERT INTO plugin_mediawiki_interwiki VALUES ($1, $2, 1, 0)',
array($project,
$url));
if (is_dir($project_dir)) {
cron_debug(" Project dir $project_dir exists, so I assumen the project already exists.");
} else {
- cron_debug(" Creating project dir $project_dir.");
- mkdir($project_dir, 0775, true);
-
// Create the DB
$schema = "plugin_mediawiki_$project";
// Sanitize schema name
cron_debug(" Creating schema $schema.");
$res = db_query_params("CREATE SCHEMA $schema", array());
if (!$res) {
- $err = "Error: Schema Creation Failed: " .
+ $err = "Error: Schema Creation Failed: " .
db_error();
cron_debug($err);
cron_entry(23,$err);
db_rollback();
exit;
}
-
+
$res = db_query_params("SET search_path=$schema", array());
if (!$res) {
- $err = "Error: DB Query Failed: " .
+ $err = "Error: DB Query Failed: " .
db_error();
cron_debug($err);
cron_entry(23,$err);
$creation_query = file_get_contents($table_file);
$res = db_query_from_file($table_file);
if (!$res) {
- $err = "Error: Mediawiki Database Creation Failed: " .
+ $err = "Error: Mediawiki Database Creation Failed: " .
db_error();
cron_debug($err);
cron_entry(23,$err);
$res = db_query_params("CREATE TEXT SEARCH CONFIGURATION $schema.default ( COPY = pg_catalog.english )", array());
if (!$res) {
- $err = "Error: DB Query Failed: " .
+ $err = "Error: DB Query Failed: " .
db_error();
cron_debug($err);
cron_entry(23,$err);
db_rollback();
exit;
}
-
+
if (!db_commit()) {
- $err = "Error: DB Commit Failed: " .
+ $err = "Error: DB Commit Failed: " .
db_error();
cron_debug($err);
cron_entry(23,$err);
exit;
}
+ cron_debug(" Creating project dir $project_dir.");
+ mkdir($project_dir, 0775, true);
+
$mwwrapper = forge_get_config('source_path')."/plugins/mediawiki/bin/mw-wrapper.php" ;
$dumpfile = forge_get_config('config_path')."/mediawiki/initial-content.xml" ;
-
+
if (file_exists ($dumpfile)) {
system ("$mwwrapper $project importDump.php $dumpfile") ;
system ("$mwwrapper $project rebuildrecentchanges.php") ;
}
- }
+ }
}