[Fusionforge-commits] r10634 - in trunk/src: common/include www/project/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Sep 22 17:23:16 CEST 2010


Author: lolando
Date: 2010-09-22 17:23:16 +0200 (Wed, 22 Sep 2010)
New Revision: 10634

Modified:
   trunk/src/common/include/RBAC.php
   trunk/src/common/include/Role.class.php
   trunk/src/www/project/admin/roleedit.php
Log:
RBAC: fixes + UI to set a group-specific role as public/shared

Modified: trunk/src/common/include/RBAC.php
===================================================================
--- trunk/src/common/include/RBAC.php	2010-09-22 14:59:21 UTC (rev 10633)
+++ trunk/src/common/include/RBAC.php	2010-09-22 15:23:16 UTC (rev 10634)
@@ -333,7 +333,11 @@
 				return false;
 			}
 			$this->data_array = db_fetch_array($res);
-			
+			if ($this->data_array['is_public'] == 't') {
+				$this->data_array['is_public'] = true ;
+			} else {
+				$this->data_array['is_public'] = false ;
+			}
 			$res = db_query_params ('SELECT section_name, ref_id, perm_val FROM pfo_role_setting WHERE role_id=$1',
 						array ($role_id)) ;
 			if (!$res) {

Modified: trunk/src/common/include/Role.class.php
===================================================================
--- trunk/src/common/include/Role.class.php	2010-09-22 14:59:21 UTC (rev 10633)
+++ trunk/src/common/include/Role.class.php	2010-09-22 15:23:16 UTC (rev 10634)
@@ -149,8 +149,8 @@
 	 *      @return boolean True if updated OK
 	 */
 	function setPublic ($flag) { // From the PFO spec
-		$res = db_query_params ('UPDATE pfo_role SET is_public=$1 WHERE role_id=$1',
-					array ($flag,
+		$res = db_query_params ('UPDATE pfo_role SET is_public=$1 WHERE role_id=$2',
+					array ($flag?'true':'false',
 					       $this->getID())) ;
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setError('update::is_public::'.db_error());

Modified: trunk/src/www/project/admin/roleedit.php
===================================================================
--- trunk/src/www/project/admin/roleedit.php	2010-09-22 14:59:21 UTC (rev 10633)
+++ trunk/src/www/project/admin/roleedit.php	2010-09-22 15:23:16 UTC (rev 10634)
@@ -102,8 +102,10 @@
 		if (($role->getHomeProject() != NULL)
 		    && ($role->getHomeProject()->getID() == $group_id)) {
 			$role_name = trim(getStringFromRequest('role_name'));
+			$public = getIntFromRequest('public') ? true : false ;
 		} else {
 			$role_name = $role->getName() ;
+			$public = $role->isPublic() ;
 		}
 		if (!$role_name) {
 			$error_msg .= ' Missing Role Name ';
@@ -116,6 +118,7 @@
 					$feedback = _('Successfully Created New Role');
 				}
 			} else {
+				$role->setPublic($public) ;
 				if (!$role->update($role_name,$data)) {
 					$error_msg .= $role->getErrorMessage();
 				} else {
@@ -157,18 +160,22 @@
 
 if (USE_PFO_RBAC) {
 	if ($role->getHomeProject() == NULL) {
-		echo '<p><strong>'._('Role Name').'</strong><br />' ;
+		echo '<p><strong>'._('Role Name').'</strong></p>' ;
 		printf (_('%s (global role)'),
 			$role->getName ()) ;
 	} elseif ($role->getHomeProject()->getID() != $group_id) {
-		echo '<p><strong>'._('Role Name').'</strong><br />' ;
+		echo '<p><strong>'._('Role Name').'</strong></p>' ;
 		printf (_('%s (in project %s)'),
 			$role->getName (),
 			$role->getHomeProject()->getPublicName()) ;
 	} else {
-		echo '<p><strong>'._('Role Name').'</strong><br /><input type="text" name="role_name" value="'.$role->getName().'">' ;
+		echo '<p><strong>'._('Role Name').'</strong><br /><input type="text" name="role_name" value="'.$role->getName().'"><br />' ;
+		echo '<input type="checkbox" name="public" value="1"' ;
+		if ($role->isPublic()) {
+			echo ' checked' ;
+		}
+		echo '> '._('Shared role').'</p>' ;
 	}
-	echo '</p>';
 } else {
 	if ($role_id != 'observer') {
 		echo '<p><strong>'._('Role Name').'</strong><br />




More information about the Fusionforge-commits mailing list