Commit ed3b5788 authored by LouisGac's avatar LouisGac

Dev: some cleaning

parent 5abf08ff
......@@ -34,14 +34,14 @@ class TokenDynamic extends LSActiveRecord
self::sid($sid);
$refresh = true;
}
$model = parent::model(__CLASS__);
//We need to refresh if we changed sid
if ($refresh === true) $model->refreshMetaData();
return $model;
}
/**
* Sets the survey ID for the next model
*
......@@ -92,8 +92,8 @@ class TokenDynamic extends LSActiveRecord
array('mpid','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('blacklisted', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
array('emailstatus', 'default', 'value' => $this->emailstatus),
// array('validfrom','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// array('validuntil','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// array('validfrom','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// array('validuntil','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// Date rules currently don't work properly with MSSQL, deactivating for now
);
}
......@@ -102,7 +102,7 @@ class TokenDynamic extends LSActiveRecord
* Checks to make sure that all required columns exist in this tokens table
* (some older tokens tables dont' get udated properly)
*
* This method should be moved to db update for 2.05 version so it runs only
* This method should be moved to db update for 2.05 version so it runs only
* once per token table / backup token table
*/
public function checkColumns() {
......@@ -128,7 +128,7 @@ class TokenDynamic extends LSActiveRecord
} else {
// On some installs we have created not null for participant_id and blacklisted fix this
$columns = array('blacklisted', 'participant_id');
foreach ($columns as $columnname)
{
$definition = $tableSchema->getColumn($columnname);
......@@ -144,12 +144,12 @@ class TokenDynamic extends LSActiveRecord
public function findUninvited($aTokenIds = false, $iMaxEmails = 0, $bEmail = true, $SQLemailstatuscondition = '', $SQLremindercountcondition = '', $SQLreminderdelaycondition = '')
{
$command = new CDbCriteria;
$command->condition = '';
$command->condition = '';
$command->addCondition("(completed ='N') or (completed='')");
$command->addCondition("token <> ''");
$command->addCondition("email <> ''");
if ($bEmail) {
if ($bEmail) {
$command->addCondition("(sent = 'N') or (sent = '')");
} else {
$command->addCondition("(sent <> 'N') AND (sent <> '')");
......@@ -157,20 +157,20 @@ class TokenDynamic extends LSActiveRecord
if ($SQLemailstatuscondition)
$command->addCondition($SQLemailstatuscondition);
if ($SQLremindercountcondition)
$command->addCondition($SQLremindercountcondition);
if ($SQLreminderdelaycondition)
$command->addCondition($SQLreminderdelaycondition);
if ($aTokenIds)
if ($aTokenIds)
$command->addCondition("tid IN ('".implode("', '", $aTokenIds)."')" );
if ($iMaxEmails)
$command->limit = $iMaxEmails;
$command->order = 'tid';
$command->order = 'tid';
$oResult = TokenDynamic::model()->findAll($command);
return $oResult;
......@@ -179,11 +179,11 @@ class TokenDynamic extends LSActiveRecord
public function findUninvitedIDs($aTokenIds = false, $iMaxEmails = 0, $bEmail = true, $SQLemailstatuscondition = '', $SQLremindercountcondition = '', $SQLreminderdelaycondition = '')
{
$command = new CDbCriteria;
$command->condition = '';
$command->condition = '';
$command->addCondition("(completed ='N') or (completed='')");
$command->addCondition("token <> ''");
$command->addCondition("email <> ''");
if ($bEmail) {
if ($bEmail) {
$command->addCondition("(sent = 'N') or (sent = '')");
} else {
$command->addCondition("(sent <> 'N') AND (sent <> '')");
......@@ -191,20 +191,20 @@ class TokenDynamic extends LSActiveRecord
if ($SQLemailstatuscondition)
$command->addCondition($SQLemailstatuscondition);
if ($SQLremindercountcondition)
$command->addCondition($SQLremindercountcondition);
if ($SQLreminderdelaycondition)
$command->addCondition($SQLreminderdelaycondition);
if ($aTokenIds)
if ($aTokenIds)
$command->addCondition("tid IN ('".implode("', '", $aTokenIds)."')" );
if ($iMaxEmails)
$command->limit = $iMaxEmails;
$command->order = 'tid';
$command->order = 'tid';
$oResult=$this->getCommandBuilder()
->createFindCommand($this->getTableSchema(), $command)
......@@ -212,7 +212,7 @@ class TokenDynamic extends LSActiveRecord
->queryColumn();
return $oResult;
}
function insertParticipant($data)
{
$token = new self;
......@@ -252,7 +252,7 @@ class TokenDynamic extends LSActiveRecord
{
return Yii::app()->db->createCommand("SELECT tid FROM {{tokens_{$iSurveyID}}} WHERE token IS NULL OR token=''")->queryAll();
}
public static function countAllAndCompleted($sid)
{
$select = array(
......@@ -277,11 +277,11 @@ class TokenDynamic extends LSActiveRecord
//get token length from survey settings
$tlrow = Survey::model()->findByAttributes(array("sid"=>self::$sid));
$iTokenLength = $tlrow->tokenlength;
//get all existing tokens
$criteria = $this->getDbCriteria();
$criteria->select = 'token';
$ntresult = $this->findAllAsArray($criteria);
$ntresult = $this->findAllAsArray($criteria);
foreach ($ntresult as $tkrow)
{
$existingtokens[] = $tkrow['token'];
......@@ -299,7 +299,7 @@ class TokenDynamic extends LSActiveRecord
//update specific token row
$itresult = $this->updateToken($iTokenID, $newtoken);
return $newtoken;
}
}
/**
* Creates tokens for all token records that have empty token fields and returns the number
......@@ -380,7 +380,7 @@ class TokenDynamic extends LSActiveRecord
{
if ($this->usesleft>0)
{
$this->completed='N';
$this->completed='N';
}
return parent::beforeSave();
}
......@@ -414,7 +414,7 @@ class TokenDynamic extends LSActiveRecord
/**
* Get CDbCriteria for a json search string
*
*
* @param array $condition
* @return \CDbCriteria
*/
......@@ -422,7 +422,7 @@ class TokenDynamic extends LSActiveRecord
{
$i=0;
$j=1;
$tobedonelater =array();
$tobedonelater =array();
$command = new CDbCriteria;
$command->condition = '';
$iNumberOfConditions = (count($condition)+1)/4;
......@@ -434,27 +434,27 @@ class TokenDynamic extends LSActiveRecord
$sValue=$condition[($i*4)+2];
switch ($sOperator)
{
case 'equal':
case 'equal':
$command->addCondition($sFieldname.' = :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = $sValue;
break;
case 'contains':
case 'contains':
$command->addCondition($sFieldname.' LIKE :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = '%'.$sValue.'%';
break;
case 'notequal':
case 'notequal':
$command->addCondition($sFieldname.' <> :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = $sValue;
break;
case 'notcontains':
case 'notcontains':
$command->addCondition($sFieldname.' NOT LIKE :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = '%'.$sValue.'%';
break;
case 'greaterthan':
case 'greaterthan':
$command->addCondition($sFieldname.' > :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = $sValue;
break;
case 'lessthan':
case 'lessthan':
$command->addCondition($sFieldname.' < :condition_'.$i, $sConnectingOperator);
$aParams[':condition_'.$i] = $sValue;
break;
......@@ -474,7 +474,7 @@ class TokenDynamic extends LSActiveRecord
{
$command->params = $aParams;
}
return $command;
}
......
......@@ -52,7 +52,7 @@
</a>
</li>
<?php } ?>
<?php if($surveylocale || $surveysettings || $surveysecurity || $quotas || $assessments || $surveycontent) { ?>
<li><a href='#'>
<img src='<?php echo $sImageURL;?>edit.png' alt='<?php eT("Survey properties");?>' width="<?php echo $iIconSize;?>" height="<?php echo $iIconSize;?>"/></a><ul>
......@@ -96,11 +96,11 @@
</li>
<?php } ?>
<?php } ?>
</ul>
</ul>
</li>
<?php } ?>
<?php if($surveydelete || $surveytranslate || Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')) { ?>
<?php if($surveydelete || $surveytranslate || Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')) { ?>
<li><a href="#">
<img src='<?php echo $sImageURL;?>tools.png' alt='<?php eT("Tools");?>' width="<?php echo $iIconSize;?>" height="<?php echo $iIconSize;?>"/></a><ul>
<?php if ($surveydelete) { ?>
......@@ -145,10 +145,10 @@
</li>
<?php } ?>
<?php } ?>
</ul>
</ul>
</li>
<?php } ?>
<?php } ?>
<?php if($surveyexport || Permission::model()->hasSurveyPermission($surveyid,'surveycontent','read')) { ?>
<li><a href='#'>
<img src='<?php echo $sImageURL;?>display_export.png' alt='<?php eT("Display / Export");?>' width="<?php echo $iIconSize;?>" height="<?php echo $iIconSize;?>"/></a>
......@@ -157,7 +157,7 @@
<li><a href='#'>
<img src='<?php echo $sImageURL;?>export_30.png' alt='' /> <?php eT("Export...");?></a>
<?php } ?>
<ul>
<ul>
<?php if($surveyexport) { ?>
<li><a href='<?php echo $this->createUrl("admin/export/sa/survey/action/exportstructurexml/surveyid/$surveyid");?>' >
<img src='<?php echo $sImageURL;?>export_30.png' alt='' /> <?php eT("Survey structure (.lss)");?></a>
......@@ -203,15 +203,15 @@
?>
<li><a href='<?php echo $this->createUrl("admin/export/quexml/surveyid/$surveyid");?>' >
<img src='<?php echo $sImageURL;?>export_30.png' alt='' /> <?php eT("queXML PDF export");?></a></li>
<?php
<?php
} ?>
</ul>
</ul>
</li>
<?php } ?>
<?php } ?>
<?php if($respstatsread || $responsescreate || $responsesread) { ?>
<li><a href='#'><img src='<?php echo $sImageURL;?>responses.png' alt='<?php eT("Responses");?>' width="<?php echo $iIconSize;?>" height="<?php echo $iIconSize;?>"/></a>
<ul>
<li><a href='#'><img src='<?php echo $sImageURL;?>responses.png' alt='<?php eT("Responses");?>' width="<?php echo $iIconSize;?>" height="<?php echo $iIconSize;?>"/></a>
<ul>
<?php if($respstatsread) {
if($activated) { ?>
<li><a href='<?php echo $this->createUrl("admin/responses/sa/index/surveyid/$surveyid/");?>' >
......@@ -239,9 +239,9 @@
<img src='<?php echo $sImageURL;?>saved_disabled_30.png' alt='' /> <?php eT("Partial (saved) responses");?></a></li>
<?php }
} ?>
</ul>
</ul>
</li>
<?php } ?>
<?php } ?>
<?php if($surveycontent)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment