Skip to content

Commit

Permalink
Some coding guideline cleanups
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12153 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jan 22, 2012
1 parent b6dd2bd commit a2571a5
Show file tree
Hide file tree
Showing 37 changed files with 486 additions and 547 deletions.
10 changes: 5 additions & 5 deletions application/controllers/RegisterController.php
Expand Up @@ -35,7 +35,7 @@ function actionAjaxregisterform($surveyid)
WHERE a.sid = $surveyid ";


$sresult = db_execute_assoc($squery) or show_error("Couldn't execute $squery");
$sresult = dbExecuteAssoc($squery) or show_error("Couldn't execute $squery");


$row = $sresult->read();
Expand Down Expand Up @@ -69,7 +69,7 @@ function actionIndex($surveyid = null)
}

$usquery = "SELECT stg_value FROM {{settings_global}} where stg_name='SessionName'";
$usresult = db_execute_assoc($usquery,'',true); //Checked
$usresult = dbExecuteAssoc($usquery,'',true); //Checked
if ($usresult->count() > 0)
{
$usrow = $usresult->read();
Expand Down Expand Up @@ -137,7 +137,7 @@ function actionIndex($surveyid = null)
//Check if this email already exists in token database
$query = "SELECT email FROM {{tokens_$surveyid}}\n"
. "WHERE email = '".sanitize_email(Yii::app()->request->getPost('register_email'))."'";
$result = db_execute_assoc($query) or show_error("Unable to execute this query : \n <br/>".$query."<br />"); //Checked)
$result = dbExecuteAssoc($query) or show_error("Unable to execute this query : \n <br/>".$query."<br />"); //Checked)
if (($result->count()) > 0)
{
$register_errormsg=$clang->gT("The email you used has already been registered.");
Expand Down Expand Up @@ -169,7 +169,7 @@ function actionIndex($surveyid = null)
{
$newtoken = randomChars($tokenlength);
$ntquery = "SELECT * FROM {{tokens_$surveyid}} WHERE token='$newtoken'";
$ntresult = db_execute_assoc($ntquery); //Checked
$ntresult = dbExecuteAssoc($ntquery); //Checked
if (!$ntresult->count()) {$mayinsert = true;}
}

Expand Down Expand Up @@ -254,7 +254,7 @@ function actionIndex($surveyid = null)
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$query = "UPDATE {{tokens_$surveyid}}\n"
."SET sent='$today' WHERE tid=$tid";
$result=db_execute_assoc($query) or show_error("Unable to execute this query : $query<br />"); //Checked
$result=dbExecuteAssoc($query) or show_error("Unable to execute this query : $query<br />"); //Checked
$html="<center>".$clang->gT("Thank you for registering to participate in this survey.")."<br /><br />\n".$clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.")."<br /><br />\n".$clang->gT("Survey administrator")." {ADMINNAME} ({ADMINEMAIL})";
$html=ReplaceFields($html, $fieldsarray);
$html .= "<br /><br /></center>\n";
Expand Down
22 changes: 11 additions & 11 deletions application/controllers/SurveyAction.php
Expand Up @@ -169,7 +169,7 @@ function action()
AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
ORDER BY surveyls_title";
$result = db_execute_assoc($query,false,true) or safeDie("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage."); //Checked
$result = dbExecuteAssoc($query,false,true) or safeDie("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage."); //Checked
$list=array();

if($result->count() > 0)
Expand Down Expand Up @@ -202,7 +202,7 @@ function action()
AND a.startdate is not null
ORDER BY surveyls_title";

$sresult = db_execute_assoc($squery) or safeDie("Couldn't execute $squery");
$sresult = dbExecuteAssoc($squery) or safeDie("Couldn't execute $squery");


if($sresult->count() > 0)
Expand Down Expand Up @@ -423,7 +423,7 @@ function sendreq(surveyid)
} else {
$tkquery = "SELECT * FROM {{'tokens_'".$surveyid."}} WHERE token=".$token." AND (completed = 'N' or completed='')";
}
$tkresult = db_execute_assoc($tkquery); //Checked
$tkresult = dbExecuteAssoc($tkquery); //Checked
$tokendata = $tkresult->read();
if ($tkresult->count()==0 || $areTokensUsed)
{
Expand All @@ -443,15 +443,15 @@ function sendreq(surveyid)
$this->_niceExit($redata, __LINE__, $thistpl, $asMessage, true);
}
}
if ($tokensexist == 1 && isset($token) && $token && db_tables_exist("{{tokens_".$surveyid."}}")) //check if token is in a valid time frame
if ($tokensexist == 1 && isset($token) && $token && tableExists("{{tokens_".$surveyid."}}")) //check if token is in a valid time frame
{
// check also if it is allowed to change survey after completion
if ($thissurvey['alloweditaftercompletion'] == 'Y' ) {
$tkquery = "SELECT * FROM {{tokens_".$surveyid."}} WHERE token=".$token." ";
} else {
$tkquery = "SELECT * FROM {{tokens_".$surveyid."}} WHERE token=".$token." AND (completed = 'N' or completed='')";
}
$tkresult = db_execute_assoc($tkquery); //Checked
$tkresult = dbExecuteAssoc($tkquery); //Checked
$tokendata = $tkresult->read();
if (isset($tokendata['validfrom']) && (trim($tokendata['validfrom'])!='' && $tokendata['validfrom']>dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)) ||
isset($tokendata['validuntil']) && (trim($tokendata['validuntil'])!='' && $tokendata['validuntil']<dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)))
Expand Down Expand Up @@ -497,7 +497,7 @@ function sendreq(surveyid)
if (isset($qid))
{
$query = "SELECT * FROM {{survey_".$surveyid."}} WHERE id=".$_SESSION['survey_'.$surveyid]['srid'];
$result = db_execute_assoc($query);
$result = dbExecuteAssoc($query);
foreach($result->readAll() as $row)
{
foreach ($qid as $question)
Expand All @@ -522,10 +522,10 @@ function sendreq(surveyid)


// delete the response but only if not already completed
db_execute_assoc('DELETE FROM {{survey_'.$surveyid.'}} WHERE id='.$_SESSION['survey_'.$surveyid]['srid']." AND submitdate IS NULL");
dbExecuteAssoc('DELETE FROM {{survey_'.$surveyid.'}} WHERE id='.$_SESSION['survey_'.$surveyid]['srid']." AND submitdate IS NULL");

// also delete a record from saved_control when there is one
db_execute_assoc('DELETE FROM {{saved_control}} WHERE srid='.$_SESSION['survey_'.$surveyid]['srid'].' AND sid='.$surveyid);
dbExecuteAssoc('DELETE FROM {{saved_control}} WHERE srid='.$_SESSION['survey_'.$surveyid]['srid'].' AND sid='.$surveyid);
}
killSurveySession($surveyid);
sendCacheHeaders();
Expand Down Expand Up @@ -574,7 +574,7 @@ function sendreq(surveyid)
$srquery="SELECT id FROM {$thissurvey['tablename']}"
. " WHERE {$thissurvey['tablename']}.token='".$token."' order by id desc";

$result = db_select_limit_assoc($srquery,1);
$result = dbSelectLimitAssoc($srquery,1);
if ($result->count()>0)
{
$row=reset($result->read());
Expand Down Expand Up @@ -696,7 +696,7 @@ function _surveyExistsAndIsActive($surveyId)

if ($surveyId)
{
$aRow = db_execute_assoc("SELECT active FROM {{surveys}} WHERE sid='".$surveyId."'")->read();
$aRow = dbExecuteAssoc("SELECT active FROM {{surveys}} WHERE sid='".$surveyId."'")->read();
if (isset($aRow['active']))
{
$surveyExists = true;
Expand Down Expand Up @@ -745,7 +745,7 @@ function _canUserPreviewSurvey($iSurveyID)
if ( $_SESSION['USER_RIGHT_SUPERADMIN'] == 1 )
return true;

$rightresult = db_execute_assoc(
$rightresult = dbExecuteAssoc(
"SELECT uid
FROM {{survey_permissions}}
WHERE sid = ".$iSurveyID."
Expand Down
18 changes: 9 additions & 9 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -339,8 +339,8 @@ protected function _checkintegrity()

/*** Check for active survey tables with missing survey entry and rename them ***/
$sDBPrefix = Yii::app()->db->tablePrefix;
$sQuery = db_select_tables_like('{{survey}}\_%');
$aResult = db_query_or_false($sQuery) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
$sQuery = dbSelectTablesLike('{{survey}}\_%');
$aResult = dbQueryOrFalse($sQuery) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
foreach ($aResult->readAll() as $aRow)
{
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
Expand All @@ -362,7 +362,7 @@ protected function _checkintegrity()
}

/*** Check for active token tables with missing survey entry ***/
$aResult = db_query_or_false(db_select_tables_like('{{tokens}}\_%')) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\_%')) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
foreach ($aResult->readAll() as $aRow)
{
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
Expand Down Expand Up @@ -613,8 +613,8 @@ protected function _checkintegrity()
//1: Get list of 'old_survey' tables and extract the survey id
//2: Check if that survey id still exists
//3: If it doesn't offer it for deletion
$sQuery = db_select_tables_like('{{old_survey}}%');
$aResult = db_query_or_false($sQuery) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
$sQuery = dbSelectTablesLike('{{old_survey}}%');
$aResult = dbQueryOrFalse($sQuery) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
$aTables = $aResult->readAll();

$aOldSIDs = array();
Expand All @@ -628,7 +628,7 @@ protected function _checkintegrity()
}
$aOldSIDs = array_unique($aOldSIDs);
$sQuery = 'SELECT sid FROM {{surveys}} ORDER BY sid';
$oResult = db_execute_assoc($sQuery) or safeDie('Couldn\'t get unique survey ids');
$oResult = dbExecuteAssoc($sQuery) or safeDie('Couldn\'t get unique survey ids');
$surveys = Survey::model()->findAll();
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
$aSIDs = array();
Expand Down Expand Up @@ -668,7 +668,7 @@ protected function _checkintegrity()
$iMinute = substr($sDateTime, 10, 2);
$sDate = date('d M Y H:i', mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));
$sQuery = 'SELECT * FROM ' . $sTableName;
$oQRresult = db_execute_assoc($sQuery) or safeDie('Failed: ' . $sQuery);
$oQRresult = dbExecuteAssoc($sQuery) or safeDie('Failed: ' . $sQuery);
$iRecordcount = $oQRresult->count();
if ($iRecordcount == 0) { // empty table - so add it to immediate deletion
$aDelete['orphansurveytables'][] = $sTableName;
Expand All @@ -686,7 +686,7 @@ protected function _checkintegrity()
//1: Get list of 'old_token' tables and extract the survey id
//2: Check if that survey id still exists
//3: If it doesn't offer it for deletion
$aResult = db_query_or_false(db_select_tables_like('{{old_token}}%')) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{old_token}}%')) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
$aTables = $aResult->readAll();

$aOldTokenSIDs = array();
Expand Down Expand Up @@ -732,7 +732,7 @@ protected function _checkintegrity()
$sDate = date('D, d M Y h:i a', mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));
$sQuery = 'SELECT * FROM ' . $sTableName;

$oQRresult = db_execute_assoc($sQuery) or safeDie('Failed: ' . $sQuery);
$oQRresult = dbExecuteAssoc($sQuery) or safeDie('Failed: ' . $sQuery);
$iRecordcount = $oQRresult->count();
if ($iRecordcount == 0) {
$aDelete['orphantokentables'][] = $sTableName;
Expand Down

0 comments on commit a2571a5

Please sign in to comment.