[Fusionforge-commits] r13708 - trunk/src/plugins/scmhook/common

Franck VILLAUME nerville at fusionforge.org
Thu Jul 7 17:28:56 CEST 2011


Author: nerville
Date: 2011-07-07 17:28:56 +0200 (Thu, 07 Jul 2011)
New Revision: 13708

Modified:
   trunk/src/plugins/scmhook/common/scmhookPlugin.class.php
Log:
handle correctly the scm_enable_anonymous

Modified: trunk/src/plugins/scmhook/common/scmhookPlugin.class.php
===================================================================
--- trunk/src/plugins/scmhook/common/scmhookPlugin.class.php	2011-07-07 12:51:11 UTC (rev 13707)
+++ trunk/src/plugins/scmhook/common/scmhookPlugin.class.php	2011-07-07 15:28:56 UTC (rev 13708)
@@ -85,17 +85,19 @@
 		$updatedb = 0;
 		foreach($params as $key => $value) {
 			if ($key == strstr($key, 'scm')) {
-				$updatedb = 1;
 				$hookname = preg_replace('/scm[a-z][a-z][a-z]_/','',$key);
-				$extensions = $this->getAllowedExtension();
-				foreach($extensions as $extension) {
-					$hookname = preg_replace('/_'.$extension.'$/', '.'.$extension, $hookname);
+				if ($key != $hookname) {	//handle the case of scm_enable_anonymous
+					$updatedb = 1;
+					$extensions = $this->getAllowedExtension();
+					foreach($extensions as $extension) {
+						$hookname = preg_replace('/_'.$extension.'$/', '.'.$extension, $hookname);
+					}
+					if (strlen($hooksString)) {
+						$hooksString .= '|'.$hookname;
+					} else {
+						$hooksString .= $hookname;
+					}
 				}
-				if (strlen($hooksString)) {
-					$hooksString .= '|'.$hookname;
-				} else {
-					$hooksString .= $hookname;
-				}
 			}
 		}
 		if ($updatedb) {
@@ -198,6 +200,21 @@
 		return array();
 	}
 
+	function isHookEnabled($group_id, $hookname) {
+		$res = db_query_params('SELECT hooks FROM plugin_scmhook
+					WHERE id_group = $1
+					AND hooks like $2',
+					array($group_id, '%'.$hookname.'%'));
+
+		if (!$res)
+			return false;
+
+		if (db_numrows($res) != 1)
+			return false;
+
+		return true;
+	}
+
 	function getListLibraryScm() {
 		return array_values(array_diff(scandir(dirname(__FILE__).'/../library/'), Array('.', '..', '.svn')));
 	}
@@ -224,7 +241,7 @@
 	}
 
 	function getAllowedExtension() {
-		return array("sh", "pl");
+		return array("sh", "pl", "php");
 	}
 
 	/**




More information about the Fusionforge-commits mailing list