[Fusionforge-commits] r7533 - in trunk/gforge/common: forum tracker

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Apr 29 12:24:43 CEST 2009


Author: lolando
Date: 2009-04-29 12:24:42 +0200 (Wed, 29 Apr 2009)
New Revision: 7533

Modified:
   trunk/gforge/common/forum/Forum.class.php
   trunk/gforge/common/tracker/ArtifactType.class.php
Log:
New parameter to setMonitor() method allowing to subscribe a non-logged-in user to a forum or a tracker

Modified: trunk/gforge/common/forum/Forum.class.php
===================================================================
--- trunk/gforge/common/forum/Forum.class.php	2009-04-29 10:12:11 UTC (rev 7532)
+++ trunk/gforge/common/forum/Forum.class.php	2009-04-29 10:24:42 UTC (rev 7533)
@@ -452,22 +452,24 @@
 	 *
 	 *	@return	boolean	success.
 	 */
-	function setMonitor() {
-		if (!session_loggedin()) {
-			$this->setError(_('You can only monitor if you are logged in'));
-			return false;
+	function setMonitor ($u = -1) {
+		if ($u == -1) {
+			if (!session_loggedin()) {
+				$this->setError(_('You can only monitor if you are logged in'));
+				return false;
+			}
+			$u = user_getid() ;
 		}
 		$result = db_query_params ('SELECT * FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
-					   array (user_getid(),
+					   array ($u,
 						  $this->getID())) ;
-
 		if (!$result || db_numrows($result) < 1) {
 			/*
 				User is not already monitoring thread, so
 				insert a row so monitoring can begin
 			*/
 			$sql="INSERT INTO forum_monitored_forums (forum_id,user_id)
-				VALUES ('".$this->getID()."','".user_getid()."')";
+				VALUES ('".$this->getID()."','$u')";
 
 			$result = db_query_params ('INSERT INTO forum_monitored_forums (forum_id,user_id) VALUES ($1,$2)',
 						   array ($this->getID(),
@@ -487,13 +489,16 @@
 	 *
 	 *	@return	boolean	success.
 	 */
-	function stopMonitor() {
-		if (!session_loggedin()) {
-			$this->setError(_('You can only monitor if you are logged in'));
-			return false;
+	function stopMonitor ($u = -1) {
+		if ($u == -1) {
+			if (!session_loggedin()) {
+				$this->setError(_('You can only monitor if you are logged in'));
+				return false;
+			}
+			$u = user_getid() ;
 		}
 		return db_query_params ('DELETE FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
-					array (user_getid(),
+					array ($u,
 					       $this->getID())) ;
 	}
 

Modified: trunk/gforge/common/tracker/ArtifactType.class.php
===================================================================
--- trunk/gforge/common/tracker/ArtifactType.class.php	2009-04-29 10:12:11 UTC (rev 7532)
+++ trunk/gforge/common/tracker/ArtifactType.class.php	2009-04-29 10:24:42 UTC (rev 7533)
@@ -545,23 +545,18 @@
 	 *
 	 *  @return false - always false - always use the getErrorMessage() for feedback
 	 */
-	function setMonitor() {
-		if (session_loggedin()) {
-
-			$user_id=user_getid();
-			$user =& user_get_object(user_getid());
-
-		} else {
-
-			$this->setError(_('SetMonitor::Valid Email Address Required'));
-			return false;
-
+	function setMonitor ($user_id = -1) {
+		if ($user_id == -1) {
+			if (!session_loggedin()) {
+				$this->setError(_('You can only monitor if you are logged in'));
+				return false;
+			}
+			$user_id = user_getid() ;
 		}
 
 		$res = db_query_params ('SELECT * FROM artifact_type_monitor WHERE group_artifact_id=$1 AND user_id=$2',
 					array ($this->getID(),
 					       $user_id)) ;
-
 		if (!$res || db_numrows($res) < 1) {
 			//not yet monitoring
 			$res = db_query_params ('INSERT INTO artifact_type_monitor (group_artifact_id,user_id) VALUES ($1,$2)',




More information about the Fusionforge-commits mailing list