Skip to content

Commit

Permalink
Fixed #6955: CDbException (Error 500) when viewing participant panel …
Browse files Browse the repository at this point in the history
…as a restricted user
  • Loading branch information
mennodekker committed Nov 28, 2012
1 parent fc287eb commit 450976e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions application/models/Participants.php
Expand Up @@ -35,7 +35,7 @@ class Participants extends CActiveRecord
* @static
* @access public
* @param string $class
* @return CActiveRecord
* @return Participants
*/
public static function model($class = __CLASS__)
{
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion application/models/User.php
Expand Up @@ -21,7 +21,7 @@ class User extends CActiveRecord
* @static
* @access public
* @param string $class
* @return CActiveRecord
* @return User
*/
public static function model($class = __CLASS__)
{
Expand Down

0 comments on commit 450976e

Please sign in to comment.