[evolvis-commits] r11393: Initial revision↵
mirabilos at evolvis.org
mirabilos at evolvis.org
Thu Feb 24 18:09:14 CET 2011
Author: mirabilos
Date: 2011-02-24 18:09:14 +0100 (Thu, 24 Feb 2011)
New Revision: 11393
Added:
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/INSTALL
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/bin/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/bin/sayhello
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/HelloWorldPlugin.class
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/helloworld-init.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/languages/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/languages/Base.tab
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/db/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/db/helloworld-init.sql
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/helloworld/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/helloworld/config.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/httpd.conf
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/www/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/www/index.php
Log:
Initial revision
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/INSTALL
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/INSTALL (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/INSTALL 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,17 @@
+0. INSTALLATION of Helloworld Plugin
+
+i.e. : if the directory where the plugins are is /srv/www/gforge/plugins you should end up
+ with /srv/www/gforge/plugins/helloworld and all the files in it
+
+1. CONFIGURATION
+
+A) Make the symbolic links for each section
+
+(this is just an example, you should change the variables for what you have on your installation)
+
+/$GFORGEDIR/www/plugins/helloworld -> /$GFORGEPLUGINSDIR/helloworld/www
+/$ETC/gforge -> /$GFORGEPLUGINSDIR/helloworld/etc/plugins/helloworld
+
+B) Run the db/helloworld-init.sql file
+
+psql -U gforge gforge < db/helloworld-init.sql
\ No newline at end of file
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/bin/sayhello
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/bin/sayhello (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/bin/sayhello 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,9 @@
+#! /usr/bin/perl -w
+
+my $world ;
+
+do "/etc/gforge/plugins/helloworld/world.conf"
+ or die "Cannot read /etc/gforge/plugins/helloworld/world.conf" ;
+
+print STDOUT "Hello $world on STDOUT!\n" ;
+print STDERR "Hello $world on STDERR!\n" ;
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/HelloWorldPlugin.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/HelloWorldPlugin.class (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/HelloWorldPlugin.class 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,157 @@
+<?php
+
+/**
+ * HelloWorldPlugin Class
+ *
+ *
+ * This file is part of GForge.
+ *
+ * GForge 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.
+ *
+ * GForge 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 GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class HelloWorldPlugin extends Plugin {
+ function HelloWorldPlugin () {
+ $this->Plugin() ;
+ $this->name = "helloworld" ;
+ $this->text = "Hello World!" ; // To show in the tabs, use...
+ $this->hooks[] = "user_personal_links";//to make a link to the user´s personal part of the plugin
+ $this->hooks[] = "usermenu" ;
+ $this->hooks[] = "groupmenu" ; // To put into the project tabs
+ $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
+ $this->hooks[] = "groupisactivecheckboxpost" ; //
+ $this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
+ $this->hooks[] = "userisactivecheckboxpost" ; //
+ $this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
+ }
+
+ function CallHook ($hookname, $params) {
+ global $use_helloworldplugin,$G_SESSION,$HTML;
+ $group_id=$params['group'];
+ if ($hookname == "usermenu") {
+ $text = $this->text; // this is what shows in the tab
+ if ($G_SESSION->usesPlugin("helloworld")) {
+ $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/helloworld/index.php' . $param ));
+ }
+ } elseif ($hookname == "groupmenu") {
+ $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'][]='/plugins/helloworld/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['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 = &group_get_object($group_id);
+ echo "<tr>";
+ echo "<td>";
+ echo ' <input type="CHECKBOX" name="use_helloworldplugin" 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 = &group_get_object($group_id);
+ $use_hellowordplugin = getStringFromRequest('use_helloworldplugin');
+ if ( $use_helloworldplugin == 1 ) {
+ $group->setPluginUse ( $this->name );
+ } else {
+ $group->setPluginUse ( $this->name, false );
+ }
+ } elseif ($hookname == "userisactivecheckbox") {
+ //check if user is active
+ // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
+ $user = $params['user'];
+ echo "<tr>";
+ echo "<td>";
+ echo ' <input type="CHECKBOX" name="use_helloworldplugin" value="1" ';
+ // CHECKED OR UNCHECKED?
+ if ( $user->usesPlugin ( $this->name ) ) {
+ echo "CHECKED";
+ }
+ echo "> Use ".$this->text." Plugin";
+ echo "</td>";
+ echo "</tr>";
+ } elseif ($hookname == "userisactivecheckboxpost") {
+ // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
+ $user = $params['user'];
+ $use_hellowordplugin = getStringFromRequest('use_helloworldplugin');
+ if ( $use_hellowordplugin == 1 ) {
+ $user->setPluginUse ( $this->name );
+ } else {
+ $user->setPluginUse ( $this->name, false );
+ }
+ echo "<tr>";
+ echo "<td>";
+ echo ' <input type="CHECKBOX" name="use_hellowordplugin" value="1" ';
+ // CHECKED OR UNCHECKED?
+ if ( $user->usesPlugin ( $this->name ) ) {
+ echo "CHECKED";
+ }
+ echo "> Use ".$this->text." Plugin";
+ echo "</td>";
+ echo "</tr>";
+ } elseif ($hookname == "user_personal_links") {
+ global $Language;
+ // this displays the link in the user´s profile page to it´s personal HelloWorld (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>
+ <a href="/plugins/helloworld/index.php?id=' . $userid . '&type=user&pluginname=' . $this->name . '">' . $Language->getText('user_home','view_helloworld') .'</a></p>';
+ }
+ } elseif ($hookname == "project_admin_plugins") {
+ global $Language;
+ // this displays the link in the project admin options page to it´s HelloWorld administration
+ $group_id = $params['group_id'];
+ $group = &group_get_object($group_id);
+ if ( $group->usesPlugin ( $this->name ) ) {
+ echo '<a href="/plugins/helloworld/index.php?id=' . $group->getID() . '&type=admin&pluginname=' . $this->name . '">' . $Language->getText('project_admin','helloworld') . '</a><br />';
+ }
+ }
+ elseif ($hookname == "blahblahblah") {
+ // ...
+ }
+ }
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/helloworld-init.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/helloworld-init.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/helloworld-init.php 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ *
+ * This file is part of GForge.
+ *
+ * GForge 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.
+ *
+ * GForge 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 GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+require_once ('HelloWorldPlugin.class') ;
+
+$HelloWorldPluginObject = new HelloWorldPlugin ;
+
+register_plugin ($HelloWorldPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/languages/Base.tab
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/languages/Base.tab (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/common/languages/Base.tab 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,14 @@
+#/**
+# *
+# * HelloWorld message catalog (English)
+# *
+# * GForge: Breaking Down the Barriers to Open Source Development
+# * Copyright 1999-2001 (c) VA Linux Systems
+# * 2005 (c) Daniel Pérez <danielperez.arg at gmail.com>
+# * http://sourceforge.net
+# * Here you can add your own language customizations
+# *
+# *
+# */
+user_home view_helloworld View Personal HelloWorld
+project_admin helloworld View the HelloWorld Administration
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/db/helloworld-init.sql
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/db/helloworld-init.sql (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/db/helloworld-init.sql 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,6 @@
+CREATE TABLE plugin_helloworld_sample_data (
+ domain text,
+ ip_address text
+) ;
+
+INSERT INTO plugins (plugin_name,plugin_desc) VALUES ('helloworld','HelloWorld GForge Plugin');
\ No newline at end of file
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/helloworld/config.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/helloworld/config.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/etc/plugins/helloworld/config.php 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,7 @@
+<?php
+
+// here you can put all your configuration variables
+
+$world = 'Earth';
+
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/httpd.conf
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/httpd.conf (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/httpd.conf 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,4 @@
+<Location /plugins/helloworld/>
+ SetEnv PLUGINNAME helloworld
+ SetEnv PLUGINVERSION 0.1-1
+</Location>
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/www/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/www/index.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-helloworld2/www/index.php 2011-02-24 17:09:14 UTC (rev 11393)
@@ -0,0 +1,107 @@
+<?php
+
+/*
+ * Hello world plugin 2
+ *
+ * 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('pre.php');
+require_once ('plugins/helloworld/config.php');
+
+// the header that displays for the user portion of the plugin
+function helloworld_Project_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$id,$Language;
+ $params['toptab']='HelloWorld';
+ $params['group']=$id;
+ /*
+ Show horizontal links
+ */
+ site_project_header($params);
+}
+
+// the header that displays for the project portion of the plugin
+function helloworld_User_Header($params) {
+ global $DOCUMENT_ROOT,$HTML,$user_id,$Language;
+ $params['toptab']='HelloWorld';
+ $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 HelloWorld plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission($user);//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...
+ helloworld_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 Helloworld 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 HelloWorld part of this user
+ exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+ }
+ helloworld_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 Helloworld 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 HelloWorld plugin active
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ }
+ $userperm = $group->getPermission($user);//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() ) {
+ helloworld_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 Helloworld 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(array());
+
+?>
More information about the evolvis-commits
mailing list