Skip to content

Commit

Permalink
Fixed issue #9447: Token sending email is unusuable with a lot of token
Browse files Browse the repository at this point in the history
  • Loading branch information
Aestu committed Jan 29, 2015
1 parent 27dd87f commit 651cc9c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions application/config/config-defaults.php
Expand Up @@ -376,6 +376,8 @@
// If used, the appearance (font size, justification, etc.) may be adjusted by editing td.questionHelpBefore and $helpBeforeBorderBottom of quexml.
$config['quexmlshowprintablehelp'] = false;

$config['minlengthshortimplode'] = 20; // Min length required to use short_implode instead of standard implode

// CAS Settings
/**
* Please note that CAS functionality is very basic and you have to modify the client to your needs.
Expand Down
48 changes: 48 additions & 0 deletions application/helpers/common_helper.php
Expand Up @@ -5630,6 +5630,54 @@ function isNumericInt($mStr)
}


/**
* Implode and sort content array for very long arrays
*
* @param string $sDelimeter
* @param array $aArray
* @return string String showing array content
*/
function short_implode($sDelimeter, $aArray)
{
if (sizeof($aArray) < Yii::app()->getConfig('minlengthshortimplode'))
{
sort($aArray);
return implode($sDelimeter, $aArray);
}
else
{
sort($aArray);
$iIndexA = 0;
$iIndexB = 1;
while ($iIndexA < sizeof($aArray))
{
if ($iIndexA == 0)
{
$sResult = $aArray[$iIndexA];
}
else
{
$sResult = $sResult.', '.$aArray[$iIndexA];
}
$iIndexB = $iIndexA+1;
if ($iIndexB < sizeof($aArray))
{
while ($iIndexB < sizeof($aArray) && $aArray[$iIndexB] - 1 == $aArray[$iIndexB-1])
{
$iIndexB++;
}
if ($iIndexA < $iIndexB - 1)
{
$sResult = $sResult.'-'.$aArray[$iIndexB-1];
}
}
$iIndexA = $iIndexB;
}
return $sResult;
}
}


/**
* Include Keypad headers
*/
Expand Down
7 changes: 7 additions & 0 deletions application/views/admin/token/email.php
Expand Up @@ -83,6 +83,13 @@
</ul></div>
<?php } ?>

<?php
if (count($tokenids)>0)
{ ?>
<p>
<label><?php $clang->eT("Send invitation email to token ID(s):"); ?></label>
<?php echo short_implode(", ", (array) $tokenids); ?></p>
<?php } ?>
<p>
<label for='bypassbademails'><?php $clang->eT("Bypass token with failing email addresses"); ?>:</label>
<?php echo CHtml::dropDownList('bypassbademails', 'Y',array("Y"=>gT("Yes"),"N"=>gT("No"))); ?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/token/remind.php
Expand Up @@ -68,7 +68,7 @@
{ ?>
<li>
<label><?php $clang->eT("Send reminder to token ID(s):"); ?></label>
<?php echo implode(", ", (array) $tokenids); ?></li>
<?php echo short_implode(", ", (array) $tokenids); ?></li>
<?php } ?>
<li><label for='bypassbademails'>
<?php $clang->eT("Bypass token with failing email addresses"); ?>:</label>
Expand Down

0 comments on commit 651cc9c

Please sign in to comment.