Skip to content

Commit

Permalink
Fixed issue #6867: Modification of user and survey rights results in …
Browse files Browse the repository at this point in the history
…an error
  • Loading branch information
c-schmitz committed Nov 15, 2012
1 parent c58d127 commit 020ae9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
28 changes: 13 additions & 15 deletions application/controllers/admin/surveypermission.php
Expand Up @@ -9,15 +9,13 @@
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/

/**
* surveypermission
*
* @package LimeSurvey
* @copyright 2011
* @version $Id$
* @access public
*/
class surveypermission extends Survey_Common_Action {
Expand All @@ -44,12 +42,12 @@ function index($surveyid)
$result2 = Survey_permissions::model()->getUserDetails($surveyid);

$surveysecurity ="<div class='header ui-widget-header'>".$clang->gT("Survey permissions")."</div>\n"
. "<table class='surveysecurity'><thead>"
. "<tr>\n"
. "<th>".$clang->gT("Action")."</th>\n"
. "<th>".$clang->gT("Username")."</th>\n"
. "<th>".$clang->gT("User group")."</th>\n"
. "<th>".$clang->gT("Full name")."</th>\n";
. "<table class='surveysecurity'><thead>"
. "<tr>\n"
. "<th>".$clang->gT("Action")."</th>\n"
. "<th>".$clang->gT("Username")."</th>\n"
. "<th>".$clang->gT("User group")."</th>\n"
. "<th>".$clang->gT("Full name")."</th>\n";
foreach ($aBaseSurveyPermissions as $sPermission=>$aSubPermissions )
{
$surveysecurity.="<th><img src=\"{$imageurl}{$aSubPermissions['img']}_30.png\" alt=\"<span style='font-weight:bold;'>".$aSubPermissions['title']."</span><br />".$aSubPermissions['description']."\" /></th>\n";
Expand All @@ -66,7 +64,7 @@ function index($surveyid)
$surveysecurity .= "<tbody>\n";
if(count($result2) > 0)
{
// output users
// output users
$row = 0;

foreach ($result2 as $PermissionRow)
Expand Down Expand Up @@ -369,8 +367,8 @@ function set($surveyid)
$where.= "AND owner_id != :postuserid";
$params[':postuserid'] = $postuserid;
}
$result = Survey::model()->findAll($where,$params);
if(count($result) > 0 || Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1)
$result = Survey::model()->count($where,$params);
if($result > 0 || Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1)
{
//$js_admin_includes[]='../scripts/jquery/jquery.tablesorter.min.js';
//$js_admin_includes[]='scripts/surveysecurity.js';
Expand All @@ -379,8 +377,7 @@ function set($surveyid)
if ($action == "setsurveysecurity")
{
$query = "select users_name from {{users}} where uid=:uid";
$res = Yii::app()->db->createCommand($query)->bindParam(":uid", $postuserid, PDO::PARAM_INT)->query();
$resrow = $res->read();
$resrow = Yii::app()->db->createCommand($query)->bindParam(":uid", $postuserid, PDO::PARAM_INT)->queryRow();
$sUsername=$resrow['users_name'];
$usersummary = "<div class='header ui-widget-header'>".sprintf($clang->gT("Edit survey permissions for user %s"),"<span style='font-style:italic'>".$sUsername."</span>")."</div>";
}
Expand All @@ -405,6 +402,7 @@ function set($surveyid)
. "</tr></thead>\n";

//content

$aBasePermissions=Survey_permissions::model()->getBasePermissions();

$oddcolumn=false;
Expand Down Expand Up @@ -575,7 +573,7 @@ function surveyright($surveyid)
{
foreach ($oResult as $aRow)
{
Survey_permissions::model()->setPermission($aRow->uid, $surveyid, $aPermissions);
Survey_permissions::model()->setPermission($aRow->uid, $surveyid, $aPermissions);
}
$addsummary .= "<div class=\"successheader\">".$clang->gT("Survey permissions for all users in this group were successfully updated.")."</div>\n";
}
Expand Down
18 changes: 8 additions & 10 deletions application/views/admin/user/setuserrights.php
Expand Up @@ -12,15 +12,13 @@
$userlist = getUserList();
foreach ($userlist as $usr) {
if ($usr['uid'] == $postuserid) {
$squery = "SELECT create_survey, configurator, create_user, delete_user, superadmin, participant_panel,manage_template, manage_label FROM {{users}} WHERE uid=".Yii::app()->session['loginID']; // added by Dennis
$sresult = dbSelectLimitAssoc($squery); //Checked
$parent = $sresult->read();
$squery = "SELECT create_survey, configurator, create_user, delete_user, superadmin, participant_panel,manage_template, manage_label FROM {{users}} WHERE uid=".Yii::app()->session['loginID']; // added by Dennis
$parent = Yii::app()->db->createCommand($squery)->queryRow();

// Initial SuperAdmin has parent_id == 0
$adminquery = "SELECT uid FROM {{users}} WHERE parent_id=0";
$adminresult = dbSelectLimitAssoc($adminquery, 1);
$row=$adminresult->read();
?>
$row = Yii::app()->db->createCommand($adminquery)->queryRow();
?>

<tr>

Expand Down Expand Up @@ -48,7 +46,7 @@
if($parent['manage_label']) {
echo "<th align='center'>".$clang->gT("Manage labels")."</th>\n";
}
?>
?>

</tr>
<tr>
Expand Down Expand Up @@ -111,7 +109,7 @@
}
echo " /></td>\n";
}
?>
?>
</tr>

<tr>
Expand All @@ -124,6 +122,6 @@
</table>
</form>
<?php continue;
} // if
} // foreach
} // if
} // foreach
?>

0 comments on commit 020ae9e

Please sign in to comment.