Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LimeSurvey/LimeSurvey
Browse files Browse the repository at this point in the history
  • Loading branch information
limesurvey-translations committed Aug 24, 2015
2 parents 5a0aa8e + f75d307 commit 25070fc
Show file tree
Hide file tree
Showing 36 changed files with 448 additions and 251 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.06+";
$config['dbversionnumber'] = 183;
$config['dbversionnumber'] = 184;
$config['buildnumber'] = '';
$config['updatable'] = true;

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/RegisterController.php
Expand Up @@ -419,20 +419,20 @@ private function display($iSurveyId)
$aData['thissurvey']=getSurveyInfo($iSurveyId,$sLanguage);
$sTemplate=getTemplatePath($aData['thissurvey']['template']);
Yii::app()->setConfig('surveyID',$iSurveyId);//Needed for languagechanger
$aData['languagechanger']=makeLanguageChangerSurvey($sLanguage);
$aData['sitename']=Yii::app()->getConfig('sitename');
$aData['aRegisterErrors']=$this->aRegisterErrors;
$aData['sMessage']=$this->sMessage;

sendCacheHeaders();
doHeader();
$aViewData['sTemplate']=$sTemplate;
$aViewData['aData']=$aData;
if(!$this->sMessage){
$aData['languagechanger']=makeLanguageChangerSurvey($sLanguage); // Only show language changer shown the form is shown, not after submission
$aViewData['content']=self::getRegisterForm($iSurveyId);
}else{
$aViewData['content']=templatereplace($this->sMessage);
}
$aViewData['aData']=$aData;
// Test if we come from index or from register
if(empty(App()->clientScript->scripts)){
App()->getClientScript()->registerPackage('jqueryui');
Expand Down
92 changes: 40 additions & 52 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -250,26 +250,30 @@ private function _deleteQuotaMembers(array $aData)
return $aData;
}

/**
* This function Deletes quota language settings without related main entries
*
*/
private function _deleteQuotaLanguageSettings()
{
$quotas = Quota::model()->findAll();
foreach ($quotas as $quota) $quota_ids[] = $quota['id'];
$criteria = new CDbCriteria;
$criteria->addNotInCondition('quotals_quota_id', $quota_ids);

QuotaLanguageSetting::model()->deleteAll($criteria);
$oCriteria = new CDbCriteria;
$oCriteria->join = 'LEFT JOIN {{quota}} q ON t.quotals_quota_id=q.id';
$oCriteria->condition = '(q.id IS NULL)';
QuotaLanguageSetting::model()->deleteAll($oCriteria);
if (QuotaLanguageSetting::model()->hasErrors()) safeDie(QuotaLanguageSetting::model()->getError());
}

/**
* This function deletes quota entries which not having a related survey entry
*
* @param mixed $aData
*/
private function _deleteQuotas(array $aData)
{
$sids = array();
$surveys = Survey::model()->findAll();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$criteria = new CDbCriteria;
$criteria->addNotInCondition('sid', $sids);

Quota::model()->deleteAll($criteria);
$oCriteria = new CDbCriteria;
$oCriteria->join = 'LEFT JOIN {{surveys}} q ON t.sid=q.sid';
$oCriteria->condition = '(q.sid IS NULL)';
Quota::model()->deleteAll($oCriteria);
if (Quota::model()->hasErrors()) safeDie(Quota::model()->getError());
$aData['messages'][] = gT('Deleting orphaned quotas.');
return $aData;
Expand Down Expand Up @@ -322,25 +326,21 @@ private function _deleteConditions(array $conditions, array $aData)
*/
protected function _checkintegrity()
{


/*** Plainly delete survey permissions if the survey or user does not exist ***/
$users = User::model()->findAll();
$uids = array();
foreach ($users as $user) $uids[] = $user['uid'];
// Delete survey permissions if the user does not exist
$oCriteria = new CDbCriteria;
$oCriteria->addNotInCondition('uid', $uids, 'OR');

$surveys = Survey::model()->findAll();
$sids = array();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$oCriteria->addNotInCondition('entity_id', $sids, 'OR');
$oCriteria->addCondition("entity='survey'");
$oCriteria->join = 'LEFT JOIN {{users}} u ON {{permissions}}.uid=u.uid';
$oCriteria->condition = '(u.uid IS NULL)';
Permission::model()->deleteAll($oCriteria);

// Delete survey permissions if the survey does not exist
$oCriteria = new CDbCriteria;
$oCriteria->join = 'LEFT JOIN {{surveys}} s ON {{permissions}}.entity_id=s.sid';
$oCriteria->condition = "(s.sid IS NULL AND entity='survey')";
Permission::model()->deleteAll($oCriteria);


// Deactivate surveys that have a missing response table
$surveys = Survey::model()->findAll();
foreach ($surveys as $survey)
{
if ($survey['active']=='Y' && !tableExists("{{survey_{$survey['sid']}}}"))
Expand All @@ -359,6 +359,8 @@ protected function _checkintegrity()
$sDBPrefix = Yii::app()->db->tablePrefix;
$sQuery = dbSelectTablesLike('{{survey}}\_%');
$aResult = dbQueryOrFalse($sQuery);
$sSurveyIDs = Yii::app()->db->createCommand('select sid from {{surveys}}')->queryColumn();

foreach ($aResult->readAll() as $aRow)
{
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
Expand All @@ -367,7 +369,7 @@ protected function _checkintegrity()
if (isset($aTableName[1]) && ctype_digit($aTableName[1]))
{
$iSurveyID = $aTableName[1];
if (!in_array($iSurveyID, $sids)) {
if (!in_array($iSurveyID, $sSurveyIDs)) {
$sDate = date('YmdHis') . rand(1, 1000);
$sOldTable = "survey_{$iSurveyID}";
$sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
Expand All @@ -386,7 +388,7 @@ protected function _checkintegrity()
{
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
$iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1);
if (!in_array($iSurveyID, $sids)) {
if (!in_array($iSurveyID, $sSurveyIDs)) {
$sDate = date('YmdHis') . rand(1, 1000);
$sOldTable = "tokens_{$iSurveyID}";
$sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
Expand Down Expand Up @@ -457,26 +459,19 @@ protected function _checkintegrity()
/**********************************************************************/
/* Check quotas */
/**********************************************************************/
$surveys = Survey::model()->findAll();
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
$sids = array();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$oCriteria = new CDbCriteria;
$oCriteria->addNotInCondition('sid', $sids);

$oCriteria = new CDbCriteria;
$oCriteria->join = 'LEFT JOIN {{surveys}} s ON t.sid=s.sid';
$oCriteria->condition = '(s.sid IS NULL)';
$aDelete['quotas'] = count(Quota::model()->findAll($oCriteria));
if (Quota::model()->hasErrors()) safeDie(Quota::model()->getError());

/**********************************************************************/
/* Check quota languagesettings */
/**********************************************************************/
$quotas = Quota::model()->findAll();
if (Quota::model()->hasErrors()) safeDie(Quota::model()->getError());
$ids = array();
foreach ($quotas as $quota) $ids[] = $quota['id'];
$oCriteria = new CDbCriteria;
$oCriteria->addNotInCondition('quotals_quota_id', $ids);

$oCriteria->join = 'LEFT JOIN {{quota}} s ON t.quotals_quota_id=s.id';
$oCriteria->condition = '(s.id IS NULL)';
$aDelete['quotals'] = count(QuotaLanguageSetting::model()->findAll($oCriteria));
if (QuotaLanguageSetting::model()->hasErrors()) safeDie(QuotaLanguageSetting::model()->getError());

Expand Down Expand Up @@ -563,19 +558,14 @@ protected function _checkintegrity()
}
}


/**********************************************************************/
/* Check survey language settings */
/**********************************************************************/
$surveys = Survey::model()->findAll();
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
$sids = array();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$oCriteria = new CDbCriteria;
$oCriteria->addNotInCondition('surveyls_survey_id', $sids);
$oCriteria->join = 'LEFT JOIN {{surveys}} s ON t.surveyls_survey_id=s.sid';
$oCriteria->condition = '(s.sid IS NULL)';
$surveys_languagesettings = SurveyLanguageSetting::model()->findAll($oCriteria);
if (SurveyLanguageSetting::model()->hasErrors()) safeDie(SurveyLanguageSetting::model()->getError());

foreach ($surveys_languagesettings as $surveys_languagesetting)
{
$aDelete['surveylanguagesettings'][] = array('slid' => $surveys_languagesetting['surveyls_survey_id'], 'reason' => gT('The related survey is missing.'));
Expand All @@ -597,13 +587,11 @@ protected function _checkintegrity()
/**********************************************************************/
/* Check groups */
/**********************************************************************/
$surveys = Survey::model()->findAll();
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
$sids = array();
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$oCriteria = new CDbCriteria;
$oCriteria->addNotInCondition('sid', $sids);
$oCriteria->join = 'LEFT JOIN {{surveys}} s ON t.sid=s.sid';
$oCriteria->condition = '(s.sid IS NULL)';
$groups = QuestionGroup::model()->findAll($oCriteria);
/** @var QuestionGroup $group */
foreach ($groups as $group)
{
$aDelete['groups'][] = array('gid' => $group['gid'], 'reason' => gT('There is no matching survey.') . ' SID:' . $group['sid']);
Expand Down
4 changes: 0 additions & 4 deletions application/controllers/admin/globalsettings.php
Expand Up @@ -80,8 +80,6 @@ private function _displaySettings()
{
$data[$key] = $row;
}
$data['thisupdatecheckperiod'] = getGlobalSetting('updatecheckperiod');
$data['sUpdateNotification'] = getGlobalSetting('updatenotification');
Yii::app()->loadLibrary('Date_Time_Converter');
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
$datetimeobj = new date_time_converter(dateShift(getGlobalSetting("updatelastcheck"),'Y-m-d H:i:s',getGlobalSetting('timeadjust')), 'Y-m-d H:i:s');
Expand Down Expand Up @@ -149,8 +147,6 @@ private function _saveSettings()
setGlobalSetting('defaultlang', $defaultlang);
setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages));
setGlobalSetting('sitename', strip_tags($_POST['sitename']));
setGlobalSetting('updatecheckperiod', (int)($_POST['updatecheckperiod']));
setGlobalSetting('updatenotification', strip_tags($_POST['updatenotification']));
setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode']));
setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode']));
setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode']));
Expand Down
22 changes: 11 additions & 11 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -1475,17 +1475,17 @@ function shareParticipants()
$bCanEdit = Yii::app()->request->getPost('can_edit');

$i = 0;
foreach ($iParticipantId as $iId)
{
$time = time();
$aData = array('participant_id' => $iId,
'share_uid' => $iShareUserId,
'date_added' => date('Y-m-d H:i:s', $time),
'can_edit' => $bCanEdit);
ParticipantShare::model()->storeParticipantShare($aData);
$i++;
}

if (Permission::model()->hasGlobalPermission('participantpanel','update') && $iShareUserId>0)
foreach ($iParticipantId as $iId)
{
$time = time();
$aData = array('participant_id' => $iId,
'share_uid' => $iShareUserId,
'date_added' => date('Y-m-d H:i:s', $time),
'can_edit' => $bCanEdit);
ParticipantShare::model()->storeParticipantShare($aData);
$i++;
}
printf(gT("%s participants have been shared"), $i);
}

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/responses.php
Expand Up @@ -877,7 +877,7 @@ public function actionDelete($iSurveyId,$sResponseId)
Response::model($iSurveyId)->findByPk($iResponseId)->delete(true);
$oSurvey=Survey::model()->findByPk($iSurveyId);
if($oSurvey->savetimings == "Y"){// TODO : add it to response delete (maybe test if timing table exist)
SurveyTimingDynamic::model($iSurveyID)->deleteByPk($iResponseId);
SurveyTimingDynamic::model($iSurveyId)->deleteByPk($iResponseId);
}
}
}
Expand Down
38 changes: 21 additions & 17 deletions application/controllers/admin/update.php
Expand Up @@ -118,9 +118,9 @@ public function checkLocalErrors()
$aData['destinationBuild'] = $destinationBuild;
$aData['access_token'] = $access_token;

return $this->controller->renderPartial('update/updater/steps/_check_local_errors', $aData, false, true);
return $this->controller->renderPartial('update/updater/steps/_check_local_errors', $aData, false, false);
}
return $this->_renderErrorString("unkown_destination_build");
return $this->_renderErrorString("unknown_destination_build");
}

/**
Expand Down Expand Up @@ -152,9 +152,9 @@ public function changeLog()
{
return $this->_renderError($changelog);
}
return $this->controller->renderPartial('update/updater/steps/_change_log', $aData, false, true);
return $this->controller->renderPartial('update/updater/steps/_change_log', $aData, false, false);
}
return $this->_renderErrorString("unkown_destination_build");
return $this->_renderErrorString("unknown_destination_build");
}

/**
Expand Down Expand Up @@ -184,11 +184,11 @@ public function fileSystem()
$aData['updateinfo'] = $changedFiles->files;
$aData['access_token'] = $access_token;

return $this->controller->renderPartial('update/updater/steps/_fileSystem', $aData, false, true);
return $this->controller->renderPartial('update/updater/steps/_fileSystem', $aData, false, false);
}
return $this->_renderError($changedFiles);
}
return $this->_renderErrorString("unkown_destination_build");
return $this->_renderErrorString("unknown_destination_build");
}

/**
Expand Down Expand Up @@ -220,7 +220,7 @@ public function backup()
$aData['datasupdateinfo'] = $this->_parseToView($updateinfos);
$aData['destinationBuild'] = $destinationBuild;
$aData['access_token'] = $access_token;
return $this->controller->renderPartial('update/updater/steps/_backup', $aData, false, true);
return $this->controller->renderPartial('update/updater/steps/_backup', $aData, false, false);

}
else
Expand All @@ -235,7 +235,7 @@ public function backup()
}
else
{
$error = "unkown_destination_build";
$error = "unknown_destination_build";
}
return $this->_renderErrorString($error);
}
Expand Down Expand Up @@ -273,8 +273,12 @@ function step4()
$updateModel->removeTmpFile('update.zip');
$updateModel->removeTmpFile('comfort_updater_cookie.txt');

Yii::app()->session['update_result'] = null;
Yii::app()->session['security_update'] = null;
$next_update_check = null;

// TODO : aData should contains information about each step
return $this->controller->renderPartial('update/updater/steps/_final', array(), false, true);
return $this->controller->renderPartial('update/updater/steps/_final', array(), false, false);
}
else
{
Expand All @@ -298,7 +302,7 @@ function step4()
}
else
{
$error = "unkown_destination_build";
$error = "unknown_destination_build";
}
return $this->_renderErrorString($error);
}
Expand Down Expand Up @@ -327,7 +331,7 @@ public function updateUpdater()
$unzip = $updateModel->unzipUpdateUpdaterFile();
if( $unzip->result )
{
return $this->controller->renderPartial('update/updater/steps/_updater_updated', array('destinationBuild'=>$destinationBuild), false, true);
return $this->controller->renderPartial('update/updater/steps/_updater_updated', array('destinationBuild'=>$destinationBuild), false, false);
}
else
{
Expand All @@ -341,7 +345,7 @@ public function updateUpdater()
}
else
{
return $this->controller->renderPartial('update/updater/welcome/_error_files_update_updater', array('localChecks'=>$localChecks), false, true);
return $this->controller->renderPartial('update/updater/welcome/_error_files_update_updater', array('localChecks'=>$localChecks), false, false);
}

}
Expand Down Expand Up @@ -440,10 +444,10 @@ private function _getButtons($crosscheck)
if( $serverAnswer->result )
{
unset($serverAnswer->result);
return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable', array('updateInfos' => $serverAnswer));
return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable', array('updateInfos' => $serverAnswer), false, false);
}
// Error : we build the error title and messages
return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable_error', array('serverAnswer' => $serverAnswer));
return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable_error', array('serverAnswer' => $serverAnswer), false, false);
}

/**
Expand All @@ -458,7 +462,7 @@ private function _renderWelcome($serverAnswer)
$views = array('welcome', 'subscribe', 'key_updated', 'updater_update');
if( in_array($serverAnswer->view, $views) )
{
return $this->controller->renderPartial('//admin/update/updater/welcome/_'.$serverAnswer->view, array('serverAnswer' => $serverAnswer), false, true);
return $this->controller->renderPartial('//admin/update/updater/welcome/_'.$serverAnswer->view, array('serverAnswer' => $serverAnswer), false, false);
}
else
{
Expand All @@ -478,7 +482,7 @@ private function _renderWelcome($serverAnswer)
*/
private function _renderError($errorObject)
{
echo $this->controller->renderPartial('//admin/update/updater/_error', array('errorObject' => $errorObject), false, true);
echo $this->controller->renderPartial('//admin/update/updater/_error', array('errorObject' => $errorObject), false, false);
}

/**
Expand Down Expand Up @@ -506,4 +510,4 @@ private function _parseToView($updateinfos)
return base64_encode($data);
}

}
}

0 comments on commit 25070fc

Please sign in to comment.