View Issue Details

IDProjectCategoryView StatusLast Update
02457User patchesStatisticspublic2010-06-03 16:16
Reporteruser617Assigned Touser617 
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Product Version 
Target VersionFixed in Version1.90 
Summary02457: Feature to add number of surveys against a user
Description

Hi,

I have attached a script which will show the number of surveys against a particular user. Only superadmin can view this.

The file belongs in ...limesurvey\admin

Let me know if its any good or would be better suited in another place.

Cheerz

TagsNo tags attached.
Complete LimeSurvey version number (& build)

Activities

user372

2008-08-29 20:00

  ~05686

Hi, is it possible to add a SVN diff.patch file of your modification?

2008-08-29 20:33

 

diff.patch (4,417 bytes)
Index: userrighthandling.php
===================================================================
--- userrighthandling.php	(revision 5509)
+++ userrighthandling.php	(working copy)
@@ -365,6 +365,7 @@
 		$usersummary = "<br /><strong>".$clang->gT("Setting as Administrator Child")."</strong><br />"
 		. "<br />".$clang->gT("Set Parent successful.")."<br />"
 		. "<br /><a href='$scriptname?action=editusers'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
+		
 	}
 	else
 	{
@@ -374,11 +375,14 @@
 
 if ($action == "editusers")
 {
-	$usersummary = "<table width='100%' border='0'>\n"
+	if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
+	{
+			$usersummary = "<table width='100%' border='0'>\n"
 	. "<tr><td colspan='6' class='header'>"
 	. $clang->gT("User Control")
     ."</td></tr>\n"
 	. "<tr>\n"
+	. "<th width='5%'>".$clang->gT("No of Surveys")."</th>\n"
 	. "<th width='20%'>".$clang->gT("Username")."</th>\n"
 	. "<th width='20%'>".$clang->gT("Email")."</th>\n"
 	. "<th width='20%'>".$clang->gT("Full name")."</th>\n"
@@ -386,22 +390,59 @@
 	. "<th width='15%'>".$clang->gT("Created by")."</th>\n"
 	. "<th></th>\n"
 	. "</tr>\n";
+	}
+	else
+	{
+			$usersummary = "<table width='100%' border='0'>\n"
+	. "<tr><td colspan='6' class='header'>"
+	. $clang->gT("User Control")
+    ."</td></tr>\n"
+	. "<tr>\n"
+	. "<th width='20%'>".$clang->gT("Username")."</th>\n"
+	. "<th width='20%'>".$clang->gT("Email")."</th>\n"
+	. "<th width='20%'>".$clang->gT("Full name")."</th>\n"
+	. "<th width='15%'>".$clang->gT("Password")."</th>\n"
+	. "<th width='15%'>".$clang->gT("Created by")."</th>\n"
+	. "<th></th>\n"
+	. "</tr>\n";
+	}
 
+
 	$userlist = getuserlist();
+	//print_r($userlist);
 	$ui = count($userlist);
 	$usrhimself = $userlist[0];
 	unset($userlist[0]);
 
+	
+		
+	$result = mysql_query("SELECT sid FROM `lime_surveys` WHERE `owner_id`='1'");
+	while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
+	$noofsurveys = $noofsurveys+1;
+}
+		
+	
 	//	output users
 	// output admin user only if the user logged in has user management rights
 //	if ($_SESSION['USER_RIGHT_DELETE_USER']||$_SESSION['USER_RIGHT_CREATE_USER']||$_SESSION['USER_RIGHT_SUPERADMIN']){
 
-
-		$usersummary .= "<tr class='oddrow'>\n"
+if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
+	{
+			$usersummary .= "<tr class='oddrow'>\n"
+		. "<td class='oddrow' align='center'><strong>{$noofsurveys}</strong></td>\n"
 		. "<td class='oddrow' align='center'><strong>{$usrhimself['user']}</strong></td>\n"
 		. "<td class='oddrow' align='center'><strong>{$usrhimself['email']}</strong></td>\n"
 		. "<td class='oddrow' align='center'><strong>{$usrhimself['full_name']}</strong></td>\n"
 		. "<td class='oddrow' align='center'><strong>********</strong></td>\n";
+	}
+	else
+	{
+			$usersummary .= "<tr class='oddrow'>\n"
+		. "<td class='oddrow' align='center'><strong>{$usrhimself['user']}</strong></td>\n"
+		. "<td class='oddrow' align='center'><strong>{$usrhimself['email']}</strong></td>\n"
+		. "<td class='oddrow' align='center'><strong>{$usrhimself['full_name']}</strong></td>\n"
+		. "<td class='oddrow' align='center'><strong>********</strong></td>\n";
+	}
 		
 		if(isset($usrhimself['parent_id']) && $usrhimself['parent_id']!=0) { 
 		$uquery = "SELECT users_name FROM ".db_table_name('users')." WHERE uid=".$usrhimself['parent_id'];
@@ -448,6 +489,20 @@
 	// other users
 	$row = 0;
 	$usr_arr = $userlist;
+	$noofsurveyslist = array(  );
+
+	//This loops through for each user and checks the amount of surveys against them.
+	for($i=1;$i<=count($usr_arr);$i++)
+	{
+		$noofsurveys = 0;
+		$query = "SELECT 'sid' FROM `lime_surveys` WHERE `owner_id`='".$usr_arr[$i][uid]."'";
+		$result = mysql_query($query);
+		while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
+		$noofsurveys = $noofsurveys+1;
+		}
+		$noofsurveyslist[$i] = $noofsurveys;
+	}
+
 	for($i=1; $i<=count($usr_arr); $i++)
 	{
 		if (!isset($bgcc)) {$bgcc="evenrow";}
@@ -458,8 +513,9 @@
 		}
 		$usr = $usr_arr[$i];
 		$usersummary .= "<tr class='$bgcc'>\n";
-
-		$usersummary .= "<td class='$bgcc' align='center'>{$usr['user']}</td>\n"
+	
+		$usersummary .= "<td class='$bgcc' align='center'>{$noofsurveyslist[$i]}</td>\n"
+		."<td class='$bgcc' align='center'>{$usr['user']}</td>\n"
 		. "<td class='$bgcc' align='center'><a href='mailto:{$usr['email']}'>{$usr['email']}</a></td>\n"
 		. "<td class='$bgcc' align='center'>{$usr['full_name']}</td>\n";
 
diff.patch (4,417 bytes)

user617

2008-08-29 20:34

  ~05687

Sure, just uploaded.

user372

2008-08-29 20:44

  ~05688

@ jak82: THX - project leader Carsten Schmitz will have a look at it and if the quality is OK, we'll integrate it into the v1.80 development branch.

Plz provide all modifications as diff.patches in the future, because they are much easier to implement - TXH!

user372

2008-08-30 20:20

  ~05695

Hi, it looks like your patch contains MySQL specific code; LimeSurvey supports MSSQL and PostgresSQL outofthebox too - plz contact Carsten Schmitz for a code review.

c_schmitz

c_schmitz

2008-10-06 00:53

administrator   ~05948

Jak, can you get in touch about this please?

c_schmitz

c_schmitz

2008-10-14 22:38

administrator   ~06003

Hi Jak,

beta release is by next Monday. I need the patch by now or we will have to drop the feature - that would be very sad.
Please provide an updated patch as soon as possible!

c_schmitz

c_schmitz

2008-10-19 13:36

administrator   ~06037

Unassigning from 1.8beta. If there is any progress we can still change that.

user617

2008-10-19 18:45

  ~06045

Apologies for not getting back sooner, I dont have the time at the moment to progress this further. the l8 nights from the baby is catching up, when I get time again ill look into it further.

Issue History

Date Modified Username Field Change
2008-08-29 19:07 user617 New Issue
2008-08-29 19:07 user617 Status new => assigned
2008-08-29 19:07 user617 Assigned To => user372
2008-08-29 19:07 user617 File Added: userrighthandling.php
2008-08-29 19:07 user617 Database & DB-Version => MYSQL
2008-08-29 19:07 user617 Operating System (Server) => XP
2008-08-29 19:07 user617 PHP Version => 5
2008-08-29 19:07 user617 Webserver => WAMP
2008-08-29 20:00 user372 Note Added: 05686
2008-08-29 20:01 user372 Status assigned => feedback
2008-08-29 20:33 user617 File Added: diff.patch
2008-08-29 20:34 user617 Note Added: 05687
2008-08-29 20:44 user372 Note Added: 05688
2008-08-29 20:44 user372 Status feedback => assigned
2008-08-29 20:44 user372 Assigned To user372 => c_schmitz
2008-08-29 20:45 user372 Project Bug reports => User patches
2008-08-29 20:45 user372 Product Version 1.71+ =>
2008-08-29 20:45 user372 Target Version => 1.80
2008-08-29 20:46 user372 File Deleted: userrighthandling.php
2008-08-30 20:20 user372 Note Added: 05695
2008-10-06 00:53 c_schmitz Note Added: 05948
2008-10-06 00:53 c_schmitz Assigned To c_schmitz => user617
2008-10-06 00:53 c_schmitz Status assigned => feedback
2008-10-14 22:38 c_schmitz Note Added: 06003
2008-10-19 13:35 c_schmitz Target Version 1.80 =>
2008-10-19 13:36 c_schmitz Note Added: 06037
2008-10-19 18:45 user617 Note Added: 06045
2009-04-18 14:12 c_schmitz Status feedback => acknowledged
2010-03-11 12:54 c_schmitz Status acknowledged => feedback
2010-03-13 16:13 c_schmitz Status feedback => acknowledged
2010-03-15 17:12 c_schmitz Status acknowledged => resolved
2010-03-15 17:12 c_schmitz Fixed in Version => 1.90
2010-03-15 17:12 c_schmitz Resolution open => fixed
2010-06-03 16:16 c_schmitz Status resolved => closed