From 450976ef0be03ba66ef3df6a04aabc51f32f59bb Mon Sep 17 00:00:00 2001 From: Menno Dekker Date: Wed, 28 Nov 2012 15:19:43 +0100 Subject: [PATCH] Fixed #6955: CDbException (Error 500) when viewing participant panel as a restricted user --- application/models/Participants.php | 20 +++++++++++++------- application/models/User.php | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/application/models/Participants.php b/application/models/Participants.php index 39dc6988b2c..60b18207aee 100644 --- a/application/models/Participants.php +++ b/application/models/Participants.php @@ -35,7 +35,7 @@ class Participants extends CActiveRecord * @static * @access public * @param string $class - * @return CActiveRecord + * @return Participants */ public static function model($class = __CLASS__) { @@ -167,15 +167,21 @@ function updateRow($data) */ function getParticipantsOwner($userid) { - return Yii::app()->db->createCommand() - ->select('{{participants}}.*,{{participant_shares}}.can_edit') + $subquery = Yii::app()->db->createCommand() + ->select('{{participants}}.participant_id,{{participant_shares}}.can_edit') ->from('{{participants}}') ->leftJoin('{{participant_shares}}', ' {{participants}}.participant_id={{participant_shares}}.participant_id') ->where('owner_uid = :userid1 OR share_uid = :userid2') - ->group('{{participants}}.participant_id') - ->bindParam(":userid1", $userid, PDO::PARAM_INT) - ->bindParam(":userid2", $userid, PDO::PARAM_INT) - ->queryAll(); + ->group('{{participants}}.participant_id'); + + $command = Yii::app()->db->createCommand() + ->select('p.*, ps.can_edit') + ->from('{{participants}} p') + ->join('(' . $subquery->getText() . ') ps', 'ps.participant_id = p.participant_id') + ->bindParam(":userid1", $userid, PDO::PARAM_INT) + ->bindParam(":userid2", $userid, PDO::PARAM_INT); + + return $command->queryAll(); } function getParticipantsOwnerCount($userid) diff --git a/application/models/User.php b/application/models/User.php index f32fec8ffa7..3979ce85f25 100644 --- a/application/models/User.php +++ b/application/models/User.php @@ -21,7 +21,7 @@ class User extends CActiveRecord * @static * @access public * @param string $class - * @return CActiveRecord + * @return User */ public static function model($class = __CLASS__) {