[Fusionforge-commits] r9422 - in trunk/plugins/templates/helloworld: . common include

Christian Bayle cbayle at libremir.placard.fr.eu.org
Wed Apr 7 17:34:51 CEST 2010


Author: cbayle
Date: 2010-04-07 17:34:50 +0200 (Wed, 07 Apr 2010)
New Revision: 9422

Added:
   trunk/plugins/templates/helloworld/include/
   trunk/plugins/templates/helloworld/include/helloworldPlugin.class.php
Removed:
   trunk/plugins/templates/helloworld/common/HelloWorldPlugin.class.php
Modified:
   trunk/plugins/templates/helloworld/common/helloworld-init.php
Log:
Make template more 'codendi' portable


Deleted: trunk/plugins/templates/helloworld/common/HelloWorldPlugin.class.php
===================================================================
--- trunk/plugins/templates/helloworld/common/HelloWorldPlugin.class.php	2010-04-07 15:34:46 UTC (rev 9421)
+++ trunk/plugins/templates/helloworld/common/HelloWorldPlugin.class.php	2010-04-07 15:34:50 UTC (rev 9422)
@@ -1,163 +0,0 @@
-<?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 = "HelloWorld!" ; // 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;
-		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") {
-			$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/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['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_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_id=$params['group'];
-			$group = &group_get_object($group_id);
-			$use_helloworldplugin = 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_helloworldplugin = getStringFromRequest('use_helloworldplugin');
-			if ( $use_helloworldplugin == 1 ) {
-				$user->setPluginUse ( $this->name );
-			} else {
-				$user->setPluginUse ( $this->name, false );
-			}
-			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 == "user_personal_links") {
-			// 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>' ;
-				echo util_make_link ("/plugins/helloworld/index.php?id=$userid&type=user&pluginname=".$this->name,
-						     _('View Personal HelloWorld')
-					);
-				echo '</p>';
-			}
-		} elseif ($hookname == "project_admin_plugins") {
-			// 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 util_make_link ("/plugins/projects_hierarchy/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
-						     _('View the HelloWorld Administration')) ;
-				echo '</p>';
-			}
-		}												    
-		elseif ($hookname == "blahblahblah") {
-			// ...
-		} 
-	}
-}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
-
-?>

Modified: trunk/plugins/templates/helloworld/common/helloworld-init.php
===================================================================
--- trunk/plugins/templates/helloworld/common/helloworld-init.php	2010-04-07 15:34:46 UTC (rev 9421)
+++ trunk/plugins/templates/helloworld/common/helloworld-init.php	2010-04-07 15:34:50 UTC (rev 9422)
@@ -20,11 +20,11 @@
  */
 
 global $gfplugins;
-require_once $gfplugins.'helloworld/common/HelloWorldPlugin.class.php' ;
+require_once $gfplugins.'helloworld/include/helloworldPlugin.class.php' ;
 
-$HelloWorldPluginObject = new HelloWorldPlugin ;
+$helloworldPluginObject = new helloworldPlugin ;
 
-register_plugin ($HelloWorldPluginObject) ;
+register_plugin ($helloworldPluginObject) ;
 
 // Local Variables:
 // mode: php

Copied: trunk/plugins/templates/helloworld/include/helloworldPlugin.class.php (from rev 9421, trunk/plugins/templates/helloworld/common/HelloWorldPlugin.class.php)
===================================================================
--- trunk/plugins/templates/helloworld/include/helloworldPlugin.class.php	                        (rev 0)
+++ trunk/plugins/templates/helloworld/include/helloworldPlugin.class.php	2010-04-07 15:34:50 UTC (rev 9422)
@@ -0,0 +1,163 @@
+<?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 = "HelloWorld!" ; // 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;
+		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") {
+			$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/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['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_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_id=$params['group'];
+			$group = &group_get_object($group_id);
+			$use_helloworldplugin = 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_helloworldplugin = getStringFromRequest('use_helloworldplugin');
+			if ( $use_helloworldplugin == 1 ) {
+				$user->setPluginUse ( $this->name );
+			} else {
+				$user->setPluginUse ( $this->name, false );
+			}
+			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 == "user_personal_links") {
+			// 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>' ;
+				echo util_make_link ("/plugins/helloworld/index.php?id=$userid&type=user&pluginname=".$this->name,
+						     _('View Personal HelloWorld')
+					);
+				echo '</p>';
+			}
+		} elseif ($hookname == "project_admin_plugins") {
+			// 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 util_make_link ("/plugins/projects_hierarchy/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
+						     _('View the HelloWorld Administration')) ;
+				echo '</p>';
+			}
+		}												    
+		elseif ($hookname == "blahblahblah") {
+			// ...
+		} 
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>




More information about the Fusionforge-commits mailing list