Skip to content

Commit

Permalink
Dev: Refactor the 'quotas' admin controller in the LimeSurvey Yii por…
Browse files Browse the repository at this point in the history
…t (GCI2011 By Guatam Gupta)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11719 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Pieter Jan Speelmans committed Dec 21, 2011
1 parent 23c1955 commit 7c7b959
Show file tree
Hide file tree
Showing 11 changed files with 654 additions and 652 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/authentication.php
Expand Up @@ -50,7 +50,7 @@ public function run()
*/
public function index()
{
redirect('/admin', 'refresh');
$this->_doRedirect();
}

/**
Expand Down
1,150 changes: 572 additions & 578 deletions application/controllers/admin/quotas.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions application/helpers/common_helper.php
Expand Up @@ -6010,14 +6010,14 @@ function SSL_mode()
/**
* Returns the number of answers matching the quota
*
* @param int $surveyid - Survey identification number
* @param int $iSurveyId - Survey identification number
* @param int $quotaid - quota id for which you want to compute the completed field
* @return mixed - Integer of matching entries in the result DB or 'N/A'
*/
function get_quotaCompletedCount($surveyid, $quotaid)
function get_quotaCompletedCount($iSurveyId, $quotaid)
{
$result = "N/A";
$quota_info = getQuotaInformation($surveyid, GetBaseLanguageFromSurveyID($surveyid), $quotaid);
$quota_info = getQuotaInformation($iSurveyId, GetBaseLanguageFromSurveyID($iSurveyId), $quotaid);
$quota = $quota_info[0];

if (Yii::app()->db->schema->getTable('{{survey_' . $surveyid . '}}') &&
Expand Down
84 changes: 43 additions & 41 deletions application/views/admin/quotas/editquota_view.php
@@ -1,42 +1,44 @@
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/modifyquota");?>" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
<tbody>
<tr>
<td colspan="2" class="header ui-widget-header"><?php echo $clang->gT("Edit quota");?></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota name");?>:</strong></p>
</blockquote></td>
<td align="left"> <input name="quota_name" type="text" size="30" maxlength="255" value="<?php echo $quotainfo['name'];?>" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota limit");?>:</strong></p>
</blockquote></td>
<td align="left"><input name="quota_limit" type="text" size="12" maxlength="8" value="<?php echo $quotainfo['qlimit'];?>" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota action");?>:</strong></p>
</blockquote></td>
<td align="left"> <select name="quota_action">
<option value ="1" '<?php if($quotainfo['action'] == 1) echo "selected"; ?>'><?php echo $clang->gT("Terminate survey");?></option>
<option value ="2" '<?php if($quotainfo['action'] == 2) echo "selected"; ?>'><?php echo $clang->gT("Terminate survey with warning");?></option>
</select></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Autoload URL");?>:</strong></p>
</blockquote></td>
<td align="left"><input name="autoload_url" type="checkbox" value="1"<?php if($quotainfo['autoload_url'] == "1") {echo " checked";}?> /></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/modifyquota");?>" method="post">
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
<tbody>
<tr>
<td colspan="2" class="header ui-widget-header"><?php echo $clang->gT("Edit quota");?></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota name");?>:</strong></p>
</blockquote></td>
<td align="left"> <input name="quota_name" type="text" size="30" maxlength="255" value="<?php echo $quotainfo['name'];?>" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota limit");?>:</strong></p>
</blockquote></td>
<td align="left"><input name="quota_limit" type="text" size="12" maxlength="8" value="<?php echo $quotainfo['qlimit'];?>" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Quota action");?>:</strong></p>
</blockquote></td>
<td align="left"> <select name="quota_action">
<option value ="1" '<?php if($quotainfo['action'] == 1) echo "selected"; ?>'><?php echo $clang->gT("Terminate survey");?></option>
<option value ="2" '<?php if($quotainfo['action'] == 2) echo "selected"; ?>'><?php echo $clang->gT("Terminate survey with warning");?></option>
</select></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong><?php echo $clang->gT("Autoload URL");?>:</strong></p>
</blockquote></td>
<td align="left"><input name="autoload_url" type="checkbox" value="1"<?php if($quotainfo['autoload_url'] == "1") {echo " checked";}?> /></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
<div id="tabs">
8 changes: 4 additions & 4 deletions application/views/admin/quotas/newanswer_view.php
@@ -1,6 +1,6 @@
<div class="header ui-widget-header"><?php echo $clang->gT("Survey Quota");?>: <?php echo $clang->gT("Add Answer");?></div><br />
<div class="messagebox ui-corner-all" style="width: 600px">
<form action="<?php echo $this->createUrl("/admin/quotas/surveyid/$surveyid/subaction/new_answer_two");?>" method="post">
<form action="<?php echo $this->createUrl("/admin/quotas/surveyid/$iSurveyId/subaction/new_answer_two");?>" method="post">
<table class="addquotaanswer" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<thead>
<tr>
Expand Down Expand Up @@ -30,13 +30,13 @@
<td>&nbsp;</td>
<td>
<input name="submit" type="submit" class="submit" value="<?php echo $clang->gT("Next");?>" />
<input type="hidden" name="sid" value="'.$surveyid.'" />
<input type="hidden" name="sid" value="'.$iSurveyId.'" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="new_answer_two" />
<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id'];?>" />
<input type="hidden" name="quota_id" value="<?php echo sanitize_int($_POST['quota_id']);?>" />
</td>
</tr>
</tbody>
</table><br />
</form>
</div>
</div>
2 changes: 1 addition & 1 deletion application/views/admin/quotas/newanswererror_view.php
@@ -1,5 +1,5 @@
<div class="header"><?php echo $clang->gT("Add Answer");?>: <?php echo $clang->gT("Question Selection");?></div><br />
<div class="messagebox">
<?php echo $clang->gT("Sorry there are no supported question types in this survey.");?>
<br/><br/><input type="submit" onclick="window.open('<?php echo site_url("admin/quotas/$surveyid");?>', '_top')" value="<?php echo $clang->gT("Continue");?>"/>
<br/><br/><input type="submit" onclick="window.open('<?php echo site_url("admin/quotas/$iSurveyId");?>', '_top')" value="<?php echo $clang->gT("Continue");?>"/>
</div>
12 changes: 6 additions & 6 deletions application/views/admin/quotas/newanswertwo_view.php
Expand Up @@ -2,12 +2,12 @@
<div class="header"><?php echo $clang->gT("Add Answer");?>: <?php echo $clang->gT("Question Selection");?></div><br />
<div class="messagebox">
<?php echo $clang->gT("All answers are already selected in this quota.");?>
<br/><br/><input type="submit" onclick="window.open('<?php echo $this->createUrl("admin/quotas/$surveyid");?>', '_top')" value="<?php echo $clang->gT("Continue");?>"/>
<br/><br/><input type="submit" onclick="window.open('<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId");?>', '_top')" value="<?php echo $clang->gT("Continue");?>"/>
</div>
<?php } else { ?>
<div class="header ui-widget-header"><?php echo $clang->gT("Survey Quota");?>: <?php echo $clang->gT("Add Answer");?></div><br />
<div class="messagebox ui-corner-all" style="width: 600px">
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/insertquotaanswer");?>#quota_<?php echo $_POST['quota_id'];?>" method="post">
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/insertquotaanswer");?>#quota_<?php echo sanitize_int($_POST['quota_id']);?>" method="post">
<table class="addquotaanswer" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tbody>
<thead>
Expand Down Expand Up @@ -43,15 +43,15 @@
<td>&nbsp;</td>
<td>
<input name="submit" type="submit" class="submit" value="<?php echo $clang->gT("Next");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="insertquotaanswer" />
<input type="hidden" name="quota_qid" value="<?php echo $_POST['quota_qid'];?>" />
<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id'];?>" />
<input type="hidden" name="quota_qid" value="<?php echo sanitize_int($_POST['quota_qid']);?>" />
<input type="hidden" name="quota_id" value="<?php echo sanitize_int($_POST['quota_id']);?>" />
</td>
</tr>
</tbody>
</table><br />
</form>
</div>
<?php } ?>
<?php } ?>
8 changes: 7 additions & 1 deletion application/views/admin/quotas/viewquotas_view.php
@@ -1,4 +1,10 @@
<?php if(isset($showerror)) echo $showerror;?>
<?php if (isset($sShowError)) {?>
<script type="text/javascript">
<!--
alert("<?php $clang->eT("Quota could not be added.", 'js'); ?>\n\n<?php $clang->eT("It is missing a quota message for the following languages:", 'js'); ?>\n<?php echo $sShowError; ?>");
//-->
</script>
<?php } ?>

<div class="header ui-widget-header"><?php echo $clang->gT("Survey quotas");?></div>
<br />
Expand Down
8 changes: 4 additions & 4 deletions application/views/admin/quotas/viewquotasfooter_view.php
Expand Up @@ -5,10 +5,10 @@
<td align="center"><?php echo $totalquotas;?></td>
<td align="center"><?php echo $totalcompleted;?></td>
<td align="center" style="padding: 3px;">
<?php if (bHasSurveyPermission($surveyid, 'quotas','create')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/new_quota");?>" method="post">
<?php if (bHasSurveyPermission($iSurveyId, 'quotas','create')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/new_quota");?>" method="post">
<input name="submit" type="submit" class="quota_new" value="<?php echo $clang->gT("Add New Quota");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="new_quota" />
</form>
Expand All @@ -17,4 +17,4 @@
</td>
</tr>
</tbody>
</table>
</table>
20 changes: 10 additions & 10 deletions application/views/admin/quotas/viewquotasrow_view.php
Expand Up @@ -23,18 +23,18 @@
<td align="center"><?php echo $quotalisting['qlimit'];?></td>
<td align="center" <?php echo $highlight;?>><?php echo $completed;?></td>
<td align="center" style="padding: 3px;">
<?php if (bHasSurveyPermission($surveyid, 'quotas','update')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/quota_editquota");?>" method="post">
<?php if (bHasSurveyPermission($iSurveyId, 'quotas','update')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/quota_editquota");?>" method="post">
<input name="submit" type="submit" class="submit" value="<?php echo $clang->gT("Edit");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="quota_id" value="<?php echo $quotalisting['id'];?>" />
<input type="hidden" name="subaction" value="quota_editquota" />
</form>
<?php } if (bHasSurveyPermission($surveyid, 'quotas','delete')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/quota_delquota");?>" method="post">
<?php } if (bHasSurveyPermission($iSurveyId, 'quotas','delete')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/quota_delquota");?>" method="post">
<input name="submit" type="submit" class="submit" value="<?php echo $clang->gT("Remove");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="quota_id" value="<?php echo $quotalisting['id'];?>" />
<input type="hidden" name="subaction" value="quota_delquota" />
Expand All @@ -49,14 +49,14 @@
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td style="padding: 3px;" align="center">
<?php if (bHasSurveyPermission($surveyid, 'quotas','update')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/new_answer");?>" method="post">
<?php if (bHasSurveyPermission($iSurveyId, 'quotas','update')) { ?>
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/new_answer");?>" method="post">
<input name="submit" type="submit" class="quota_new" value="<?php echo $clang->gT("Add Answer");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="quota_id" value="<?php echo $quotalisting['id'];?>" />
<input type="hidden" name="subaction" value="new_answer" />
</form>
<?php } ?>
</td>
</tr>
</tr>
6 changes: 3 additions & 3 deletions application/views/admin/quotas/viewquotasrowsub_view.php
Expand Up @@ -5,14 +5,14 @@
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td style="padding: 3px;" align="center">
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$surveyid/subaction/quota_delans");?>" method="post">
<form action="<?php echo $this->createUrl("admin/quotas/surveyid/$iSurveyId/subaction/quota_delans");?>" method="post">
<input name="submit" type="submit" class="submit" value="<?php echo $clang->gT("Remove");?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid;?>" />
<input type="hidden" name="sid" value="<?php echo $iSurveyId;?>" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="quota_member_id" value="<?php echo $quota_questions['id'];?>" />
<input type="hidden" name="quota_qid" value="<?php echo $quota_questions['qid'];?>" />
<input type="hidden" name="quota_anscode" value="<?php echo $quota_questions['code'];?>" />
<input type="hidden" name="subaction" value="quota_delans" />
</form>
</td>
</tr>
</tr>

0 comments on commit 7c7b959

Please sign in to comment.