src/common/forum/ForumAdmin.class.php -text
src/common/include/Codendi_HTMLPurifier.class.php -text
src/common/include/Codendi_Request.class.php -text
+src/common/include/DatabaseInstaller.class.php -text
src/common/include/HTTPRequest.class.php -text
src/common/include/Navigation.class.php -text
src/common/include/PFO-RBAC.interface.php -text
--- /dev/null
+<?php
+
+class DatabaseInstaller extends Error {
+
+ function DatabaseInstaller($name='', $path='') {
+ $this->name = $name;
+ $this->path = $path;
+ }
+
+ function install() {
+ $name = $this->name;
+ $path = $this->path;
+
+ $init = "$path/$name-init.sql";
+ if (is_file($init)) {
+ $ret = $this->runScript($init);
+ if (!$ret) {
+ return false;
+ }
+ return $this->upgrade($name, $path);
+ }
+ return $this->setError(_('No database installation scripts found.'));
+ }
+
+ function upgrade() {
+ $name = $this->name;
+ $path = $this->path;
+
+ if ($name) {
+ $prefix = $name.':';
+ $date = -1;
+ } else {
+ $prefix = '';
+ $date = $this->getDatabaseDate();
+ }
+
+ $scripts = $this->getScripts($path);
+ $output = '';
+ foreach ($scripts as $script) {
+ if ((int) $script['date'] > $date) {
+ $res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
+ array ($prefix.$script['filename'])) ;
+ if (!$res) {
+ return $this->setError("ERROR-2: ".db_error());
+ } else if (db_numrows($res) == 0) {
+ $output .= "Running script: {$script['filename']}\n";
+ $result = $this->runScript($path.'/'.$script['filename']);
+ if ($result) {
+ $res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
+ array ($prefix.$script['filename'])) ;
+ if (!$res) {
+ return $this->setError("ERROR-3: ".db_error());
+ }
+ } else {
+ return false;
+ }
+ } else {
+// $output .= "Skipping script: $prefix{$script['filename']}\n";
+ }
+ }
+ }
+ return $output;
+ }
+
+ private static function getDatabaseDate() {
+ // Check if table 'database_startpoint' has proper values
+ $res = db_query_params ('SELECT * FROM database_startpoint', array()) ;
+ if (!$res) { // db error
+ return $this->setError("DB-ERROR-3: ".db_error()."\n");
+ } else if (db_numrows($res) == 0) { // table 'database_startpoint' is empty
+ return $this->setError("Table 'database_startpoint' is empty, run startpoint.php first.");
+ } else { // get the start date from the db
+ return (int) db_result($res, 0, 'db_start_date');
+ }
+ return false;
+ }
+
+ private function runScript($file) {
+ // If a condition statement if found, then run the script only if true.
+ $content = file($file);
+ if (preg_match('/^-- TRUE\? (.+)/', $content[0], $match)) {
+ $res = db_query_params($match[1], array());
+ if (db_result($res,0,0) == 'f') {
+ return true;
+ }
+ }
+ $res = db_query_from_file($file);
+ if ($res) {
+ while ($res) {
+ db_free_result($res);
+ $res = db_next_result();
+ }
+ } else {
+ return $this->setError(_('Database initialisation error:').' '.db_error());
+ }
+ return true;
+ }
+
+ private static function getScripts($dir) {
+ $data = array();
+ if (is_dir($dir)) {
+ if ($dh = opendir($dir)) {
+ while (($file = readdir($dh)) !== false) {
+ $pos = strrpos($file, '.');
+ if ($pos !== false && $pos > 0) {
+ $name = substr($file, 0, $pos);
+ if (strlen($name) >= 8) {
+ $date_aux = substr($name, 0, 8);
+ $type_aux = substr($file, $pos + 1);
+ if ((int) $date_aux > 20000000 && ($type_aux=='sql' || $type_aux=='php')
+ && strpos($file, 'debian') === false) {
+ $data[] = array('date'=>$date_aux, 'filename'=>$file, 'ext'=>$type_aux);
+ }
+ }
+ }
+ }
+ closedir($dh);
+ }
+ usort($data, array('DatabaseInstaller', 'compare_scripts'));
+ reset($data);
+ }
+ return $data;
+ }
+
+ private static function compare_scripts($script1, $script2) {
+ return strcmp($script1['filename'], $script2['filename']);
+ }
+}
$this->error_state=true;
$this->error_message=$string;
$this->error_code=$code;
+ return false;
}
/**
*
* @return array of User objects for this group.
*/
- function &getMembers() {
+ function getMembers() {
return $this->getUsers (true) ;
}
$role =& $params['role'];
}
- function groupisactivecheckbox(&$params) {
+ function install() {
+ $this->installCode();
+ $this->installConfig();
+ $this->installDatabase();
+ }
+
+ function installCode() {
+ $name = $this->name;
+ $path = forge_get_config('plugins_path') . '/' . $name;
+ $installdir = $this->getInstallDir();
+
+ // Create a symbolic links to plugins/<plugin>/www (if directory exists).
+ if (is_dir($path . '/www')) { // if the plugin has a www dir make a link to it
+ // The apache group or user should have write perms the www/plugins folder...
+ if (!is_link('../'.$installdir)) {
+ $code = symlink($path . '/www', '../'.$installdir);
+ if (!$code) {
+ $this->setError('['.'../'.$installdir.'->'.$path . '/www]'.
+ '<br />Soft link to www couldn\'t be created. Check the write permissions for apache in gforge www/plugins dir or create the link manually.');
+ }
+ }
+ }
+
+ // Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
+ if (is_dir($path . '/etc/plugins/' . $name)) {
+ // The apache group or user should have write perms in /etc/gforge/plugins folder...
+ if (!is_link(forge_get_config('config_path'). '/plugins/'.$name) && !is_dir(forge_get_config('config_path'). '/plugins/'.$name)) {
+ $code = symlink($path . '/etc/plugins/' . $name, forge_get_config('config_path'). '/plugins/'.$name);
+ if (!$code) {
+ $this->setError('['.forge_get_config('config_path'). '/plugins/'.$name.'->'.$path . '/etc/plugins/' . $name . ']'.
+ _('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $name);
+ }
+ }
+ }
+ }
+
+ function installConfig() {
+ $name = $this->name;
+ $path = forge_get_config('plugins_path') . '/' . $name;
+
+ // Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
+ if (is_dir($path . '/etc/plugins/' . $name)) {
+ // The apache group or user should have write perms in /etc/gforge/plugins folder...
+ if (!is_link(forge_get_config('config_path'). '/plugins/'.$name) && !is_dir(forge_get_config('config_path'). '/plugins/'.$name)) {
+ $code = symlink($path . '/etc/plugins/' . $name, forge_get_config('config_path'). '/plugins/'.$name);
+ if (!$code) {
+ $this->setError('['.forge_get_config('config_path'). '/plugins/'.$name.'->'.$path . '/etc/plugins/' . $name . ']'.
+ _('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $name);
+ }
+ }
+ }
+ }
+
+ function installDatabase() {
+ $name = $this->name;
+ $path = forge_get_config('plugins_path') . '/' . $name . '/db';
+
+ require_once $GLOBALS['gfcommon'].'include/DatabaseInstaller.class.php';
+ $di = new DatabaseInstaller($name, $path);
+
+ // Search for database tables, if present then upgrade.
+ $res=db_query_params ('SELECT COUNT(*) FROM pg_class WHERE (relname=$1 OR relname like $2) AND relkind=$3',
+ array ('plugin_'.$name, 'plugin_'.$name.'_%', 'r'));
+ $count = db_result($res,0,0);
+ if ($count == 0) {
+ $di->install();
+ } else {
+ $di->upgrade();
+ }
+ }
+
+ function groupisactivecheckbox (&$params) {
//Check if the group is active
// this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
$display = 1;
#! /usr/bin/php
<?php
+// upgrade-db.php => Upgrade the main database.
+// upgrade-db.php all => Upgrade the main database and active plugins.
+// upgrade-db.php <plugin> => Upgrade only the database of the given active plugin.
+
require_once dirname(__FILE__).'/../www/env.inc.php';
require_once $gfcommon.'include/pre.php';
exit();
}
-$scripts = get_scripts($db_path);
-
-foreach ($scripts as $script) {
- if ((int) $script['date'] > $date) {
- $res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
- array ("{$script['filename']}")) ;
- if (!$res) {
- // error
- show("ERROR-2: ".db_error()."\n");
- exit();
- } else if (db_numrows($res) == 0) {
- show("Running script: {$script['filename']}\n");
- $result = run_script($script);
- if ($result) {
- $res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
- array ("{$script['filename']}")) ;
- if (!$res)
- {
- show("ERROR-3: ".db_error()."\n");
+// Upgrade main database if no argument or if all)
+if ($argc == 1 || $argv[1] == 'all') {
+ $scripts = get_scripts($db_path);
+ foreach ($scripts as $script) {
+ if ((int) $script['date'] > $date) {
+ $res = db_query_params ('SELECT * FROM database_changes WHERE filename=$1',
+ array ("{$script['filename']}")) ;
+ if (!$res) {
+ // error
+ show("ERROR-2: ".db_error()."\n");
+ exit();
+ } else if (db_numrows($res) == 0) {
+ show("Running script: {$script['filename']}\n");
+ $result = run_script($script);
+ if ($result) {
+ $res = db_query_params ('INSERT INTO database_changes (filename) VALUES ($1)',
+ array ("{$script['filename']}")) ;
+ if (!$res)
+ {
+ show("ERROR-3: ".db_error()."\n");
+ exit();
+ }
+ } else {
+ // error
exit();
}
} else {
- // error
- exit();
+ // show("Skipping script: {$script['filename']}\n");
}
- } else {
- show("Skipping script: {$script['filename']}\n");
}
}
}
+// Upgrade activated plugins.
+if ($argc == 2) {
+ require_once $gfcommon.'include/DatabaseInstaller.class.php';
+ $plugins = get_installed_plugins();
+ foreach ($plugins as $plugin) {
+ if ($argv[1] == 'all' || $argv[1] == $plugin) {
+ $di = new DatabaseInstaller($plugin, dirname($db_path) . '/plugins/' . $plugin . '/db');
+ echo $di->upgrade();
+ }
+ }
+}
+
+function get_installed_plugins() {
+ $plugins = array();
+ $res = db_query_params ('SELECT plugin_name FROM plugins', array ());
+ while ($row = db_fetch_array($res)) {
+ $plugins[] = $row['plugin_name'];
+ }
+ return $plugins;
+}
+
function get_scripts($dir) {
$data = array();
if (is_dir($dir)) {
@FORGENAME@ is packaged for Debian, and was formerly packaged under
the 'gforge' source package name. Even though a transition is in
progress towards renaming it widely, only high-level meta-packages are
-named with the '@FORGENAME@' prefix. The rest of the packages are
+named with the '@PACKAGE@' prefix. The rest of the packages are
still named with the 'gforge-' prefix, so expect most paths and
filenames to still be named in relation to 'gforge'.
Note on documentation
---------------------
+See contents of /usr/share/doc/@OLDPACKAGE@-common/ first.
+
Although a few documentation files from upstream are included, they
are either very out of date or practically useless. I mostly include
them for completeness's sake (and per request, too). The files I'm
Should these settings not suit you, it is possible to change
configuration options by :
- 1. modifying /etc/@FORGENAME@/@FORGENAME@.conf which contains the
+ 1. modifying /etc/@PACKAGE@/@PACKAGE@.conf which contains the
basic settings
( 2. Optional : copy some template files from
/usr/share/gforge/etc/local.d/ to /etc/gforge/local.d/ (TO BE
3. regenerate the runtime config files by issueing :
# fusionforge-config
-Customizations in /etc/@FORGENAME@/@FORGENAME@.conf may include :
+Customizations in /etc/@PACKAGE@/@PACKAGE@.conf may include :
- switching to HTTPS with 'sys_use_ssl=true',
- - setting a custom URL prefix with 'sys_urlprefix=/@FORGENAME@/' for
+ - setting a custom URL prefix with 'sys_urlprefix=/@PACKAGE@/' for
instance,
etc.
### Plugin setup ###
%{__cp} $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/*/etc/*.ini $RPM_BUILD_ROOT%{FORGE_CONF_DIR}/config.ini.d/
%{__cp} $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/*/etc/cron.d/* $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/
-%{__cp} $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/*/etc/httpd.d/* $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/
+%{__cp} $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/*/etc/httpd.d/* $RPM_BUILD_ROOT%{FORGE_CONF_DIR}/httpd.d/
%{__cp} -rp $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/*/etc/plugins/* $RPM_BUILD_ROOT%{FORGE_CONF_DIR}/plugins/
%{__rm} -f $RPM_BUILD_ROOT%{FORGE_DIR}/plugins/README
%files plugin-hudson
%config(noreplace) %{FORGE_CONF_DIR}/plugins/hudson/
-%{_sysconfdir}/httpd/conf.d/62plugin-hudson
+%{FORGE_CONF_DIR}/httpd.d/62plugin-hudson
%{FORGE_DIR}/plugins/hudson
%{FORGE_DIR}/www/plugins/hudson
%files plugin-mediawiki
%config(noreplace) %{FORGE_CONF_DIR}/config.ini.d/mediawiki.ini
%config(noreplace) %{FORGE_CONF_DIR}/httpd.d/03mediawiki.conf
-%{_sysconfdir}/httpd/conf.d/61plugin-mediawiki
+%{FORGE_CONF_DIR}/httpd.d/61plugin-mediawiki
%{FORGE_DIR}/plugins/mediawiki/
%{FORGE_DIR}/www/plugins/mediawiki
/usr/share/mediawiki/skins/gforge
%files plugin-oslc
%config(noreplace) %{FORGE_CONF_DIR}/plugins/oslc/
-%{_sysconfdir}/httpd/conf.d/plugin-oslc.inc
+%{FORGE_CONF_DIR}/httpd.d/plugin-oslc.inc
%{FORGE_DIR}/plugins/oslc
%{FORGE_DIR}/www/plugins/oslc
%files plugin-scmgit
%config(noreplace) %{FORGE_CONF_DIR}/plugins/scmgit/
%config(noreplace) %{FORGE_CONF_DIR}/config.ini.d/scmgit.ini
+%{FORGE_CONF_DIR}/httpd.d/plugin-scmgit.conf
%{FORGE_DIR}/plugins/scmgit
%{FORGE_DIR}/www/plugins/scmgit
%config(noreplace) %{FORGE_CONF_DIR}/plugins/scmcvs/
%config(noreplace) %{FORGE_CONF_DIR}/config.ini.d/scmcvs.ini
%{_sysconfdir}/cron.d/%{name}-plugin-scmcvs
-%{_sysconfdir}/httpd/conf.d/30virtualcvs
-%{_sysconfdir}/httpd/conf.d/31virtualcvs.ssl
+%{FORGE_CONF_DIR}/httpd.d/30virtualcvs
+%{FORGE_CONF_DIR}/httpd.d/31virtualcvs.ssl
%{FORGE_DIR}/plugins/scmcvs
%{FORGE_DIR}/www/plugins/scmcvs
%{FORGE_VAR_LIB}/chroot/scmrepos/cvs
%files plugin-wiki
%config(noreplace) %{FORGE_CONF_DIR}/plugins/wiki/
%{_sysconfdir}/cron.d/cron.wiki
-%{_sysconfdir}/httpd/conf.d/03wiki.conf
+%{FORGE_CONF_DIR}/httpd.d/03wiki.conf
%{FORGE_DIR}/plugins/wiki
%{FORGE_DIR}/www/wiki
%files plugin-mailman
%config(noreplace) %{FORGE_CONF_DIR}/plugins/mailman/
-%{_sysconfdir}/httpd/conf.d/62plugin-list-mailman
-%{_sysconfdir}/httpd/conf.d/200list.vhost
-%{_sysconfdir}/httpd/conf.d/20list
-%{_sysconfdir}/httpd/conf.d/20zlist.vhost
-%{_sysconfdir}/httpd/conf.d/21list.vhost.ssl
+%{FORGE_CONF_DIR}/httpd.d/62plugin-list-mailman
+%{FORGE_CONF_DIR}/httpd.d/200list.vhost
+%{FORGE_CONF_DIR}/httpd.d/20list
+%{FORGE_CONF_DIR}/httpd.d/20zlist.vhost
+%{FORGE_CONF_DIR}/httpd.d/21list.vhost.ssl
%{FORGE_DIR}/plugins/mailman
%{FORGE_DIR}/www/plugins/mailman
+-- TRUE? SELECT data_type = 'date' FROM information_schema.columns WHERE table_name = 'plugin_cvstracker_data_master' AND column_name='cvs_date';
+
DROP INDEX plugin_cvstracker_group_artifact_id;
ALTER TABLE plugin_cvstracker_data_master ADD COLUMN cvs_date2 int4;
CREATE INDEX plugincvstrackerdataartifact_projecttaskid ON plugin_cvstracker_data_artifact(project_task_id);
CREATE INDEX plugincvstrackerdatamaster_holderid ON plugin_cvstracker_data_master(holder_id);
-CREATE INDEX plugincvstrackerdatamaster_cvsdate ON plugin_cvstracker_data_master(cvs_date);
\ No newline at end of file
+CREATE INDEX plugincvstrackerdatamaster_cvsdate ON plugin_cvstracker_data_master(cvs_date);
class GitPlugin extends SCMPlugin {
function GitPlugin () {
- global $gfconfig;
$this->SCMPlugin () ;
$this->name = 'scmgit';
$this->text = 'Git';
+ $this->hooks[] = 'scm_browser_page';
$this->hooks[] = 'scm_update_repolist' ;
- $this->hooks[] = 'scm_browser_page' ;
- $this->hooks[] = 'scm_gather_stats' ;
$this->hooks[] = 'scm_generate_snapshots' ;
+ $this->hooks[] = 'scm_gather_stats' ;
$this->register () ;
}
}
function getInstructionsForAnon ($project) {
- $b = '<h2>';
- $b .= _('Anonymous Git Access');
- $b .= '</h2>';
+ $b = '<h2>' . _('Anonymous Git Access') . '</h2>';
$b .= '<p>';
$b .= _('This project\'s Git repository can be checked out through anonymous access with the following command.');
$b .= '</p>';
+
$b .= '<p>' ;
$b .= '<tt>git clone '.util_make_url ('/anonscm/git/'.$project->getUnixName().'/'.$project->getUnixName().'.git').'</tt><br />';
$b .= '</p>';
// return $b ;
// }
+
function getStatsBlock ($project) {
return ;
}
if (!$project) {
return false ;
}
-
+
if (! $project->usesPlugin ($this->name)) {
return false;
}
return $list;
}
- function generateSnapshots ($params) {
-
-
- $project = $this->checkParams ($params) ;
- if (!$project) {
- return false ;
- }
-
- $group_name = $project->getUnixName() ;
-
- $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
- $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
-
- if (! $project->usesPlugin ($this->name)) {
- return false;
- }
-
- if (! $project->enableAnonSCM()) {
- unlink ($tarball) ;
- return false;
- }
-
- // TODO: ideally we generate one snapshot per git repository
- $toprepo = forge_get_config('repos_path', 'scmgit') ;
- $repo = $toprepo . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git' ;
-
- if (!is_dir ($repo)) {
- unlink ($tarball) ;
- return false ;
- }
-
- $today = date ('Y-m-d') ;
- $tmp = trim (`mktemp -d`) ;
- if ($tmp == '') {
- return false ;
- }
-
- system ("GIT_DIR=\"$repo\" git archive --format=tar --prefix=$group_name-scm-$today/ HEAD | gzip > $tmp/snapshot.tar.gz");
- chmod ("$tmp/snapshot.tar.gz", 0644) ;
- copy ("$tmp/snapshot.tar.gz", $snapshot) ;
- unlink ("$tmp/snapshot.tar.gz") ;
-
- system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
- chmod ("$tmp/tarball.tar.gz", 0644) ;
- copy ("$tmp/tarball.tar.gz", $tarball) ;
- unlink ("$tmp/tarball.tar.gz") ;
- system ("rm -rf $tmp") ;
- }
-
function gatherStats ($params) {
global $last_user, $usr_adds, $usr_deletes,
$usr_updates, $updates, $adds;
} else {
continue;
}
-
+
$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
if ($uu > 0 || $ua > 0) {
}
db_commit();
}
- }
+
+ function generateSnapshots ($params) {
+
+ $project = $this->checkParams ($params) ;
+ if (!$project) {
+ return false ;
+ }
+
+ $group_name = $project->getUnixName() ;
+
+ $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
+ $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+
+ if (! $project->usesPlugin ($this->name)) {
+ return false;
+ }
+
+ if (! $project->enableAnonSCM()) {
+ if (is_file($snapshot)) {
+ unlink ($snapshot) ;
+ }
+ if (is_file($tarball)) {
+ unlink ($tarball) ;
+ }
+ return false;
+ }
+
+ // TODO: ideally we generate one snapshot per git repository
+ $toprepo = forge_get_config('repos_path', 'scmgit') ;
+ $repo = $toprepo . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git' ;
+
+ if (!is_dir ($repo)) {
+ if (is_file($snapshot)) {
+ unlink ($snapshot) ;
+ }
+ if (is_file($tarball)) {
+ unlink ($tarball) ;
+ }
+ return false ;
+ }
+
+ $tmp = trim (`mktemp -d`) ;
+ if ($tmp == '') {
+ return false ;
+ }
+ $today = date ('Y-m-d') ;
+ system ("GIT_DIR=\"$repo\" git archive --format=tar --prefix=$group_name-scm-$today/ HEAD | gzip > $tmp/snapshot.tar.gz");
+ chmod ("$tmp/snapshot.tar.gz", 0644) ;
+ copy ("$tmp/snapshot.tar.gz", $snapshot) ;
+ unlink ("$tmp/snapshot.tar.gz") ;
+
+ system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
+ chmod ("$tmp/tarball.tar.gz", 0644) ;
+ copy ("$tmp/tarball.tar.gz", $tarball) ;
+ unlink ("$tmp/tarball.tar.gz") ;
+ system ("rm -rf $tmp") ;
+ }
+}
// Local Variables:
// mode: php
$this->register () ;
}
-
+
function getDefaultServer() {
return forge_get_config('default_server', 'scmsvn') ;
}
}
function getInstructionsForAnon ($project) {
- $b = '<h2>' . _("Anonymous Subversion Access") . '</h2>';
+ $b = '<h2>' . _('Anonymous Subversion Access') . '</h2>';
$b .= '<p>';
$b .= _("This project's SVN repository can be checked out through anonymous access with the following command(s).");
$b .= '</p>';
$start_time = gmmktime( 0, 0, 0, $month, $day, $year);
$end_time = $start_time + 86400;
+ $adds = 0 ;
$updates = 0 ;
- $adds = 0 ;
- $usr_adds = array () ;
+ $usr_adds = array () ;
$usr_updates = array () ;
$repo = forge_get_config('repos_path', 'scmsvn') . '/' . $project->getUnixName() ;
} else {
continue;
}
-
+
$uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
$ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
if ($uu > 0 || $ua > 0) {
function generateSnapshots ($params) {
-
-
$project = $this->checkParams ($params) ;
if (!$project) {
return false ;
$pluginname = getStringFromRequest('update');
if ((getStringFromRequest('action')=='deactivate')) {
- if (getStringFromRequest('delusers')) {
- $res = db_query_params ('DELETE FROM user_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
+ $res = db_query_params ('DELETE FROM user_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
array($pluginname));
- if (!$res) {
- exit_error(db_error(),'admin');
- } else {
- $feedback .= sprintf(ngettext('%d user detached from plugin.', '%d users detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
- }
+ if (!$res) {
+ exit_error(db_error(),'admin');
+ } else {
+ $feedback .= sprintf(ngettext('%d user detached from plugin.', '%d users detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
}
- if (getStringFromRequest('delgroups')) {
- $res = db_query_params ('DELETE FROM group_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
+ $res = db_query_params ('DELETE FROM group_plugin WHERE plugin_id = (SELECT plugin_id FROM plugins WHERE plugin_name = $1)',
array($pluginname));
- if (!$res) {
- exit_error(db_error(),'admin');
- } else {
- $feedback .= sprintf(ngettext('%d project detached from plugin.', '%d projects detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
- }
+ if (!$res) {
+ exit_error(db_error(),'admin');
+ } else {
+ $feedback .= sprintf(ngettext('%d project detached from plugin.', '%d projects detached from plugin.', db_affected_rows($res)), db_affected_rows($res));
}
+
$res = $pm->deactivate($pluginname);
if (!$res) {
exit_error(db_error(),'admin');
// Load the plugin and now get information from it.
$pm = plugin_manager_get_object();
$pm->LoadPlugin($pluginname);
- $plugin = $pm->GetPluginObject($pluginname);
- $installdir = $plugin->getInstallDir();
- // Create a symbolic links to plugins/<plugin>/www (if directory exists).
- if (is_dir(forge_get_config('plugins_path') . '/' . $pluginname . '/www')) { // if the plugin has a www dir make a link to it
- // The apache group or user should have write perms the www/plugins folder...
- if (!is_link('../'.$installdir)) {
- $code = symlink(forge_get_config('plugins_path') . '/' . $pluginname . '/www', '../'.$installdir);
- if (!$code) {
- $error_msg .= '<br />['.'../'.$installdir.'->'.forge_get_config('plugins_path') . '/' . $pluginname . '/www]';
- $error_msg .= _('<br />Soft link to www couldn\'t be created. Check the write permissions for apache in gforge www/plugins dir or create the link manually.');
- }
- }
- }
-
- // Create a symbolic links to plugins/<plugin>/etc/plugins/<plugin> (if directory exists).
- if (is_dir(forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname)) {
- // The apache group or user should have write perms in /etc/gforge/plugins folder...
- if (!is_link(forge_get_config('config_path'). '/plugins/'.$pluginname) && !is_dir(forge_get_config('config_path'). '/plugins/'.$pluginname)) {
- $code = symlink(forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname, forge_get_config('config_path'). '/plugins/'.$pluginname);
- if (!$code) {
- $error_msg .= '<br />['.forge_get_config('config_path'). '/plugins/'.$pluginname.'->'.forge_get_config('plugins_path') . '/' . $pluginname . '/etc/plugins/' . $pluginname . ']';
- $error_msg .= sprintf(_('<br />Config file could not be linked to etc/gforge/plugins/%1$s. Check the write permissions for apache in /etc/gforge/plugins or create the link manually.'), $pluginname);
- }
- }
- }
-
- if (getStringFromRequest('init')) {
- // now we're going to check if there's a XX-init.sql file and run it
- $db_init = forge_get_config('plugins_path') . '/' . $pluginname . '/db/' . $pluginname . '-init-pgsql.sql';
- if (!is_file($db_init)) {
- $db_init = forge_get_config('plugins_path') . '/' . $pluginname . '/db/' . $pluginname . '-init.sql';
- if (!is_file($db_init)) {
- $db_init = 0;
- }
- }
-
- if ($db_init) {
- $res = db_query_from_file($db_init);
-
- if ($res) {
- while ($res) {
- db_free_result($res);
- $res = db_next_result();
- }
- } else {
- $error_msg .= _('Initialisation error<br />Database said: ').db_error();
- }
- }
- //we check for a php script
- if (is_file(forge_get_config('plugins_path') . '/' . $pluginname . '/script/' . $pluginname . '-init.php')) {
- include(forge_get_config('plugins_path') . '/' . $pluginname . '/script/' . $pluginname . '-init.php');
- }
- }
+ $plugin = $pm->GetPluginObject($pluginname);
+ $plugin->installCode();
+ $plugin->installConfig();
+ $plugin->installDatabase();
}
}
}
echo '<h1>' . _('Plugin Manager') . '</h1>';
?>
-<script type="text/javascript">
-<!--
- function change(url,plugin)
- {
- field = document.theform.elements[plugin];
- if (field.checked) {
- window.location=(url + "&init=yes");
- } else {
- window.location=(url);
- }
- }
-
-// -->
-</script>
-
<form name="theform" action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get">
<?php
echo '<p>';
echo _('Here you can activate / deactivate site-wide plugins which are in the plugins/ folder. Then, you should activate them also per project, per user or whatever the plugin specifically applies to.');
echo '</p>';
echo '<p class="important">' . _('Be careful because some projects/users can be using the plugin. Deactivating it will remove the plugin from all users/projects.') . '</p>';
-echo '<p class="important">' . _('Be EXTRA careful running the SQL init script when a plugin has been deactivated prior use (and you want to re-activate) because some scripts have DROP TABLE statements.') . '</p>';
+
$title_arr = array( _('Plugin Name'),
_('Status'),
_('Action'),
- _('Run Init Script?'),
_('Users Using it'),
_('Projects Using it'),);
echo $HTML->listTableTop($title_arr);
//get the directories from the plugins dir
$filelist = array();
-$has_init = array();
if($handle = opendir(forge_get_config('plugins_path'))) {
while (($filename = readdir($handle)) !== false) {
if ($filename != '..' && $filename != '.' && $filename != ".svn" && $filename != "CVS" &&
}
if ($addPlugin) {
$filelist[] = $filename;
- $has_init[$filename] = is_dir(forge_get_config('plugins_path').'/'.$filename.'/db');
}
}
}
$j = 0;
foreach ($filelist as $filename) {
- $init = '<input type="hidden" id="'.$filename.'" name="script[]" value="'.$filename.'" />';
if ($pm->PluginIsInstalled($filename)) {
$msg = _('Active');
- $status="active";
- $link = "<a href=\"javascript:change('" . getStringFromServer('PHP_SELF') . "?update=$filename&action=deactivate";
+ $status = "active";
+ $link = util_make_link("/admin/pluginman.php?update=$filename&action=deactivate", _('Deactivate'));
- $res = db_query_params ('SELECT u.user_name FROM plugins p, user_plugin up, users u WHERE p.plugin_name = $1 and up.user_id = u.user_id and p.plugin_id = up.plugin_id',
+ $res = db_query_params ('SELECT u.user_name FROM plugins p, user_plugin up, users u WHERE p.plugin_name = $1 and up.user_id = u.user_id and p.plugin_id = up.plugin_id',
array($filename));
if ($res) {
if (db_numrows($res)>0) {
- // tell the form to delete the users, so that we don't re-do the query
- $link .= "&delusers=1";
$users = " ";
for($i=0;$i<db_numrows($res);$i++) {
$users .= db_result($res,$i,0) . " | ";
}
$users = substr($users,0,strlen($users) - 3); //remove the last |
} else {
- $users = _("none");
+ $users = _('None');
}
}
array($filename));
if ($res) {
if (db_numrows($res)>0) {
- // tell the form to delete the groups, so that we don't re-do the query
- $link .= "&delgroups=1";
$groups = " ";
for($i=0;$i<db_numrows($res);$i++) {
$groups .= db_result($res,$i,0) . " | ";
}
$groups = substr($groups,0,strlen($groups) - 3); //remove the last |
} else {
- $groups = _("none");
+ $groups = _('None');
}
}
- $link .= "','$filename');" . '">' . _('Deactivate') . "</a>";
- if ($has_init[$filename]) {
- $init = '<input id="'.$filename.'" type="checkbox" disabled="disabled" name="script[]" value="'.$filename.'" />';
- }
} else {
$msg = _('Inactive');
$status = "inactive";
- $link = "<a href=\"javascript:change('" . getStringFromServer('PHP_SELF') . "?update=$filename&action=activate','$filename');" . '">' . _('Activate') . "</a>";
- if ($has_init[$filename]) {
- $init = '<input id="'.$filename.'" type="checkbox" name="script[]" value="'.$filename.'" />';
- }
- $users = _("none");
- $groups = _("none");
+ $link = util_make_link("/admin/pluginman.php?update=$filename&action=activate", _('Activate'));
+ $users = _('None');
+ $groups = _('None');
}
$title = _('Current plugin status:'). ' ' .forge_get_config('plugin_status', $filename);
'<td title="'. $title .'" >'. $filename.'</td>'.
'<td class="'.$status.'" style="text-align:center">'. $msg .'</td>'.
'<td style="text-align:center;">'. $link .'</td>'.
- '<td style="text-align:center;">'. $init .'</td>'.
'<td style="text-align:left;">'. $users .'</td>'.
'<td style="text-align:left;">'. $groups .'</td></tr>'."\n";
// Install a fake sendmail to catch all outgoing emails.
system("ssh root@".HOST." 'perl -spi -e s#/usr/sbin/sendmail#/usr/share/tests/scripts/catch_mail.php# /etc/gforge/local.inc'");
+
+ system("ssh root@".HOST." 'service crond stop'");
}
}
?>
}
protected function activatePlugin($pluginName) {
+ $this->switchUser('admin');
$this->open( ROOT . '/admin/pluginman.php?update='.$pluginName.'&action=deactivate');
$this->waitForPageToLoad("30000");
- $this->open( ROOT );
- $this->waitForPageToLoad("30000");
- $this->login('admin');
- $this->clickAndWait("link=Site Admin");
- $this->clickAndWait("link=Plugin Manager");
- $this->click($pluginName);
- $this->click("//a[contains(@href, \"javascript:change('".ROOT."/admin/pluginman.php?update=$pluginName&action=activate','$pluginName');\")]");
+ $this->open( ROOT . '/admin/pluginman.php?update='.$pluginName.'&action=activate');
$this->waitForPageToLoad("30000");
$this->logout();
}
// Install a fake sendmail to catch all outgoing emails.
system("ssh root@".HOST." 'perl -spi -e s#/usr/sbin/sendmail#/opt/tests/scripts/catch_mail.php# /etc/gforge/local.inc'");
+
+ system("ssh root@".HOST." 'service crond stop'");
}
}
?>