Skip to content

Commit

Permalink
Dev: Indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Feb 4, 2016
1 parent 3a4177e commit ca3aeeb
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions application/models/Participant.php
Expand Up @@ -885,16 +885,35 @@ function getParticipantsSearchMultipleCondition($condition)
}

/**
* Returns true if participant_id has ownership or shared rights over this participant false if not
*
* @param mixed $participant_id
* @returns bool true/false
*/
* Returns true if participant_id has ownership or shared rights over this participant false if not
*
* @param mixed $participant_id
* @returns bool true/false
*/
function is_owner($participant_id)
{
$userid = Yii::app()->session['loginID'];
$is_owner = Yii::app()->db->createCommand()->select('count(*)')->where('participant_id = :participant_id AND owner_uid = :userid')->from('{{participants}}')->bindParam(":participant_id", $participant_id, PDO::PARAM_STR)->bindParam(":userid", $userid, PDO::PARAM_INT)->queryScalar();
$is_shared = Yii::app()->db->createCommand()->select('count(*)')->where('participant_id = :participant_id AND share_uid = :userid')->from('{{participant_shares}}')->bindParam(":participant_id", $participant_id, PDO::PARAM_STR)->bindParam(":userid", $userid, PDO::PARAM_INT)->queryScalar();

$is_owner = Yii::app()
->db
->createCommand()
->select('count(*)')
->where('participant_id = :participant_id AND owner_uid = :userid')
->from('{{participants}}')
->bindParam(":participant_id", $participant_id, PDO::PARAM_STR)
->bindParam(":userid", $userid, PDO::PARAM_INT)
->queryScalar();

$is_shared = Yii::app()
->db
->createCommand()
->select('count(*)')
->where('participant_id = :participant_id AND share_uid = :userid')
->from('{{participant_shares}}')
->bindParam(":participant_id", $participant_id, PDO::PARAM_STR)
->bindParam(":userid", $userid, PDO::PARAM_INT)
->queryScalar();

if ($is_shared > 0 || $is_owner > 0)
{
return true;
Expand All @@ -905,19 +924,17 @@ function is_owner($participant_id)
}
}

/*
/**
* This funciton is responsible for showing all the participant's shared by a particular user based on the user id
*/

function getParticipantShared($userid)
{
return Yii::app()->db->createCommand()->select('{{participants}}.*, {{participant_shares}}.*')->from('{{participants}}')->join('{{participant_shares}}', '{{participant_shares}}.participant_id = {{participants}}.participant_id')->where('owner_uid = :userid')->bindParam(":userid", $userid, PDO::PARAM_INT)->queryAll();
}

/*
/**
* This funciton is responsible for showing all the participant's shared to the superadmin
*/

function getParticipantSharedAll()
{
return Yii::app()->db->createCommand()->select('{{participants}}.*,{{participant_shares}}.*')->from('{{participants}}')->join('{{participant_shares}}', '{{participant_shares}}.participant_id = {{participants}}.participant_id')->queryAll();
Expand Down Expand Up @@ -1170,6 +1187,7 @@ function copyCPBDAttributesToTokens($surveyid, $mapped, $newcreate, $participant
* @return bool true/false
*/
function updateTokenAttributeValue($surveyId, $participantId, $participantAttributeId, $tokenFieldname) {

//Get the value from the participant_attribute field
$val = Yii::app()->db
->createCommand()
Expand Down

0 comments on commit ca3aeeb

Please sign in to comment.