[evolvis-commits] r15974: Show only allowed parts of the forge-wide administrative links in the widget

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Mar 1 00:42:10 CET 2011


Author: mirabilos
Date: 2011-03-01 00:42:10 +0100 (Tue, 01 Mar 2011)
New Revision: 15974

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget.class.php
   trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget_MyAdmin.class.php
Log:
Show only allowed parts of the forge-wide administrative links in the widget

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget.class.php	2011-02-28 23:42:07 UTC (rev 15973)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget.class.php	2011-02-28 23:42:10 UTC (rev 15974)
@@ -181,7 +181,9 @@
 				break;
 
 			case 'myadmin':
-				if (UserManager::instance()->getCurrentUser()->is_super_user) { //This widget is only for super admin
+				if (forge_check_global_perm ('forge_admin')
+					|| forge_check_global_perm ('approve_projects')
+					|| forge_check_global_perm ('approve_news')) {
 					$o = new Widget_MyAdmin();
 				}
 				break;/*

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget_MyAdmin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget_MyAdmin.class.php	2011-02-28 23:42:07 UTC (rev 15973)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/widget/Widget_MyAdmin.class.php	2011-02-28 23:42:10 UTC (rev 15974)
@@ -30,88 +30,87 @@
         $this->Widget('myadmin');
     }
     function getTitle() {
-        return _("Pending users, projects and news");
+        return _("Pending administrative tasks");
     }
     function getContent() {
-        
-        //require_once('www/forum/forum_utils.php');
-        //require_once('www/project/admin/ugroup_utils.php');
-        
-        $html_my_admin = '';
-        // Get the number of pending users and projects
-        $res = db_query_params("SELECT count(*) AS count FROM groups WHERE status='P'",array());
-        $row = db_fetch_array($res);
-        $pending_projects = $row['count'];
-
-	$res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
-	$row = db_fetch_array($res);
-	$pending_users = $row['count'];
-	$res = db_query_params("SELECT count(*) AS count FROM users WHERE status='V' OR status='W'",array());
-	$row = db_fetch_array($res);
-	$validated_users = $row['count'];
-
-
-	$sql="SELECT * FROM news_bytes WHERE is_approved=0 OR is_approved=3";
-	$result=db_query_params($sql,array());
-	$pending_news = 0;
-	$rows=db_numrows($result);
-	for ($i=0; $i<$rows; $i++) {
-		//if the news is private, not display it in the list of news to be approved
-		$forum_id=db_result($result,$i,'forum_id');
-		/*$res = news_read_permissions($forum_id);
-		// check on db_result($res,0,'ugroup_id') == $UGROUP_ANONYMOUS only to be consistent
-		// with ST DB state
-		if ((db_numrows($res) < 1) || (db_result($res,0,'ugroup_id') == $GLOBALS['UGROUP_ANONYMOUS'])) {
-			$pending_news++;
-		}*/
-	}
-
-
 	$i = 0;
-	$html_my_admin .= '<table width="100%">';
-	$html_my_admin .= $this->_get_admin_row(
+	$html_my_admin = '<table width="100%">';
+
+	if (forge_check_global_perm ('forge_admin')) {
+		$res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
+		$row = db_fetch_array($res);
+		$pending_users = $row['count'];
+		$res = db_query_params("SELECT count(*) AS count FROM users WHERE status='V' OR status='W'",array());
+		$row = db_fetch_array($res);
+		$validated_users = $row['count'];
+		
+		$html_my_admin .= $this->_get_admin_row(
 			$i++, 
 			vsprintf(_('Users in <a href="%s"><B>P</B> (pending) Status</a>'), array("/admin/approve_pending_users.php?page=pending")),
 			$pending_users,
 			$this->_get_color($pending_users)
 			);
-
-	if ($GLOBALS['sys_user_approval'] == 1) {
-		$html_my_admin .= $this->_get_admin_row(
+		
+		if ($GLOBALS['sys_user_approval'] == 1) {
+			$html_my_admin .= $this->_get_admin_row(
 				$i++, 
 				vsprintf(_('Validated users <a href="%s"><B>pending email activation</B></a>'), array("/admin/approve_pending_users.php?page=validated")),
 				$validated_users,
 				$this->_get_color($validated_users)
 				);
+		}
 	}
 
-	$html_my_admin .= $this->_get_admin_row(
+	if (forge_check_global_perm ('approve_projects')) {
+		$res = db_query_params("SELECT count(*) AS count FROM groups WHERE status='P'",array());
+		$row = db_fetch_array($res);
+		$pending_projects = $row['count'];
+
+		$html_my_admin .= $this->_get_admin_row(
 			$i++, 
 			vsprintf(_('Groups in <a href="%s"><B>P</B> (pending) Status</A>'), array("/admin/approve-pending.php")),
 			$pending_projects,
 			$this->_get_color($pending_projects)
 			);
+	}
 
-	$html_my_admin .= $this->_get_admin_row(
+	if (forge_check_global_perm ('approve_news')) {
+		$sql="SELECT * FROM news_bytes WHERE is_approved=0 OR is_approved=3";
+		$result=db_query_params($sql,array());
+		$pending_news = 0;
+		$rows=db_numrows($result);
+		for ($i=0; $i<$rows; $i++) {
+			//if the news is private, not display it in the list of news to be approved
+			$forum_id=db_result($result,$i,'forum_id');
+			/*$res = news_read_permissions($forum_id);
+			// check on db_result($res,0,'ugroup_id') == $UGROUP_ANONYMOUS only to be consistent
+			// with ST DB state
+			if ((db_numrows($res) < 1) || (db_result($res,0,'ugroup_id') == $GLOBALS['UGROUP_ANONYMOUS'])) {
+			$pending_news++;
+			}*/
+		}
+		
+		
+		$html_my_admin .= $this->_get_admin_row(
 			$i++, 
 			'<a href="/news/admin">'. _("Site News Approval") .'</a>',
 			$pending_news,
 			$this->_get_color($pending_news)
 			);
-
-	$result = array();
-	//$em =& EventManager::instance();
-	//$em->processEvent('widget_myadmin', array('result' => &$result));
-	foreach($result as $entry) {
-		$html_my_admin .= $this->_get_admin_row(
+		
+		$result = array();
+		//$em =& EventManager::instance();
+		//$em->processEvent('widget_myadmin', array('result' => &$result));
+		foreach($result as $entry) {
+			$html_my_admin .= $this->_get_admin_row(
 				$i++, 
 				$entry['text'],
 				$entry['value'],
 				$entry['bgcolor'],
 				isset($entry['textcolor']) ? $entry['textcolor'] : 'white'
 				);
+		}
 	}
-
 	$html_my_admin .= '</table>';
 
 	return $html_my_admin;



More information about the evolvis-commits mailing list