[Fusionforge-commits] r12906 - in trunk/src/plugins: . message message/common message/db message/www message/www/js

Alain Peyrat aljeux at fusionforge.org
Fri Mar 25 11:51:38 CET 2011


Author: aljeux
Date: 2011-03-25 11:51:38 +0100 (Fri, 25 Mar 2011)
New Revision: 12906

Added:
   trunk/src/plugins/message/
   trunk/src/plugins/message/common/
   trunk/src/plugins/message/common/messagePlugin.class.php
   trunk/src/plugins/message/db/
   trunk/src/plugins/message/db/message-init.sql
   trunk/src/plugins/message/www/
   trunk/src/plugins/message/www/index.php
   trunk/src/plugins/message/www/js/
   trunk/src/plugins/message/www/js/message.js
Log:
Initial code for the message plugin (global message displayed)

Added: trunk/src/plugins/message/common/messagePlugin.class.php
===================================================================
--- trunk/src/plugins/message/common/messagePlugin.class.php	                        (rev 0)
+++ trunk/src/plugins/message/common/messagePlugin.class.php	2011-03-25 10:51:38 UTC (rev 12906)
@@ -0,0 +1,64 @@
+<?php
+/**
+ * GForge Plugin SVNHudson Class
+ *
+ * Copyright 2009 (c) Alain Peyrat <alain.peyrat at alcatel-lucent.com>
+ *
+ * This file is part of GForge-plugin-svnhudson
+ *
+ * GForge-plugin-svnhudson 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-plugin-svnhudson 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-plugin-svnhudson; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
+ *
+ */
+/**
+ * The svnhudsonPlugin class. It implements the Hooks for the presentation
+ *  of table in hudson and task in detailed mode.
+ *
+ */
+
+class messagePlugin extends Plugin {
+
+	function messagePlugin () {
+		$this->Plugin() ;
+		$this->name = "message" ;
+		$this->text = _('Message');
+		$this->hooks[] = 'message';
+		$this->hooks[] = 'htmlhead';
+		$this->hooks[] = 'site_admin_option_hook';
+	}
+
+	function htmlhead() {
+		use_javascript('/scripts/jquery/jquery-1.4.2.min.js');
+		use_javascript('/plugins/message/js/message.js');
+	}
+	
+	function site_admin_option_hook() {
+		echo '<li>' . util_make_link ('/plugins/message/index.php', _('Configure Global Message')) . '</li>';
+	}
+
+	function message() {
+		$res = db_query_params('SELECT message FROM plugin_message', array());
+		if ($res && db_numrows($res)>0) {
+			echo '<div id="message_box">';
+			echo '<img id="message_close" style="float:right;cursor:pointer"  src="/themes/acos/images/ic/close.png" />';
+			echo db_result($res, 0, 'message');
+			echo '</div>';
+		}
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:

Added: trunk/src/plugins/message/db/message-init.sql
===================================================================
--- trunk/src/plugins/message/db/message-init.sql	                        (rev 0)
+++ trunk/src/plugins/message/db/message-init.sql	2011-03-25 10:51:38 UTC (rev 12906)
@@ -0,0 +1,3 @@
+CREATE TABLE plugin_message (
+	"message" text
+);

Added: trunk/src/plugins/message/www/index.php
===================================================================
--- trunk/src/plugins/message/www/index.php	                        (rev 0)
+++ trunk/src/plugins/message/www/index.php	2011-03-25 10:51:38 UTC (rev 12906)
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Copyright (C) 2011 Alain Peyrat, Alcatel-Lucent
+ *
+ * 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 FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+/*
+ * Standard Alcatel-Lucent disclaimer for contributing to open source
+ *
+ * "The provided file ("Contribution") has not been tested and/or
+ * validated for release as or in products, combinations with products or
+ * other commercial use. Any use of the Contribution is entirely made at
+ * the user's own responsibility and the user can not rely on any features,
+ * functionalities or performances Alcatel-Lucent has attributed to the
+ * Contribution.
+ *
+ * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
+ * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
+ * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
+ * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
+ * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
+ * ALONE BASIS."
+ */
+
+require_once dirname(__FILE__)."/../../env.inc.php";
+require_once $gfcommon.'include/pre.php';
+require_once $gfwww.'admin/admin_utils.php';
+
+$message= getStringFromRequest('body');
+if ($message) {
+	$res = db_query_params('SELECT message FROM plugin_message', array());
+	if (!$res || db_numrows($res)==0) {
+		db_query_params('INSERT INTO plugin_message (message) VALUES ($1)', array($message));
+	} else {
+		db_query_params('UPDATE plugin_message SET message=$1', array($message));
+	}
+} else {
+	$res = db_query_params('SELECT message FROM plugin_message', array());
+	if ($res && db_numrows($res)>0) {
+		$message = db_result($res, 0, 'message');
+	}
+}
+
+site_admin_header($params);														
+
+print _("Edit the message as you want. If you activate the HTML editor, you will be able to use WYSIWYG formatting (bold, colors...)");
+
+print "<p/><center>";
+print "<form action=\"/plugins/message/\" method=\"post\">";
+
+$params['body'] = $message;
+$params['width'] = "800";
+$params['height'] = "300";
+$params['group'] = $id;
+$params['content'] = '<textarea name="body"  rows="20" cols="80">'.$message.'</textarea>';
+plugin_hook_by_reference("text_editor", $params);
+echo $params['content'];
+
+print "<br /><br /><input type=\"submit\" value=\"" ._("Save") ."\" />";
+print "</form>";
+print "</center>";
+
+site_admin_footer($params);														

Added: trunk/src/plugins/message/www/js/message.js
===================================================================
--- trunk/src/plugins/message/www/js/message.js	                        (rev 0)
+++ trunk/src/plugins/message/www/js/message.js	2011-03-25 10:51:38 UTC (rev 12906)
@@ -0,0 +1,61 @@
+jQuery.cookie = function(name, value, options) {
+    if (typeof value != 'undefined') { // name and value given, set cookie
+        options = options || {};
+        if (value === null) {
+            value = '';
+            options.expires = -1;
+        }
+        var expires = '';
+        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
+            var date;
+            if (typeof options.expires == 'number') {
+                date = new Date();
+                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
+            } else {
+                date = options.expires;
+            }
+            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
+        }
+        // CAUTION: Needed to parenthesize options.path and options.domain
+        // in the following expressions, otherwise they evaluate to undefined
+        // in the packed version for some reason...
+        var path = options.path ? '; path=' + (options.path) : '';
+        var domain = options.domain ? '; domain=' + (options.domain) : '';
+        var secure = options.secure ? '; secure' : '';
+        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
+    } else { // only name given, get cookie
+        var cookieValue = null;
+        if (document.cookie && document.cookie != '') {
+            var cookies = document.cookie.split(';');
+            for (var i = 0; i < cookies.length; i++) {
+                var cookie = jQuery.trim(cookies[i]);
+                // Does this cookie string begin with the name we want?
+                if (cookie.substring(0, name.length + 1) == (name + '=')) {
+                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+                    break;
+                }
+            }
+        }
+        return cookieValue;
+    }
+};
+
+jQuery(function() {
+	  var $box = jQuery("#message_box"),
+	      stateCookieName = 'message_box',
+	      alreadyClosed = jQuery.cookie(stateCookieName);
+
+	  // The box should already be hidden initially (using CSS preferrably).
+	  // If not, uncomment the line below:
+	  // $box.hide();
+
+	  // Show the box if it hasn't already been closed.
+	  if (alreadyClosed != 1) {
+	    $box.show();
+	  }
+
+	  $box.find('#message_close').click(function() {
+	    $box.hide();
+	    jQuery.cookie(stateCookieName, 1, { expires: 1, path: '/'});
+	  });
+	});




More information about the Fusionforge-commits mailing list