[Fusionforge-commits] r8477 - in branches/Branch_4_8/gforge/common: forum include

Alexandre Neymann neymanna at libremir.placard.fr.eu.org
Wed Dec 9 11:26:26 CET 2009


Author: neymanna
Date: 2009-12-09 11:26:26 +0100 (Wed, 09 Dec 2009)
New Revision: 8477

Modified:
   branches/Branch_4_8/gforge/common/forum/Forum.class.php
   branches/Branch_4_8/gforge/common/include/Group.class.php
Log:
fix role settings for forums

Modified: branches/Branch_4_8/gforge/common/forum/Forum.class.php
===================================================================
--- branches/Branch_4_8/gforge/common/forum/Forum.class.php	2009-12-08 15:44:11 UTC (rev 8476)
+++ branches/Branch_4_8/gforge/common/forum/Forum.class.php	2009-12-09 10:26:26 UTC (rev 8477)
@@ -183,6 +183,22 @@
 		}
 		$this->group_forum_id=db_insertid($result,'forum_group_list','group_forum_id');
 		$this->fetchData($this->group_forum_id);
+		
+		// set the permission for the role's group 
+		$roles_group = $this->Group->getRolesId();
+		for ($i=0; $i<sizeof($roles_group); $i++) {
+			$role_setting_res = db_query_params ('INSERT INTO role_setting (role_id,section_name,ref_id,value) VALUES ($1,$2,$3,$4)',
+						array ($roles_group[$i],
+						       'forum',
+						       $this->group_forum_id,
+						       1)) ;
+			if (!$role_setting_res) {
+				db_rollback();
+				$this->setError('Error: Role setting for forum id ' . $this->group_forum_id . ' for groud id ' . $this->Group->getID() . ' ' .db_error());
+				return false;
+			}
+		}
+		
 		if ($create_default_message) {
 			$fm=new ForumMessage($this);
 			// Use the system side default language
@@ -652,6 +668,10 @@
 		db_query_params ('DELETE FROM forum_group_list WHERE group_forum_id=$1',
 				 array ($this->getID())) ;
 //echo '5'.db_error();
+		//delete forum's role setting
+		db_query_params ('DELETE FROM role_setting WHERE section_name=$1 AND ref_id=$2',
+				 array ('forum',
+				 $this->getID())) ;
 		db_commit();
 		return true;
 	}

Modified: branches/Branch_4_8/gforge/common/include/Group.class.php
===================================================================
--- branches/Branch_4_8/gforge/common/include/Group.class.php	2009-12-08 15:44:11 UTC (rev 8476)
+++ branches/Branch_4_8/gforge/common/include/Group.class.php	2009-12-09 10:26:26 UTC (rev 8477)
@@ -2399,8 +2399,29 @@
 	}
 
 
+	/**
+	 *	getRoles - Get the roles of the group.
+	 *
+	 *	@return	array of Role id of this group.
+	 */
+	function getRolesId () {
+		
+		$rolesId = Array();
+		
+		$roles_group_res = db_query_params ('SELECT role_id FROM role WHERE group_id=$1',
+					array ($this->getID()));
+		if (!$roles_group_res) {
+			$this->setError('Error: Roles from group id '. $this->Group->getID() . ' ' .db_error());
+			return false;
+		} else {
+		for ($i=0; $i<db_numrows($roles_group_res); $i++) {
+				 $rolesId[$i] = db_result($roles_group_res,$i,'role_id');
+			}
+		}
+		
+		return $rolesId;
+	}
 
-
 }
 
 /**




More information about the Fusionforge-commits mailing list