[Fusionforge-commits] r14369 - trunk/src/plugins/extsubproj/include

Olivier Berger olberger at fusionforge.org
Wed Sep 14 14:00:52 CEST 2011


Author: olberger
Date: 2011-09-14 14:00:52 +0200 (Wed, 14 Sep 2011)
New Revision: 14369

Added:
   trunk/src/plugins/extsubproj/include/extsubproj_Widget_SubProjects.class.php
Modified:
   trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php
Log:
Initial support for a new widget

Modified: trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php
===================================================================
--- trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php	2011-09-14 12:00:45 UTC (rev 14368)
+++ trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php	2011-09-14 12:00:52 UTC (rev 14369)
@@ -38,6 +38,8 @@
 		$this->_addHook("groupisactivecheckboxpost"); //
 		$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
 		$this->_addHook('site_admin_option_hook');  // to provide a link to the site wide administrative pages of plugin
+		$this->_addHook('widget_instance'); // creates widgets when requested
+		$this->_addHook('widgets'); // declares which widgets are provided by the plugin
 	}
 
 	function site_admin_option_hook(&$params) {
@@ -218,6 +220,35 @@
 	}
 	
 	/**
+	* widgets - 'widgets' hook handler
+	* @param array $params
+	* @return boolean
+	*/
+	function widgets($params) {
+		require_once('common/widget/WidgetLayoutManager.class.php');
+		if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_GROUP) {
+			$params['fusionforge_widgets'][] = 'plugin_extsubproj_project_subprojects';
+		}/*
+		if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USER) {
+			$params['fusionforge_widgets'][] = 'plugin_scmgit_user_myrepositories';
+		}*/
+		return true;
+	}
+	
+	/**
+	 * Process the 'widget_instance' hook to create instances of the widgets
+	 * @param array $params
+	 */
+	function widget_instance($params) {
+		global $gfplugins;
+		//$user = UserManager::instance()->getCurrentUser();
+		require_once('common/widget/WidgetLayoutManager.class.php');
+		if ($params['widget'] == 'plugin_extsubproj_project_subprojects') {
+			require_once $gfplugins.$this->name.'/include/extsubproj_Widget_SubProjects.class.php';
+			$params['instance'] = new extsubproj_Widget_SubProjects(WidgetLayoutManager::OWNER_TYPE_GROUP);
+		}
+	}
+	/**
 	* getConf - return the configuration defined at project level
 	*
 	* @param	integer	the group id

Added: trunk/src/plugins/extsubproj/include/extsubproj_Widget_SubProjects.class.php
===================================================================
--- trunk/src/plugins/extsubproj/include/extsubproj_Widget_SubProjects.class.php	                        (rev 0)
+++ trunk/src/plugins/extsubproj/include/extsubproj_Widget_SubProjects.class.php	2011-09-14 12:00:52 UTC (rev 14369)
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Copyright 2011, Franck Villaume - Capgemini
+ * http://fusionforge.org
+ *
+ * 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 Licence, 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+require_once('common/widget/Widget.class.php');
+require_once('common/widget/WidgetLayoutManager.class.php');
+
+class extsubproj_Widget_SubProjects extends Widget {
+	function extsubproj_Widget_SubProjects($owner_type) {
+		$this->Widget('plugin_extsubproj_project_subprojects');
+	}
+
+	function getTitle() {
+		return _("Project external subprojects");
+	}
+
+	function getCategory() {
+		return _('Plugin (project)');
+	}
+
+	function getDescription() {
+		return _("Displays links to external subprojects of the project");
+	}
+
+	function getContent() {
+		/*
+		$user = UserManager::instance()->getCurrentUser();
+		$scmgitplugin = plugin_get_object('scmgit');
+		$GitRepositories = $this->getMyRepositoriesList();
+		if (count($GitRepositories)) {
+			$returnhtml = '<table>';
+			foreach ($GitRepositories as $GitRepository) {
+				$project = group_get_object($GitRepository);
+				$returnhtml .= '<tr><td><tt>git clone git+ssh://'.$user->getUnixName().'@' . $scmgitplugin->getBoxForProject($project) . forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/users/'. $user->getUnixName() .'.git</tt></p></td><tr>';
+			}
+			$returnhtml .= '</table>';
+			return $returnhtml;
+		} else {
+			return '<p class="information">'._('No personal git repository').'</p>';
+		}
+		*/
+		return 'COIN!';
+	}
+/*
+	function getMyRepositoriesList() {
+		$returnedArray = array();
+		$res = db_query_params('SELECT p.group_id FROM plugin_scmgit_personal_repos p, users u WHERE u.user_id=p.user_id AND u.unix_status = $1 AND u.user_id = $2',
+					array('A',$this->owner_id));
+		if (!$res) {
+			return $returnedArray;
+		} else {
+			$rows = db_numrows($res);
+			for ($i=0; $i<$rows; $i++) {
+				$returnedArray[] = db_result($res,$i,'group_id');
+			}
+		}
+		return $returnedArray;
+	}
+	*/
+}
+
+?>




More information about the Fusionforge-commits mailing list