[Fusionforge-commits] FusionForge branch import_export created. e7b231be4d7cde19addecaef385f9705cb988f1c
Dionysios Fryganas
nioniosfr at fusionforge.org
Fri May 30 13:39:54 CEST 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, import_export has been created
at e7b231be4d7cde19addecaef385f9705cb988f1c (commit)
- Log -----------------------------------------------------------------
commit e7b231be4d7cde19addecaef385f9705cb988f1c
Author: Dionysios Fryganas <dfryganas at gmail.com>
Date: Fri May 30 13:19:42 2014 +0200
Adding basic functionality structure.
diff --git a/src/plugins/importexport/INSTALL b/src/plugins/importexport/INSTALL
new file mode 100644
index 0000000..5f3c74d
--- /dev/null
+++ b/src/plugins/importexport/INSTALL
@@ -0,0 +1,10 @@
+How to install importexport plugin.
+
+Currently the plugin is in development and many fields need to be experimented with, so do not trust the code to be fuctional at all times.
+
+* Make all the appropriate links to the installation of fusionforge.
+ $fusionforge/plugins -> $source/src/plugins/importexport/
+ $fusionforge/www/plugins/ -> $source/src/plugins/importexport
+ $fusionforge/common/ -> $source/src/plugins/importexport/common/
+ $fusionforge/etc/ -> $source/src/plugins/importexport/etc
+* You do not need to run the database script, since it is not yet used.
\ No newline at end of file
diff --git a/src/plugins/importexport/common/importexport-init.php b/src/plugins/importexport/common/importexport-init.php
index b984ce8..5c99859 100644
--- a/src/plugins/importexport/common/importexport-init.php
+++ b/src/plugins/importexport/common/importexport-init.php
@@ -20,7 +20,18 @@
*/
global $gfplugins;
-require_once $gfplugins.'importexport/include/importexportPlugin.class.php' ;
+$required = $gfplugins.'importexport/include/importexportPlugin.class.php';
+
+// TODO: Fix the require issue.
+// Although file exists, it isn't readable(!?).
+// Tried copying the file, linking it, even adding the plugin in the DB(!?).
+// relative - absolute paths..same behaviour I am missing smthng here...
+if (file_exists($required) && is_readable($required)) {
+ require_once $required;
+}
+else {
+ return;
+}
$importexportPluginObject = new importexportPlugin ;
diff --git a/src/plugins/importexport/db/importexport-init.sql b/src/plugins/importexport/db/importexport-init.sql
index d87f39a..9249ce8 100644
--- a/src/plugins/importexport/db/importexport-init.sql
+++ b/src/plugins/importexport/db/importexport-init.sql
@@ -1,4 +1,5 @@
-CREATE TABLE plugin_importexport_sample_data (
- domain text,
- ip_address text
+CREATE TABLE plugin_importexport_meta_data (
+ plugin_id text,
+ active boolean,
+ version text
) ;
diff --git a/src/plugins/importexport/etc/importexport.ini b/src/plugins/importexport/etc/importexport.ini
index 03e1a15..afa6ff3 100644
--- a/src/plugins/importexport/etc/importexport.ini
+++ b/src/plugins/importexport/etc/importexport.ini
@@ -4,4 +4,4 @@
; valid means : production ready.
; Any other strings means it's under work or broken and plugin
; is available in installation_environment = development only.
-plugin_status = 'example only'
+plugin_status = 'development'
diff --git a/src/plugins/importexport/include/importexportPlugin.class.php b/src/plugins/importexport/include/importexportPlugin.class.php
index d45b2cd..257a8e4 100644
--- a/src/plugins/importexport/include/importexportPlugin.class.php
+++ b/src/plugins/importexport/include/importexportPlugin.class.php
@@ -22,18 +22,25 @@
*/
class importexportPlugin extends Plugin {
- public function __construct($id=0) {
- $this->Plugin($id) ;
+ public function __construct() {
+ $this->Plugin();
$this->name = "importexport";
- $this->text = "importexport!"; // To show in the tabs, use...
- $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
+ $this->text = _("Import/Export"); // To show in the tabs, use...
+
+/* $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
$this->_addHook("usermenu");
$this->_addHook("groupmenu"); // To put into the project tabs
+*/
+ $this->_addHook('site_admin_option_hook');
+
+/* $this->_addHook('project_admin_plugins');
$this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
$this->_addHook("groupisactivecheckboxpost"); //
$this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
$this->_addHook("userisactivecheckboxpost"); //
$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
+ $this->_addHook('group_delete');
+*/
}
function CallHook ($hookname, &$params) {
@@ -43,7 +50,7 @@ class importexportPlugin extends Plugin {
if ($G_SESSION->usesPlugin("importexport")) {
$param = '?type=user&id=' . $G_SESSION->getId() . '&pluginname=' . $this->name; // we indicate the part we're calling is the user one
echo $HTML->PrintSubMenu (array ($text),
- array ('/plugins/importexport/index.php' . $param ));
+ array ('/plugins/importexport/index.php' . $param ));
}
} elseif ($hookname == "groupmenu") {
@@ -103,7 +110,7 @@ class importexportPlugin extends Plugin {
if ($user->usesPlugin($this->name)) {
echo ' <p>' ;
echo util_make_link ("/plugins/importexport/index.php?id=$userid&type=user&pluginname=".$this->name,
- _('View Personal importexport')
+ _('View Personal importexport')
);
echo '</p>';
}
@@ -113,13 +120,17 @@ class importexportPlugin extends Plugin {
$group = group_get_object($group_id);
if ( $group->usesPlugin ( $this->name ) ) {
echo '<p>'.util_make_link ("/plugins/importexport/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
- _('importexport Admin')).'</p>' ;
+ _('importexport Admin')).'</p>' ;
}
}
- elseif ($hookname == "blahblahblah") {
- // ...
+ elseif ($hookname == "site_admin_option_hook") {
+ echo '<li>'.$this->getAdminOptionLink().'</li>';
}
}
+
+ function getAdminOptionLink() {
+ return util_make_link('/plugins/'.$this->name.'/?type=globaladmin', _('Import/Export admin'), array('title' => _('Direct link to global configuration of this plugin')));
+ }
}
// Local Variables:
diff --git a/src/plugins/importexport/www/admin/index.php b/src/plugins/importexport/www/admin/index.php
index 363ba27..cd9c6f6 100644
--- a/src/plugins/importexport/www/admin/index.php
+++ b/src/plugins/importexport/www/admin/index.php
@@ -10,7 +10,7 @@
require_once '../../../env.inc.php';
require_once $gfwww.'include/pre.php';
-require_once $gfconfig.'plugins/importexport/config.php';
+//require_once $gfconfig.'plugins/importexport/config.php';
// the header that displays for the user portion of the plugin
function importexport_Project_Header($params) {
@@ -42,7 +42,7 @@ function importexport_User_Header($params) {
$type = getStringFromRequest('type');
$id = getStringFromRequest('id');
- $pluginname = getStringFromRequest('pluginname');
+ $pluginname = getStringFromRequest('importexport');
if (!$type) {
exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
diff --git a/src/plugins/importexport/www/index.php b/src/plugins/importexport/www/index.php
index cdd9bf0..2ff8f0f 100644
--- a/src/plugins/importexport/www/index.php
+++ b/src/plugins/importexport/www/index.php
@@ -8,102 +8,145 @@
* This is an example to watch things in action. You can obviously modify things and logic as you see fit
*/
-require_once '../../env.inc.php';
-require_once $gfwww.'include/pre.php';
-require_once $gfconfig.'plugins/importexport/config.php';
+require_once '../../../www/env.inc.php';
+require_once $gfcommon.'include/pre.php';
+require_once $gfwww.'admin/admin_utils.php';
-// the header that displays for the user portion of the plugin
-function importexport_Project_Header($params) {
- global $DOCUMENT_ROOT,$HTML,$id;
- $params['toptab']='importexport';
- $params['group']=$id;
- /*
- Show horizontal links
- */
- site_project_header($params);
-}
+site_admin_header(array('title'=>_('Import/Export')));
+
+//$plugin = plugin_get_object('importexport');
+//$plugin_id = $plugin->getID();
+$func = getStringFromRequest('func');
-// the header that displays for the project portion of the plugin
-function importexport_User_Header($params) {
- global $DOCUMENT_ROOT,$HTML,$user_id;
- $params['toptab']='importexport';
- $params['user']=$user_id;
- /*
- Show horizontal links
- */
- site_user_header($params);
-}
+//$type = getStringFromRequest('type');
+//$id = getStringFromRequest('id');
- $user = session_get_user(); // get the session user
+ /**
+ * defaultView - Renders when plugin is accessed with no arguments.
+ *
+ */
+ function defaultView()
+ {
+ // TODO: Add the actions in a class to automate this.
+ echo '<br />';
+ echo '<h2>'._('Available Actions').'</h2>';
- if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
- exit_error("Invalid User", "Cannot Process your request for this user.");
+ echo '<h3>'._('Import').'</h3>';
+ echo '<ul>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=import_from_platform&',
+ _('[Import Data from a different platform.]')) ;
+ echo '</li>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=show_import_options',
+ _('[Show available data for import, from a specific project]')) ;
+ echo '</li>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=select_project_to_import_into',
+ _('[Select the projects to import into]')) ;
+ echo '</li>';
+ echo '</ul>';
+ echo '<br />';
+
+ echo '<h3>'._('Export').'</h3>';
+ echo '<ul>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=importData&',
+ _('[Export Data from a different platform.]')) ;
+ echo '</li>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=show_export_options',
+ _('[Show available data for export, from all projects]')) ;
+ echo '</li>';
+ echo '<li>';
+ echo util_make_link ('/plugins/importexport/?func=select_export',
+ _('[Select a project to export its data]')) ;
+ echo '</li>';
+ echo '</ul>';
+
}
- $type = getStringFromRequest('type');
- $id = getStringFromRequest('id');
- $pluginname = getStringFromRequest('pluginname');
+ function importData()
+ {
+ echo util_make_link ('/plugins/importexport/?func=import_project&label_id=',
+ _('[Import Data]')) ;
+ echo util_make_link ('/plugins/importexport/?func=export_project&project_id=',
+ _('[Export Data from a specific project]')) ;
+ }
- if (!$type) {
- exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
- } elseif (!$id) {
- exit_error("Cannot Process your request","No ID specified");
- } else {
- if ($type == 'group') {
- $group = group_get_object($id);
- if ( !$group) {
- exit_error("Invalid Project", "Inexistent Project");
- }
- if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
- }
- $userperm = $group->getPermission();//we'll check if the user belongs to the group (optional)
- if ( !$userperm->IsMember()) {
- exit_error("Access Denied", "You are not a member of this project");
- }
- // other perms checks here...
- importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
- // DO THE STUFF FOR THE PROJECT PART HERE
- echo "We are in the Project importexport plugin <br>";
- echo "Greetings from planet " . $world; // $world comes from the config file in /etc
- } elseif ($type == 'user') {
- $realuser = user_get_object($id);//
- if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
- exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
- }
- if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private importexport part of this user
- exit_error("Access Denied", "You cannot access other user's personal $pluginname");
- }
- importexport_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
- // DO THE STUFF FOR THE USER PART HERE
- echo "We are in the User importexport plugin <br>";
- echo "Greetings from planet " . $world; // $world comes from the config file in /etc
- } elseif ($type == 'admin') {
- $group = group_get_object($id);
- if ( !$group) {
- exit_error("Invalid Project", "Inexistent Project");
- }
- if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
- }
- $userperm = $group->getPermission();//we'll check if the user belongs to the group
- if ( !$userperm->IsMember()) {
- exit_error("Access Denied", "You are not a member of this project");
- }
- //only project admin can access here
- if ( $userperm->isAdmin() ) {
- importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
- // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
- echo "We are in the Project importexport plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
- echo "Greetings from planet " . $world; // $world comes from the config file in /etc
- } else {
- exit_error("Access Denied", "You are not a project Admin");
- }
- }
+ function import_from_platform()
+ {
+ echo '<h2>'._('Import Data From Another Platform').'</h2>';
+ ?>
+ <br />
+ <form name="importFromPlatform" method="post" enctype="multipart/form-data" action="<?php echo util_make_url ('/plugins/importexport/?import_from_paltform', _('Upload file')) ; ?>">
+ <p>
+ <?php echo _('Import from')._(': '); ?>
+
+ <select type=select name="import_from">
+ <option value="Platform1">
+ Platform 1
+ </option>
+ <option value="Platform2">
+ Platform 2
+ </option>
+ <option value="Platform3">
+ Platform 3
+ </option>
+ </select>
+ </p><p>
+ <?php echo _('Import into project')._(': '); ?>
+ <select type=select name="import_into">
+ <option value="Project1">
+ Project 1
+ </option>
+ <option value="Project2">
+ Project 2
+ </option>
+ <option value="Project3">
+ Project 3
+ </option>
+ </select>
+ </p><p>
+ <?php echo _('Select file to import from')._(': '); ?>
+ <input type="file" name="importfrom" size="chars">
+ </p>
+ <?php echo util_make_link ('/plugins/importexport/',
+ _('[Cancel]')) ; ?>
+ <input type="hidden" name="func" value="import">
+ <input type="submit" value="<?php echo _('Import') ?>">
+ <input type="hidden" value="<?php echo ''; ?>" name=label_id>
+ </form>
+ <?php
}
+ switch ($func) {
+ case 'import_from_platform':{
+ import_from_platform();
+ break;
+ }
+ case 'show_import_options':{
+
+ break;
+ }
+ case 'select_import':{
+
+ break;
+ }
+ case 'select_import':{
+
+ break;
+ }
+ case 'import_project':{
+
+ break;
+ }
+ default:{
+ defaultView();
+ break;
+ }
+ }
site_project_footer();
-
// Local Variables:
// mode: php
// c-file-style: "bsd"
commit a3f3422a648e04821c98fd30645bcd9def1176b4
Author: Dionysios Fryganas <dfryganas at gmail.com>
Date: Fri May 30 00:26:38 2014 +0200
Generated the plugin structure
diff --git a/src/plugins/importexport/NAME b/src/plugins/importexport/NAME
new file mode 100644
index 0000000..bf1a210
--- /dev/null
+++ b/src/plugins/importexport/NAME
@@ -0,0 +1 @@
+importexport
\ No newline at end of file
diff --git a/src/plugins/importexport/README b/src/plugins/importexport/README
new file mode 100644
index 0000000..81a06fd
--- /dev/null
+++ b/src/plugins/importexport/README
@@ -0,0 +1 @@
+importexport plugin
\ No newline at end of file
diff --git a/src/plugins/importexport/common/importexport-init.php b/src/plugins/importexport/common/importexport-init.php
new file mode 100644
index 0000000..b984ce8
--- /dev/null
+++ b/src/plugins/importexport/common/importexport-init.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ *
+ * 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.
+ */
+
+global $gfplugins;
+require_once $gfplugins.'importexport/include/importexportPlugin.class.php' ;
+
+$importexportPluginObject = new importexportPlugin ;
+
+register_plugin ($importexportPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
diff --git a/src/plugins/importexport/db/importexport-init.sql b/src/plugins/importexport/db/importexport-init.sql
new file mode 100644
index 0000000..d87f39a
--- /dev/null
+++ b/src/plugins/importexport/db/importexport-init.sql
@@ -0,0 +1,4 @@
+CREATE TABLE plugin_importexport_sample_data (
+ domain text,
+ ip_address text
+) ;
diff --git a/src/plugins/importexport/etc/importexport.ini b/src/plugins/importexport/etc/importexport.ini
new file mode 100644
index 0000000..03e1a15
--- /dev/null
+++ b/src/plugins/importexport/etc/importexport.ini
@@ -0,0 +1,7 @@
+[importexport]
+
+; plugin_status is a string.
+; valid means : production ready.
+; Any other strings means it's under work or broken and plugin
+; is available in installation_environment = development only.
+plugin_status = 'example only'
diff --git a/src/plugins/importexport/include/ImportExportPluginDescriptor.class.php b/src/plugins/importexport/include/ImportExportPluginDescriptor.class.php
new file mode 100644
index 0000000..2de3351
--- /dev/null
+++ b/src/plugins/importexport/include/ImportExportPluginDescriptor.class.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
+ *
+ * This file is a part of Codendi.
+ *
+ * Codendi 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.
+ *
+ * Codendi 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 Codendi. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Portions Copyright 2010 (c) Mélanie Le Bail
+ * Portions Copyright 2011 (c) France Telecom, Coclico project
+ */
+
+require_once 'common/plugin/PluginDescriptor.class.php';
+
+class importexportPluginDescriptor extends PluginDescriptor {
+
+ function importexportPluginDescriptor() {
+ $this->PluginDescriptor(_('importexport'), 'v1.0', _('importexport integration in the forge'));
+ }
+}
diff --git a/src/plugins/importexport/include/ImportExportPluginInfo.class.php b/src/plugins/importexport/include/ImportExportPluginInfo.class.php
new file mode 100644
index 0000000..d88f046
--- /dev/null
+++ b/src/plugins/importexport/include/ImportExportPluginInfo.class.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
+ *
+ * This file is a part of Codendi.
+ *
+ * Codendi 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.
+ *
+ * Codendi 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 Codendi. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2010 (c) Mélanie Le Bail
+ * Copyright 2011 (c) France Telecom, Coclico project
+ */
+require_once 'common/plugin/PluginInfo.class.php';
+require_once 'importexportPluginDescriptor.class.php';
+
+class importexportPluginInfo extends PluginInfo {
+
+ function importexportPluginInfo(&$plugin) {
+ $this->PluginInfo($plugin);
+ $this->setPluginDescriptor(new importexportPluginDescriptor());
+ }
+
+}
diff --git a/src/plugins/importexport/include/importexportPlugin.class.php b/src/plugins/importexport/include/importexportPlugin.class.php
new file mode 100644
index 0000000..d45b2cd
--- /dev/null
+++ b/src/plugins/importexport/include/importexportPlugin.class.php
@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * importexportPlugin Class
+ *
+ *
+ * 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.
+ */
+
+class importexportPlugin extends Plugin {
+ public function __construct($id=0) {
+ $this->Plugin($id) ;
+ $this->name = "importexport";
+ $this->text = "importexport!"; // To show in the tabs, use...
+ $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
+ $this->_addHook("usermenu");
+ $this->_addHook("groupmenu"); // To put into the project tabs
+ $this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
+ $this->_addHook("groupisactivecheckboxpost"); //
+ $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
+ $this->_addHook("userisactivecheckboxpost"); //
+ $this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
+ }
+
+ function CallHook ($hookname, &$params) {
+ global $use_importexportplugin,$G_SESSION,$HTML;
+ if ($hookname == "usermenu") {
+ $text = $this->text; // this is what shows in the tab
+ if ($G_SESSION->usesPlugin("importexport")) {
+ $param = '?type=user&id=' . $G_SESSION->getId() . '&pluginname=' . $this->name; // we indicate the part we're calling is the user one
+ echo $HTML->PrintSubMenu (array ($text),
+ array ('/plugins/importexport/index.php' . $param ));
+
+ }
+ } elseif ($hookname == "groupmenu") {
+ $group_id=$params['group'];
+ $project = group_get_object($group_id);
+ if (!$project || !is_object($project)) {
+ return;
+ }
+ if ($project->isError()) {
+ return;
+ }
+ if (!$project->isProject()) {
+ return;
+ }
+ if ( $project->usesPlugin ( $this->name ) ) {
+ $params['TITLES'][]=$this->text;
+ $params['DIRS'][]=util_make_url ('/plugins/importexport/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name) ; // we indicate the part we're calling is the project one
+ } else {
+ $params['TITLES'][]=$this->text." is [Off]";
+ $params['DIRS'][]='';
+ }
+ (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
+ } elseif ($hookname == "groupisactivecheckbox") {
+ //Check if the group is active
+ // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
+ $group_id=$params['group'];
+ $group = group_get_object($group_id);
+ echo "<tr>";
+ echo "<td>";
+ echo ' <input type="checkbox" name="use_importexportplugin" value="1" ';
+ // checked or unchecked?
+ if ( $group->usesPlugin ( $this->name ) ) {
+ echo "checked";
+ }
+ echo " /><br/>";
+ echo "</td>";
+ echo "<td>";
+ echo "<strong>Use ".$this->text." Plugin</strong>";
+ echo "</td>";
+ echo "</tr>";
+ } elseif ($hookname == "groupisactivecheckboxpost") {
+ // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
+ $group_id=$params['group'];
+ $group = group_get_object($group_id);
+ $use_importexportplugin = getStringFromRequest('use_importexportplugin');
+ if ( $use_importexportplugin == 1 ) {
+ $group->setPluginUse ( $this->name );
+ } else {
+ $group->setPluginUse ( $this->name, false );
+ }
+ } elseif ($hookname == "user_personal_links") {
+ // this displays the link in the user's profile page to it's personal importexport (if you want other sto access it, youll have to change the permissions in the index.php
+ $userid = $params['user_id'];
+ $user = user_get_object($userid);
+ $text = $params['text'];
+ //check if the user has the plugin activated
+ if ($user->usesPlugin($this->name)) {
+ echo ' <p>' ;
+ echo util_make_link ("/plugins/importexport/index.php?id=$userid&type=user&pluginname=".$this->name,
+ _('View Personal importexport')
+ );
+ echo '</p>';
+ }
+ } elseif ($hookname == "project_admin_plugins") {
+ // this displays the link in the project admin options page to it's importexport administration
+ $group_id = $params['group_id'];
+ $group = group_get_object($group_id);
+ if ( $group->usesPlugin ( $this->name ) ) {
+ echo '<p>'.util_make_link ("/plugins/importexport/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
+ _('importexport Admin')).'</p>' ;
+ }
+ }
+ elseif ($hookname == "blahblahblah") {
+ // ...
+ }
+ }
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
diff --git a/src/plugins/importexport/packaging/control/456plugin-importexport b/src/plugins/importexport/packaging/control/456plugin-importexport
new file mode 100644
index 0000000..6baa975
--- /dev/null
+++ b/src/plugins/importexport/packaging/control/456plugin-importexport
@@ -0,0 +1,7 @@
+Package: @PACKAGE at -plugin-importexport
+Architecture: all
+Depends: @OLDPACKAGE at -common, @OLDPACKAGE at -db-postgresql | @OLDPACKAGE at -db, @OLDPACKAGE at -web-apache2 | @OLDPACKAGE at -web, @OLDPACKAGE at -shell-postgresql | @OLDPACKAGE at -shell, php5-cli, ${misc:Depends}
+Provides: @OLDPACKAGE at -plugin-importexport
+Conflicts: @OLDPACKAGE at -plugin-importexport
+Replaces: @OLDPACKAGE at -plugin-importexport
+Description: Allows interoperability of the forge data - Import Export plugin
diff --git a/src/plugins/importexport/packaging/control/456plugin-importexport.shortdesc b/src/plugins/importexport/packaging/control/456plugin-importexport.shortdesc
new file mode 100644
index 0000000..61254f0
--- /dev/null
+++ b/src/plugins/importexport/packaging/control/456plugin-importexport.shortdesc
@@ -0,0 +1,4 @@
+This is an import export plugin for the FusionForge platform.
+It enables interopreability and enables the export of a project
+data in various formats. It also enables the import of data exported
+from other platforms.
diff --git a/src/plugins/importexport/packaging/dirs/plugin-importexport b/src/plugins/importexport/packaging/dirs/plugin-importexport
new file mode 100644
index 0000000..1c36889
--- /dev/null
+++ b/src/plugins/importexport/packaging/dirs/plugin-importexport
@@ -0,0 +1,2 @@
+ at PLUGIN_PATH@/importexport/common
+ at PLUGIN_PATH@/importexport/www
diff --git a/src/plugins/importexport/packaging/install/plugin-importexport b/src/plugins/importexport/packaging/install/plugin-importexport
new file mode 100644
index 0000000..0ffb93b
--- /dev/null
+++ b/src/plugins/importexport/packaging/install/plugin-importexport
@@ -0,0 +1,4 @@
+plugins/importexport/common/* @PLUGIN_PATH@/scmgit/common/
+plugins/importexport/www/* @PLUGIN_PATH@/scmgit/www/
+plugins/importexport/db/* @PLUGIN_PATH@/scmgit/db/
+plugins/importexport/etc/*.ini etc/@PACKAGE@/config.ini.d/
diff --git a/src/plugins/importexport/packaging/links/plugin-importexport b/src/plugins/importexport/packaging/links/plugin-importexport
new file mode 100644
index 0000000..e69de29
diff --git a/src/plugins/importexport/www/admin/index.php b/src/plugins/importexport/www/admin/index.php
new file mode 100644
index 0000000..363ba27
--- /dev/null
+++ b/src/plugins/importexport/www/admin/index.php
@@ -0,0 +1,110 @@
+<?php
+
+/*
+ * importexport plugin
+ *
+ * Daniel Perez <danielperez.arg at gmail.com>
+ *
+ * This is an example to watch things in action. You can obviously modify things and logic as you see fit
+ */
+
+require_once '../../../env.inc.php';
+require_once $gfwww.'include/pre.php';
+require_once $gfconfig.'plugins/importexport/config.php';
+
+// the header that displays for the user portion of the plugin
+function importexport_Project_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$id;
+ $params['toptab']='importexport';
+ $params['group']=$id;
+ /*
+ Show horizontal links
+ */
+ site_project_header($params);
+}
+
+// the header that displays for the project portion of the plugin
+function importexport_User_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$user_id;
+ $params['toptab']='importexport';
+ $params['user']=$user_id;
+ /*
+ Show horizontal links
+ */
+ site_user_header($params);
+}
+
+ $user = session_get_user(); // get the session user
+
+ if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+ exit_error("Invalid User", "Cannot Process your request for this user.");
+ }
+
+ $type = getStringFromRequest('type');
+ $id = getStringFromRequest('id');
+ $pluginname = getStringFromRequest('pluginname');
+
+ if (!$type) {
+ exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
+ } elseif (!$id) {
+ exit_error("Cannot Process your request","No ID specified");
+ } else {
+ if ($type == 'group') {
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", "Inexistent Project");
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission();//we'll check if the user belongs to the group (optional)
+ if ( !$userperm->IsMember()) {
+ exit_error("Access Denied", "You are not a member of this project");
+ }
+ // other perms checks here...
+ importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ // DO THE STUFF FOR THE PROJECT PART HERE
+ echo "We are in the Project importexport plugin <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } elseif ($type == 'user') {
+ $realuser = user_get_object($id);//
+ if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+ exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
+ }
+ if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private importexport part of this user
+ exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+ }
+ importexport_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+ // DO THE STUFF FOR THE USER PART HERE
+ echo "We are in the User importexport plugin <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } elseif ($type == 'admin') {
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", "Inexistent Project");
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission();//we'll check if the user belongs to the group
+ if ( !$userperm->IsMember()) {
+ exit_error("Access Denied", "You are not a member of this project");
+ }
+ //only project admin can access here
+ if ( $userperm->isAdmin() ) {
+ importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+ echo "We are in the Project importexport plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } else {
+ exit_error("Access Denied", "You are not a project Admin");
+ }
+ }
+ }
+
+ site_project_footer();
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
diff --git a/src/plugins/importexport/www/index.php b/src/plugins/importexport/www/index.php
new file mode 100644
index 0000000..cdd9bf0
--- /dev/null
+++ b/src/plugins/importexport/www/index.php
@@ -0,0 +1,110 @@
+<?php
+
+/*
+ * importexport plugin
+ *
+ * Daniel Perez <danielperez.arg at gmail.com>
+ *
+ * This is an example to watch things in action. You can obviously modify things and logic as you see fit
+ */
+
+require_once '../../env.inc.php';
+require_once $gfwww.'include/pre.php';
+require_once $gfconfig.'plugins/importexport/config.php';
+
+// the header that displays for the user portion of the plugin
+function importexport_Project_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$id;
+ $params['toptab']='importexport';
+ $params['group']=$id;
+ /*
+ Show horizontal links
+ */
+ site_project_header($params);
+}
+
+// the header that displays for the project portion of the plugin
+function importexport_User_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$user_id;
+ $params['toptab']='importexport';
+ $params['user']=$user_id;
+ /*
+ Show horizontal links
+ */
+ site_user_header($params);
+}
+
+ $user = session_get_user(); // get the session user
+
+ if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+ exit_error("Invalid User", "Cannot Process your request for this user.");
+ }
+
+ $type = getStringFromRequest('type');
+ $id = getStringFromRequest('id');
+ $pluginname = getStringFromRequest('pluginname');
+
+ if (!$type) {
+ exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
+ } elseif (!$id) {
+ exit_error("Cannot Process your request","No ID specified");
+ } else {
+ if ($type == 'group') {
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", "Inexistent Project");
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission();//we'll check if the user belongs to the group (optional)
+ if ( !$userperm->IsMember()) {
+ exit_error("Access Denied", "You are not a member of this project");
+ }
+ // other perms checks here...
+ importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ // DO THE STUFF FOR THE PROJECT PART HERE
+ echo "We are in the Project importexport plugin <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } elseif ($type == 'user') {
+ $realuser = user_get_object($id);//
+ if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+ exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
+ }
+ if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private importexport part of this user
+ exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+ }
+ importexport_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+ // DO THE STUFF FOR THE USER PART HERE
+ echo "We are in the User importexport plugin <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } elseif ($type == 'admin') {
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", "Inexistent Project");
+ }
+ if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the importexport plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission();//we'll check if the user belongs to the group
+ if ( !$userperm->IsMember()) {
+ exit_error("Access Denied", "You are not a member of this project");
+ }
+ //only project admin can access here
+ if ( $userperm->isAdmin() ) {
+ importexport_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+ echo "We are in the Project importexport plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
+ echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+ } else {
+ exit_error("Access Denied", "You are not a project Admin");
+ }
+ }
+ }
+
+ site_project_footer();
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
-----------------------------------------------------------------------
hooks/post-receive
--
FusionForge
More information about the Fusionforge-commits
mailing list