[Fusionforge-commits] r10722 - trunk/src/common/widget

Roland Mas lolando at libremir.placard.fr.eu.org
Sun Sep 26 18:40:15 CEST 2010


Author: lolando
Date: 2010-09-26 18:40:14 +0200 (Sun, 26 Sep 2010)
New Revision: 10722

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

Modified: trunk/src/common/widget/Widget.class.php
===================================================================
--- trunk/src/common/widget/Widget.class.php	2010-09-26 16:37:31 UTC (rev 10721)
+++ trunk/src/common/widget/Widget.class.php	2010-09-26 16:40:14 UTC (rev 10722)
@@ -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/src/common/widget/Widget_MyAdmin.class.php
===================================================================
--- trunk/src/common/widget/Widget_MyAdmin.class.php	2010-09-26 16:37:31 UTC (rev 10721)
+++ trunk/src/common/widget/Widget_MyAdmin.class.php	2010-09-26 16:40:14 UTC (rev 10722)
@@ -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 Fusionforge-commits mailing list