Skip to content

Commit

Permalink
dev: participant panel export to csv now operates on the current sear…
Browse files Browse the repository at this point in the history
…ch/filter
  • Loading branch information
mennodekker committed Nov 30, 2012
1 parent 51436c4 commit 78cab8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
62 changes: 31 additions & 31 deletions application/controllers/admin/participantsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,26 +557,27 @@ function exporttocsvcount()

$searchconditionurl = Yii::app()->request->getPost('searchcondition');
$searchcondition = basename($searchconditionurl);

if (Yii::app()->session['USER_RIGHT_SUPERADMIN']) //If super admin all the participants in the cpdb are counted
if ($searchcondition != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
{
if ($searchcondition != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
{
$condition = explode("||", $searchcondition);
$query = Participants::model()->getParticipantsSearchMultiple($condition, 0, 0);
$count = count($query);
}
else // if no search criteria all the participants will be counted
{
$count = Participants::model()->getParticipantsCountWithoutLimit();
}
$condition = explode("||", $searchcondition);
$search = Participants::model()->getParticipantsSearchMultipleCondition($condition);
} else {
$search = null;
}
else // If no search criteria it will simply return the number of participants

$attid = ParticipantAttributeNames::model()->getVisibleAttributes();

//If super admin all the participants will be visible
if (Yii::app()->session['USER_RIGHT_SUPERADMIN'])
{
$iUserID = null;
} else {
$iUserID = Yii::app()->session['loginID'];
$query = Participants::model()->getParticipantsOwner($iUserID);
$count = count($query);
}


$count = Participants::model()->getParticipantsCount($attid, $search, $iUserID);

echo sprintf($clang->gT("Export %s participant(s) to CSV"), $count);
}
Expand Down Expand Up @@ -782,27 +783,26 @@ function exporttocsv()

$searchconditionurl = Yii::app()->request->getPost('searchcondition');
$searchcondition = basename($searchconditionurl);

if (Yii::app()->session['USER_RIGHT_SUPERADMIN']) //If super admin all the participants will be visible
if ($searchcondition != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
{
if ($searchcondition != 'getParticipants_json') // If there is a search condition then only does participants are exported
{
$condition = explode("||", $searchcondition);

$query = Participants::model()->getParticipantsSearchMultiple($condition, 0, 0);

} // else all the participants in the central table will be exported since it's superadmin
else
{
$query = Participants::model()->getParticipantsWithoutLimit();
}
$condition = explode("||", $searchcondition);
$search = Participants::model()->getParticipantsSearchMultipleCondition($condition);
} else {
$search = null;
}
else

$attid = ParticipantAttributeNames::model()->getVisibleAttributes();

//If super admin all the participants will be visible
if (Yii::app()->session['USER_RIGHT_SUPERADMIN'])
{
$iUserID = Yii::app()->session['loginID']; // else only the
$query = Participants::model()->getParticipantsOwner($iUserID);
$iUserID = null;
} else {
$iUserID = Yii::app()->session['loginID'];
}

$query = Participants::model()->getParticipants(0, 0, $attid, null, $search, $iUserID);
if (!$query)
return false;

Expand Down
8 changes: 5 additions & 3 deletions application/models/Participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,11 @@ private function getParticipantsSelectCommand($count = false, $attid, $search =
$data->setOrder($order);
}

$offset = ($page - 1) * $limit;
$data->offset($offset)
->limit($limit);
if ($page <> 0) {
$offset = ($page - 1) * $limit;
$data->offset($offset)
->limit($limit);
}
}

$data->bindValues($aParams);
Expand Down

0 comments on commit 78cab8f

Please sign in to comment.