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
Conflicts:
	application/controllers/admin/export.php
	application/controllers/admin/responses.php
	application/controllers/survey/index.php
	application/core/Survey_Common_Action.php
	application/helpers/admin/activate_helper.php
	application/helpers/admin/exportresults_helper.php
	application/helpers/admin/statistics_helper.php
	application/helpers/common_helper.php
	application/helpers/expressions/em_manager_helper.php
	application/helpers/frontend_helper.php
	application/helpers/qanda_helper.php
	application/helpers/replacements_helper.php
	application/helpers/update/updatedb_helper.php
	installer/sql/create-mssql.sql
	installer/sql/create-mysql.sql
	installer/sql/create-pgsql.sql
  • Loading branch information
aaronschmitz committed Jul 30, 2012
2 parents aaa4828 + 39b5089 commit ed1ae69
Show file tree
Hide file tree
Showing 461 changed files with 45,098 additions and 885,966 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,5 @@
/upload/surveys/*
/styles/gringegreen/images/Thumbs.db
/upload/templates/*

/tmp/runtime/HTML
1 change: 0 additions & 1 deletion application/cache/.htaccess

This file was deleted.

24 changes: 14 additions & 10 deletions application/config/config-defaults.php
Expand Up @@ -306,15 +306,13 @@

/**
* PDF Export Settings
* This feature configures PDF export for Print Answers
* The PDF export is totally experimental. The output is mostly ugly.
* At this point no support can be given - if you want to help to fix it please get in touch with us
* This feature configures PDF export for Export Answers
*/

//$config['pdfdefaultfont'] = 'freemono'; //Default font for the pdf Export
//$config['pdffontsize'] = 9; //Fontsize for normal text; Surveytitle is +4; grouptitle is +2
$config['pdfdefaultfont'] = 'freemono'; //Default font for the pdf Export
$config['pdffontsize'] = 9; //Fontsize for normal text; Surveytitle is +4; grouptitle is +2
$config['notsupportlanguages'] = array('zh-Hant-TW','zh-Hant-HK','zh-Hans','ja','th');
//$config['pdforientation'] = 'P'; // Set L for Landscape or P for portrait format
$config['pdforientation'] = 'P'; // Set L for Landscape or P for portrait format



Expand Down Expand Up @@ -476,13 +474,19 @@
$config['restrictToLanguages'] = '';

/**
* This parameter enables/disables the XML-RPC interface
* Set 1 to enable and 0 to disable
* @var integer
* This parameter enables/disables the RPC interface
* Set to 'json' (for JSON-RPC) )or 'xml' (for XML-RPC) to enable and 'off' to disable
* @var string
*/
$config['enableXMLRPCInterface'] = 0;
$config['RPCInterface'] = 'off';


/**
* This parameter sets the default session expiration time in seconds
* Default is 8 hours
* @var integer
*/
$config['iSessionExpirationTime'] = 28800;

// === Advanced Setup
// The following parameters need information from config.php
Expand Down
2 changes: 1 addition & 1 deletion application/config/email.php
Expand Up @@ -29,7 +29,7 @@
$config['siteadminbounce'] = 'your-email@example.net'; // The default email address used for error notification of sent messages for the site administrator (Return-Path)
$config['siteadminname'] = 'Your Name'; // The name of the site administrator

$config['emailmethod'] = 'sendmail'; // The following values can be used:
$config['emailmethod'] = 'mail'; // The following values can be used:
$config['protocol'] = $config['emailmethod'];
// mail - use internal PHP Mailer
// sendmail - use Sendmail Mailer
Expand Down
4 changes: 2 additions & 2 deletions application/config/tcpdf.php
Expand Up @@ -75,8 +75,8 @@
* ADD TRAILING SLASH!
***********************************************************/

$tcpdf['image_directory'] = Yii::app()->getConfig('imagedir').DIRECTORY_SEPARATOR;

//$tcpdf['image_directory'] = Yii::app()->getConfig('imagedir').DIRECTORY_SEPARATOR;
$tcpdf['image_directory'] = Yii::app()->getConfig('rootdir').DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR.Yii::app()->getConfig('admintheme').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;

/************************************************************
* TCPDF default (blank) image
Expand Down
4 changes: 2 additions & 2 deletions application/config/version.php
Expand Up @@ -12,8 +12,8 @@
*
*/

$config['versionnumber'] = "2.0RC2";
$config['dbversionnumber'] = 158;
$config['versionnumber'] = "2.0RC7";
$config['dbversionnumber'] = 162;
$config['buildnumber'] = '';
$config['updatable'] = false;

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/AdminController.php
Expand Up @@ -181,7 +181,6 @@ public function getActionClasses()
return array(
'assessments' => 'assessments',
'authentication' => 'authentication',
'browse' => 'browse',
'checkintegrity' => 'checkintegrity',
'conditions' => 'conditionsaction',
'database' => 'database',
Expand All @@ -202,6 +201,7 @@ public function getActionClasses()
'questiongroup' => 'questiongroup',
'quotas' => 'quotas',
'remotecontrol' => 'remotecontrol',
'responses' => 'responses',
'saved' => 'saved',
'statistics' => 'statistics',
'survey' => 'surveyadmin',
Expand Down
41 changes: 31 additions & 10 deletions application/controllers/InstallerController.php
Expand Up @@ -184,7 +184,7 @@ private function stepLicense()
public function stepViewLicense()
{
$filename = dirname(BASEPATH) . '/docs/license.txt';
header('Content-Type: text/plain;');
header('Content-Type: text/plain; charset=UTF-8');
readfile($filename);
exit;
}
Expand Down Expand Up @@ -294,7 +294,6 @@ private function stepDatabaseConfiguration()
if ($bDBExists == true) {
try {
$this->connection->createCommand()->select()->from('{{surveys}}')->queryAll();
$bTablesDoNotExist = false;
} catch(Exception $e) {
$bTablesDoNotExist = true;
}
Expand Down Expand Up @@ -703,6 +702,22 @@ function check_HTML_image($result)
return sprintf('<img src="%s/installer/images/tick-%s.png" alt="Found" />', Yii::app()->baseUrl, $label[$result]);
}


function is_writable_recursive($dir)
{
$folder = opendir($dir);
while($file = readdir( $folder ))
if($file != '.' && $file != '..' &&
( !is_writable( $dir."/".$file ) ||
( is_dir( $dir."/".$file ) && !is_writable_recursive( $dir."/".$file ) ) ))
{
closedir($folder);
return false;
}
closedir($folder);
return true;
}

/**
* check for a specific PHPFunction, return HTML image
*
Expand All @@ -727,7 +742,7 @@ function check_PHPFunction($function, &$image)
* @param string $keyError key for error data
* @return bool result of check (that it is writeable which implies existance)
*/
function check_PathWriteable($path, $type, &$data, $base, $keyError)
function check_PathWriteable($path, $type, &$data, $base, $keyError, $bRecursive=false)
{
$result = false;
$data[$base.'Present'] = 'Not Found';
Expand All @@ -745,7 +760,7 @@ function check_PathWriteable($path, $type, &$data, $base, $keyError)
if ($exists)
{
$data[$base.'Present'] = 'Found';
if (is_writable($path))
if ((!$bRecursive && is_writable($path)) || ($bRecursive && is_writable_recursive($path)))
{
$data[$base.'Writable'] = 'Writable';
$result = true;
Expand Down Expand Up @@ -783,9 +798,9 @@ function check_FileWriteable($file, &$data, $base, $keyError)
* @param string $keyError key for error data
* @return bool result of check (that it is writeable which implies existance)
*/
function check_DirectoryWriteable($directory, &$data, $base, $keyError)
function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecursive=false)
{
return check_PathWriteable($directory, 2, $data, $base, $keyError);
return check_PathWriteable($directory, 2, $data, $base, $keyError, $bRecursive);
}

// version check
Expand All @@ -803,11 +818,11 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError)
$bProceed = false;

// templates directory check
if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/templates/', $data, 'templatedir', 'tperror') )
if (!check_DirectoryWriteable(Yii::app()->getConfig('tempdir').'/', $data, 'tmpdir', 'tperror',true) )
$bProceed = false;

//upload directory check
if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/upload/', $data, 'uploaddir', 'uerror') )
if (!check_DirectoryWriteable(Yii::app()->getConfig('uploaddir').'/', $data, 'uploaddir', 'uerror',true) )
$bProceed = false;

// ** optional settings check **
Expand Down Expand Up @@ -947,6 +962,7 @@ function _writeConfigFile()
."*/" ."\n"
. "return array(" . "\n"
."\t" . "'basePath' => dirname(dirname(__FILE__))," . "\n"
."\t" . "'runtimePath' => dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'runtime'," . "\n"
."\t" . "'name' => 'LimeSurvey'," . "\n"
."\t" . "'defaultController' => 'survey'," . "\n"
."\t" . "" . "\n"
Expand All @@ -969,8 +985,13 @@ function _writeConfigFile()
$dbdata .="\t\t\t" . "'username' => '$sDatabaseUser'," . "\n"
."\t\t\t" . "'password' => '$sDatabasePwd'," . "\n"
."\t\t\t" . "'charset' => 'utf8'," . "\n"
."\t\t\t" . "'tablePrefix' => '$sDatabasePrefix'," . "\n"
."\t\t" . ")," . "\n"
."\t\t\t" . "'tablePrefix' => '$sDatabasePrefix'," . "\n";

if (in_array($sDatabaseType, array('mssql', 'sqlsrv'))) {
$dbdata .="\t\t\t" ."'initSQLs'=>array('SET DATEFORMAT ymd;','SET QUOTED_IDENTIFIER ON;')," . "\n";
}

$dbdata .="\t\t" . ")," . "\n"
."\t\t" . "" . "\n"

."\t\t" . "// Uncomment the following line if you need table-based sessions". "\n"
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/OptinController.php
Expand Up @@ -93,7 +93,7 @@ function actionLocal($surveyid, $token, $langcode = '')
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath($defaulttemplate);
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
Expand Down
122 changes: 116 additions & 6 deletions application/controllers/OptoutController.php
Expand Up @@ -23,22 +23,32 @@
*/
class OptoutController extends LSYii_Controller {

function actionLocal($surveyid, $token, $langcode = '')
/* This function is run when opting out of an individual token table. The other function /optout/participants
* opts the user out of ALL survey invitations from the system
*
*
* */
function actiontokens()
{
$surveyid=Yii::app()->request->getQuery('surveyid');
$langcode=Yii::app()->request->getQuery('langcode');
$token=Yii::app()->request->getQuery('token');

Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;

$iSurveyID = $surveyid;
$sToken = $token;
$sToken = sanitize_token($sToken);

if (!$iSurveyID)
if (!$iSurveyID) //IF there is no survey id, redirect back to the default public page
{
$this->redirect($this->getController()->createUrl('/'));
$this->redirect(Yii::app()->getController()->createUrl('/'));
}
$iSurveyID = (int)$iSurveyID;
$iSurveyID = (int)$iSurveyID; //Make sure it's an integer (protect from SQL injects)
//Check that there is a SID
// Get passed language from form, so that we dont loose this!
// Get passed language from form, so that we dont lose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode)
{
$baselang = Survey::model()->findByPk($iSurveyID)->language;
Expand Down Expand Up @@ -86,7 +96,107 @@ function actionLocal($surveyid, $token, $langcode = '')
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath($defaulttemplate);
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
$thistpl=getTemplatePath($thissurvey['templatedir']);
}

$this->_renderHtml($html,$thistpl);
}

/* This function is run when opting out of the participants system. The other function /optout/token
* opts the user out of just a single token/survey invite list
*
*
* */
function actionparticipants()
{
$surveyid=Yii::app()->request->getQuery('surveyid');
$langcode=Yii::app()->request->getQuery('langcode');
$token=Yii::app()->request->getQuery('token');

Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;

$iSurveyID = $surveyid;
$sToken = $token;
$sToken = sanitize_token($sToken);

if (!$iSurveyID) //IF there is no survey id, redirect back to the default public page
{
$this->redirect(Yii::app()->getController()->createUrl('/'));
}
$iSurveyID = (int)$iSurveyID; //Make sure it's an integer (protect from SQL injects)
//Check that there is a SID
// Get passed language from form, so that we dont lose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode)
{
$baselang = Survey::model()->findByPk($iSurveyID)->language;
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($baselang);
}
else
{
$sLanguageCode = sanitize_languagecode($sLanguageCode);
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($sLanguageCode);
$baselang = $sLanguageCode;
}

Yii::app()->lang = $clang;

$thissurvey=getSurveyInfo($iSurveyID,$baselang);

if ($thissurvey==false || !tableExists("{{tokens_{$iSurveyID}}}")){
$html = $clang->gT('This survey does not seem to exist.');
}
else
{
$row = Tokens_dynamic::getEmailStatus($iSurveyID, $sToken);
$datas = Tokens_dynamic::model($iSurveyID)->find('token = :token', array(":token"=>$sToken));

if ($row == false)
{
$html = $clang->gT('You are not a participant in this survey.');
}
else
{
$usresult = $row['emailstatus'];
if ($usresult == 'OK')
{
$usresult = Tokens_dynamic::updateEmailStatus($iSurveyID, $sToken, 'OptOut');
$html = $clang->gT('You have been successfully removed from this survey.');
}
else
{
$html = $clang->gT('You have been already removed from this survey.');
}
if(!empty($datas->participant_id) && $datas->participant_id != "")
{
//Participant also exists in central db
$cpdb = Participants::model()->find('participant_id = :participant_id', array(":participant_id"=>$datas->participant_id));
if($cpdb->blacklisted=="Y")
{
$html .= "<br />";
$html .= $clang->gt("You have already been removed from the central participants list for this site");
} else
{
$cpdb->blacklisted='Y';
$cpdb->save();
$html .= "<br />";
$html .= $clang->gT("You have been removed from the central participants list for this site");
}
}
}
}

//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/RegisterController.php
Expand Up @@ -29,9 +29,9 @@ function actionAJAXRegisterForm
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('replacements');
$redata = compact(array_keys(get_defined_vars()));
$thistpl = Yii::app()->getConfig("standardtemplaterootdir").'/default';
$surveyid = sanitize_int($surveyid);
$row = Survey::model()->find('sid=:sid',array(':sid' => $surveyid)) or show_error("Can't find survey data");
$thistpl=getTemplatePath(validateTemplateDir($row->template));
$data['sid'] = $surveyid;
$data['startdate'] = $row->startdate;
$data['enddate'] = $row->expires;
Expand Down

0 comments on commit ed1ae69

Please sign in to comment.