Skip to content

Commit

Permalink
Merge branch 'Yii' of github.com:LimeSurvey/LimeSurvey into Yii
Browse files Browse the repository at this point in the history
  • Loading branch information
dklischies committed May 15, 2012
2 parents 1442f71 + df17ff7 commit f7c172a
Show file tree
Hide file tree
Showing 206 changed files with 684,609 additions and 682,991 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.project
/upload/surveys/*
/styles/gringegreen/images/Thumbs.db
/styles/gringegreen/images/Thumbs.db
/upload/templates/*
12 changes: 10 additions & 2 deletions application/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,23 @@ public function error($message, $url = array())
*/
protected function _sessioncontrol()
{
Yii::import('application.libraries.Limesurvey_lang');
// From personal settings
if (Yii::app()->request->getPost('action') == 'savepersonalsettings') {
Yii::app()->session['adminlang'] = Yii::app()->request->getPost('lang');
if (Yii::app()->request->getPost('lang')=='auto')
{
$sLanguage= getBrowserLanguage();
}
else
{
$sLanguage=Yii::app()->request->getPost('lang');
}
Yii::app()->session['adminlang'] = $sLanguage;
}

if (empty(Yii::app()->session['adminlang']))
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");

Yii::import('application.libraries.Limesurvey_lang');
$this->lang = new Limesurvey_lang(Yii::app()->session['adminlang']);
Yii::app()->setLang($this->lang);

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ private function stepOptionalConfiguration()

//checking DB Connection
if ($this->connection->getActive() == true) {
$this->loadLibrary('admin/sha256','sha256');
$this->loadLibrary('admin/sha256');
$this->sha256 = new SHA256;
$password_hash = $this->sha256->hashing($defaultpass);

Expand Down Expand Up @@ -1200,7 +1200,7 @@ function cmd_install_db()
echo $sError.PHP_EOL;
}

$this->loadLibrary('admin/sha256','sha256');
$this->loadLibrary('admin/sha256');
$this->sha256 = new SHA256;
$sPasswordHash = $this->sha256->hashing(Yii::app()->getConfig('defaultpass'));

Expand Down
5 changes: 2 additions & 3 deletions application/controllers/UploaderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,14 @@ function run()
}
return;
}

$meta = '<script type="text/javascript">
$meta ='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'jquery/jquery.js"></script>';
$meta .= '<script type="text/javascript">
var uploadurl = "'.$this->createUrl('/uploader/index/mode/upload/').'";
var imageurl = "'.Yii::app()->getConfig('imageurl').'/";
var surveyid = "'.$surveyid.'";
var fieldname = "'.$param['fieldname'].'";
var questgrppreview = '.$param['preview'].';
</script>';

$meta .='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.Yii::app()->getConfig("generalscripts").'/uploader.css" rel="stylesheet" />';
Expand Down
10 changes: 8 additions & 2 deletions application/controllers/admin/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,20 @@ private function _setSessionData($user)
*/
private function _setLanguageSettings($user)
{

if (Yii::app()->request->getPost('loginlang') !== 'default')
{
$user->lang = sanitize_languagecode(Yii::app()->request->getPost('loginlang'));
$user->save();
$sLanguage=$user->lang;
}

Yii::app()->session['adminlang'] = $user->lang;
$this->getController()->lang->limesurvey_lang(array('langcode' => $user->lang));
if ($user->lang=='auto')
{
$sLanguage= getBrowserLanguage();
}
Yii::app()->session['adminlang'] = $sLanguage;
$this->getController()->lang= new limesurvey_lang($sLanguage);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function index($sa = null)
if (strlen(Yii::app()->request->getPost('title')) < 1)
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n "
."alert(\"".$clang->gT("The question could not be added. You must enter at least enter a question code.","js")."\")\n "
."alert(\"".$clang->gT("The question could not be added. You must enter at least a question code.","js")."\")\n "
."//-->\n</script>\n";
}
else
Expand Down
27 changes: 27 additions & 0 deletions application/controllers/admin/dataentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ function vvimport()
}
}
}

function iteratesurvey()
{
$aData = array();

$surveyid = sanitize_int(Yii::app()->request->getParam('surveyid'));
if (!empty($_REQUEST['sid'])) {
$surveyid = sanitize_int($_REQUEST['sid']);
}
$aData['surveyid'] = $surveyid;
$aData['clang'] = $this->getController()->lang;
$aData['success'] = false;
if (hasSurveyPermission($surveyid,'surveyactivation','update'))
{
if (Yii::app()->request->getParam('unfinalizeanswers') == 'true')
{
Survey_dynamic::sid($surveyid);
Yii::app()->db->createCommand("DELETE from {{survey_$surveyid}} WHERE submitdate IS NULL AND token in (SELECT * FROM ( SELECT answ2.token from {{survey_$surveyid}} AS answ2 WHERE answ2.submitdate IS NOT NULL) tmp )")->execute();
// Then set all remaining answers to incomplete state
Yii::app()->db->createCommand("UPDATE {{survey_$surveyid}} SET submitdate=NULL, lastpage=NULL")->execute();
// Finally, reset the token completed and sent status
Yii::app()->db->createCommand("UPDATE {{tokens_$surveyid}} SET sent='N', remindersent='N', remindercount=0, completed='N', usesleft=1 where usesleft=0")->execute();
$aData['success']=true;
}
$this->_renderWrappedTemplate('dataentry', 'iteratesurvey', $aData);
}
}

private function _handleFileUpload($surveyid, $aData)
{
Expand Down
15 changes: 14 additions & 1 deletion application/controllers/admin/participantsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,26 @@ function displayParticipants()
{
$aSurveyNames = Surveys_languagesettings::model()->with('survey', 'owner')->findAll('survey.owner_id=:uid AND surveyls_language=:lang',array('survey.uid'=>Yii::app()->session['loginID'], ':lang'=>$lang));
}
//echo "<pre>"; print_r($aSurveyNames); echo "</pre>";
$tSurveyNames=array();
foreach($aSurveyNames as $row)
{
//echo $row['surveyls_survey_id']."<br />";
$bTokenExists = tableExists('{{tokens_' . $row['surveyls_survey_id'] . '}}');
if ($bTokenExists) //If tokens table exists
{
$tSurveyNames[]=$row;
}
}

// data to be passed to view
$aData = array(
'names' => User::model()->findAll(),
'attributes' => ParticipantAttributeNames::getVisibleAttributes(),
'allattributes' => ParticipantAttributeNames::getAllAttributes(),
'attributeValues' => ParticipantAttributeNames::getAllAttributesValues(),
'surveynames' => $aSurveyNames
'surveynames' => $aSurveyNames,
'tokensurveynames' => $tSurveyNames
);

$this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts') . 'jquery/jqGrid/js/i18n/grid.locale-en.js');
Expand Down
31 changes: 29 additions & 2 deletions application/controllers/admin/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ public function index($editfile = 'startpage.pstpl', $screenname = 'welcome', $t
$aViewUrls = $this->_initialise($templatename, $screenname, $editfile);
$this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts') . 'templates.js');
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminscripts') . 'codemirror_ui/lib/CodeMirror-2.0/lib/codemirror.css');
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminscripts') . 'codemirror_ui/lib/CodeMirror-2.0/mode/css/css.css');
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminscripts') . 'codemirror_ui/lib/CodeMirror-2.0/mode/javascript/javascript.css');
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminscripts') . 'codemirror_ui/lib/CodeMirror-2.0/mode/xml/xml.css');
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminscripts') . 'codemirror_ui/css/codemirror-ui.css');


Expand Down Expand Up @@ -272,10 +274,20 @@ public function fileredirect($templatename = 'default', $screenname = 'welcome',
*/
public function templatefiledelete()
{
$clang = $this->getController()->lang;
if (returnGlobal('action') == "templatefiledelete") {
// This is where the temp file is
$the_full_file_path = Yii::app()->getConfig('usertemplaterootdir') . "/" . $_POST['templatename'] . "/" . returnGlobal('otherfile');
unlink($the_full_file_path);
$sFileToDelete=preg_replace("[^\w\s\d\.\-_~,;:\[\]\(\]]", '', returnGlobal('otherfile'));

$the_full_file_path = Yii::app()->getConfig('usertemplaterootdir') . "/" . $_POST['templatename'] . "/" . $sFileToDelete;
if (@unlink($the_full_file_path))
{
Yii::app()->session['flashmessage'] = sprintf($clang->gT("The file %s was deleted."), htmlspecialchars($sFileToDelete));
}
else
{
Yii::app()->session['flashmessage'] = sprintf($clang->gT("File %s couldn't be deleted. Please check the permissions on the /upload/template folder"), htmlspecialchars($sFileToDelete));
}
$this->getController()->redirect($this->getController()->createUrl("admin/templates/view/editfile/" . returnGlobal('editfile') . "/screenname/" . returnGlobal('screenname') . "/templatename/" . returnGlobal('templatename')));
}
}
Expand Down Expand Up @@ -508,6 +520,20 @@ protected function _templatesummary($templatename, $screenname, $editfile, $temp
@fclose($fnew);
}

$sExtension=substr(strrchr($editfile, '.'), 1);
switch ($sExtension)
{
case 'css':$sEditorFileType='css';
break;
case 'pstpl':$sEditorFileType='htmlmixed';
break;
case 'js':$sEditorFileType='javascript';
break;
default: $sEditorFileType='htmlmixed';
break;
}


$aData['clang'] = $this->getController()->lang;
$aData['screenname'] = $screenname;
$aData['editfile'] = $editfile;
Expand All @@ -520,6 +546,7 @@ protected function _templatesummary($templatename, $screenname, $editfile, $temp
$aData['otherfiles'] = $otherfiles;
$aData['tempurl'] = $tempurl;
$aData['time'] = $time;
$aData['sEditorFileType'] = $sEditorFileType;

$aViewUrls['templatesummary_view'][] = $aData;

Expand Down
15 changes: 13 additions & 2 deletions application/controllers/admin/useraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ function usertemplates()
*/
function personalsettings()
{
$clang = Yii::app()->lang;

// Save Data
if (Yii::app()->request->getPost("action")) {
Expand All @@ -601,7 +600,19 @@ function personalsettings()

$uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData);

Yii::app()->session['adminlang'] = Yii::app()->request->getPost('lang');
if (Yii::app()->request->getPost('lang')=='auto')
{
$sLanguage= getBrowserLanguage();
}
else
{
$sLanguage=Yii::app()->request->getPost('lang');
}

Yii::app()->session['adminlang'] = $sLanguage;
Yii::app()->lang=new limesurvey_lang($sLanguage);
$clang = Yii::app()->lang;

Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode');
Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode');
Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode');
Expand Down
15 changes: 12 additions & 3 deletions application/controllers/survey/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function action()


//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid)
if ($surveyid && $surveyExists)
{
$clang = SetSurveyLanguage( $surveyid, $sTempLanguage);
}
Expand Down Expand Up @@ -261,14 +261,23 @@ function action()
$list[]="<li class='surveytitle'>".$clang->gT("No available surveys")."</li>";
}
Yii::app()->loadConfig('email');
if(!$surveyid)
{
$thissurvey['name']=Yii::app()->getConfig("sitename");
$nosid=$clang->gT("You have not provided a survey identification number");
}
else
{
$thissurvey['name']=$clang->gT("The survey identification number is invalid");
$nosid=$clang->gT("The survey identification number is invalid");
}
$surveylist=array(
"nosid"=>$clang->gT("You have not provided a survey identification number"),
"nosid"=>$nosid,
"contact"=>sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),Yii::app()->getConfig("siteadminname"),encodeEmail(Yii::app()->getConfig("siteadminemail"))),
"listheading"=>$clang->gT("The following surveys are available:"),
"list"=>implode("\n",$list),
);

$thissurvey['name'] = Yii::app()->getConfig("sitename");
$thissurvey['templatedir'] = $defaulttemplate;

$data['thissurvey'] = $thissurvey;
Expand Down
2 changes: 1 addition & 1 deletion application/core/LSYii_Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function loadHelper($helper)
*/
public function loadLibrary($library)
{
Yii::import('application.libraries.'.$library.'', true);
Yii::import('application.libraries.'.$library, true);
}

/**
Expand Down
60 changes: 31 additions & 29 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3082,15 +3082,15 @@ function questionAttributes($returnByName=false)
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'text',
"help"=>$clang->gT("Enter the code of a Multiple choice question to only show the matching answer options in this question."),
"help"=>$clang->gT("Enter the code(s) of Multiple choice question(s) (separated by semicolons) to only show the matching answer options in this question."),
"caption"=>$clang->gT('Array filter'));

$qattributes["array_filter_exclude"]=array(
"types"=>"1ABCEF:;MPLKQ",
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'text',
"help"=>$clang->gT("Enter the code of a Multiple choice question to exclude the matching answer options in this question."),
"help"=>$clang->gT("Enter the code(s) of Multiple choice question(s) (separated by semicolons) to exclude the matching answer options in this question."),
"caption"=>$clang->gT('Array filter exclusion'));

$qattributes["assessment_value"]=array(
Expand Down Expand Up @@ -3557,7 +3557,7 @@ function questionAttributes($returnByName=false)
"caption"=>$clang->gT('Integer only'));

$qattributes["numbers_only"]=array(
"types"=>"Q;S",
"types"=>"Q;S*",
'category'=>$clang->gT('Other'),
'sortorder'=>100,
'inputtype'=>'singleselect',
Expand Down Expand Up @@ -7076,25 +7076,6 @@ function getHeader($meta = false)
$languagecode = Yii::app()->getConfig('defaultlang');
}

$js_header = ''; $css_header='';
if(Yii::app()->getConfig("js_admin_includes"))
{
foreach (Yii::app()->getConfig("js_admin_includes") as $jsinclude)
{
if (substr($jsinclude,0,4) == 'http')
$js_header .= "<script type=\"text/javascript\" src=\"{$jsinclude}\"></script>\n";
else
$js_header .= "<script type=\"text/javascript\" src=\"".Yii::app()->baseUrl."{$jsinclude}\"></script>\n";
}
}
if(Yii::app()->getConfig("css_admin_includes"))
{
foreach (Yii::app()->getConfig("css_admin_includes") as $cssinclude)
{
$css_header .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".Yii::app()->baseUrl.$cssinclude."\" />\n";
}
}

if ( !$embedded )
{
$header= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
Expand All @@ -7103,13 +7084,7 @@ function getHeader($meta = false)
{
$header.=" dir=\"rtl\" ";
}
$header.= ">\n\t<head>\n"
. $css_header
. "<script type=\"text/javascript\" src=\"".Yii::app()->getConfig('generalscripts')."jquery/jquery.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"".Yii::app()->getConfig('generalscripts')."jquery/jquery-ui.js\"></script>\n"
. "<link href=\"".Yii::app()->getConfig('generalscripts')."jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. "<link href=\"".Yii::app()->getConfig('generalscripts')."jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. $js_header;
$header.= ">\n\t<head>\n";

if ($meta)
$header .= $meta;
Expand Down Expand Up @@ -7537,4 +7512,31 @@ function getIPAddress()
}
}


/**
* This function tries to find out a valid language code for the language of the browser used
* If it cannot find it it will return the default language from global settings
*
*/
function getBrowserLanguage()
{
$sLanguage=Yii::app()->getRequest()->getPreferredLanguage();
Yii::app()->loadHelper("surveytranslator");
$aLanguages=getLanguageData();
if (!isset($aLanguages[$sLanguage]))
{
$sLanguage=str_replace('_','-',$sLanguage);
if (!isset($aLanguages[$sLanguage]))
{
$sLanguage=substr($sLanguage,0,strpos($sLanguage,'-'));
if (!isset($aLanguages[$sLanguage]))
{
$sLanguage=Yii::app()->getConfig('defaultlang');
}
}
}
return $sLanguage;
}


// Closing PHP tag intentionally omitted - yes, it is okay

0 comments on commit f7c172a

Please sign in to comment.