4 * Copyright 2011, Roland Mas
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 /** This script will automatically dump Mediawiki databases to an XML file.
24 * It is intended to be started in a cronjob.
26 * Note: Wiki dumps of Wikis made private since the last invocation
27 * will be removed; Wiki dumps of groups no longer using the
28 * MediaWiki plugin will not be removed (probably a mistake)!
31 require_once dirname(__FILE__) . '/../../../www/env.inc.php';
32 require_once $gfcommon.'include/pre.php';
33 require_once $gfcommon.'include/cron_utils.php';
35 $src_path = forge_get_config('src_path', 'mediawiki');
36 $master_path = forge_get_config('master_path', 'mediawiki');
38 // Get all projects that use the mediawiki plugin
39 $project_res = db_query_params ("SELECT g.unix_group_name,g.group_id from groups g, group_plugin gp, plugins p where g.group_id = gp.group_id and gp.plugin_id = p.plugin_id and p.plugin_name = $1;", array("mediawiki"));
41 $err = "Error: Database Query Failed: ".db_error();
47 // Loop over all projects that use the plugin
48 while ( $row = db_fetch_array($project_res) ) {
49 $project = $row['unix_group_name'];
50 $project_id = $row['group_id'];
51 $dump_file = forge_get_config('data_path') . "/plugins/mediawiki/dumps/$project.xml";
53 $ra = RoleAnonymous::getInstance();
54 if ($ra->hasPermission('plugin_mediawiki_read',$project_id)) {
55 cron_debug("Dumping $project...");
56 $mwwrapper = forge_get_config('source_path')."/plugins/mediawiki/bin/mw-wrapper.php" ;
57 $tmp = tempnam(forge_get_config('data_path')."/plugins/mediawiki/dumps/", "tmp");
58 system ("$mwwrapper $project dumpBackup.php --current --quiet > $tmp") ;
60 rename ($tmp, $dump_file);
62 cron_debug("Not dumping $project (private)...");
63 if (file_exists($dump_file)) {
71 // c-file-style: "bsd"