mirror of
https://github.com/YunoHost-Apps/limesurvey_ynh.git
synced 2024-09-03 19:36:32 +02:00
[enh] Update sources with limesurvey205plus-build150520.zip
This commit is contained in:
parent
f3f9db0088
commit
406e39e8c7
609 changed files with 45003 additions and 72298 deletions
|
@ -1,11 +0,0 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
|
||||
# if a directory or a file exists, use it directly
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
|
||||
# otherwise forward it to index.php
|
||||
RewriteRule . index.php
|
||||
</IfModule>
|
||||
# General setting to properly handle LimeSurvey paths
|
||||
# AcceptPathInfo on
|
|
@ -1,11 +0,0 @@
|
|||
filter:
|
||||
excluded_paths: [framework/*, locale/*, docs/*, fonts/*, third_party/*, application/third_party/*, images/*, styles/*, styles-public/*, templates/*, themes/*, tmp/*, upload/*]
|
||||
paths: [application/*]
|
||||
tools:
|
||||
php_code_sniffer:
|
||||
config:
|
||||
standard: "PSR1"
|
||||
php_pdepend:
|
||||
command: pdepend
|
||||
php_cs_fixer:
|
||||
config: { level: psr1 }
|
|
@ -41,9 +41,6 @@
|
|||
$sql_file = 'mysql';
|
||||
break;
|
||||
case 'pgsql':
|
||||
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
|
||||
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($this->getDBConnectionStringProperty('dbname')) ." SET bytea_output='escape';")->execute();
|
||||
}
|
||||
$sql_file = 'pgsql';
|
||||
break;
|
||||
case 'dblib':
|
||||
|
@ -52,7 +49,7 @@
|
|||
$sql_file = 'mssql';
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf('Unkown database type "%s".', $this->connection->driverName));
|
||||
throw new Exception(sprintf('Unknown database type "%s".', $this->connection->driverName));
|
||||
}
|
||||
$this->_executeSQLFile(dirname(Yii::app()->basePath).'/installer/sql/create-'.$sql_file.'.sql');
|
||||
$this->connection->createCommand()->insert($this->connection->tablePrefix.'users', array(
|
||||
|
@ -130,10 +127,12 @@
|
|||
|
||||
protected function createDatabase()
|
||||
{
|
||||
App()->configure(array('components'=>array('db'=>array('autoConnect'=>false)))) ;
|
||||
$this->connection=App()->db;
|
||||
App()->configure(array('components'=>array('db'=>array('autoConnect'=>true)))) ;
|
||||
$connectionString = $this->connection->connectionString;
|
||||
$this->connection->connectionString = preg_replace('/dbname=([^;]*)/', '', $connectionString);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$this->connection->active=true;
|
||||
}
|
||||
catch(Exception $e){
|
||||
|
|
|
@ -68,10 +68,8 @@ $config['minrepeatheadings'] = 3; // The minimum number of rem
|
|||
$config['defaultlang'] = 'en'; // The default language to use - the available languages are the directory names in the /locale dir - for example de = German
|
||||
|
||||
$config['timeadjust'] = 0; // Number of hours to adjust between your webserver local time and your own local time (for datestamping responses)
|
||||
$config['allowexportalldb'] = 1; // 0 will only export prefixed tables when doing a database dump. If set to 1 ALL tables in the database will be exported
|
||||
$config['allowexportalldb'] = 0; // 0 will only export prefixed tables when doing a database dump. If set to 1 ALL tables in the database will be exported
|
||||
$config['maxdumpdbrecords'] = 500; // The maximum number of records that would be ouputted in a go during a database backup. Reduce this number if you're getting errors while backing up the entire database.
|
||||
$config['allowmandbackwards'] = 1; // Allow moving backwards (ie: << prev) through survey if a mandatory question
|
||||
// has not been answered. 1=Allow, 0=Deny
|
||||
$config['deletenonvalues'] = 1; // By default, LimeSurvey does not save responses to conditional questions that haven't been answered/shown. To have LimeSurvey save these responses change this value to 0.
|
||||
$config['stringcomparizonoperators'] = 0; // By default, LimeSurvey assumes the numrical order for comparizon operators in conditions. If you need string comparizon operators, set this parameter to 1
|
||||
$config['shownoanswer'] = 1; // Show 'no answer' for non mandatory questions ( 0 = no , 1 = yes , 2 = survey admin can choose )
|
||||
|
@ -84,11 +82,11 @@ $config['allowunblacklist'] = 'N'; // Allow participant to unbl
|
|||
$config['userideditable'] = 'N'; // Allow editing of user IDs
|
||||
$config['defaulttemplate'] = 'default'; // This setting specifys the default theme used for the 'public list' of surveys
|
||||
|
||||
$config['allowedtemplateuploads'] = 'gif,ico,jpg,png,css,js'; // File types allowed to be uploaded in the templates section.
|
||||
$config['allowedtemplateuploads'] = 'gif,ico,jpg,png,css,js,map,json,eot,svg,ttf,woff,txt,md'; // File types allowed to be uploaded in the templates section.
|
||||
|
||||
$config['allowedresourcesuploads'] = '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,ico,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,xml,zip,pstpl,css,js'; // File types allowed to be uploaded in the resources sections, and with the HTML Editor
|
||||
|
||||
$config['memory_limit'] = '32'; // This sets how much memory LimeSurvey can access in megabytes. 32 mb is the minimum recommended - if you are using PDF functions up to 64 mb may be needed
|
||||
$config['memory_limit'] = '128'; // This sets how much memory LimeSurvey can access in megabytes. 128 MB is the minimum recommended - if you are using PDF functions up to 256 MB may be needed
|
||||
|
||||
$config['showpopups'] = 1; // Show popup messages if mandatory or conditional questions have not been answered correctly.
|
||||
// 1=Show popup message, 0=Show message on page instead.
|
||||
|
@ -237,15 +235,15 @@ $config['usercontrolSameGroupPolicy'] = true;
|
|||
$config['demoMode'] = false;
|
||||
|
||||
/**
|
||||
* Prefill the login mask using the parameters 'defaultuser' and 'default pass'. This works only if demo mode (demoMode) is activated.
|
||||
* Prefill the login mask using the parameters 'defaultuser' and 'default pass'. This works only if demo mode (demoMode) is activated.
|
||||
* Also a notice will be shown that the user knows that he can just login by using the Login button.
|
||||
*
|
||||
*
|
||||
* @var $config['demoModePrefill'] boolan If set to true prefill the login mask
|
||||
*/
|
||||
$config['demoModePrefill'] = false;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* column_style
|
||||
* Because columns are tricky things, in terms of balancing visual
|
||||
* layout against semantic markup. The choice has been left to the
|
||||
|
@ -312,15 +310,22 @@ $config['standard_templates_readonly'] = true;
|
|||
$config['showsgqacode'] = false;
|
||||
|
||||
/**
|
||||
* When this settings is true/1 (default = false/0) then the printable survey option will show
|
||||
* When this settings is true/1 (default = false/0) then the printable survey option will show
|
||||
* the raw relevance equation below the general fill-out instructions in case the question has conditions.
|
||||
*/
|
||||
$config['showrelevance'] = false;
|
||||
|
||||
/**
|
||||
* To prevent brute force against forgotten password functionality, there is a random delay
|
||||
* that prevent attacker from knowing whether username and email address are valid or not.
|
||||
*/
|
||||
$config['minforgottenpasswordemaildelay'] = 500000;
|
||||
$config['maxforgottenpasswordemaildelay'] = 1500000;
|
||||
|
||||
/**
|
||||
* PDF Export Settings
|
||||
* This feature configures PDF export for Export Answers
|
||||
* PDF core fonts are not included in PDF: make ligther pdf
|
||||
* PDF core fonts are not included in PDF: make ligther pdf
|
||||
* See http://www.tcpdf.org/fonts.php to have the list of PDF core fonts
|
||||
*/
|
||||
|
||||
|
@ -334,14 +339,15 @@ $config['alternatepdffontfile']=array(
|
|||
'ar'=>'dejavusans',// 'dejavusans' work but maybe more characters in aealarabiya or almohanad: but then need a dynamic font size too
|
||||
'be'=>'dejavusans',
|
||||
'bg'=>'dejavusans',
|
||||
'zh-Hans'=>'chinese',
|
||||
'zh-Hant-HK'=>'chinese',
|
||||
'zh-Hant-TW'=>'chinese',
|
||||
'zh-Hans'=>'cid0cs',
|
||||
'zh-Hant-HK'=>'cid0ct',
|
||||
'zh-Hant-TW'=>'cid0ct',
|
||||
'cs'=>'dejavusans',
|
||||
'cs-informal'=>'dejavusans',// This one not really tested: no translation for Yes/No or Gender
|
||||
'el'=>'dejavusans',
|
||||
'he'=>'freesans',
|
||||
'hi'=>'dejavusans',
|
||||
'hr'=>'dejavusans',
|
||||
'hu'=>'dejavusans',
|
||||
'ja'=>'cid0jp',
|
||||
'ko'=>'cid0kr',
|
||||
|
@ -367,27 +373,19 @@ $config['notsupportlanguages'] = array(
|
|||
);
|
||||
$config['pdffontsize'] = 9; //Fontsize for normal text; Surveytitle is +4; grouptitle is +2
|
||||
$config['pdforientation'] = 'P'; // Set L for Landscape or P for portrait format
|
||||
$config['pdfshowheader'] = 'N'; // Show header in pdf answer export
|
||||
$config['pdflogofile'] = 'logo_pdf.png'; // File name of logo for single answer export. Path is template path, i.e. template/default/logo_pdf.png.
|
||||
// If not found, resulting pdf doesn't have header. A large image implies slower pdf generation.
|
||||
$config['pdflogowidth'] = '50'; // Logo width
|
||||
$config['pdfheadertitle'] = ''; // Header title (bold font). If this config param is empty and header is enabled, site name is used
|
||||
$config['pdfheaderstring'] = ''; // Header string (under title). If this config param is empty and header is enabled, survey name is used
|
||||
|
||||
// QueXML-PDF: If set to true, the printable_help attribute will be visible on the exported PDF questionnaires
|
||||
// If used, the appearance (font size, justification, etc.) may be adjusted by editing td.questionHelpBefore and $helpBeforeBorderBottom of quexml.
|
||||
$config['quexmlshowprintablehelp'] = false;
|
||||
|
||||
// CAS Settings
|
||||
/**
|
||||
* Please note that CAS functionality is very basic and you have to modify the client to your needs.
|
||||
* At least the hard work is done.
|
||||
* The Client is deployed in Limesurvey and a file login_check_cas.php does what login_check.php does in normal mode.
|
||||
*
|
||||
* $casEnabled determines if CAS should be used or not for Authentication.
|
||||
* $casAuthServer the servername of the cas Auth Server. Without http://
|
||||
* $casAuthPort CAS Server listening Port
|
||||
* $casAuthUri relative uri from $casAuthServer to cas workingdirectory
|
||||
*/
|
||||
$config['casEnabled'] = false;
|
||||
$config['casAuthServer'] = 'localhost';
|
||||
$config['casAuthPort'] = 8443;
|
||||
$config['casAuthUri'] = '/cas-server/';
|
||||
|
||||
$config['minlengthshortimplode'] = 20; // Min length required to use short_implode instead of standard implode
|
||||
$config['maxstringlengthshortimplode'] = 100; // short_implode: Max length of returned string
|
||||
|
||||
/**
|
||||
* Statistics chart settings
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
|
|
||||
*/
|
||||
return array(
|
||||
'name' => 'LimeSurvey',
|
||||
'components' => array(
|
||||
'db' => array(
|
||||
'connectionString' => 'mysql:host=localhost;port=3306;dbname=limesurvey',
|
||||
'connectionString' => 'mysql:host=localhost;port=3306;dbname=limesurvey;',
|
||||
'emulatePrepare' => true,
|
||||
'username' => 'root',
|
||||
'password' => '',
|
||||
|
|
|
@ -18,6 +18,7 @@ $route['<_sid:\d+>/lang-<_lang:\w+[-\w]+>/tk-<_token:\w+>/*'] = "survey/index/si
|
|||
$route['<_sid:\d+>/lang-<_lang:\w+[-\w]+>/*'] = "survey/index/sid/<_sid>/lang/<_lang>";
|
||||
$route['<_sid:\d+>/tk-<_token:\w+>/*'] = "survey/index/sid/<_sid>/token/<_token>";
|
||||
$route['<_sid:\d+>/*'] = "survey/index/sid/<_sid>";
|
||||
$route['<sid:\d+>'] = array('survey/index','matchValue'=>true);
|
||||
|
||||
//Admin Routes
|
||||
$route['admin/index'] = "admin";
|
||||
|
@ -28,12 +29,15 @@ $route['admin/<action:\w+>/<sa:\w+>/*'] = 'admin/<action>/sa/<sa>';
|
|||
$route['admin/labels/<_action:\w+>'] = "admin/labels/index/<_action>";
|
||||
$route['admin/labels/<_action:\w+>/<_lid:\d+>'] = "admin/labels/index/<_action>/<_lid>";
|
||||
|
||||
$route['<_controller:\w+>/<_action:\w+>'] = '<_controller>/<_action>';
|
||||
|
||||
//Expression Manager tests
|
||||
$route['admin/expressions'] = "admin/expressions/index";
|
||||
|
||||
//optout
|
||||
//optout - optin
|
||||
$route['optout/<_sid:\d+>/(:any)/(:any)'] = "optout/index/<_sid>/$2/$3";
|
||||
$route['optout/tokens/<surveyid:\d+>'] = array('optout/tokens','matchValue'=>true);
|
||||
$route['optin/tokens/<surveyid:\d+>'] = array('optin/tokens','matchValue'=>true);
|
||||
$route['statistics_user/<surveyid:\d+>'] = array('statistics_user/action','matchValue'=>true);
|
||||
|
||||
return $route;
|
||||
$route['<_controller:\w+>/<_action:\w+>'] = '<_controller>/<_action>';
|
||||
|
||||
return $route;
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
* ADD TRAILING SLASH!
|
||||
***********************************************************/
|
||||
|
||||
$tcpdf['base_url'] = '';
|
||||
$tcpdf['base_url'] = 'dummy'; // If empty and debug === 2, "empty needle" occurs
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
@ -97,15 +97,6 @@
|
|||
$tcpdf['blank_image'] = $tcpdf['image_directory'].'_blank.png';
|
||||
|
||||
|
||||
/************************************************************
|
||||
* TCPDF language settings file
|
||||
* ----------------------------------------------------------
|
||||
* Directory and filename of the language settings file
|
||||
***********************************************************/
|
||||
|
||||
$tcpdf['language_file'] = $tcpdf['base_directory'].'config'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'eng.php';
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* DOCUMENT CONFIGURATION PARAMETERS
|
||||
|
@ -203,8 +194,11 @@
|
|||
* HTML <small> font size ratio
|
||||
***********************************************************/
|
||||
|
||||
$tcpdf['page_font'] = 'freemono';
|
||||
$tcpdf['page_font'] = 'freesans';
|
||||
$tcpdf['page_font_size'] = 9;
|
||||
$tcpdf['data_font'] = 'freesans';
|
||||
$tcpdf['data_font_size'] = 8;
|
||||
$tcpdf['mono_font'] = 'freemono';
|
||||
|
||||
$tcpdf['small_font_ratio'] = 2/3;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
*/
|
||||
|
||||
$config['versionnumber'] = "2.05+";
|
||||
$config['dbversionnumber'] = 177;
|
||||
$config['buildnumber'] = '';
|
||||
$config['dbversionnumber'] = 178;
|
||||
$config['buildnumber'] = '150520';
|
||||
$config['updatable'] = true;
|
||||
|
||||
return $config;
|
||||
|
|
|
@ -47,6 +47,7 @@ class InstallerController extends CController {
|
|||
{
|
||||
self::_checkInstallation();
|
||||
self::_sessioncontrol();
|
||||
Yii::import('application.helpers.common_helper', true);
|
||||
|
||||
switch ($action) {
|
||||
|
||||
|
@ -237,6 +238,13 @@ class InstallerController extends CController {
|
|||
$aData['classesForStep'] = array('off','off','off','on','off','off');
|
||||
$aData['progressValue'] = 40;
|
||||
$aData['model'] = $oModel = new InstallerConfigForm;
|
||||
if (isset(Yii::app()->session['populateerror']))
|
||||
{
|
||||
$oModel->addError('dblocation',Yii::app()->session['populateerror']);
|
||||
$oModel->addError('dbpwd','');
|
||||
$oModel->addError('dbuser','');
|
||||
unset(Yii::app()->session['populateerror']);
|
||||
}
|
||||
|
||||
if(isset($_POST['InstallerConfigForm']))
|
||||
{
|
||||
|
@ -461,7 +469,7 @@ class InstallerController extends CController {
|
|||
$bCreateDB=false;
|
||||
}
|
||||
break;
|
||||
case 'postgres':
|
||||
case 'pgsql':
|
||||
try
|
||||
{
|
||||
$this->connection->createCommand("CREATE DATABASE \"$sDatabaseName\" ENCODING 'UTF8'")->execute();
|
||||
|
@ -547,7 +555,7 @@ class InstallerController extends CController {
|
|||
case 'mysql':
|
||||
$sql_file = 'mysql';
|
||||
break;
|
||||
case 'dblib':
|
||||
case 'dblib':
|
||||
case 'sqlsrv':
|
||||
case 'mssql':
|
||||
$sql_file = 'mssql';
|
||||
|
@ -556,7 +564,7 @@ class InstallerController extends CController {
|
|||
$sql_file = 'pgsql';
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf('Unkown database type "%s".', $sDatabaseType));
|
||||
throw new Exception(sprintf('Unknown database type "%s".', $sDatabaseType));
|
||||
}
|
||||
|
||||
//checking DB Connection
|
||||
|
@ -575,12 +583,15 @@ class InstallerController extends CController {
|
|||
}
|
||||
else
|
||||
{
|
||||
$sConfirmation = $clang->gT('Database was populated but there were errors:').'<p><ul>';
|
||||
$sConfirmation = $clang->gT('There were errors when trying to populate the database:').'<p><ul>';
|
||||
foreach ($aErrors as $sError)
|
||||
{
|
||||
$sConfirmation.='<li>'.htmlspecialchars($sError).'</li>';
|
||||
}
|
||||
$sConfirmation.='</ul>';
|
||||
Yii::app()->session['populateerror']=$sConfirmation;
|
||||
|
||||
$this->redirect(array('installer/database'));
|
||||
}
|
||||
|
||||
Yii::app()->session['tablesexist'] = true;
|
||||
|
@ -617,7 +628,7 @@ class InstallerController extends CController {
|
|||
$sDefaultAdminRealName = $model->adminName;
|
||||
$sDefaultSiteName = $model->siteName;
|
||||
$sDefaultSiteLanguage = $model->surveylang;
|
||||
$sDefaultAdminEmail = $model->adminEmail;
|
||||
$sDefaultAdminEmail = $model->adminEmail;
|
||||
|
||||
$aData['title'] = $clang->gT("Database configuration");
|
||||
$aData['descp'] = $clang->gT("Please enter the database settings you want to use for LimeSurvey:");
|
||||
|
@ -631,8 +642,16 @@ class InstallerController extends CController {
|
|||
if ($this->connection->getActive() == true) {
|
||||
$sPasswordHash=hash('sha256', $sDefaultAdminPassword);
|
||||
try {
|
||||
|
||||
if (User::model()->count()>0){
|
||||
die();
|
||||
}
|
||||
// Save user
|
||||
$user=new User;
|
||||
// Fix UserID to 1 for MySQL even if installed in master-master configuration scenario
|
||||
if (in_array($this->connection->getDriverName(), array('mysql', 'mysqli'))) {
|
||||
$user->uid=1;
|
||||
}
|
||||
$user->users_name=$sDefaultAdminUserName;
|
||||
$user->password=$sPasswordHash;
|
||||
$user->full_name=$sDefaultAdminRealName;
|
||||
|
@ -835,10 +854,10 @@ class InstallerController extends CController {
|
|||
if (version_compare(PHP_VERSION, '5.3.0', '<'))
|
||||
$bProceed = !$aData['verror'] = true;
|
||||
|
||||
if ($this->return_bytes(ini_get('memory_limit'))/1024/1024<64 && ini_get('memory_limit')!=-1)
|
||||
if (convertPHPSizeToBytes(ini_get('memory_limit'))/1024/1024<64 && ini_get('memory_limit')!=-1)
|
||||
$bProceed = !$aData['bMemoryError'] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
// mbstring library check
|
||||
if (!check_PHPFunction('mb_convert_encoding', $aData['mbstringPresent']))
|
||||
$bProceed = false;
|
||||
|
@ -904,16 +923,15 @@ class InstallerController extends CController {
|
|||
function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
|
||||
{
|
||||
extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
|
||||
switch ($sDatabaseType) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
|
||||
break;
|
||||
case 'pgsql':
|
||||
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
|
||||
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." SET bytea_output='escape';")->execute();
|
||||
}
|
||||
break;
|
||||
try{
|
||||
switch ($sDatabaseType) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
|
||||
break;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
return array($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
|
||||
|
@ -1052,7 +1070,7 @@ class InstallerController extends CController {
|
|||
|
||||
$sConfig .="\t\t" . ")," . "\n"
|
||||
."\t\t" . "" . "\n"
|
||||
|
||||
|
||||
."\t\t" . "// Uncomment the following line if you need table-based sessions". "\n"
|
||||
."\t\t" . "// 'session' => array (" . "\n"
|
||||
."\t\t\t" . "// 'class' => 'system.web.CDbHttpSession'," . "\n"
|
||||
|
@ -1133,7 +1151,7 @@ class InstallerController extends CController {
|
|||
case 'mysql':
|
||||
case 'mysqli':
|
||||
// MySQL allow unix_socket for database location, then test if $sDatabaseLocation start with "/"
|
||||
if(substr($sDatabaseLocation,0,1)=="/")
|
||||
if(substr($sDatabaseLocation,0,1)=="/")
|
||||
$sDSN = "mysql:unix_socket={$sDatabaseLocation};dbname={$sDatabaseName};";
|
||||
else
|
||||
$sDSN = "mysql:host={$sDatabaseLocation};port={$sDatabasePort};dbname={$sDatabaseName};";
|
||||
|
@ -1153,7 +1171,7 @@ class InstallerController extends CController {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'dblib' :
|
||||
case 'dblib' :
|
||||
$sDSN = $sDatabaseType.":host={$sDatabaseLocation};dbname={$sDatabaseName}";
|
||||
break;
|
||||
case 'mssql' :
|
||||
|
@ -1238,33 +1256,12 @@ class InstallerController extends CController {
|
|||
return true;
|
||||
} catch(Exception $e) {
|
||||
if (!empty($aData['model']) && !empty($aData['clang'])) {
|
||||
$aData['model']->addError('dblocation', $aData['clang']->gT('Try again! Connection with database failed. Reason: ') . $e->message);
|
||||
$aData['model']->addError('dblocation', $aData['clang']->gT('Try again! Connection with database failed. Reason: ') . $e->getMessage());
|
||||
$this->render('/installer/dbconfig_view', $aData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the full number from a PHP ini value
|
||||
*
|
||||
* @param string $sValue
|
||||
*/
|
||||
function return_bytes($sValue) {
|
||||
$sValue = trim($sValue);
|
||||
$sLast = strtolower($sValue[strlen($sValue)-1]);
|
||||
switch($sLast) {
|
||||
// The 'G' modifier is available since PHP 5.1.0
|
||||
case 'g':
|
||||
$sValue *= 1024;
|
||||
case 'm':
|
||||
$sValue *= 1024;
|
||||
case 'k':
|
||||
$sValue *= 1024;
|
||||
}
|
||||
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class OptoutController extends LSYii_Controller {
|
|||
}
|
||||
else
|
||||
{
|
||||
if ($oToken->emailstatus == 'OK')
|
||||
if (substr($oToken->emailstatus, 0, strlen('OptOut')) !== 'OptOut')
|
||||
{
|
||||
$oToken->emailstatus = 'OptOut';
|
||||
$oToken->save();
|
||||
|
@ -148,7 +148,7 @@ class OptoutController extends LSYii_Controller {
|
|||
}
|
||||
else
|
||||
{
|
||||
if ($oToken->emailstatus == 'OK')
|
||||
if (substr($oToken->emailstatus, 0, strlen('OptOut')) !== 'OptOut')
|
||||
{
|
||||
$oToken->emailstatus = 'OptOut';
|
||||
$oToken->save();
|
||||
|
@ -166,7 +166,8 @@ class OptoutController extends LSYii_Controller {
|
|||
{
|
||||
$sMessage .= "<br />";
|
||||
$sMessage .= $clang->gT("You have already been removed from the central participants list for this site");
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
$oParticipant->blacklisted='Y';
|
||||
$oParticipant->save();
|
||||
|
|
|
@ -95,15 +95,19 @@ class PluginsController extends LSYii_Controller
|
|||
$this->forward('plugins/index', true);
|
||||
}
|
||||
|
||||
// Prepare settings to be send to the view.
|
||||
$aSettings = $oPluginObject->getPluginSettings();
|
||||
|
||||
if (empty($aSettings))
|
||||
{
|
||||
// And show a message
|
||||
Yii::app()->user->setFlash('pluginmanager', 'This plugin has no settings');
|
||||
$this->forward('plugins/index', true);
|
||||
}
|
||||
$this->render('/plugins/configure', array('settings' => $aSettings, 'plugin' => $arPlugin));
|
||||
|
||||
// Send to view plugin porperties: name and description
|
||||
$aPluginProp = App()->getPluginManager()->getPluginInfo($arPlugin['name']);
|
||||
|
||||
$this->render('/plugins/configure', array('settings' => $aSettings, 'plugin' => $arPlugin, 'properties' => $aPluginProp));
|
||||
}
|
||||
|
||||
public function actionDeactivate($id)
|
||||
|
|
|
@ -91,104 +91,130 @@
|
|||
$sSRID = $_SESSION['survey_'.$iSurveyID]['srid']; //I want to see the answers with this id
|
||||
//Ensure script is not run directly, avoid path disclosure
|
||||
//if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
|
||||
if ($aSurveyInfo['printanswers'] == 'N')
|
||||
|
||||
//Ensure Participants printAnswer setting is set to true or that the logged user have read permissions over the responses.
|
||||
if ($aSurveyInfo['printanswers'] == 'N' && !Permission::model()->hasSurveyPermission($iSurveyID,'responses','read'))
|
||||
{
|
||||
die(); //Die quietly if print answers is not permitted
|
||||
throw new CHttpException(401, 'You are not allowed to print answers.');
|
||||
}
|
||||
|
||||
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
|
||||
$sSurveyName = $aSurveyInfo['surveyls_title'];
|
||||
$sAnonymized = $aSurveyInfo['anonymized'];
|
||||
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
|
||||
//SHOW HEADER
|
||||
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post')
|
||||
."<center><input type='submit' value='".$clang->gT("PDF export")."'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
|
||||
if($sExportType == 'pdf')
|
||||
if ($sExportType != 'pdf')
|
||||
{
|
||||
//require (Yii::app()->getConfig('rootdir').'/application/config/tcpdf.php');
|
||||
Yii::import('application.libraries.admin.pdf', true);
|
||||
Yii::import('application.helpers.pdfHelper');
|
||||
$aPdfLanguageSettings=pdfHelper::getPdfLanguageSettings($clang->langcode);
|
||||
$oPDF = new pdf();
|
||||
$oPDF->SetTitle($clang->gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
|
||||
$oPDF->SetSubject($sSurveyName);
|
||||
$oPDF->SetDisplayMode('fullpage', 'two');
|
||||
$oPDF->setLanguageArray($aPdfLanguageSettings['lg']);
|
||||
$oPDF->setHeaderFont(Array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_MAIN));
|
||||
$oPDF->setFooterFont(Array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_DATA));
|
||||
$oPDF->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
|
||||
$oPDF->AddPage();
|
||||
$oPDF->titleintopdf($clang->gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
|
||||
}
|
||||
$sOutput .= "\t<div class='printouttitle'><strong>".$clang->gT("Survey name (ID):")."</strong> $sSurveyName ($iSurveyID)</div><p> \n";
|
||||
LimeExpressionManager::StartProcessingPage(true); // means that all variables are on the same page
|
||||
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
|
||||
LimeExpressionManager::StartProcessingGroup(1,($aSurveyInfo['anonymized']!="N"),$iSurveyID);
|
||||
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
|
||||
$aFullResponseTable = getFullResponseTable($iSurveyID,$sSRID,$sLanguage,$printanswershonorsconditions);
|
||||
//Get the fieldmap @TODO: do we need to filter out some fields?
|
||||
if($aSurveyInfo['datestamp']!="Y" || $sAnonymized == 'Y'){
|
||||
unset ($aFullResponseTable['submitdate']);
|
||||
}else{
|
||||
unset ($aFullResponseTable['id']);
|
||||
}
|
||||
unset ($aFullResponseTable['token']);
|
||||
unset ($aFullResponseTable['lastpage']);
|
||||
unset ($aFullResponseTable['startlanguage']);
|
||||
unset ($aFullResponseTable['datestamp']);
|
||||
unset ($aFullResponseTable['startdate']);
|
||||
$sOutput .= "<table class='printouttable' >\n";
|
||||
foreach ($aFullResponseTable as $sFieldname=>$fname)
|
||||
{
|
||||
if (substr($sFieldname,0,4) == 'gid_')
|
||||
{
|
||||
|
||||
|
||||
$sOutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
|
||||
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post')
|
||||
."<center><input type='submit' value='".$clang->gT("PDF export")."'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
|
||||
$sOutput .= "\t<div class='printouttitle'><strong>".$clang->gT("Survey name (ID):")."</strong> $sSurveyName ($iSurveyID)</div><p> \n";
|
||||
LimeExpressionManager::StartProcessingPage(true); // means that all variables are on the same page
|
||||
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
|
||||
LimeExpressionManager::StartProcessingGroup(1,($aSurveyInfo['anonymized']!="N"),$iSurveyID);
|
||||
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
|
||||
$aFullResponseTable = getFullResponseTable($iSurveyID,$sSRID,$sLanguage,$printanswershonorsconditions);
|
||||
//Get the fieldmap @TODO: do we need to filter out some fields?
|
||||
if($aSurveyInfo['datestamp']!="Y" || $sAnonymized == 'Y'){
|
||||
unset ($aFullResponseTable['submitdate']);
|
||||
}else{
|
||||
unset ($aFullResponseTable['id']);
|
||||
}
|
||||
elseif (substr($sFieldname,0,4)=='qid_')
|
||||
unset ($aFullResponseTable['token']);
|
||||
unset ($aFullResponseTable['lastpage']);
|
||||
unset ($aFullResponseTable['startlanguage']);
|
||||
unset ($aFullResponseTable['datestamp']);
|
||||
unset ($aFullResponseTable['startdate']);
|
||||
$sOutput .= "<table class='printouttable' >\n";
|
||||
foreach ($aFullResponseTable as $sFieldname=>$fname)
|
||||
{
|
||||
$sOutput .= "\t<tr class='printanswersquestionhead'><td colspan='2'>{$fname[0]}</td></tr>\n";
|
||||
}
|
||||
elseif ($sFieldname=='submitdate')
|
||||
{
|
||||
if($sAnonymized != 'Y')
|
||||
if (substr($sFieldname,0,4) == 'gid_')
|
||||
{
|
||||
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]} {$sFieldname}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
|
||||
$sOutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
|
||||
}
|
||||
elseif ($sFieldname=='submitdate')
|
||||
{
|
||||
if($sAnonymized != 'Y')
|
||||
{
|
||||
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]} {$sFieldname}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
|
||||
}
|
||||
}
|
||||
elseif (substr($sFieldname,0,4) != 'qid_') // Question text is already in subquestion text, skipping it
|
||||
{
|
||||
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>".flattenText($fname[2])."</td></tr>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>".flattenText($fname[2])."</td></tr>";
|
||||
}
|
||||
}
|
||||
$sOutput .= "</table>\n";
|
||||
if($sExportType == 'pdf')
|
||||
{
|
||||
$oPDF->writeHTML($sOutput);
|
||||
header("Pragma: public");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
$sExportFileName = sanitize_filename($sSurveyName);
|
||||
$oPDF->Output($sExportFileName."-".$iSurveyID.".pdf","D");
|
||||
}
|
||||
else//Display the page with user answers
|
||||
{
|
||||
$sOutput .= "</table>\n";
|
||||
$sData['thissurvey']=$aSurveyInfo;
|
||||
$sOutput=templatereplace($sOutput, array() , $sData, '', $aSurveyInfo['anonymized']=="Y",NULL, array(), true);// Do a static replacement
|
||||
ob_start(function($buffer, $phase) {
|
||||
App()->getClientScript()->render($buffer);
|
||||
App()->getClientScript()->reset();
|
||||
return $buffer;
|
||||
});
|
||||
ob_implicit_flush(false);
|
||||
|
||||
|
||||
sendCacheHeaders();
|
||||
doHeader();
|
||||
$sData['thissurvey']=$aSurveyInfo;
|
||||
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/startpage.pstpl'),array(),$sData);
|
||||
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/printanswers.pstpl'),array('ANSWERTABLE'=>$sOutput),$sData);
|
||||
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/endpage.pstpl'),array(),$sData);
|
||||
echo "</body></html>";
|
||||
|
||||
|
||||
ob_flush();
|
||||
}
|
||||
if($sExportType == 'pdf')
|
||||
{
|
||||
// Get images for TCPDF from template directory
|
||||
define('K_PATH_IMAGES', getTemplatePath($aSurveyInfo['template']).DIRECTORY_SEPARATOR);
|
||||
|
||||
Yii::import('application.libraries.admin.pdf', true);
|
||||
Yii::import('application.helpers.pdfHelper');
|
||||
$aPdfLanguageSettings=pdfHelper::getPdfLanguageSettings($clang->langcode);
|
||||
|
||||
$oPDF = new pdf();
|
||||
$sDefaultHeaderString = $sSurveyName." (".$clang->gT("ID",'unescaped').":".$iSurveyID.")";
|
||||
$oPDF->initAnswerPDF($aSurveyInfo, $aPdfLanguageSettings, Yii::app()->getConfig('sitename'), $sSurveyName, $sDefaultHeaderString);
|
||||
|
||||
LimeExpressionManager::StartProcessingPage(true); // means that all variables are on the same page
|
||||
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
|
||||
LimeExpressionManager::StartProcessingGroup(1,($aSurveyInfo['anonymized']!="N"),$iSurveyID);
|
||||
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
|
||||
$aFullResponseTable = getFullResponseTable($iSurveyID,$sSRID,$sLanguage,$printanswershonorsconditions);
|
||||
//Get the fieldmap @TODO: do we need to filter out some fields?
|
||||
if($aSurveyInfo['datestamp']!="Y" || $sAnonymized == 'Y'){
|
||||
unset ($aFullResponseTable['submitdate']);
|
||||
}else{
|
||||
unset ($aFullResponseTable['id']);
|
||||
}
|
||||
unset ($aFullResponseTable['token']);
|
||||
unset ($aFullResponseTable['lastpage']);
|
||||
unset ($aFullResponseTable['startlanguage']);
|
||||
unset ($aFullResponseTable['datestamp']);
|
||||
unset ($aFullResponseTable['startdate']);
|
||||
foreach ($aFullResponseTable as $sFieldname=>$fname)
|
||||
{
|
||||
if (substr($sFieldname,0,4) == 'gid_')
|
||||
{
|
||||
$oPDF->addGidAnswer($fname[0]);
|
||||
}
|
||||
elseif ($sFieldname=='submitdate')
|
||||
{
|
||||
if($sAnonymized != 'Y')
|
||||
{
|
||||
$oPDF->addAnswer($fname[0]." ".$fname[1], $fname[2]);
|
||||
}
|
||||
}
|
||||
elseif (substr($sFieldname,0,4) != 'qid_') // Question text is already in subquestion text, skipping it
|
||||
{
|
||||
$oPDF->addAnswer($fname[0]." ".$fname[1], $fname[2]);
|
||||
}
|
||||
}
|
||||
|
||||
header("Pragma: public");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
$sExportFileName = sanitize_filename($sSurveyName);
|
||||
$oPDF->Output($sExportFileName."-".$iSurveyID.".pdf","D");
|
||||
}
|
||||
|
||||
LimeExpressionManager::FinishProcessingGroup();
|
||||
LimeExpressionManager::FinishProcessingPage();
|
||||
|
|
|
@ -27,148 +27,131 @@
|
|||
class Statistics_userController extends LSYii_Controller {
|
||||
|
||||
|
||||
public function _remap($method, $params = array())
|
||||
{
|
||||
array_unshift($params, $method);
|
||||
return call_user_func_array(array($this, "action"), $params);
|
||||
}
|
||||
public function _remap($method, $params = array())
|
||||
{
|
||||
array_unshift($params, $method);
|
||||
return call_user_func_array(array($this, "action"), $params);
|
||||
}
|
||||
|
||||
function actionAction($surveyid,$language)
|
||||
{
|
||||
ob_start(function($buffer, $phase) {
|
||||
App()->getClientScript()->render($buffer);
|
||||
return $buffer;
|
||||
});
|
||||
ob_implicit_flush(false);
|
||||
$iSurveyID=(int)$surveyid;
|
||||
function actionAction($surveyid,$language=null)
|
||||
{
|
||||
$sLanguage=$language;
|
||||
ob_start(function($buffer, $phase) {
|
||||
App()->getClientScript()->render($buffer);
|
||||
App()->getClientScript()->reset();
|
||||
return $buffer;
|
||||
});
|
||||
ob_implicit_flush(false);
|
||||
$iSurveyID=(int)$surveyid;
|
||||
//$postlang = returnglobal('lang');
|
||||
Yii::import('application.libraries.admin.progressbar',true);
|
||||
Yii::app()->loadHelper("admin/statistics");
|
||||
Yii::app()->loadHelper('database');
|
||||
Yii::app()->loadHelper('surveytranslator');
|
||||
Yii::import('application.libraries.admin.progressbar',true);
|
||||
Yii::app()->loadHelper("admin/statistics");
|
||||
Yii::app()->loadHelper('database');
|
||||
Yii::app()->loadHelper('surveytranslator');
|
||||
App()->getClientScript()->registerPackage('jqueryui');
|
||||
App()->getClientScript()->registerPackage('jquery-touch-punch');
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");
|
||||
|
||||
$data = array();
|
||||
$data = array();
|
||||
|
||||
//XXX enable/disable this for testing
|
||||
//$publicgraphs = 1;
|
||||
//$showaggregateddata = 1;
|
||||
|
||||
/*
|
||||
* List of important settings:
|
||||
* - publicstatistics: General survey setting which determines if public statistics for this survey
|
||||
* should be shown at all.
|
||||
*
|
||||
* - publicgraphs: General survey setting which determines if public statistics for this survey
|
||||
* should include graphs or only show a tabular overview.
|
||||
*
|
||||
* - public_statistics: Question attribute which has to be applied to each question so that
|
||||
* its statistics will be shown to the user. If not set no statistics for this question will be shown.
|
||||
*
|
||||
* - filterout_incomplete_answers: Setting taken from config-defaults.php which determines if
|
||||
* not completed answers will be filtered.
|
||||
*/
|
||||
|
||||
if(!isset($iSurveyID))
|
||||
{
|
||||
$iSurveyID=returnGlobal('sid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$iSurveyID = (int) $iSurveyID;
|
||||
}
|
||||
if (!$iSurveyID)
|
||||
{
|
||||
//This next line ensures that the $iSurveyID value is never anything but a number.
|
||||
safeDie('You have to provide a valid survey ID.');
|
||||
}
|
||||
|
||||
|
||||
if ($iSurveyID)
|
||||
{
|
||||
$actresult = Survey::model()->findAll('sid = :sid AND active = :active', array(':sid' => $iSurveyID, ':active' => 'Y')); //Checked
|
||||
if (count($actresult) == 0)
|
||||
{
|
||||
safeDie('You have to provide a valid survey ID.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$surveyinfo = getSurveyInfo($iSurveyID);
|
||||
// CHANGE JSW_NZ - let's get the survey title for display
|
||||
$thisSurveyTitle = $surveyinfo["name"];
|
||||
// CHANGE JSW_NZ - let's get css from individual template.css - so define path
|
||||
$thisSurveyCssPath = getTemplateURL($surveyinfo["template"]);
|
||||
if ($surveyinfo['publicstatistics']!='Y')
|
||||
{
|
||||
safeDie('The public statistics for this survey are deactivated.');
|
||||
}
|
||||
|
||||
//check if graphs should be shown for this survey
|
||||
if ($surveyinfo['publicgraphs']=='Y')
|
||||
{
|
||||
$publicgraphs = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$publicgraphs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we collect all the output within this variable
|
||||
$statisticsoutput ='';
|
||||
|
||||
|
||||
//for creating graphs we need some more scripts which are included here
|
||||
//True -> include
|
||||
//False -> forget about charts
|
||||
if (isset($publicgraphs) && $publicgraphs == 1)
|
||||
{
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pChart.class');
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pData.class');
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pCache.class');
|
||||
|
||||
$MyCache = new pCache(Yii::app()->getConfig("tempdir").DIRECTORY_SEPARATOR);
|
||||
//$currentuser is created as prefix for pchart files
|
||||
if (isset($_SERVER['REDIRECT_REMOTE_USER']))
|
||||
{
|
||||
$currentuser=$_SERVER['REDIRECT_REMOTE_USER'];
|
||||
}
|
||||
else if (session_id())
|
||||
{
|
||||
$currentuser=substr(session_id(), 0, 15);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentuser="standard";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set language for questions and labels to base language of this survey
|
||||
if (isset($postlang) && $postlang != null )
|
||||
$language = $postlang;
|
||||
if(!isset($iSurveyID))
|
||||
{
|
||||
$iSurveyID=returnGlobal('sid');
|
||||
}
|
||||
else
|
||||
$language = Survey::model()->findByPk($iSurveyID)->language;
|
||||
{
|
||||
$iSurveyID = (int) $iSurveyID;
|
||||
}
|
||||
if (!$iSurveyID)
|
||||
{
|
||||
//This next line ensures that the $iSurveyID value is never anything but a number.
|
||||
safeDie('You have to provide a valid survey ID.');
|
||||
}
|
||||
|
||||
|
||||
//set survey language for translations
|
||||
$clang = SetSurveyLanguage($iSurveyID, $language);
|
||||
if ($iSurveyID)
|
||||
{
|
||||
$actresult = Survey::model()->findAll('sid = :sid AND active = :active', array(':sid' => $iSurveyID, ':active' => 'Y')); //Checked
|
||||
if (count($actresult) == 0)
|
||||
{
|
||||
safeDie('You have to provide a valid survey ID.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$surveyinfo = getSurveyInfo($iSurveyID);
|
||||
// CHANGE JSW_NZ - let's get the survey title for display
|
||||
$thisSurveyTitle = $surveyinfo["name"];
|
||||
// CHANGE JSW_NZ - let's get css from individual template.css - so define path
|
||||
$thisSurveyCssPath = getTemplateURL($surveyinfo["template"]);
|
||||
if ($surveyinfo['publicstatistics']!='Y')
|
||||
{
|
||||
safeDie('The public statistics for this survey are deactivated.');
|
||||
}
|
||||
|
||||
//check if graphs should be shown for this survey
|
||||
if ($surveyinfo['publicgraphs']=='Y')
|
||||
{
|
||||
$publicgraphs = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$publicgraphs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we collect all the output within this variable
|
||||
$statisticsoutput ='';
|
||||
|
||||
|
||||
//Create header (fixes bug #3097)
|
||||
$surveylanguage= $language;
|
||||
sendCacheHeaders();
|
||||
$condition = false;
|
||||
$sitename = Yii::app()->getConfig("sitename");
|
||||
//for creating graphs we need some more scripts which are included here
|
||||
//True -> include
|
||||
//False -> forget about charts
|
||||
if (isset($publicgraphs) && $publicgraphs == 1)
|
||||
{
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pChart.class');
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pData.class');
|
||||
require_once(APPPATH.'third_party/pchart/pchart/pCache.class');
|
||||
|
||||
$data['surveylanguage'] = $surveylanguage;
|
||||
$data['sitename'] = $sitename;
|
||||
$data['condition'] = $condition;
|
||||
$data['thisSurveyCssPath'] = $thisSurveyCssPath;
|
||||
$MyCache = new pCache(Yii::app()->getConfig("tempdir").DIRECTORY_SEPARATOR);
|
||||
//$currentuser is created as prefix for pchart files
|
||||
if (isset($_SERVER['REDIRECT_REMOTE_USER']))
|
||||
{
|
||||
$currentuser=$_SERVER['REDIRECT_REMOTE_USER'];
|
||||
}
|
||||
else if (session_id())
|
||||
{
|
||||
$currentuser=substr(session_id(), 0, 15);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentuser="standard";
|
||||
}
|
||||
}
|
||||
// Set language for questions and labels to base language of this survey
|
||||
if ($sLanguage== null || !in_array($sLanguage,Survey::model()->findByPk($iSurveyID)->getAllLanguages()))
|
||||
{
|
||||
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sLanguage=sanitize_languagecode($sLanguage);
|
||||
}
|
||||
//set survey language for translations
|
||||
$clang = SetSurveyLanguage($iSurveyID, $sLanguage);
|
||||
//Create header
|
||||
sendCacheHeaders();
|
||||
$condition = false;
|
||||
$sitename = Yii::app()->getConfig("sitename");
|
||||
|
||||
/*
|
||||
* only show questions where question attribute "public_statistics" is set to "1"
|
||||
*/
|
||||
$data['surveylanguage'] = $sLanguage;
|
||||
$data['sitename'] = $sitename;
|
||||
$data['condition'] = $condition;
|
||||
$data['thisSurveyCssPath'] = $thisSurveyCssPath;
|
||||
|
||||
/*
|
||||
* only show questions where question attribute "public_statistics" is set to "1"
|
||||
*/
|
||||
|
||||
$query = "SELECT q.* , group_name, group_order FROM {{questions}} q, {{groups}} g, {{question_attributes}} qa
|
||||
WHERE g.gid = q.gid AND g.language = :lang1 AND q.language = :lang2 AND q.sid = :surveyid AND q.qid = qa.qid AND q.parent_qid = 0 AND qa.attribute = 'public_statistics'";
|
||||
|
@ -182,185 +165,185 @@ class Statistics_userController extends LSYii_Controller {
|
|||
$query .=" AND qa.value='1'\n";
|
||||
}
|
||||
|
||||
//execute query
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":lang1", $language, PDO::PARAM_STR)->bindParam(":lang2", $language, PDO::PARAM_STR)->bindParam(":surveyid", $iSurveyID, PDO::PARAM_INT)->queryAll();
|
||||
//execute query
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":lang1", $sLanguage, PDO::PARAM_STR)->bindParam(":lang2", $sLanguage, PDO::PARAM_STR)->bindParam(":surveyid", $iSurveyID, PDO::PARAM_INT)->queryAll();
|
||||
|
||||
//store all the data in $rows
|
||||
$rows = $result;
|
||||
//store all the data in $rows
|
||||
$rows = $result;
|
||||
|
||||
|
||||
//SORT IN NATURAL ORDER!
|
||||
usort($rows, 'groupOrderThenQuestionOrder');
|
||||
//SORT IN NATURAL ORDER!
|
||||
usort($rows, 'groupOrderThenQuestionOrder');
|
||||
|
||||
//put the question information into the filter array
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
//store some column names in $filters array
|
||||
$filters[]=array($row['qid'],
|
||||
$row['gid'],
|
||||
$row['type'],
|
||||
$row['title'],
|
||||
$row['group_name'],
|
||||
flattenText($row['question']));
|
||||
}
|
||||
//put the question information into the filter array
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
//store some column names in $filters array
|
||||
$filters[]=array($row['qid'],
|
||||
$row['gid'],
|
||||
$row['type'],
|
||||
$row['title'],
|
||||
$row['group_name'],
|
||||
flattenText($row['question']));
|
||||
}
|
||||
|
||||
//number of records for this survey
|
||||
$totalrecords = 0;
|
||||
//number of records for this survey
|
||||
$totalrecords = 0;
|
||||
|
||||
//count number of answers
|
||||
$query = "SELECT count(*) FROM {{survey_".intval($iSurveyID)."}}";
|
||||
//count number of answers
|
||||
$query = "SELECT count(*) FROM {{survey_".intval($iSurveyID)."}}";
|
||||
|
||||
//if incompleted answers should be filtert submitdate has to be not null
|
||||
//this setting is taken from config-defaults.php
|
||||
if (Yii::app()->getConfig("filterout_incomplete_answers") == true)
|
||||
{
|
||||
$query .= " WHERE {{survey_".intval($iSurveyID)."}}.submitdate is not null";
|
||||
}
|
||||
$result = Yii::app()->db->createCommand($query)->queryAll();
|
||||
//if incompleted answers should be filtert submitdate has to be not null
|
||||
//this setting is taken from config-defaults.php
|
||||
if (Yii::app()->getConfig("filterout_incomplete_answers") == true)
|
||||
{
|
||||
$query .= " WHERE {{survey_".intval($iSurveyID)."}}.submitdate is not null";
|
||||
}
|
||||
$result = Yii::app()->db->createCommand($query)->queryAll();
|
||||
|
||||
//$totalrecords = total number of answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$totalrecords = reset($row);
|
||||
}
|
||||
//$totalrecords = total number of answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$totalrecords = reset($row);
|
||||
}
|
||||
|
||||
|
||||
//this is the array which we need later...
|
||||
$summary = array();
|
||||
//...while this is the array from copy/paste which we don't want to replace because this is a nasty source of error
|
||||
$allfields = array();
|
||||
//this is the array which we need later...
|
||||
$summary = array();
|
||||
//...while this is the array from copy/paste which we don't want to replace because this is a nasty source of error
|
||||
$allfields = array();
|
||||
|
||||
|
||||
//---------- CREATE SGQA OF ALL QUESTIONS WHICH USE "PUBLIC_STATISTICS" ----------
|
||||
//---------- CREATE SGQA OF ALL QUESTIONS WHICH USE "PUBLIC_STATISTICS" ----------
|
||||
|
||||
/*
|
||||
* let's go through the filter array which contains
|
||||
* ['qid'],
|
||||
['gid'],
|
||||
['type'],
|
||||
['title'],
|
||||
['group_name'],
|
||||
['question'];
|
||||
*/
|
||||
/*
|
||||
* let's go through the filter array which contains
|
||||
* ['qid'],
|
||||
['gid'],
|
||||
['type'],
|
||||
['title'],
|
||||
['group_name'],
|
||||
['question'];
|
||||
*/
|
||||
|
||||
$currentgroup='';
|
||||
// use to check if there are any question with public statistics
|
||||
if(isset($filters)){
|
||||
foreach ($filters as $flt)
|
||||
{
|
||||
//SGQ identifier
|
||||
$myfield = "{$iSurveyID}X{$flt[1]}X{$flt[0]}";
|
||||
$currentgroup='';
|
||||
// use to check if there are any question with public statistics
|
||||
if(isset($filters)){
|
||||
foreach ($filters as $flt)
|
||||
{
|
||||
//SGQ identifier
|
||||
$myfield = "{$iSurveyID}X{$flt[1]}X{$flt[0]}";
|
||||
|
||||
//let's switch through the question type for each question
|
||||
switch ($flt[2])
|
||||
{
|
||||
case "K": // Multiple Numerical
|
||||
case "Q": // Multiple Short Text
|
||||
//get answers
|
||||
$query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid=:flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
//let's switch through the question type for each question
|
||||
switch ($flt[2])
|
||||
{
|
||||
case "K": // Multiple Numerical
|
||||
case "Q": // Multiple Short Text
|
||||
//get answers
|
||||
$query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid=:flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
|
||||
//go through all the (multiple) answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$myfield2=$flt[2].$myfield.reset($row);
|
||||
$allfields[] = $myfield2;
|
||||
}
|
||||
break;
|
||||
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
|
||||
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
|
||||
case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
|
||||
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
|
||||
case "F": // FlEXIBLE ARRAY
|
||||
case "H": // ARRAY (By Column)
|
||||
//get answers
|
||||
$query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid=:flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
//go through all the (multiple) answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$myfield2=$flt[2].$myfield.reset($row);
|
||||
$allfields[] = $myfield2;
|
||||
}
|
||||
break;
|
||||
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
|
||||
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
|
||||
case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
|
||||
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
|
||||
case "F": // FlEXIBLE ARRAY
|
||||
case "H": // ARRAY (By Column)
|
||||
//get answers
|
||||
$query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid=:flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
|
||||
//go through all the (multiple) answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$myfield2 = $myfield.reset($row);
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
break;
|
||||
// all "free text" types (T, U, S) get the same prefix ("T")
|
||||
case "T": // Long free text
|
||||
case "U": // Huge free text
|
||||
case "S": // Short free text
|
||||
$myfield="T$myfield";
|
||||
$allfields[] = $myfield;
|
||||
break;
|
||||
case ";": //ARRAY (Multi Flex) (Text)
|
||||
case ":": //ARRAY (Multi Flex) (Numbers)
|
||||
//go through all the (multiple) answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
$myfield2 = $myfield.reset($row);
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
break;
|
||||
// all "free text" types (T, U, S) get the same prefix ("T")
|
||||
case "T": // Long free text
|
||||
case "U": // Huge free text
|
||||
case "S": // Short free text
|
||||
$myfield="T$myfield";
|
||||
$allfields[] = $myfield;
|
||||
break;
|
||||
case ";": //ARRAY (Multi Flex) (Text)
|
||||
case ":": //ARRAY (Multi Flex) (Numbers)
|
||||
$query = "SELECT title, question FROM {{questions}} WHERE parent_qid=:flt_0 AND language=:lang AND scale_id = 0 ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
foreach($result as $row)
|
||||
{
|
||||
$fquery = "SELECT * FROM {{questions}} WHERE parent_qid = :flt_0 AND language = :lang AND scale_id = 1 ORDER BY question_order, title";
|
||||
$fresult = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
foreach($fresult as $frow)
|
||||
{
|
||||
$myfield2 = $myfield . reset($row) . "_" . $frow['title'];
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "R": //RANKING
|
||||
//get some answers
|
||||
$query = "SELECT code, answer FROM {{answers}} WHERE qid = :flt_0 AND language = :lang ORDER BY sortorder, answer";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
foreach($result as $row)
|
||||
{
|
||||
$fquery = "SELECT * FROM {{questions}} WHERE parent_qid = :flt_0 AND language = :lang AND scale_id = 1 ORDER BY question_order, title";
|
||||
$fresult = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
foreach($fresult as $frow)
|
||||
{
|
||||
$myfield2 = $myfield . reset($row) . "_" . $frow['title'];
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "R": //RANKING
|
||||
//get some answers
|
||||
$query = "SELECT code, answer FROM {{answers}} WHERE qid = :flt_0 AND language = :lang ORDER BY sortorder, answer";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
|
||||
//get number of answers
|
||||
$count = count($result);
|
||||
//get number of answers
|
||||
$count = count($result);
|
||||
|
||||
//loop through all answers. if there are 3 items to rate there will be 3 statistics
|
||||
for ($i=1; $i<=$count; $i++)
|
||||
{
|
||||
$myfield2 = "R" . $myfield . $i . "-" . strlen($i);
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
break;
|
||||
//Boilerplate questions are only used to put some text between other questions -> no analysis needed
|
||||
case "X": //This is a boilerplate question and it has no business in this script
|
||||
break;
|
||||
case "1": // MULTI SCALE
|
||||
//get answers
|
||||
$query = "SELECT title, question FROM {{questions}} WHERE parent_qid = :flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $language, PDO::PARAM_STR)->queryAll();
|
||||
//loop through all answers. if there are 3 items to rate there will be 3 statistics
|
||||
for ($i=1; $i<=$count; $i++)
|
||||
{
|
||||
$myfield2 = "R" . $myfield . $i . "-" . strlen($i);
|
||||
$allfields[]=$myfield2;
|
||||
}
|
||||
break;
|
||||
//Boilerplate questions are only used to put some text between other questions -> no analysis needed
|
||||
case "X": //This is a boilerplate question and it has no business in this script
|
||||
break;
|
||||
case "1": // MULTI SCALE
|
||||
//get answers
|
||||
$query = "SELECT title, question FROM {{questions}} WHERE parent_qid = :flt_0 AND language = :lang ORDER BY question_order";
|
||||
$result = Yii::app()->db->createCommand($query)->bindParam(":flt_0", $flt[0], PDO::PARAM_INT)->bindParam(":lang", $sLanguage, PDO::PARAM_STR)->queryAll();
|
||||
|
||||
//loop through answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
//----------------- LABEL 1 ---------------------
|
||||
$myfield2 = $myfield . $row['title']."#0";
|
||||
$allfields[]=$myfield2;
|
||||
//----------------- LABEL 2 ---------------------
|
||||
$myfield2 = $myfield . $row['title']."#1";
|
||||
$allfields[]=$myfield2;
|
||||
} //end WHILE -> loop through all answers
|
||||
break;
|
||||
//loop through answers
|
||||
foreach($result as $row)
|
||||
{
|
||||
//----------------- LABEL 1 ---------------------
|
||||
$myfield2 = $myfield . $row['title']."#0";
|
||||
$allfields[]=$myfield2;
|
||||
//----------------- LABEL 2 ---------------------
|
||||
$myfield2 = $myfield . $row['title']."#1";
|
||||
$allfields[]=$myfield2;
|
||||
} //end WHILE -> loop through all answers
|
||||
break;
|
||||
|
||||
case "P": //P - Multiple choice with comments
|
||||
case "M": //M - Multiple choice
|
||||
case "N": //N - Numerical input
|
||||
case "D": //D - Date
|
||||
$myfield2 = $flt[2].$myfield;
|
||||
$allfields[]=$myfield2;
|
||||
break;
|
||||
default: //Default settings
|
||||
$allfields[] = $myfield;
|
||||
break;
|
||||
case "P": //P - Multiple choice with comments
|
||||
case "M": //M - Multiple choice
|
||||
case "N": //N - Numerical input
|
||||
case "D": //D - Date
|
||||
$myfield2 = $flt[2].$myfield;
|
||||
$allfields[]=$myfield2;
|
||||
break;
|
||||
default: //Default settings
|
||||
$allfields[] = $myfield;
|
||||
break;
|
||||
|
||||
} //end switch -> check question types and create filter forms
|
||||
}
|
||||
//end foreach -> loop through all questions with "public_statistics" enabled
|
||||
}// end if -> for removing the error message in case there are no filters
|
||||
$summary = $allfields;
|
||||
} //end switch -> check question types and create filter forms
|
||||
}
|
||||
//end foreach -> loop through all questions with "public_statistics" enabled
|
||||
}// end if -> for removing the error message in case there are no filters
|
||||
$summary = $allfields;
|
||||
|
||||
|
||||
// Get the survey inforamtion
|
||||
$thissurvey = getSurveyInfo($surveyid,$language);
|
||||
$thissurvey = getSurveyInfo($surveyid,$sLanguage);
|
||||
|
||||
//SET THE TEMPLATE DIRECTORY
|
||||
if (!isset($thissurvey['templatedir']) || !$thissurvey['templatedir'])
|
||||
|
@ -373,96 +356,96 @@ class Statistics_userController extends LSYii_Controller {
|
|||
}
|
||||
|
||||
|
||||
//---------- CREATE STATISTICS ----------
|
||||
//---------- CREATE STATISTICS ----------
|
||||
$redata = compact(array_keys(get_defined_vars()));
|
||||
doHeader();
|
||||
echo templatereplace(file_get_contents(getTemplatePath(validateTemplateDir($data['sTemplatePath'])).DIRECTORY_SEPARATOR."startpage.pstpl"),array(), $redata);
|
||||
|
||||
|
||||
//some progress bar stuff
|
||||
//some progress bar stuff
|
||||
|
||||
// Create progress bar which is shown while creating the results
|
||||
$prb = new ProgressBar();
|
||||
$prb->pedding = 2; // Bar Pedding
|
||||
$prb->brd_color = "#404040 #dfdfdf #dfdfdf #404040"; // Bar Border Color
|
||||
// Create progress bar which is shown while creating the results
|
||||
$prb = new ProgressBar();
|
||||
$prb->pedding = 2; // Bar Pedding
|
||||
$prb->brd_color = "#404040 #dfdfdf #dfdfdf #404040"; // Bar Border Color
|
||||
|
||||
$prb->setFrame(); // set ProgressBar Frame
|
||||
$prb->frame['left'] = 50; // Frame position from left
|
||||
$prb->frame['top'] = 80; // Frame position from top
|
||||
$prb->addLabel('text','txt1',$clang->gT("Please wait ...")); // add Text as Label 'txt1' and value 'Please wait'
|
||||
$prb->addLabel('percent','pct1'); // add Percent as Label 'pct1'
|
||||
$prb->addButton('btn1',$clang->gT('Go back'),'?action=statistics&sid='.$iSurveyID); // add Button as Label 'btn1' and action '?restart=1'
|
||||
$prb->setFrame(); // set ProgressBar Frame
|
||||
$prb->frame['left'] = 50; // Frame position from left
|
||||
$prb->frame['top'] = 80; // Frame position from top
|
||||
$prb->addLabel('text','txt1',$clang->gT("Please wait ...")); // add Text as Label 'txt1' and value 'Please wait'
|
||||
$prb->addLabel('percent','pct1'); // add Percent as Label 'pct1'
|
||||
$prb->addButton('btn1',$clang->gT('Go back'),'?action=statistics&sid='.$iSurveyID); // add Button as Label 'btn1' and action '?restart=1'
|
||||
|
||||
//progress bar starts with 35%
|
||||
$process_status = 35;
|
||||
$prb->show(); // show the ProgressBar
|
||||
//progress bar starts with 35%
|
||||
$process_status = 35;
|
||||
$prb->show(); // show the ProgressBar
|
||||
|
||||
|
||||
// 1: Get list of questions with answers chosen
|
||||
//"Getting Questions and Answer ..." is shown above the bar
|
||||
$prb->setLabelValue('txt1',$clang->gT('Getting questions and answers ...'));
|
||||
$prb->moveStep(5);
|
||||
// 1: Get list of questions with answers chosen
|
||||
//"Getting Questions and Answer ..." is shown above the bar
|
||||
$prb->setLabelValue('txt1',$clang->gT('Getting questions and answers ...'));
|
||||
$prb->moveStep(5);
|
||||
|
||||
// creates array of post variable names
|
||||
for (reset($_POST); $key=key($_POST); next($_POST))
|
||||
{
|
||||
$postvars[]=$key;
|
||||
}
|
||||
$data['thisSurveyTitle'] = $thisSurveyTitle;
|
||||
$data['totalrecords'] = $totalrecords;
|
||||
$data['clang'] = $clang;
|
||||
$data['summary'] = $summary;
|
||||
//show some main data at the beginnung
|
||||
// CHANGE JSW_NZ - let's allow html formatted questions to show
|
||||
// creates array of post variable names
|
||||
for (reset($_POST); $key=key($_POST); next($_POST))
|
||||
{
|
||||
$postvars[]=$key;
|
||||
}
|
||||
$data['thisSurveyTitle'] = $thisSurveyTitle;
|
||||
$data['totalrecords'] = $totalrecords;
|
||||
$data['clang'] = $clang;
|
||||
$data['summary'] = $summary;
|
||||
//show some main data at the beginnung
|
||||
// CHANGE JSW_NZ - let's allow html formatted questions to show
|
||||
|
||||
|
||||
//push progress bar from 35 to 40
|
||||
$process_status = 40;
|
||||
//push progress bar from 35 to 40
|
||||
$process_status = 40;
|
||||
|
||||
//Show Summary results
|
||||
if (isset($summary) && $summary)
|
||||
{
|
||||
//"Generating Summaries ..." is shown above the progress bar
|
||||
$prb->setLabelValue('txt1',$clang->gT('Generating summaries ...'));
|
||||
$prb->moveStep($process_status);
|
||||
//Show Summary results
|
||||
if (isset($summary) && $summary)
|
||||
{
|
||||
//"Generating Summaries ..." is shown above the progress bar
|
||||
$prb->setLabelValue('txt1',$clang->gT('Generating summaries ...'));
|
||||
$prb->moveStep($process_status);
|
||||
|
||||
//let's run through the survey // Fixed bug 3053 with array_unique
|
||||
$runthrough=array_unique($summary);
|
||||
//let's run through the survey // Fixed bug 3053 with array_unique
|
||||
$runthrough=array_unique($summary);
|
||||
|
||||
//loop through all selected questions
|
||||
foreach ($runthrough as $rt)
|
||||
{
|
||||
//loop through all selected questions
|
||||
foreach ($runthrough as $rt)
|
||||
{
|
||||
|
||||
//update progress bar
|
||||
if ($process_status < 100) $process_status++;
|
||||
$prb->moveStep($process_status);
|
||||
//update progress bar
|
||||
if ($process_status < 100) $process_status++;
|
||||
$prb->moveStep($process_status);
|
||||
|
||||
} // end foreach -> loop through all questions
|
||||
} // end foreach -> loop through all questions
|
||||
|
||||
$helper = new statistics_helper();
|
||||
$statisticsoutput .= $helper->generate_statistics($iSurveyID, $summary, $summary, $publicgraphs, 'html', null,$language,false);
|
||||
$statisticsoutput .= $helper->generate_statistics($iSurveyID, $summary, $summary, $publicgraphs, 'html', null,$sLanguage,false);
|
||||
|
||||
} //end if -> show summary results
|
||||
} //end if -> show summary results
|
||||
|
||||
$data['statisticsoutput']=$statisticsoutput;
|
||||
//done! set progress bar to 100%
|
||||
if (isset($prb))
|
||||
{
|
||||
$prb->setLabelValue('txt1',$clang->gT('Completed'));
|
||||
$prb->moveStep(100);
|
||||
$prb->hide();
|
||||
}
|
||||
//done! set progress bar to 100%
|
||||
if (isset($prb))
|
||||
{
|
||||
$prb->setLabelValue('txt1',$clang->gT('Completed'));
|
||||
$prb->moveStep(100);
|
||||
$prb->hide();
|
||||
}
|
||||
|
||||
$redata = compact(array_keys(get_defined_vars()));
|
||||
$data['redata'] = $redata;
|
||||
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . 'statistics_user.js');
|
||||
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . 'statistics_user.js');
|
||||
$this->renderPartial('/statistics_user_view',$data);
|
||||
|
||||
//output footer
|
||||
echo getFooter();
|
||||
//output footer
|
||||
echo getFooter();
|
||||
|
||||
//Delete all Session Data
|
||||
Yii::app()->session['finished'] = true;
|
||||
}
|
||||
//Delete all Session Data
|
||||
Yii::app()->session['finished'] = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ class UploaderController extends SurveyController {
|
|||
|
||||
// Validate and filter and throw error if problems
|
||||
// Using 'futmp_'.randomChars(15).'_'.$pathinfo['extension'] for filename, then remove all other characters
|
||||
$sFileGetContentFiltered=preg_replace('/[^a-z0-9_]/', '', $sFileGetContent);
|
||||
$sFileNameFiltered = preg_replace('/[^a-z0-9_]/', '',$sFileName);
|
||||
$sFileGetContentFiltered=preg_replace('/[^a-zA-Z0-9_]/', '', $sFileGetContent);
|
||||
$sFileNameFiltered = preg_replace('/[^a-zA-Z0-9_]/', '',$sFileName);
|
||||
$sFieldNameFiltered=preg_replace('/[^X0-9]/', '', $sFieldName);
|
||||
if($sFileGetContent!=$sFileGetContentFiltered || $sFileName!=$sFileNameFiltered || $sFieldName!=$sFieldNameFiltered)
|
||||
{// If one seems to be a hack: Bad request
|
||||
|
|
|
@ -79,15 +79,23 @@ class Authentication extends Survey_Common_Action
|
|||
// Now authenticate
|
||||
if ($identity->authenticate())
|
||||
{
|
||||
FailedLoginAttempt::model()->deleteAttempts();
|
||||
FailedLoginAttempt::model()->deleteAttempts();
|
||||
App()->user->setState('plugin', $authMethod);
|
||||
$this->getController()->_GetSessionUserRights(Yii::app()->session['loginID']);
|
||||
Yii::app()->session['just_logged_in'] = true;
|
||||
Yii::app()->session['loginsummary'] = $this->_getSummary();
|
||||
|
||||
$event = new PluginEvent('afterSuccessfulLogin');
|
||||
App()->getPluginManager()->dispatchEvent($event);
|
||||
|
||||
$this->_doRedirect();
|
||||
|
||||
} else {
|
||||
// Failed
|
||||
$event = new PluginEvent('afterFailedLoginAttempt');
|
||||
$event->set('identity', $identity);
|
||||
App()->getPluginManager()->dispatchEvent($event);
|
||||
|
||||
$message = $identity->errorMessage;
|
||||
if (empty($message)) {
|
||||
// If no message, return a default message
|
||||
|
@ -105,19 +113,16 @@ class Authentication extends Survey_Common_Action
|
|||
*/
|
||||
public function logout()
|
||||
{
|
||||
// Fetch the current user
|
||||
$plugin = App()->user->getState('plugin', null); // Save for afterLogout, current user will be destroyed by then
|
||||
|
||||
/* Adding beforeLogout event */
|
||||
$beforeLogout = new PluginEvent('beforeLogout');
|
||||
App()->getPluginManager()->dispatchEvent($beforeLogout, array($plugin));
|
||||
App()->getPluginManager()->dispatchEvent($beforeLogout);
|
||||
|
||||
App()->user->logout();
|
||||
App()->user->setFlash('loginmessage', gT('Logout successful.'));
|
||||
|
||||
/* Adding afterLogout event */
|
||||
$event = new PluginEvent('afterLogout');
|
||||
App()->getPluginManager()->dispatchEvent($event, array($plugin));
|
||||
App()->getPluginManager()->dispatchEvent($event);
|
||||
|
||||
$this->getController()->redirect(array('/admin/authentication/sa/login'));
|
||||
}
|
||||
|
@ -140,18 +145,19 @@ class Authentication extends Survey_Common_Action
|
|||
|
||||
$aFields = User::model()->findAllByAttributes(array('users_name' => $sUserName, 'email' => $sEmailAddr));
|
||||
|
||||
// Preventing attacker from easily knowing whether the user and email address are valid or not (and slowing down brute force attacks)
|
||||
usleep(rand(Yii::app()->getConfig("minforgottenpasswordemaildelay"),Yii::app()->getConfig("maxforgottenpasswordemaildelay")));
|
||||
|
||||
if (count($aFields) < 1)
|
||||
{
|
||||
// wrong or unknown username and/or email
|
||||
$aData['errormsg'] = $this->getController()->lang->gT('User name and/or email not found!');
|
||||
$aData['maxattempts'] = '';
|
||||
$this->_renderWrappedTemplate('authentication', 'error', $aData);
|
||||
$aData['message'] = '<br>'.gT('If username and email that you specified are valid, a new password has been sent to you').'<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$aData['message'] = $this->_sendPasswordEmail($sEmailAddr, $aFields);
|
||||
$this->_renderWrappedTemplate('authentication', 'message', $aData);
|
||||
$aData['message'] = '<br>'.$this->_sendPasswordEmail($sEmailAddr, $aFields).'</br>';
|
||||
}
|
||||
$this->_renderWrappedTemplate('authentication', 'message', $aData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,12 +190,11 @@ class Authentication extends Survey_Common_Action
|
|||
if (SendEmailMessage($body, $sSubject, $sTo, $sFrom, $sSiteName, false, $sSiteAdminBounce))
|
||||
{
|
||||
User::model()->updatePassword($aFields[0]['uid'], $sNewPass);
|
||||
$sMessage = $username . '<br />' . $email . '<br /><br />' . $clang->gT('An email with your login data was sent to you.');
|
||||
$sMessage = gT('If username and email that you specified are valid, a new password has been sent to you');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sTmp = str_replace("{NAME}", '<strong>' . $aFields[0]['users_name'] . '</strong>', $clang->gT("Email to {NAME} ({EMAIL}) failed."));
|
||||
$sMessage = str_replace("{EMAIL}", $sEmailAddr, $sTmp) . '<br />';
|
||||
$sMessage = gT("Email failed.");
|
||||
}
|
||||
|
||||
return $sMessage;
|
||||
|
|
|
@ -237,23 +237,15 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
|
||||
private function _deleteQuotaMembers(array $aData, Limesurvey_lang $clang)
|
||||
{
|
||||
$quota_ids = array();
|
||||
$quotas = Quota::model()->findAll();
|
||||
foreach ($quotas as $quota) $quota_ids[] = $quota['id'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('quota_id', $quota_ids);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid LEFT JOIN {{surveys}} s ON t.sid=s.sid';
|
||||
$oCriteria->condition = '(q.qid IS NULL) OR (s.sid IS NULL)';
|
||||
|
||||
$qids = array();
|
||||
$questions = Question::model()->findAll();
|
||||
foreach ($questions as $question) $qids[] = $question['qid'];
|
||||
$criteria->addNotInCondition('qid', $qids, 'OR');
|
||||
|
||||
$sids = array();
|
||||
$surveys = Survey::model()->findAll();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria->addNotInCondition('sid', $sids, 'OR');
|
||||
|
||||
QuotaMember::model()->deleteAll($criteria);
|
||||
$aRecords=QuotaMember::model()->findAll($oCriteria);
|
||||
foreach ($aRecords as $aRecord)
|
||||
{
|
||||
QuotaMember::model()->deleteAllByAttributes($aRecord);
|
||||
}
|
||||
if (QuotaLanguageSetting::model()->hasErrors()) safeDie(QuotaLanguageSetting::model()->getError());
|
||||
$aData['messages'][] = $clang->gT('Deleting orphaned quota members.');
|
||||
return $aData;
|
||||
|
@ -286,14 +278,15 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
|
||||
private function _deleteDefaultValues(array $aData, Limesurvey_lang $clang)
|
||||
{
|
||||
$qids = array();
|
||||
$questions = Question::model()->findAll();
|
||||
foreach ($questions as $question) $qids[] = $question['qid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('qid', $qids);
|
||||
$criteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
|
||||
$criteria->condition = 'q.qid IS NULL';
|
||||
|
||||
DefaultValue::model()->deleteAll($criteria);
|
||||
if (DefaultValue::model()->hasErrors()) safeDie(DefaultValue::model()->getError());
|
||||
$aRecords=DefaultValue::model()->findAll($criteria);
|
||||
foreach ($aRecords as $aRecord)
|
||||
{
|
||||
DefaultValue::model()->deleteAllByAttributes($aRecord);
|
||||
}
|
||||
$aData['messages'][] = $clang->gT('Deleting orphaned default values.');
|
||||
return $aData;
|
||||
}
|
||||
|
@ -336,36 +329,37 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
$users = User::model()->findAll();
|
||||
$uids = array();
|
||||
foreach ($users as $user) $uids[] = $user['uid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('uid', $uids, 'OR');
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->addNotInCondition('uid', $uids, 'OR');
|
||||
|
||||
$surveys = Survey::model()->findAll();
|
||||
$sids = array();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria->addNotInCondition('entity_id', $sids, 'OR');
|
||||
$criteria->addCondition("entity='survey'");
|
||||
$oCriteria->addNotInCondition('entity_id', $sids, 'OR');
|
||||
$oCriteria->addCondition("entity='survey'");
|
||||
|
||||
Permission::model()->deleteAll($oCriteria);
|
||||
|
||||
Permission::model()->deleteAll($criteria);
|
||||
|
||||
|
||||
// Deactivate surveys that have a missing response table
|
||||
foreach ($surveys as $survey)
|
||||
foreach ($surveys as $survey)
|
||||
{
|
||||
if ($survey['active']=='Y' && !tableExists("{{survey_{$survey['sid']}}}"))
|
||||
{
|
||||
Survey::model()->updateByPk($survey['sid'],array('active'=>'N'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unset($surveys);
|
||||
|
||||
|
||||
|
||||
// Fix subquestions
|
||||
fixSubquestions();
|
||||
|
||||
/*** Check for active survey tables with missing survey entry and rename them ***/
|
||||
$sDBPrefix = Yii::app()->db->tablePrefix;
|
||||
$sQuery = dbSelectTablesLike('{{survey}}\_%');
|
||||
$aResult = dbQueryOrFalse($sQuery) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
|
||||
$aResult = dbQueryOrFalse($sQuery);
|
||||
foreach ($aResult->readAll() as $aRow)
|
||||
{
|
||||
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
|
||||
|
@ -388,7 +382,7 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
}
|
||||
|
||||
/*** Check for active token tables with missing survey entry ***/
|
||||
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\_%')) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
|
||||
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\_%'));
|
||||
foreach ($aResult->readAll() as $aRow)
|
||||
{
|
||||
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
|
||||
|
@ -408,16 +402,15 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
/**********************************************************************/
|
||||
/* Check conditions */
|
||||
/**********************************************************************/
|
||||
// TMSW Condition->Relevance: Replace this with analysis of relevance
|
||||
$conditions = Condition::model()->findAll();
|
||||
if (Condition::model()->hasErrors()) safeDie(Condition::model()->getError());
|
||||
$okQuestion = array();
|
||||
foreach ($conditions as $condition)
|
||||
$sQuery = 'SELECT cqid,cid,cfieldname FROM {{conditions}}';
|
||||
$aConditions = Yii::app()->db->createCommand($sQuery)->queryAll();
|
||||
foreach ($aConditions as $condition)
|
||||
{
|
||||
if ($condition['cqid'] != 0) { // skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
|
||||
if (!array_key_exists($condition['cqid'], $okQuestion)) {
|
||||
$iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
|
||||
if (Question::model()->hasErrors()) safeDie(Question::model()->getError());
|
||||
if (Question::model()->hasErrors()) safeDie(Question::model()->getError());
|
||||
if (!$iRowCount) {
|
||||
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
|
||||
} else {
|
||||
|
@ -439,7 +432,8 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No CFIELDNAME field set!') . " ({$condition['cfieldname']})");
|
||||
}
|
||||
}
|
||||
|
||||
unset($okQuestion);
|
||||
unset($aConditions);
|
||||
/**********************************************************************/
|
||||
/* Check question attributes */
|
||||
/**********************************************************************/
|
||||
|
@ -454,14 +448,11 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
/**********************************************************************/
|
||||
/* Check default values */
|
||||
/**********************************************************************/
|
||||
$questions = Question::model()->findAll();
|
||||
if (Question::model()->hasErrors()) safeDie(Question::model()->getError());
|
||||
$qids = array();
|
||||
foreach ($questions as $question) $qids[] = $question['qid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('qid', $qids);
|
||||
|
||||
$aDelete['defaultvalues'] = count(DefaultValue::model()->findAll($criteria));
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
|
||||
$oCriteria->condition = 'q.qid IS NULL';
|
||||
$aRecords=DefaultValue::model()->findAll($oCriteria);
|
||||
$aDelete['defaultvalues'] = count($aRecords);
|
||||
if (DefaultValue::model()->hasErrors()) safeDie(DefaultValue::model()->getError());
|
||||
|
||||
/**********************************************************************/
|
||||
|
@ -471,10 +462,10 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
|
||||
$sids = array();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('sid', $sids);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->addNotInCondition('sid', $sids);
|
||||
|
||||
$aDelete['quotas'] = count(Quota::model()->findAll($criteria));
|
||||
$aDelete['quotas'] = count(Quota::model()->findAll($oCriteria));
|
||||
if (Quota::model()->hasErrors()) safeDie(Quota::model()->getError());
|
||||
|
||||
/**********************************************************************/
|
||||
|
@ -484,40 +475,28 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
if (Quota::model()->hasErrors()) safeDie(Quota::model()->getError());
|
||||
$ids = array();
|
||||
foreach ($quotas as $quota) $ids[] = $quota['id'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('quotals_quota_id', $ids);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->addNotInCondition('quotals_quota_id', $ids);
|
||||
|
||||
$aDelete['quotals'] = count(QuotaLanguageSetting::model()->findAll($criteria));
|
||||
$aDelete['quotals'] = count(QuotaLanguageSetting::model()->findAll($oCriteria));
|
||||
if (QuotaLanguageSetting::model()->hasErrors()) safeDie(QuotaLanguageSetting::model()->getError());
|
||||
|
||||
/**********************************************************************/
|
||||
/* Check quota members */
|
||||
/**********************************************************************/
|
||||
$quotas = Quota::model()->findAll();
|
||||
$quota_ids = array();
|
||||
foreach ($quotas as $quota) $quota_ids[] = $quota['id'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('quota_id', $quota_ids);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid LEFT JOIN {{surveys}} s ON t.sid=s.sid';
|
||||
$oCriteria->condition = '(q.qid IS NULL) OR (s.sid IS NULL)';
|
||||
|
||||
$questions = Question::model()->findAll();
|
||||
$qids = array();
|
||||
foreach ($questions as $question) $qids[] = $question['qid'];
|
||||
$criteria->addNotInCondition('qid', $qids, 'OR');
|
||||
|
||||
$surveys = Survey::model()->findAll();
|
||||
$sids = array();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria->addNotInCondition('sid', $sids, 'OR');
|
||||
|
||||
$aDelete['quotamembers'] = count(QuotaMember::model()->findAll($criteria));
|
||||
$aDelete['quotamembers'] = count(QuotaMember::model()->findAll($oCriteria));
|
||||
if (QuotaMember::model()->hasErrors()) safeDie(QuotaMember::model()->getError());
|
||||
|
||||
/**********************************************************************/
|
||||
/* Check assessments */
|
||||
/**********************************************************************/
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->compare('scope', 'T');
|
||||
$assessments = Assessment::model()->findAll($criteria);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->compare('scope', 'T');
|
||||
$assessments = Assessment::model()->findAll($oCriteria);
|
||||
if (Assessment::model()->hasErrors()) safeDie(Assessment::model()->getError());
|
||||
foreach ($assessments as $assessment)
|
||||
{
|
||||
|
@ -528,9 +507,9 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->compare('scope', 'G');
|
||||
$assessments = Assessment::model()->findAll($criteria);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->compare('scope', 'G');
|
||||
$assessments = Assessment::model()->findAll($oCriteria);
|
||||
if (Assessment::model()->hasErrors()) safeDie(Assessment::model()->getError());
|
||||
foreach ($assessments as $assessment)
|
||||
{
|
||||
|
@ -540,25 +519,19 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
$aDelete['assessments'][] = array('id' => $assessment['id'], 'assessment' => $assessment['name'], 'reason' => $clang->gT('No matching group'));
|
||||
}
|
||||
}
|
||||
unset($assessments);
|
||||
/**********************************************************************/
|
||||
/* Check answers */
|
||||
/**********************************************************************/
|
||||
$answers = Answer::model()->findAll();
|
||||
if (Answer::model()->hasErrors()) safeDie(Answer::model()->getError());
|
||||
$okQuestion = array();
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
|
||||
$oCriteria->condition = '(q.qid IS NULL)';
|
||||
|
||||
$answers = Answer::model()->findAll($oCriteria);
|
||||
foreach ($answers as $answer)
|
||||
{
|
||||
if (!array_key_exists($answer['qid'], $okQuestion)) {
|
||||
$iAnswerCount = Question::model()->countByAttributes(array('qid' => $answer['qid']));
|
||||
if (Question::model()->hasErrors()) safeDie(Question::model()->getError());
|
||||
if (!$iAnswerCount) {
|
||||
$aDelete['answers'][] = array('qid' => $answer['qid'], 'code' => $answer['code'], 'reason' => $clang->gT('No matching question'));
|
||||
} else {
|
||||
$okQuestion[$answer['qid']] = $answer['qid'];
|
||||
}
|
||||
}
|
||||
$aDelete['answers'][] = array('qid' => $answer['qid'], 'code' => $answer['code'], 'reason' => $clang->gT('No matching question'));
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* Check survey languagesettings and restore them if they don't exist */
|
||||
/***************************************************************************/
|
||||
|
@ -590,7 +563,7 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Check survey language settings */
|
||||
|
@ -599,9 +572,9 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
|
||||
$sids = array();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('surveyls_survey_id', $sids);
|
||||
$surveys_languagesettings = SurveyLanguageSetting::model()->findAll($criteria);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->addNotInCondition('surveyls_survey_id', $sids);
|
||||
$surveys_languagesettings = SurveyLanguageSetting::model()->findAll($oCriteria);
|
||||
if (SurveyLanguageSetting::model()->hasErrors()) safeDie(SurveyLanguageSetting::model()->getError());
|
||||
|
||||
foreach ($surveys_languagesettings as $surveys_languagesetting)
|
||||
|
@ -612,23 +585,14 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
/**********************************************************************/
|
||||
/* Check questions */
|
||||
/**********************************************************************/
|
||||
$questions = Question::model()->findAll();
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->join = 'LEFT JOIN {{surveys}} s ON t.sid=s.sid LEFT JOIN {{groups}} g ON t.gid=g.gid';
|
||||
$oCriteria->condition = '(g.gid IS NULL) OR (s.sid IS NULL)';
|
||||
$questions = Question::model()->findAll($oCriteria);
|
||||
if (Question::model()->hasErrors()) safeDie(Question::model()->getError());
|
||||
$groups = QuestionGroup::model()->findAll();
|
||||
if (QuestionGroup::model()->hasErrors()) safeDie(QuestionGroup::model()->getError());
|
||||
$gids = array();
|
||||
foreach ($groups as $group) $gids[] = $group['gid'];
|
||||
|
||||
foreach ($questions as $question)
|
||||
{
|
||||
//Make sure the group exists
|
||||
if (!in_array($question['gid'], $gids)) {
|
||||
$aDelete['questions'][] = array('qid' => $question['qid'], 'reason' => $clang->gT('No matching group') . " ({$question['gid']})");
|
||||
}
|
||||
//Make sure survey exists
|
||||
if (!in_array($question['sid'], $sids)) {
|
||||
$aDelete['questions'][] = array('qid' => $question['qid'], 'reason' => $clang->gT('There is no matching survey.') . " ({$question['sid']})");
|
||||
}
|
||||
$aDelete['questions'][] = array('qid' => $question['qid'], 'reason' => $clang->gT('No matching group') . " ({$question['gid']})");
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
@ -638,9 +602,9 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
if (Survey::model()->hasErrors()) safeDie(Survey::model()->getError());
|
||||
$sids = array();
|
||||
foreach ($surveys as $survey) $sids[] = $survey['sid'];
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addNotInCondition('sid', $sids);
|
||||
$groups = QuestionGroup::model()->findAll($criteria);
|
||||
$oCriteria = new CDbCriteria;
|
||||
$oCriteria->addNotInCondition('sid', $sids);
|
||||
$groups = QuestionGroup::model()->findAll($oCriteria);
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
$aDelete['groups'][] = array('gid' => $group['gid'], 'reason' => $clang->gT('There is no matching survey.') . ' SID:' . $group['sid']);
|
||||
|
@ -653,14 +617,12 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
//2: Check if that survey id still exists
|
||||
//3: If it doesn't offer it for deletion
|
||||
$sQuery = dbSelectTablesLike('{{old_survey}}%');
|
||||
$aResult = dbQueryOrFalse($sQuery) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
|
||||
$aTables = $aResult->readAll();
|
||||
$aTables = Yii::app()->db->createCommand($sQuery)->queryColumn();
|
||||
|
||||
$aOldSIDs = array();
|
||||
$aSIDs = array();
|
||||
foreach ($aTables as $sTable)
|
||||
{
|
||||
$sTable = reset($sTable);
|
||||
list($sOldText, $SurveyText, $iSurveyID, $sDate) = explode('_', substr($sTable, strlen($sDBPrefix)));
|
||||
$aOldSIDs[] = $iSurveyID;
|
||||
$aFullOldSIDs[$iSurveyID][] = $sTable;
|
||||
|
@ -724,8 +686,8 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
//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 = dbQueryOrFalse(dbSelectTablesLike('{{old_token}}%')) or safeDie("Couldn't get list of conditions from database<br />$sQuery<br />");
|
||||
$aTables = $aResult->readAll();
|
||||
$sQuery = dbSelectTablesLike('{{old_token}}%');
|
||||
$aTables = Yii::app()->db->createCommand($sQuery)->queryColumn();
|
||||
|
||||
$aOldTokenSIDs = array();
|
||||
$aTokenSIDs = array();
|
||||
|
@ -733,8 +695,6 @@ class CheckIntegrity extends Survey_Common_Action
|
|||
|
||||
foreach ($aTables as $sTable)
|
||||
{
|
||||
$sTable = reset($sTable);
|
||||
|
||||
list($sOldText, $SurveyText, $iSurveyID, $sDateTime) = explode('_', substr($sTable, strlen($sDBPrefix)));
|
||||
$aTokenSIDs[] = $iSurveyID;
|
||||
$aFullOldTokenSIDs[$iSurveyID][] = $sTable;
|
||||
|
|
|
@ -515,6 +515,7 @@ class conditionsaction extends Survey_Common_Action {
|
|||
|
||||
//BEGIN: GATHER INFORMATION
|
||||
// 1: Get information for this question
|
||||
// @todo : use viewHelper::getFieldText and getFieldCode for 2.06 for string show to user
|
||||
if (!isset($qid)) { $qid = returnGlobal('qid'); }
|
||||
if (!isset($iSurveyID)) { $iSurveyID = returnGlobal('sid'); }
|
||||
$thissurvey = getSurveyInfo($iSurveyID);
|
||||
|
@ -814,8 +815,10 @@ class conditionsaction extends Survey_Common_Action {
|
|||
foreach ($aresult as $arows)
|
||||
{
|
||||
$attr = getQuestionAttributeValues($rows['qid']);
|
||||
$label1 = isset($attr['dualscale_headerA']) ? $attr['dualscale_headerA'] : 'Label1';
|
||||
$label2 = isset($attr['dualscale_headerB']) ? $attr['dualscale_headerB'] : 'Label2';
|
||||
$sLanguage=Survey::model()->findByPk($iSurveyID)->language;
|
||||
// dualscale_header are allways set, but can be empty
|
||||
$label1 = empty($attr['dualscale_headerA'][$sLanguage]) ? gt('Scale 1') : $attr['dualscale_headerA'][$sLanguage];
|
||||
$label2 = empty($attr['dualscale_headerB'][$sLanguage]) ? gt('Scale 2') : $attr['dualscale_headerB'][$sLanguage];
|
||||
$shortanswer = "{$arows['title']}: [" . strip_tags($arows['question']) . "][$label1]";
|
||||
$shortquestion = $rows['title'].":$shortanswer ".strip_tags($rows['question']);
|
||||
$cquestions[] = array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."#0");
|
||||
|
@ -1280,7 +1283,7 @@ class conditionsaction extends Survey_Common_Action {
|
|||
->bindValue(":lang1", $sLanguage, PDO::PARAM_STR)
|
||||
->bindValue(":lang2", $sLanguage, PDO::PARAM_STR)
|
||||
->query() or safeDie ("Couldn't get other conditions for question $qid<br />$query<br />");
|
||||
|
||||
|
||||
$querytoken = "SELECT count(*) as recordcount "
|
||||
."FROM {{conditions}} "
|
||||
."WHERE "
|
||||
|
@ -1310,7 +1313,7 @@ class conditionsaction extends Survey_Common_Action {
|
|||
->bindValue(":scenario", $scenarionr['scenario'], PDO::PARAM_INT)
|
||||
->bindValue(":qid", $qid, PDO::PARAM_INT)
|
||||
->query() or safeDie ("Couldn't get other conditions for question $qid<br />$query<br />");
|
||||
|
||||
|
||||
$conditionscount=$conditionscount+$conditionscounttoken;
|
||||
|
||||
if ($conditionscount > 0)
|
||||
|
@ -1341,19 +1344,17 @@ class conditionsaction extends Survey_Common_Action {
|
|||
$markcidstyle="editedrow";
|
||||
}
|
||||
|
||||
if (isset($currentfield) && $currentfield != $rows['cfieldname'])
|
||||
if (isset($currentfield) && $currentfield != $rows['cfieldname'] )
|
||||
{
|
||||
$aViewUrls['output'] .= "<tr class='evenrow'>\n"
|
||||
."\t<td colspan='2'>\n"
|
||||
."<span><strong>"
|
||||
.$clang->gT("and")."</strong></span></td></tr>";
|
||||
."\t<td colspan='2' class='operator'>\n"
|
||||
.$clang->gT("and")."</td></tr>";
|
||||
}
|
||||
elseif (isset($currentfield))
|
||||
{
|
||||
$aViewUrls['output'] .= "<tr class='evenrow'>\n"
|
||||
."\t<td colspan='2'>\n"
|
||||
."<span><strong>"
|
||||
.$clang->gT("or")."</strong></span></td></tr>";
|
||||
."\t<td colspan='2' class='operator'>\n"
|
||||
.$clang->gT("or")."</td></tr>";
|
||||
}
|
||||
|
||||
$aViewUrls['output'] .= "\t<tr class='{$markcidstyle}'>\n"
|
||||
|
@ -1378,14 +1379,23 @@ class conditionsaction extends Survey_Common_Action {
|
|||
{
|
||||
$leftOperandType = 'tokenattr';
|
||||
$aTokenAttrNames=getTokenFieldsAndNames($iSurveyID);
|
||||
if (count($aTokenAttrNames) != 0)
|
||||
if(isset($aTokenAttrNames[strtolower($extractedTokenAttr[1])]))
|
||||
{
|
||||
$thisAttrName=HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description'])." [".$clang->gT("From token table")."]";
|
||||
$thisAttrName=HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$thisAttrName=HTMLEscape($extractedTokenAttr[1])." [".$clang->gT("Inexistant token table")."]";
|
||||
$thisAttrName=HTMLEscape($extractedTokenAttr[1]);
|
||||
}
|
||||
if(tableExists("{{tokens_$iSurveyID}}"))
|
||||
{
|
||||
$thisAttrName.= " [".$clang->gT("From token table")."]";
|
||||
}
|
||||
else
|
||||
{
|
||||
$thisAttrName.= " [".$clang->gT("Inexistant token table")."]";
|
||||
}
|
||||
|
||||
$aViewUrls['output'] .= "\t$thisAttrName\n";
|
||||
// TIBO not sure this is used anymore !!
|
||||
$conditionsList[]=array("cid"=>$rows['cid'],
|
||||
|
@ -1473,7 +1483,7 @@ class conditionsaction extends Survey_Common_Action {
|
|||
}
|
||||
}
|
||||
}
|
||||
// if $rightOperandType is still unkown then it is a simple constant
|
||||
// if $rightOperandType is still unknown then it is a simple constant
|
||||
if ($rightOperandType == 'unknown')
|
||||
{
|
||||
$rightOperandType = 'constantVal';
|
||||
|
@ -1524,7 +1534,7 @@ class conditionsaction extends Survey_Common_Action {
|
|||
|
||||
// now set the corresponding hidden input field
|
||||
// depending on the rightOperandType
|
||||
// This is used when Editting a condition
|
||||
// This is used when editing a condition
|
||||
if ($rightOperandType == 'predefinedAnsw')
|
||||
{
|
||||
$aViewUrls['output'] .= CHtml::hiddenField('EDITcanswers[]', HTMLEscape($rows['value']), array(
|
||||
|
|
|
@ -95,11 +95,30 @@ class database extends Survey_Common_Action
|
|||
{
|
||||
foreach ($aSurveyLanguages as $sLanguage)
|
||||
{
|
||||
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage.'_0')))
|
||||
{
|
||||
$this->_updateDefaultValues($iQuestionID,0,0,'',$sLanguage,Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage.'_0'),true);
|
||||
// Qick and dirty insert for yes/no defaul value
|
||||
// write the the selectbox option, or if "EM" is slected, this value to table
|
||||
if ($sQuestionType == 'Y'){
|
||||
/// value for all langs
|
||||
if (Yii::app()->request->getPost('samedefault') == 1){
|
||||
$sLanguage = $aSurveyLanguages[0]; // turn
|
||||
}else{
|
||||
$sCurrentLang = $sLanguage; // edit the next lines
|
||||
}
|
||||
if ( Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage) == 'EM') { // Case EM, write expression to database
|
||||
$this->_updateDefaultValues($iQuestionID,0,0,'',$sLanguage,Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage.'_EM'),true);
|
||||
}
|
||||
else{
|
||||
// Case "other", write list value to database
|
||||
$this->_updateDefaultValues($iQuestionID,0,0,'',$sLanguage,Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage),true);
|
||||
}
|
||||
///// end yes/no
|
||||
}else{
|
||||
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage.'_0')))
|
||||
{
|
||||
$this->_updateDefaultValues($iQuestionID,0,0,'',$sLanguage,Yii::app()->request->getPost('defaultanswerscale_0_'.$sLanguage.'_0'),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("Default value settings were successfully saved.");
|
||||
LimeExpressionManager::SetDirtyFlag();
|
||||
|
@ -135,12 +154,6 @@ class database extends Survey_Common_Action
|
|||
for ($iSortOrderID=1;$iSortOrderID<$iMaxCount;$iSortOrderID++)
|
||||
{
|
||||
$sCode=sanitize_paranoid_string(Yii::app()->request->getPost('code_'.$iSortOrderID.'_'.$iScaleID));
|
||||
if (Yii::app()->request->getPost('oldcode_'.$iSortOrderID.'_'.$iScaleID)) {
|
||||
$sOldCode=sanitize_paranoid_string(Yii::app()->request->getPost('oldcode_'.$iSortOrderID.'_'.$iScaleID));
|
||||
if($sCode !== $sOldCode) {
|
||||
Condition::model()->updateAll(array('value'=>$sCode), 'cqid=:cqid AND value=:value', array(':cqid'=>$iQuestionID, ':value'=>$sOldCode));
|
||||
}
|
||||
}
|
||||
|
||||
$iAssessmentValue=(int) Yii::app()->request->getPost('assessment_'.$iSortOrderID.'_'.$iScaleID);
|
||||
foreach ($aSurveyLanguages as $sLanguage)
|
||||
|
@ -161,8 +174,11 @@ class database extends Survey_Common_Action
|
|||
{
|
||||
Yii::app()->setFlashMessage($clang->gT("Failed to update answers"),'error');
|
||||
}
|
||||
} // foreach ($alllanguages as $language)
|
||||
if(isset($sOldCode) && $sCode !== $sOldCode) {
|
||||
}
|
||||
// Updating code (oldcode!==null) => update condition with the new code
|
||||
$sOldCode=Yii::app()->request->getPost('oldcode_'.$iSortOrderID.'_'.$iScaleID);
|
||||
if(isset($sOldCode) && $sCode !== $sOldCode)
|
||||
{
|
||||
Condition::model()->updateAll(array('value'=>$sCode), 'cqid=:cqid AND value=:value', array(':cqid'=>$iQuestionID, ':value'=>$sOldCode));
|
||||
}
|
||||
} // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++)
|
||||
|
@ -283,7 +299,14 @@ class database extends Survey_Common_Action
|
|||
$oSubQuestion->scale_id=$iScaleID;
|
||||
}
|
||||
}
|
||||
$bSubQuestionResult=$oSubQuestion->save();
|
||||
if ($oSubQuestion->qid) {
|
||||
switchMSSQLIdentityInsert('questions',true);
|
||||
$bSubQuestionResult=$oSubQuestion->save();
|
||||
switchMSSQLIdentityInsert('questions',false);
|
||||
}else
|
||||
{
|
||||
$bSubQuestionResult=$oSubQuestion->save();
|
||||
}
|
||||
if($bSubQuestionResult)
|
||||
{
|
||||
if(substr($subquestionkey,0,3)!='new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition])
|
||||
|
@ -894,10 +917,6 @@ class database extends Survey_Common_Action
|
|||
$url = Yii::app()->request->getPost('url_'.$langname);
|
||||
if ($url == 'http://') {$url="";}
|
||||
|
||||
$short_title = html_entity_decode(Yii::app()->request->getPost('short_title_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
$description = html_entity_decode(Yii::app()->request->getPost('description_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
$welcome = html_entity_decode(Yii::app()->request->getPost('welcome_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
$endtext = html_entity_decode(Yii::app()->request->getPost('endtext_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
$sURLDescription = html_entity_decode(Yii::app()->request->getPost('urldescrip_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
$sURL = html_entity_decode(Yii::app()->request->getPost('url_'.$langname), ENT_QUOTES, "UTF-8");
|
||||
|
||||
|
|
|
@ -138,9 +138,9 @@ class dataentry extends Survey_Common_Action
|
|||
$clang = $this->getController()->lang;
|
||||
$filePath = $this->_moveUploadedFile($aData);
|
||||
//$aFileContents = $this->_readFile($filePath);
|
||||
|
||||
|
||||
Yii::app()->loadHelper('admin/import');
|
||||
// Fill option
|
||||
// Fill option
|
||||
$aOptions=array();
|
||||
$aOptions['bDeleteFistLine']=(Yii::app()->request->getPost('dontdeletefirstline') == "dontdeletefirstline")?false:true;// Force, maybe function change ;)
|
||||
if(Yii::app()->request->getPost('noid')==="noid"){
|
||||
|
@ -157,7 +157,7 @@ class dataentry extends Survey_Common_Action
|
|||
$aData['class']="";
|
||||
$aData['title']=$clang->gT("Import a VV response data file");
|
||||
$aData['aResult']['success'][]=$clang->gT("File upload succeeded.");
|
||||
if(isset($aResult['success'])){
|
||||
if(isset($aResult['success'])){
|
||||
$aData['aResult']['success']=array_merge($aData['aResult']['success'],$aResult['success']);
|
||||
}
|
||||
$aData['aResult']['errors']=(isset($aResult['errors'])) ? $aResult['errors'] : false;
|
||||
|
@ -251,7 +251,7 @@ class dataentry extends Survey_Common_Action
|
|||
{
|
||||
if (!App()->getRequest()->isPostRequest || App()->getRequest()->getPost('table') == 'none')
|
||||
{
|
||||
|
||||
|
||||
// Schema that serves as the base for compatibility checks.
|
||||
$baseSchema = SurveyDynamic::model($iSurveyId)->getTableSchema();
|
||||
$tables = App()->getApi()->getOldResponseTables($iSurveyId);
|
||||
|
@ -272,7 +272,7 @@ class dataentry extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$aData = array();
|
||||
$aData['surveyid'] = $iSurveyId;
|
||||
$aData['settings']['table'] = array(
|
||||
|
@ -297,10 +297,11 @@ class dataentry extends Survey_Common_Action
|
|||
}
|
||||
else
|
||||
{
|
||||
$aSRIDConversions=array();
|
||||
$targetSchema = SurveyDynamic::model($iSurveyId)->getTableSchema();
|
||||
$sourceTable = PluginDynamic::model($_POST['table']);
|
||||
$sourceSchema = $sourceTable->getTableSchema();
|
||||
|
||||
|
||||
$fieldMap = array();
|
||||
$pattern = '/([\d]+)X([\d]+)X([\d]+.*)/';
|
||||
foreach ($sourceSchema->getColumnNames() as $name)
|
||||
|
@ -332,7 +333,7 @@ class dataentry extends Survey_Common_Action
|
|||
$sourceResponses = new CDataProviderIterator(new CActiveDataProvider($sourceTable), 500);
|
||||
foreach ($sourceResponses as $sourceResponse)
|
||||
{
|
||||
|
||||
$iOldID=$sourceResponse->id;
|
||||
// Using plugindynamic model because I dont trust surveydynamic.
|
||||
$targetResponse = new PluginDynamic("{{survey_$iSurveyId}}");
|
||||
|
||||
|
@ -342,37 +343,36 @@ class dataentry extends Survey_Common_Action
|
|||
}
|
||||
$imported++;
|
||||
$targetResponse->save();
|
||||
$aSRIDConversions[$iOldID]=$targetResponse->id;
|
||||
unset($targetResponse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Yii::app()->session['flashmessage'] = sprintf(gT("%s old response(s) were successfully imported."), $imported);
|
||||
$sOldTimingsTable=substr($sourceTable->tableName(),0,strrpos($sourceTable->tableName(),'_')).'_timings'.substr($sourceTable->tableName(),strrpos($sourceTable->tableName(),'_'));
|
||||
$sNewTimingsTable = "{{{$surveyid}_timings}}";
|
||||
$sOldTimingsTable=substr(substr($sourceTable->tableName(),0,strrpos($sourceTable->tableName(),'_')).'_timings'.substr($sourceTable->tableName(),strrpos($sourceTable->tableName(),'_')),strlen(Yii::app()->db->tablePrefix));
|
||||
$sNewTimingsTable = "survey_{$surveyid}_timings";
|
||||
|
||||
if (isset($_POST['timings']) && $_POST['timings'] == 1 && tableExists($sOldTimingsTable) && tableExists($sNewTimingsTable))
|
||||
{
|
||||
// Import timings
|
||||
$aFieldsOldTimingTable=array_values($schema->getTable($sOldTimingsTable)->columnNames);
|
||||
$aFieldsNewTimingTable=array_values($schema->getTable($sNewTimingsTable)->columnNames);
|
||||
$arDestination=SurveyTimingDynamic::model($surveyid);
|
||||
$aFieldsOldTimingTable=array_values(Yii::app()->db->schema->getTable('{{'.$sOldTimingsTable.'}}')->columnNames);
|
||||
$aFieldsNewTimingTable=array_values(Yii::app()->db->schema->getTable('{{'.$sNewTimingsTable.'}}')->columnNames);
|
||||
|
||||
$aValidTimingFields=array_intersect($aFieldsOldTimingTable,$aFieldsNewTimingTable);
|
||||
|
||||
$queryOldValues = "SELECT ".implode(", ",$aValidTimingFields)." FROM {$sOldTimingsTable} ";
|
||||
$resultOldValues = dbExecuteAssoc($queryOldValues) or show_error("Error:<br />$queryOldValues<br />");
|
||||
$sQueryOldValues = "SELECT ".implode(", ",$aValidTimingFields)." FROM {{{$sOldTimingsTable}}} ";
|
||||
$aQueryOldValues = Yii::app()->db->createCommand($sQueryOldValues)->query()->readAll(); //Checked
|
||||
$iRecordCountT=0;
|
||||
$aSRIDConversions=array();
|
||||
foreach ($resultOldValues->readAll() as $sTable)
|
||||
foreach ($aQueryOldValues as $sRecord)
|
||||
{
|
||||
if (isset($aSRIDConversions[$sTable['id']]))
|
||||
if (isset($aSRIDConversions[$sRecord['id']]))
|
||||
{
|
||||
$sTable['id']=$aSRIDConversions[$sTable['id']];
|
||||
$sRecord['id']=$aSRIDConversions[$sRecord['id']];
|
||||
}
|
||||
else continue;
|
||||
//$sInsertSQL=Yii::app()->db->GetInsertSQL($sNewTimingsTable,$row);
|
||||
$sInsertSQL="INSERT into {$sNewTimingsTable} (".implode(",", array_map("dbQuoteID", array_keys($sTable))).") VALUES (".implode(",", array_map("dbQuoteAll", array_values($sTable))).")";
|
||||
$aTables = dbExecuteAssoc($sInsertSQL) or show_error("Error:<br />$sInsertSQL<br />");
|
||||
Yii::app()->db->createCommand()->insert("{{{$sNewTimingsTable}}}",$sRecord);
|
||||
$iRecordCountT++;
|
||||
}
|
||||
Yii::app()->session['flashmessage'] = sprintf(gT("%s old response(s) and according timings were successfully imported."),$imported,$iRecordCountT);
|
||||
|
@ -1828,7 +1828,7 @@ class dataentry extends Survey_Common_Action
|
|||
$message .= $clang->gT("Reload your survey by clicking on the following link (or pasting it into your browser):")."\n";
|
||||
$message .= Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}/loadall/reload/scid/{$scid}/loadname/".rawurlencode ($saver['identifier'])."/loadpass/".rawurlencode ($saver['password'])."/lang/".rawurlencode($saver['language']));
|
||||
if (isset($tokendata['token'])) { $message .= "/token/".rawurlencode($tokendata['token']); }
|
||||
|
||||
|
||||
$from = $thissurvey['adminemail'];
|
||||
|
||||
if (SendEmailMessage($message, $subject, $saver['email'], $from, $sitename, false, getBounceEmail($surveyid)))
|
||||
|
@ -2120,7 +2120,7 @@ class dataentry extends Survey_Common_Action
|
|||
case "R": //RANKING TYPE QUESTION
|
||||
$thisqid=$deqrow['qid'];
|
||||
$ansquery = "SELECT * FROM {{answers}} WHERE qid=$thisqid AND language='{$sDataEntryLanguage}' ORDER BY sortorder, answer";
|
||||
$ansresult = dbExecuteAssoc($ansquery);
|
||||
$ansresult = dbExecuteAssoc($ansquery);
|
||||
$ansresult = $ansresult->readAll();
|
||||
$anscount = count($ansresult);
|
||||
|
||||
|
@ -2150,7 +2150,7 @@ class dataentry extends Survey_Common_Action
|
|||
}
|
||||
$meaquery = "SELECT title, question FROM {{questions}} WHERE parent_qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' ORDER BY question_order";
|
||||
$mearesult = dbExecuteAssoc($meaquery);
|
||||
|
||||
|
||||
$cdata['mearesult'] = $mearesult->readAll();
|
||||
$meacount = count($cdata['mearesult']);
|
||||
$cdata['meacount'] = $meacount;
|
||||
|
|
|
@ -87,9 +87,9 @@ class emailtemplates extends Survey_Common_Action {
|
|||
$uploadUrl = Yii::app()->getBaseUrl(true) . substr(Yii::app()->getConfig('uploadurl'),strlen(Yii::app()->getConfig('publicurl'))-1);
|
||||
// We need the real path since we check that the resolved file name starts with this path.
|
||||
$uploadDir = realpath(Yii::app()->getConfig('uploaddir'));
|
||||
$save=Yii::app()->request->getPost('save','');
|
||||
$sSaveMethod=Yii::app()->request->getPost('save','');
|
||||
$clang = $this->getController()->lang;
|
||||
if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveylocale','update'))
|
||||
if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveylocale','update') && $sSaveMethod!='')
|
||||
{
|
||||
$languagelist = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
|
||||
$languagelist[] = Survey::model()->findByPk($iSurveyId)->language;
|
||||
|
@ -116,7 +116,7 @@ class emailtemplates extends Survey_Common_Action {
|
|||
unset($attachments[$index]);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
unset($attachments[$index]);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class emailtemplates extends Survey_Common_Action {
|
|||
{
|
||||
$_POST['attachments'][$langname] = array();
|
||||
}
|
||||
|
||||
|
||||
$attributes = array(
|
||||
'surveyls_email_invite_subj' => $_POST['email_invitation_subj_'.$langname],
|
||||
'surveyls_email_invite' => $_POST['email_invitation_'.$langname],
|
||||
|
@ -147,8 +147,9 @@ class emailtemplates extends Survey_Common_Action {
|
|||
$usquery = SurveyLanguageSetting::model()->updateAll($attributes,'surveyls_survey_id = :ssid AND surveyls_language = :sl', array(':ssid' => $iSurveyId, ':sl' => $langname));
|
||||
}
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("Email templates successfully saved.");
|
||||
$this->getController()->redirect(array('admin/emailtemplates/sa/index/surveyid/'.$iSurveyId));
|
||||
}
|
||||
if($save=='saveclose')
|
||||
if($sSaveMethod=='saveclose')
|
||||
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/'.$iSurveyId));
|
||||
else
|
||||
self::index($iSurveyId);
|
||||
|
@ -163,7 +164,7 @@ class emailtemplates extends Survey_Common_Action {
|
|||
* @param array $aData Data to be passed on. Optional.
|
||||
*/
|
||||
protected function _renderWrappedTemplate($sAction = 'emailtemplates', $aViewUrls = array(), $aData = array())
|
||||
{
|
||||
{
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'emailtemplates.js');
|
||||
|
||||
$aData['display']['menu_bars']['surveysummary'] = 'editemailtemplates';
|
||||
|
|
|
@ -154,7 +154,7 @@ class export extends Survey_Common_Action {
|
|||
|
||||
// Get info about the survey
|
||||
$thissurvey = getSurveyInfo($iSurveyID);
|
||||
|
||||
|
||||
// Load ExportSurveyResultsService so we know what exports are available
|
||||
$resultsService = new ExportSurveyResultsService();
|
||||
$exports = $resultsService->getExports();
|
||||
|
@ -190,15 +190,16 @@ class export extends Survey_Common_Action {
|
|||
{
|
||||
$sCode=viewHelper::getFieldCode($fieldinfo);
|
||||
$aFields[$sFieldName]=$sCode.' - '.htmlspecialchars(ellipsize(html_entity_decode(viewHelper::getFieldText($fieldinfo)),30,.6,'...'));
|
||||
$aFieldsOptions[$sFieldName]=array('title'=>viewHelper::getFieldText($fieldinfo),'data-fieldname'=>$fieldinfo['fieldname'],'data-emcode'=>viewHelper::getFieldCode($fieldinfo,array('LEMcompat'=>true))); // No need to filter title : Yii do it (remove all tag)
|
||||
}
|
||||
|
||||
|
||||
$data['SingleResponse']=(int)returnGlobal('id');
|
||||
$data['selecthide'] = $selecthide;
|
||||
$data['selectshow'] = $selectshow;
|
||||
$data['selectinc'] = $selectinc;
|
||||
$data['afieldcount'] = $iFieldCount;
|
||||
$data['aFields'] = $aFields;
|
||||
|
||||
$data['aFieldsOptions'] = $aFieldsOptions;
|
||||
//get max number of datasets
|
||||
$iMaximum = SurveyDynamic::model($iSurveyID)->getMaxId();
|
||||
|
||||
|
@ -207,7 +208,7 @@ class export extends Survey_Common_Action {
|
|||
$data['imageurl'] = Yii::app()->getConfig('imageurl');
|
||||
$data['thissurvey'] = $thissurvey;
|
||||
$data['display']['menu_bars']['browse'] = $clang->gT("Export results");
|
||||
|
||||
|
||||
// Export plugins, leave out all entries that are not plugin
|
||||
$exports = array_filter($exports);
|
||||
$exportData = array();
|
||||
|
@ -223,7 +224,7 @@ class export extends Survey_Common_Action {
|
|||
'tooltip' => $event->get('tooltip', null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$data['exports'] = $exportData; // Pass available exports
|
||||
|
||||
$this->_renderWrappedTemplate('export', 'exportresults_view', $data);
|
||||
|
@ -321,7 +322,7 @@ class export extends Survey_Common_Action {
|
|||
{
|
||||
global $length_vallabel;
|
||||
$iSurveyID = sanitize_int(Yii::app()->request->getParam('sid'));
|
||||
$clang = $this->getController()->lang;
|
||||
$clang = $this->getController()->lang;
|
||||
//for scale 1=nominal, 2=ordinal, 3=scale
|
||||
|
||||
// $typeMap = $this->_getTypeMap();
|
||||
|
@ -362,7 +363,7 @@ class export extends Survey_Common_Action {
|
|||
|
||||
if ( isset($_POST['dldata']) ) $subaction = "dldata";
|
||||
if ( isset($_POST['dlstructure']) ) $subaction = "dlstructure";
|
||||
|
||||
|
||||
if ( ! isset($subaction) )
|
||||
{
|
||||
$selecthide = "";
|
||||
|
@ -391,7 +392,7 @@ class export extends Survey_Common_Action {
|
|||
$this->_renderWrappedTemplate('export', 'spss_view', $data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get Base language:
|
||||
$language = Survey::model()->findByPk($iSurveyID)->language;
|
||||
$clang = new limesurvey_lang($language);
|
||||
|
@ -427,40 +428,33 @@ class export extends Survey_Common_Action {
|
|||
|
||||
//Now get the query string with all fields to export
|
||||
$query = SPSSGetQuery($iSurveyID, 500, 0); // Sample first 500 responses for adjusting fieldmap
|
||||
$result = $query->query();
|
||||
$result = $query->queryAll();
|
||||
|
||||
$num_fields = 0;
|
||||
//Now we check if we need to adjust the size of the field or the type of the field
|
||||
foreach ( $result as $row )
|
||||
{
|
||||
if($num_fields==0) {
|
||||
$num_fields = count($row);
|
||||
}
|
||||
$row = array_values($row);
|
||||
$fieldno = 0;
|
||||
|
||||
while ( $fieldno < $num_fields )
|
||||
foreach ( $fields as $iIndex=>$aField )
|
||||
{
|
||||
//Performance improvement, don't recheck fields that have valuelabels
|
||||
if ( ! isset($fields[$fieldno]['answers']) )
|
||||
if ( ! isset($aField['answers']) )
|
||||
{
|
||||
$strTmp = mb_substr(stripTagsFull($row[$fieldno]), 0, $iLength);
|
||||
$strTmp = mb_substr(stripTagsFull($row[$aField['sql_name']]), 0, $iLength);
|
||||
$len = mb_strlen($strTmp);
|
||||
|
||||
if ( $len > $fields[$fieldno]['size'] ) $fields[$fieldno]['size'] = $len;
|
||||
if ( $len > $fields[$iIndex]['size'] ) $fields[$iIndex]['size'] = $len;
|
||||
|
||||
if ( trim($strTmp) != '' )
|
||||
{
|
||||
if ( $fields[$fieldno]['SPSStype'] == 'F' && (isNumericExtended($strTmp) === FALSE || $fields[$fieldno]['size'] > 16) )
|
||||
if ( $fields[$iIndex]['SPSStype'] == 'F' && (isNumericExtended($strTmp) === FALSE || $fields[$iIndex]['size'] > 16) )
|
||||
{
|
||||
$fields[$fieldno]['SPSStype'] = 'A';
|
||||
$fields[$iIndex]['SPSStype'] = 'A';
|
||||
}
|
||||
}
|
||||
}
|
||||
$fieldno++;
|
||||
}
|
||||
}
|
||||
$result->close();
|
||||
|
||||
/**
|
||||
* End of DATA print out
|
||||
|
@ -503,7 +497,7 @@ class export extends Survey_Common_Action {
|
|||
{
|
||||
$field['size'] .= '.' . ($field['size']-1);
|
||||
}
|
||||
|
||||
|
||||
if ( !$field['hide'] ) echo "\n {$field['id']} {$field['SPSStype']}{$field['size']}";
|
||||
}
|
||||
|
||||
|
@ -872,6 +866,7 @@ class export extends Survey_Common_Action {
|
|||
|
||||
public function dumplabel()
|
||||
{
|
||||
if (!Permission::model()->hasGlobalPermission('labelsets','export')) die ('No permission.');
|
||||
$lid = sanitize_int(Yii::app()->request->getParam('lid'));
|
||||
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
|
||||
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
|
||||
|
@ -895,7 +890,7 @@ class export extends Survey_Common_Action {
|
|||
$fn = "limesurvey_labelset_" . implode('_', $lids) . ".lsl";
|
||||
$xml = getXMLWriter();
|
||||
|
||||
$this->_addHeaders($fn, "text/html/force-download", "Mon, 26 Jul 1997 05:00:00 GMT", "cache");
|
||||
$this->_addHeaders($fn, "application/force-download", "Mon, 26 Jul 1997 05:00:00 GMT", "cache");
|
||||
|
||||
$xml->openURI('php://output');
|
||||
|
||||
|
@ -948,27 +943,21 @@ class export extends Survey_Common_Action {
|
|||
if ( $aSurveyInfo['active'] == 'Y' )
|
||||
{
|
||||
getXMLDataSingleTable($iSurveyID, 'survey_' . $iSurveyID, 'Responses', 'responses', $sLSRFileName, FALSE);
|
||||
|
||||
$this->_addToZip($zip, $sLSRFileName, 'survey_' . $iSurveyID . '_responses.lsr');
|
||||
|
||||
unlink($sLSRFileName);
|
||||
}
|
||||
|
||||
if ( Yii::app()->db->schema->getTable('{{tokens_' . $iSurveyID . '}}') )
|
||||
if ( tableExists('{{tokens_' . $iSurveyID . '}}') )
|
||||
{
|
||||
getXMLDataSingleTable($iSurveyID, 'tokens_' . $iSurveyID, 'Tokens', 'tokens', $sLSTFileName);
|
||||
|
||||
$this->_addToZip($zip, $sLSTFileName, 'survey_' . $iSurveyID . '_tokens.lst');
|
||||
|
||||
unlink($sLSTFileName);
|
||||
}
|
||||
|
||||
if ( Yii::app()->db->schema->getTable('{{survey_' . $iSurveyID . '_timings}}') )
|
||||
if ( tableExists('{{survey_' . $iSurveyID . '_timings}}') )
|
||||
{
|
||||
getXMLDataSingleTable($iSurveyID, 'survey_' . $iSurveyID . '_timings', 'Timings', 'timings', $sLSIFileName);
|
||||
|
||||
$this->_addToZip($zip, $sLSIFileName, 'survey_' . $iSurveyID . '_timings.lsi');
|
||||
|
||||
unlink($sLSIFileName);
|
||||
}
|
||||
|
||||
|
@ -1027,7 +1016,7 @@ class export extends Survey_Common_Action {
|
|||
// now convert this xml into json format and then return
|
||||
echo _xmlToJson($surveyInXmlFormat);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
elseif ( $action == "exportstructurequexml" )
|
||||
{
|
||||
|
@ -1096,7 +1085,7 @@ class export extends Survey_Common_Action {
|
|||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header("Pragma: {$pragma}"); // HTTP/1.0
|
||||
}
|
||||
|
||||
|
||||
private function _xmlToJson($fileContents) {
|
||||
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
|
||||
$fileContents = trim(str_replace('"', "'", $fileContents));
|
||||
|
|
|
@ -57,21 +57,19 @@ class GlobalSettings extends Survey_Common_Action
|
|||
updateCheck();
|
||||
$this->getController()->redirect(array('admin/globalsettings'));
|
||||
}
|
||||
|
||||
|
||||
private function _displaySettings()
|
||||
{
|
||||
Yii::app()->loadHelper('surveytranslator');
|
||||
|
||||
//save refurl from where global settings screen is called!
|
||||
$refurl = Yii::app()->getRequest()->getUrlReferrer();
|
||||
|
||||
|
||||
// Some URLs are not to be allowed to refered back to.
|
||||
// These exceptions can be added to the $aReplacements array
|
||||
$aReplacements=array('admin/user/adduser'=>'admin/user/index',
|
||||
$aReplacements=array('admin/update/sa/step4b'=>'admin/sa/index',
|
||||
'admin/user/sa/adduser'=>'admin/user/sa/index',
|
||||
'admin/user/sa/setusertemplates'=>'admin/user/sa/index',
|
||||
'admin/user/setusertemplates'=>'admin/user/sa/index'
|
||||
|
||||
'admin/user/sa/setusertemplates'=>'admin/user/sa/index'
|
||||
);
|
||||
$refurl= str_replace(array_keys($aReplacements),array_values($aReplacements),$refurl);
|
||||
Yii::app()->session['refurl'] = htmlspecialchars($refurl); //just to be safe!
|
||||
|
@ -87,9 +85,9 @@ class GlobalSettings extends Survey_Common_Action
|
|||
$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');
|
||||
$datetimeobj = new date_time_converter(dateShift(getGlobalSetting("updatelastcheck"),'Y-m-d H:i:s',getGlobalSetting('timeadjust')), 'Y-m-d H:i:s');
|
||||
$data['updatelastcheck']=$datetimeobj->convert($dateformatdetails['phpdate'] . " H:i:s");
|
||||
|
||||
|
||||
$data['updateavailable'] = (getGlobalSetting("updateavailable") && Yii::app()->getConfig("updatable"));
|
||||
$data['updatable'] = Yii::app()->getConfig("updatable");
|
||||
$data['updateinfo'] = getGlobalSetting("updateinfo");
|
||||
|
@ -122,6 +120,18 @@ class GlobalSettings extends Survey_Common_Action
|
|||
$clang = $this->getController()->lang;
|
||||
Yii::app()->loadHelper('surveytranslator');
|
||||
|
||||
$iPDFFontSize = sanitize_int($_POST['pdffontsize']);
|
||||
if ($iPDFFontSize < 1)
|
||||
{
|
||||
$iPDFFontSize = 9;
|
||||
}
|
||||
|
||||
$iPDFLogoWidth = sanitize_int($_POST['pdflogowidth']);
|
||||
if ($iPDFLogoWidth < 1)
|
||||
{
|
||||
$iPDFLogoWidth = 50;
|
||||
}
|
||||
|
||||
$maxemails = $_POST['maxemails'];
|
||||
if (sanitize_int($_POST['maxemails']) < 1) {
|
||||
$maxemails = 1;
|
||||
|
@ -148,7 +158,12 @@ class GlobalSettings extends Survey_Common_Action
|
|||
setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode']));
|
||||
if (!Yii::app()->getConfig('demoMode'))
|
||||
{
|
||||
setGlobalSetting('defaulttemplate', sanitize_paranoid_string($_POST['defaulttemplate']));
|
||||
$sTemplate=Yii::app()->getRequest()->getPost("defaulttemplate");
|
||||
if(array_key_exists($sTemplate,getTemplateList()))// Filter template name
|
||||
{
|
||||
setGlobalSetting('defaulttemplate', $sTemplate);
|
||||
}
|
||||
|
||||
}
|
||||
setGlobalSetting('admintheme', sanitize_paranoid_string($_POST['admintheme']));
|
||||
setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir").DIRECTORY_SEPARATOR.sanitize_paranoid_string($_POST['admintheme']).DIRECTORY_SEPARATOR.'iconsize')));
|
||||
|
@ -163,7 +178,7 @@ class GlobalSettings extends Survey_Common_Action
|
|||
setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser')));
|
||||
|
||||
if (returnGlobal('bounceaccountpass') != 'enteredpassword') setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass')));
|
||||
|
||||
|
||||
setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl','')));
|
||||
setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug','0')));
|
||||
setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser')));
|
||||
|
@ -196,6 +211,11 @@ class GlobalSettings extends Survey_Common_Action
|
|||
if ($iSessionExpirationTime == 0) $iSessionExpirationTime = 7200;
|
||||
setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime);
|
||||
setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']);
|
||||
setGlobalSetting('pdffontsize', $iPDFFontSize);
|
||||
setGlobalSetting('pdfshowheader', $_POST['pdfshowheader']);
|
||||
setGlobalSetting('pdflogowidth', $iPDFLogoWidth);
|
||||
setGlobalSetting('pdfheadertitle', $_POST['pdfheadertitle']);
|
||||
setGlobalSetting('pdfheaderstring', $_POST['pdfheaderstring']);
|
||||
setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']);
|
||||
setGlobalSetting('googleanalyticsapikey',$_POST['googleanalyticsapikey']);
|
||||
setGlobalSetting('googletranslateapikey',$_POST['googletranslateapikey']);
|
||||
|
|
|
@ -319,37 +319,31 @@ class labels extends Survey_Common_Action
|
|||
*/
|
||||
public function process()
|
||||
{
|
||||
if ( Permission::model()->hasGlobalPermission('labelsets','update'))
|
||||
{
|
||||
if (isset($_POST['method']) && get_magic_quotes_gpc())
|
||||
$_POST['method'] = stripslashes($_POST['method']);
|
||||
|
||||
$action = returnGlobal('action');
|
||||
Yii::app()->loadHelper('admin/label');
|
||||
$lid = returnGlobal('lid');
|
||||
|
||||
if ($action == "updateset")
|
||||
if ($action == "updateset" && Permission::model()->hasGlobalPermission('labelsets','update'))
|
||||
{
|
||||
updateset($lid);
|
||||
Yii::app()->session['flashmessage'] = Yii::app()->lang->gT("Label set properties sucessfully updated.");
|
||||
Yii::app()->setFlashMessage(Yii::app()->lang->gT("Label set properties sucessfully updated."),'success');
|
||||
}
|
||||
if ($action == "insertlabelset")
|
||||
if ($action == "insertlabelset" && Permission::model()->hasGlobalPermission('labelsets','create'))
|
||||
$lid = insertlabelset();
|
||||
if (($action == "modlabelsetanswers") || ($action == "ajaxmodlabelsetanswers"))
|
||||
if (($action == "modlabelsetanswers" || ($action == "ajaxmodlabelsetanswers")) && Permission::model()->hasGlobalPermission('labelsets','update'))
|
||||
modlabelsetanswers($lid);
|
||||
if ($action == "deletelabelset")
|
||||
if ($action == "deletelabelset" && Permission::model()->hasGlobalPermission('labelsets','delete'))
|
||||
{
|
||||
if (deletelabelset($lid))
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = Yii::app()->lang->gT("Label set sucessfully deleted.");
|
||||
Yii::app()->setFlashMessage(Yii::app()->lang->gT("Label set sucessfully deleted."),'success');
|
||||
$lid = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ($lid)
|
||||
$this->getController()->redirect(array("admin/labels/sa/view/lid/" . $lid));
|
||||
else
|
||||
$this->getController()->redirect(array("admin/labels/sa/view"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,8 +354,11 @@ class labels extends Survey_Common_Action
|
|||
*/
|
||||
public function exportmulti()
|
||||
{
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'labels.js');
|
||||
$this->_renderWrappedTemplate('labels', 'exportmulti_view');
|
||||
if (Permission::model()->hasGlobalPermission('labelsets','export'))
|
||||
{
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'labels.js');
|
||||
$this->_renderWrappedTemplate('labels', 'exportmulti_view');
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllSets()
|
||||
|
@ -372,9 +369,9 @@ class labels extends Survey_Common_Action
|
|||
|
||||
foreach($results as $row)
|
||||
{
|
||||
$output[$row->lid] = $row->getAttribute('label_name');
|
||||
$output[$row->lid] = flattenText($row->getAttribute('label_name'));
|
||||
}
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo ls_json_encode($output);
|
||||
}
|
||||
|
||||
|
@ -383,6 +380,7 @@ class labels extends Survey_Common_Action
|
|||
$lid = Yii::app()->getRequest()->getPost('lid');
|
||||
$answers = Yii::app()->getRequest()->getPost('answers');
|
||||
$code = Yii::app()->getRequest()->getPost('code');
|
||||
$aAssessmentValues = Yii::app()->getRequest()->getPost('assessmentvalues',array());
|
||||
//Create new label set
|
||||
$language = "";
|
||||
foreach ($answers as $lang => $answer) {
|
||||
|
@ -412,6 +410,7 @@ class labels extends Survey_Common_Action
|
|||
$label->title = $ans;
|
||||
$label->sortorder = $key;
|
||||
$label->language = $lang;
|
||||
$label->assessment_value = isset($aAssessmentValues[$key])?$aAssessmentValues[$key]:0;
|
||||
if(!$label->save())
|
||||
$res = 'fail';
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class participantsaction extends Survey_Common_Action
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Loads jqGrid for the view
|
||||
* @param string $sScript Subaction
|
||||
|
@ -77,23 +77,23 @@ class participantsaction extends Survey_Common_Action
|
|||
protected function _renderWrappedTemplate($sAction = 'participants', $aViewUrls = array(), $aData = array())
|
||||
{
|
||||
App()->getClientScript()->registerPackage('bootstrap-multiselect');
|
||||
$aData['display']['menu_bars'] = false;
|
||||
$aData['display']['menu_bars'] = false;
|
||||
foreach((array) $aViewUrls as $sViewUrl)
|
||||
{
|
||||
$a_ViewUrls[] = $sViewUrl . '_view';
|
||||
}
|
||||
parent::_renderWrappedTemplate($sAction, $a_ViewUrls, $aData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export to csv using optional search/filter
|
||||
*
|
||||
*
|
||||
* @param type $search CDCriteria?
|
||||
* @paran mixed $mAttributeIDs Empty array for no attributes, or array of attribute IDs or null for all attributes
|
||||
* @paran mixed $mAttributeIDs Empty array for no attributes, or array of attribute IDs or null for all attributes
|
||||
*/
|
||||
private function csvExport($search = null, $aAttributeIDs=null) {
|
||||
Yii::app()->loadHelper('export');
|
||||
|
||||
Yii::app()->loadHelper('export');
|
||||
|
||||
//If super admin all the participants will be visible
|
||||
if (Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ class participantsaction extends Survey_Common_Action
|
|||
} else {
|
||||
$iUserID = Yii::app()->session['loginID'];
|
||||
}
|
||||
|
||||
$aAttributeIDs=array_combine($aAttributeIDs,$aAttributeIDs);
|
||||
$query = Participant::model()->getParticipants(0, 0, $aAttributeIDs, null, $search, $iUserID);
|
||||
if (!$query)
|
||||
return false;
|
||||
|
@ -109,14 +109,14 @@ class participantsaction extends Survey_Common_Action
|
|||
// Field names in the first row
|
||||
$fields = array('participant_id', 'firstname', 'lastname', 'email', 'language', 'blacklisted', 'owner_uid');
|
||||
$outputarray = array(); // The array to be passed to the export helper to be written to a csv file
|
||||
|
||||
|
||||
$outputarray[0] = $fields; //fields written to output array
|
||||
|
||||
// If attribute fields are selected, add them to the output
|
||||
if ($aAttributeIDs==null)
|
||||
{
|
||||
$aAttributes = ParticipantAttributeName::model()->getAllAttributes();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($aAttributeIDs as $value)
|
||||
|
@ -126,29 +126,29 @@ class participantsaction extends Survey_Common_Action
|
|||
$attributename = ParticipantAttributeName::model()->getAttributeNames($value);
|
||||
$outputarray[0][] = $attributename[0]['attribute_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fieldNeededKeys=array_fill_keys($fields, '');
|
||||
$fieldKeys = array_flip($fields);
|
||||
$fieldNeededKeys=array_fill_keys($outputarray[0], '');
|
||||
foreach ($query as $field => $aData)
|
||||
{
|
||||
$outputarray[] = array_merge($fieldNeededKeys,array_intersect_key($aData, $fieldKeys));
|
||||
}
|
||||
CPDBExport($outputarray, "central_" . time());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string with the number of participants available for export or 0
|
||||
*
|
||||
*
|
||||
* @param type $search
|
||||
* @return string|0
|
||||
*/
|
||||
protected function csvExportCount($search = null)
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
|
||||
|
||||
$attid = ParticipantAttributeName::model()->getVisibleAttributes();
|
||||
|
||||
|
||||
//If super admin all the participants will be visible
|
||||
if (Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ class participantsaction extends Survey_Common_Action
|
|||
} else {
|
||||
$iUserID = Yii::app()->session['loginID'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$count = Participant::model()->getParticipantsCount($attid, $search, $iUserID);
|
||||
|
||||
|
@ -253,7 +253,7 @@ class participantsaction extends Survey_Common_Action
|
|||
);
|
||||
App()->getClientScript()->registerPackage('jqgrid');
|
||||
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . 'displayParticipants.css');
|
||||
|
||||
|
||||
|
||||
// loads the participant panel view and display participant view
|
||||
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'displayParticipants'), $aData);
|
||||
|
@ -400,16 +400,16 @@ class participantsaction extends Survey_Common_Action
|
|||
$aData->total = ceil(ParticipantAttributeName::model()->getCPDBAttributes(true) / $limit);
|
||||
$i = 0;
|
||||
foreach($records as $row) { //Iterate through each attribute
|
||||
$sAttributeCaption=$row->defaultname; //Choose the first item by default
|
||||
$sAttributeCaption=htmlspecialchars($row->defaultname); //Choose the first item by default
|
||||
foreach($row->participant_attribute_names_lang as $names) { //Iterate through each language version of this attribute
|
||||
if($names->lang == Yii::app()->session['adminlang']) {$sAttributeCaption= $sAttributeCaption." ({$names->attribute_name})";} //Override the default with the admin language version if found
|
||||
if($names->lang == Yii::app()->session['adminlang']) {$sAttributeCaption= $sAttributeCaption.htmlspecialchars(" ({$names->attribute_name})");} //Override the default with the admin language version if found
|
||||
}
|
||||
$aData->rows[$i]['id'] = $row->attribute_id;
|
||||
$aData->rows[$i]['cell'] = array('', $sAttributeCaption, $attribute_types[$row->attribute_type], $row->visible);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo ls_json_encode($aData);
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ class participantsaction extends Survey_Common_Action
|
|||
* Basically takes the call on can_edit
|
||||
*/
|
||||
function editAttributeInfo()
|
||||
{
|
||||
{
|
||||
$clang = Yii::app()->lang;
|
||||
$operation = Yii::app()->request->getPost('oper');
|
||||
|
||||
|
@ -584,7 +584,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$i = 0;
|
||||
foreach ($records as $row)
|
||||
{
|
||||
$oSurvey=Survey::model()->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findByAttributes(array('sid' => $row['survey_id']));
|
||||
$oSurvey=Survey::model()->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findByAttributes(array('sid' => $row['survey_id']));
|
||||
foreach($oSurvey->languagesettings as $oLanguageSetting)
|
||||
{
|
||||
$surveyname= $oLanguageSetting->surveyls_title;
|
||||
|
@ -614,7 +614,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$searchconditionurl = Yii::app()->request->getPost('searchURL');
|
||||
$searchcondition = Yii::app()->request->getPost('searchcondition');
|
||||
$searchconditionurl = basename($searchconditionurl);
|
||||
|
||||
|
||||
if ($searchconditionurl != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
|
||||
{
|
||||
$condition = explode("||", $searchcondition);
|
||||
|
@ -622,7 +622,7 @@ class participantsaction extends Survey_Common_Action
|
|||
} else {
|
||||
$search = null;
|
||||
}
|
||||
|
||||
|
||||
echo $this->csvExportCount($search);
|
||||
}
|
||||
|
||||
|
@ -763,24 +763,25 @@ class participantsaction extends Survey_Common_Action
|
|||
*/
|
||||
function getParticipants_json($search = null)
|
||||
{
|
||||
$page = Yii::app()->request->getPost('page');
|
||||
$limit = Yii::app()->request->getPost('rows');
|
||||
$limit = isset($limit) ? $limit : 50; //Stop division by zero errors
|
||||
$page = (int) Yii::app()->request->getPost('page');
|
||||
$limit = (int) Yii::app()->request->getPost('rows');
|
||||
$limit = empty($limit) ? 50:$limit; //Stop division by zero errors
|
||||
|
||||
$attid = ParticipantAttributeName::model()->getVisibleAttributes();
|
||||
$participantfields = array('participant_id', 'can_edit', 'firstname', 'lastname', 'email', 'blacklisted', 'survey', 'language', 'owner_uid');
|
||||
foreach ($attid as $key => $value)
|
||||
{
|
||||
array_push($participantfields, $value['attribute_id']);
|
||||
array_push($participantfields, 'a'.$value['attribute_id']);
|
||||
}
|
||||
$sidx = Yii::app()->request->getPost('sidx');
|
||||
$sidx = !empty($sidx) ? $sidx : "lastname";
|
||||
$sidx = in_array($sidx,$participantfields) ? $sidx : "lastname";
|
||||
$sord = Yii::app()->request->getPost('sord');
|
||||
$sord = !empty($sord) ? $sord : "asc";
|
||||
$sord = ($sord=='desc') ? 'desc' : 'asc';
|
||||
$order = $sidx. " ". $sord;
|
||||
|
||||
|
||||
|
||||
$aData = new stdClass;
|
||||
|
||||
|
||||
//If super admin all the participants will be visible
|
||||
if (Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
{
|
||||
|
@ -795,11 +796,11 @@ class participantsaction extends Survey_Common_Action
|
|||
}
|
||||
$aData->page = $page;
|
||||
$records = Participant::model()->getParticipants($page, $limit,$attid, $order, $search, $iUserID);
|
||||
|
||||
|
||||
|
||||
|
||||
$aRowToAdd=array();
|
||||
foreach ($records as $key => $row)
|
||||
{
|
||||
{
|
||||
if (array_key_exists('can_edit', $row)) {
|
||||
$sCanEdit = $row['can_edit'];
|
||||
if (is_null($sCanEdit)) {
|
||||
|
@ -810,7 +811,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$sCanEdit = "true";
|
||||
}
|
||||
if (trim($row['ownername'])=='') {
|
||||
$row['ownername']=$row['username'];
|
||||
$row['ownername']=$row['username'];
|
||||
}
|
||||
$aRowToAdd['cell'] = array($row['participant_id'], $sCanEdit, htmlspecialchars($row['firstname']), htmlspecialchars($row['lastname']), htmlspecialchars($row['email']), $row['blacklisted'], $row['survey'], $row['language'], $row['ownername']);
|
||||
$aRowToAdd['id'] = $row['participant_id'];
|
||||
|
@ -822,7 +823,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$aRowToAdd['cell'][] = $attvalue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$aData->rows[] = $aRowToAdd;
|
||||
}
|
||||
|
||||
|
@ -834,7 +835,7 @@ class participantsaction extends Survey_Common_Action
|
|||
*/
|
||||
function getAttribute_json()
|
||||
{
|
||||
$iParticipantId = Yii::app()->request->getQuery('pid');
|
||||
$iParticipantId = strip_tags(Yii::app()->request->getQuery('pid'));
|
||||
$records = ParticipantAttributeName::model()->getParticipantVisibleAttribute($iParticipantId);
|
||||
$records = subval_sort($records, "attribute_name", "asc");
|
||||
|
||||
|
@ -1056,7 +1057,7 @@ class participantsaction extends Survey_Common_Action
|
|||
|
||||
$clang = $this->getController()->lang;
|
||||
if ($_FILES['the_file']['name']=='')
|
||||
{
|
||||
{
|
||||
Yii::app()->setFlashMessage($clang->gT('Please select a file to import!'),'error');
|
||||
Yii::app()->getController()->redirect(array('admin/participants/sa/importCSV'));
|
||||
}
|
||||
|
@ -1080,7 +1081,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'uploadSummary'),$templateData);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$bMoveFileResult)
|
||||
{
|
||||
|
@ -1095,10 +1096,20 @@ class participantsaction extends Survey_Common_Action
|
|||
$sFileName = $_FILES['the_file']['name'];
|
||||
|
||||
$regularfields = array('firstname', 'participant_id', 'lastname', 'email', 'language', 'blacklisted', 'owner_uid');
|
||||
$csvread = fopen($sFilePath, 'r');
|
||||
$oCSVFile = fopen($sFilePath, 'r');
|
||||
$aFirstLine = fgets($oCSVFile);
|
||||
rewind($oCSVFile);
|
||||
|
||||
$separator = Yii::app()->request->getPost('separatorused');
|
||||
$firstline = fgetcsv($csvread, 1000, ',');
|
||||
$sSeparator = Yii::app()->request->getPost('separatorused');
|
||||
if ($sSeparator=='auto')
|
||||
{
|
||||
$aCount[',']=substr_count($aFirstLine,',');
|
||||
$aCount[';']=substr_count($aFirstLine,';');
|
||||
$aCount['|']=substr_count($aFirstLine,'|');
|
||||
$aResult = array_keys($aCount, max($aCount));
|
||||
$sSeparator=$aResult[0];
|
||||
}
|
||||
$firstline = fgetcsv($oCSVFile, 1000, $sSeparator[0]);
|
||||
$selectedcsvfields = array();
|
||||
foreach ($firstline as $key => $value)
|
||||
{
|
||||
|
@ -1124,7 +1135,7 @@ class participantsaction extends Survey_Common_Action
|
|||
App()->getClientScript()->registerPackage('qTip2');
|
||||
App()->getClientScript()->registerPackage('jquery-nestedSortable');
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "attributeMapCSV.js");
|
||||
|
||||
|
||||
$sAttributeMapJS="var copyUrl = '".App()->createUrl("admin/participants/sa/uploadCSV")."';\n"
|
||||
."var displayParticipants = '".App()->createUrl("admin/participants/sa/displayParticipants")."';\n"
|
||||
."var mapCSVcancelled = '".App()->createUrl("admin/participants/sa/mapCSVcancelled")."';\n"
|
||||
|
@ -1242,7 +1253,7 @@ class participantsaction extends Survey_Common_Action
|
|||
$separator = ';'; else
|
||||
$separator = ',';
|
||||
}
|
||||
$firstline = convertCSVRowToArray($buffer, $separator, '"');
|
||||
$firstline = str_getcsv($buffer, $separator, '"');
|
||||
$firstline = array_map('trim', $firstline);
|
||||
$ignoredcolumns = array();
|
||||
//now check the first line for invalid fields
|
||||
|
@ -1264,7 +1275,7 @@ class participantsaction extends Survey_Common_Action
|
|||
}
|
||||
} else {
|
||||
// After looking at the first line, we now import the actual values
|
||||
$line = convertCSVRowToArray($buffer, $separator, '"');
|
||||
$line = str_getcsv($buffer, $separator, '"');
|
||||
// Discard lines where the number of fields do not match
|
||||
if (count($firstline) != count($line))
|
||||
{
|
||||
|
@ -1278,7 +1289,7 @@ class participantsaction extends Survey_Common_Action
|
|||
{
|
||||
unset($writearray[$column]);
|
||||
}
|
||||
// Add aFilterDuplicateFields not in CSV to writearray : quick fix
|
||||
// Add aFilterDuplicateFields not in CSV to writearray : quick fix
|
||||
foreach($aFilterDuplicateFields as $sFilterDuplicateField){
|
||||
if(!in_array($sFilterDuplicateField, $firstline))
|
||||
$writearray[$sFilterDuplicateField]="";
|
||||
|
@ -1428,7 +1439,7 @@ class participantsaction extends Survey_Common_Action
|
|||
}
|
||||
|
||||
function summaryview()
|
||||
{
|
||||
{
|
||||
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'uploadSummary'),array('aAttributes' => ParticipantAttributeName::model()->getAllAttributes()));
|
||||
}
|
||||
|
||||
|
@ -1512,30 +1523,6 @@ class participantsaction extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Responsible for adding the participant to the specified survey
|
||||
*/
|
||||
function addToToken()
|
||||
{
|
||||
$response = Participant::model()->copytoSurvey(Yii::app()->request
|
||||
->getPost('participantid'),
|
||||
Yii::app()->request
|
||||
->getPost('surveyid'), Yii::app()
|
||||
->request->getPost('attributeid')
|
||||
);
|
||||
$clang = $this->getController()->lang;
|
||||
|
||||
printf($clang->gT("%s participants have been copied to the survey token table"), $response['success']);
|
||||
if($response['duplicate']>0) {
|
||||
echo "\r\n";
|
||||
printf($clang->gT("%s entries were not copied because they already existed"), $response['duplicate']);
|
||||
}
|
||||
if($response['overwrite']=="true") {
|
||||
echo "\r\n";
|
||||
$clang->eT("Attribute values for existing participants have been updated from the participants records");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Responsible for adding the participant to the specified survey with attribute mapping
|
||||
*/
|
||||
|
|
|
@ -31,25 +31,26 @@ class printablesurvey extends Survey_Common_Action
|
|||
$surveyid = sanitize_int($surveyid);
|
||||
if(!Permission::model()->hasSurveyPermission($surveyid,'surveycontent','read'))
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$aData['surveyid'] = $surveyid;
|
||||
App()->getClientScript()->registerPackage('jquery-superfish');
|
||||
$message['title']= $clang->gT('Access denied!');
|
||||
$message['message']= $clang->gT('You do not have sufficient rights to access this page.');
|
||||
$message['title']= gT('Access denied!');
|
||||
$message['message']= gT('You do not have sufficient rights to access this page.');
|
||||
$message['class']= "error";
|
||||
$this->_renderWrappedTemplate('survey', array("message"=>$message), $aData);
|
||||
}
|
||||
else
|
||||
{
|
||||
$aSurveyInfo=getSurveyInfo($surveyid,$lang);
|
||||
if (!($aSurveyInfo))
|
||||
$oSurvey=Survey::model()->findByPk($surveyid);
|
||||
if (!$oSurvey)
|
||||
$this->getController()->error('Invalid survey ID');
|
||||
// Be sure to have a valid language
|
||||
$surveyprintlang=$aSurveyInfo['surveyls_language'];
|
||||
|
||||
// Setting the selected language for printout
|
||||
$clang = new limesurvey_lang($surveyprintlang);
|
||||
//Language
|
||||
if(!in_array($lang,$oSurvey->getAllLanguages()))
|
||||
$lang=$oSurvey->language;
|
||||
// Start EM fore expression
|
||||
LimeExpressionManager::SetSurveyId($surveyid);
|
||||
SetSurveyLanguage($surveyid,$lang);
|
||||
|
||||
$aSurveyInfo=getSurveyInfo($surveyid,$lang);
|
||||
$templatename = validateTemplateDir($aSurveyInfo['templatedir']);
|
||||
$welcome = $aSurveyInfo['surveyls_welcometext'];
|
||||
$end = $aSurveyInfo['surveyls_endtext'];
|
||||
|
@ -77,7 +78,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
{
|
||||
$surveyexpirydate .= ' – '.$expirytimeofday_h.':'.$expirytimeofday_m;
|
||||
};
|
||||
sprintf($clang->gT("Please submit by %s"), $surveyexpirydate);
|
||||
sprintf(gT("Please submit by %s"), $surveyexpirydate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,7 +105,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
LimeExpressionManager::StartSurvey($surveyid, 'survey',NULL,false,LEM_PRETTY_PRINT_ALL_SYNTAX);
|
||||
$moveResult = LimeExpressionManager::NavigateForwards();
|
||||
|
||||
$condition = "sid = '{$surveyid}' AND language = '{$surveyprintlang}'";
|
||||
$condition = "sid = '{$surveyid}' AND language = '{$lang}'";
|
||||
$degresult = QuestionGroup::model()->getAllGroups($condition, array('group_order')); //xiao,
|
||||
|
||||
if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber))
|
||||
|
@ -119,7 +120,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$showsgqacode = Yii::app()->getConfig("showsgqacode");
|
||||
if(isset($showsgqacode) && $showsgqacode == true)
|
||||
{
|
||||
$surveyname = $surveyname."<br />[".$clang->gT('Database')." ".$clang->gT('table').": $surveytable]";
|
||||
$surveyname = $surveyname."<br />[".gT('Database')." ".gT('table').": $surveytable]";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -133,9 +134,9 @@ class printablesurvey extends Survey_Common_Action
|
|||
,'WELCOME' => $welcome
|
||||
,'END' => $end
|
||||
,'THEREAREXQUESTIONS' => 0
|
||||
,'SUBMIT_TEXT' => $clang->gT("Submit Your Survey.")
|
||||
,'SUBMIT_TEXT' => gT("Submit Your Survey.")
|
||||
,'SUBMIT_BY' => $surveyexpirydate
|
||||
,'THANKS' => $clang->gT("Thank you for completing this survey.")
|
||||
,'THANKS' => gT("Thank you for completing this survey.")
|
||||
,'HEADELEMENTS' => $headelements
|
||||
,'TEMPLATEURL' => PRINT_TEMPLATE_URL
|
||||
,'FAXTO' => $surveyfaxto
|
||||
|
@ -146,7 +147,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$survey_output['FAX_TO'] ='';
|
||||
if(!empty($surveyfaxto) && $surveyfaxto != '000-00000000') //If no fax number exists, don't display faxing information!
|
||||
{
|
||||
$survey_output['FAX_TO'] = $clang->gT("Please fax your completed survey to:")." $surveyfaxto";
|
||||
$survey_output['FAX_TO'] = gT("Please fax your completed survey to:")." $surveyfaxto";
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +155,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$mapquestionsNumbers=Array();
|
||||
$answertext = ''; // otherwise can throw an error on line 1617
|
||||
|
||||
$fieldmap = createFieldMap($surveyid,'full',false,false,$surveyprintlang);
|
||||
$fieldmap = createFieldMap($surveyid,'full',false,false,$lang);
|
||||
|
||||
// =========================================================
|
||||
// START doin the business:
|
||||
|
@ -162,7 +163,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
{
|
||||
// ---------------------------------------------------
|
||||
// START doing groups
|
||||
$deqresult=Question::model()->getQuestions($surveyid, $degrow['gid'], $surveyprintlang, 0, '"I"');
|
||||
$deqresult=Question::model()->getQuestions($surveyid, $degrow['gid'], $lang, 0, '"I"');
|
||||
$deqrows = array(); //Create an empty array in case FetchRow does not return any rows
|
||||
foreach ($deqresult->readAll() as $deqrow) {$deqrows[] = $deqrow;} // Get table output into array
|
||||
|
||||
|
@ -228,7 +229,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
if($s > 0)
|
||||
{
|
||||
$sExplanation .= '<p class="scenario">'.' -------- '.$clang->gT("or")." Scenario {$scenariorow['scenario']} --------</p>\n\n";
|
||||
$sExplanation .= '<p class="scenario">'.' -------- '.gT("or")." Scenario {$scenariorow['scenario']} --------</p>\n\n";
|
||||
}
|
||||
|
||||
$x=0;
|
||||
|
@ -239,12 +240,12 @@ class printablesurvey extends Survey_Common_Action
|
|||
//Loop through each condition for a particular scenario.
|
||||
foreach ($distinctresult->readAll() as $distinctrow)
|
||||
{
|
||||
$condition = "qid = '{$distinctrow['cqid']}' AND parent_qid = 0 AND language = '{$surveyprintlang}'";
|
||||
$condition = "qid = '{$distinctrow['cqid']}' AND parent_qid = 0 AND language = '{$lang}'";
|
||||
$subresult=Question::model()->find($condition);
|
||||
|
||||
if($x > 0)
|
||||
{
|
||||
$sExplanation .= ' <em class="scenario-and-separator">'.$clang->gT('and').'</em> ';
|
||||
$sExplanation .= ' <em class="scenario-and-separator">'.gT('and').'</em> ';
|
||||
}
|
||||
if(trim($distinctrow['method'])=='') //If there is no method chosen assume "equals"
|
||||
{
|
||||
|
@ -254,35 +255,35 @@ class printablesurvey extends Survey_Common_Action
|
|||
if($distinctrow['cqid']){ // cqid != 0 ==> previous answer match
|
||||
if($distinctrow['method']=='==')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was")." ";
|
||||
$sExplanation .= gT("Answer was")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='!=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was NOT")." ";
|
||||
$sExplanation .= gT("Answer was NOT")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='<')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was less than")." ";
|
||||
$sExplanation .= gT("Answer was less than")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='<=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was less than or equal to")." ";
|
||||
$sExplanation .= gT("Answer was less than or equal to")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='>=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was greater than or equal to")." ";
|
||||
$sExplanation .= gT("Answer was greater than or equal to")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='>')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was greater than")." ";
|
||||
$sExplanation .= gT("Answer was greater than")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='RX')
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer matched (regexp)")." ";
|
||||
$sExplanation .= gT("Answer matched (regexp)")." ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sExplanation .= $clang->gT("Answer was")." ";
|
||||
$sExplanation .= gT("Answer was")." ";
|
||||
}
|
||||
}
|
||||
if(!$distinctrow['cqid']) { // cqid == 0 ==> token attribute match
|
||||
|
@ -291,40 +292,40 @@ class printablesurvey extends Survey_Common_Action
|
|||
$sExplanation .= "Your ".$tokenData[strtolower($extractedTokenAttr[1])]['description']." ";
|
||||
if($distinctrow['method']=='==')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is")." ";
|
||||
$sExplanation .= gT("is")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='!=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is NOT")." ";
|
||||
$sExplanation .= gT("is NOT")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='<')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is less than")." ";
|
||||
$sExplanation .= gT("is less than")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='<=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is less than or equal to")." ";
|
||||
$sExplanation .= gT("is less than or equal to")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='>=')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is greater than or equal to")." ";
|
||||
$sExplanation .= gT("is greater than or equal to")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='>')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is greater than")." ";
|
||||
$sExplanation .= gT("is greater than")." ";
|
||||
}
|
||||
elseif($distinctrow['method']=='RX')
|
||||
{
|
||||
$sExplanation .= $clang->gT("is matched (regexp)")." ";
|
||||
$sExplanation .= gT("is matched (regexp)")." ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sExplanation .= $clang->gT("is")." ";
|
||||
$sExplanation .= gT("is")." ";
|
||||
}
|
||||
$answer_section = ' '.$distinctrow['value'].' ';
|
||||
}
|
||||
|
||||
$conresult=Condition::model()->getConditionsQuestions($distinctrow['cqid'],$deqrow['qid'],$scenariorow['scenario'],$surveyprintlang);
|
||||
$conresult=Condition::model()->getConditionsQuestions($distinctrow['cqid'],$deqrow['qid'],$scenariorow['scenario'],$lang);
|
||||
|
||||
$conditions=array();
|
||||
foreach ($conresult->readAll() as $conrow)
|
||||
|
@ -337,15 +338,15 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "Y":
|
||||
switch ($conrow['value'])
|
||||
{
|
||||
case "Y": $conditions[]=$clang->gT("Yes"); break;
|
||||
case "N": $conditions[]=$clang->gT("No"); break;
|
||||
case "Y": $conditions[]=gT("Yes"); break;
|
||||
case "N": $conditions[]=gT("No"); break;
|
||||
}
|
||||
break;
|
||||
case "G":
|
||||
switch($conrow['value'])
|
||||
{
|
||||
case "M": $conditions[]=$clang->gT("Male"); break;
|
||||
case "F": $conditions[]=$clang->gT("Female"); break;
|
||||
case "M": $conditions[]=gT("Male"); break;
|
||||
case "F": $conditions[]=gT("Female"); break;
|
||||
} // switch
|
||||
break;
|
||||
case "A":
|
||||
|
@ -358,24 +359,24 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "C":
|
||||
switch($conrow['value'])
|
||||
{
|
||||
case "Y": $conditions[]=$clang->gT("Yes"); break;
|
||||
case "U": $conditions[]=$clang->gT("Uncertain"); break;
|
||||
case "N": $conditions[]=$clang->gT("No"); break;
|
||||
case "Y": $conditions[]=gT("Yes"); break;
|
||||
case "U": $conditions[]=gT("Uncertain"); break;
|
||||
case "N": $conditions[]=gT("No"); break;
|
||||
} // switch
|
||||
break;
|
||||
case "E":
|
||||
switch($conrow['value'])
|
||||
{
|
||||
case "I": $conditions[]=$clang->gT("Increase"); break;
|
||||
case "D": $conditions[]=$clang->gT("Decrease"); break;
|
||||
case "S": $conditions[]=$clang->gT("Same"); break;
|
||||
case "I": $conditions[]=gT("Increase"); break;
|
||||
case "D": $conditions[]=gT("Decrease"); break;
|
||||
case "S": $conditions[]=gT("Same"); break;
|
||||
}
|
||||
case "1":
|
||||
$labelIndex=preg_match("/^[^#]+#([01]{1})$/",$conrow['cfieldname']);
|
||||
if ($labelIndex == 0)
|
||||
{ // TIBO
|
||||
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND scale_id=0 AND language='{$surveyprintlang}'";
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND scale_id=0 AND language='{$lang}'";
|
||||
$fresult=Answer::model()->getAllRecords($condition);
|
||||
|
||||
foreach($fresult->readAll() as $frow)
|
||||
|
@ -387,7 +388,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
elseif ($labelIndex == 1)
|
||||
{
|
||||
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND scale_id=1 AND language='{$surveyprintlang}'";
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND scale_id=1 AND language='{$lang}'";
|
||||
$fresult=Answer::model()->getAllRecords($condition);
|
||||
foreach($fresult->readAll() as $frow)
|
||||
{
|
||||
|
@ -400,7 +401,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "!":
|
||||
case "O":
|
||||
case "R":
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$surveyprintlang}'";
|
||||
$condition="qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$lang}'";
|
||||
$ansresult=Answer::model()->findAll($condition);
|
||||
|
||||
foreach ($ansresult as $ansrow)
|
||||
|
@ -408,13 +409,13 @@ class printablesurvey extends Survey_Common_Action
|
|||
$conditions[]=$ansrow['answer'];
|
||||
}
|
||||
if($conrow['value'] == "-oth-") {
|
||||
$conditions[]=$clang->gT("Other");
|
||||
$conditions[]=gT("Other");
|
||||
}
|
||||
$conditions = array_unique($conditions);
|
||||
break;
|
||||
case "M":
|
||||
case "P":
|
||||
$condition=" parent_qid='{$conrow['cqid']}' AND title='{$conrow['value']}' AND language='{$surveyprintlang}'";
|
||||
$condition=" parent_qid='{$conrow['cqid']}' AND title='{$conrow['value']}' AND language='{$lang}'";
|
||||
$ansresult=Question::model()->findAll($condition);
|
||||
foreach ($ansresult as $ansrow)
|
||||
{
|
||||
|
@ -431,7 +432,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
default:
|
||||
$value=substr($conrow['cfieldname'], strpos($conrow['cfieldname'], "X".$conrow['cqid'])+strlen("X".$conrow['cqid']), strlen($conrow['cfieldname']));
|
||||
|
||||
$condition=" qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$surveyprintlang}'";
|
||||
$condition=" qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$lang}'";
|
||||
|
||||
$fresult=Answer::model()->getAllRecords($condition);
|
||||
foreach ($fresult->readAll() as $frow)
|
||||
|
@ -454,7 +455,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "H":
|
||||
case "K":
|
||||
$thiscquestion=$fieldmap[$conrow['cfieldname']];
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'";
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$lang}'";
|
||||
$ansresult= Question::model()->findAll($condition);
|
||||
|
||||
foreach ($ansresult as $ansrow)
|
||||
|
@ -466,39 +467,39 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "1": // dual: (Label 1), (Label 2)
|
||||
$labelIndex=substr($conrow['cfieldname'],-1);
|
||||
$thiscquestion=$fieldmap[$conrow['cfieldname']];
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'";
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$lang}'";
|
||||
$ansresult= Question::model()->findAll($condition);
|
||||
$cqidattributes = getQuestionAttributeValues($conrow['cqid'], $conrow['type']);
|
||||
if ($labelIndex == 0)
|
||||
{
|
||||
if (trim($cqidattributes['dualscale_headerA'][$surveyprintlang]) != '') {
|
||||
$header = $clang->gT($cqidattributes['dualscale_headerA'][$surveyprintlang]);
|
||||
if (trim($cqidattributes['dualscale_headerA'][$lang]) != '') {
|
||||
$header = gT($cqidattributes['dualscale_headerA'][$lang]);
|
||||
} else {
|
||||
$header = '1';
|
||||
}
|
||||
}
|
||||
elseif ($labelIndex == 1)
|
||||
{
|
||||
if (trim($cqidattributes['dualscale_headerB'][$surveyprintlang]) != '') {
|
||||
$header = $clang->gT($cqidattributes['dualscale_headerB'][$surveyprintlang]);
|
||||
if (trim($cqidattributes['dualscale_headerB'][$lang]) != '') {
|
||||
$header = gT($cqidattributes['dualscale_headerB'][$lang]);
|
||||
} else {
|
||||
$header = '2';
|
||||
}
|
||||
}
|
||||
foreach ($ansresult as $ansrow)
|
||||
{
|
||||
$answer_section=" (".$ansrow->question." ".sprintf($clang->gT("Label %s"),$header).")";
|
||||
$answer_section=" (".$ansrow->question." ".sprintf(gT("Label %s"),$header).")";
|
||||
}
|
||||
break;
|
||||
case ":":
|
||||
case ";": //multi flexi: ( answer [label] )
|
||||
$thiscquestion=$fieldmap[$conrow['cfieldname']];
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'";
|
||||
$condition="parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$lang}'";
|
||||
$ansresult= Question::model()->findAll($condition);
|
||||
foreach ($ansresult as $ansrow)
|
||||
{
|
||||
|
||||
$condition = "qid = '{$conrow['cqid']}' AND code = '{$conrow['value']}' AND language= '{$surveyprintlang}'";
|
||||
$condition = "qid = '{$conrow['cqid']}' AND code = '{$conrow['value']}' AND language= '{$lang}'";
|
||||
$fresult= Answer::model()->findAll($condition);
|
||||
foreach ($fresult as $frow)
|
||||
{
|
||||
|
@ -510,7 +511,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "R": // (Rank 1), (Rank 2)... TIBO
|
||||
$thiscquestion=$fieldmap[$conrow['cfieldname']];
|
||||
$rankid=$thiscquestion['aid'];
|
||||
$answer_section=" (".$clang->gT("RANK")." $rankid)";
|
||||
$answer_section=" (".gT("RANK")." $rankid)";
|
||||
break;
|
||||
default: // nothing to add
|
||||
break;
|
||||
|
@ -519,7 +520,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
if (count($conditions) > 1)
|
||||
{
|
||||
$sExplanation .= "'".implode("' <em class='scenario-or-separator'>".$clang->gT("or")."</em> '", $conditions)."'";
|
||||
$sExplanation .= "'".implode("' <em class='scenario-or-separator'>".gT("or")."</em> '", $conditions)."'";
|
||||
}
|
||||
elseif (count($conditions) == 1)
|
||||
{
|
||||
|
@ -527,9 +528,9 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
unset($conditions);
|
||||
// Following line commented out because answer_section was lost, but is required for some question types
|
||||
//$explanation .= " ".$clang->gT("to question")." '".$mapquestionsNumbers[$distinctrow['cqid']]."' $answer_section ";
|
||||
//$explanation .= " ".gT("to question")." '".$mapquestionsNumbers[$distinctrow['cqid']]."' $answer_section ";
|
||||
if($distinctrow['cqid']){
|
||||
$sExplanation .= " <span class='scenario-at-separator'>".$clang->gT("at question")."</span> '".$mapquestionsNumbers[$distinctrow['cqid']]." [".$subresult['title']."]' (".strip_tags($subresult['question'])."$answer_section)" ;
|
||||
$sExplanation .= " <span class='scenario-at-separator'>".gT("at question")."</span> '".$mapquestionsNumbers[$distinctrow['cqid']]." [".$subresult['title']."]' (".strip_tags($subresult['question'])."$answer_section)" ;
|
||||
}
|
||||
else{
|
||||
$sExplanation .= " ".$distinctrow['value'] ;
|
||||
|
@ -546,16 +547,16 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
if (trim($relevance) != '' && trim($relevance) != '1')
|
||||
{
|
||||
if (isset($qidattributes['printable_help'][$surveyprintlang]) && $qidattributes['printable_help'][$surveyprintlang]!='')
|
||||
if (isset($qidattributes['printable_help'][$lang]) && $qidattributes['printable_help'][$lang]!='')
|
||||
{
|
||||
$sExplanation=$qidattributes['printable_help'][$surveyprintlang];
|
||||
$sExplanation=$qidattributes['printable_help'][$lang];
|
||||
}
|
||||
elseif ($sExplanation=='') // There is only a relevance equation without conditions
|
||||
{
|
||||
$sExplanation=$sEquation;
|
||||
$sEquation=' '; // No need to show it twice
|
||||
}
|
||||
$sExplanation = "<b>".$clang->gT('Only answer this question if the following conditions are met:')."</b><br/> ".$sExplanation;
|
||||
$sExplanation = "<b>".gT('Only answer this question if the following conditions are met:')."</b><br/> ".$sExplanation;
|
||||
if (Yii::app()->getConfig('showrelevance'))
|
||||
{
|
||||
$sExplanation.="<span class='printable_equation'><br>".$sEquation."</span>";
|
||||
|
@ -577,8 +578,8 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
if(isset($showsgqacode) && $showsgqacode == true)
|
||||
{
|
||||
$deqrow['question'] = $deqrow['question']."<br />".$clang->gT("ID:")." $fieldname <br />".
|
||||
$clang->gT("Question code:")." ".$deqrow['title'];
|
||||
$deqrow['question'] = $deqrow['question']."<br />".gT("ID:")." $fieldname <br />".
|
||||
gT("Question code:")." ".$deqrow['title'];
|
||||
}
|
||||
|
||||
$question = array(
|
||||
|
@ -613,7 +614,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
if ($deqrow['mandatory'] == 'Y')
|
||||
{
|
||||
$question['QUESTION_MANDATORY'] = $clang->gT('*');
|
||||
$question['QUESTION_MANDATORY'] = gT('*');
|
||||
$question['QUESTION_CLASS'] .= ' mandatory';
|
||||
}
|
||||
|
||||
|
@ -639,7 +640,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
{
|
||||
// ==================================================================
|
||||
case "5": //5 POINT CHOICE
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT('Please choose *only one* of the following:');
|
||||
$question['QUESTION_TYPE_HELP'] .= gT('Please choose *only one* of the following:');
|
||||
$question['ANSWER'] .= "\n\t<ul>\n";
|
||||
for ($i=1; $i<=5; $i++)
|
||||
{
|
||||
|
@ -651,17 +652,17 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// ==================================================================
|
||||
case "D": //DATE
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT('Please enter a date:');
|
||||
$question['QUESTION_TYPE_HELP'] .= gT('Please enter a date:');
|
||||
$question['ANSWER'] .= "\t".self::_input_type_image('text',$question['QUESTION_TYPE_HELP'],30,1);
|
||||
break;
|
||||
|
||||
// ==================================================================
|
||||
case "G": //GENDER
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose *only one* of the following:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose *only one* of the following:");
|
||||
|
||||
$question['ANSWER'] .= "\n\t<ul>\n";
|
||||
$question['ANSWER'] .= "\t\t<li>\n\t\t\t".self::_input_type_image('radio',$clang->gT("Female"))."\n\t\t\t".$clang->gT("Female")." ".self::_addsgqacode("(F)")."\n\t\t</li>\n";
|
||||
$question['ANSWER'] .= "\t\t<li>\n\t\t\t".self::_input_type_image('radio',$clang->gT("Male"))."\n\t\t\t".$clang->gT("Male")." ".self::_addsgqacode("(M)")."\n\t\t</li>\n";
|
||||
$question['ANSWER'] .= "\t\t<li>\n\t\t\t".self::_input_type_image('radio',gT("Female"))."\n\t\t\t".gT("Female")." ".self::_addsgqacode("(F)")."\n\t\t</li>\n";
|
||||
$question['ANSWER'] .= "\t\t<li>\n\t\t\t".self::_input_type_image('radio',gT("Male"))."\n\t\t\t".gT("Male")." ".self::_addsgqacode("(M)")."\n\t\t</li>\n";
|
||||
$question['ANSWER'] .= "\t</ul>\n";
|
||||
break;
|
||||
|
||||
|
@ -686,10 +687,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
unset($optCategorySeparator);
|
||||
}
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose *only one* of the following:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose *only one* of the following:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$dearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('sortorder','answer'));
|
||||
$dearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$lang}' ", array('sortorder','answer'));
|
||||
$dearesult=$dearesult->readAll();
|
||||
$deacount=count($dearesult);
|
||||
if ($deqrow['other'] == "Y") {$deacount++;}
|
||||
|
@ -737,10 +738,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
if ($deqrow['other'] == 'Y')
|
||||
{
|
||||
if(trim($qidattributes["other_replace_text"][$surveyprintlang])=='')
|
||||
{$qidattributes["other_replace_text"][$surveyprintlang]="Other";}
|
||||
// $printablesurveyoutput .="\t".$wrapper['item-start']."\t\t".self::_input_type_image('radio' , $clang->gT("Other"))."\n\t\t\t".$clang->gT("Other")."\n\t\t\t<input type='text' size='30' readonly='readonly' />\n".$wrapper['item-end'];
|
||||
$question['ANSWER'] .= $wrapper['item-start-other'].self::_input_type_image('radio',$clang->gT($qidattributes["other_replace_text"][$surveyprintlang])).' '.$clang->gT($qidattributes["other_replace_text"][$surveyprintlang]).self::_addsgqacode(" (-oth-)")."\n\t\t\t".self::_input_type_image('other').self::_addsgqacode(" (".$deqrow['sid']."X".$deqrow['gid']."X".$deqrow['qid']."other)")."\n".$wrapper['item-end'];
|
||||
if(trim($qidattributes["other_replace_text"][$lang])=='')
|
||||
{$qidattributes["other_replace_text"][$lang]="Other";}
|
||||
// $printablesurveyoutput .="\t".$wrapper['item-start']."\t\t".self::_input_type_image('radio' , gT("Other"))."\n\t\t\t".gT("Other")."\n\t\t\t<input type='text' size='30' readonly='readonly' />\n".$wrapper['item-end'];
|
||||
$question['ANSWER'] .= $wrapper['item-start-other'].self::_input_type_image('radio',gT($qidattributes["other_replace_text"][$lang])).' '.gT($qidattributes["other_replace_text"][$lang]).self::_addsgqacode(" (-oth-)")."\n\t\t\t".self::_input_type_image('other').self::_addsgqacode(" (".$deqrow['sid']."X".$deqrow['gid']."X".$deqrow['qid']."other)")."\n".$wrapper['item-end'];
|
||||
}
|
||||
$question['ANSWER'] .= $wrapper['whole-end'];
|
||||
//Let's break the presentation into columns.
|
||||
|
@ -748,8 +749,8 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// ==================================================================
|
||||
case "O": //LIST WITH COMMENT
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose *only one* of the following:");
|
||||
$dearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$surveyprintlang}'", array('sortorder', 'answer') );
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose *only one* of the following:");
|
||||
$dearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$lang}'", array('sortorder', 'answer') );
|
||||
|
||||
$question['ANSWER'] = "\t<ul>\n";
|
||||
foreach ($dearesult->readAll() as $dearow)
|
||||
|
@ -758,17 +759,17 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
$question['ANSWER'] .= "\t</ul>\n";
|
||||
|
||||
$question['ANSWER'] .= "\t<p class=\"comment\">\n\t\t".$clang->gT("Make a comment on your choice here:")."\n";
|
||||
$question['ANSWER'] .= "\t\t".self::_input_type_image('textarea',$clang->gT("Make a comment on your choice here:"),50,8).self::_addsgqacode(" (".$deqrow['sid']."X".$deqrow['gid']."X".$deqrow['qid']."comment)")."\n\t</p>\n";
|
||||
$question['ANSWER'] .= "\t<p class=\"comment\">\n\t\t".gT("Make a comment on your choice here:")."\n";
|
||||
$question['ANSWER'] .= "\t\t".self::_input_type_image('textarea',gT("Make a comment on your choice here:"),50,8).self::_addsgqacode(" (".$deqrow['sid']."X".$deqrow['gid']."X".$deqrow['qid']."comment)")."\n\t</p>\n";
|
||||
break;
|
||||
|
||||
// ==================================================================
|
||||
case "R": //RANKING Type Question
|
||||
$rearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$surveyprintlang}'", array('sortorder', 'answer'));
|
||||
$rearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$lang}'", array('sortorder', 'answer'));
|
||||
$rearesult = $rearesult->readAll();
|
||||
$reacount = count($rearesult);
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please number each box in order of preference from 1 to")." $reacount";
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_min_max_answers_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please number each box in order of preference from 1 to")." $reacount";
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_min_max_answers_help($qidattributes, $lang, $surveyid);
|
||||
$question['ANSWER'] = "\n<ul>\n";
|
||||
foreach ($rearesult as $rearow)
|
||||
{
|
||||
|
@ -788,10 +789,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
{
|
||||
$dcols=0;
|
||||
}
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose *all* that apply:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose *all* that apply:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$mearesult = Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult = Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$lang}' ", array('question_order'));
|
||||
$mearesult = $mearesult->readAll();
|
||||
$meacount = count($mearesult);
|
||||
if ($deqrow['other'] == 'Y') {$meacount++;}
|
||||
|
@ -822,12 +823,12 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
if ($deqrow['other'] == "Y")
|
||||
{
|
||||
if (trim($qidattributes['other_replace_text'][$surveyprintlang])=='')
|
||||
if (trim($qidattributes['other_replace_text'][$lang])=='')
|
||||
{
|
||||
$qidattributes["other_replace_text"][$surveyprintlang]="Other";
|
||||
$qidattributes["other_replace_text"][$lang]="Other";
|
||||
}
|
||||
if(!isset($mearow['answer'])) $mearow['answer']="";
|
||||
$question['ANSWER'] .= $wrapper['item-start-other'].self::_input_type_image('checkbox',$mearow['answer']).$clang->gT($qidattributes["other_replace_text"][$surveyprintlang]).":\n\t\t".self::_input_type_image('other').self::_addsgqacode(" (".$fieldname."other) ").$wrapper['item-end'];
|
||||
$question['ANSWER'] .= $wrapper['item-start-other'].self::_input_type_image('checkbox',$mearow['answer']).gT($qidattributes["other_replace_text"][$lang]).":\n\t\t".self::_input_type_image('other').self::_addsgqacode(" (".$fieldname."other) ").$wrapper['item-end'];
|
||||
}
|
||||
$question['ANSWER'] .= $wrapper['whole-end'];
|
||||
// }
|
||||
|
@ -835,11 +836,11 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// ==================================================================
|
||||
case "P": //Multiple choice with comments
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose all that apply and provide a comment:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose all that apply and provide a comment:");
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$mearesult=Question::model()->getAllRecords("parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}'", array('question_order'));
|
||||
// $printablesurveyoutput .="\t\t\t<u>".$clang->gT("Please choose all that apply and provide a comment:")."</u><br />\n";
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
$mearesult=Question::model()->getAllRecords("parent_qid='{$deqrow['qid']}' AND language='{$lang}'", array('question_order'));
|
||||
// $printablesurveyoutput .="\t\t\t<u>".gT("Please choose all that apply and provide a comment:")."</u><br />\n";
|
||||
$j=0;
|
||||
$longest_string = 0;
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
|
@ -850,7 +851,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
if ($deqrow['other'] == "Y")
|
||||
{
|
||||
$question['ANSWER'] .= "\t<li class=\"other\">\n\t\t<div class=\"other-replacetext\">".$clang->gT('Other:').self::_input_type_image('other','',1)."</div>".self::_input_type_image('othercomment','comment box',50).self::_addsgqacode(" (".$fieldname."other) ")."\n\t</li>\n";
|
||||
$question['ANSWER'] .= "\t<li class=\"other\">\n\t\t<div class=\"other-replacetext\">".gT('Other:').self::_input_type_image('other','',1)."</div>".self::_input_type_image('othercomment','comment box',50).self::_addsgqacode(" (".$fieldname."other) ")."\n\t</li>\n";
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
@ -869,22 +870,22 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// if (!empty($qidattributes['equals_num_value']))
|
||||
// {
|
||||
// $question['QUESTION_TYPE_HELP'] .= "* ".sprintf($clang->gT('Total of all entries must equal %d'),$qidattributes['equals_num_value'])."<br />\n";
|
||||
// $question['QUESTION_TYPE_HELP'] .= "* ".sprintf(gT('Total of all entries must equal %d'),$qidattributes['equals_num_value'])."<br />\n";
|
||||
// }
|
||||
// if (!empty($qidattributes['max_num_value']))
|
||||
// {
|
||||
// $question['QUESTION_TYPE_HELP'] .= sprintf($clang->gT('Total of all entries must not exceed %d'), $qidattributes['max_num_value'])."<br />\n";
|
||||
// $question['QUESTION_TYPE_HELP'] .= sprintf(gT('Total of all entries must not exceed %d'), $qidattributes['max_num_value'])."<br />\n";
|
||||
// }
|
||||
// if (!empty($qidattributes['min_num_value']))
|
||||
// {
|
||||
// $question['QUESTION_TYPE_HELP'] .= sprintf($clang->gT('Total of all entries must be at least %s'),$qidattributes['min_num_value'])."<br />\n";
|
||||
// $question['QUESTION_TYPE_HELP'] .= sprintf(gT('Total of all entries must be at least %s'),$qidattributes['min_num_value'])."<br />\n";
|
||||
// }
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please write your answer(s) here:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please write your answer(s) here:");
|
||||
|
||||
|
||||
$longest_string = 0;
|
||||
$mearesult=Question::model()->getAllRecords("parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}'", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords("parent_qid='{$deqrow['qid']}' AND language='{$lang}'", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
$longest_string = longestString($mearow['question'] , $longest_string );
|
||||
|
@ -901,21 +902,21 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// ==================================================================
|
||||
case "S": //SHORT TEXT
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please write your answer here:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please write your answer here:");
|
||||
$question['ANSWER'] = self::_input_type_image('text',$question['QUESTION_TYPE_HELP'], 50);
|
||||
break;
|
||||
|
||||
|
||||
// ==================================================================
|
||||
case "T": //LONG TEXT
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please write your answer here:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please write your answer here:");
|
||||
$question['ANSWER'] = self::_input_type_image('textarea',$question['QUESTION_TYPE_HELP'], '100%' , 8);
|
||||
break;
|
||||
|
||||
|
||||
// ==================================================================
|
||||
case "U": //HUGE TEXT
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please write your answer here:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please write your answer here:");
|
||||
$question['ANSWER'] = self::_input_type_image('textarea',$question['QUESTION_TYPE_HELP'], '100%' , 30);
|
||||
break;
|
||||
|
||||
|
@ -924,29 +925,29 @@ class printablesurvey extends Survey_Common_Action
|
|||
case "N": //NUMERICAL
|
||||
$prefix="";
|
||||
$suffix="";
|
||||
if($qidattributes['prefix'][$surveyprintlang] != "") {
|
||||
$prefix=$qidattributes['prefix'][$surveyprintlang];
|
||||
if($qidattributes['prefix'][$lang] != "") {
|
||||
$prefix=$qidattributes['prefix'][$lang];
|
||||
}
|
||||
if($qidattributes['suffix'][$surveyprintlang] != "") {
|
||||
$suffix=$qidattributes['suffix'][$surveyprintlang];
|
||||
if($qidattributes['suffix'][$lang] != "") {
|
||||
$suffix=$qidattributes['suffix'][$lang];
|
||||
}
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please write your answer here:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please write your answer here:");
|
||||
$question['ANSWER'] = "<ul>\n\t<li>\n\t\t<span>$prefix</span>\n\t\t".self::_input_type_image('text',$question['QUESTION_TYPE_HELP'],20)."\n\t\t<span>$suffix</span>\n\t\t</li>\n\t</ul>";
|
||||
break;
|
||||
|
||||
// ==================================================================
|
||||
case "Y": //YES/NO
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose *only one* of the following:");
|
||||
$question['ANSWER'] = "\n<ul>\n\t<li>\n\t\t".self::_input_type_image('radio',$clang->gT('Yes'))."\n\t\t".$clang->gT('Yes').self::_addsgqacode(" (Y)")."\n\t</li>\n";
|
||||
$question['ANSWER'] .= "\n\t<li>\n\t\t".self::_input_type_image('radio',$clang->gT('No'))."\n\t\t".$clang->gT('No').self::_addsgqacode(" (N)")."\n\t</li>\n</ul>\n";
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose *only one* of the following:");
|
||||
$question['ANSWER'] = "\n<ul>\n\t<li>\n\t\t".self::_input_type_image('radio',gT('Yes'))."\n\t\t".gT('Yes').self::_addsgqacode(" (Y)")."\n\t</li>\n";
|
||||
$question['ANSWER'] .= "\n\t<li>\n\t\t".self::_input_type_image('radio',gT('No'))."\n\t\t".gT('No').self::_addsgqacode(" (N)")."\n\t</li>\n</ul>\n";
|
||||
break;
|
||||
|
||||
|
||||
// ==================================================================
|
||||
case "A": //ARRAY (5 POINT CHOICE)
|
||||
$condition = "parent_qid = '{$deqrow['qid']}' AND language= '{$surveyprintlang}'";
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$condition = "parent_qid = '{$deqrow['qid']}' AND language= '{$lang}'";
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] = "
|
||||
<table>
|
||||
|
@ -1003,8 +1004,8 @@ class printablesurvey extends Survey_Common_Action
|
|||
// ==================================================================
|
||||
case "B": //ARRAY (10 POINT CHOICE)
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] .= "\n<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<td> </td>\n";
|
||||
for ($i=1; $i<=10; $i++)
|
||||
|
@ -1014,7 +1015,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$question['ANSWER'] .= "\t</thead>\n\n\t<tbody>\n";
|
||||
$j=0;
|
||||
$rowclass = 'array1';
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$lang}' ", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
|
||||
|
@ -1034,17 +1035,17 @@ class printablesurvey extends Survey_Common_Action
|
|||
// ==================================================================
|
||||
case "C": //ARRAY (YES/UNCERTAIN/NO)
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] = '
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<th>'.$clang->gT("Yes").self::_addsgqacode(" (Y)").'</th>
|
||||
<th>'.$clang->gT("Uncertain").self::_addsgqacode(" (U)").'</th>
|
||||
<th>'.$clang->gT("No").self::_addsgqacode(" (N)").'</th>
|
||||
<th>'.gT("Yes").self::_addsgqacode(" (Y)").'</th>
|
||||
<th>'.gT("Uncertain").self::_addsgqacode(" (U)").'</th>
|
||||
<th>'.gT("No").self::_addsgqacode(" (N)").'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -1053,14 +1054,14 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
$rowclass = 'array1';
|
||||
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$lang}' ", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
$question['ANSWER'] .= "\t\t<tr class=\"$rowclass\">\n";
|
||||
$question['ANSWER'] .= "\t\t\t<th class=\"answertext\">{$mearow['question']}".self::_addsgqacode(" (".$fieldname.$mearow['title'].")")."</th>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("Yes"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("Uncertain"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("No"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("Yes"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("Uncertain"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("No"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t</tr>\n";
|
||||
|
||||
$j++;
|
||||
|
@ -1070,17 +1071,17 @@ class printablesurvey extends Survey_Common_Action
|
|||
break;
|
||||
|
||||
case "E": //ARRAY (Increase/Same/Decrease)
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] = '
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<th>'.$clang->gT("Increase").self::_addsgqacode(" (I)").'</th>
|
||||
<th>'.$clang->gT("Same").self::_addsgqacode(" (S)").'</th>
|
||||
<th>'.$clang->gT("Decrease").self::_addsgqacode(" (D)").'</th>
|
||||
<th>'.gT("Increase").self::_addsgqacode(" (I)").'</th>
|
||||
<th>'.gT("Same").self::_addsgqacode(" (S)").'</th>
|
||||
<th>'.gT("Decrease").self::_addsgqacode(" (D)").'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -1088,14 +1089,14 @@ class printablesurvey extends Survey_Common_Action
|
|||
$j=0;
|
||||
$rowclass = 'array1';
|
||||
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$lang}' ", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
$question['ANSWER'] .= "\t\t<tr class=\"$rowclass\">\n";
|
||||
$question['ANSWER'] .= "\t\t\t<th class=\"answertext\">{$mearow['question']}".self::_addsgqacode(" (".$fieldname.$mearow['title'].")")."</th>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("Increase"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("Same"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',$clang->gT("Decrease"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("Increase"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("Same"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t\t<td>".self::_input_type_image('radio',gT("Decrease"))."</td>\n";
|
||||
$question['ANSWER'] .= "\t\t</tr>\n";
|
||||
$j++;
|
||||
$rowclass = alternation($rowclass,'row');
|
||||
|
@ -1138,10 +1139,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
$checkboxlayout=false;
|
||||
}
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] .= "\n<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<td> </td>\n";
|
||||
$fresult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' and scale_id=1 AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$fresult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' and scale_id=1 AND language='{$lang}' ", array('question_order'));
|
||||
$fresult = $fresult->readAll();
|
||||
$fcount = count($fresult);
|
||||
$fwidth = "120";
|
||||
|
@ -1161,7 +1162,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$a=1; //Counter for pdfoutput
|
||||
$rowclass = 'array1';
|
||||
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' and scale_id=0 AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' and scale_id=0 AND language='{$lang}' ", array('question_order'));
|
||||
$result = $mearesult->readAll();
|
||||
foreach ($result as $frow)
|
||||
{
|
||||
|
@ -1201,13 +1202,13 @@ class printablesurvey extends Survey_Common_Action
|
|||
// ==================================================================
|
||||
case ";": //ARRAY (Multi Flexible) (text)
|
||||
$headstyle="style='padding-left: 20px; padding-right: 7px'";
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND scale_id=0 AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND scale_id=0 AND language='{$lang}' ", array('question_order'));
|
||||
$mearesult=$mearesult->readAll();
|
||||
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] .= "\n<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<td> </td>\n";
|
||||
$fresult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND scale_id=1 AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$fresult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND scale_id=1 AND language='{$lang}' ", array('question_order'));
|
||||
$fresult = $fresult->readAll();
|
||||
$fcount = count($fresult);
|
||||
$fwidth = "120";
|
||||
|
@ -1254,10 +1255,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
// ==================================================================
|
||||
case "F": //ARRAY (Flexible Labels)
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$fresult=Answer::model()->getAllRecords(" scale_id=0 AND qid='{$deqrow['qid']}' AND language='{$surveyprintlang}'", array('sortorder','code'));
|
||||
$fresult=Answer::model()->getAllRecords(" scale_id=0 AND qid='{$deqrow['qid']}' AND language='{$lang}'", array('sortorder','code'));
|
||||
$fresult = $fresult->readAll();
|
||||
$fcount = count($fresult);
|
||||
$fwidth = "120";
|
||||
|
@ -1295,7 +1296,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$counter = 1;
|
||||
$rowclass = 'array1';
|
||||
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid='{$deqrow['qid']}' AND language='{$lang}' ", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
$question['ANSWER'] .= "\t\t<tr class=\"$rowclass\">\n";
|
||||
|
@ -1345,17 +1346,17 @@ class printablesurvey extends Survey_Common_Action
|
|||
// ==================================================================
|
||||
case "1": //ARRAY (Flexible Labels) multi scale
|
||||
|
||||
$leftheader= $qidattributes['dualscale_headerA'][$surveyprintlang];
|
||||
$rightheader= $qidattributes['dualscale_headerB'][$surveyprintlang];
|
||||
$leftheader= $qidattributes['dualscale_headerA'][$lang];
|
||||
$rightheader= $qidattributes['dualscale_headerB'][$lang];
|
||||
|
||||
$headstyle = 'style="padding-left: 20px; padding-right: 7px"';
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid);
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $lang, $surveyid);
|
||||
|
||||
$question['ANSWER'] .= "\n<table>\n\t<thead>\n";
|
||||
|
||||
|
||||
$condition = "qid= '{$deqrow['qid']}' AND language= '{$surveyprintlang}' AND scale_id=0";
|
||||
$condition = "qid= '{$deqrow['qid']}' AND language= '{$lang}' AND scale_id=0";
|
||||
$fresult= Answer::model()->getAllRecords( $condition, array('sortorder', 'code'));
|
||||
$fresult = $fresult->readAll();
|
||||
$fcount = count($fresult);
|
||||
|
@ -1372,9 +1373,9 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
// second scale
|
||||
$printablesurveyoutput2 .="\t\t\t<td> </td>\n";
|
||||
//$fquery1 = "SELECT * FROM {{answers}} WHERE qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' AND scale_id=1 ORDER BY sortorder, code";
|
||||
//$fquery1 = "SELECT * FROM {{answers}} WHERE qid='{$deqrow['qid']}' AND language='{$lang}' AND scale_id=1 ORDER BY sortorder, code";
|
||||
// $fresult1 = Yii::app()->db->createCommand($fquery1)->query();
|
||||
$fresult1 = Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$surveyprintlang}' AND scale_id=1 ", array('sortorder','code'));
|
||||
$fresult1 = Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND language='{$lang}' AND scale_id=1 ", array('sortorder','code'));
|
||||
$fresult1 = $fresult1->readAll();
|
||||
$fcount1 = count ($fresult1);
|
||||
$fwidth = "120";
|
||||
|
@ -1418,7 +1419,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
|
||||
//counter for each subquestion
|
||||
$sqcounter = 0;
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid={$deqrow['qid']} AND language='{$surveyprintlang}' ", array('question_order'));
|
||||
$mearesult=Question::model()->getAllRecords(" parent_qid={$deqrow['qid']} AND language='{$lang}' ", array('question_order'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
$question['ANSWER'] .= "\t\t<tr class=\"$rowclass\">\n";
|
||||
|
@ -1455,10 +1456,10 @@ class printablesurvey extends Survey_Common_Action
|
|||
//$headstyle="style='border-left-style: solid; border-left-width: 1px; border-left-color: #AAAAAA'";
|
||||
$headstyle="style='padding-left: 20px; padding-right: 7px'";
|
||||
|
||||
$condition = "parent_qid= '{$deqrow['qid']}' AND language= '{$surveyprintlang}'";
|
||||
$condition = "parent_qid= '{$deqrow['qid']}' AND language= '{$lang}'";
|
||||
$fresult= Question::model()->getAllRecords( $condition, array('question_order', 'title'));
|
||||
$fresult = $fresult->readAll();
|
||||
$question['QUESTION_TYPE_HELP'] .= $clang->gT("Please choose the appropriate response for each item:");
|
||||
$question['QUESTION_TYPE_HELP'] .= gT("Please choose the appropriate response for each item:");
|
||||
$question['ANSWER'] .= "\n<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<td> </td>\n";
|
||||
|
||||
$fcount = count($fresult);
|
||||
|
@ -1473,7 +1474,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
$a=1;
|
||||
$rowclass = 'array1';
|
||||
|
||||
$mearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND scale_id=0 AND language='{$surveyprintlang}' ", array('sortorder','code'));
|
||||
$mearesult=Answer::model()->getAllRecords(" qid='{$deqrow['qid']}' AND scale_id=0 AND language='{$lang}' ", array('sortorder','code'));
|
||||
foreach ($mearesult->readAll() as $mearow)
|
||||
{
|
||||
//$_POST['type']=$type;
|
||||
|
@ -1508,7 +1509,7 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
|
||||
$survey_output['THEREAREXQUESTIONS'] = str_replace( '{NUMBEROFQUESTIONS}' , $total_questions , $clang->gT('There are {NUMBEROFQUESTIONS} questions in this survey'));
|
||||
$survey_output['THEREAREXQUESTIONS'] = str_replace( '{NUMBEROFQUESTIONS}' , $total_questions , gT('There are {NUMBEROFQUESTIONS} questions in this survey'));
|
||||
|
||||
// START recursive tag stripping.
|
||||
// PHP 5.1.0 introduced the count parameter for preg_replace() and thus allows this procedure to run with only one regular expression.
|
||||
|
@ -1653,14 +1654,14 @@ class printablesurvey extends Survey_Common_Action
|
|||
}
|
||||
}
|
||||
|
||||
private function _min_max_answers_help($qidattributes, $surveyprintlang, $surveyid) {
|
||||
private function _min_max_answers_help($qidattributes, $lang, $surveyid) {
|
||||
$clang = $this->getController()->lang;
|
||||
$output = "";
|
||||
if(!empty($qidattributes['min_answers'])) {
|
||||
$output .= "\n<p class='extrahelp'>".sprintf($clang->gT("Please choose at least %s items."), $qidattributes['min_answers'])."</p>\n";
|
||||
$output .= "\n<p class='extrahelp'>".sprintf(gT("Please choose at least %s items."), $qidattributes['min_answers'])."</p>\n";
|
||||
}
|
||||
if(!empty($qidattributes['max_answers'])) {
|
||||
$output .= "\n<p class='extrahelp'>".sprintf($clang->gT("Please choose no more than %s items."),$qidattributes['max_answers'])."</p>\n";
|
||||
$output .= "\n<p class='extrahelp'>".sprintf(gT("Please choose no more than %s items."),$qidattributes['max_answers'])."</p>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
@ -1740,35 +1741,45 @@ class printablesurvey extends Survey_Common_Action
|
|||
);
|
||||
}
|
||||
|
||||
private function _array_filter_help($qidattributes, $surveyprintlang, $surveyid)
|
||||
private function _array_filter_help($qidattributes, $lang, $surveyid)
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$output = "";
|
||||
if(!empty($qidattributes['array_filter']))
|
||||
{
|
||||
$newquestiontext = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter'], 'language' => $surveyprintlang, 'sid' => $surveyid))->getAttribute('question');
|
||||
$output .= "\n<p class='extrahelp'>
|
||||
".sprintf($clang->gT("Only answer this question for the items you selected in question %s ('%s')"),$qidattributes['array_filter'], flattenText(breakToNewline($newquestiontext)))."
|
||||
</p>\n";
|
||||
$aFilter=explode(';',$qidattributes['array_filter']);
|
||||
$output .= "\n<p class='extrahelp'>";
|
||||
foreach ($aFilter as $sFilter)
|
||||
{
|
||||
$oQuestion=Question::model()->findByAttributes(array('title' => $sFilter, 'language' => $lang, 'sid' => $surveyid));
|
||||
if ($oQuestion)
|
||||
{
|
||||
$sNewQuestionText = flattenText(breakToNewline($oQuestion->getAttribute('question')));
|
||||
$output .= sprintf(gT("Only answer this question for the items you selected in question %s ('%s')"),$qidattributes['array_filter'], $sNewQuestionText );
|
||||
|
||||
}
|
||||
}
|
||||
$output .= "</p>\n";
|
||||
}
|
||||
if(!empty($qidattributes['array_filter_exclude']))
|
||||
if(!empty($qidattributes['array_filter']))
|
||||
{
|
||||
$arQuestion = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter_exclude'], 'language' => $surveyprintlang, 'sid' => $surveyid));
|
||||
if ($arQuestion)
|
||||
$aFilter=explode(';',$qidattributes['array_filter']);
|
||||
$output .= "\n<p class='extrahelp'>";
|
||||
foreach ($aFilter as $sFilter)
|
||||
{
|
||||
$newquestiontext=$arQuestion->getAttribute('question');
|
||||
$oQuestion=Question::model()->findByAttributes(array('title' => $sFilter, 'language' => $lang, 'sid' => $surveyid));
|
||||
if ($oQuestion)
|
||||
{
|
||||
$sNewQuestionText = flattenText(breakToNewline($oQuestion->getAttribute('question')));
|
||||
$output .= sprintf(gT("Only answer this question for the items you did not select in question %s ('%s')"),$qidattributes['array_filter'], $sNewQuestionText );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
$output .= "\n <p class='extrahelp'>
|
||||
".sprintf($clang->gT("Only answer this question for the items you did not select in question %s ('%s')"),$qidattributes['array_filter_exclude'], breakToNewline($newquestiontext))."
|
||||
</p>\n";
|
||||
}
|
||||
$output .= "</p>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $code: Text string containing the reference (column heading) for the current (sub-) question
|
||||
*
|
||||
|
|
|
@ -1020,10 +1020,48 @@ class questions extends Survey_Common_Action
|
|||
$language=null;
|
||||
}
|
||||
$resultdata=getlabelsets($language);
|
||||
// Label set title really don't need HTML
|
||||
foreach($resultdata as &$aResult)
|
||||
{
|
||||
$aResult = array_map('flattenText', $aResult);
|
||||
}
|
||||
header('Content-type: application/json');
|
||||
echo ls_json_encode($resultdata);
|
||||
}
|
||||
|
||||
public function ajaxchecklabel()
|
||||
{
|
||||
$iLabelID = (int) Yii::app()->request->getParam('lid');
|
||||
$aNewLanguages = Yii::app()->request->getParam('languages');
|
||||
$bCheckAssessments = Yii::app()->request->getParam('bCheckAssessments',0);
|
||||
$arLabelSet=LabelSet::model()->find('lid=:lid',array(':lid' => $iLabelID));
|
||||
$iLabelsWithAssessmentValues=Label::model()->count('lid=:lid AND assessment_value<>0',array(':lid' => $iLabelID));
|
||||
$aLabelSetLanguages=explode(' ',$arLabelSet->languages);
|
||||
$aErrorMessages=array();
|
||||
if ($bCheckAssessments && $iLabelsWithAssessmentValues)
|
||||
{
|
||||
$aErrorMessages[]=gT('The existing label set has some assessment values assigned.').'<strong>'.gT('If you replace the label set the existing asssessment values will be lost.').'</strong>';
|
||||
}
|
||||
if (count(array_diff($aLabelSetLanguages,$aNewLanguages)))
|
||||
{
|
||||
$aErrorMessages[]=gT('The existing label has different/more languages.').'<strong>'.gT('If you replace the label set these translations will be lost.').'</strong>';
|
||||
}
|
||||
if (count($aErrorMessages)){
|
||||
foreach ($aErrorMessages as $sErrorMessage)
|
||||
{
|
||||
echo $sErrorMessage.'<br>';
|
||||
}
|
||||
eT('Do you really want to continue?');
|
||||
}
|
||||
else
|
||||
{
|
||||
eT('You are about to replace a given label set with the current answer options');
|
||||
echo '<br>';
|
||||
eT('Continue?');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load preview of a question screen.
|
||||
*
|
||||
|
@ -1073,8 +1111,6 @@ class questions extends Survey_Common_Action
|
|||
|
||||
setNoAnswerMode($thissurvey);
|
||||
|
||||
Yii::app()->session['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat']);
|
||||
|
||||
$qrows = Question::model()->findByAttributes(array('sid' => $surveyid, 'qid' => $qid, 'language' => $language))->getAttributes();
|
||||
|
||||
$ia = array(
|
||||
|
|
|
@ -453,6 +453,8 @@ class quotas extends Survey_Common_Action
|
|||
$sBaseLang = $aData['sBaseLang'];
|
||||
$clang = $aData['clang'];
|
||||
$this->_checkPermissions($iSurveyId, 'read');
|
||||
|
||||
|
||||
$aQuestion = Question::model()->findByPk(array('qid' => $iQuestionId, 'language' => $sBaseLang));
|
||||
$aQuestionType = $aQuestion['type'];
|
||||
|
||||
|
@ -473,7 +475,8 @@ class quotas extends Survey_Common_Action
|
|||
'F' => array('Title' => $aQuestion['title'], 'Display' => $clang->gT("Female"), 'code' => 'F'));
|
||||
} elseif ($aQuestionType == 'L' || $aQuestionType == 'O' || $aQuestionType == '!')
|
||||
{
|
||||
$aAnsResults = Answer::model()->findAllByAttributes(array('qid' => $iQuestionId));
|
||||
|
||||
$aAnsResults = Answer::model()->findAllByAttributes(array('qid' => $iQuestionId, 'language' => $sBaseLang));
|
||||
|
||||
$aAnswerList = array();
|
||||
|
||||
|
@ -481,6 +484,7 @@ class quotas extends Survey_Common_Action
|
|||
{
|
||||
$aAnswerList[$aDbAnsList['code']] = array('Title' => $aQuestion['title'], 'Display' => substr($aDbAnsList['answer'], 0, 40), 'code' => $aDbAnsList['code']);
|
||||
}
|
||||
|
||||
} elseif ($aQuestionType == 'A')
|
||||
{
|
||||
$aAnsResults = Question::model()->findAllByAttributes(array('parent_qid' => $iQuestionId));
|
||||
|
@ -497,7 +501,7 @@ class quotas extends Survey_Common_Action
|
|||
}
|
||||
} elseif ($aQuestionType == 'B')
|
||||
{
|
||||
$aAnsResults = Answer::model()->findAllByAttributes(array('qid' => $iQuestionId));
|
||||
$aAnsResults = Answer::model()->findAllByAttributes(array('qid' => $iQuestionId, 'language' => $sBaseLang));
|
||||
|
||||
$aAnswerList = array();
|
||||
|
||||
|
|
|
@ -93,12 +93,16 @@ class remotecontrol extends Survey_Common_Action
|
|||
*/
|
||||
public function test()
|
||||
{
|
||||
die(); // Remove if you want to test this function
|
||||
$RPCType=Yii::app()->getConfig("RPCInterface");
|
||||
$serverUrl = App()->createAbsoluteUrl('/admin/remotecontrol');
|
||||
$sFileToImport=dirname(Yii::app()->basePath).DIRECTORY_SEPARATOR.'docs'.DIRECTORY_SEPARATOR.'demosurveys'.DIRECTORY_SEPARATOR.'limesurvey2_sample_survey_english.lss';
|
||||
|
||||
if ($RPCType == 'xml') {
|
||||
$cur_path = get_include_path();
|
||||
set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers');
|
||||
require_once('Zend/XmlRpc/Client.php');
|
||||
|
||||
$client = new Zend_XmlRpc_Client($serverUrl);
|
||||
} elseif ($RPCType == 'json') {
|
||||
Yii::app()->loadLibrary('jsonRPCClient');
|
||||
|
@ -113,7 +117,7 @@ class remotecontrol extends Survey_Common_Action
|
|||
{
|
||||
echo 'Retrieved session key'.'<br>';
|
||||
}
|
||||
|
||||
|
||||
$sLSSData=base64_encode(file_get_contents($sFileToImport));
|
||||
$iSurveyID=$client->call('import_survey', array($sSessionKey, $sLSSData, 'lss','Test import by JSON_RPC',1000));
|
||||
echo 'Created new survey SID:'.$iSurveyID.'<br>';
|
||||
|
|
|
@ -125,7 +125,7 @@ class responses extends Survey_Common_Action
|
|||
continue;
|
||||
if ($field['type'] == 'answer_time')
|
||||
continue;
|
||||
|
||||
|
||||
//$question = $field['question'];
|
||||
$question = viewHelper::getFieldText($field);
|
||||
|
||||
|
@ -359,8 +359,8 @@ class responses extends Survey_Common_Action
|
|||
}
|
||||
|
||||
Response::model($iSurveyID)->deleteByPk(Yii::app()->request->getPost('markedresponses'));
|
||||
|
||||
|
||||
|
||||
|
||||
Yii::app()->session['flashmessage'] = sprintf(ngT("%s response was successfully deleted.","%s responses were successfully deleted.",count(Yii::app()->request->getPost('markedresponses'))),count(Yii::app()->request->getPost('markedresponses')),'js');
|
||||
}
|
||||
else
|
||||
|
@ -396,7 +396,7 @@ class responses extends Survey_Common_Action
|
|||
$iId = (int) Yii::app()->request->getParam('id');
|
||||
$downloadindividualfile = Yii::app()->request->getParam('downloadindividualfile');
|
||||
$fieldname = Yii::app()->request->getParam('fieldname');
|
||||
|
||||
|
||||
$oRow = SurveyDynamic::model($iSurveyID)->findByAttributes(array('id' => $iId));
|
||||
$phparray = json_decode_ls($oRow->$fieldname);
|
||||
|
||||
|
@ -405,7 +405,7 @@ class responses extends Survey_Common_Action
|
|||
if (rawurldecode($phparray[$i]['name']) == rawurldecode($downloadindividualfile))
|
||||
{
|
||||
$file = Yii::app()->getConfig('uploaddir') . "/surveys/" . $iSurveyID . "/files/" . $phparray[$i]['filename'];
|
||||
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
@ob_clean();
|
||||
|
@ -420,6 +420,10 @@ class responses extends Survey_Common_Action
|
|||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
Yii::app()->session['flashmessage']=gT("The requested file does not exist on the server.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -497,8 +501,8 @@ class responses extends Survey_Common_Action
|
|||
|
||||
$fncount = count($fnames);
|
||||
|
||||
$start = Yii::app()->request->getParam('start', 0);
|
||||
$limit = Yii::app()->request->getParam('limit', 50);
|
||||
$start = (int)Yii::app()->request->getParam('start', 0);
|
||||
$limit = (int)Yii::app()->request->getParam('limit', 50);
|
||||
$order = Yii::app()->request->getParam('order', 'asc');
|
||||
if(!$limit){$limit=50;}
|
||||
$oCriteria = new CDbCriteria;
|
||||
|
@ -527,7 +531,7 @@ class responses extends Survey_Common_Action
|
|||
//NOW LETS SHOW THE DATA
|
||||
if (Yii::app()->request->getPost('sql') && stripcslashes(Yii::app()->request->getPost('sql')) !== "" && Yii::app()->request->getPost('sql') != "NULL")
|
||||
$oCriteria->addCondition(stripcslashes(Yii::app()->request->getPost('sql')));
|
||||
|
||||
|
||||
if (!is_null($tokenRequest)) {
|
||||
$oCriteria->addCondition('t.token = ' . Yii::app()->db->quoteValue($tokenRequest));
|
||||
}
|
||||
|
@ -622,7 +626,7 @@ class responses extends Survey_Common_Action
|
|||
if ($aData['surveyinfo']['savetimings'] != "Y")
|
||||
die();
|
||||
|
||||
if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') != '' && Yii::app()->request->getPost('deleteanswer') != 'marked'
|
||||
if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') != '' && Yii::app()->request->getPost('deleteanswer') != 'marked'
|
||||
&& Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'delete'))
|
||||
{
|
||||
$iResponseID=(int) Yii::app()->request->getPost('deleteanswer');
|
||||
|
@ -632,7 +636,7 @@ class responses extends Survey_Common_Action
|
|||
|
||||
if (Yii::app()->request->getPost('markedresponses') && count(Yii::app()->request->getPost('markedresponses')) > 0)
|
||||
{
|
||||
if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') === 'marked' &&
|
||||
if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') === 'marked' &&
|
||||
Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'delete'))
|
||||
{
|
||||
foreach (Yii::app()->request->getPost('markedresponses') as $iResponseID)
|
||||
|
@ -796,7 +800,7 @@ class responses extends Survey_Common_Action
|
|||
* @todo Move this to model.
|
||||
*/
|
||||
Yii::app()->loadLibrary('admin/pclzip');
|
||||
|
||||
|
||||
$tmpdir = Yii::app()->getConfig('uploaddir') . DIRECTORY_SEPARATOR."surveys". DIRECTORY_SEPARATOR . $iSurveyID . DIRECTORY_SEPARATOR."files".DIRECTORY_SEPARATOR;
|
||||
|
||||
$filelist = array();
|
||||
|
@ -844,6 +848,8 @@ class responses extends Survey_Common_Action
|
|||
exit;
|
||||
}
|
||||
}
|
||||
else Yii::app()->session['flashmessage']=gT("The requested file does not exist on the server.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,43 +66,40 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
|
||||
public function regenquestioncodes($iSurveyID, $sSubAction )
|
||||
{
|
||||
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update'))
|
||||
$clang = $this->getController()->lang;
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update'))
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
|
||||
//Automatically renumbers the "question codes" so that they follow
|
||||
//a methodical numbering method
|
||||
$iQuestionNumber=1;
|
||||
$iGroupNumber=0;
|
||||
$iSequence=0;
|
||||
$sQuery="SELECT a.qid, a.gid\n"
|
||||
."FROM {{questions}} as a, {{groups}} g "
|
||||
."WHERE a.gid=g.gid AND a.sid={$iSurveyID} AND a.parent_qid=0 "
|
||||
."GROUP BY a.gid, a.qid, g.group_order, question_order "
|
||||
."ORDER BY g.group_order, question_order";
|
||||
$arResult=dbExecuteAssoc($sQuery) or safe_die ("Error: ".$connect->ErrorMsg()); // Checked
|
||||
$grows = array(); //Create an empty array in case FetchRow does not return any rows
|
||||
foreach ($arResult->readAll() as $grow) {$grows[] = $grow;} // Get table output into array
|
||||
foreach($grows as $grow)
|
||||
{
|
||||
//Go through all the questions
|
||||
if ($sSubAction == 'bygroup' && (!isset($iGroupNumber) || $iGroupNumber != $grow['gid']))
|
||||
{ //If we're doing this by group, restart the numbering when the group number changes
|
||||
$iQuestionNumber=1;
|
||||
$iGroupNumber = $grow['gid'];
|
||||
$iSequence++;
|
||||
}
|
||||
$usql="UPDATE {{questions}} "
|
||||
."SET title='".(($sSubAction == 'bygroup') ? ('G' . $iSequence ) : '')."Q".str_pad($iQuestionNumber, 5, "0", STR_PAD_LEFT)."'\n"
|
||||
."WHERE qid=".$grow['qid'];
|
||||
//$databaseoutput .= "[$sql]";
|
||||
$uresult=dbExecuteAssoc($usql) or safe_die("Error: ".$connect->ErrorMsg()); // Checked
|
||||
$iQuestionNumber++;
|
||||
$iGroupNumber=$grow['gid'];
|
||||
}
|
||||
$_SESSION['flashmessage'] = $clang->gT("Question codes were successfully regenerated.");
|
||||
LimeExpressionManager::SetDirtyFlag(); // so refreshes syntax highlighting
|
||||
Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access this page."),'error');
|
||||
$this->getController()->redirect(array('admin/survey','sa'=>'view','surveyid'=>$iSurveyID));
|
||||
}
|
||||
$oSurvey=Survey::model()->findByPk($iSurveyID);
|
||||
if ($oSurvey->active=='Y')
|
||||
{
|
||||
Yii::app()->setFlashMessage($clang->gT("You can't update question code for an active survey."),'error');
|
||||
$this->getController()->redirect(array('admin/survey','sa'=>'view','surveyid'=>$iSurveyID));
|
||||
}
|
||||
//Automatically renumbers the "question codes" so that they follow
|
||||
//a methodical numbering method
|
||||
$iQuestionNumber=1;
|
||||
$iGroupNumber=0;
|
||||
$iGroupSequence=0;
|
||||
$oQuestions=Question::model()->with('groups')->findAll(array('select'=>'t.qid,t.gid','condition'=>"t.sid=:sid and t.language=:language and parent_qid=0",'order'=>'groups.group_order, question_order','params'=>array(':sid'=>$iSurveyID,':language'=>$oSurvey->language)));
|
||||
foreach($oQuestions as $oQuestion)
|
||||
{
|
||||
if ($sSubAction == 'bygroup' && $iGroupNumber != $oQuestion->gid)
|
||||
{ //If we're doing this by group, restart the numbering when the group number changes
|
||||
$iQuestionNumber=1;
|
||||
$iGroupNumber = $oQuestion->gid;
|
||||
$iGroupSequence++;
|
||||
}
|
||||
$sNewTitle=(($sSubAction == 'bygroup') ? ('G' . $iGroupSequence ) : '')."Q".str_pad($iQuestionNumber, 5, "0", STR_PAD_LEFT);
|
||||
Question::model()->updateAll(array('title'=>$sNewTitle),'qid=:qid',array(':qid'=>$oQuestion->qid));
|
||||
$iQuestionNumber++;
|
||||
$iGroupNumber=$oQuestion->gid;
|
||||
}
|
||||
|
||||
Yii::app()->setFlashMessage($clang->gT("Question codes were successfully regenerated."));
|
||||
LimeExpressionManager::SetDirtyFlag(); // so refreshes syntax highlighting
|
||||
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
|
||||
}
|
||||
|
||||
|
@ -137,12 +134,12 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
|
||||
$this->_renderWrappedTemplate('survey', $aViewUrls, $arrayed_data);
|
||||
}
|
||||
|
||||
|
||||
function fakebrowser()
|
||||
{
|
||||
$aData['clang'] = $this->getController()->lang;
|
||||
Yii::app()->getController()->renderPartial('/admin/survey/newSurveyBrowserMessage', $aData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function prepares the view for editing a survey
|
||||
|
@ -167,7 +164,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
|
||||
Yii::app()->loadHelper('/admin/htmleditor');
|
||||
initKcfinder();
|
||||
|
||||
|
||||
$esrow = array();
|
||||
$esrow = self::_fetchSurveyInfo('editsurvey', $iSurveyID);
|
||||
$aData['esrow'] = $esrow;
|
||||
|
@ -307,15 +304,15 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$iSurveyID = Yii::app()->request->getPost('sid', $iSurveyID);
|
||||
$iSurveyID = sanitize_int($iSurveyID);
|
||||
$clang = $this->getController()->lang;
|
||||
if (!tableExists('survey_'.$iSurveyID))
|
||||
{
|
||||
$_SESSION['flashmessage'] = $clang->gT("Error: Response table does not exist. Survey cannot be deactivated.");
|
||||
$this->getController()->redirect($this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}"));
|
||||
}
|
||||
$date = date('YmdHis'); //'His' adds 24hours+minutes to name to allow multiple deactiviations in a day
|
||||
|
||||
if (empty($_POST['ok']))
|
||||
{
|
||||
if (!tableExists('survey_'.$iSurveyID))
|
||||
{
|
||||
$_SESSION['flashmessage'] = $clang->gT("Error: Response table does not exist. Survey cannot be deactivated.");
|
||||
$this->getController()->redirect($this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}"));
|
||||
}
|
||||
$aData['surveyid'] = $iSurveyID;
|
||||
$aData['date'] = $date;
|
||||
$aData['dbprefix'] = Yii::app()->db->tablePrefix;
|
||||
|
@ -326,18 +323,19 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
//See if there is a tokens table for this survey
|
||||
if (tableExists("{{tokens_{$iSurveyID}}}"))
|
||||
{
|
||||
if (Yii::app()->db->getDriverName() == 'postgre')
|
||||
$toldtable = Yii::app()->db->tablePrefix."tokens_{$iSurveyID}";
|
||||
$tnewtable = Yii::app()->db->tablePrefix."old_tokens_{$iSurveyID}_{$date}";
|
||||
if (Yii::app()->db->getDriverName() == 'pgsql')
|
||||
{
|
||||
$deactivateresult = Yii::app()->db->createCommand()->renameTable($toldtable . '_tid_seq', $tnewtable . '_tid_seq');
|
||||
$setsequence = "ALTER TABLE ".Yii::app()->db->quoteTableName($tnewtable)." ALTER COLUMN tid SET DEFAULT nextval('{{{$tnewtable}}}_tid_seq'::regclass);";
|
||||
$deactivateresult = Yii::app()->db->createCommand($setsequence)->query();
|
||||
$setidx = "ALTER INDEX {{{$toldtable}}}_idx RENAME TO {{{$tnewtable}}}_idx;";
|
||||
$deactivateresult = Yii::app()->db->createCommand($setidx)->query();
|
||||
$tidDefault = Yii::app()->db->createCommand("SELECT pg_attrdef.adsrc FROM pg_attribute JOIN pg_class ON (pg_attribute.attrelid=pg_class.oid) JOIN pg_attrdef ON(pg_attribute.attrelid=pg_attrdef.adrelid AND pg_attribute.attnum=pg_attrdef.adnum) WHERE pg_class.relname='$toldtable' and pg_attribute.attname='tid'")->queryScalar();
|
||||
if(preg_match("/nextval\('(tokens_\d+_tid_seq\d*)'::regclass\)/", $tidDefault, $matches)){
|
||||
$oldSeq = $matches[1];
|
||||
$deactivateresult = Yii::app()->db->createCommand()->renameTable($oldSeq, $tnewtable . '_tid_seq');
|
||||
$setsequence = "ALTER TABLE ".Yii::app()->db->quoteTableName($toldtable)." ALTER COLUMN tid SET DEFAULT nextval('{$tnewtable}_tid_seq'::regclass);";
|
||||
$deactivateresult = Yii::app()->db->createCommand($setsequence)->query();
|
||||
}
|
||||
}
|
||||
|
||||
$toldtable = "{{tokens_{$iSurveyID}}}";
|
||||
$tnewtable = "{{old_tokens_{$iSurveyID}_{$date}}}";
|
||||
|
||||
$tdeactivateresult = Yii::app()->db->createCommand()->renameTable($toldtable, $tnewtable);
|
||||
|
||||
$aData['tnewtable'] = $tnewtable;
|
||||
|
@ -346,7 +344,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
|
||||
//Remove any survey_links to the CPDB
|
||||
SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
|
||||
|
||||
|
||||
|
||||
// IF there are any records in the saved_control table related to this survey, they have to be deleted
|
||||
$result = SavedControl::model()->deleteSomeRecords(array('sid' => $iSurveyID)); //Yii::app()->db->createCommand($query)->query();
|
||||
|
@ -362,11 +360,15 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$survey = Survey::model()->findByAttributes(array('sid' => $iSurveyID));
|
||||
$survey->autonumber_start = $new_autonumber_start;
|
||||
$survey->save();
|
||||
if (Yii::app()->db->getDrivername() == 'postgre')
|
||||
if (Yii::app()->db->getDriverName() == 'pgsql')
|
||||
{
|
||||
$deactivateresult = Yii::app()->db->createCommand()->renameTable($sOldSurveyTableName . '_id_seq', $sNewSurveyTableName . '_id_seq');
|
||||
$setsequence = "ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$sNewSurveyTableName}_id_seq'::regclass);";
|
||||
$deactivateresult = Yii::app()->db->createCommand($setsequence)->execute();
|
||||
$idDefault = Yii::app()->db->createCommand("SELECT pg_attrdef.adsrc FROM pg_attribute JOIN pg_class ON (pg_attribute.attrelid=pg_class.oid) JOIN pg_attrdef ON(pg_attribute.attrelid=pg_attrdef.adrelid AND pg_attribute.attnum=pg_attrdef.adnum) WHERE pg_class.relname='$sOldSurveyTableName' and pg_attribute.attname='id'")->queryScalar();
|
||||
if(preg_match("/nextval\('(survey_\d+_id_seq\d*)'::regclass\)/", $idDefault, $matches)){
|
||||
$oldSeq = $matches[1];
|
||||
$deactivateresult = Yii::app()->db->createCommand()->renameTable($oldSeq, $sNewSurveyTableName . '_id_seq');
|
||||
$setsequence = "ALTER TABLE ".Yii::app()->db->quoteTableName($sOldSurveyTableName)." ALTER COLUMN id SET DEFAULT nextval('{{{$sNewSurveyTableName}}}_id_seq'::regclass);";
|
||||
$deactivateresult = Yii::app()->db->createCommand($setsequence)->query();
|
||||
}
|
||||
}
|
||||
|
||||
$deactivateresult = Yii::app()->db->createCommand()->renameTable($sOldSurveyTableName, $sNewSurveyTableName);
|
||||
|
@ -572,14 +574,13 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$clang = $this->getController()->lang;
|
||||
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
|
||||
|
||||
$surveys = Survey::model();
|
||||
//!!! Is this even possible to execute?
|
||||
if (!Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
$surveys->permission(Yii::app()->user->getId());
|
||||
$surveys = $surveys->with(array('languagesettings'=>array('condition'=>'surveyls_language=language'), 'owner'))->findAll();
|
||||
$oSurvey = new Survey;
|
||||
$oSurvey->permission(Yii::app()->user->getId());
|
||||
|
||||
$aSurveys = $oSurvey->with(array('languagesettings'=>array('condition'=>'surveyls_language=language'), 'owner'))->findAll();
|
||||
$aSurveyEntries = new stdClass();
|
||||
$aSurveyEntries->page = 1;
|
||||
foreach ($surveys as $rows)
|
||||
foreach ($aSurveys as $rows)
|
||||
{
|
||||
if (!isset($rows->owner->attributes)) $aOwner=array('users_name'=>$clang->gT('(None)')); else $aOwner=$rows->owner->attributes;
|
||||
$rows = array_merge($rows->attributes, $rows->defaultlanguage->attributes, $aOwner);
|
||||
|
@ -705,7 +706,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
* @param string $sa
|
||||
* @return void
|
||||
*/
|
||||
public function delete($iSurveyID, $delete = 'no')
|
||||
public function delete($iSurveyID)
|
||||
{
|
||||
$aData = $aViewUrls = array();
|
||||
$aData['surveyid'] = $iSurveyID = (int) $iSurveyID;
|
||||
|
@ -713,7 +714,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
|
||||
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'delete'))
|
||||
{
|
||||
if ($delete == 'yes')
|
||||
if (Yii::app()->request->getPost("delete") == 'yes')
|
||||
{
|
||||
$aData['issuperadmin'] = Permission::model()->hasGlobalPermission('superadmin','read');
|
||||
$this->_deleteSurvey($iSurveyID);
|
||||
|
@ -842,8 +843,8 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
else
|
||||
{
|
||||
$sExtension = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($action == 'copysurvey')
|
||||
{
|
||||
|
@ -852,7 +853,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
}
|
||||
// Start traitment and messagebox
|
||||
$aData['bFailed'] = false; // Put a var for continue
|
||||
|
||||
|
||||
if ($action == 'importsurvey')
|
||||
{
|
||||
|
||||
|
@ -923,11 +924,11 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
if ($action == 'importsurvey' && !$aData['bFailed'])
|
||||
{
|
||||
$aImportResults=importSurveyFile($sFullFilepath,(isset($_POST['translinksfields'])));
|
||||
if (is_null($aImportResults) || isset($aImportResults['error']))
|
||||
if (is_null($aImportResults) || !empty($aImportResults['error']) )
|
||||
{
|
||||
$aData['sErrorMessage']=$aImportResults['error'];
|
||||
$aData['bFailed'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($action == 'copysurvey' && !$aData['bFailed'])
|
||||
{
|
||||
|
@ -951,8 +952,6 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
unlink($sFullFilepath);
|
||||
}
|
||||
|
||||
// if (isset($aImportResults['error']) && $aImportResults['error']) safeDie($aImportResults['error']);
|
||||
|
||||
if (!$aData['bFailed'])
|
||||
{
|
||||
$aData['action'] = $action;
|
||||
|
@ -987,7 +986,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
{
|
||||
// Prepare data for the view
|
||||
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
|
||||
|
||||
LimeExpressionManager::StartSurvey($iSurveyID, 'survey');
|
||||
LimeExpressionManager::StartProcessingPage(true, Yii::app()->baseUrl);
|
||||
|
||||
$aGrouplist = QuestionGroup::model()->getGroups($iSurveyID);
|
||||
|
@ -1160,16 +1159,16 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$aData['sRadixDefault'] = $aLanguageDetails['radixpoint'];
|
||||
$aData['sDateFormatDefault'] = $aLanguageDetails['dateformat'];
|
||||
foreach (getRadixPointData() as $index=>$radixptdata){
|
||||
$aRadixPointData[$index]=$radixptdata['desc'];
|
||||
$aRadixPointData[$index]=$radixptdata['desc'];
|
||||
}
|
||||
$aData['aRadixPointData']=$aRadixPointData;
|
||||
|
||||
foreach (getDateFormatData (0,Yii::app()->session['adminlang']) as $index => $dateformatdata)
|
||||
|
||||
foreach (getDateFormatData (0,Yii::app()->session['adminlang']) as $index => $dateformatdata)
|
||||
{
|
||||
$aDateFormatData[$index]=$dateformatdata['dateformat'];
|
||||
$aDateFormatData[$index]=$dateformatdata['dateformat'];
|
||||
}
|
||||
$aData['aDateFormatData']=$aDateFormatData;
|
||||
|
||||
|
||||
return $aData;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1186,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$aData['clang'] = $clang;
|
||||
$aData['esrow'] = $esrow;
|
||||
$aData['surveyid'] = $iSurveyID;
|
||||
|
||||
|
||||
$beforeSurveySettings = new PluginEvent('beforeSurveySettings');
|
||||
$beforeSurveySettings->set('survey', $iSurveyID);
|
||||
App()->getPluginManager()->dispatchEvent($beforeSurveySettings);
|
||||
|
@ -1362,12 +1361,12 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
function getUrlParamsJSON($iSurveyID)
|
||||
{
|
||||
$iSurveyID = (int) $iSurveyID;
|
||||
Yii::app()->loadHelper('database');
|
||||
$oResult = dbExecuteAssoc("select '' as act, up.*,q.title, sq.title as sqtitle, q.question, sq.question as sqquestion from {{survey_url_parameters}} up
|
||||
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
|
||||
$sQuery = "select '' as act, up.*,q.title, sq.title as sqtitle, q.question, sq.question as sqquestion from {{survey_url_parameters}} up
|
||||
left join {{questions}} q on q.qid=up.targetqid
|
||||
left join {{questions}} sq on sq.qid=up.targetsqid
|
||||
where up.sid={$iSurveyID}");
|
||||
$oResult= $oResult->readAll();
|
||||
where up.sid={$iSurveyID} and q.language='{$sBaseLanguage}' and (sq.language='{$sBaseLanguage}' or sq.language is null)";
|
||||
$oResult = Yii::app()->db->createCommand($sQuery)->queryAll();
|
||||
$i = 0;
|
||||
$clang = $this->getController()->lang;
|
||||
$aData = new stdClass();
|
||||
|
@ -1427,7 +1426,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$generalscripts_path = Yii::app()->getConfig('generalscripts');
|
||||
$adminscripts_path = Yii::app()->getConfig('adminscripts');
|
||||
$styleurl = Yii::app()->getConfig('styleurl');
|
||||
|
||||
|
||||
$js_files = array(
|
||||
$adminscripts_path . 'surveysettings.js',
|
||||
);
|
||||
|
@ -1440,7 +1439,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
{
|
||||
App()->getClientScript()->registerScriptFile($file);
|
||||
|
||||
|
||||
|
||||
}
|
||||
App()->getClientScript()->registerPackage('jquery-json');
|
||||
App()->getClientScript()->registerPackage('jqgrid');
|
||||
|
@ -1496,7 +1495,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$converter = new Date_Time_Converter($sExpiryDate, $aDateFormatData['phpdate'] . ' H:i:s');
|
||||
$sExpiryDate = $converter->convert("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
|
||||
$iTokenLength=$_POST['tokenlength'];
|
||||
//token length has to be at least 5, otherwise set it to default (15)
|
||||
if($iTokenLength < 5)
|
||||
|
@ -1507,7 +1506,7 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
{
|
||||
$iTokenLength = 36;
|
||||
}
|
||||
|
||||
|
||||
// Insert base settings into surveys table
|
||||
$aInsertData = array(
|
||||
'expires' => $sExpiryDate,
|
||||
|
@ -1560,14 +1559,14 @@ class SurveyAdmin extends Survey_Common_Action
|
|||
$aInsertData['adminemail'] = Yii::app()->request->getPost('adminemail');
|
||||
} else {
|
||||
$aInsertData['adminemail'] = '';
|
||||
$warning .= $this->getController()->lang->gT("Warning! Notification email was not updated because it was not valid.").'<br/>';
|
||||
$warning .= $this->getController()->lang->gT("Warning! Notification email was not updated because it was not valid.").'<br/>';
|
||||
}
|
||||
if (Yii::app()->request->getPost('bounce_email', '') == ''
|
||||
|| validateEmailAddress(Yii::app()->request->getPost('bounce_email'))) {
|
||||
$aInsertData['bounce_email'] = Yii::app()->request->getPost('bounce_email');
|
||||
} else {
|
||||
$aInsertData['bounce_email'] = '';
|
||||
$warning .= $this->getController()->lang->gT("Warning! Bounce email was not updated because it was not valid.").'<br/>';
|
||||
$warning .= $this->getController()->lang->gT("Warning! Bounce email was not updated because it was not valid.").'<br/>';
|
||||
}
|
||||
|
||||
if (!is_null($iSurveyID))
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* other free or open source software licenses.
|
||||
* See COPYRIGHT.php for copyright notices and details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* surveypermission
|
||||
*
|
||||
|
@ -31,7 +31,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
$aViewUrls = array();
|
||||
$clang = Yii::app()->lang;
|
||||
$imageurl = Yii::app()->getConfig('adminimageurl');
|
||||
|
||||
|
||||
if(Permission::model()->hasSurveyPermission($surveyid,'surveysecurity','read'))
|
||||
{
|
||||
$aBaseSurveyPermissions=Permission::model()->getSurveyBasePermissions();
|
||||
|
@ -83,7 +83,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
{
|
||||
$group_ids_query = implode(",", $group_ids);
|
||||
unset($group_ids);
|
||||
$result4 = UserGroup::model()->findAll("ugid IN ($group_ids_query)");
|
||||
$result4 = UserGroup::model()->findAll("ugid IN ($group_ids_query)");
|
||||
|
||||
foreach ($result4 as $resul4row)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
$surveysecurity .= "<tr>\n";
|
||||
|
||||
$surveysecurity .= "<td>\n";
|
||||
|
||||
|
||||
if(Permission::model()->hasSurveyPermission($surveyid,'surveysecurity','update'))
|
||||
{
|
||||
if($PermissionRow['uid']!=Yii::app()->user->getId() || Permission::model()->hasGlobalPermission('superadmin','read')) // Can not update own security
|
||||
|
@ -171,7 +171,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
if(Permission::model()->hasSurveyPermission($surveyid,'surveysecurity','create'))
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
. "<input style='width: 15em;' type='submit' value='".$clang->gT("Add user")."' onclick=\"if (document.getElementById('uidselect').value == -1) { alert('".$clang->gT("Please select a user first","js")."'); return false;}\"/>"
|
||||
. "<input type='hidden' name='action' value='addsurveysecurity' />"
|
||||
. "</li></ul></form>\n";
|
||||
|
||||
|
||||
$surveysecurity .= CHtml::form(array("admin/surveypermission/sa/addusergroup/surveyid/{$surveyid}"), 'post', array('class'=>"form44"))."<ul><li>\n"
|
||||
. "<label for='ugidselect'>".$clang->gT("User group").": </label><select id='ugidselect' name='ugid'>\n"
|
||||
. getSurveyUserGroupList('htmloptions',$surveyid)
|
||||
|
@ -227,7 +227,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
$addsummary .= "<div class=\"messagebox ui-corner-all\" >\n";
|
||||
|
||||
$result = Survey::model()->findAll('sid = :surveyid AND owner_id = :owner_id',array(':surveyid' => $surveyid, ':owner_id' => Yii::app()->session['loginID']));
|
||||
if( Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'create')
|
||||
if( Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'create')
|
||||
&& in_array($postusergroupid,getSurveyUserGroupList('simpleugidarray',$surveyid))
|
||||
)
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
$addsummary .= "<div class=\"messagebox ui-corner-all\">\n";
|
||||
|
||||
$result = Survey::model()->findAll('sid = :sid AND owner_id = :owner_id AND owner_id != :postuserid',array(':sid' => $surveyid, ':owner_id' => Yii::app()->session['loginID'], ':postuserid' => $postuserid));
|
||||
if( Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'create')
|
||||
if( Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'create')
|
||||
&& in_array($postuserid,getUserList('onlyuidarray'))
|
||||
)
|
||||
{
|
||||
|
@ -387,7 +387,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
}
|
||||
elseif( $action == "setusergroupsurveysecurity" )
|
||||
{
|
||||
if ( !Permission::model()->hasGlobalPermission('superadmin','read') && !in_array($postusergroupid,getUserList('onlyuidarray')) ) // User can not change own security (except for superadmin ?)
|
||||
if ( !Permission::model()->hasGlobalPermission('superadmin','read') && !in_array($postusergroupid,getUserGroupList(null, 'simplegidarray')) ) // User can not change own security (except for superadmin ?)
|
||||
{
|
||||
$this->getController()->error('Access denied');
|
||||
}
|
||||
|
@ -431,14 +431,14 @@ class surveypermission extends Survey_Common_Action {
|
|||
. "</tr></thead>\n";
|
||||
|
||||
//content
|
||||
|
||||
|
||||
$aBasePermissions=Permission::model()->getSurveyBasePermissions();
|
||||
|
||||
$oddcolumn=false;
|
||||
foreach($aBasePermissions as $sPermissionKey=>$aCRUDPermissions)
|
||||
{
|
||||
$oddcolumn=!$oddcolumn;
|
||||
$usersummary .= "<tr><td><img src='{$imageurl}{$aCRUDPermissions['img']}_30.png' alt='{$aCRUDPermissions['description']}'/></td>";
|
||||
$usersummary .= "<tr><td><img src='{$imageurl}{$aCRUDPermissions['img']}_30.png' alt='' title='{$aCRUDPermissions['description']}'/></td>";
|
||||
$usersummary .= "<td>{$aCRUDPermissions['title']}</td>";
|
||||
$usersummary .= "<td ><input type=\"checkbox\" class=\"markrow\" name='all_{$sPermissionKey}' /></td>";
|
||||
foreach ($aCRUDPermissions as $sCRUDKey=>$CRUDValue)
|
||||
|
@ -451,8 +451,17 @@ class surveypermission extends Survey_Common_Action {
|
|||
if (!($sPermissionKey=='survey' && $sCRUDKey=='read'))
|
||||
{
|
||||
$usersummary .= "<input type=\"checkbox\" class=\"checkboxbtn\" name='perm_{$sPermissionKey}_{$sCRUDKey}' ";
|
||||
if($action=='setsurveysecurity' && Permission::model()->hasSurveyPermission( $surveyid,$sPermissionKey,$sCRUDKey,$postuserid)) {
|
||||
$usersummary .= ' checked="checked" ';
|
||||
if($action=='setsurveysecurity')
|
||||
{
|
||||
if(Permission::model()->hasPermission($surveyid,'survey',$sPermissionKey,$sCRUDKey,$postuserid))
|
||||
{
|
||||
$usersummary .= ' checked="checked" ';// User have this permission set for this survey
|
||||
|
||||
}
|
||||
elseif(Permission::model()->hasSurveyPermission( $surveyid,$sPermissionKey,$sCRUDKey,$postuserid))
|
||||
{
|
||||
$usersummary .= ' data-indeterminate=true ';// User have this permission for this survey by another system (global or owner)
|
||||
}
|
||||
}
|
||||
$usersummary .=" />";
|
||||
}
|
||||
|
@ -478,6 +487,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
$usersummary .= "</form>\n";
|
||||
|
||||
$aViewUrls['output'] = $usersummary;
|
||||
App()->getClientScript()->registerScript("data-indeterminate","$(':checkbox[data-indeterminate]').prop('indeterminate', true);",CClientScript::POS_READY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -524,7 +534,7 @@ class surveypermission extends Survey_Common_Action {
|
|||
{
|
||||
if (isset($postuserid))
|
||||
{
|
||||
$dbresult = Permission::model()->deleteAll('uid = :uid AND entity_id = :sid AND entity = :entity',array(':uid' => $postuserid, ':sid' => $surveyid, ':entity' => 'survey'));
|
||||
$dbresult = Permission::model()->deleteAll("uid = :uid AND entity_id = :sid AND entity = 'survey'",array(':uid' => $postuserid, ':sid' => $surveyid));
|
||||
$addsummary .= "<br />".$clang->gT("Username").": ".sanitize_xss_string($_POST['user'])."<br /><br />\n";
|
||||
$addsummary .= "<div class=\"successheader\">".$clang->gT("Success!")."</div>\n";
|
||||
}
|
||||
|
|
|
@ -111,9 +111,9 @@ class templates extends Survey_Common_Action
|
|||
Yii::app()->loadLibrary('admin.pclzip');
|
||||
|
||||
$zip = new PclZip($_FILES['the_file']['tmp_name']);
|
||||
|
||||
|
||||
// Create temporary directory so that if dangerous content is unzipped it would be unaccessible
|
||||
$sNewDirectoryName=sanitize_dirname($_FILES['the_file']['name']);
|
||||
$sNewDirectoryName=sanitize_dirname(pathinfo($_FILES['the_file']['name'], PATHINFO_FILENAME ));
|
||||
$destdir = Yii::app()->getConfig('usertemplaterootdir').DIRECTORY_SEPARATOR.$sNewDirectoryName;
|
||||
|
||||
if (!is_writeable(dirname($destdir)))
|
||||
|
@ -282,7 +282,7 @@ class templates extends Survey_Common_Action
|
|||
}
|
||||
Yii::app()->session['flashmessage'] = $uploadresult;
|
||||
}
|
||||
$this->getController()->redirect(array("admin/templates/view/editfile/" . $editfile . "/screenname/" . $screenname . "/templatename/" . $templatename));
|
||||
$this->getController()->redirect(array("admin/templates/sa/view/editfile/" . $editfile . "/screenname/" . $screenname . "/templatename/" . $templatename));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,8 +33,8 @@ class tokens extends Survey_Common_Action
|
|||
$thissurvey = getSurveyInfo($iSurveyId);
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'read') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update')
|
||||
&& !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'export') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'import')
|
||||
&& !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update')
|
||||
)
|
||||
&& !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update')
|
||||
)
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
|
||||
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
|
@ -71,7 +71,7 @@ class tokens extends Survey_Common_Action
|
|||
function bounceprocessing($iSurveyId)
|
||||
{
|
||||
$iSurveyId = sanitize_int($iSurveyId);
|
||||
$clang = $this->getController()->lang;
|
||||
$clang = $this->getController()->lang;
|
||||
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
|
||||
if (!$bTokenExists) //If no tokens table exists
|
||||
{
|
||||
|
@ -331,7 +331,13 @@ class tokens extends Survey_Common_Action
|
|||
$aData['order'] = $order;
|
||||
$aData['surveyprivate'] = $aData['thissurvey']['anonymized'];
|
||||
$aData['dateformatdetails'] = $dateformatdetails;
|
||||
|
||||
$aLanguageCodes=Survey::model()->findByPk($iSurveyId)->getAllLanguages();
|
||||
$aLanguages=array();
|
||||
foreach ($aLanguageCodes as $aCode)
|
||||
{
|
||||
$aLanguages[$aCode]=getLanguageNameFromCode($aCode,false);
|
||||
}
|
||||
$aData['aLanguages'] = $aLanguages;
|
||||
$this->_renderWrappedTemplate('token', array('tokenbar', 'browse'), $aData);
|
||||
}
|
||||
|
||||
|
@ -361,25 +367,29 @@ class tokens extends Survey_Common_Action
|
|||
$sidx = Yii::app()->request->getPost('sidx', 'lastname');
|
||||
$sord = Yii::app()->request->getPost('sord', 'asc');
|
||||
$limit = Yii::app()->request->getPost('rows', 25);
|
||||
|
||||
|
||||
$aData = new stdClass;
|
||||
$aData->page = $page;
|
||||
|
||||
|
||||
$aSearchArray=Yii::app()->request->getPost('searcharray');
|
||||
if(empty($search) && !empty($aSearchArray)){
|
||||
$search=$aSearchArray;
|
||||
}
|
||||
if (!empty($search)) {
|
||||
$condition = TokenDynamic::model($iSurveyId)->getSearchMultipleCondition($search);
|
||||
} else {
|
||||
}else{
|
||||
$condition = new CDbCriteria();
|
||||
}
|
||||
|
||||
|
||||
$condition->order = $sidx. " ". $sord;
|
||||
$condition->offset = ($page - 1) * $limit;
|
||||
$condition->limit = $limit;
|
||||
$tokens = Token::model($iSurveyId)->findAll($condition);
|
||||
|
||||
|
||||
$condition->offset=0;
|
||||
$condition->limit=0;
|
||||
$condition->limit=0;
|
||||
$aData->records = Token::model($iSurveyId)->count($condition);
|
||||
|
||||
|
||||
if ($limit>$aData->records)
|
||||
{
|
||||
$limit=$aData->records;
|
||||
|
@ -399,7 +409,7 @@ class tokens extends Survey_Common_Action
|
|||
|
||||
$aSurveyInfo = Survey::model()->findByPk($iSurveyId)->getAttributes(); //Get survey settings
|
||||
$attributes = getAttributeFieldNames($iSurveyId);
|
||||
|
||||
|
||||
// Now find all responses for the visible tokens
|
||||
$visibleTokens = array();
|
||||
$answeredTokens = array();
|
||||
|
@ -413,7 +423,7 @@ class tokens extends Survey_Common_Action
|
|||
$answeredTokens[$answer['token']] = $answer['token'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$bReadPermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read');
|
||||
$bCreatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'create');
|
||||
$bTokenUpdatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update');
|
||||
|
@ -447,7 +457,7 @@ class tokens extends Survey_Common_Action
|
|||
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
|
||||
}
|
||||
// Check if the token can be taken
|
||||
if ($token['token'] != "" && ($token['completed'] == "N" || $token['completed'] == "") && $bCreatePermission) {
|
||||
if ($token['token'] != "" && ($token['completed'] == "N" || $token['completed'] == "" || $aSurveyInfo['alloweditaftercompletion']=="Y") && $bCreatePermission) {
|
||||
$action .= viewHelper::getImageLink('do_16.png', "survey/index/sid/{$iSurveyId}/token/{$token['token']}/lang/{$token['language']}/newtest/Y", $clang->gT("Do survey"), '_blank');
|
||||
} else {
|
||||
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
|
||||
|
@ -499,10 +509,10 @@ class tokens extends Survey_Common_Action
|
|||
|
||||
/**
|
||||
* Called by jqGrid if a token is saved after editing
|
||||
*
|
||||
*
|
||||
* @param mixed $iSurveyId The Survey ID
|
||||
*/
|
||||
function editToken($iSurveyId)
|
||||
function editToken($iSurveyId)
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create'))
|
||||
|
@ -540,7 +550,7 @@ class tokens extends Survey_Common_Action
|
|||
// {
|
||||
// $sLang = Yii::app()->request->getPost('language');
|
||||
// }
|
||||
|
||||
|
||||
echo $from . ',' . $until;
|
||||
$aData = array(
|
||||
'firstname' => Yii::app()->request->getPost('firstname'),
|
||||
|
@ -866,7 +876,7 @@ class tokens extends Survey_Common_Action
|
|||
SurveyLink::model()->deleteTokenLink($aTokenIds, $iSurveyID);
|
||||
|
||||
//Then delete the tokens
|
||||
Token::model($iSurveyID)->deleteByPk($aTokenIds);
|
||||
Token::model($iSurveyID)->deleteByPk($aTokenIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,7 +930,6 @@ class tokens extends Survey_Common_Action
|
|||
$aData = array('firstname' => Yii::app()->request->getPost('firstname'),
|
||||
'lastname' => Yii::app()->request->getPost('lastname'),
|
||||
'email' => Yii::app()->request->getPost('email'),
|
||||
'emailstatus' => 'OK',
|
||||
'token' => $santitizedtoken,
|
||||
'language' => sanitize_languagecode(Yii::app()->request->getPost('language')),
|
||||
'sent' => 'N',
|
||||
|
@ -955,14 +964,14 @@ class tokens extends Survey_Common_Action
|
|||
$existingtokens[$tokenRow['token']] = true;
|
||||
}
|
||||
$result->close();
|
||||
|
||||
|
||||
$invalidtokencount=0;
|
||||
$newDummyToken=0;
|
||||
while ($newDummyToken < $amount && $invalidtokencount < 50)
|
||||
{
|
||||
$token = Token::create($iSurveyId);
|
||||
$token->setAttributes($aData, false);
|
||||
|
||||
|
||||
$token->firstname = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->firstname);
|
||||
$token->lastname = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->lastname);
|
||||
$token->email = str_replace('{TOKEN_COUNTER}', $newDummyToken, $token->email);
|
||||
|
@ -1027,7 +1036,7 @@ class tokens extends Survey_Common_Action
|
|||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$iSurveyId = sanitize_int($iSurveyId);
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update'))
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update'))
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
|
||||
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
|
@ -1054,7 +1063,7 @@ class tokens extends Survey_Common_Action
|
|||
$descrition=sprintf($clang->gT("Attribute %s (%s)"),str_replace("attribute_","",$tokenfield),$descrition);
|
||||
$tokenfieldlist[]=array("id"=>$tokenfield,"descrition"=>$descrition);
|
||||
}
|
||||
$aData['tokenfieldlist'] = $tokenfieldlist;
|
||||
$aData['tokenfieldlist'] = $tokenfieldlist;
|
||||
$languages = array_merge((array) Survey::model()->findByPk($iSurveyId)->language, Survey::model()->findByPk($iSurveyId)->additionalLanguages);
|
||||
$captions = array();
|
||||
foreach ($languages as $language)
|
||||
|
@ -1062,11 +1071,11 @@ class tokens extends Survey_Common_Action
|
|||
$aData['languages'] = $languages;
|
||||
$aData['tokencaptions'] = $captions;
|
||||
$aData['nrofattributes'] = 0;
|
||||
$aData['examplerow'] = TokenDynamic::model($iSurveyId)->find();
|
||||
$aData['examplerow'] = TokenDynamic::model($iSurveyId)->find();
|
||||
$aData['aCPDBAttributes']['']=$clang->gT('(none)');
|
||||
foreach (ParticipantAttributeName::model()->getCPDBAttributes() as $aCPDBAttribute)
|
||||
{
|
||||
$aData['aCPDBAttributes'][$aCPDBAttribute['attribute_id']]=$aCPDBAttribute['attribute_name'];
|
||||
$aData['aCPDBAttributes'][$aCPDBAttribute['attribute_id']]=$aCPDBAttribute['attribute_name'];
|
||||
}
|
||||
$this->_renderWrappedTemplate('token', array('tokenbar', 'managetokenattributes'), $aData);
|
||||
}
|
||||
|
@ -1078,7 +1087,7 @@ class tokens extends Survey_Common_Action
|
|||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$iSurveyId = sanitize_int($iSurveyId);
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update'))
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update'))
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
|
||||
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
|
@ -1127,7 +1136,7 @@ class tokens extends Survey_Common_Action
|
|||
Yii::app()->session['flashmessage'] = $clang->gT("No token table.");
|
||||
$this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
}
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update'))
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update'))
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
|
||||
$this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
|
@ -1161,9 +1170,14 @@ class tokens extends Survey_Common_Action
|
|||
}
|
||||
elseif($sAttributeToDelete)
|
||||
{
|
||||
// Update field attributedescriptions in survey table
|
||||
$aTokenAttributeDescriptions=decodeTokenAttributes(Survey::model()->findByPk($iSurveyId)->attributedescriptions);
|
||||
unset($aTokenAttributeDescriptions[$sAttributeToDelete]);
|
||||
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => json_encode($aTokenAttributeDescriptions)));
|
||||
|
||||
$sTableName="{{tokens_".intval($iSurveyId)."}}";
|
||||
Yii::app()->db->createCommand(Yii::app()->db->getSchema()->dropColumn($sTableName, $sAttributeToDelete))->execute();
|
||||
Yii::app()->db->schema->getTable($sTableName, true); // Refresh schema cache just in case the table existed in the past
|
||||
Yii::app()->db->schema->getTable($sTableName, true); // Refresh schema cache
|
||||
LimeExpressionManager::SetDirtyFlag();
|
||||
Yii::app()->session['flashmessage'] = sprintf($clang->gT("Attribute %s was deleted."), $sAttributeToDelete);
|
||||
Yii::app()->getController()->redirect(Yii::app()->getController()->createUrl("/admin/tokens/sa/managetokenattributes/surveyid/$iSurveyId"));
|
||||
|
@ -1182,7 +1196,7 @@ class tokens extends Survey_Common_Action
|
|||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$iSurveyId = sanitize_int($iSurveyId);
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update'))
|
||||
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update'))
|
||||
{
|
||||
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
|
||||
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
|
||||
|
@ -1211,7 +1225,7 @@ class tokens extends Survey_Common_Action
|
|||
$captions[$language][$fieldname] = $_POST["caption_{$fieldname}_$language"];
|
||||
}
|
||||
|
||||
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => serialize($fieldcontents)));
|
||||
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => json_encode($fieldcontents)));
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$ls = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $iSurveyId, 'surveyls_language' => $language));
|
||||
|
@ -1229,7 +1243,7 @@ class tokens extends Survey_Common_Action
|
|||
/**
|
||||
* Handle email action
|
||||
*/
|
||||
function email($iSurveyId, $tokenids = null)
|
||||
function email($iSurveyId, $tokenids = null)
|
||||
{
|
||||
$clang = $this->getController()->lang;
|
||||
$iSurveyId = sanitize_int($iSurveyId);
|
||||
|
@ -1256,7 +1270,7 @@ class tokens extends Survey_Common_Action
|
|||
$aTokenIds = array_filter($aTokenIds);
|
||||
$aTokenIds = array_map('sanitize_int', $aTokenIds);
|
||||
}
|
||||
$aTokenIds=array_unique(array_filter((array) $aTokenIds));
|
||||
$aTokenIds=array_unique(array_filter((array) $aTokenIds));
|
||||
|
||||
$sSubAction = Yii::app()->request->getParam('action');
|
||||
$sSubAction = !in_array($sSubAction, array('email', 'remind')) ? 'email' : $sSubAction;
|
||||
|
@ -1281,7 +1295,7 @@ class tokens extends Survey_Common_Action
|
|||
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
|
||||
foreach($aSurveyLangs as $sSurveyLanguage)
|
||||
{
|
||||
$aData['thissurvey'][$sSurveyLanguage] = getSurveyInfo($iSurveyId, $sSurveyLanguage);
|
||||
$aData['thissurvey'][$sSurveyLanguage] = getSurveyInfo($iSurveyId, $sSurveyLanguage);
|
||||
}
|
||||
$aData['surveyid'] = $iSurveyId;
|
||||
$aData['sSubAction'] = $sSubAction;
|
||||
|
@ -1451,7 +1465,7 @@ class tokens extends Survey_Common_Action
|
|||
if (isset($aAttachments[$sTemplate]))
|
||||
{
|
||||
LimeExpressionManager::singleton()->loadTokenInformation($aData['thissurvey']['sid'], $emrow['token']);
|
||||
|
||||
|
||||
foreach ($aAttachments[$sTemplate] as $aAttachment)
|
||||
{
|
||||
if (LimeExpressionManager::singleton()->ProcessRelevance($aAttachment['relevance']))
|
||||
|
@ -1558,7 +1572,7 @@ class tokens extends Survey_Common_Action
|
|||
}
|
||||
else
|
||||
{
|
||||
$aData['tokenoutput'].='<b>All emails were sent.</b>';
|
||||
$aData['tokenoutput'].="<strong class='result success text-success'>".gT("All emails were sent.")."<strong>";
|
||||
}
|
||||
|
||||
$this->_renderWrappedTemplate('token', $aViewUrls, $aData);
|
||||
|
@ -1570,7 +1584,7 @@ class tokens extends Survey_Common_Action
|
|||
'message' => $clang->gT("There were no eligible emails to send. This will be because none satisfied the criteria of:")
|
||||
. "<br/> <ul><li>" . $clang->gT("having a valid email address") . "</li>"
|
||||
. "<li>" . $clang->gT("not having been sent an invitation already") . "</li>"
|
||||
. "<li>" . $clang->gT("having already completed the survey") . "</li>"
|
||||
. "<li>" . $clang->gT("not having already completed the survey") . "</li>"
|
||||
. "<li>" . $clang->gT("having a token") . "</li></ul>"
|
||||
)), $aData);
|
||||
}
|
||||
|
@ -1651,7 +1665,7 @@ class tokens extends Survey_Common_Action
|
|||
{
|
||||
$filterduplicatetoken = (Yii::app()->request->getPost('filterduplicatetoken') && Yii::app()->request->getPost('filterduplicatetoken') == 'on');
|
||||
$filterblankemail = (Yii::app()->request->getPost('filterblankemail') && Yii::app()->request->getPost('filterblankemail') == 'on');
|
||||
|
||||
|
||||
$ldap_queries = Yii::app()->getConfig('ldap_queries');
|
||||
$ldap_server = Yii::app()->getConfig('ldap_server');
|
||||
|
||||
|
@ -1922,6 +1936,7 @@ class tokens extends Survey_Common_Action
|
|||
$duplicatelist = array();
|
||||
$invalidemaillist = array();
|
||||
$invalidformatlist = array();
|
||||
$errorlist = array();
|
||||
$firstline = array();
|
||||
|
||||
$sPath = Yii::app()->getConfig('tempdir');
|
||||
|
@ -1960,12 +1975,12 @@ class tokens extends Survey_Common_Action
|
|||
$buffer = @mb_convert_encoding($buffer, "UTF-8", $uploadcharset);
|
||||
if ($recordcount == 0)
|
||||
{
|
||||
// Parse first line (header) from CSV
|
||||
// Parse first line (header) from CSV
|
||||
$buffer = removeBOM($buffer);
|
||||
// We alow all field except tid because this one is really not needed.
|
||||
$allowedfieldnames = array('participant_id','firstname','lastname','email','emailstatus','token','language','blacklisted','sent','remindersent','remindercount','validfrom','validuntil','completed','usesleft');
|
||||
$allowedfieldnames = array_merge($attrfieldnames, $allowedfieldnames);
|
||||
// Some header don't have same column name
|
||||
// Some header don't have same column name
|
||||
$aReplacedFields=array(
|
||||
'invited'=>'sent'
|
||||
);
|
||||
|
@ -1984,7 +1999,7 @@ class tokens extends Survey_Common_Action
|
|||
$separator = ';'; else
|
||||
$separator = ',';
|
||||
}
|
||||
$firstline = convertCSVRowToArray($buffer, $separator, '"');
|
||||
$firstline = str_getcsv($buffer, $separator, '"');
|
||||
$firstline = array_map('trim', $firstline);
|
||||
$ignoredcolumns = array();
|
||||
// Now check the first line for invalid fields
|
||||
|
@ -2010,16 +2025,15 @@ class tokens extends Survey_Common_Action
|
|||
else
|
||||
{
|
||||
|
||||
$line = convertCSVRowToArray($buffer, $separator, '"');
|
||||
$line = str_getcsv($buffer, $separator, '"');
|
||||
|
||||
if (count($firstline) != count($line))
|
||||
{
|
||||
$invalidformatlist[] = $recordcount;
|
||||
$invalidformatlist[] = sprintf(gt("Line %s"),$recordcount);
|
||||
$recordcount++;
|
||||
continue;
|
||||
}
|
||||
$writearray = array_combine($firstline, $line);
|
||||
|
||||
//kick out ignored columns
|
||||
foreach ($ignoredcolumns as $column)
|
||||
{
|
||||
|
@ -2030,29 +2044,34 @@ class tokens extends Survey_Common_Action
|
|||
|
||||
if ($filterduplicatetoken != false)
|
||||
{
|
||||
$dupquery = "SELECT count(tid) from {{tokens_".intval($iSurveyId)."}} where 1=1";
|
||||
$aParams=array();
|
||||
$oCriteria= new CDbCriteria;
|
||||
$oCriteria->condition="";
|
||||
foreach ($filterduplicatefields as $field)
|
||||
{
|
||||
if (isset($writearray[$field]))
|
||||
{
|
||||
$dupquery.= " and ".Yii::app()->db->quoteColumnName($field)." = " . Yii::app()->db->quoteValue($writearray[$field]);
|
||||
$oCriteria->addCondition("{$field} = :{$field}");
|
||||
$aParams[":{$field}"]=$writearray[$field];
|
||||
}
|
||||
}
|
||||
$dupresult = Yii::app()->db->createCommand($dupquery)->queryScalar();
|
||||
if(!empty($aParams))
|
||||
$oCriteria->params=$aParams;
|
||||
$dupresult = TokenDynamic::model($iSurveyId)->count($oCriteria);
|
||||
if ($dupresult > 0)
|
||||
{
|
||||
$dupfound = true;
|
||||
$duplicatelist[] = Yii::app()->db->quoteValue($writearray['firstname']) . " " . Yii::app()->db->quoteValue($writearray['lastname']) . " (" . Yii::app()->db->quoteValue($writearray['email']) . ")";
|
||||
$duplicatelist[] = sprintf(gt("Line %s : %s %s (%s)"),$recordcount,$writearray['firstname'],$writearray['lastname'],$writearray['email']);
|
||||
}
|
||||
}
|
||||
$writearray['email'] = trim($writearray['email']);
|
||||
//treat blank emails
|
||||
if ($filterblankemail && $writearray['email'] == '')
|
||||
if (!$dupfound && $filterblankemail && $writearray['email'] == '')
|
||||
{
|
||||
$invalidemail = true;
|
||||
$invalidemaillist[] = $line[0] . " " . $line[1] . " ( )";
|
||||
}
|
||||
if ($writearray['email'] != '')
|
||||
if (!$dupfound && $writearray['email'] != '')
|
||||
{
|
||||
$aEmailAddresses = explode(';', $writearray['email']);
|
||||
foreach ($aEmailAddresses as $sEmailaddress)
|
||||
|
@ -2068,6 +2087,15 @@ class tokens extends Survey_Common_Action
|
|||
if (isset($writearray['token']))
|
||||
{
|
||||
$writearray['token'] = sanitize_token($writearray['token']);
|
||||
if(!$dupfound && $writearray['token']) // We allways filter duplicate token
|
||||
{
|
||||
$dupresult = TokenDynamic::model($iSurveyId)->count("token=:token",array('token'=>$writearray['token']));
|
||||
if($dupresult>0)
|
||||
{
|
||||
$duplicatelist[] = sprintf(gt("Line %s : token %s already used."),$recordcount,$writearray['token']);
|
||||
$dupfound=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$dupfound && !$invalidemail)
|
||||
|
@ -2075,25 +2103,27 @@ class tokens extends Survey_Common_Action
|
|||
// unset all empty value
|
||||
foreach ($writearray as $key=>$value)
|
||||
{
|
||||
if($writearray[$key]=="")
|
||||
if($writearray[$key]=="" && !in_array($key,array('firstname','lastname','email')))
|
||||
unset($writearray[$key]);
|
||||
if (substr($value, 0, 1)=='"' && substr($value, -1)=='"')// Fix CSV quote
|
||||
$value = substr($value, 1, -1);
|
||||
}
|
||||
// Some default value : to be moved to Token model rules in future release ?
|
||||
// But think we have to accept invalid email etc ... then use specific scenario
|
||||
$writearray['emailstatus']=isset($writearray['emailstatus'])?$writearray['emailstatus']:"OK";
|
||||
//$writearray['emailstatus']=isset($writearray['emailstatus'])?$writearray['emailstatus']:"OK";
|
||||
$writearray['language']=isset($writearray['language'])?$writearray['language']:$sBaseLanguage;
|
||||
$oToken = Token::create($iSurveyId);
|
||||
//$oToken = Token::create($iSurveyId);//
|
||||
TokenDynamic::sid($iSurveyId);
|
||||
$oToken = new TokenDynamic;
|
||||
foreach ($writearray as $key => $value)
|
||||
{
|
||||
//if(in_array($key,$oToken->attributes)) Not needed because we filter attributes before
|
||||
$oToken->$key=$value;
|
||||
}
|
||||
$ir=$oToken->save();
|
||||
if (!$ir)
|
||||
if (!$oToken->save())
|
||||
{
|
||||
$duplicatelist[] = $writearray['firstname'] . " " . $writearray['lastname'] . " (" . $writearray['email'] . ")";
|
||||
$errorlist[] = sprintf(gt("Line %s : %s %s (%s)"),$recordcount,$writearray['firstname'],$writearray['lastname'],$writearray['email']);
|
||||
tracevar($oToken->getErrors());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2116,6 +2146,7 @@ class tokens extends Survey_Common_Action
|
|||
$aData['duplicatelist'] = $duplicatelist;
|
||||
$aData['invalidformatlist'] = $invalidformatlist;
|
||||
$aData['invalidemaillist'] = $invalidemaillist;
|
||||
$aData['errorlist'] = $errorlist;
|
||||
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
|
||||
$aData['iSurveyId'] = $aData['surveyid'] = $iSurveyId;
|
||||
|
||||
|
@ -2135,13 +2166,13 @@ class tokens extends Survey_Common_Action
|
|||
unset($aTokenTableFields['usesleft']);
|
||||
foreach ($aTokenTableFields as $sKey=>$sValue)
|
||||
{
|
||||
if ($sValue['description']!=$sKey)
|
||||
if ($sValue['description']!=$sKey)
|
||||
{
|
||||
$sValue['description'] .= ' - '.$sKey;
|
||||
$sValue['description'] .= ' - '.$sKey;
|
||||
}
|
||||
$aNewTokenTableFields[$sKey]= $sValue['description'];
|
||||
}
|
||||
$aData['aTokenTableFields'] = $aNewTokenTableFields;
|
||||
$aData['aTokenTableFields'] = $aNewTokenTableFields;
|
||||
$this->_renderWrappedTemplate('token', array('tokenbar', 'csvupload'), $aData);
|
||||
}
|
||||
}
|
||||
|
@ -2309,7 +2340,6 @@ class tokens extends Survey_Common_Action
|
|||
}
|
||||
else
|
||||
{
|
||||
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "tokenbounce.js");
|
||||
$this->_renderWrappedTemplate('token', array('tokenbar', 'bounce'), $aData);
|
||||
}
|
||||
}
|
||||
|
@ -2355,10 +2385,10 @@ class tokens extends Survey_Common_Action
|
|||
{
|
||||
if (strpos($sTokenFieldName,'attribute_')===0 && (!isset($aData['attrfieldnames']) || !isset($aData['attrfieldnames'][$sTokenFieldName])))
|
||||
{
|
||||
$aData['attrfieldnames'][$sTokenFieldName]=array('description'=>$sTokenFieldName,'mandatory'=>'N');
|
||||
$aData['attrfieldnames'][$sTokenFieldName]=array('description'=>$sTokenFieldName,'mandatory'=>'N');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$aData['thissurvey'] = $thissurvey;
|
||||
$aData['surveyid'] = $iSurveyId;
|
||||
$aData['subaction'] = $subaction;
|
||||
|
@ -2404,7 +2434,7 @@ class tokens extends Survey_Common_Action
|
|||
//Rebuild attributedescription value for the surveys table
|
||||
$table = Yii::app()->db->schema->getTable(Yii::app()->request->getPost('oldtable'));
|
||||
$fields=array_filter(array_keys($table->columns), 'filterForAttributes');
|
||||
$fieldcontents = $aSurveyInfo['attributedescriptions'];
|
||||
$fieldcontents = $aSurveyInfo['attributedescriptions'];
|
||||
if (!is_array($fieldcontents)) $fieldcontents=array();
|
||||
foreach ($fields as $fieldname)
|
||||
{
|
||||
|
@ -2423,12 +2453,12 @@ class tokens extends Survey_Common_Action
|
|||
);
|
||||
}
|
||||
}
|
||||
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => serialize($fieldcontents)));
|
||||
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => json_encode($fieldcontents)));
|
||||
|
||||
|
||||
Yii::app()->db->createCommand()->renameTable(Yii::app()->request->getPost('oldtable'), Yii::app()->db->tablePrefix."tokens_".intval($iSurveyId));
|
||||
Yii::app()->db->schema->getTable(Yii::app()->db->tablePrefix."tokens_".intval($iSurveyId), true); // Refresh schema cache just in case the table existed in the past
|
||||
|
||||
|
||||
//Check that the tokens table has the required fields
|
||||
TokenDynamic::model($iSurveyId)->checkColumns();
|
||||
|
||||
|
@ -2466,6 +2496,7 @@ class tokens extends Survey_Common_Action
|
|||
|
||||
$this->_renderWrappedTemplate('token', 'tokenwarning', $aData);
|
||||
}
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2476,7 +2507,7 @@ class tokens extends Survey_Common_Action
|
|||
* @param array $aData Data to be passed on. Optional.
|
||||
*/
|
||||
protected function _renderWrappedTemplate($sAction = 'token', $aViewUrls = array(), $aData = array())
|
||||
{
|
||||
{
|
||||
$aData['imageurl'] = Yii::app()->getConfig('adminimageurl');
|
||||
$aData['display']['menu_bars'] = false;
|
||||
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
|
||||
|
|
|
@ -1017,29 +1017,35 @@ class translate extends Survey_Common_Action {
|
|||
return $image;
|
||||
}
|
||||
|
||||
public function ajaxtranslategoogleapi()
|
||||
{
|
||||
// Ensure YII_CSRF_TOKEN, we are in admin, then only user with admin rigth can post
|
||||
if(Yii::app()->request->isPostRequest)
|
||||
{
|
||||
echo self::translate_google_api();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* translate_google_api.php
|
||||
* Creates a JSON interface for the auto-translate feature
|
||||
*/
|
||||
private function translate_google_api()
|
||||
{
|
||||
header('Content-type: application/json');
|
||||
|
||||
$sBaselang = Yii::app()->getRequest()->getPost('baselang');
|
||||
$sTolang = Yii::app()->getRequest()->getPost('tolang');
|
||||
$sToconvert = Yii::app()->getRequest()->getPost('text');
|
||||
|
||||
$aSearch = array('zh-Hans','zh-Hant-HK','zh-Hant-TW',
|
||||
'nl-informal','de-informal','it-formal','pt-BR','es-MX','nb','nn');
|
||||
$aSearch = array('zh-Hans','zh-Hant-HK','zh-Hant-TW','nl-informal','de-informal','it-formal','pt-BR','es-MX','nb','nn');
|
||||
$aReplace = array('zh-CN','zh-TW','zh-TW','nl','de','it','pt','es','no','no');
|
||||
|
||||
$sBaselang = str_replace($aSearch, $aReplace, $sBaselang);
|
||||
$sTolang = str_replace($aSearch, $aReplace, $sTolang);
|
||||
|
||||
$error = FALSE;
|
||||
$error = false;
|
||||
|
||||
try
|
||||
{
|
||||
{
|
||||
Yii::app()->loadLibrary('admin/gtranslate/GTranslate');
|
||||
$gtranslate = new Gtranslate();
|
||||
$gtranslate = new Gtranslate();
|
||||
$objGt = $gtranslate;
|
||||
|
||||
// Gtranslate requires you to run function named XXLANG_to_XXLANG
|
||||
|
@ -1078,7 +1084,9 @@ class translate extends Survey_Common_Action {
|
|||
'converted' => $sOutput
|
||||
);
|
||||
|
||||
return ls_json_encode($aOutput) . "\n";
|
||||
header('Content-type: application/json');
|
||||
return ls_json_encode($aOutput);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,16 +147,21 @@ class update extends Survey_Common_Action
|
|||
|
||||
function step2()
|
||||
{
|
||||
|
||||
$aReadOnlyFiles=array();
|
||||
$clang = $this->getController()->lang;
|
||||
$buildnumber = Yii::app()->getConfig("buildnumber");
|
||||
$updatebuild = getGlobalSetting("updatebuild");
|
||||
|
||||
list($error, $updateinfo, $cookies) = $this->_getChangedFiles($buildnumber, $updatebuild);
|
||||
$aData = $this->_getFileStatus($updateinfo);
|
||||
$aReadOnlyFiles=array_unique($aData['readonlyfiles']);
|
||||
sort($aReadOnlyFiles);
|
||||
$aData['readonlyfiles']=$aReadOnlyFiles;
|
||||
if(count($aData['readonlyfiles']))
|
||||
{
|
||||
foreach (array_unique($aData['readonlyfiles']) as $aFile)
|
||||
{
|
||||
$aReadOnlyFiles[]=substr($aFile,strlen(Yii::app()->getConfig("rootdir")));
|
||||
}
|
||||
sort($aReadOnlyFiles);
|
||||
$aData['readonlyfiles']=$aReadOnlyFiles;
|
||||
}
|
||||
Yii::app()->session['updateinfo'] = $updateinfo;
|
||||
Yii::app()->session['updatesession'] = $cookies;
|
||||
|
||||
|
@ -292,7 +297,7 @@ class update extends Survey_Common_Action
|
|||
if ((in_array($aDatabasetype, array('mysql', 'mysqli'))) && Yii::app()->getConfig('demoMode') != true) {
|
||||
Yii::app()->loadHelper("admin/backupdb");
|
||||
$sfilename = $tempdir.DIRECTORY_SEPARATOR."backup_db_".randomChars(20)."_".dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).".sql";
|
||||
$dfilename = $tempdir.DIRECTORY_SEPARATOR."LimeSurvey_database_backup_".$basefilename.".sql.gz";
|
||||
$dfilename = $tempdir.DIRECTORY_SEPARATOR."LimeSurvey_database_backup_".$basefilename.".zip";
|
||||
|
||||
outputDatabase('',false,$sfilename);
|
||||
// Before try to zip: test size of file
|
||||
|
|
|
@ -119,7 +119,7 @@ class UserAction extends Survey_Common_Action
|
|||
$body = sprintf($clang->gT("Hello %s,"), $new_full_name) . "<br /><br />\n";
|
||||
$body .= sprintf($clang->gT("this is an automated email to notify that a user has been created for you on the site '%s'."), Yii::app()->getConfig("sitename")) . "<br /><br />\n";
|
||||
$body .= $clang->gT("You can use now the following credentials to log into the site:") . "<br />\n";
|
||||
$body .= $clang->gT("Username") . ": " . $new_user . "<br />\n";
|
||||
$body .= $clang->gT("Username") . ": " . htmlspecialchars($new_user) . "<br />\n";
|
||||
if (Yii::app()->getConfig("auth_webserver") === false) { // authent is not delegated to web server
|
||||
// send password (if authorized by config)
|
||||
if (Yii::app()->getConfig("display_user_password_in_email") === true) {
|
||||
|
|
|
@ -337,11 +337,18 @@ class Usergroups extends Survey_Common_Action
|
|||
$clang = Yii::app()->lang;
|
||||
$uid = (int) Yii::app()->request->getPost('uid');
|
||||
|
||||
$group = UserGroup::model()->findByAttributes(array('ugid' => $ugid, 'owner_id' => Yii::app()->session['loginID']));
|
||||
if (Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
{
|
||||
$group = UserGroup::model()->findByAttributes(array('ugid' => $ugid));
|
||||
}
|
||||
else
|
||||
{
|
||||
$group = UserGroup::model()->findByAttributes(array('ugid' => $ugid, 'owner_id' => Yii::app()->session['loginID']));
|
||||
}
|
||||
|
||||
if (empty($group))
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index(0, array('type' => 'warning', 'message' => $clang->gT('Failed.') . '<br />' . $clang->gT('Group not found.')));
|
||||
list($aViewUrls, $aData) = $this->index(0, array('type' => 'warning', 'message' => $clang->gT('Failed.') . ' ' . $clang->gT('You are ')));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -349,35 +356,36 @@ class Usergroups extends Survey_Common_Action
|
|||
{
|
||||
if ($group->owner_id == $uid)
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed.') . '<br />' . $clang->gT('You can not add or remove the group owner from the group.')));
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed.') . ' ' . $clang->gT('You can not add or remove the group owner from the group.')));
|
||||
}
|
||||
else {
|
||||
$user_in_group = UserInGroup::model()->findByPk(array('ugid' => $ugid, 'uid' => $uid));
|
||||
|
||||
$user_in_group = UserInGroup::model()->findByPk(array('ugid' => $ugid, 'uid' => $uid));
|
||||
switch ($action)
|
||||
{
|
||||
case 'add' :
|
||||
if (empty($user_in_group) && UserInGroup::model()->insertRecords(array('ugid' => $ugid, 'uid' => $uid)))
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'success', 'message' => $clang->gT('User added.')));
|
||||
}
|
||||
else
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed to add user.') . ' ' . $clang->gT('User already exists in the group.')));
|
||||
}
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'add' :
|
||||
if (empty($user_in_group) && UserInGroup::model()->insertRecords(array('ugid' => $ugid, 'uid' => $uid)))
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'success', 'message' => $clang->gT('User added.')));
|
||||
}
|
||||
else
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed to add user.') . '<br />' . $clang->gT('User already exists in the group.')));
|
||||
}
|
||||
break;
|
||||
case 'remove' :
|
||||
if (!empty($user_in_group) && UserInGroup::model()->deleteByPk(array('ugid' => $ugid, 'uid' => $uid)))
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'success', 'message' => $clang->gT('User removed.')));
|
||||
}
|
||||
else
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed to remove user.') . ' ' . $clang->gT('User does not exist in the group.')));
|
||||
}
|
||||
|
||||
break;
|
||||
case 'remove' :
|
||||
if (!empty($user_in_group) && UserInGroup::model()->deleteByPk(array('ugid' => $ugid, 'uid' => $uid)))
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'success', 'message' => $clang->gT('User removed.')));
|
||||
}
|
||||
else
|
||||
{
|
||||
list($aViewUrls, $aData) = $this->index($ugid, array('type' => 'warning', 'message' => $clang->gT('Failed to remove user.') . '<br />' . $clang->gT('User does not exist in the group.')));
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -69,7 +69,7 @@ class index extends CAction {
|
|||
$thisstep = $param['thisstep'];
|
||||
$move=getMove();
|
||||
Yii::app()->setConfig('move',$move);
|
||||
$clienttoken = $param['token'];
|
||||
$clienttoken = trim($param['token']);
|
||||
$standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
|
||||
if (is_null($thissurvey) && !is_null($surveyid)) $thissurvey = getSurveyInfo($surveyid);
|
||||
|
||||
|
@ -313,11 +313,8 @@ class index extends CAction {
|
|||
}
|
||||
}
|
||||
|
||||
$_SESSION['survey_'.$surveyid]['holdname'] = $sLoadName;
|
||||
$_SESSION['survey_'.$surveyid]['holdpass'] = $sLoadPass;
|
||||
|
||||
if ($errormsg == "") {
|
||||
LimeExpressionManager::SetDirtyFlag();
|
||||
LimeExpressionManager::SetDirtyFlag();
|
||||
buildsurveysession($surveyid);
|
||||
if (loadanswers()){
|
||||
Yii::app()->setConfig('move','movenext');
|
||||
|
@ -378,27 +375,35 @@ class index extends CAction {
|
|||
}
|
||||
if (!isset($tokenInstance))
|
||||
{
|
||||
$tk = Token::model($surveyid)->findByAttributes(array('token' => $token));
|
||||
if($tk->completed == 'N')
|
||||
$oToken = Token::model($surveyid)->findByAttributes(array('token' => $token));
|
||||
if($oToken)
|
||||
{
|
||||
$now = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust"));
|
||||
if(strtotime($now) < strtotime($tk->validfrom))
|
||||
if($oToken->completed != 'N' && !empty($oToken->completed))
|
||||
{
|
||||
$err = $clang->gT("This invitation is not valid yet.");
|
||||
$sError = $clang->gT("This invitation has already been used.");
|
||||
}
|
||||
else
|
||||
elseif(strtotime($now) < strtotime($oToken->validfrom))
|
||||
{
|
||||
$err = $clang->gT("This invitation is not valid anymore.");
|
||||
$sError = $clang->gT("This invitation is not valid yet.");
|
||||
}
|
||||
elseif(strtotime($now) > strtotime($oToken->validuntil))
|
||||
{
|
||||
$sError = $clang->gT("This invitation is not valid anymore.");
|
||||
}
|
||||
else // This can not happen
|
||||
{
|
||||
$sError = $clang->gT("This is a controlled survey. You need a valid token to participate.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$err = $clang->gT("This invitation has already been used.");
|
||||
$sError = $clang->gT("This is a controlled survey. You need a valid token to participate.");
|
||||
}
|
||||
$asMessage = array(
|
||||
null,
|
||||
$clang->gT("We are sorry but you are not allowed to enter this survey."),
|
||||
$err,
|
||||
$sError,
|
||||
sprintf($clang->gT("For further information please contact %s"), $thissurvey['adminname']." (<a href='mailto:{$thissurvey['adminemail']}'>"."{$thissurvey['adminemail']}</a>)")
|
||||
);
|
||||
|
||||
|
@ -499,25 +504,52 @@ class index extends CAction {
|
|||
if (!isset($_SESSION['survey_'.$surveyid]['srid']) && $thissurvey['anonymized'] == "N" && $thissurvey['active'] == "Y" && isset($token) && $token !='')
|
||||
{
|
||||
// load previous answers if any (dataentry with nosubmit)
|
||||
//$oSurveyTokenInstance=SurveyDynamic::model($surveyid)->find(array('select'=>'id,submitdate,lastpage', 'condition'=>'token=:token', 'order'=>'id DESC','params'=>array('token' => $token)));
|
||||
$oSurveyTokenInstance=SurveyDynamic::model($surveyid)->find(array('condition'=>'token=:token', 'order'=>'id DESC','params'=>array('token' => $token)));
|
||||
if ( $oSurveyTokenInstance )
|
||||
$oResponses = Response::model($surveyid)->findAllByAttributes(array(
|
||||
'token' => $token
|
||||
), array('order' => 'id DESC'));
|
||||
if (!empty($oResponses))
|
||||
{
|
||||
if((empty($oSurveyTokenInstance->submitdate) || $thissurvey['alloweditaftercompletion'] == 'Y' ) && $thissurvey['tokenanswerspersistence'] == 'Y')
|
||||
/**
|
||||
* We fire the response selection event when at least 1 response was found.
|
||||
* If there is just 1 response the plugin still has to option to choose
|
||||
* NOT to use it.
|
||||
*/
|
||||
$event = new PluginEvent('beforeLoadResponse');
|
||||
$event->set('responses', $oResponses);
|
||||
$event->set('surveyId', $surveyid);
|
||||
App()->pluginManager->dispatchEvent($event);
|
||||
|
||||
$oResponse = $event->get('response');
|
||||
// If $oResponse is false we act as if no response was found.
|
||||
// This allows a plugin to deny continuing a response.
|
||||
if ($oResponse !== false)
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['srid'] = $oSurveyTokenInstance->id;
|
||||
if (!empty($oSurveyTokenInstance->lastpage))
|
||||
// If plugin does not set a response we use the first one found, (this replicates pre-plugin behavior)
|
||||
if (!isset($oResponse) && (!isset($oResponses[0]->submitdate) || $thissurvey['alloweditaftercompletion'] == 'Y') && $thissurvey['tokenanswerspersistence'] == 'Y')
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['LEMtokenResume'] = true;
|
||||
$_SESSION['survey_'.$surveyid]['step'] = $oSurveyTokenInstance->lastpage;
|
||||
$oResponse = $oResponses[0];
|
||||
}
|
||||
|
||||
if (isset($oResponse))
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['srid'] = $oResponse->id;
|
||||
if (!empty($oResponse->lastpage))
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['LEMtokenResume'] = true;
|
||||
// If the response was completed and user is allowed to edit after completion start at the beginning and not at the last page - just makes more sense
|
||||
if (!($oResponse->submitdate && $thissurvey['alloweditaftercompletion'] == 'Y'))
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['step'] = $oResponse->lastpage;
|
||||
}
|
||||
}
|
||||
buildsurveysession($surveyid);
|
||||
if(!empty($oResponse->submitdate)) // alloweditaftercompletion
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['maxstep'] = $_SESSION['survey_'.$surveyid]['totalsteps'];
|
||||
}
|
||||
loadanswers();
|
||||
}
|
||||
}
|
||||
buildsurveysession($surveyid);
|
||||
if(!empty($oSurveyTokenInstance->submitdate)) // alloweditaftercompletion
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['maxstep'] = $_SESSION['survey_'.$surveyid]['totalsteps'];
|
||||
}
|
||||
loadanswers();
|
||||
}
|
||||
}
|
||||
// Preview action : Preview right already tested before
|
||||
|
@ -567,7 +599,7 @@ class index extends CAction {
|
|||
foreach(array('lang','action','newtest','qid','gid','sid','loadname','loadpass','scid','thisstep','move','token') as $sNeededParam)
|
||||
{
|
||||
$param[$sNeededParam]=returnGlobal($sNeededParam,true);
|
||||
}
|
||||
}
|
||||
|
||||
return $param;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class LSUserIdentity extends CUserIdentity {
|
|||
// Delegate actual authentication to plugin
|
||||
$authEvent = new PluginEvent('newUserSession', $this);
|
||||
$authEvent->set('identity', $this);
|
||||
App()->getPluginManager()->dispatchEvent($authEvent, array($this->plugin));
|
||||
App()->getPluginManager()->dispatchEvent($authEvent);
|
||||
$pluginResult = $authEvent->get('result');
|
||||
if ($pluginResult instanceof LSAuthResult) {
|
||||
$result = $pluginResult;
|
||||
|
|
47
sources/application/core/LSYii_CaseValidator.php
Normal file
47
sources/application/core/LSYii_CaseValidator.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
* LimeSurvey
|
||||
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
|
||||
* All rights reserved.
|
||||
* License: GNU/GPL License v2 or later, see LICENSE.php
|
||||
* LimeSurvey is free software. This version may have been modified pursuant
|
||||
* to the GNU General Public License, and as distributed it includes or
|
||||
* is derivative of works licensed under the GNU General Public License or
|
||||
* other free or open source software licenses.
|
||||
* See COPYRIGHT.php for copyright notices and details.
|
||||
*
|
||||
*/
|
||||
|
||||
class LSYii_CaseValidator extends CValidator {
|
||||
|
||||
public $type='lower';
|
||||
|
||||
|
||||
public function validateAttribute($object,$attribute){
|
||||
|
||||
if ($this->type=='upper')
|
||||
{
|
||||
if (strtoupper($object->$attribute)==$object->$attribute){
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addError($object, $attribute, gT('Text needs to be uppercase.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // default to lowercase
|
||||
{
|
||||
if (strtolower($object->$attribute)==$object->$attribute){
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addError($object, $attribute, gT('Text needs to be lowercase.'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
|
@ -36,7 +36,7 @@ class LSYii_EmailIDNAValidator extends CValidator {
|
|||
|
||||
foreach ($aEmailAdresses as $sEmailAddress)
|
||||
{
|
||||
if (!validateEmailAddress($object->$attribute))
|
||||
if (!validateEmailAddress($sEmailAddress))
|
||||
{
|
||||
$this->addError($object, $attribute, gT('Invalid email address.'));
|
||||
return;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* See COPYRIGHT.php for copyright notices and details.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class LSYii_Validators extends CValidator {
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ class LSYii_Validators extends CValidator {
|
|||
if($this->isUrl)
|
||||
{
|
||||
if ($object->$attribute== 'http://' || $object->$attribute=='https://') {$object->$attribute="";}
|
||||
$object->$attribute=html_entity_decode($object->$attribute, ENT_QUOTES, "UTF-8"); // 140219 : Why not urlencode ?
|
||||
$object->$attribute=str_replace(array('"',"'",' ','<','>'),'',html_entity_decode($object->$attribute, ENT_QUOTES, "UTF-8")); // 140219 : Why not urlencode ?
|
||||
}
|
||||
if($this->isLanguage)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ class LSYii_Validators extends CValidator {
|
|||
/**
|
||||
* Remove some empty characters put by CK editor
|
||||
* Did we need to do if user don't use inline HTML editor ?
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function fixCKeditor($value)
|
||||
|
@ -95,8 +95,8 @@ class LSYii_Validators extends CValidator {
|
|||
return $value;
|
||||
}
|
||||
/**
|
||||
* Remove any script or dangerous HTML
|
||||
*
|
||||
* Remove any script or dangerous HTML
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function xssFilter($value)
|
||||
|
@ -104,11 +104,12 @@ class LSYii_Validators extends CValidator {
|
|||
$filter = new CHtmlPurifier();
|
||||
$filter->options = array(
|
||||
'AutoFormat.RemoveEmpty'=>false,
|
||||
'Core.NormalizeNewlines'=>false,
|
||||
'CSS.AllowTricky'=>true, // Allow display:none; (and other)
|
||||
'HTML.SafeObject'=>true, // To allow including youtube
|
||||
'Output.FlashCompat'=>true,
|
||||
'Attr.EnableID'=>true, // Allow to set id
|
||||
'Attr.AllowedFrameTargets'=>array('_blank','_self'),
|
||||
'Attr.AllowedFrameTargets'=>array('_blank','_self'),
|
||||
'URI.AllowedSchemes'=>array(
|
||||
'http' => true,
|
||||
'https' => true,
|
||||
|
@ -119,22 +120,29 @@ class LSYii_Validators extends CValidator {
|
|||
)
|
||||
);
|
||||
// To allow script BUT purify : HTML.Trusted=true (plugin idea for admin or without XSS filtering ?)
|
||||
|
||||
/** Start to get complete filtered value with url decode {QCODE} (bug #09300). This allow only question number in url, seems OK with XSS protection **/
|
||||
$sFiltered=preg_replace('#%7B([a-zA-Z0-9\.]*)%7D#','{$1}',$filter->purify($value));
|
||||
Yii::import('application.helpers.expressions.em_core_helper');// Already imported in em_manager_helper.php ?
|
||||
$oExpressionManager= new ExpressionManager;
|
||||
/** We get 2 array : one filtered, other unfiltered **/
|
||||
$aValues=$oExpressionManager->asSplitStringOnExpressions($value);// Return array of array : 0=>the string,1=>string length,2=>string type (STRING or EXPRESSION)
|
||||
$aFilteredValues=$oExpressionManager->asSplitStringOnExpressions($sFiltered);// Same but for the filtered string
|
||||
$bCountIsOk=count($aValues)==count($aFilteredValues);
|
||||
/** Construction of new string with unfiltered EM and filtered HTML **/
|
||||
$sNewValue="";
|
||||
foreach($aValues as $aValue){
|
||||
foreach($aValues as $key=>$aValue){
|
||||
if($aValue[2]=="STRING")
|
||||
$sNewValue.=$filter->purify($aValue[0]);
|
||||
$sNewValue.=$bCountIsOk ? $aFilteredValues[$key][0]:$filter->purify($aValue[0]);// If EM is broken : can throw invalid $key
|
||||
else
|
||||
{
|
||||
$sExpression=trim($aValue[0], '{}');
|
||||
$sNewValue.="{";
|
||||
$aParsedExpressions=$oExpressionManager->Tokenize($sExpression,true);// Return array of array : 0=>the string,1=>string length,2=>string type
|
||||
$aParsedExpressions=$oExpressionManager->Tokenize($sExpression,true);
|
||||
foreach($aParsedExpressions as $aParsedExpression)
|
||||
{
|
||||
if($aParsedExpression[2]=='DQ_STRING')
|
||||
$sNewValue.="\"".$filter->purify($aParsedExpression[0])."\"";
|
||||
$sNewValue.="\"".$filter->purify($aParsedExpression[0])."\""; // This disallow complex HTML construction with XSS
|
||||
elseif($aParsedExpression[2]=='SQ_STRING')
|
||||
$sNewValue.="'".$filter->purify($aParsedExpression[0])."'";
|
||||
else
|
||||
|
@ -143,11 +151,12 @@ class LSYii_Validators extends CValidator {
|
|||
$sNewValue.="}";
|
||||
}
|
||||
}
|
||||
gc_collect_cycles(); // To counter a high memory usage of HTML-Purifier
|
||||
return $sNewValue;
|
||||
}
|
||||
/**
|
||||
* Defines the customs validation rule for language string
|
||||
*
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function languageFilter($value)
|
||||
|
@ -157,7 +166,7 @@ class LSYii_Validators extends CValidator {
|
|||
}
|
||||
/**
|
||||
* Defines the customs validation rule for multi language string
|
||||
*
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function multiLanguageFilter($value)
|
||||
|
@ -166,5 +175,5 @@ class LSYii_Validators extends CValidator {
|
|||
$aValue=array_map("sanitize_languagecode",$aValue);
|
||||
return implode(" ",$aValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class Survey_Common_Action extends CAction
|
|||
// Make sure viewHelper can be autoloaded
|
||||
Yii::import('application.helpers.viewHelper');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override runWithParams() implementation in CAction to help us parse
|
||||
* requests with subactions.
|
||||
|
@ -344,7 +344,7 @@ class Survey_Common_Action extends CAction
|
|||
|
||||
if(!isset($aData['display']['footer']) || $aData['display']['footer'] !== false)
|
||||
Yii::app()->getController()->_getAdminFooter('http://manual.limesurvey.org', $clang->gT('LimeSurvey online manual'));
|
||||
|
||||
|
||||
$out = ob_get_contents();
|
||||
ob_clean();
|
||||
App()->getClientScript()->render($out);
|
||||
|
@ -816,7 +816,7 @@ class Survey_Common_Action extends CAction
|
|||
|
||||
if ($aSurveyInfo['surveyls_url'] != "")
|
||||
{
|
||||
$aData['endurl'] = " <a target='_blank' href=\"" . flattenText($aSurveyInfo['surveyls_url']) . "\" title=\"" . flattenText($aSurveyInfo['surveyls_url']) . "\">".flattenText($aSurveyInfo['surveyls_urldescription'])."</a>";
|
||||
$aData['endurl'] = " <a target='_blank' href=\"" . htmlspecialchars($aSurveyInfo['surveyls_url']) . "\" title=\"" . htmlspecialchars($aSurveyInfo['surveyls_url']) . "\">".flattenText($aSurveyInfo['surveyls_urldescription'])."</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -922,7 +922,7 @@ class Survey_Common_Action extends CAction
|
|||
{
|
||||
$sQuery .=" AND gu.uid = ".Yii::app()->session['loginID'];
|
||||
}
|
||||
|
||||
|
||||
$grpresult = Yii::app()->db->createCommand($sQuery)->queryRow(); //Checked
|
||||
|
||||
if ($grpresult) {
|
||||
|
|
|
@ -108,16 +108,6 @@ class AuthLDAP extends AuthPluginBase
|
|||
->addContent(CHtml::tag('li', array(), "<label for='password'>" . gT("Password") . "</label><input name='password' id='password' type='password' size='40' maxlength='40' value='' />"));
|
||||
}
|
||||
|
||||
public function afterLoginFormSubmit()
|
||||
{
|
||||
// Here we handle post data
|
||||
$request = $this->api->getRequest();
|
||||
if ($request->getIsPostRequest()) {
|
||||
$this->setUsername( $request->getPost('user'));
|
||||
$this->setPassword($request->getPost('password'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modified getPluginSettings since we have a select box that autosubmits
|
||||
* and we only want to show the relevant options.
|
||||
|
@ -166,6 +156,13 @@ class AuthLDAP extends AuthPluginBase
|
|||
|
||||
public function newUserSession()
|
||||
{
|
||||
// Do nothing if this user is not Authdb type
|
||||
$identity = $this->getEvent()->get('identity');
|
||||
if ($identity->plugin != 'AuthLDAP')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Here we do the actual authentication
|
||||
$username = $this->getUsername();
|
||||
$password = $this->getPassword();
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
class Authdb extends AuthPluginBase
|
||||
{
|
||||
protected $storage = 'DbStorage';
|
||||
|
||||
protected $_onepass = null;
|
||||
|
||||
|
||||
static protected $description = 'Core: Database authentication + exports';
|
||||
static protected $name = 'LimeSurvey internal database';
|
||||
|
||||
public function __construct(PluginManager $manager, $id) {
|
||||
|
||||
public function __construct(PluginManager $manager, $id)
|
||||
{
|
||||
parent::__construct($manager, $id);
|
||||
|
||||
|
||||
/**
|
||||
* Here you should handle subscribing to the events your plugin will handle
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ class Authdb extends AuthPluginBase
|
|||
$this->subscribe('afterLoginFormSubmit');
|
||||
$this->subscribe('newUserSession');
|
||||
$this->subscribe('beforeDeactivate');
|
||||
|
||||
|
||||
// Now register for the core exports
|
||||
$this->subscribe('listExportPlugins');
|
||||
$this->subscribe('listExportOptions');
|
||||
|
@ -34,7 +34,7 @@ class Authdb extends AuthPluginBase
|
|||
// Optionally set a custom error message.
|
||||
$this->getEvent()->set('message', gT('Core plugin can not be disabled.'));
|
||||
}
|
||||
|
||||
|
||||
public function beforeLogin()
|
||||
{
|
||||
$this->getEvent()->set('default', get_class($this)); // This is the default login method, should be configurable from plugin settings
|
||||
|
@ -49,7 +49,7 @@ class Authdb extends AuthPluginBase
|
|||
$this->setAuthPlugin(); // This plugin will handle authentication and skips the login form
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the onetime password (if set)
|
||||
*
|
||||
|
@ -59,10 +59,9 @@ class Authdb extends AuthPluginBase
|
|||
{
|
||||
return $this->_onepass;
|
||||
}
|
||||
|
||||
|
||||
public function newLoginForm()
|
||||
{
|
||||
|
||||
$sUserName='';
|
||||
$sPassword='';
|
||||
if (Yii::app()->getConfig("demoMode") === true && Yii::app()->getConfig("demoModePrefill") === true)
|
||||
|
@ -75,27 +74,24 @@ class Authdb extends AuthPluginBase
|
|||
->addContent(CHtml::tag('li', array(), "<label for='user'>" . gT("Username") . "</label>".CHtml::textField('user',$sUserName,array('size'=>40,'maxlength'=>40))))
|
||||
->addContent(CHtml::tag('li', array(), "<label for='password'>" . gT("Password") . "</label>".CHtml::passwordField('password',$sPassword,array('size'=>40,'maxlength'=>40))));
|
||||
}
|
||||
|
||||
public function afterLoginFormSubmit()
|
||||
{
|
||||
// Here we handle post data
|
||||
$request = $this->api->getRequest();
|
||||
if ($request->getIsPostRequest()) {
|
||||
$this->setUsername( $request->getPost('user'));
|
||||
$this->setPassword($request->getPost('password'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function newUserSession()
|
||||
{
|
||||
// Do nothing if this user is not Authdb type
|
||||
$identity = $this->getEvent()->get('identity');
|
||||
if ($identity->plugin != 'Authdb')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Here we do the actual authentication
|
||||
$username = $this->getUsername();
|
||||
$password = $this->getPassword();
|
||||
$onepass = $this->getOnePass();
|
||||
|
||||
|
||||
$user = $this->api->getUserByName($username);
|
||||
|
||||
if ($user !== null)
|
||||
|
||||
if ($user !== null and $username==$user->users_name) // Control of equality for uppercase/lowercase with mysql
|
||||
{
|
||||
if (gettype($user->password)=='resource')
|
||||
{
|
||||
|
@ -118,17 +114,16 @@ class Authdb extends AuthPluginBase
|
|||
$user->save();
|
||||
$this->setAuthSuccess($user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sStoredPassword !== hash('sha256', $password))
|
||||
{
|
||||
$this->setAuthFailure(self::ERROR_PASSWORD_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setAuthSuccess($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the onetime password
|
||||
*
|
||||
|
@ -141,8 +136,8 @@ class Authdb extends AuthPluginBase
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Now the export part:
|
||||
public function listExportOptions()
|
||||
{
|
||||
|
@ -181,7 +176,7 @@ class Authdb extends AuthPluginBase
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers this export type
|
||||
*/
|
||||
|
@ -201,7 +196,7 @@ class Authdb extends AuthPluginBase
|
|||
|
||||
$event->set('exportplugins', $exports);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the required IWriter
|
||||
*/
|
||||
|
@ -234,4 +229,4 @@ class Authdb extends AuthPluginBase
|
|||
|
||||
$event->set('writer', $writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,18 @@ class Authwebserver extends AuthPluginBase
|
|||
protected $settings = array(
|
||||
'strip_domain' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => 'Strip domain part (DOMAIN\\USER or USER@DOMAIN)'
|
||||
'label' => 'Strip domain part (DOMAIN\\USER or USER@DOMAIN)',
|
||||
),
|
||||
'serverkey' => array(
|
||||
'type' => 'string',
|
||||
'label' => 'Key to use for username e.g. PHP_AUTH_USER, LOGON_USER, REMOTE_USER. See phpinfo in global settings.',
|
||||
'default' => 'REMOTE_USER'
|
||||
'default' => 'REMOTE_USER',
|
||||
),
|
||||
'is_default' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => 'Check to make default authentication method (This disable Default LimeSurvey authentification by database)',
|
||||
'default' => true,
|
||||
)
|
||||
);
|
||||
|
||||
public function __construct(PluginManager $manager, $id) {
|
||||
|
@ -52,16 +57,31 @@ class Authwebserver extends AuthPluginBase
|
|||
{
|
||||
$sUser = $aUserMappings[$sUser];
|
||||
}
|
||||
$this->setUsername($sUser);
|
||||
$this->setAuthPlugin(); // This plugin handles authentication, halt further execution of auth plugins
|
||||
$oUser = $this->api->getUserByName($sUser);
|
||||
if($oUser || $this->api->getConfigKey('auth_webserver_autocreate_user'))
|
||||
{
|
||||
$this->setUsername($sUser);
|
||||
$this->setAuthPlugin(); // This plugin handles authentication, halt further execution of auth plugins
|
||||
}
|
||||
elseif($this->get('is_default',null,null,$this->settings['is_default']['default']))
|
||||
{
|
||||
throw new CHttpException(401,'Wrong credentials for LimeSurvey administration.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function newUserSession()
|
||||
{
|
||||
// Do nothing if this user is not Authwebserver type
|
||||
$identity = $this->getEvent()->get('identity');
|
||||
if ($identity->plugin != 'Authwebserver')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* @var $identity LSUserIdentity */
|
||||
$sUser = $this->getUserName();
|
||||
|
||||
|
||||
$oUser = $this->api->getUserByName($sUser);
|
||||
if (is_null($oUser))
|
||||
{
|
||||
|
@ -103,10 +123,9 @@ class Authwebserver extends AuthPluginBase
|
|||
{
|
||||
$this->setAuthFailure(self::ERROR_USERNAME_INVALID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ class RDataWriter extends CsvWriter {
|
|||
}
|
||||
|
||||
if ($value == 'Y') { // Yes
|
||||
return 1;
|
||||
return 2;
|
||||
} elseif ($value === '') { // No
|
||||
return 0;
|
||||
return 1;
|
||||
} else { // Not shown
|
||||
return $this->na;
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ class RDataWriter extends CsvWriter {
|
|||
|
||||
case 'Y': // Yes no question
|
||||
if ($value == 'Y') {
|
||||
return 1;
|
||||
return 2;
|
||||
} elseif ($value == 'N') {
|
||||
return 0;
|
||||
return 1;
|
||||
} else {
|
||||
// No data, probably a hidden question
|
||||
return $this->na;
|
||||
|
|
|
@ -351,7 +351,7 @@ class STATAxmlWriter extends Writer
|
|||
if (empty($this->headers))
|
||||
{
|
||||
$this->headers = $headers;
|
||||
foreach ($this->headers as $iKey => $sVarname)
|
||||
foreach ($this->headers as $iKey => &$sVarname)
|
||||
{
|
||||
$this->headers[$iKey] = $this->STATAvarname($sVarname);
|
||||
}
|
||||
|
@ -366,10 +366,11 @@ class STATAxmlWriter extends Writer
|
|||
*/
|
||||
protected function updateCustomresponsemap()
|
||||
{
|
||||
//create array that holds each values' data type
|
||||
foreach ($this->customResponsemap as $iRespId => $aResponses)
|
||||
//go through each particpants' responses
|
||||
foreach ($this->customResponsemap as $iRespId => &$aResponses)
|
||||
{
|
||||
foreach ($aResponses as $iVarid => $response)
|
||||
// go through variables and response items
|
||||
foreach ($aResponses as $iVarid => &$response)
|
||||
{
|
||||
$response=trim($response);
|
||||
//recode answercode=answer if codes are non-numeric (cannot be used with value labels)
|
||||
|
@ -382,18 +383,15 @@ class STATAxmlWriter extends Writer
|
|||
{
|
||||
$iScaleID = $this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['scale_id'];
|
||||
}
|
||||
$iQID = $this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['qid'];
|
||||
$iQID = $this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['qid'];
|
||||
if (isset($this->customFieldmap['answers'][$iQID][$iScaleID][$response]['answer']))
|
||||
{
|
||||
$response = trim($this->customFieldmap['answers'][$iQID][$iScaleID][$response]['answer']); // get answertext instead of answercode
|
||||
}
|
||||
}
|
||||
|
||||
if ($response == '')
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'emptystr';
|
||||
}
|
||||
else
|
||||
|
||||
if ($response != '')
|
||||
{
|
||||
// recode some values from letters to numeric, so we can attach value labels and have more time doing statistics
|
||||
switch ($this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['type'])
|
||||
|
@ -435,7 +433,16 @@ class STATAxmlWriter extends Writer
|
|||
break;
|
||||
}
|
||||
|
||||
// look at each of the responses and fill $aDatatypes with the respective STATA data type
|
||||
/* look at each of the responses and determine STATA data type and format of the respective variables
|
||||
datatypes coded as follows:
|
||||
1=""
|
||||
2=byte
|
||||
3=int
|
||||
4=long
|
||||
5=float
|
||||
6=double
|
||||
7=string
|
||||
*/
|
||||
$numberresponse = trim($response);
|
||||
if ($this->customFieldmap['info']['surveyls_numberformat'] == 1) // if settings: decimal seperator==','
|
||||
{
|
||||
|
@ -448,83 +455,98 @@ class STATAxmlWriter extends Writer
|
|||
{
|
||||
if ($numberresponse >= $this->minByte && $numberresponse <= $this->maxByte)
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'byte'; //this response is of STATA type 'byte'
|
||||
$iDatatype=2; //this response is of STATA type 'byte'
|
||||
}
|
||||
elseif ($numberresponse >= $this->minInt && $numberresponse <= $this->maxInt)
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'int'; // and this is is 'int'
|
||||
$iDatatype=3; // and this is is 'int'
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['type'] == 'D') // if datefield then a 'double' data type is needed
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'double';
|
||||
$iDatatype=6; // double
|
||||
}
|
||||
else
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'long';
|
||||
$iDatatype=4; //long
|
||||
}
|
||||
}
|
||||
}
|
||||
else //non-integer numeric response
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'float';
|
||||
$iDatatype=5; // float
|
||||
$response = $numberresponse; //replace in customResponsemap: value with '.' as decimal
|
||||
}
|
||||
}
|
||||
else // non-numeric response
|
||||
{
|
||||
$aDatatypes[$this->headersSGQA[$iVarid]][$iRespId] = 'string';
|
||||
$strlenarray[$this->headersSGQA[$iVarid]][$iRespId] = strlen($response); //for strings we need the length as well for the data type
|
||||
$iDatatype=7; //string
|
||||
$iStringlength=strlen($response); //for strings we need the length for the format and the data type
|
||||
}
|
||||
}
|
||||
$this->customResponsemap[$iRespId][$iVarid]=$response; //write the recoded response back to the response array
|
||||
else
|
||||
{
|
||||
$iDatatype=1; // response = ""
|
||||
}
|
||||
|
||||
// initialize format and type (default: empty)
|
||||
if (!isset($aStatatypelist[$this->headersSGQA[$iVarid]]['type']))
|
||||
$aStatatypelist[$this->headersSGQA[$iVarid]]['type']=1;
|
||||
if (!isset($aStatatypelist[$this->headersSGQA[$iVarid]]['format']))
|
||||
$aStatatypelist[$this->headersSGQA[$iVarid]]['format']=0;
|
||||
|
||||
// Does the variable need a higher datatype because of the current response?
|
||||
if ($aStatatypelist[$this->headersSGQA[$iVarid]]['type'] < $iDatatype)
|
||||
$aStatatypelist[$this->headersSGQA[$iVarid]]['type'] = $iDatatype;
|
||||
|
||||
// if datatype is a string, set needed stringlength
|
||||
if ($iDatatype==7)
|
||||
{
|
||||
// Does the variable need a higher stringlength because of the current response?
|
||||
if ($aStatatypelist[$this->headersSGQA[$iVarid]]['format'] < $iStringlength)
|
||||
$aStatatypelist[$this->headersSGQA[$iVarid]]['format'] = $iStringlength;
|
||||
|
||||
}
|
||||
//write the recoded response back to the response array
|
||||
$this->customResponsemap[$iRespId][$iVarid]=$response;
|
||||
}
|
||||
}
|
||||
// create an array $typelist from $aDatatypes with content: variable=> data type and data format
|
||||
foreach ($aDatatypes as $variable => $responses)
|
||||
|
||||
// translate coding into STATA datatypes, format and length
|
||||
foreach ($aStatatypelist as $variable => $data)
|
||||
{
|
||||
if (in_array('string', $responses, true))
|
||||
switch ($data['type'])
|
||||
{
|
||||
$max = max($strlenarray[$variable]); // get maximum string length per string variable
|
||||
// cap str[length] at $maxStringLength
|
||||
$typelist[$variable]['type'] = 'str' . $max = $max > $this->maxStringLength ? $this->maxStringLength : $max;
|
||||
$typelist[$variable]['format'] = '%' . $max = $max > $this->maxStringLength ? $this->maxStringLength : $max . 's';
|
||||
case 7:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'str'. min($data['format'], $this->maxStringLength);
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%' . min($data['format'], $this->maxStringLength) . 's';
|
||||
break;
|
||||
case 6:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'double';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%tc';
|
||||
break;
|
||||
case 5:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'float';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%10.0g';
|
||||
break;
|
||||
case 4:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'long';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%10.0g';
|
||||
break;
|
||||
case 3:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'int';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%10.0g';
|
||||
break;
|
||||
case 2:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'byte';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%10.0g';
|
||||
break;
|
||||
case 1:
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = 'byte';
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = '%9.0g';
|
||||
break;
|
||||
}
|
||||
elseif (in_array('double', $responses, true)) // only used for dates/times (milliseconds passed since 1960)
|
||||
{
|
||||
$typelist[$variable]['type'] = 'double';
|
||||
$typelist[$variable]['format'] = '%tc';
|
||||
}
|
||||
elseif (in_array('float', $responses, true))
|
||||
{
|
||||
$typelist[$variable]['type'] = 'float';
|
||||
$typelist[$variable]['format'] = '%10.0g';
|
||||
}
|
||||
elseif (in_array('long', $responses, true))
|
||||
{
|
||||
$typelist[$variable]['type'] = 'long';
|
||||
$typelist[$variable]['format'] = '%10.0g';
|
||||
}
|
||||
elseif (in_array('int', $responses, true))
|
||||
{
|
||||
$typelist[$variable]['type'] = 'int';
|
||||
$typelist[$variable]['format'] = '%10.0g';
|
||||
}
|
||||
elseif (in_array('byte', $responses, true))
|
||||
{
|
||||
$typelist[$variable]['type'] = 'byte';
|
||||
$typelist[$variable]['format'] = '%10.0g';
|
||||
}
|
||||
elseif (in_array('emptystr', $responses, true))
|
||||
{
|
||||
$typelist[$variable]['type'] = 'byte'; //variables that only contain '' as responses will be a byte...
|
||||
$typelist[$variable]['format'] = '%9.0g';
|
||||
}
|
||||
$this->customFieldmap['questions'][$variable]['statatype'] = $typelist[$variable]['type'];
|
||||
$this->customFieldmap['questions'][$variable]['stataformat'] = $typelist[$variable]['format'];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,10 +233,10 @@
|
|||
{
|
||||
$out .= CHtml::label($metaData['label'], $id, $metaData['labelOptions']);
|
||||
}
|
||||
$out .= CHtml::textField($id, $value, array(
|
||||
$out .= CHtml::numberField($id, $value, array(
|
||||
'id' => $id,
|
||||
'form' => $form,
|
||||
'pattern' => '\d+(\.\d+)?'
|
||||
'data-type'=>'float',
|
||||
));
|
||||
|
||||
return $out;
|
||||
|
@ -266,6 +266,17 @@
|
|||
);
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function renderInfo($name, array $metaData, $form = null)
|
||||
{
|
||||
$out = '';
|
||||
$id = $name;
|
||||
$value = isset($metaData['content']) ? $metaData['content'] : '';
|
||||
if (is_array($value)) { throw new CException('wrong type' . $name); }
|
||||
$out .= $value;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function renderInt($name, array $metaData, $form = null)
|
||||
{
|
||||
|
@ -277,11 +288,12 @@
|
|||
{
|
||||
$out .= CHtml::label($metaData['label'], $id, $metaData['labelOptions']);
|
||||
}
|
||||
$out .= CHtml::textField($id, $value, array(
|
||||
$step=isset($metaData['step'])?$metaData['step']:1;
|
||||
$out .= CHtml::numberField($id, $value, array(
|
||||
'id' => $id,
|
||||
'form' => $form,
|
||||
'data-type' => 'int',
|
||||
'pattern' => '\d+'
|
||||
'step' => 1,
|
||||
));
|
||||
|
||||
return $out;
|
||||
|
@ -313,6 +325,21 @@
|
|||
{
|
||||
return CHtml::image($metaData['path']);
|
||||
}
|
||||
|
||||
public function renderRadio($name, array $metaData, $form = null)
|
||||
{
|
||||
$out = '';
|
||||
$id = $name;
|
||||
$value = isset($metaData['current']) ? $metaData['current'] : (isset($metaData['default']) ? $metaData['default'] : null);
|
||||
if (isset($metaData['label']))
|
||||
{
|
||||
$out .= CHtml::label($metaData['label'], $id);
|
||||
}
|
||||
|
||||
$out .= CHtml::radioButtonList($name, $value, $metaData['options']);
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function renderRelevance($name, array $metaData, $form = null)
|
||||
{
|
||||
$out = '';
|
||||
|
@ -405,6 +432,24 @@
|
|||
return $out;
|
||||
}
|
||||
|
||||
public function renderLink($name, array $metaData, $form = null)
|
||||
{
|
||||
$out = '';
|
||||
$id = $name;
|
||||
if (isset($metaData['label']))
|
||||
{
|
||||
$out .= CHtml::label($metaData['label'], $id);
|
||||
}
|
||||
|
||||
$metaData['class'][] = 'btn';
|
||||
$out .= CHtml::link($metaData['label'], $metaData['link'], array(
|
||||
'id' => $id,
|
||||
'style' => $metaData['style'],
|
||||
'class' => implode(' ', $metaData['class'])
|
||||
));
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function renderList($name, array $metaData, $form = null)
|
||||
{
|
||||
$id = $name;
|
||||
|
@ -452,4 +497,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -8,8 +8,7 @@ div.row {
|
|||
}
|
||||
|
||||
.settingswidget input[type^='button'], .settingswidget label{
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
line-height: normal;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
|
@ -69,6 +68,7 @@ div.row {
|
|||
padding-right: 10px;
|
||||
width: 40%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
.settingswidget .setting > label:after{
|
||||
content: ':';
|
||||
|
|
|
@ -15,154 +15,154 @@
|
|||
class SurveyRuntimeHelper {
|
||||
|
||||
|
||||
protected function createFullQuestionIndex($LEMsessid, $surveyMode)
|
||||
{
|
||||
if ($surveyMode == 'group')
|
||||
{
|
||||
$this->createFullQuestionIndexByGroup($LEMsessid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->createFullQuestionIndexByQuestion($LEMsessid);
|
||||
}
|
||||
|
||||
}
|
||||
protected function createFullQuestionIndex($LEMsessid, $surveyMode)
|
||||
{
|
||||
if ($surveyMode == 'group')
|
||||
{
|
||||
$this->createFullQuestionIndexByGroup($LEMsessid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->createFullQuestionIndexByQuestion($LEMsessid);
|
||||
}
|
||||
|
||||
protected function createFullQuestionIndexByGroup($LEMsessid)
|
||||
{
|
||||
echo "\n\n<!-- PRESENT THE INDEX -->\n";
|
||||
echo CHtml::openTag('div', array('id' => 'index'));
|
||||
echo CHtml::openTag('div', array('class' => 'container'));
|
||||
echo CHtml::tag('h2', array(), gT("Question index"));
|
||||
echo CHtml::openTag('ol');
|
||||
foreach ($_SESSION[$LEMsessid]['grouplist'] as $key => $group)
|
||||
{
|
||||
// echo '<script>';
|
||||
// echo 'var session = '. json_encode(LimeExpressionManager::singleton()->_ValidateGroup($key)) . ';';
|
||||
// echo 'console.log(session);';
|
||||
// echo '</script>';
|
||||
// Better to use tracevar /
|
||||
if (LimeExpressionManager::GroupIsRelevant($group['gid']))
|
||||
{
|
||||
$group['step'] = $key + 1;
|
||||
$stepInfo = LimeExpressionManager::singleton()->_ValidateGroup($key);
|
||||
$classes = implode(' ', array(
|
||||
'row',
|
||||
$stepInfo['anyUnanswered'] ? 'missing' : '',
|
||||
$_SESSION[$LEMsessid]['step'] == $group['step'] ? 'current' : ''
|
||||
}
|
||||
|
||||
));
|
||||
$sButtonSubmit=CHtml::htmlButton(gT('Go to this group'),array('type'=>'submit','value'=>$group['step'],'name'=>'move','class'=>'jshide'));
|
||||
echo CHtml::tag('li', array(
|
||||
'data-gid' => $group['gid'],
|
||||
'title' => $group['description'],
|
||||
'class' => $classes,
|
||||
), $group['group_name'].$sButtonSubmit);
|
||||
}
|
||||
}
|
||||
echo CHtml::closeTag('ol');
|
||||
echo CHtml::closeTag('div');
|
||||
echo CHtml::closeTag('div');
|
||||
protected function createFullQuestionIndexByGroup($LEMsessid)
|
||||
{
|
||||
echo "\n\n<!-- PRESENT THE INDEX -->\n";
|
||||
echo CHtml::openTag('div', array('id' => 'index'));
|
||||
echo CHtml::openTag('div', array('class' => 'container'));
|
||||
echo CHtml::tag('h2', array(), gT("Question index"));
|
||||
echo CHtml::openTag('ol');
|
||||
foreach ($_SESSION[$LEMsessid]['grouplist'] as $key => $group)
|
||||
{
|
||||
// echo '<script>';
|
||||
// echo 'var session = '. json_encode(LimeExpressionManager::singleton()->_ValidateGroup($key)) . ';';
|
||||
// echo 'console.log(session);';
|
||||
// echo '</script>';
|
||||
// Better to use tracevar /
|
||||
if (LimeExpressionManager::GroupIsRelevant($group['gid']))
|
||||
{
|
||||
$group['step'] = $key + 1;
|
||||
$stepInfo = LimeExpressionManager::singleton()->_ValidateGroup($key);
|
||||
$classes = implode(' ', array(
|
||||
'row',
|
||||
$stepInfo['anyUnanswered'] ? 'missing' : '',
|
||||
$_SESSION[$LEMsessid]['step'] == $group['step'] ? 'current' : ''
|
||||
|
||||
));
|
||||
$sButtonSubmit=CHtml::htmlButton(gT('Go to this group'),array('type'=>'submit','value'=>$group['step'],'name'=>'move','class'=>'jshide'));
|
||||
echo CHtml::tag('li', array(
|
||||
'data-gid' => $group['gid'],
|
||||
'title' => $group['description'],
|
||||
'class' => $classes,
|
||||
), $group['group_name'].$sButtonSubmit);
|
||||
}
|
||||
}
|
||||
echo CHtml::closeTag('ol');
|
||||
echo CHtml::closeTag('div');
|
||||
echo CHtml::closeTag('div');
|
||||
|
||||
App()->getClientScript()->registerScript('manageIndex',"manageIndex()\n",CClientScript::POS_END);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createFullQuestionIndexByQuestion($LEMsessid)
|
||||
{
|
||||
echo CHtml::openTag('div', array('id' => 'index'));
|
||||
echo CHtml::openTag('div', array('class' => 'container'));
|
||||
echo CHtml::tag('h2', array(), gT("Question index"));
|
||||
echo 'Question by question not yet supported, use incremental index.';
|
||||
echo CHtml::closeTag('div');
|
||||
echo CHtml::closeTag('div');
|
||||
protected function createFullQuestionIndexByQuestion($LEMsessid)
|
||||
{
|
||||
echo CHtml::openTag('div', array('id' => 'index'));
|
||||
echo CHtml::openTag('div', array('class' => 'container'));
|
||||
echo CHtml::tag('h2', array(), gT("Question index"));
|
||||
echo 'Question by question not yet supported, use incremental index.';
|
||||
echo CHtml::closeTag('div');
|
||||
echo CHtml::closeTag('div');
|
||||
|
||||
App()->getClientScript()->registerScript('manageIndex',"manageIndex()\n",CClientScript::POS_END);
|
||||
}
|
||||
|
||||
protected function createIncrementalQuestionIndex($LEMsessid, $surveyMode)
|
||||
{
|
||||
echo "\n\n<!-- PRESENT THE INDEX -->\n";
|
||||
}
|
||||
|
||||
echo '<div id="index"><div class="container"><h2>' . gT("Question index") . '</h2>';
|
||||
protected function createIncrementalQuestionIndex($LEMsessid, $surveyMode)
|
||||
{
|
||||
echo "\n\n<!-- PRESENT THE INDEX -->\n";
|
||||
|
||||
$stepIndex = LimeExpressionManager::GetStepIndexInfo();
|
||||
$lastGseq=-1;
|
||||
$gseq = -1;
|
||||
$grel = true;
|
||||
for($v = 0, $n = 0; $n != $_SESSION[$LEMsessid]['maxstep']; ++$n)
|
||||
{
|
||||
if (!isset($stepIndex[$n])) {
|
||||
continue; // this is an invalid group - skip it
|
||||
}
|
||||
$stepInfo = $stepIndex[$n];
|
||||
echo '<div id="index"><div class="container"><h2>' . gT("Question index") . '</h2>';
|
||||
|
||||
if ($surveyMode == 'question')
|
||||
{
|
||||
if ($lastGseq != $stepInfo['gseq']) {
|
||||
// show the group label
|
||||
++$gseq;
|
||||
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
|
||||
$grel = !LimeExpressionManager::GroupIsIrrelevantOrHidden($gseq);
|
||||
if ($grel)
|
||||
{
|
||||
$gtitle = LimeExpressionManager::ProcessString($g['group_name']);
|
||||
echo '<h3>' . flattenText($gtitle) . "</h3>";
|
||||
}
|
||||
$lastGseq = $stepInfo['gseq'];
|
||||
}
|
||||
if (!$grel || !$stepInfo['show'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$q = $_SESSION[$LEMsessid]['fieldarray'][$n];
|
||||
}
|
||||
else
|
||||
{
|
||||
++$gseq;
|
||||
if (!$stepInfo['show'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
|
||||
}
|
||||
$stepIndex = LimeExpressionManager::GetStepIndexInfo();
|
||||
$lastGseq=-1;
|
||||
$gseq = -1;
|
||||
$grel = true;
|
||||
for($v = 0, $n = 0; $n != $_SESSION[$LEMsessid]['maxstep']; ++$n)
|
||||
{
|
||||
if (!isset($stepIndex[$n])) {
|
||||
continue; // this is an invalid group - skip it
|
||||
}
|
||||
$stepInfo = $stepIndex[$n];
|
||||
|
||||
if ($surveyMode == 'group')
|
||||
{
|
||||
$indexlabel = LimeExpressionManager::ProcessString($g['group_name']);
|
||||
$sButtonText=gT('Go to this group');
|
||||
}
|
||||
else
|
||||
{
|
||||
$indexlabel = LimeExpressionManager::ProcessString($q[3]);
|
||||
$sButtonText=gT('Go to this question');
|
||||
}
|
||||
if ($surveyMode == 'question')
|
||||
{
|
||||
if ($lastGseq != $stepInfo['gseq']) {
|
||||
// show the group label
|
||||
++$gseq;
|
||||
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
|
||||
$grel = !LimeExpressionManager::GroupIsIrrelevantOrHidden($gseq);
|
||||
if ($grel)
|
||||
{
|
||||
$gtitle = LimeExpressionManager::ProcessString($g['group_name']);
|
||||
echo '<h3>' . flattenText($gtitle) . "</h3>";
|
||||
}
|
||||
$lastGseq = $stepInfo['gseq'];
|
||||
}
|
||||
if (!$grel || !$stepInfo['show'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$q = $_SESSION[$LEMsessid]['fieldarray'][$n];
|
||||
}
|
||||
else
|
||||
{
|
||||
++$gseq;
|
||||
if (!$stepInfo['show'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
|
||||
}
|
||||
|
||||
$sText = (($surveyMode == 'group') ? flattenText($indexlabel) : flattenText($indexlabel));
|
||||
$bGAnsw = !$stepInfo['anyUnanswered'];
|
||||
if ($surveyMode == 'group')
|
||||
{
|
||||
$indexlabel = LimeExpressionManager::ProcessString($g['group_name']);
|
||||
$sButtonText=gT('Go to this group');
|
||||
}
|
||||
else
|
||||
{
|
||||
$indexlabel = LimeExpressionManager::ProcessString($q[3]);
|
||||
$sButtonText=gT('Go to this question');
|
||||
}
|
||||
|
||||
++$v;
|
||||
$sText = (($surveyMode == 'group') ? flattenText($indexlabel) : flattenText($indexlabel));
|
||||
$bGAnsw = !$stepInfo['anyUnanswered'];
|
||||
|
||||
$class = ($n == $_SESSION[$LEMsessid]['step'] - 1 ? 'current' : ($bGAnsw ? 'answer' : 'missing'));
|
||||
if ($v % 2)
|
||||
$class .= " odd";
|
||||
++$v;
|
||||
|
||||
$s = $n + 1;
|
||||
echo "<div class=\"row $class\">";
|
||||
echo "<span class=\"hdr\">$v</span>";
|
||||
echo "<span title=\"$sText\">$sText</span>";
|
||||
$class = ($n == $_SESSION[$LEMsessid]['step'] - 1 ? 'current' : ($bGAnsw ? 'answer' : 'missing'));
|
||||
if ($v % 2)
|
||||
$class .= " odd";
|
||||
|
||||
$s = $n + 1;
|
||||
echo "<div class=\"row $class\">";
|
||||
echo "<span class=\"hdr\">$v</span>";
|
||||
echo "<span title=\"$sText\">$sText</span>";
|
||||
echo CHtml::htmlButton($sButtonText,array('type'=>'submit','value'=>$s,'name'=>'move','class'=>'jshide'));
|
||||
echo "</div>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
if ($_SESSION[$LEMsessid]['maxstep'] == $_SESSION[$LEMsessid]['totalsteps'])
|
||||
{
|
||||
if ($_SESSION[$LEMsessid]['maxstep'] == $_SESSION[$LEMsessid]['totalsteps'])
|
||||
{
|
||||
echo CHtml::htmlButton(gT('Submit'),array('type'=>'submit','value'=>'movesubmit','name'=>'move','class'=>'submit button'));
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div></div>';
|
||||
echo '</div></div>';
|
||||
App()->getClientScript()->registerScript('manageIndex',"manageIndex()\n",CClientScript::POS_END);
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Main function
|
||||
*
|
||||
|
@ -172,25 +172,18 @@ class SurveyRuntimeHelper {
|
|||
function run($surveyid,$args) {
|
||||
global $errormsg;
|
||||
extract($args);
|
||||
|
||||
if (!$thissurvey) {
|
||||
$thissurvey = getSurveyInfo($surveyid);
|
||||
}
|
||||
$LEMsessid = 'survey_' . $surveyid;
|
||||
if (isset($_SESSION[$LEMsessid]['s_lang']))
|
||||
{
|
||||
$this->setJavascriptVar($surveyid, $_SESSION[$LEMsessid]['s_lang']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setJavascriptVar($surveyid, $thissurvey['language']);
|
||||
}
|
||||
$this->setJavascriptVar($surveyid, isset($clang->langcode) ? $clang->langcode : $thissurvey['language']);
|
||||
|
||||
$sTemplatePath=getTemplatePath(Yii::app()->getConfig("defaulttemplate")).DIRECTORY_SEPARATOR;
|
||||
if (isset ($_SESSION['survey_'.$surveyid]['templatepath']))
|
||||
{
|
||||
$sTemplatePath=$_SESSION['survey_'.$surveyid]['templatepath'];
|
||||
}
|
||||
// $LEMdebugLevel - customizable debugging for Lime Expression Manager
|
||||
// $LEMdebugLevel - customizable debugging for Lime Expression Manager
|
||||
$LEMdebugLevel = 0; // LEM_DEBUG_TIMING; // (LEM_DEBUG_TIMING + LEM_DEBUG_VALIDATION_SUMMARY + LEM_DEBUG_VALIDATION_DETAIL);
|
||||
$LEMskipReprocessing=false; // true if used GetLastMoveResult to avoid generation of unneeded extra JavaScript
|
||||
switch ($thissurvey['format'])
|
||||
|
@ -208,25 +201,24 @@ class SurveyRuntimeHelper {
|
|||
}
|
||||
$radix=getRadixPointData($thissurvey['surveyls_numberformat']);
|
||||
$radix = $radix['separator'];
|
||||
|
||||
$surveyOptions = array(
|
||||
'active' => ($thissurvey['active'] == 'Y'),
|
||||
'allowsave' => ($thissurvey['allowsave'] == 'Y'),
|
||||
'anonymized' => ($thissurvey['anonymized'] != 'N'),
|
||||
'assessments' => ($thissurvey['assessments'] == 'Y'),
|
||||
'datestamp' => ($thissurvey['datestamp'] == 'Y'),
|
||||
'deletenonvalues'=>Yii::app()->getConfig('deletenonvalues'),
|
||||
'hyperlinkSyntaxHighlighting' => (($LEMdebugLevel & LEM_DEBUG_VALIDATION_SUMMARY) == LEM_DEBUG_VALIDATION_SUMMARY), // TODO set this to true if in admin mode but not if running a survey
|
||||
'ipaddr' => ($thissurvey['ipaddr'] == 'Y'),
|
||||
'radix'=>$radix,
|
||||
'refurl' => (($thissurvey['refurl'] == "Y" && isset($_SESSION[$LEMsessid]['refurl'])) ? $_SESSION[$LEMsessid]['refurl'] : NULL),
|
||||
'savetimings' => ($thissurvey['savetimings'] == "Y"),
|
||||
'surveyls_dateformat' => (isset($thissurvey['surveyls_dateformat']) ? $thissurvey['surveyls_dateformat'] : 1),
|
||||
'startlanguage'=>(isset($clang->langcode) ? $clang->langcode : $thissurvey['language']),
|
||||
'target' => Yii::app()->getConfig('uploaddir').DIRECTORY_SEPARATOR.'surveys'.DIRECTORY_SEPARATOR.$thissurvey['sid'].DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR,
|
||||
'tempdir' => Yii::app()->getConfig('tempdir').DIRECTORY_SEPARATOR,
|
||||
'timeadjust' => (isset($timeadjust) ? $timeadjust : 0),
|
||||
'token' => (isset($clienttoken) ? $clienttoken : NULL),
|
||||
'active' => ($thissurvey['active'] == 'Y'),
|
||||
'allowsave' => ($thissurvey['allowsave'] == 'Y'),
|
||||
'anonymized' => ($thissurvey['anonymized'] != 'N'),
|
||||
'assessments' => ($thissurvey['assessments'] == 'Y'),
|
||||
'datestamp' => ($thissurvey['datestamp'] == 'Y'),
|
||||
'deletenonvalues'=>Yii::app()->getConfig('deletenonvalues'),
|
||||
'hyperlinkSyntaxHighlighting' => (($LEMdebugLevel & LEM_DEBUG_VALIDATION_SUMMARY) == LEM_DEBUG_VALIDATION_SUMMARY), // TODO set this to true if in admin mode but not if running a survey
|
||||
'ipaddr' => ($thissurvey['ipaddr'] == 'Y'),
|
||||
'radix'=>$radix,
|
||||
'refurl' => (($thissurvey['refurl'] == "Y" && isset($_SESSION[$LEMsessid]['refurl'])) ? $_SESSION[$LEMsessid]['refurl'] : NULL),
|
||||
'savetimings' => ($thissurvey['savetimings'] == "Y"),
|
||||
'surveyls_dateformat' => (isset($thissurvey['surveyls_dateformat']) ? $thissurvey['surveyls_dateformat'] : 1),
|
||||
'startlanguage'=>(isset($clang->langcode) ? $clang->langcode : $thissurvey['language']),
|
||||
'target' => Yii::app()->getConfig('uploaddir').DIRECTORY_SEPARATOR.'surveys'.DIRECTORY_SEPARATOR.$thissurvey['sid'].DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR,
|
||||
'tempdir' => Yii::app()->getConfig('tempdir').DIRECTORY_SEPARATOR,
|
||||
'timeadjust' => (isset($timeadjust) ? $timeadjust : 0),
|
||||
'token' => (isset($clienttoken) ? $clienttoken : NULL),
|
||||
);
|
||||
|
||||
//Security Checked: POST, GET, SESSION, REQUEST, returnGlobal, DB
|
||||
|
@ -264,11 +256,11 @@ class SurveyRuntimeHelper {
|
|||
$_SESSION[$LEMsessid]['step'] = 0;
|
||||
if ($surveyMode == 'survey')
|
||||
{
|
||||
$move = "movenext"; // to force a call to NavigateForwards()
|
||||
LimeExpressionManager::JumpTo(1, false, false, true);
|
||||
}
|
||||
elseif (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
|
||||
elseif (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
|
||||
{
|
||||
$move = "movenext";
|
||||
$moveResult=LimeExpressionManager::JumpTo(1, false, false, true);
|
||||
$_SESSION[$LEMsessid]['step']=1;
|
||||
}
|
||||
}
|
||||
|
@ -334,16 +326,16 @@ class SurveyRuntimeHelper {
|
|||
unset($_SESSION[$LEMsessid]['LEMtokenResume']);
|
||||
}
|
||||
else if (!$LEMskipReprocessing)
|
||||
{
|
||||
//Move current step ###########################################################################
|
||||
if (isset($move) && $move == 'moveprev' && ($thissurvey['allowprev'] == 'Y' || $thissurvey['questionindex'] > 0))
|
||||
{
|
||||
//Move current step ###########################################################################
|
||||
if (isset($move) && $move == 'moveprev' && ($thissurvey['allowprev'] == 'Y' || $thissurvey['questionindex'] > 0))
|
||||
$moveResult = LimeExpressionManager::NavigateBackwards();
|
||||
if ($moveResult['at_start'])
|
||||
{
|
||||
$moveResult = LimeExpressionManager::NavigateBackwards();
|
||||
if ($moveResult['at_start'])
|
||||
{
|
||||
$_SESSION[$LEMsessid]['step'] = 0;
|
||||
unset($moveResult); // so display welcome page again
|
||||
}
|
||||
$_SESSION[$LEMsessid]['step'] = 0;
|
||||
unset($moveResult); // so display welcome page again
|
||||
}
|
||||
}
|
||||
if (isset($move) && $move == "movenext")
|
||||
{
|
||||
|
@ -362,24 +354,24 @@ class SurveyRuntimeHelper {
|
|||
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['totalsteps'] + 1, false);
|
||||
}
|
||||
}
|
||||
if (isset($move) && (preg_match('/^changelang_/', $move) || $move=='changelang'))
|
||||
if (isset($move) && $move=='changelang')
|
||||
{
|
||||
// jump to current step using new language, processing POST values
|
||||
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'], false, true, false, true); // do process the POST data
|
||||
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'], false, true, true, true); // do process the POST data
|
||||
}
|
||||
if (isset($move) && isNumericInt($move) && $thissurvey['questionindex'] == 1)
|
||||
{
|
||||
$move = (int) $move;
|
||||
$move = (int) $move;
|
||||
if ($move > 0 && (($move <= $_SESSION[$LEMsessid]['step']) || (isset($_SESSION[$LEMsessid]['maxstep']) && $move <= $_SESSION[$LEMsessid]['maxstep'])))
|
||||
{
|
||||
$moveResult = LimeExpressionManager::JumpTo($move, false);
|
||||
}
|
||||
}
|
||||
elseif (isset($move) && isNumericInt($move) && $thissurvey['questionindex'] == 2)
|
||||
{
|
||||
$move = (int) $move;
|
||||
$moveResult = LimeExpressionManager::JumpTo($move, false, true, true);
|
||||
}
|
||||
elseif (isset($move) && isNumericInt($move) && $thissurvey['questionindex'] == 2)
|
||||
{
|
||||
$move = (int) $move;
|
||||
$moveResult = LimeExpressionManager::JumpTo($move, false, true, true);
|
||||
}
|
||||
if (!isset($moveResult) && !($surveyMode != 'survey' && $_SESSION[$LEMsessid]['step'] == 0))
|
||||
{
|
||||
// Just in case not set via any other means, but don't do this if it is the welcome page
|
||||
|
@ -387,9 +379,17 @@ class SurveyRuntimeHelper {
|
|||
$LEMskipReprocessing=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($moveResult) && isset($moveResult['seq']) )// Reload at first page (welcome after click previous fill an empty $moveResult array
|
||||
{
|
||||
// With complete index, we need to revalidate whole group bug #08806. It's actually the only mode where we JumpTo with force
|
||||
if($moveResult['finished'] == true && $thissurvey['questionindex']==2)// $thissurvey['questionindex']>=2
|
||||
{
|
||||
//LimeExpressionManager::JumpTo(-1, false, false, true);
|
||||
LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions);
|
||||
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['totalsteps']+1, false, false, false);// no preview, no save data and NO force
|
||||
if(!$moveResult['mandViolation'] && $moveResult['valid'] && empty($moveResult['invalidSQs']))
|
||||
$moveResult['finished'] = true;
|
||||
}
|
||||
if ($moveResult['finished'] == true)
|
||||
{
|
||||
$move = 'movesubmit';
|
||||
|
@ -418,31 +418,12 @@ class SurveyRuntimeHelper {
|
|||
Yii::app()->end(); // So we can still see debug messages
|
||||
}
|
||||
|
||||
//CHECK IF ALL MANDATORY QUESTIONS HAVE BEEN ANSWERED ############################################
|
||||
//First, see if we are moving backwards or doing a Save so far, and its OK not to check:
|
||||
if (
|
||||
(isset($move) && ($move == "moveprev" || (is_int($move) && $_SESSION[$LEMsessid]['prevstep'] == $_SESSION[$LEMsessid]['maxstep']) || $_SESSION[$LEMsessid]['prevstep'] == $_SESSION[$LEMsessid]['step'])) ||
|
||||
(isset($_POST['saveall']) && $_POST['saveall'] == $clang->gT("Save your responses so far")))
|
||||
{
|
||||
if (Yii::app()->getConfig('allowmandbackwards') == 1)
|
||||
{
|
||||
$backok = "Y";
|
||||
}
|
||||
else
|
||||
{
|
||||
$backok = "N";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$backok = "N"; // NA, since not moving backwards
|
||||
}
|
||||
// TODO FIXME
|
||||
if ($thissurvey['active'] == "Y") {
|
||||
Yii::import("application.libraries.Save");
|
||||
$cSave = new Save();
|
||||
}
|
||||
if ($thissurvey['active'] == "Y" && Yii::app()->request->getPost('saveall')) // Don't test if save is allowed
|
||||
if ($thissurvey['active'] == "Y" && Yii::app()->request->getPost('saveall')) // Don't test if save is allowed
|
||||
{
|
||||
$bTokenAnswerPersitance = $thissurvey['tokenanswerspersistence'] == 'Y' && isset($surveyid) && tableExists('tokens_'.$surveyid);
|
||||
// must do this here to process the POSTed values
|
||||
|
@ -454,7 +435,7 @@ class SurveyRuntimeHelper {
|
|||
else
|
||||
{
|
||||
// Intentional retest of all conditions to be true, to make sure we do have tokens and surveyid
|
||||
// Now update lastpage to $_SESSION[$LEMsessid]['step'] in SurveyDynamic, otherwise we land on
|
||||
// Now update lastpage to $_SESSION[$LEMsessid]['step'] in SurveyDynamic, otherwise we land on
|
||||
// the previous page when we return.
|
||||
$iResponseID = $_SESSION[$LEMsessid]['srid'];
|
||||
$oResponse = SurveyDynamic::model($surveyid)->findByPk($iResponseID);
|
||||
|
@ -487,7 +468,7 @@ class SurveyRuntimeHelper {
|
|||
if (isset($moveResult) && !$moveResult['finished'])
|
||||
{
|
||||
$unansweredSQList = $moveResult['unansweredSQs'];
|
||||
if (strlen($unansweredSQList) > 0 && $backok != "N")
|
||||
if (strlen($unansweredSQList) > 0)
|
||||
{
|
||||
$notanswered = explode('|', $unansweredSQList);
|
||||
}
|
||||
|
@ -498,7 +479,7 @@ class SurveyRuntimeHelper {
|
|||
|
||||
//CHECK INPUT
|
||||
$invalidSQList = $moveResult['invalidSQs'];
|
||||
if (strlen($invalidSQList) > 0 && $backok != "N")
|
||||
if (strlen($invalidSQList) > 0)
|
||||
{
|
||||
$notvalidated = explode('|', $invalidSQList);
|
||||
}
|
||||
|
@ -510,7 +491,7 @@ class SurveyRuntimeHelper {
|
|||
|
||||
// CHECK UPLOADED FILES
|
||||
// TMSW - Move this into LEM::NavigateForwards?
|
||||
$filenotvalidated = checkUploadedFileValidity($surveyid, $move, $backok);
|
||||
$filenotvalidated = checkUploadedFileValidity($surveyid, $move);
|
||||
|
||||
//SEE IF THIS GROUP SHOULD DISPLAY
|
||||
$show_empty_group = false;
|
||||
|
@ -532,12 +513,12 @@ class SurveyRuntimeHelper {
|
|||
}
|
||||
}
|
||||
resetTimers();
|
||||
|
||||
|
||||
//Before doing the "templatereplace()" function, check the $thissurvey['url']
|
||||
//field for limereplace stuff, and do transformations!
|
||||
$thissurvey['surveyls_url'] = passthruReplace($thissurvey['surveyls_url'], $thissurvey);
|
||||
$thissurvey['surveyls_url'] = templatereplace($thissurvey['surveyls_url'], array(), $redata, 'URLReplace', false, NULL, array(), true ); // to do INSERTANS substitutions
|
||||
|
||||
|
||||
//END PAGE - COMMIT CHANGES TO DATABASE
|
||||
if ($thissurvey['active'] != "Y") //If survey is not active, don't really commit
|
||||
{
|
||||
|
@ -581,10 +562,10 @@ class SurveyRuntimeHelper {
|
|||
{
|
||||
if ($thissurvey['usecookie'] == "Y" && $tokensexist != 1) //don't use cookies if tokens are being used
|
||||
{
|
||||
setcookie("LS_" . $surveyid . "_STATUS", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
|
||||
setcookie("LS_" . $surveyid . "_STATUS", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
|
||||
}
|
||||
|
||||
|
||||
|
||||
$content = '';
|
||||
$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata, 'SubmitStartpage', false, NULL, array(), true );
|
||||
|
||||
|
@ -625,7 +606,7 @@ class SurveyRuntimeHelper {
|
|||
}
|
||||
|
||||
|
||||
if (trim(strip_tags($thissurvey['surveyls_endtext'])) == '')
|
||||
if (trim(str_replace(array('<p>','</p>'),'',$thissurvey['surveyls_endtext'])) == '')
|
||||
{
|
||||
$completed = "<br /><span class='success'>" . $clang->gT("Thank you!") . "</span><br /><br />\n\n"
|
||||
. $clang->gT("Your survey responses have been recorded.") . "<br /><br />\n";
|
||||
|
@ -676,7 +657,7 @@ class SurveyRuntimeHelper {
|
|||
echo $content;
|
||||
}
|
||||
$redata['completed'] = $completed;
|
||||
|
||||
|
||||
// @todo Remove direct session access.
|
||||
$event = new PluginEvent('afterSurveyComplete');
|
||||
if (isset($_SESSION[$LEMsessid]['srid']))
|
||||
|
@ -695,7 +676,7 @@ class SurveyRuntimeHelper {
|
|||
|
||||
$redata['completed'] = implode("\n", $blocks) ."\n". $redata['completed'];
|
||||
$redata['thissurvey']['surveyls_url'] = $thissurvey['surveyls_url'];
|
||||
|
||||
|
||||
echo templatereplace(file_get_contents($sTemplatePath."completed.pstpl"), array('completed' => $completed), $redata, 'SubmitCompleted', false, NULL, array(), true );
|
||||
echo "\n";
|
||||
if ((($LEMdebugLevel & LEM_DEBUG_TIMING) == LEM_DEBUG_TIMING))
|
||||
|
@ -708,12 +689,12 @@ class SurveyRuntimeHelper {
|
|||
}
|
||||
echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"), array(), $redata, 'SubmitEndpage', false, NULL, array(), true );
|
||||
doFooter();
|
||||
|
||||
|
||||
// The session cannot be killed until the page is completely rendered
|
||||
if ($thissurvey['printanswers'] != 'Y')
|
||||
{
|
||||
killSurveySession($surveyid);
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -772,21 +753,21 @@ class SurveyRuntimeHelper {
|
|||
$groupdescription = $clang->gT("There are no more questions. Please press the <Submit> button to finish this survey.");
|
||||
}
|
||||
else if ($surveyMode != 'survey')
|
||||
{
|
||||
if ($previewquestion) {
|
||||
$_qid = sanitize_int($param['qid']);
|
||||
LimeExpressionManager::StartSurvey($surveyid, 'question', $surveyOptions, false, $LEMdebugLevel);
|
||||
$qSec = LimeExpressionManager::GetQuestionSeq($_qid);
|
||||
$moveResult = LimeExpressionManager::JumpTo($qSec+1,true,false,true);
|
||||
$stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']);
|
||||
} else {
|
||||
$stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']);
|
||||
}
|
||||
|
||||
$gid = $stepInfo['gid'];
|
||||
$groupname = $stepInfo['gname'];
|
||||
$groupdescription = $stepInfo['gtext'];
|
||||
{
|
||||
if ($previewquestion) {
|
||||
$_qid = sanitize_int($param['qid']);
|
||||
LimeExpressionManager::StartSurvey($surveyid, 'question', $surveyOptions, false, $LEMdebugLevel);
|
||||
$qSec = LimeExpressionManager::GetQuestionSeq($_qid);
|
||||
$moveResult = LimeExpressionManager::JumpTo($qSec+1,true,false,true);
|
||||
$stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']);
|
||||
} else {
|
||||
$stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']);
|
||||
}
|
||||
|
||||
$gid = $stepInfo['gid'];
|
||||
$groupname = $stepInfo['gname'];
|
||||
$groupdescription = $stepInfo['gtext'];
|
||||
}
|
||||
}
|
||||
if ($previewquestion)
|
||||
{
|
||||
|
@ -942,7 +923,7 @@ class SurveyRuntimeHelper {
|
|||
}
|
||||
Yii::app()->clientScript->registerScript("showpopup","showpopup=".(int)Yii::app()->getConfig('showpopups').";",CClientScript::POS_HEAD);
|
||||
//if(count($aPopup))
|
||||
Yii::app()->clientScript->registerScript('startPopup',"startPopups=".json_encode($aPopup).";",CClientScript::POS_HEAD);
|
||||
Yii::app()->clientScript->registerScript('startPopup',"startPopups=".json_encode($aPopup).";",CClientScript::POS_HEAD);
|
||||
//ALTER PAGE CLASS TO PROVIDE WHOLE-PAGE ALTERNATION
|
||||
if ($surveyMode != 'survey' && $_SESSION[$LEMsessid]['step'] != $_SESSION[$LEMsessid]['prevstep'] ||
|
||||
(isset($_SESSION[$LEMsessid]['stepno']) && $_SESSION[$LEMsessid]['stepno'] % 2))
|
||||
|
@ -1161,12 +1142,12 @@ class SurveyRuntimeHelper {
|
|||
|
||||
if ($surveyMode != 'survey' && $thissurvey['questionindex'] == 1)
|
||||
{
|
||||
$this->createIncrementalQuestionIndex($LEMsessid, $surveyMode);
|
||||
$this->createIncrementalQuestionIndex($LEMsessid, $surveyMode);
|
||||
}
|
||||
elseif ($surveyMode != 'survey' && $thissurvey['questionindex'] == 2)
|
||||
{
|
||||
$this->createFullQuestionIndex($LEMsessid, $surveyMode);
|
||||
}
|
||||
elseif ($surveyMode != 'survey' && $thissurvey['questionindex'] == 2)
|
||||
{
|
||||
$this->createFullQuestionIndex($LEMsessid, $surveyMode);
|
||||
}
|
||||
|
||||
echo "<input type='hidden' name='thisstep' value='{$_SESSION[$LEMsessid]['step']}' id='thisstep' />\n";
|
||||
echo "<input type='hidden' name='sid' value='$surveyid' id='sid' />\n";
|
||||
|
@ -1198,16 +1179,16 @@ class SurveyRuntimeHelper {
|
|||
|
||||
}
|
||||
/**
|
||||
* setJavascriptVar
|
||||
*
|
||||
*
|
||||
* @return @void
|
||||
* @param integer $iSurveyId : the survey id for the script
|
||||
* @param string $sLanguage : the actual language for the survey
|
||||
*/
|
||||
* setJavascriptVar
|
||||
*
|
||||
*
|
||||
* @return @void
|
||||
* @param integer $iSurveyId : the survey id for the script
|
||||
* @param string $sLanguage : the actual language for the survey
|
||||
*/
|
||||
public function setJavascriptVar($iSurveyId, $sLanguage)
|
||||
{
|
||||
$aSurveyinfo=getSurveyInfo($iSurveyId);
|
||||
$aSurveyinfo=getSurveyInfo($iSurveyId,$sLanguage);
|
||||
if(isset($aSurveyinfo['surveyls_numberformat']))
|
||||
{
|
||||
$aLSJavascriptVar=array();
|
||||
|
|
|
@ -18,51 +18,62 @@
|
|||
* @param int $fixnumbering
|
||||
* @todo can call this function (no $_GET, but getParam) AND do it with Yii
|
||||
*/
|
||||
function fixNumbering($fixnumbering, $iSurveyID)
|
||||
function fixNumbering($iQuestionID, $iSurveyID)
|
||||
{
|
||||
|
||||
Yii::app()->loadHelper("database");
|
||||
|
||||
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
|
||||
//Fix a question id - requires renumbering a question
|
||||
$oldqid = (int) $fixnumbering;
|
||||
$lastqid=Question::model()->getMaxId('qid', true); // Always refresh as we insert new qid's
|
||||
$newqid=$lastqid+1;
|
||||
$iQuestionID = (int) $iQuestionID;
|
||||
$iMaxQID=Question::model()->getMaxId('qid', true); // Always refresh as we insert new qid's
|
||||
$iNewQID=$iMaxQID+1;
|
||||
|
||||
// Not sure we can do this in MSSQL ?
|
||||
$query = "UPDATE {{questions}} SET qid=$newqid WHERE qid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{questions}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
// Update subquestions
|
||||
$query = "UPDATE {{questions}} SET parent_qid=$newqid WHERE parent_qid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{questions}} SET parent_qid=$iNewQID WHERE parent_qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Update conditions.. firstly conditions FOR this question
|
||||
$query = "UPDATE {{conditions}} SET qid=$newqid WHERE qid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{conditions}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Update default values
|
||||
$sQuery = "UPDATE {{defaultvalues}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
$sQuery = "UPDATE {{defaultvalues}} SET sqid=$iNewQID WHERE sqid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Update quotas
|
||||
$sQuery = "UPDATE {{quota_members}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Update url params
|
||||
$sQuery = "UPDATE {{survey_url_parameters}} SET targetqid=$iNewQID WHERE targetqid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
$sQuery = "UPDATE {{survey_url_parameters}} SET targetsqid=$iNewQID WHERE targetsqid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Now conditions based upon this question
|
||||
$query = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid=$oldqid";
|
||||
$result = dbExecuteAssoc($query);
|
||||
foreach ($result->readAll() as $row)
|
||||
{
|
||||
$switcher[]=array("cqid"=>$row['cqid'], "cfieldname"=>$row['cfieldname']);
|
||||
$sQuery = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid=$iQuestionID";
|
||||
$sResult=Yii::app()->db->createCommand($sQuery)->query();
|
||||
foreach ($sResult->readAll() as $row){
|
||||
$aSwitcher[]=array("cqid"=>$row['cqid'], "cfieldname"=>$row['cfieldname']);
|
||||
}
|
||||
if (isset($switcher))
|
||||
if (isset($aSwitcher))
|
||||
{
|
||||
foreach ($switcher as $switch)
|
||||
foreach ($aSwitcher as $aSwitch)
|
||||
{
|
||||
$query = "UPDATE {{conditions}}
|
||||
SET cqid=$newqid,
|
||||
cfieldname='".str_replace("X".$oldqid, "X".$newqid, $switch['cfieldname'])."'
|
||||
WHERE cqid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{conditions}}
|
||||
SET cqid=$iNewQID,
|
||||
cfieldname='".str_replace("X".$iQuestionID, "X".$iNewQID, $aSwitch['cfieldname'])."'
|
||||
WHERE cqid=$iQuestionID";
|
||||
$sResult = db_execute_assosc($sQuery);
|
||||
}
|
||||
}
|
||||
// TMSW Condition->Relevance: (1) Call LEM->ConvertConditionsToRelevance()when done. (2) Should relevance for old conditions be removed first?
|
||||
//Now question_attributes
|
||||
$query = "UPDATE {{question_attributes}} SET qid=$newqid WHERE qid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{question_attributes}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
//Now answers
|
||||
$query = "UPDATE {{answers}} SET qid=$newqid WHERE qid=$oldqid";
|
||||
$result = db_execute_assosc($query);
|
||||
$sQuery = "UPDATE {{answers}} SET qid=$iNewQID WHERE qid=$iQuestionID";
|
||||
Yii::app()->db->createCommand($sQuery)->query();
|
||||
|
||||
LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
|
||||
}
|
||||
|
@ -102,11 +113,11 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
|
|||
|
||||
//CHECK TO MAKE SURE ALL QUESTION TYPES THAT REQUIRE ANSWERS HAVE ACTUALLY GOT ANSWERS
|
||||
//THESE QUESTION TYPES ARE:
|
||||
// # "L" -> LIST
|
||||
// # "L" -> LIST
|
||||
// # "O" -> LIST WITH COMMENT
|
||||
// # "M" -> Multiple choice
|
||||
// # "P" -> Multiple choice with comments
|
||||
// # "A", "B", "C", "E", "F", "H", "^" -> Various Array Types
|
||||
// # "P" -> Multiple choice with comments
|
||||
// # "A", "B", "C", "E", "F", "H", "^" -> Various Array Types
|
||||
// # "R" -> RANKING
|
||||
// # "U" -> FILE CSV MORE
|
||||
// # "I" -> LANGUAGE SWITCH
|
||||
|
@ -214,25 +225,13 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
|
|||
}
|
||||
|
||||
//CHECK THAT ALL THE CREATED FIELDS WILL BE UNIQUE
|
||||
$fieldmap = createFieldMap($iSurveyID,'full',false,false,getBaseLanguageFromSurveyID($iSurveyID));
|
||||
if (isset($fieldmap))
|
||||
$fieldmap = createFieldMap($iSurveyID,'full',true,false,getBaseLanguageFromSurveyID($iSurveyID),$aDuplicateQIDs);
|
||||
if (count($aDuplicateQIDs))
|
||||
{
|
||||
foreach($fieldmap as $fielddata)
|
||||
foreach ($aDuplicateQIDs as $iQID=>$aDuplicate)
|
||||
{
|
||||
$fieldlist[]=$fielddata['fieldname'];
|
||||
}
|
||||
$fieldlist=array_reverse($fieldlist); //let's always change the later duplicate, not the earlier one
|
||||
}
|
||||
|
||||
$checkKeysUniqueComparison = create_function('$value','if ($value > 1) return true;');
|
||||
@$duplicates = array_keys (array_filter (array_count_values($fieldlist), $checkKeysUniqueComparison));
|
||||
if (isset($duplicates))
|
||||
{
|
||||
foreach ($duplicates as $dup)
|
||||
{
|
||||
$badquestion=arraySearchByKey($dup, $fieldmap, "fieldname", 1);
|
||||
$fix = "[<a href='$scriptname?action=activate&sid=$iSurveyID&fixnumbering=".$badquestion['qid']."'>Click Here to Fix</a>]";
|
||||
$failedcheck[]=array($badquestion['qid'], $badquestion['question'], ": Bad duplicate fieldname $fix", $badquestion['gid']);
|
||||
$sFixLink = "[<a href='".Yii::app()->getController()->createUrl("/admin/survey/sa/activate/surveyid/{$iSurveyID}/fixnumbering/{$iQID}")."'>Click here to fix</a>]";
|
||||
$failedcheck[]=array($iQID, $aDuplicate['question'], ": Bad duplicate fieldname {$sFixLink}", $aDuplicate['gid']);
|
||||
}
|
||||
}
|
||||
if(isset($failedcheck))
|
||||
|
@ -261,7 +260,7 @@ function activateSurvey($iSurveyID, $simulate = false)
|
|||
|
||||
//Get list of questions for the base language
|
||||
$fieldmap = createFieldMap($iSurveyID,'full',true,false,getBaseLanguageFromSurveyID($iSurveyID));
|
||||
|
||||
|
||||
$createsurvey = array();
|
||||
|
||||
foreach ($fieldmap as $j=>$arow) //With each question, create the appropriate field(s)
|
||||
|
@ -289,7 +288,12 @@ function activateSurvey($iSurveyID, $simulate = false)
|
|||
$createsurvey[$arow['fieldname']] = "decimal (30,10)";
|
||||
break;
|
||||
case "S": //SHORT TEXT
|
||||
|
||||
if (Yii::app()->db->driverName == 'mysql' || Yii::app()->db->driverName == 'mysqli') {$createsurvey[$arow['fieldname']] = "text";}
|
||||
elseif (Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='sqlsrv' || Yii::app()->db->driverName=='dblib')
|
||||
{
|
||||
$createsurvey[$arow['fieldname']] = "nvarchar(255)";
|
||||
}
|
||||
else {$createsurvey[$arow['fieldname']] = "string";}
|
||||
break;
|
||||
case "L": //LIST (RADIO)
|
||||
|
@ -363,14 +367,19 @@ function activateSurvey($iSurveyID, $simulate = false)
|
|||
}
|
||||
$arrSim[] = array($type);
|
||||
}
|
||||
|
||||
if (Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='sqlsrv' || Yii::app()->db->driverName=='dblib')
|
||||
{
|
||||
if ($createsurvey[$arow['fieldname']] == "text")
|
||||
{
|
||||
$createsurvey[$arow['fieldname']] = "ntext";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($simulate){
|
||||
return array('dbengine'=>$CI->db->databasetabletype, 'dbtype'=>Yii::app()->db->driverName, 'fields'=>$arrSim);
|
||||
}
|
||||
|
||||
|
||||
// If last question is of type MCABCEFHP^QKJR let's get rid of the ending coma in createsurvey
|
||||
//$createsurvey = rtrim($createsurvey, ",\n")."\n"; // Does nothing if not ending with a comma
|
||||
|
||||
|
@ -389,36 +398,32 @@ function activateSurvey($iSurveyID, $simulate = false)
|
|||
{
|
||||
if (isset($createsurvey['token'])) Yii::app()->db->createCommand()->createIndex("idx_survey_token_{$iSurveyID}_".rand(1,50000),$tabname,'token');
|
||||
}
|
||||
catch (CDbException $e)
|
||||
catch (CDbException $e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
$anquery = "SELECT autonumber_start FROM {{surveys}} WHERE sid={$iSurveyID}";
|
||||
if ($anresult=Yii::app()->db->createCommand($anquery)->query()->readAll())
|
||||
$iAutoNumberStart=Yii::app()->db->createCommand($anquery)->queryScalar();
|
||||
//if there is an autonumber_start field, start auto numbering here
|
||||
if ($iAutoNumberStart!==false && $iAutoNumberStart>0)
|
||||
{
|
||||
//if there is an autonumber_start field, start auto numbering here
|
||||
foreach($anresult as $row)
|
||||
if (Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='sqlsrv' || Yii::app()->db->driverName=='dblib') {
|
||||
mssql_drop_primary_index('survey_'.$iSurveyID);
|
||||
mssql_drop_constraint('id','survey_'.$iSurveyID);
|
||||
$sQuery = "alter table {{survey_{$iSurveyID}}} drop column id ";
|
||||
Yii::app()->db->createCommand($sQuery)->execute();
|
||||
$sQuery = "alter table {{survey_{$iSurveyID}}} add [id] int identity({$iAutoNumberStart},1)";
|
||||
Yii::app()->db->createCommand($sQuery)->execute();
|
||||
}
|
||||
elseif (Yii::app()->db->driverName=='pgsql')
|
||||
{
|
||||
if ($row['autonumber_start'] > 0)
|
||||
{
|
||||
if (Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='sqlsrv' || Yii::app()->db->driverName=='dblib') {
|
||||
mssql_drop_primary_index('survey_'.$iSurveyID);
|
||||
mssql_drop_constraint('id','survey_'.$iSurveyID);
|
||||
$autonumberquery = "alter table {{survey_{$iSurveyID}}} drop column id ";
|
||||
Yii::app()->db->createCommand($autonumberquery)->execute();
|
||||
$autonumberquery = "alter table {{survey_{$iSurveyID}}} add [id] int identity({$row['autonumber_start']},1)";
|
||||
Yii::app()->db->createCommand($autonumberquery)->execute();
|
||||
}
|
||||
elseif (Yii::app()->db->driverName=='pgsql')
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$autonumberquery = "ALTER TABLE {{survey_{$iSurveyID}}} AUTO_INCREMENT = ".$row['autonumber_start'];
|
||||
$result = @Yii::app()->db->createCommand($autonumberquery)->execute();
|
||||
}
|
||||
}
|
||||
$sQuery = "SELECT setval(pg_get_serial_sequence('{{survey_{$iSurveyID}}}', 'id'),{$iAutoNumberStart},false);";
|
||||
$result = @Yii::app()->db->createCommand($sQuery)->execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sQuery = "ALTER TABLE {{survey_{$iSurveyID}}} AUTO_INCREMENT = {$iAutoNumberStart}";
|
||||
$result = @Yii::app()->db->createCommand($sQuery)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{
|
||||
echo $sOutput;
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($sFileName))
|
||||
{
|
||||
$oFile=fopen($sFileName,'w');
|
||||
|
@ -45,7 +45,7 @@
|
|||
{
|
||||
fclose($oFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function _outputDBDescription($sDbName, $bAllowExportAllDb)
|
||||
|
@ -57,26 +57,31 @@
|
|||
}
|
||||
$sOutput.= '-- Date of Dump: ' . dateShift(date('d-M-Y'), 'd-M-Y', Yii::app()->getConfig('timeadjust')) . "\n";
|
||||
$sOutput.= '--' . "\n";
|
||||
return $sOutput;
|
||||
return $sOutput;
|
||||
}
|
||||
|
||||
function _outputDBData($bAllowExportAllDb, $bEchoOutput, $sFileName, $oFile)
|
||||
{
|
||||
$aTables = Yii::app()->db->getSchema()->getTables();
|
||||
foreach ($aTables as $sTableName => $oTableData)
|
||||
if ($bAllowExportAllDb){
|
||||
$aTables = Yii::app()->db->getSchema()->getTableNames();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bAllowExportAllDb && Yii::app()->db->tablePrefix == substr($sTableName, 0, strlen(Yii::app()->db->tablePrefix))) {
|
||||
$sOutput=_outputTableDescription($sTableName);
|
||||
if ($bEchoOutput)
|
||||
{
|
||||
echo $sOutput;
|
||||
}
|
||||
if (!is_null($sFileName))
|
||||
{
|
||||
fwrite($oFile,$sOutput);
|
||||
}
|
||||
_outputTableData($sTableName, $oTableData, $bEchoOutput, $sFileName, $oFile);
|
||||
$aTables = Yii::app()->db->createCommand(dbSelectTablesLike(addcslashes(Yii::app()->db->tablePrefix,'_')."%"))->queryColumn();
|
||||
}
|
||||
foreach ($aTables as $sTableName)
|
||||
{
|
||||
$oTableData=Yii::app()->db->getSchema()->getTable($sTableName);
|
||||
$sOutput=_outputTableDescription($sTableName);
|
||||
if ($bEchoOutput)
|
||||
{
|
||||
echo $sOutput;
|
||||
}
|
||||
if (!is_null($sFileName))
|
||||
{
|
||||
fwrite($oFile,$sOutput);
|
||||
}
|
||||
_outputTableData($sTableName, $oTableData, $bEchoOutput, $sFileName, $oFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +98,7 @@
|
|||
|
||||
$aCreateTable = Yii::app()->db->createCommand('SHOW CREATE TABLE '.Yii::app()->db->quoteTableName($sTableName))->queryRow();
|
||||
$sOutput.= $aCreateTable['Create Table'].';'."\n\n";
|
||||
return $sOutput;
|
||||
return $sOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +120,7 @@
|
|||
$aRecords = Yii::app()->db->createCommand()
|
||||
->select()
|
||||
->from($sTableName)
|
||||
->limit(intval($iMaxNbRecords), ($i != 0 ? ($i * $iMaxNbRecords) + 1 : null))
|
||||
->limit(intval($iMaxNbRecords), ($i != 0 ? ($i * $iMaxNbRecords) : null))
|
||||
->query()->readAll();
|
||||
|
||||
$sOutput.=_outputRecords($sTableName, $aFieldNames, $aRecords);
|
||||
|
@ -126,13 +131,13 @@
|
|||
if (!is_null($sFileName))
|
||||
{
|
||||
fwrite($oFile,$sOutput);
|
||||
}
|
||||
}
|
||||
$sOutput='';
|
||||
|
||||
|
||||
|
||||
}
|
||||
$sOutput.= "\n";
|
||||
|
||||
|
||||
}
|
||||
if ($bEchoOutput)
|
||||
{
|
||||
|
@ -141,11 +146,13 @@
|
|||
if (!is_null($sFileName))
|
||||
{
|
||||
fwrite($oFile,$sOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _outputRecords($sTableName, $aFieldNames, $aRecords)
|
||||
{
|
||||
$sLastFieldName=end($aFieldNames);
|
||||
$aLastRecord=end($aRecords);
|
||||
$i=0;
|
||||
$sOutput='';
|
||||
foreach ($aRecords as $aRecord)
|
||||
|
@ -164,21 +171,19 @@
|
|||
{
|
||||
|
||||
if (isset($aRecord[$sFieldName]) && !is_null($aRecord[$sFieldName])) {
|
||||
$sValue= addcslashes($aRecord[$sFieldName],"'");
|
||||
$sValue = preg_replace("#\n#", "\\n", $sValue);
|
||||
$sOutput.= "'" . $sValue . "'";
|
||||
$sOutput.=Yii::app()->db->quoteValue($aRecord[$sFieldName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sOutput.= 'NULL';
|
||||
}
|
||||
|
||||
if (end($aFieldNames) != $sFieldName) {
|
||||
if ($sFieldName != $sLastFieldName) {
|
||||
$sOutput.= ', ';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
if ($i==200 || (end($aRecords) == $aRecord))
|
||||
if ($i==200 || ($aLastRecord == $aRecord))
|
||||
{
|
||||
$sOutput.= ');' . "\n";
|
||||
$i=0;
|
||||
|
@ -218,5 +223,4 @@
|
|||
$sDbName = $aMatches[1];
|
||||
|
||||
return $sDbName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,19 +37,7 @@
|
|||
} elseif ($oOptions->output == 'file') {
|
||||
$this->handle = fopen($this->filename, 'w');
|
||||
}
|
||||
$this->groupMap = array();
|
||||
$index = 0;
|
||||
foreach ($oOptions->selectedColumns as $column) {
|
||||
if (isset($survey->fieldMap[$column])) {
|
||||
$question = $survey->fieldMap[$column];
|
||||
} else {
|
||||
// Token field
|
||||
$question = array('gid'=>0, 'qid'=>'');
|
||||
}
|
||||
$question['index'] = $index;
|
||||
$this->groupMap[intval($question['gid'])][] = $question;
|
||||
$index++;
|
||||
}
|
||||
$this->groupMap = $this->setGroupMap($survey, $oOptions);
|
||||
}
|
||||
|
||||
protected function writeHeader()
|
||||
|
@ -77,6 +65,7 @@
|
|||
$this->writeHeader();
|
||||
$this->first = false;
|
||||
}
|
||||
$this->tag('h1', sprintf(gT("Survey response")));
|
||||
$this->openTag('div', array(
|
||||
'class' => 'response',
|
||||
'data-srid' => $values[0]
|
||||
|
|
|
@ -8,13 +8,21 @@ class PdfWriter extends Writer
|
|||
private $surveyName;
|
||||
private $clang;
|
||||
|
||||
/**
|
||||
* Map of questions groups
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $aGroupMap = array();
|
||||
|
||||
public function init(SurveyObj $survey, $sLanguageCode, FormattingOptions $oOptions)
|
||||
{
|
||||
parent::init($survey, $sLanguageCode, $oOptions);
|
||||
$pdforientation=Yii::app()->getConfig('pdforientation');
|
||||
$this->clang = new limesurvey_lang($sLanguageCode);
|
||||
|
||||
if ($oOptions->output=='file')
|
||||
if ($oOptions->output=='file')
|
||||
{
|
||||
$this->pdfDestination = 'F';
|
||||
} else {
|
||||
|
@ -26,16 +34,11 @@ class PdfWriter extends Writer
|
|||
|
||||
// create new PDF document
|
||||
$this->pdf = new pdf();
|
||||
$this->pdf->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
|
||||
$this->pdf->AddPage();
|
||||
$this->pdf->intopdf("PDF export ".date("Y.m.d-H:i", time()));
|
||||
$this->pdf->setLanguageArray($aPdfLanguageSettings['lg']);
|
||||
|
||||
$this->surveyName = $survey->info['surveyls_title'];
|
||||
$this->pdf->initAnswerPDF($survey->info, $aPdfLanguageSettings, Yii::app()->getConfig('sitename'), $this->surveyName);
|
||||
$this->separator="\t";
|
||||
|
||||
$this->rowCounter = 0;
|
||||
$this->surveyName = $survey->languageSettings['surveyls_title'];
|
||||
$this->pdf->titleintopdf($this->surveyName, $survey->languageSettings['surveyls_description']);
|
||||
$this->rowCounter = 0;
|
||||
$this->aGroupMap = $this->setGroupMap($survey, $oOptions);
|
||||
}
|
||||
|
||||
public function outputRecord($headers, $values, FormattingOptions $oOptions)
|
||||
|
@ -44,7 +47,6 @@ class PdfWriter extends Writer
|
|||
if ($oOptions->answerFormat == 'short')
|
||||
{
|
||||
$pdfstring = '';
|
||||
$this->pdf->titleintopdf($this->clang->gT("Survey response"));
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$pdfstring .= $value.' | ';
|
||||
|
@ -57,14 +59,28 @@ class PdfWriter extends Writer
|
|||
{
|
||||
$this->pdf->AddPage();
|
||||
}
|
||||
$this->pdf->Cell(0, 10, sprintf($this->clang->gT("Survey response %d"), $this->rowCounter), 1, 1);
|
||||
|
||||
$columnCounter = 0;
|
||||
foreach($headers as $header)
|
||||
$this->pdf->addTitle(sprintf($this->clang->gT("Survey response %d"), $this->rowCounter));
|
||||
foreach ($this->aGroupMap as $gid => $questions)
|
||||
{
|
||||
$this->pdf->intopdf($header);
|
||||
$this->pdf->intopdf($this->stripTagsFull($values[$columnCounter]));
|
||||
$columnCounter++;
|
||||
if ($gid != 0)
|
||||
{
|
||||
$this->pdf->addGidAnswer($questions[0]['group_name']);
|
||||
}
|
||||
foreach ($questions as $question)
|
||||
{
|
||||
if (isset($values[$question['index']]) && isset($headers[$question['index']]))
|
||||
{
|
||||
if ($question['type'] == 'N' || $question['type'] == 'K')
|
||||
{
|
||||
$sAuxValue=number_format(floatval($values[$question['index']]), 0, '', '');
|
||||
$this->pdf->addAnswer($headers[$question['index']], $sAuxValue, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->pdf->addAnswer($headers[$question['index']], $values[$question['index']], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -36,6 +36,31 @@ abstract class Writer implements IWriter
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return map of questions groups
|
||||
*
|
||||
* @param Survey $survey
|
||||
* @param FormattingOptions $oOptions
|
||||
* @return array
|
||||
*/
|
||||
public function setGroupMap(SurveyObj $survey, FormattingOptions $oOptions)
|
||||
{
|
||||
$aGroupMap = array();
|
||||
$index = 0;
|
||||
foreach ($oOptions->selectedColumns as $column) {
|
||||
if (isset($survey->fieldMap[$column])) {
|
||||
$question = $survey->fieldMap[$column];
|
||||
} else {
|
||||
// Token field
|
||||
$question = array('gid'=>0, 'qid'=>'');
|
||||
}
|
||||
$question['index'] = $index;
|
||||
$aGroupMap[intval($question['gid'])][] = $question;
|
||||
$index++;
|
||||
}
|
||||
return $aGroupMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an abbreviated heading for the survey's question that matches
|
||||
* the $fieldName parameter (or false if a match is not found).
|
||||
|
@ -395,6 +420,18 @@ abstract class Writer implements IWriter
|
|||
}
|
||||
//Output the results.
|
||||
$sFile='';
|
||||
|
||||
// If empty survey, prepare an empty responses array, and output just 1 empty record with header.
|
||||
if ($survey->responses->rowCount == 0)
|
||||
{
|
||||
foreach ($oOptions->selectedColumns as $column)
|
||||
{
|
||||
$elementArray[]="";
|
||||
}
|
||||
$this->outputRecord($headers, $elementArray, $oOptions);
|
||||
}
|
||||
|
||||
// If no empty survey, render/export responses array.
|
||||
foreach($survey->responses as $response)
|
||||
{
|
||||
$elementArray = array();
|
||||
|
@ -455,4 +492,4 @@ abstract class Writer implements IWriter
|
|||
* @param FormattingOptions $oOptions
|
||||
*/
|
||||
abstract protected function outputRecord($headers, $values, FormattingOptions $oOptions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
}
|
||||
|
||||
$htmlcode .= ""
|
||||
. "<a href=\"javascript:start_popup_editor('".$fieldname."','".addslashes($fieldtext)."','".$surveyID."','".$gID."','".$qID."','".$fieldtype."','".$action."')\" id='".$fieldname."_ctrl' class='editorLink'>\n"
|
||||
. "<a href=\"javascript:start_popup_editor('".$fieldname."','".addslashes(htmlspecialchars_decode($fieldtext,ENT_QUOTES))."','".$surveyID."','".$gID."','".$qID."','".$fieldtype."','".$action."')\" id='".$fieldname."_ctrl' class='editorLink'>\n"
|
||||
. "\t<img alt=\"".$clang->gT("Start HTML editor in a popup window")."\" id='".$fieldname."_popupctrlena' src='".Yii::app()->getConfig('adminimageurl')."edithtmlpopup.png' $imgopts class='btneditanswerena' />\n"
|
||||
. "\t<img alt=\"".$clang->gT("Give focus to the HTML editor popup window")."\" id='".$fieldname."_popupctrldis' src='".Yii::app()->getConfig('adminimageurl')."edithtmlpopup_disabled.png' style='display:none' $imgopts class='btneditanswerdis' />\n"
|
||||
. "</a>\n";
|
||||
|
|
|
@ -194,14 +194,14 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
$countgroups=0;
|
||||
if (isset($questionarray))
|
||||
{
|
||||
$questionfieldnames=convertCSVRowToArray($questionarray[0],',','"');
|
||||
$questionfieldnames=str_getcsv($questionarray[0],',','"');
|
||||
unset($questionarray[0]);
|
||||
$countquestions = 0;
|
||||
}
|
||||
|
||||
if (isset($answerarray))
|
||||
{
|
||||
$answerfieldnames=convertCSVRowToArray($answerarray[0],',','"');
|
||||
$answerfieldnames=str_getcsv($answerarray[0],',','"');
|
||||
unset($answerarray[0]);
|
||||
$countanswers = count($answerarray);
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
$langcode = Survey::model()->findByPk($iNewSID)->language;
|
||||
if (isset($grouparray))
|
||||
{
|
||||
$groupfieldnames = convertCSVRowToArray($grouparray[0],',','"');
|
||||
$groupfieldnames = str_getcsv($grouparray[0],',','"');
|
||||
$langfieldnum = array_search("language", $groupfieldnames);
|
||||
$gidfieldnum = array_search("gid", $groupfieldnames);
|
||||
$groupssupportbaselang = doesImportArraySupportLanguage($grouparray,Array($gidfieldnum),$langfieldnum,$sBaseLanguage,true);
|
||||
|
@ -261,7 +261,7 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
|
||||
if (count($labelsetsarray) > 1)
|
||||
{
|
||||
$labelsetfieldname = convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$labelsetfieldname = str_getcsv($labelsetsarray[0],',','"');
|
||||
$langfieldnum = array_search("languages", $labelsetfieldname);
|
||||
$lidfilednum = array_search("lid", $labelsetfieldname);
|
||||
$labelsetssupportbaselang = doesImportArraySupportLanguage($labelsetsarray,Array($lidfilednum),$langfieldnum,$sBaseLanguage,true);
|
||||
|
@ -288,8 +288,8 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
|
||||
$count=0;
|
||||
foreach ($labelsetsarray as $lsa) {
|
||||
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($lsa,',','"');
|
||||
$fieldorders =str_getcsv($labelsetsarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($lsa,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
@ -308,8 +308,8 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
if ($labelsarray) {
|
||||
$count=0;
|
||||
foreach ($labelsarray as $la) {
|
||||
$lfieldorders =convertCSVRowToArray($labelsarray[0],',','"');
|
||||
$lfieldcontents=convertCSVRowToArray($la,',','"');
|
||||
$lfieldorders =str_getcsv($labelsarray[0],',','"');
|
||||
$lfieldcontents=str_getcsv($la,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
// Combine into one array with keys and values since its easier to handle
|
||||
|
@ -385,14 +385,14 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
if (isset($grouparray) && $grouparray)
|
||||
{
|
||||
// do GROUPS
|
||||
$gafieldorders=convertCSVRowToArray($grouparray[0],',','"');
|
||||
$gafieldorders=str_getcsv($grouparray[0],',','"');
|
||||
unset($grouparray[0]);
|
||||
$newgid = 0;
|
||||
$group_order = 0; // just to initialize this variable
|
||||
|
||||
foreach ($grouparray as $ga)
|
||||
{
|
||||
$gacfieldcontents=convertCSVRowToArray($ga,',','"');
|
||||
$gacfieldcontents=str_getcsv($ga,',','"');
|
||||
$grouprowdata=array_combine($gafieldorders,$gacfieldcontents);
|
||||
|
||||
// Skip not supported languages
|
||||
|
@ -447,7 +447,7 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
|
||||
foreach ($questionarray as $qa)
|
||||
{
|
||||
$qacfieldcontents=convertCSVRowToArray($qa,',','"');
|
||||
$qacfieldcontents=str_getcsv($qa,',','"');
|
||||
$questionrowdata=array_combine($questionfieldnames,$qacfieldcontents);
|
||||
$questionrowdata=array_map('convertCSVReturnToReturn', $questionrowdata);
|
||||
$questionrowdata["type"]=strtoupper($questionrowdata["type"]);
|
||||
|
@ -582,7 +582,7 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
{
|
||||
foreach ($answerarray as $aa)
|
||||
{
|
||||
$answerfieldcontents=convertCSVRowToArray($aa,',','"');
|
||||
$answerfieldcontents=str_getcsv($aa,',','"');
|
||||
$answerrowdata=array_combine($answerfieldnames,$answerfieldcontents);
|
||||
if ($answerrowdata===false)
|
||||
{
|
||||
|
@ -682,11 +682,11 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
// Finally the question attributes - it is called just once and only if there was a question
|
||||
if (isset($question_attributesarray) && $question_attributesarray)
|
||||
{//ONLY DO THIS IF THERE ARE QUESTION_ATTRIBUES
|
||||
$fieldorders=convertCSVRowToArray($question_attributesarray[0],',','"');
|
||||
$fieldorders=str_getcsv($question_attributesarray[0],',','"');
|
||||
unset($question_attributesarray[0]);
|
||||
|
||||
foreach ($question_attributesarray as $qar) {
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
$qarowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
||||
// replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this attribute is orphan -> error, skip this record)
|
||||
|
@ -710,10 +710,10 @@ function CSVImportGroup($sFullFilePath, $iNewSID)
|
|||
$results['conditions']=0;
|
||||
if (isset($conditionsarray) && $conditionsarray)
|
||||
{
|
||||
$fieldorders=convertCSVRowToArray($conditionsarray[0],',','"');
|
||||
$fieldorders=str_getcsv($conditionsarray[0],',','"');
|
||||
unset($conditionsarray[0]);
|
||||
foreach ($conditionsarray as $car) {
|
||||
$fieldcontents=convertCSVRowToArray($car,',','"');
|
||||
$fieldcontents=str_getcsv($car,',','"');
|
||||
$conditionrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
||||
$oldqid = $conditionrowdata["qid"];
|
||||
|
@ -850,7 +850,7 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
|
|||
$insertdata['gid']=$aGIDReplacements[$oldgid];
|
||||
}
|
||||
if (isset($insertdata['gid'])) switchMSSQLIdentityInsert('groups',true);
|
||||
|
||||
|
||||
$result = Yii::app()->db->createCommand()->insert('{{groups}}', $insertdata);
|
||||
|
||||
if (isset($insertdata['gid'])) switchMSSQLIdentityInsert('groups',false);
|
||||
|
@ -896,7 +896,7 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
|
|||
$insertdata['qid']=$aQIDReplacements[$oldqid];
|
||||
}
|
||||
if (isset($insertdata['qid'])) switchMSSQLIdentityInsert('questions',true);
|
||||
|
||||
|
||||
$result = Yii::app()->db->createCommand()->insert('{{questions}}', $insertdata);
|
||||
if (isset($insertdata['qid'])) switchMSSQLIdentityInsert('questions',false);
|
||||
if (!isset($aQIDReplacements[$oldqid]))
|
||||
|
@ -938,7 +938,7 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
|
|||
$result = Yii::app()->db->createCommand()->insert('{{questions}}', $insertdata);
|
||||
$newsqid=getLastInsertID('{{questions}}');
|
||||
if (isset($insertdata['qid'])) switchMSSQLIdentityInsert('questions',true);
|
||||
|
||||
|
||||
if (!isset($insertdata['qid']))
|
||||
{
|
||||
$aQIDReplacements[$oldsqid]=$newsqid; // add old and new qid to the mapping array
|
||||
|
@ -1020,10 +1020,10 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
|
|||
$insertdata[(string)$key]=(string)$value;
|
||||
}
|
||||
$insertdata['qid']=$aQIDReplacements[(int)$insertdata['qid']]; // remap the qid
|
||||
if ($insertdata['sqid']>0)
|
||||
if ($insertdata['sqid']>0)
|
||||
{
|
||||
if (!isset($aQIDReplacements[(int)$insertdata['sqid']])) continue; // If SQID is invalid skip the default value
|
||||
$insertdata['sqid']=$aQIDReplacements[(int)$insertdata['sqid']]; // remap the subquestion id
|
||||
$insertdata['sqid']=$aQIDReplacements[(int)$insertdata['sqid']]; // remap the subquestion id
|
||||
}
|
||||
|
||||
// now translate any links
|
||||
|
@ -1238,7 +1238,7 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
|
||||
if (isset($questionarray))
|
||||
{
|
||||
$questionfieldnames=convertCSVRowToArray($questionarray[0],',','"');
|
||||
$questionfieldnames=str_getcsv($questionarray[0],',','"');
|
||||
unset($questionarray[0]);
|
||||
$countquestions = count($questionarray)-1;
|
||||
}
|
||||
|
@ -1246,7 +1246,7 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
|
||||
if (isset($answerarray))
|
||||
{
|
||||
$answerfieldnames=convertCSVRowToArray($answerarray[0],',','"');
|
||||
$answerfieldnames=str_getcsv($answerarray[0],',','"');
|
||||
unset($answerarray[0]);
|
||||
while (trim(reset($answerarray))=='')
|
||||
{
|
||||
|
@ -1298,7 +1298,7 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
|
||||
if ($countlabelsets > 0)
|
||||
{
|
||||
$labelsetfieldname = convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$labelsetfieldname = str_getcsv($labelsetsarray[0],',','"');
|
||||
$langfieldnum = array_search("languages", $labelsetfieldname);
|
||||
$lidfilednum = array_search("lid", $labelsetfieldname);
|
||||
$labelsetssupportbaselang = doesImportArraySupportLanguage($labelsetsarray,Array($lidfilednum),$langfieldnum,$sBaseLanguage,true);
|
||||
|
@ -1316,8 +1316,8 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
|
||||
$count=0;
|
||||
foreach ($labelsetsarray as $lsa) {
|
||||
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($lsa,',','"');
|
||||
$fieldorders =str_getcsv($labelsetsarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($lsa,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$results['labelsets']++;
|
||||
|
@ -1338,8 +1338,8 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
if ($labelsarray) {
|
||||
$count=0;
|
||||
foreach ($labelsarray as $la) {
|
||||
$lfieldorders =convertCSVRowToArray($labelsarray[0],',','"');
|
||||
$lfieldcontents=convertCSVRowToArray($la,',','"');
|
||||
$lfieldorders =str_getcsv($labelsarray[0],',','"');
|
||||
$lfieldcontents=str_getcsv($la,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
// Combine into one array with keys and values since its easier to handle
|
||||
|
@ -1432,7 +1432,7 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
|
||||
foreach ($questionarray as $qa)
|
||||
{
|
||||
$qacfieldcontents=convertCSVRowToArray($qa,',','"');
|
||||
$qacfieldcontents=str_getcsv($qa,',','"');
|
||||
$questionrowdata=array_combine($questionfieldnames,$qacfieldcontents);
|
||||
|
||||
// Skip not supported languages
|
||||
|
@ -1567,7 +1567,7 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
{
|
||||
foreach ($answerarray as $aa)
|
||||
{
|
||||
$answerfieldcontents=convertCSVRowToArray($aa,',','"');
|
||||
$answerfieldcontents=str_getcsv($aa,',','"');
|
||||
$answerrowdata=array_combine($answerfieldnames,$answerfieldcontents);
|
||||
if ($answerrowdata===false)
|
||||
{
|
||||
|
@ -1660,10 +1660,10 @@ function CSVImportQuestion($sFullFilePath, $iNewSID, $newgid)
|
|||
// Finally the question attributes - it is called just once and only if there was a question
|
||||
if (isset($question_attributesarray) && $question_attributesarray)
|
||||
{//ONLY DO THIS IF THERE ARE QUESTION_ATTRIBUES
|
||||
$fieldorders =convertCSVRowToArray($question_attributesarray[0],',','"');
|
||||
$fieldorders =str_getcsv($question_attributesarray[0],',','"');
|
||||
unset($question_attributesarray[0]);
|
||||
foreach ($question_attributesarray as $qar) {
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
$qarowdata=array_combine($fieldorders,$fieldcontents);
|
||||
$qarowdata["qid"]=$newqid;
|
||||
unset($qarowdata["qaid"]);
|
||||
|
@ -2019,8 +2019,8 @@ function CSVImportLabelset($sFullFilePath, $options)
|
|||
if (isset($labelsetsarray) && $labelsetsarray) {
|
||||
$count=0;
|
||||
foreach ($labelsetsarray as $lsa) {
|
||||
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($lsa,',','"');
|
||||
$fieldorders =str_getcsv($labelsetsarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($lsa,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
@ -2040,11 +2040,11 @@ function CSVImportLabelset($sFullFilePath, $options)
|
|||
|
||||
if ($labelsarray) {
|
||||
$count=0;
|
||||
$lfieldorders=convertCSVRowToArray($labelsarray[0],',','"');
|
||||
$lfieldorders=str_getcsv($labelsarray[0],',','"');
|
||||
unset($labelsarray[0]);
|
||||
foreach ($labelsarray as $la) {
|
||||
|
||||
$lfieldcontents=convertCSVRowToArray($la,',','"');
|
||||
$lfieldcontents=str_getcsv($la,',','"');
|
||||
// Combine into one array with keys and values since its easier to handle
|
||||
$labelrowdata=array_combine($lfieldorders,$lfieldcontents);
|
||||
$labellid=$labelrowdata['lid'];
|
||||
|
@ -2259,7 +2259,6 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$substitutions=array();
|
||||
$aQuestionCodeReplacements=array();
|
||||
$aQuotaReplacements=array();
|
||||
$importresults['error']=false;
|
||||
$importresults['importwarnings']=array();
|
||||
$importresults['question_attributes']=0;
|
||||
|
||||
|
@ -2597,8 +2596,8 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
if ($importresults['conditions']>0){$importresults['conditions']--;};
|
||||
if ($importresults['labelsets']>0){$importresults['labelsets']--;};
|
||||
if ($importresults['quota']>0){$importresults['quota']--;};
|
||||
$sfieldorders =convertCSVRowToArray($surveyarray[0],',','"');
|
||||
$sfieldcontents=convertCSVRowToArray($surveyarray[1],',','"');
|
||||
$sfieldorders =str_getcsv($surveyarray[0],',','"');
|
||||
$sfieldcontents=str_getcsv($surveyarray[1],',','"');
|
||||
$surveyrowdata=array_combine($sfieldorders,$sfieldcontents);
|
||||
$iOldSID=$surveyrowdata["sid"];
|
||||
|
||||
|
@ -2631,8 +2630,8 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
|
||||
|
||||
$insert=$surveyarray[0];
|
||||
$sfieldorders =convertCSVRowToArray($surveyarray[0],',','"');
|
||||
$sfieldcontents=convertCSVRowToArray($surveyarray[1],',','"');
|
||||
$sfieldorders =str_getcsv($surveyarray[0],',','"');
|
||||
$sfieldcontents=str_getcsv($surveyarray[1],',','"');
|
||||
$surveyrowdata=array_combine($sfieldorders,$sfieldcontents);
|
||||
// Set new owner ID
|
||||
$surveyrowdata['owner_id']=Yii::app()->session['loginID'];
|
||||
|
@ -2662,10 +2661,10 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$iNewSID = Survey::model()->insertNewSurvey($surveyrowdata) or safeDie ("<br />".$clang->gT("Import of this survey file failed")."<br />{$surveyarray[0]}<br /><br />\n" );
|
||||
|
||||
// Now import the survey language settings
|
||||
$fieldorders=convertCSVRowToArray($surveylsarray[0],',','"');
|
||||
$fieldorders=str_getcsv($surveylsarray[0],',','"');
|
||||
unset($surveylsarray[0]);
|
||||
foreach ($surveylsarray as $slsrow) {
|
||||
$fieldcontents=convertCSVRowToArray($slsrow,',','"');
|
||||
$fieldcontents=str_getcsv($slsrow,',','"');
|
||||
$surveylsrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
// convert back the '\'.'n' char from the CSV file to true return char "\n"
|
||||
$surveylsrowdata=array_map('convertCSVReturnToReturn', $surveylsrowdata);
|
||||
|
@ -2699,8 +2698,7 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$aLanguagesSupported=array_merge($aLanguagesSupported,Survey::model()->findByPk($iNewSID)->additionalLanguages);
|
||||
|
||||
|
||||
// DO SURVEY_RIGHTS
|
||||
|
||||
// Create survey permissions
|
||||
Permission::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'],$iNewSID);
|
||||
|
||||
$importresults['deniedcountls'] =0;
|
||||
|
@ -2718,8 +2716,8 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
|
||||
$count=0;
|
||||
foreach ($labelsetsarray as $lsa) {
|
||||
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($lsa,',','"');
|
||||
$fieldorders =str_getcsv($labelsetsarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($lsa,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
@ -2737,8 +2735,8 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
if ($labelsarray) {
|
||||
$count=0;
|
||||
foreach ($labelsarray as $la) {
|
||||
$lfieldorders =convertCSVRowToArray($labelsarray[0],',','"');
|
||||
$lfieldcontents=convertCSVRowToArray($la,',','"');
|
||||
$lfieldorders =str_getcsv($labelsarray[0],',','"');
|
||||
$lfieldcontents=str_getcsv($la,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
// Combine into one array with keys and values since its easier to handle
|
||||
|
@ -2815,11 +2813,11 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
if (isset($grouparray) && $grouparray)
|
||||
{
|
||||
// do GROUPS
|
||||
$gafieldorders=convertCSVRowToArray($grouparray[0],',','"');
|
||||
$gafieldorders=str_getcsv($grouparray[0],',','"');
|
||||
unset($grouparray[0]);
|
||||
foreach ($grouparray as $ga)
|
||||
{
|
||||
$gacfieldcontents=convertCSVRowToArray($ga,',','"');
|
||||
$gacfieldcontents=str_getcsv($ga,',','"');
|
||||
$grouprowdata=array_combine($gafieldorders,$gacfieldcontents);
|
||||
|
||||
//Now an additional integrity check if there are any groups not belonging into this survey
|
||||
|
@ -2867,11 +2865,11 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
// Import questions
|
||||
if (isset($questionarray) && $questionarray)
|
||||
{
|
||||
$qafieldorders=convertCSVRowToArray($questionarray[0],',','"');
|
||||
$qafieldorders=str_getcsv($questionarray[0],',','"');
|
||||
unset($questionarray[0]);
|
||||
foreach ($questionarray as $qa)
|
||||
{
|
||||
$qacfieldcontents=convertCSVRowToArray($qa,',','"');
|
||||
$qacfieldcontents=str_getcsv($qa,',','"');
|
||||
$questionrowdata=array_combine($qafieldorders,$qacfieldcontents);
|
||||
$questionrowdata=array_map('convertCSVReturnToReturn', $questionrowdata);
|
||||
$questionrowdata["type"]=strtoupper($questionrowdata["type"]);
|
||||
|
@ -2961,7 +2959,7 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
}
|
||||
if (!$oQuestion->save())
|
||||
{
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($oQuestion->errors, true));
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($oQuestion->errors, true));
|
||||
//
|
||||
// In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
|
||||
// Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
|
||||
|
@ -3044,12 +3042,12 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
//Do answers
|
||||
if (isset($answerarray) && $answerarray)
|
||||
{
|
||||
$answerfieldnames = convertCSVRowToArray($answerarray[0],',','"');
|
||||
$answerfieldnames = str_getcsv($answerarray[0],',','"');
|
||||
unset($answerarray[0]);
|
||||
|
||||
foreach ($answerarray as $aa)
|
||||
{
|
||||
$answerfieldcontents = convertCSVRowToArray($aa,',','"');
|
||||
$answerfieldcontents = str_getcsv($aa,',','"');
|
||||
$answerrowdata = array_combine($answerfieldnames,$answerfieldcontents);
|
||||
if (in_array($answerrowdata['qid'],$aIgnoredAnswers))
|
||||
{
|
||||
|
@ -3153,9 +3151,9 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
}
|
||||
if (!$question->save())
|
||||
{
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($question->errors, true));
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($question->errors, true));
|
||||
//
|
||||
// In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
|
||||
// In PHP 5.2.10 and some later versions a bug is triggered that resets the foreach loop when inserting a record
|
||||
// Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
|
||||
// For this reason we ignore insertion errors (because it is most likely a duplicate)
|
||||
// and continue with the next one
|
||||
|
@ -3217,10 +3215,10 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
//We've built two arrays along the way - one containing the old SID, GID and QIDs - and their NEW equivalents
|
||||
//and one containing the old 'extended fieldname' and its new equivalent. These are needed to import conditions and question_attributes.
|
||||
if (isset($question_attributesarray) && $question_attributesarray) {//ONLY DO THIS IF THERE ARE QUESTION_ATTRIBUES
|
||||
$fieldorders =convertCSVRowToArray($question_attributesarray[0],',','"');
|
||||
$fieldorders =str_getcsv($question_attributesarray[0],',','"');
|
||||
unset($question_attributesarray[0]);
|
||||
foreach ($question_attributesarray as $qar) {
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
$qarowdata=array_combine($fieldorders,$fieldcontents);
|
||||
$newqid="";
|
||||
$qarowdata["qid"]=$aQIDReplacements[$qarowdata["qid"]];
|
||||
|
@ -3231,11 +3229,11 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
}
|
||||
|
||||
if (isset($assessmentsarray) && $assessmentsarray) {//ONLY DO THIS IF THERE ARE QUESTION_ATTRIBUTES
|
||||
$fieldorders=convertCSVRowToArray($assessmentsarray[0],',','"');
|
||||
$fieldorders=str_getcsv($assessmentsarray[0],',','"');
|
||||
unset($assessmentsarray[0]);
|
||||
foreach ($assessmentsarray as $qar)
|
||||
{
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
$asrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
if (isset($asrowdata['link']))
|
||||
{
|
||||
|
@ -3257,19 +3255,12 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
}
|
||||
|
||||
if (isset($quotaarray) && $quotaarray) {//ONLY DO THIS IF THERE ARE QUOTAS
|
||||
$fieldorders=convertCSVRowToArray($quotaarray[0],',','"');
|
||||
$fieldorders=str_getcsv($quotaarray[0],',','"');
|
||||
unset($quotaarray[0]);
|
||||
foreach ($quotaarray as $qar)
|
||||
{
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
$asrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
||||
$iOldSID=$asrowdata["sid"];
|
||||
foreach ($substitutions as $subs) {
|
||||
if ($iOldSID==$subs[0]) {$iNewSID=$subs[3];}
|
||||
}
|
||||
|
||||
$asrowdata["sid"]=$iNewSID;
|
||||
$oldid = $asrowdata["id"];
|
||||
unset($asrowdata["id"]);
|
||||
|
@ -3283,27 +3274,20 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$count=0;
|
||||
foreach ($quotamembersarray as $qar) {
|
||||
|
||||
$fieldorders =convertCSVRowToArray($quotamembersarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldorders =str_getcsv($quotamembersarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$asrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
||||
$iOldSID=$asrowdata["sid"];
|
||||
$newqid="";
|
||||
$newquotaid="";
|
||||
$oldqid=$asrowdata['qid'];
|
||||
$oldquotaid=$asrowdata['quota_id'];
|
||||
|
||||
foreach ($substitutions as $subs) {
|
||||
if ($iOldSID==$subs[0]) {$iNewSID=$subs[3];}
|
||||
if ($oldqid==$subs[2]) {$newqid=$subs[5];}
|
||||
}
|
||||
|
||||
$newquotaid=$aQuotaReplacements[$oldquotaid];
|
||||
|
||||
$asrowdata["sid"]=$iNewSID;
|
||||
$asrowdata["qid"]=$newqid;
|
||||
$asrowdata["qid"]=$aQIDReplacements[$oldqid];
|
||||
$asrowdata["quota_id"]=$newquotaid;
|
||||
unset($asrowdata["id"]);
|
||||
|
||||
|
@ -3316,8 +3300,8 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
$count=0;
|
||||
foreach ($quotalsarray as $qar) {
|
||||
|
||||
$fieldorders =convertCSVRowToArray($quotalsarray[0],',','"');
|
||||
$fieldcontents=convertCSVRowToArray($qar,',','"');
|
||||
$fieldorders =str_getcsv($quotalsarray[0],',','"');
|
||||
$fieldcontents=str_getcsv($qar,',','"');
|
||||
if ($count==0) {$count++; continue;}
|
||||
|
||||
$asrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
@ -3354,12 +3338,12 @@ function CSVImportSurvey($sFullFilePath,$iDesiredSurveyId=NULL,$bTranslateLinks=
|
|||
|
||||
// Do conditions
|
||||
if (isset($conditionsarray) && $conditionsarray) {//ONLY DO THIS IF THERE ARE CONDITIONS!
|
||||
$fieldorders =convertCSVRowToArray($conditionsarray[0],',','"');
|
||||
$fieldorders =str_getcsv($conditionsarray[0],',','"');
|
||||
unset($conditionsarray[0]);
|
||||
// Exception for conditions based on attributes
|
||||
$aQIDReplacements[0]=0;
|
||||
foreach ($conditionsarray as $car) {
|
||||
$fieldcontents=convertCSVRowToArray($car,',','"');
|
||||
$fieldcontents=str_getcsv($car,',','"');
|
||||
$conditionrowdata=array_combine($fieldorders,$fieldcontents);
|
||||
|
||||
unset($conditionrowdata["cid"]);
|
||||
|
@ -3510,7 +3494,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
if ($sXMLdata == NULL)
|
||||
{
|
||||
$sXMLdata = file_get_contents($sFullFilePath);
|
||||
}
|
||||
}
|
||||
$xml = @simplexml_load_string($sXMLdata,'SimpleXMLElement',LIBXML_NONET);
|
||||
|
||||
if (!$xml || $xml->LimeSurveyDocType!='Survey')
|
||||
|
@ -3598,9 +3582,9 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
$insertdata['googleanalyticsapikey']=$insertdata['googleAnalyticsAPIKey'];
|
||||
unset($insertdata['googleAnalyticsAPIKey']);
|
||||
}
|
||||
if (isset($insertdata['allowjumps']))
|
||||
if (isset($insertdata['allowjumps']))
|
||||
{
|
||||
$insertdata['questionindex']= ($insertdata['allowjumps']=="Y")?1:0;
|
||||
$insertdata['questionindex']= ($insertdata['allowjumps']=="Y")?1:0;
|
||||
unset($insertdata['allowjumps']);
|
||||
}
|
||||
/* Remove unknow column */
|
||||
|
@ -3613,7 +3597,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
{
|
||||
$results['importwarnings'][]=sprintf($clang->gT("This survey setting has not been imported: %s => %s"),$key,$value);
|
||||
}
|
||||
|
||||
|
||||
$iNewSID = $results['newsid'] = Survey::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error").": Failed to insert data [1]<br />");
|
||||
|
||||
$results['surveys']++;
|
||||
|
@ -3655,7 +3639,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
{
|
||||
unset($insertdata['surveyls_attributecaptions']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = SurveyLanguageSetting::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error").": Failed to insert data [2]<br />");
|
||||
|
@ -3741,7 +3725,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
if ($insertdata)
|
||||
XSSFilterArray($insertdata);
|
||||
|
||||
if (!$bConvertInvalidQuestionCodes)
|
||||
if (!$bConvertInvalidQuestionCodes)
|
||||
{
|
||||
$sScenario='archiveimport';
|
||||
}
|
||||
|
@ -3787,7 +3771,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
}
|
||||
if (!$oQuestion->save())
|
||||
{
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($oQuestion->errors, true));
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($oQuestion->errors, true));
|
||||
//
|
||||
// In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
|
||||
// Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
|
||||
|
@ -3851,7 +3835,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
XSSFilterArray($insertdata);
|
||||
|
||||
|
||||
if (!$bConvertInvalidQuestionCodes)
|
||||
if (!$bConvertInvalidQuestionCodes)
|
||||
{
|
||||
$sScenario='archiveimport';
|
||||
}
|
||||
|
@ -3895,7 +3879,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
}
|
||||
if (!$question->save())
|
||||
{
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($question->errors, true));
|
||||
// safeDie($clang->gT("Error while saving: "). print_r($question->errors, true));
|
||||
//
|
||||
// In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
|
||||
// Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
|
||||
|
@ -3946,7 +3930,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
}
|
||||
if ($insertdata)
|
||||
XSSFilterArray($insertdata);
|
||||
|
||||
|
||||
if (Answer::model()->insertRecords($insertdata))
|
||||
{
|
||||
$results['answers']++;
|
||||
|
@ -3965,17 +3949,17 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
{
|
||||
$insertdata[(string)$key]=(string)$value;
|
||||
}
|
||||
|
||||
|
||||
// take care of renaming of date min/max adv. attributes fields
|
||||
if ($iDBVersion < 170)
|
||||
{
|
||||
if (isset($insertdata['attribute']))
|
||||
{
|
||||
if ($insertdata['attribute']=='dropdown_dates_year_max')
|
||||
if ($insertdata['attribute']=='dropdown_dates_year_max')
|
||||
{
|
||||
$insertdata['attribute']='date_max';
|
||||
$insertdata['attribute']='date_max';
|
||||
}
|
||||
if ($insertdata['attribute']=='dropdown_dates_year_min')
|
||||
if ($insertdata['attribute']=='dropdown_dates_year_min')
|
||||
{
|
||||
$insertdata['attribute']='date_min';
|
||||
}
|
||||
|
@ -4203,7 +4187,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
$insertdata['sid']=$iNewSID; // remap the survey id
|
||||
if (isset($insertdata['targetsqid']) && $insertdata['targetsqid']!='')
|
||||
{
|
||||
$insertdata['targetsqid'] =$aSQIDReplacements[(int)$insertdata['targetsqid']]; // remap the qid
|
||||
$insertdata['targetsqid'] =$aQIDReplacements[(int)$insertdata['targetsqid']]; // remap the qid
|
||||
}
|
||||
if (isset($insertdata['targetqid']) && $insertdata['targetqid']!='')
|
||||
{
|
||||
|
@ -4215,7 +4199,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
|
|||
}
|
||||
}
|
||||
|
||||
// Set survey rights
|
||||
// Set survey permissions
|
||||
Permission::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'],$iNewSID);
|
||||
$aOldNewFieldmap=reverseTranslateFieldNames($iOldSID,$iNewSID,$aGIDReplacements,$aQIDReplacements);
|
||||
$results['FieldReMap']=$aOldNewFieldmap;
|
||||
|
@ -4282,7 +4266,7 @@ function XMLImportTokens($sFullFilePath,$iSurveyID,$sCreateMissingAttributeField
|
|||
$results['tokens']=0;
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
$results['tokens']=0;
|
||||
$results['tokenfieldscreated']=0;
|
||||
|
||||
|
@ -4322,13 +4306,16 @@ function XMLImportTokens($sFullFilePath,$iSurveyID,$sCreateMissingAttributeField
|
|||
$token = Token::create($iSurveyID);
|
||||
$token->setAttributes($insertdata, false);
|
||||
if (!$token->save())
|
||||
{
|
||||
{
|
||||
$results['warnings'][]=$clang->gT("Skipped tokens entry:").' '. implode('. ',$token->errors['token']);
|
||||
};
|
||||
$results['tokens']++;
|
||||
}
|
||||
switchMSSQLIdentityInsert('tokens_'.$iSurveyID,false);
|
||||
|
||||
if (Yii::app()->db->getDriverName() == 'pgsql')
|
||||
{
|
||||
try {Yii::app()->db->createCommand("SELECT pg_catalog.setval(pg_get_serial_sequence('{{tokens_".$iSurveyID."}}', 'tid'), (SELECT MAX(tid) FROM {{tokens_".$iSurveyID."}}))")->execute();} catch(Exception $oException){};
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
@ -4379,7 +4366,7 @@ function XMLImportResponses($sFullFilePath,$iSurveyID,$aFieldReMap=array())
|
|||
$aInsertData[$sFieldname]='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = SurveyDynamic::model($iSurveyID)->insertRecords($aInsertData) or safeDie($clang->gT("Error").": Failed to insert data[16]<br />");
|
||||
$results['responses']++;
|
||||
}
|
||||
|
@ -4389,7 +4376,10 @@ function XMLImportResponses($sFullFilePath,$iSurveyID,$aFieldReMap=array())
|
|||
}
|
||||
|
||||
switchMSSQLIdentityInsert('survey_'.$iSurveyID,false);
|
||||
|
||||
if (Yii::app()->db->getDriverName() == 'pgsql')
|
||||
{
|
||||
try {Yii::app()->db->createCommand("SELECT pg_catalog.setval(pg_get_serial_sequence('{{survey_".$iSurveyID."}}', 'id'), (SELECT MAX(id) FROM {{survey_".$iSurveyID."}}))")->execute();} catch(Exception $oException){};
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
@ -4510,6 +4500,7 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
$aResponsesError=array();
|
||||
$aExistingsId=array();
|
||||
|
||||
$iMaxId=0; // If we set the id, keep the max
|
||||
// Some specific header (with options)
|
||||
$iIdKey=array_search('id', $aCsvHeader); // the id is allways needed and used a lot
|
||||
if(is_int($iIdKey)){unset($aKeyForFieldNames['id']);}
|
||||
|
@ -4565,6 +4556,7 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
if(!$bExistingsId) // If not exist : allways import it
|
||||
{
|
||||
$oSurvey->id=$aResponses[$iIdKey];
|
||||
$iMaxId=($aResponses[$iIdKey]>$iMaxId)?$aResponses[$iIdKey]:$iMaxId;
|
||||
}
|
||||
elseif($aOptions['sExistingId']=='replace' || $aOptions['sExistingId']=='replaceanswers')// Set it depending with some options
|
||||
{
|
||||
|
@ -4578,7 +4570,7 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
elseif(is_int($iSubmitdateKey))
|
||||
{
|
||||
if( $aResponses[$iSubmitdateKey]=='{question_not_shown}' || trim($aResponses[$iSubmitdateKey]=='')){
|
||||
$oSurvey->submitdate = new CDbExpression('NULL');
|
||||
$oSurvey->submitdate = new CDbExpression('NULL');
|
||||
}else{
|
||||
// Maybe control valid date : see http://php.net/manual/en/function.checkdate.php#78362 for example
|
||||
$oSurvey->submitdate=$aResponses[$iSubmitdateKey];
|
||||
|
@ -4587,7 +4579,7 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
foreach($aKeyForFieldNames as $sFieldName=>$iFieldKey)
|
||||
{
|
||||
if( $aResponses[$iFieldKey]=='{question_not_shown}'){
|
||||
$oSurvey->$sFieldName = new CDbExpression('NULL');
|
||||
$oSurvey->$sFieldName = new CDbExpression('NULL');
|
||||
}else{
|
||||
$sResponse=str_replace(array("{quote}","{tab}","{cr}","{newline}","{lbrace}"),array("\"","\t","\r","\n","{"),$aResponses[$iFieldKey]);
|
||||
$oSurvey->$sFieldName = $sResponse;
|
||||
|
@ -4597,6 +4589,11 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
$oTransaction = Yii::app()->db->beginTransaction();
|
||||
try
|
||||
{
|
||||
if (isset($oSurvey->id) && !is_null($oSurvey->id))
|
||||
{
|
||||
switchMSSQLIdentityInsert('survey_'.$iSurveyId, true);
|
||||
$bSwitched=true;
|
||||
}
|
||||
if($oSurvey->save())
|
||||
{
|
||||
$oTransaction->commit();
|
||||
|
@ -4614,6 +4611,10 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
$oTransaction->rollBack();
|
||||
$aResponsesError[]=$aResponses[$iIdReponsesKey];
|
||||
}
|
||||
if (isset($bSwitched) && $bSwitched==true){
|
||||
switchMSSQLIdentityInsert('survey_'.$iSurveyId, false);
|
||||
$bSwitched=false;
|
||||
}
|
||||
}
|
||||
catch(Exception $oException)
|
||||
{
|
||||
|
@ -4626,6 +4627,19 @@ function CSVImportResponses($sFullFilePath,$iSurveyId,$aOptions=array())
|
|||
|
||||
}
|
||||
}
|
||||
// Fix max next id (for pgsql)
|
||||
// mysql dot need fix, but what for mssql ?
|
||||
// Do a model function for this can be a good idea (see activate_helper/activateSurvey)
|
||||
if (Yii::app()->db->driverName=='pgsql')
|
||||
{
|
||||
$sSequenceName= Yii::app()->db->getSchema()->getTable("{{survey_{$iSurveyId}}}")->sequenceName;
|
||||
$iActualSerial=Yii::app()->db->createCommand("SELECT last_value FROM {$sSequenceName}")->queryScalar();
|
||||
if($iActualSerial<$iMaxId)
|
||||
{
|
||||
$sQuery = "SELECT setval(pg_get_serial_sequence('{{survey_{$iSurveyId}}}', 'id'),{$iMaxId},false);";
|
||||
$result = @Yii::app()->db->createCommand($sQuery)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
// End of import
|
||||
// Construction of returned information
|
||||
|
@ -4674,9 +4688,9 @@ function XMLImportTimings($sFullFilePath,$iSurveyID,$aFieldReMap=array())
|
|||
}
|
||||
$results['languages']=count($aLanguagesSupported);
|
||||
// Return if there are no timing records to import
|
||||
if (!isset($xml->timings->rows))
|
||||
if (!isset($xml->timings->rows))
|
||||
{
|
||||
return $results;
|
||||
return $results;
|
||||
}
|
||||
switchMSSQLIdentityInsert('survey_'.$iSurveyID.'_timings',true);
|
||||
foreach ($xml->timings->rows->row as $row)
|
||||
|
@ -4850,7 +4864,7 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$surveyinfo['active']='N';
|
||||
// unset($surveyinfo['datecreated']);
|
||||
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo) ; //or safeDie($clang->gT("Error").": Failed to insert survey<br />");
|
||||
if ($iNewSID==false)
|
||||
if (!$iNewSID)
|
||||
{
|
||||
$results['error'] = Survey::model()->getErrors();
|
||||
$results['bFailed'] = true;
|
||||
|
@ -4915,7 +4929,7 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$glang = (!empty($row['language']) ? $row['language'] : $baselang);
|
||||
// when a multi-lang tsv-file without information on the group id/number (old style) is imported,
|
||||
// we make up this information by giving a number 0..[numberofgroups-1] per language.
|
||||
// the number and order of groups per language should be the same, so we can also import these files
|
||||
// the number and order of groups per language should be the same, so we can also import these files
|
||||
if ($lastglang!=$glang) //reset counter on language change
|
||||
{
|
||||
$iGroupcounter=0;
|
||||
|
@ -4936,7 +4950,7 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$insertdata['group_order'] = $ginfo[$sGroupseq]['group_order'];
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$insertdata['group_order'] = $gseq;
|
||||
}
|
||||
$newgid = QuestionGroup::model()->insertRecords($insertdata);
|
||||
|
@ -4969,7 +4983,7 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$insertdata['help'] = (isset($row['help']) ? $row['help'] : '');
|
||||
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
|
||||
$insertdata['mandatory'] = (isset($row['mandatory']) ? $row['mandatory'] : '');
|
||||
$insertdata['other'] = (isset($row['other']) ? $row['other'] : 'N');
|
||||
$lastother = $insertdata['other'] = (isset($row['other']) ? $row['other'] : 'N'); // Keep trace of other settings for sub question
|
||||
$insertdata['same_default'] = (isset($row['same_default']) ? $row['same_default'] : 0);
|
||||
$insertdata['parent_qid'] = 0;
|
||||
|
||||
|
@ -5030,7 +5044,7 @@ function TSVImportSurvey($sFullFilePath)
|
|||
{
|
||||
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$insertdata['language'] = NULL;
|
||||
}
|
||||
|
@ -5062,17 +5076,17 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$results['defaultvalues']++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'SQ':
|
||||
$sqname = (isset($row['name']) ? $row['name'] : 'SQ' . $sqseq);
|
||||
if ($qtype == 'O' || $qtype == '|')
|
||||
{
|
||||
; // these are fake rows to show naming of comment and filecount fields
|
||||
}
|
||||
elseif ($sqname == 'other' && ($qtype == '!' || $qtype == 'L'))
|
||||
elseif ($sqname == 'other' && $lastother=="Y") // If last question have other to Y : it's not a real SQ row
|
||||
{
|
||||
if($qtype=="!" || $qtype=="L")
|
||||
{
|
||||
// only want to set default value for 'other' in these cases - not a real SQ row
|
||||
// TODO - this isn't working
|
||||
// only used to set default value for 'other' in these cases
|
||||
if (isset($row['default']))
|
||||
{
|
||||
$insertdata=array();
|
||||
|
@ -5081,12 +5095,14 @@ function TSVImportSurvey($sFullFilePath)
|
|||
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
|
||||
$insertdata['defaultvalue'] = $row['default'];
|
||||
$result = DefaultValue::model()->insertRecords($insertdata);
|
||||
if(!$result){
|
||||
if(!$result)
|
||||
{
|
||||
$results['importwarnings'][] = $clang->gT("Warning")." : ".$clang->gT("Failed to insert default value").". ".$clang->gT("Text file row number ").$rownumber;
|
||||
break;
|
||||
}
|
||||
$results['defaultvalues']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5179,6 +5195,6 @@ function TSVImportSurvey($sFullFilePath)
|
|||
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
|
||||
LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ function createChart($iQuestionID, $iSurveyID, $type=null, $lbl, $gdata, $grawda
|
|||
$language = $oLanguage->langcode;
|
||||
$clang = $oLanguage;
|
||||
$cachefilename = "";
|
||||
|
||||
|
||||
/* Set the fonts for the chart */
|
||||
if ($chartfontfile=='auto')
|
||||
{
|
||||
|
@ -200,12 +200,13 @@ function createChart($iQuestionID, $iSurveyID, $type=null, $lbl, $gdata, $grawda
|
|||
|
||||
if ($legendsize[1]<320) $gheight=420; else $gheight=$legendsize[1]+100;
|
||||
$graph = new pChart(690+$legendsize[0],$gheight);
|
||||
$graph->drawFilledRectangle(0,0,690+$legendsize[0],$gheight,254,254,254,false);
|
||||
$graph->loadColorPalette($homedir.DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR.$admintheme.DIRECTORY_SEPARATOR.'limesurvey.pal');
|
||||
$graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile,$chartfontsize);
|
||||
$graph->setGraphArea(50,30,500,$gheight-60);
|
||||
$graph->drawFilledRoundedRectangle(7,7,523+$legendsize[0],$gheight-7,5,254,255,254);
|
||||
$graph->drawRoundedRectangle(5,5,525+$legendsize[0],$gheight-5,5,230,230,230);
|
||||
$graph->drawGraphArea(255,255,255,TRUE);
|
||||
$graph->drawGraphArea(254,254,254,TRUE);
|
||||
$graph->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,150,150,150,TRUE,90,0,TRUE,5,false);
|
||||
$graph->drawGrid(4,TRUE,230,230,230,50);
|
||||
// Draw the 0 line
|
||||
|
@ -217,7 +218,7 @@ function createChart($iQuestionID, $iSurveyID, $type=null, $lbl, $gdata, $grawda
|
|||
//$Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie4","1","Important point!");
|
||||
// Finish the graph
|
||||
$graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile, $chartfontsize);
|
||||
$graph->drawLegend(510,30,$DataSet->GetDataDescription(),255,255,255);
|
||||
$graph->drawLegend(510,30,$DataSet->GetDataDescription(),250,250,250);
|
||||
|
||||
$cache->WriteToCache("graph".$iSurveyID.$language.$iQuestionID,$DataSet->GetData(),$graph);
|
||||
$cachefilename=basename($cache->GetFileFromCache("graph".$iSurveyID.$language.$iQuestionID,$DataSet->GetData()));
|
||||
|
@ -292,6 +293,7 @@ function createChart($iQuestionID, $iSurveyID, $type=null, $lbl, $gdata, $grawda
|
|||
|
||||
$gheight=ceil($gheight);
|
||||
$graph = new pChart(690,$gheight);
|
||||
$graph->drawFilledRectangle(0,0,690,$gheight,254,254,254,false);
|
||||
$graph->loadColorPalette($homedir.'/styles/'.$admintheme.'/limesurvey.pal');
|
||||
$graph->drawFilledRoundedRectangle(7,7,687,$gheight-3,5,254,255,254);
|
||||
$graph->drawRoundedRectangle(5,5,689,$gheight-1,5,230,230,230);
|
||||
|
@ -2362,7 +2364,7 @@ class statistics_helper {
|
|||
$this->sheet->writeNumber($this->xlsRow,1,$grawdata[$i]);
|
||||
$this->sheet->writeNumber($this->xlsRow,2,$percentage/100, $this->xlsPercents);
|
||||
if ($aggregatedPercentage !== 'na') {
|
||||
$this->sheet->writeNumber($this->xlsRow,3,$percentage/100, $this->xlsPercents);
|
||||
$this->sheet->writeNumber($this->xlsRow,3,$aggregatedPercentage/100, $this->xlsPercents);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -3102,9 +3104,9 @@ class statistics_helper {
|
|||
|
||||
elseif (!empty($newsql)) {$sql = $newsql;}
|
||||
|
||||
if (!isset($sql) || !$sql)
|
||||
if (!isset($sql) || !$sql)
|
||||
{
|
||||
$sql= null;
|
||||
$sql= null;
|
||||
}
|
||||
|
||||
//only continue if we have something to output
|
||||
|
@ -3245,7 +3247,7 @@ class statistics_helper {
|
|||
static $recordCount = 0;
|
||||
static $field = null;
|
||||
static $allRows = null;
|
||||
|
||||
|
||||
if ($surveyid !== $sid || $fieldname !== $field) {
|
||||
//get data
|
||||
$query =" FROM {{survey_$surveyid}} WHERE ".Yii::app()->db->quoteColumnName($fieldname)." IS NOT null";
|
||||
|
@ -3292,15 +3294,15 @@ class statistics_helper {
|
|||
// Need at least 2 records
|
||||
if ($recordCount<2) return;
|
||||
break;
|
||||
|
||||
|
||||
case 0:
|
||||
return $recordCount;
|
||||
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$q1 = $quartile/4 * ($recordCount+1);
|
||||
$row = $q1-1; // -1 since we start counting at 0
|
||||
if ($q1 === (int) $q1) {
|
||||
|
@ -3326,7 +3328,7 @@ class statistics_helper {
|
|||
//filter incomplete answers if set
|
||||
if (incompleteAnsFilterState() == "incomplete") {$search['condition'] .= " AND submitdate is null";}
|
||||
elseif (incompleteAnsFilterState() == "complete") {$search['condition'] .= " AND submitdate is not null";}
|
||||
|
||||
|
||||
//Look for any selects/filters set in the original statistics query, and apply them to the column listing
|
||||
if (isset(Yii::app()->session['statistics_selects_'.$surveyid]) && is_array(Yii::app()->session['statistics_selects_'.$surveyid]))
|
||||
{
|
||||
|
@ -3355,7 +3357,7 @@ class statistics_helper {
|
|||
$output[]=array("id"=>$row['id'], "value"=>$row[$column]);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,34 @@ function createTokenTable($iSurveyID, $aAttributeFields=array())
|
|||
{
|
||||
$fields[$sAttributeField]='string';
|
||||
}
|
||||
|
||||
if (Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='sqlsrv' || Yii::app()->db->driverName=='dblib')
|
||||
{
|
||||
$fields = array(
|
||||
'tid' => 'pk',
|
||||
'participant_id' => 'varchar(50)',
|
||||
'firstname' => 'nvarchar(40)',
|
||||
'lastname' => 'nvarchar(40)',
|
||||
'email' => 'ntext',
|
||||
'emailstatus' => 'ntext',
|
||||
'token' => 'varchar(35)',
|
||||
'language' => 'varchar(25)',
|
||||
'blacklisted' => 'varchar(17)',
|
||||
'sent' => "varchar(17) DEFAULT 'N'",
|
||||
'remindersent' => "varchar(17) DEFAULT 'N'",
|
||||
'remindercount' => 'integer DEFAULT 0',
|
||||
'completed' => "varchar(17) DEFAULT 'N'",
|
||||
'usesleft' => 'integer DEFAULT 1',
|
||||
'validfrom' => 'datetime',
|
||||
'validuntil' => 'datetime',
|
||||
'mpid' => 'integer'
|
||||
);
|
||||
foreach ($aAttributeFields as $sAttributeField)
|
||||
{
|
||||
$fields[$sAttributeField]='nvarchar(255)';
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
$sTableName="{{tokens_".intval($iSurveyID)."}}";
|
||||
createTable($sTableName, $fields);
|
||||
|
@ -84,14 +112,14 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
$bHtml = true;
|
||||
else
|
||||
$bHtml = false;
|
||||
|
||||
$attributes = array_keys(getTokenFieldsAndNames($iSurveyID));
|
||||
|
||||
$attributes = array_keys(getTokenFieldsAndNames($iSurveyID));
|
||||
$oSurveyLocale=SurveyLanguageSetting::model()->findAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
|
||||
$oTokens = Token::model($iSurveyID);
|
||||
$aSurveyLangs = $oSurvey->additionalLanguages;
|
||||
array_unshift($aSurveyLangs, $oSurvey->language);
|
||||
|
||||
//Convert result to associative array to minimize SurveyLocale access attempts
|
||||
|
||||
//Convert result to associative array to minimize SurveyLocale access attempts
|
||||
foreach($oSurveyLocale as $rows)
|
||||
{
|
||||
$oTempObject=array();
|
||||
|
@ -103,7 +131,7 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
}
|
||||
|
||||
foreach ($aResultTokens as $aTokenRow)
|
||||
{
|
||||
{
|
||||
//Select language
|
||||
$aTokenRow['language'] = trim($aTokenRow['language']);
|
||||
$found = array_search($aTokenRow['language'], $aSurveyLangs);
|
||||
|
@ -112,7 +140,7 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
$aTokenRow['language'] = $oSurvey['language'];
|
||||
}
|
||||
$sTokenLanguage = $aTokenRow['language'];
|
||||
|
||||
|
||||
|
||||
//Build recipient
|
||||
$to = array();
|
||||
|
@ -121,34 +149,34 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
{
|
||||
$to[] = ($aTokenRow['firstname'] . " " . $aTokenRow['lastname'] . " <{$sEmailaddress}>");
|
||||
}
|
||||
|
||||
|
||||
//Populate attributes
|
||||
|
||||
//Populate attributes
|
||||
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_title'];
|
||||
if ($fieldsarray["{SURVEYNAME}"] == '')
|
||||
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_title'];
|
||||
|
||||
|
||||
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_description'];
|
||||
if ($fieldsarray["{SURVEYDESCRIPTION}"] == '')
|
||||
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_description'];
|
||||
|
||||
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_description'];
|
||||
|
||||
$fieldsarray["{ADMINNAME}"] = $oSurvey['admin'];
|
||||
$fieldsarray["{ADMINEMAIL}"] = $oSurvey['adminemail'];
|
||||
$from = $fieldsarray["{ADMINEMAIL}"];
|
||||
if($from == '')
|
||||
$from = Yii::app()->getConfig('siteadminemail');
|
||||
|
||||
$from = Yii::app()->getConfig('siteadminemail');
|
||||
|
||||
foreach ($attributes as $attributefield)
|
||||
{
|
||||
$fieldsarray['{' . strtoupper($attributefield) . '}'] = $aTokenRow[$attributefield];
|
||||
$fieldsarray['{TOKEN:'.strtoupper($attributefield).'}']=$aTokenRow[$attributefield];
|
||||
}
|
||||
|
||||
|
||||
//create urls
|
||||
$fieldsarray["{OPTOUTURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optout/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
|
||||
$fieldsarray["{OPTINURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optin/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
|
||||
$fieldsarray["{SURVEYURL}"] = Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}/token/{$aTokenRow['token']}/lang/" . trim($aTokenRow['language']) . "/");
|
||||
|
||||
|
||||
if($bHtml)
|
||||
{
|
||||
foreach(array('OPTOUT', 'OPTIN', 'SURVEY') as $key)
|
||||
|
@ -161,12 +189,12 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//mail headers
|
||||
$customheaders = array('1' => "X-surveyid: " . $iSurveyID,'2' => "X-tokenid: " . $fieldsarray["{TOKEN}"]);
|
||||
|
||||
|
||||
global $maildebug;
|
||||
|
||||
|
||||
//choose appriopriate email message
|
||||
if($sType == 'invite')
|
||||
{
|
||||
|
@ -178,7 +206,7 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind_subj'];
|
||||
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind'];
|
||||
}
|
||||
|
||||
|
||||
$modsubject = Replacefields($sSubject, $fieldsarray);
|
||||
$modmessage = Replacefields($sMessage, $fieldsarray);
|
||||
|
||||
|
@ -188,45 +216,45 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
$modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (isset($aTokenRow['validfrom']) && trim($aTokenRow['validfrom']) != '' && convertDateTimeFormat($aTokenRow['validfrom'], 'Y-m-d H:i:s', 'U') * 1 > date('U') * 1)
|
||||
{
|
||||
$aResult[$aTokenRow['tid']] = array('name'=>$fieldsarray["{FIRSTNAME}"]." ".$fieldsarray["{LASTNAME}"],
|
||||
'email'=>$fieldsarray["{EMAIL}"],
|
||||
'status'=>'fail',
|
||||
'error'=>'Token not valid yet');
|
||||
|
||||
|
||||
}
|
||||
elseif (isset($aTokenRow['validuntil']) && trim($aTokenRow['validuntil']) != '' && convertDateTimeFormat($aTokenRow['validuntil'], 'Y-m-d H:i:s', 'U') * 1 < date('U') * 1)
|
||||
{
|
||||
$aResult[$aTokenRow['tid']] = array('name'=>$fieldsarray["{FIRSTNAME}"]." ".$fieldsarray["{LASTNAME}"],
|
||||
'email'=>$fieldsarray["{EMAIL}"],
|
||||
'status'=>'fail',
|
||||
'error'=>'Token not valid anymore');
|
||||
'error'=>'Token not valid anymore');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyID), null, $customheaders))
|
||||
{
|
||||
$aResult[$aTokenRow['tid']] = array('name'=>$fieldsarray["{FIRSTNAME}"]." ".$fieldsarray["{LASTNAME}"],
|
||||
'email'=>$fieldsarray["{EMAIL}"],
|
||||
'status'=>'OK');
|
||||
|
||||
|
||||
if($sType == 'invite')
|
||||
$oTokens->updateByPk($aTokenRow['tid'], array('sent' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"))));
|
||||
|
||||
if($sType == 'remind')
|
||||
|
||||
if($sType == 'remind')
|
||||
{
|
||||
$iRCount = $oTokens->findByPk($aTokenRow['tid'])->remindercount +1;
|
||||
$oTokens->updateByPk($aTokenRow['tid'], array('remindersent' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"))));
|
||||
$oTokens->updateByPk($aTokenRow['tid'],array('remindercount' => $iRCount));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
$aResult[$aTokenRow['tid']] = array('name'=>$fieldsarray["{FIRSTNAME}"]." ".$fieldsarray["{LASTNAME}"],
|
||||
|
@ -235,7 +263,7 @@ function emailTokens($iSurveyID,$aResultTokens,$sType)
|
|||
'error'=>$maildebug);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unset($fieldsarray);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,22 +12,6 @@
|
|||
*/
|
||||
Yii::import('application.helpers.sanitize_helper', true);
|
||||
|
||||
/**
|
||||
* Simple function to sort the permissions by title
|
||||
*
|
||||
* @param mixed $aPermissionA Permission A to compare
|
||||
* @param mixed $aPermissionB Permission B to compare
|
||||
*/
|
||||
function comparePermission($aPermissionA,$aPermissionB)
|
||||
{
|
||||
if($aPermissionA['title'] >$aPermissionB['title']) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation helper function.
|
||||
* @param string $string
|
||||
|
@ -69,7 +53,7 @@ function ngT($single, $plural, $number, $escapemode = 'html')
|
|||
function getQuestionTypeList($SelectedCode = "T", $ReturnType = "selector")
|
||||
{
|
||||
$publicurl = Yii::app()->getConfig('publicurl');
|
||||
|
||||
|
||||
$qtypes = Question::typeList();
|
||||
if ($ReturnType == "array")
|
||||
return $qtypes;
|
||||
|
@ -151,12 +135,8 @@ function getSurveyList($returnarray=false, $surveyid=false)
|
|||
|
||||
if(is_null($cached)) {
|
||||
$args = array('order'=>'surveyls_title');
|
||||
if (!Permission::model()->hasGlobalPermission('superadmin','read'))
|
||||
{
|
||||
$surveyidresult = Survey::model()->permission(Yii::app()->user->getId())->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findAll($args);
|
||||
} else {
|
||||
$surveyidresult = Survey::model()->with(array('languagesettings'=>array('condition'=>'surveyls_language=language')))->findAll($args);
|
||||
}
|
||||
$surveyidresult = Survey::model()->permission(Yii::app()->user->getId())->with('defaultlanguage')->findAll($args);
|
||||
|
||||
|
||||
$surveynames = array();
|
||||
foreach ($surveyidresult as $result)
|
||||
|
@ -1365,13 +1345,13 @@ function fixMovedQuestionConditions($qid,$oldgid,$newgid) //Function rewrites th
|
|||
*/
|
||||
function returnGlobal($stringname,$bRestrictToString=false)
|
||||
{
|
||||
$urlParam=Yii::app()->request->getParam($stringname);
|
||||
$urlParam=Yii::app()->request->getParam($stringname);
|
||||
if(is_null($urlParam) && $aCookies=Yii::app()->request->getCookies() && $stringname!='sid')
|
||||
{
|
||||
if(isset($aCookies[$stringname]))
|
||||
{
|
||||
$urlParam = $aCookies[$stringname];
|
||||
}
|
||||
}
|
||||
}
|
||||
$bUrlParamIsArray=is_array($urlParam);// Needed to array map or if $bRestrictToString
|
||||
if (!is_null($urlParam) && $stringname!='' && (!$bUrlParamIsArray || !$bRestrictToString))
|
||||
|
@ -1465,8 +1445,8 @@ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $oLanguage)
|
|||
return false;
|
||||
|
||||
// If it is a comment field there is nothing to convert here
|
||||
if ($fields['aid']=='comment') return $sValue;
|
||||
|
||||
if ($fields['aid']=='comment') return $sValue;
|
||||
|
||||
//Find out the question type
|
||||
$this_type = $fields['type'];
|
||||
switch($this_type)
|
||||
|
@ -1613,16 +1593,16 @@ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $oLanguage)
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate an email address - also supports IDN email addresses
|
||||
* Validate an email address - also supports IDN email addresses
|
||||
* @returns True/false for valid/invalid
|
||||
*
|
||||
*
|
||||
* @param mixed $sEmailAddress Email address to check
|
||||
*/
|
||||
function validateEmailAddress($sEmailAddress){
|
||||
require_once(APPPATH.'third_party/idna-convert/idna_convert.class.php');
|
||||
$oIdnConverter = new idna_convert();
|
||||
$sEmailAddress=$oIdnConverter->encode($sEmailAddress);
|
||||
$bResult=filter_var($sEmailAddress, FILTER_VALIDATE_EMAIL);
|
||||
$bResult=filter_var($sEmailAddress, FILTER_VALIDATE_EMAIL);
|
||||
if ($bResult!==false)
|
||||
{
|
||||
return true;
|
||||
|
@ -1630,6 +1610,29 @@ function validateEmailAddress($sEmailAddress){
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an list of email addresses - either as array or as semicolon-limited text
|
||||
* @returns List with valid email addresses - invalid email addresses are filtered - false if none of the email addresses are valid
|
||||
*
|
||||
* @param mixed $sEmailAddresses Email address to check
|
||||
*/
|
||||
function validateEmailAddresses($aEmailAddressList){
|
||||
$aOutList=false;
|
||||
if (!is_array($aEmailAddressList))
|
||||
{
|
||||
$aEmailAddressList=explode(';',$aEmailAddressList);
|
||||
}
|
||||
foreach ($aEmailAddressList as $sEmailAddress)
|
||||
{
|
||||
$sEmailAddress= trim($sEmailAddress);
|
||||
if (validateEmailAddress($sEmailAddress)){
|
||||
$aOutList=$sEmailAddress;
|
||||
}
|
||||
}
|
||||
return $aOutList;
|
||||
}
|
||||
|
||||
|
||||
function validateTemplateDir($sTemplateName)
|
||||
{
|
||||
$usertemplaterootdir = Yii::app()->getConfig('usertemplaterootdir');
|
||||
|
@ -1718,7 +1721,7 @@ function validateTemplateDir($sTemplateName)
|
|||
case ";": //ARRAY (Multi Flex) (Text)
|
||||
case ":": //ARRAY (Multi Flex) (Numbers)
|
||||
$result = Question::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[qid] AND language = '{$sLanguage}' AND scale_id = 0", 'question_order');
|
||||
|
||||
|
||||
foreach($result as $row)
|
||||
{
|
||||
$fresult = Question::model()->getQuestionsForStatistics('title, question', "parent_qid=$flt[qid] AND language = '{$sLanguage}' AND scale_id = 1", 'question_order');
|
||||
|
@ -1793,8 +1796,7 @@ return $allfields;
|
|||
* @param string $sQuestionLanguage The language to use
|
||||
* @return array
|
||||
*/
|
||||
function createFieldMap($surveyid, $style='short', $force_refresh=false, $questionid=false, $sLanguage) {
|
||||
global $aDuplicateQIDs;
|
||||
function createFieldMap($surveyid, $style='short', $force_refresh=false, $questionid=false, $sLanguage, &$aDuplicateQIDs=array()) {
|
||||
|
||||
$sLanguage = sanitize_languagecode($sLanguage);
|
||||
$surveyid = sanitize_int($surveyid);
|
||||
|
@ -1837,12 +1839,6 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
|
|||
$fieldmap["startlanguage"]['group_name']="";
|
||||
}
|
||||
|
||||
// Select which question IDs have default values
|
||||
$_aDefaultValues = DefaultValue::model()->with(array('question' => array('condition' => 'question.sid=' . $surveyid)))->findAll();
|
||||
$aDefaultValues = array();
|
||||
foreach ($_aDefaultValues as $k => $v)
|
||||
$aDefaultValues[] = $v->qid;
|
||||
|
||||
//Check for any additional fields for this survey and create necessary fields (token and datestamp and ipaddr)
|
||||
$prow = Survey::model()->findByPk($surveyid)->getAttributes(); //Checked
|
||||
|
||||
|
@ -2376,7 +2372,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
|
|||
* @return bool
|
||||
*/
|
||||
function hasFileUploadQuestion($iSurveyID) {
|
||||
$iCount = Question::model()->count( "sid=:surveyid AND parent_qid=0 AND type='|'", array(':surveyid' => $iSurveyID));
|
||||
$iCount = Question::model()->count( "sid=:surveyid AND parent_qid=0 AND type='|'", array(':surveyid' => $iSurveyID));
|
||||
return $iCount>0 ;
|
||||
}
|
||||
|
||||
|
@ -3321,8 +3317,8 @@ function questionAttributes($returnByName=false)
|
|||
'i18n'=>true,
|
||||
'default'=>"",
|
||||
"help"=>$clang->gT('In the printable version replace the relevance equation with this explanation text.'),
|
||||
"caption"=>$clang->gT("Relevance help for printable survey"));
|
||||
|
||||
"caption"=>$clang->gT("Relevance help for printable survey"));
|
||||
|
||||
$qattributes["public_statistics"]=array(
|
||||
"types"=>"15ABCEFGHKLMNOPRWYZ!:*",
|
||||
'category'=>$clang->gT('Statistics'),
|
||||
|
@ -3415,7 +3411,7 @@ function questionAttributes($returnByName=false)
|
|||
'category'=>$clang->gT('Slider'),
|
||||
'sortorder'=>10,
|
||||
'inputtype'=>'text',
|
||||
"help"=>$clang->gT('Slider minimum value'),
|
||||
"help"=>$clang->gT('You can use Expression manager, but this must be a number before showing the page else set to 0. If minimum value is not set, this value is used.'),
|
||||
"caption"=>$clang->gT('Slider minimum value'));
|
||||
|
||||
$qattributes["slider_max"]=array(
|
||||
|
@ -3423,7 +3419,7 @@ function questionAttributes($returnByName=false)
|
|||
'category'=>$clang->gT('Slider'),
|
||||
'sortorder'=>11,
|
||||
'inputtype'=>'text',
|
||||
"help"=>$clang->gT('Slider maximum value'),
|
||||
"help"=>$clang->gT('You can use Expression manager, but this must be a number before showing the page else set to 100. If maximum value is not set, this value is used.'),
|
||||
"caption"=>$clang->gT('Slider maximum value'));
|
||||
|
||||
$qattributes["slider_accuracy"]=array(
|
||||
|
@ -3431,7 +3427,7 @@ function questionAttributes($returnByName=false)
|
|||
'category'=>$clang->gT('Slider'),
|
||||
'sortorder'=>30,
|
||||
'inputtype'=>'text',
|
||||
"help"=>$clang->gT('Slider accuracy'),
|
||||
"help"=>$clang->gT('You can use Expression manager, but this must be a number before showing the page else set to 1.'),
|
||||
"caption"=>$clang->gT('Slider accuracy'));
|
||||
|
||||
$qattributes["slider_default"]=array(
|
||||
|
@ -3439,7 +3435,7 @@ function questionAttributes($returnByName=false)
|
|||
'category'=>$clang->gT('Slider'),
|
||||
'sortorder'=>50,
|
||||
'inputtype'=>'text',
|
||||
"help"=>$clang->gT('Slider start as this value (this will set the initial value).'),
|
||||
"help"=>$clang->gT('Slider start as this value (this will set the initial value). You can use Expression manager, but this must be a number before showing the page.'),
|
||||
"caption"=>$clang->gT('Slider initial value'));
|
||||
|
||||
$qattributes["slider_middlestart"]=array(
|
||||
|
@ -3817,7 +3813,7 @@ function questionAttributes($returnByName=false)
|
|||
'category'=>$clang->gT('Other'),
|
||||
'sortorder'=>134,
|
||||
"inputtype"=>"text",
|
||||
'default'=>"png, gif, doc, odt",
|
||||
'default'=>"png, gif, jpg, doc, odt",
|
||||
"help"=>$clang->gT("Allowed file types in comma separated format. e.g. pdf,doc,odt"),
|
||||
"caption"=>$clang->gT("Allowed file types"));
|
||||
|
||||
|
@ -3883,14 +3879,6 @@ function categorySort($a, $b)
|
|||
return $result;
|
||||
}
|
||||
|
||||
// make sure the given string (which comes from a POST or GET variable)
|
||||
// is safe to use in MySQL. This does nothing if gpc_magic_quotes is on.
|
||||
function autoEscape($str) {
|
||||
if (!get_magic_quotes_gpc()) {
|
||||
return addslashes ($str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
// the opposite of the above: takes a POST or GET variable which may or
|
||||
// may not have been 'auto-quoted', and return the *unquoted* version.
|
||||
|
@ -4106,7 +4094,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false,
|
|||
{
|
||||
$mail->AddAttachment($attachment[0], $attachment[1]);
|
||||
}
|
||||
else
|
||||
else
|
||||
{ // Or a string with the filename.
|
||||
$mail->AddAttachment($attachment);
|
||||
}
|
||||
|
@ -4426,13 +4414,6 @@ function CSVEscape($sString)
|
|||
return '"' . str_replace('"','""', $sString) . '"';
|
||||
}
|
||||
|
||||
function convertCSVRowToArray($string, $separator, $quotechar)
|
||||
{
|
||||
$fields=preg_split('/' . $separator . '(?=([^"]*"[^"]*")*(?![^"]*"))/',trim($string));
|
||||
$fields=array_map('CSVUnquote',$fields);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function createPassword()
|
||||
{
|
||||
$aCharacters = "ABCDEGHJIKLMNOPQURSTUVWXYZabcdefhjmnpqrstuvwxyz23456789";
|
||||
|
@ -4769,7 +4750,7 @@ function translateLinks($sType, $iOldSurveyID, $iNewSurveyID, $sString)
|
|||
$replace = Yii::app()->getConfig("publicurl")."upload/labels/{$iNewSurveyID}/";
|
||||
return preg_replace('#'.$pattern.'#', $replace, $sString);
|
||||
}
|
||||
else // unkown type
|
||||
else // unknown type
|
||||
{
|
||||
return $sString;
|
||||
}
|
||||
|
@ -5256,10 +5237,10 @@ function updateCheck()
|
|||
$aUpdateVersions=getUpdateInfo();
|
||||
$clang = Yii::app()->lang;
|
||||
|
||||
if (isset($aUpdateVersions['errorcode']))
|
||||
if (isset($aUpdateVersions['errorcode']))
|
||||
{
|
||||
Yii::app()->setFlashMessage(sprintf($clang->gT("Error when checking for new version: %s"),$aUpdateVersions['errorcode']).'<br>'.$aUpdateVersions['errorhtml'],'error');
|
||||
$aUpdateVersions=array();
|
||||
$aUpdateVersions=array();
|
||||
}
|
||||
if (count($aUpdateVersions) && trim(Yii::app()->getConfig('buildnumber'))!='')
|
||||
{
|
||||
|
@ -5276,28 +5257,28 @@ function updateCheck()
|
|||
|
||||
case 'both':
|
||||
// Show first available update
|
||||
$aUpdateVersion=reset($aUpdateVersions);
|
||||
$aUpdateVersion=reset($aUpdateVersions);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
// Never show a notification
|
||||
$aUpdateVersions=array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setGlobalSetting('updateversions',json_encode($aUpdateVersions));
|
||||
|
||||
|
||||
|
||||
|
||||
if (isset($aUpdateVersion)) {
|
||||
setGlobalSetting('updateavailable',1);
|
||||
setGlobalSetting('updatebuild',$aUpdateVersion['build']);
|
||||
setGlobalSetting('updateversion',$aUpdateVersion['versionnumber']);
|
||||
} else {
|
||||
setGlobalSetting('updateavailable',0);
|
||||
setGlobalSetting('updateavailable',0);
|
||||
$aUpdateVersions = array();
|
||||
}
|
||||
|
||||
|
||||
setGlobalSetting('updatelastcheck',date('Y-m-d H:i:s'));
|
||||
return $aUpdateVersions;
|
||||
}
|
||||
|
@ -5487,17 +5468,17 @@ function enforceSSLMode()
|
|||
*
|
||||
* @param int $iSurveyId - Survey identification number
|
||||
* @param int $quotaid - quota id for which you want to compute the completed field
|
||||
* @return mixed - Integer of matching entries in the result DB or 'N/A'
|
||||
* @return string - Integer of matching entries in the result DB or 'N/A'
|
||||
*/
|
||||
function getQuotaCompletedCount($iSurveyId, $quotaid)
|
||||
{
|
||||
$result = "N/A";
|
||||
if(!tableExists("survey_{$iSurveyId}")) // Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}' are not updated even after Yii::app()->db->schema->refresh();
|
||||
return $result;
|
||||
$aColumnName=SurveyDynamic::model($iSurveyId)->getTableSchema()->getColumnNames();
|
||||
$quota_info = getQuotaInformation($iSurveyId, Survey::model()->findByPk($iSurveyId)->language, $quotaid);
|
||||
$quota = $quota_info[0];
|
||||
if (Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}') &&
|
||||
count($quota['members']) > 0)
|
||||
if (count($quota['members']) > 0) // Existence of table already tested
|
||||
{
|
||||
// Keep a list of fields for easy reference
|
||||
$fields_list = array();
|
||||
|
@ -5507,26 +5488,28 @@ function getQuotaCompletedCount($iSurveyId, $quotaid)
|
|||
|
||||
foreach ($quota['members'] as $member)
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
|
||||
foreach ($member['fieldnames'] as $fieldname)
|
||||
{
|
||||
if (!in_array($fieldname, $fields_list))
|
||||
$fields_list[] = $fieldname;
|
||||
|
||||
// Yii does not quote column names (duh!) so we have to do it.
|
||||
$criteria->addColumnCondition(array(Yii::app()->db->quoteColumnName($fieldname) => $member['value']), 'OR');
|
||||
}
|
||||
|
||||
$fields_query[$fieldname] = $criteria;
|
||||
if(in_array($member['fieldname'],$aColumnName))
|
||||
$fields_list[$member['fieldname']][] = $member['value'];
|
||||
else
|
||||
return $result;// We return N/A even for activated survey : $member['fieldname'] don't exist anymore (deleted question for example)
|
||||
}
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
|
||||
foreach ($fields_list as $fieldname)
|
||||
$criteria->mergeWith($fields_query[$fieldname]);
|
||||
$criteria->mergeWith(array('condition'=>"submitdate IS NOT NULL"));
|
||||
$result = SurveyDynamic::model($iSurveyId)->count($criteria);
|
||||
$criteria->condition="submitdate IS NOT NULL";
|
||||
foreach ($fields_list as $fieldname=>$aValue)
|
||||
{
|
||||
if(count($aValue)==1)
|
||||
{
|
||||
$criteria->compare(Yii::app()->db->quoteColumnName($fieldname),$aValue[0]);// NO need params
|
||||
}
|
||||
else
|
||||
{
|
||||
$criteria->addInCondition(Yii::app()->db->quoteColumnName($fieldname),$aValue); // NO need params : addInCondition bind automatically
|
||||
}
|
||||
}
|
||||
// Ensure to return a string, Yii count return a string (see http://www.yiiframework.com/doc/api/1.1/CActiveRecord#count-detail)
|
||||
// But seems under certain condition, count return integer see http://bugs.limesurvey.org/view.php?id=9587#c31917
|
||||
$result = strval(SurveyDynamic::model($iSurveyId)->count($criteria));
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -5609,16 +5592,16 @@ function getFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonorC
|
|||
continue;
|
||||
}
|
||||
if (isset($fname['subquestion']))
|
||||
$subquestion = "{$fname['subquestion']}";
|
||||
$subquestion = "[{$fname['subquestion']}]";
|
||||
|
||||
if (isset($fname['subquestion1']))
|
||||
$subquestion = "{$fname['subquestion1']}";
|
||||
$subquestion = "[{$fname['subquestion1']}]";
|
||||
|
||||
if (isset($fname['subquestion2']))
|
||||
$subquestion .= "[{$fname['subquestion2']}]";
|
||||
|
||||
$answer = getExtendedAnswer($iSurveyID,$fname['fieldname'], $idrow[$fname['fieldname']],$oLanguage);
|
||||
$aResultTable[$fname['fieldname']]=array('',$subquestion,$answer);
|
||||
$aResultTable[$fname['fieldname']]=array($question,$subquestion,$answer);
|
||||
}
|
||||
return $aResultTable;
|
||||
}
|
||||
|
@ -5638,6 +5621,61 @@ function isNumericInt($mStr)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implode and sort content array for very long arrays
|
||||
*
|
||||
* @param string $sDelimeter
|
||||
* @param array $aArray
|
||||
* @return string String showing array content
|
||||
*/
|
||||
function short_implode($sDelimeter, $sHyphen, $aArray)
|
||||
{
|
||||
if (sizeof($aArray) < Yii::app()->getConfig('minlengthshortimplode'))
|
||||
{
|
||||
sort($aArray);
|
||||
return implode($sDelimeter, $aArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
sort($aArray);
|
||||
$iIndexA = 0;
|
||||
$iIndexB = 1;
|
||||
while ($iIndexA < sizeof($aArray))
|
||||
{
|
||||
if ($iIndexA == 0)
|
||||
{
|
||||
$sResult = $aArray[$iIndexA];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($sResult) > Yii::app()->getConfig('maxstringlengthshortimplode') - strlen($sDelimeter) - 3)
|
||||
{
|
||||
return $sResult.$sDelimeter.'...';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sResult = $sResult.$sDelimeter.$aArray[$iIndexA];
|
||||
}
|
||||
}
|
||||
$iIndexB = $iIndexA+1;
|
||||
if ($iIndexB < sizeof($aArray))
|
||||
{
|
||||
while ($iIndexB < sizeof($aArray) && $aArray[$iIndexB] - 1 == $aArray[$iIndexB-1])
|
||||
{
|
||||
$iIndexB++;
|
||||
}
|
||||
if ($iIndexA < $iIndexB - 1)
|
||||
{
|
||||
$sResult = $sResult.$sHyphen.$aArray[$iIndexB-1];
|
||||
}
|
||||
}
|
||||
$iIndexA = $iIndexB;
|
||||
}
|
||||
return $sResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Include Keypad headers
|
||||
*/
|
||||
|
@ -5664,7 +5702,6 @@ function includeKeypad()
|
|||
function getQuotaInformation($surveyid,$language,$iQuotaID='all')
|
||||
{
|
||||
Yii::log('getQuotaInformation');
|
||||
global $clienttoken;
|
||||
$baselang = Survey::model()->findByPk($surveyid)->language;
|
||||
$aAttributes=array('sid' => $surveyid);
|
||||
if ($iQuotaID != 'all')
|
||||
|
@ -5673,7 +5710,7 @@ function getQuotaInformation($surveyid,$language,$iQuotaID='all')
|
|||
}
|
||||
|
||||
$result = Quota::model()->with(array('languagesettings' => array('condition' => "quotals_language='$language'")))->findAllByAttributes($aAttributes);
|
||||
|
||||
|
||||
$quota_info = array();
|
||||
$x=0;
|
||||
|
||||
|
@ -5687,18 +5724,8 @@ function getQuotaInformation($surveyid,$language,$iQuotaID='all')
|
|||
foreach ($result as $_survey_quotas)
|
||||
{
|
||||
$survey_quotas = array_merge($_survey_quotas->attributes,$_survey_quotas->languagesettings[0]->attributes);// We have only one language, then we can use first only
|
||||
// !!! Doubting this
|
||||
# foreach ($_survey_quotas->defaultlanguage as $k => $v)
|
||||
# $survey_quotas[$k] = $v;
|
||||
|
||||
array_push($quota_info,array('Name' => $survey_quotas['name'],
|
||||
'Limit' => $survey_quotas['qlimit'],
|
||||
'Action' => $survey_quotas['action'],
|
||||
'Message' => $survey_quotas['quotals_message'],
|
||||
'Url' => $survey_quotas['quotals_url'],
|
||||
'UrlDescrip' => $survey_quotas['quotals_urldescrip'],
|
||||
'AutoloadUrl' => $survey_quotas['autoload_url']));
|
||||
|
||||
array_push($quota_info,$survey_quotas);
|
||||
$result_qe = QuotaMember::model()->findAllByAttributes(array('quota_id'=>$survey_quotas['id']));
|
||||
$quota_info[$x]['members'] = array();
|
||||
if (count($result_qe) > 0)
|
||||
|
@ -5706,42 +5733,47 @@ function getQuotaInformation($surveyid,$language,$iQuotaID='all')
|
|||
foreach ($result_qe as $quota_entry)
|
||||
{
|
||||
$quota_entry = $quota_entry->attributes;
|
||||
$result_quest=Question::model()->findByAttributes(array('qid'=>$quota_entry['qid'], 'language'=>$baselang));
|
||||
$qtype=$result_quest->attributes;
|
||||
|
||||
$fieldnames = "0";
|
||||
|
||||
if ($qtype['type'] == "I" || $qtype['type'] == "G" || $qtype['type'] == "Y")
|
||||
$oMemberQuestion=Question::model()->findByAttributes(array('qid'=>$quota_entry['qid'], 'language'=>$baselang));
|
||||
if($oMemberQuestion)
|
||||
{
|
||||
$fieldnames=array(0 => $surveyid.'X'.$qtype['gid'].'X'.$quota_entry['qid']);
|
||||
$value = $quota_entry['code'];
|
||||
}
|
||||
$fieldname = "0";
|
||||
|
||||
if($qtype['type'] == "L" || $qtype['type'] == "O" || $qtype['type'] =="!")
|
||||
{
|
||||
$fieldnames=array(0 => $surveyid.'X'.$qtype['gid'].'X'.$quota_entry['qid']);
|
||||
$value = $quota_entry['code'];
|
||||
}
|
||||
if ($oMemberQuestion->type == "I" || $oMemberQuestion->type == "G" || $oMemberQuestion->type == "Y")
|
||||
{
|
||||
$fieldname= $surveyid.'X'.$oMemberQuestion->gid.'X'.$quota_entry['qid'];
|
||||
$value = $quota_entry['code'];
|
||||
}
|
||||
|
||||
if($qtype['type'] == "M")
|
||||
{
|
||||
$fieldnames=array(0 => $surveyid.'X'.$qtype['gid'].'X'.$quota_entry['qid'].$quota_entry['code']);
|
||||
$value = "Y";
|
||||
}
|
||||
if($oMemberQuestion->type == "L" || $oMemberQuestion->type == "O" || $oMemberQuestion->type =="!")
|
||||
{
|
||||
$fieldname=$surveyid.'X'.$oMemberQuestion->gid.'X'.$quota_entry['qid'];
|
||||
$value = $quota_entry['code'];
|
||||
}
|
||||
|
||||
if($qtype['type'] == "A" || $qtype['type'] == "B")
|
||||
{
|
||||
$temp = explode('-',$quota_entry['code']);
|
||||
$fieldnames=array(0 => $surveyid.'X'.$qtype['gid'].'X'.$quota_entry['qid'].$temp[0]);
|
||||
$value = $temp[1];
|
||||
}
|
||||
if($oMemberQuestion->type == "M")
|
||||
{
|
||||
// Need to remove invalid $quota_entry['code']
|
||||
$fieldname=$surveyid.'X'.$oMemberQuestion->gid.'X'.$quota_entry['qid'].$quota_entry['code'];
|
||||
$value = "Y";
|
||||
}
|
||||
|
||||
array_push($quota_info[$x]['members'],array('Title' => $qtype['title'],
|
||||
'type' => $qtype['type'],
|
||||
'code' => $quota_entry['code'],
|
||||
'value' => $value,
|
||||
'qid' => $quota_entry['qid'],
|
||||
'fieldnames' => $fieldnames));
|
||||
if($oMemberQuestion->type == "A" || $oMemberQuestion->type == "B")
|
||||
{
|
||||
$temp = explode('-',$quota_entry['code']);
|
||||
$fieldname=$surveyid.'X'.$oMemberQuestion->gid.'X'.$quota_entry['qid'].$temp[0];
|
||||
$value = $temp[1];
|
||||
}
|
||||
|
||||
array_push($quota_info[$x]['members'],array(
|
||||
'Title' => $oMemberQuestion->title,
|
||||
'type' => $oMemberQuestion->type,
|
||||
'code' => $quota_entry['code'],
|
||||
'value' => $value,
|
||||
'qid' => $quota_entry['qid'],
|
||||
'fieldname' => $fieldname
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
|
@ -5950,7 +5982,7 @@ function translateInsertansTags($newsid,$oldsid,$fieldnames)
|
|||
|
||||
/**
|
||||
* Replaces EM variable codes in a current survey with a new one
|
||||
*
|
||||
*
|
||||
* @param mixed $iSurveyID The survey ID
|
||||
* @param mixed $aCodeMap The codemap array (old_code=>new_code)
|
||||
*/
|
||||
|
@ -5963,12 +5995,12 @@ function replaceExpressionCodes ($iSurveyID, $aCodeMap)
|
|||
foreach ($aCodeMap as $sOldCode=>$sNewCode)
|
||||
{
|
||||
// Don't search/replace old codes that are too short or were numeric (because they would not have been usable in EM expressions anyway)
|
||||
if (strlen($sOldCode)>1 && !is_numeric($sOldCode[0]))
|
||||
if (strlen($sOldCode)>1 && !is_numeric($sOldCode[0]))
|
||||
{
|
||||
$sOldCode=preg_quote($sOldCode,'/');
|
||||
$arQuestion->relevance=preg_replace("/\b{$sOldCode}/",$sNewCode,$arQuestion->relevance,-1,$iCount);
|
||||
$arQuestion->relevance=preg_replace("~{[^}]*\K{$sOldCode}(?=[^}]*?})~",$sNewCode,$arQuestion->relevance,-1,$iCount);
|
||||
$bModified = $bModified || $iCount;
|
||||
$arQuestion->question=preg_replace("/\b{$sOldCode}/",$sNewCode,$arQuestion->question,-1,$iCount);
|
||||
$arQuestion->question=preg_replace("~{[^}]*\K{$sOldCode}(?=[^}]*?})~",$sNewCode,$arQuestion->question,-1,$iCount);
|
||||
$bModified = $bModified || $iCount;
|
||||
}
|
||||
}
|
||||
|
@ -5984,9 +6016,9 @@ function replaceExpressionCodes ($iSurveyID, $aCodeMap)
|
|||
foreach ($aCodeMap as $sOldCode=>$sNewCode)
|
||||
{
|
||||
$sOldCode=preg_quote($sOldCode,'/');
|
||||
$arGroup->grelevance=preg_replace("/\b{$sOldCode}/",$sNewCode,$arGroup->grelevance,-1,$iCount);
|
||||
$arGroup->grelevance=preg_replace("~{[^}]*\K{$sOldCode}(?=[^}]*?})~",$sNewCode,$arGroup->grelevance,-1,$iCount);
|
||||
$bModified = $bModified || $iCount;
|
||||
$arGroup->description=preg_replace("/\b{$sOldCode}/",$sNewCode,$arGroup->description,-1,$iCount);
|
||||
$arGroup->description=preg_replace("~{[^}]*\K{$sOldCode}(?=[^}]*?})~",$sNewCode,$arGroup->description,-1,$iCount);
|
||||
$bModified = $bModified || $iCount;
|
||||
}
|
||||
if ($bModified)
|
||||
|
@ -7072,7 +7104,7 @@ function getDBTableUsage($surveyid){
|
|||
$hard_limit = 1600;
|
||||
$size_limit = 0;
|
||||
}
|
||||
elseif ($arrCols['dbtype'] == 'mssql' || $arrCols['dbtype'] == 'dblib'){
|
||||
elseif ($arrCols['dbtype'] == 'mssql' || $arrCols['dbtype'] == 'dblib'){
|
||||
$hard_limit = 1024;
|
||||
$size_limit = 0;
|
||||
}
|
||||
|
@ -7109,7 +7141,7 @@ function doesImportArraySupportLanguage($csvarray,$idkeysarray,$langfieldnum,$l
|
|||
|
||||
foreach ($csvarray as $csvrow)
|
||||
{
|
||||
$rowcontents = convertCSVRowToArray($csvrow,',','"');
|
||||
$rowcontents = str_getcsv($csvrow,',','"');
|
||||
$rowid = "";
|
||||
foreach ($idkeysarray as $idfieldnum)
|
||||
{
|
||||
|
@ -7168,7 +7200,7 @@ function getSurveyUserList($bIncludeOwner=true, $bIncludeSuperAdmins=true,$surve
|
|||
if (!$bIncludeSuperAdmins)
|
||||
{
|
||||
// @todo: Adjust for new permission system - not urgent since it it just display
|
||||
// $sSurveyIDQuery.='and superadmin=0 ';
|
||||
// $sSurveyIDQuery.='and superadmin=0 ';
|
||||
}
|
||||
$sSurveyIDQuery.= 'ORDER BY a.users_name';
|
||||
$oSurveyIDResult = Yii::app()->db->createCommand($sSurveyIDQuery)->query(); //Checked
|
||||
|
@ -7248,16 +7280,32 @@ function getSurveyUserGroupList($outputformat='htmloptions',$surveyid)
|
|||
|
||||
/**
|
||||
* This function fixes the group ID and type on all subquestions
|
||||
*
|
||||
* Optimized for minimum memory usage even on huge databases
|
||||
*/
|
||||
function fixSubquestions()
|
||||
{
|
||||
$surveyidresult=Yii::app()->db->createCommand("select sq.qid, sq.parent_qid, sq.gid as sqgid, q.gid, sq.type as sqtype, q.type
|
||||
from {{questions}} sq JOIN {{questions}} q on sq.parent_qid=q.qid
|
||||
where sq.parent_qid>0 and (sq.gid!=q.gid or sq.type!=q.type)")->query();
|
||||
foreach($surveyidresult->readAll() as $sv)
|
||||
$surveyidresult=Yii::app()->db->createCommand()
|
||||
->select('sq.qid, q.gid , q.type ')
|
||||
->from('{{questions}} sq')
|
||||
->join('{{questions}} q','sq.parent_qid=q.qid')
|
||||
->where('sq.parent_qid>0 AND (sq.gid!=q.gid or sq.type!=q.type)')
|
||||
->limit(10000)
|
||||
->query();
|
||||
$aRecords=$surveyidresult->readAll();
|
||||
while (count($aRecords)>0)
|
||||
{
|
||||
Yii::app()->db->createCommand("update {{questions}} set type='{$sv['type']}', gid={$sv['gid']} where qid={$sv['qid']}")->query();
|
||||
foreach($aRecords as $sv)
|
||||
{
|
||||
Yii::app()->db->createCommand("update {{questions}} set type='{$sv['type']}', gid={$sv['gid']} where qid={$sv['qid']}")->execute();
|
||||
}
|
||||
$surveyidresult=Yii::app()->db->createCommand()
|
||||
->select('sq.qid, q.gid , q.type ')
|
||||
->from('{{questions}} sq')
|
||||
->join('{{questions}} q','sq.parent_qid=q.qid')
|
||||
->where('sq.parent_qid>0 AND (sq.gid!=q.gid or sq.type!=q.type)')
|
||||
->limit(10000)
|
||||
->query();
|
||||
$aRecords=$surveyidresult->readAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7267,6 +7315,10 @@ function fixSubquestions()
|
|||
*/
|
||||
function ls_json_encode($content)
|
||||
{
|
||||
if (is_string($content) && get_magic_quotes_gpc())
|
||||
{
|
||||
$content=stripslashes($content);
|
||||
}
|
||||
$ans = json_encode($content);
|
||||
$ans = str_replace(array('{','}'),array('{ ',' }'), $ans);
|
||||
return $ans;
|
||||
|
@ -7295,7 +7347,7 @@ function json_decode_ls($jsonString)
|
|||
* Return accepted codingsArray for importing files
|
||||
*
|
||||
* Used in vvimport
|
||||
* TODO : use in token and
|
||||
* TODO : use in token and
|
||||
* @return array
|
||||
*/
|
||||
function aEncodingsArray()
|
||||
|
@ -7467,31 +7519,70 @@ function array_diff_assoc_recursive($array1, $array2) {
|
|||
}
|
||||
|
||||
|
||||
function convertPHPSizeToBytes($sSize)
|
||||
{
|
||||
//This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
|
||||
$sSuffix = substr($sSize, -1);
|
||||
$iValue = substr($sSize, 0, -1);
|
||||
switch(strtoupper($sSuffix)){
|
||||
case 'P':
|
||||
$iValue *= 1024;
|
||||
case 'T':
|
||||
$iValue *= 1024;
|
||||
case 'G':
|
||||
$iValue *= 1024;
|
||||
case 'M':
|
||||
$iValue *= 1024;
|
||||
case 'K':
|
||||
$iValue *= 1024;
|
||||
break;
|
||||
}
|
||||
return $iValue;
|
||||
}
|
||||
|
||||
function getMaximumFileUploadSize()
|
||||
{
|
||||
return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
|
||||
}
|
||||
function convertPHPSizeToBytes($sSize)
|
||||
{
|
||||
//This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
|
||||
$sSuffix = substr($sSize, -1);
|
||||
$iValue = substr($sSize, 0, -1);
|
||||
switch(strtoupper($sSuffix)){
|
||||
case 'P':
|
||||
$iValue *= 1024;
|
||||
case 'T':
|
||||
$iValue *= 1024;
|
||||
case 'G':
|
||||
$iValue *= 1024;
|
||||
case 'M':
|
||||
$iValue *= 1024;
|
||||
case 'K':
|
||||
$iValue *= 1024;
|
||||
break;
|
||||
}
|
||||
return $iValue;
|
||||
}
|
||||
|
||||
function getMaximumFileUploadSize()
|
||||
{
|
||||
return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes token attribute data because due to bugs in the past it can be written in JSON or be serialized - future format should be JSON as serialized data can be exploited
|
||||
*
|
||||
* @param string $oTokenAttributeData The original token attributes as stored in the database
|
||||
*/
|
||||
function decodeTokenAttributes($oTokenAttributeData){
|
||||
if (trim($oTokenAttributeData)=='') return array();
|
||||
if (substr($oTokenAttributeData,0,1)!='{' && substr($oTokenAttributeData,0,1)!='[')
|
||||
{
|
||||
$sSerialType=getSerialClass($oTokenAttributeData);
|
||||
if ($sSerialType=='array') // Safe to decode
|
||||
{
|
||||
$aReturnData=@unserialize($oTokenAttributeData);
|
||||
}
|
||||
else // Something else, might be unsafe
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$aReturnData=@json_decode($oTokenAttributeData,true);
|
||||
}
|
||||
if ($aReturnData===false || $aReturnData===null) return array();
|
||||
return $aReturnData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the data type of serialized data
|
||||
*
|
||||
* @param mixed $sSerial The serialized data to examine
|
||||
*/
|
||||
function getSerialClass($sSerial) {
|
||||
$aTypes = array('s' => 'string', 'a' => 'array', 'b' => 'bool', 'i' => 'int', 'd' => 'float', 'N;' => 'NULL');
|
||||
|
||||
$aParts = explode(':', $sSerial, 4);
|
||||
return isset($aTypes[$aParts[0]]) ? $aTypes[$aParts[0]] : ( isset($aParts[2]) ? trim($aParts[2], '"') : null);
|
||||
}
|
||||
|
||||
// Closing PHP tag intentionally omitted - yes, it is okay
|
||||
|
||||
|
|
|
@ -84,12 +84,12 @@ function SPSSExportData ($iSurveyID, $iLength, $na = '', $q='\'', $header=FALSE)
|
|||
// Now see if we have parameters for from (offset) & num (limit)
|
||||
$limit = App()->getRequest()->getParam('limit');
|
||||
$offset = App()->getRequest()->getParam('offset');
|
||||
|
||||
|
||||
//Now get the query string with all fields to export
|
||||
$query = SPSSGetQuery($iSurveyID, $limit, $offset);
|
||||
|
||||
|
||||
$result = $query->query();
|
||||
|
||||
|
||||
$rownr = 0;
|
||||
|
||||
foreach ($result as $row) {
|
||||
|
@ -330,7 +330,7 @@ function SPSSGetValues ($field = array(), $qidattributes = null, $language ) {
|
|||
*/
|
||||
function SPSSFieldMap($iSurveyID, $prefix = 'V') {
|
||||
global $clang, $surveyprivate;
|
||||
|
||||
|
||||
$typeMap = array(
|
||||
'5'=>Array('name'=>'5 Point Choice','size'=>1,'SPSStype'=>'F','Scale'=>3),
|
||||
'B'=>Array('name'=>'Array (10 Point Choice)','size'=>1,'SPSStype'=>'F','Scale'=>3),
|
||||
|
@ -434,7 +434,8 @@ function SPSSFieldMap($iSurveyID, $prefix = 'V') {
|
|||
$fieldtype = 'A';
|
||||
$val_size = 255;
|
||||
} elseif ($fieldname == 'lastpage') {
|
||||
$hide = 1;
|
||||
$fieldtype = 'F';
|
||||
$val_size = 7; //Arbitrarilty restrict to 9,999,999 (7 digits) pages
|
||||
}
|
||||
|
||||
#Get qid (question id)
|
||||
|
@ -530,7 +531,7 @@ function SPSSGetQuery($iSurveyID, $limit = null, $offset = null) {
|
|||
$columns[] = 't.' . $attributefield;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query->leftJoin('{{tokens_' . $iSurveyID . '}} t', App()->db->quoteColumnName('s.token') . ' = ' . App()->db->quoteColumnName('t.token'));
|
||||
//LEFT JOIN {{tokens_$iSurveyID}} t ON ";
|
||||
}
|
||||
|
@ -545,12 +546,12 @@ function SPSSGetQuery($iSurveyID, $limit = null, $offset = null) {
|
|||
$query->where('s.submitdate IS NOT NULL');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($limit) & !is_null($offset))
|
||||
|
||||
if (!empty($limit) & !is_null($offset))
|
||||
{
|
||||
$query->limit((int) $limit, (int) $offset);
|
||||
}
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -980,7 +981,7 @@ function quexml_get_lengthth($qid,$attribute,$default, $quexmllang=false)
|
|||
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND language='$quexmllang' AND attribute='$attribute'";
|
||||
else
|
||||
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND attribute='$attribute'";
|
||||
|
||||
|
||||
//$QueryResult = mysql_query($Query) or die ("ERROR: $QueryResult<br />".mysql_error());
|
||||
$QueryResult = Yii::app()->db->createCommand($Query)->query();
|
||||
|
||||
|
@ -1275,12 +1276,12 @@ function quexml_export($surveyi, $quexmllan)
|
|||
|
||||
$question->appendChild($directive);
|
||||
}
|
||||
|
||||
|
||||
if (Yii::app()->getConfig('quexmlshowprintablehelp')==true)
|
||||
{
|
||||
|
||||
|
||||
$RowQ['printable_help']=quexml_get_lengthth($qid,"printable_help","", $quexmllang);
|
||||
|
||||
|
||||
if (!empty($RowQ['printable_help']))
|
||||
{
|
||||
$directive = $dom->createElement("directive");
|
||||
|
@ -1324,11 +1325,11 @@ function quexml_export($surveyi, $quexmllan)
|
|||
$response = $dom->createElement("response");
|
||||
$response->setAttribute("varName",QueXMLCleanup($sgq));
|
||||
$response->appendChild(QueXMLCreateFixed($qid,false,false,0,$other,$sgq));
|
||||
|
||||
|
||||
$response2 = $dom->createElement("response");
|
||||
$response2->setAttribute("varName",QueXMLCleanup($sgq) . "_comment");
|
||||
$response2->appendChild(QueXMLCreateFree("longtext","40",""));
|
||||
|
||||
|
||||
$question->appendChild($response);
|
||||
$question->appendChild($response2);
|
||||
break;
|
||||
|
@ -1428,7 +1429,7 @@ function quexml_export($surveyi, $quexmllan)
|
|||
if ($QROW['value'])
|
||||
$response->setAttribute("varName",QueXMLCleanup($QROW['value']));
|
||||
$response->appendChild(QueXMLCreateFixed($qid,false,false,0,$other,$sgq));
|
||||
|
||||
|
||||
//get the header of the second scale of the dual scale question
|
||||
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND language='$quexmllang' AND attribute='dualscale_headerB'";
|
||||
$QRE = Yii::app()->db->createCommand($Query)->query();
|
||||
|
@ -1506,10 +1507,12 @@ function concat()
|
|||
|
||||
function group_export($action, $iSurveyID, $gid)
|
||||
{
|
||||
viewHelper::disableHtmlLogging();
|
||||
|
||||
$fn = "limesurvey_group_$gid.lsg";
|
||||
$xml = getXMLWriter();
|
||||
|
||||
header("Content-Type: text/html/force-download");
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Disposition: attachment; filename=$fn");
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
@ -1576,7 +1579,7 @@ function groupGetXMLStructure($xml,$gid)
|
|||
$iSurveyID=$iSurveyID['sid'];
|
||||
$sBaseLanguage=Survey::model()->findByPk($iSurveyID)->language;
|
||||
$platform = Yii::app()->db->getDriverName();
|
||||
if ($platform == 'mssql' || $platform =='sqlsrv' || $platform =='dblib')
|
||||
if ($platform == 'mssql' || $platform =='sqlsrv' || $platform =='dblib')
|
||||
{
|
||||
$query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value, qa.language
|
||||
FROM {{question_attributes}} qa JOIN {{questions}} q ON q.qid = qa.qid AND q.sid={$iSurveyID} and q.gid={$gid}
|
||||
|
@ -1611,7 +1614,7 @@ function questionExport($action, $iSurveyID, $gid, $qid)
|
|||
$fn = "limesurvey_question_$qid.lsq";
|
||||
$xml = getXMLWriter();
|
||||
|
||||
header("Content-Type: text/html/force-download");
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Disposition: attachment; filename=$fn");
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
@ -1692,57 +1695,66 @@ function questionGetXMLStructure($xml,$gid,$qid)
|
|||
|
||||
function tokensExport($iSurveyID)
|
||||
{
|
||||
$sEmailFiter=trim(App()->request->getPost('filteremail'));
|
||||
$iTokenStatus=App()->request->getPost('tokenstatus');
|
||||
$iInvitationStatus=App()->request->getPost('invitationstatus');
|
||||
$iReminderStatus=App()->request->getPost('reminderstatus');
|
||||
$sTokenLanguage=App()->request->getPost('tokenlanguage');
|
||||
|
||||
$oSurvey=Survey::model()->findByPk($iSurveyID);
|
||||
$bIsNotAnonymous= ($oSurvey->anonymized=='N' && $oSurvey->active=='Y');// db table exist (survey_$iSurveyID) ?
|
||||
|
||||
$bquery = "SELECT * FROM {{tokens_$iSurveyID}} where 1=1";
|
||||
$databasetype = Yii::app()->db->getDriverName();
|
||||
if (trim($_POST['filteremail'])!='')
|
||||
if ($sEmailFiter!='')
|
||||
{
|
||||
if (in_array($databasetype, array('mssql', 'sqlsrv', 'dblib')))
|
||||
{
|
||||
$bquery .= ' and CAST(email as varchar) like '.dbQuoteAll('%'.$_POST['filteremail'].'%', true);
|
||||
$bquery .= ' and CAST(email as varchar) like '.dbQuoteAll('%'.$sEmailFiter.'%', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bquery .= ' and email like '.dbQuoteAll('%'.$_POST['filteremail'].'%', true);
|
||||
$bquery .= ' and email like '.dbQuoteAll('%'.$sEmailFiter.'%', true);
|
||||
}
|
||||
}
|
||||
if ($_POST['tokenstatus']==1)
|
||||
if ($iTokenStatus==1)
|
||||
{
|
||||
$bquery .= " and completed<>'N'";
|
||||
}
|
||||
if ($_POST['tokenstatus']==2)
|
||||
elseif ($iTokenStatus==2)
|
||||
{
|
||||
$bquery .= " and completed='N'";
|
||||
if ($thissurvey['anonymized']=='N')
|
||||
if ($bIsNotAnonymous)
|
||||
{
|
||||
$bquery .=" and token not in (select token from {{survey_$iSurveyID}} group by token)";
|
||||
}
|
||||
}
|
||||
if ($_POST['tokenstatus']==3 && $thissurvey['anonymized']=='N')
|
||||
if ($iTokenStatus==3 && $bIsNotAnonymous)
|
||||
{
|
||||
$bquery .= " and completed='N' and token in (select token from {{survey_$iSurveyID}} group by token)";
|
||||
}
|
||||
|
||||
if ($_POST['invitationstatus']==1)
|
||||
if ($iInvitationStatus==1)
|
||||
{
|
||||
$bquery .= " and sent<>'N'";
|
||||
}
|
||||
if ($_POST['invitationstatus']==2)
|
||||
if ($iInvitationStatus==2)
|
||||
{
|
||||
$bquery .= " and sent='N'";
|
||||
}
|
||||
|
||||
if ($_POST['reminderstatus']==1)
|
||||
if ($iReminderStatus==1)
|
||||
{
|
||||
$bquery .= " and remindersent<>'N'";
|
||||
}
|
||||
if ($_POST['reminderstatus']==2)
|
||||
if ($iReminderStatus==2)
|
||||
{
|
||||
$bquery .= " and remindersent='N'";
|
||||
}
|
||||
|
||||
if ($_POST['tokenlanguage']!='')
|
||||
if ($sTokenLanguage!='')
|
||||
{
|
||||
$bquery .= " and language=".dbQuoteAll($_POST['tokenlanguage']);
|
||||
$bquery .= " and language=".dbQuoteAll($sTokenLanguage);
|
||||
}
|
||||
$bquery .= " ORDER BY tid";
|
||||
Yii::app()->loadHelper('database');
|
||||
|
|
|
@ -227,6 +227,7 @@ class ExpressionManager {
|
|||
'sum' => array('array_sum', 'LEMsum', gT('Calculate the sum of values in an array'), 'number sum(arg1, arg2, ... argN)', '', -2),
|
||||
'sumifop' => array('exprmgr_sumifop', 'LEMsumifop', gT('Sum the values of answered questions in the list which pass the critiera (arg op value)'), 'number sumifop(op, value, arg1, arg2, ... argN)', '', -3),
|
||||
'tan' => array('tan', 'Math.tan', gT('Tangent'), 'number tan(arg)', 'http://www.php.net/manual/en/function.tan.php', 1),
|
||||
'convert_value' => array('exprmgr_convert_value', 'LEMconvert_value', gT('Convert a numerical value using a inputTable and outputTable of numerical values'), 'number convert_value(fValue, iStrict, sTranslateFromList, sTranslateToList)', '', 4),
|
||||
'time' => array('time', 'time', gT('Return current UNIX timestamp'), 'number time()', 'http://www.php.net/manual/en/function.time.php', 0),
|
||||
'trim' => array('trim', 'trim', gT('Strip whitespace (or other characters) from the beginning and end of a string'), 'string trim(string [, charlist])', 'http://www.php.net/manual/en/function.trim.php', 1,2),
|
||||
'ucwords' => array('ucwords', 'ucwords', gT('Uppercase the first character of each word in a string'), 'string ucwords(string)', 'http://www.php.net/manual/en/function.ucwords.php', 1),
|
||||
|
@ -1294,7 +1295,7 @@ class ExpressionManager {
|
|||
}
|
||||
else
|
||||
{
|
||||
$stringParts[] = is_numeric($code) ? $code : ("'" . addcslashes($code,"'") . "'"); // htmlspecialchars($code,ENT_QUOTES,'UTF-8',false) . "'");
|
||||
$stringParts[] = "'" . addcslashes($code,"'") . "'";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2576,6 +2577,52 @@ function exprmgr_sumifop($args)
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the closest matching numerical input values in a list an replace it by the
|
||||
* corresponding value within another list
|
||||
*
|
||||
* @author Johannes Weberhofer, 2013
|
||||
*
|
||||
* @param numeric $fValueToReplace
|
||||
* @param numeric $iStrict - 1 for exact matches only otherwise interpolation the
|
||||
* closest value should be returned
|
||||
* @param string $sTranslateFromList - comma seperated list of numeric values to translate from
|
||||
* @param string $sTranslateToList - comma seperated list of numeric values to translate to
|
||||
* @return numeric
|
||||
*/
|
||||
function exprmgr_convert_value($fValueToReplace, $iStrict, $sTranslateFromList, $sTranslateToList)
|
||||
{
|
||||
if ( (is_numeric($fValueToReplace)) && ($iStrict!=null) && ($sTranslateFromList!=null) && ($sTranslateToList!=null) )
|
||||
{
|
||||
$aFromValues = explode( ',', $sTranslateFromList);
|
||||
$aToValues = explode( ',', $sTranslateToList);
|
||||
if ( (count($aFromValues) > 0) && (count($aFromValues) == count($aToValues)) )
|
||||
{
|
||||
$fMinimumDiff = null;
|
||||
$iNearestIndex = 0;
|
||||
for ( $i = 0; $i < count($aFromValues); $i++) {
|
||||
if ( !is_numeric($aFromValues[$i])) {
|
||||
// break processing when non-numeric variables are about to be processed
|
||||
return null;
|
||||
}
|
||||
$fCurrentDiff = abs($aFromValues[$i] - $fValueToReplace);
|
||||
if ($fCurrentDiff === 0) {
|
||||
return $aToValues[$i];
|
||||
} else if ($i === 0) {
|
||||
$fMinimumDiff = $fCurrentDiff;
|
||||
} else if ( $fMinimumDiff > $fCurrentDiff ) {
|
||||
$fMinimumDiff = $fCurrentDiff;
|
||||
$iNearestIndex = $i;
|
||||
}
|
||||
}
|
||||
if ( $iStrict !== 1 ) {
|
||||
return $aToValues[$iNearestIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If $test is true, return $ok, else return $error
|
||||
* @param <type> $test
|
||||
|
@ -2596,14 +2643,17 @@ function exprmgr_if($test,$ok,$error)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true if the variable is an integer
|
||||
* Return true if the variable is an integer for LimeSurvey
|
||||
* Can not really use is_int due to SQL DECIMAL system
|
||||
* @param string $arg
|
||||
* @return boolean
|
||||
* @link http://php.net/is_int#82857
|
||||
*/
|
||||
function exprmgr_int($arg)
|
||||
{
|
||||
return (ctype_digit((string)$arg));// Accept empty value too before PHP 5.1 see http://php.net/ctype-digit#refsect1-function.ctype-digit-changelog
|
||||
if(strpos($arg,"."))
|
||||
$arg=preg_replace("/\.$/","",rtrim(strval($arg),"0"));// DECIMAL from SQL return always .00000000, the remove all 0 and one . , see #09550
|
||||
return (ctype_digit($arg));// Accept empty value too before PHP 5.1 see http://php.net/ctype-digit#refsect1-function.ctype-digit-changelog
|
||||
}
|
||||
/**
|
||||
* Join together $args[0-N] with ', '
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,44 +13,53 @@
|
|||
|
||||
function loadanswers()
|
||||
{
|
||||
Yii::trace('start', 'survey.loadanswers');
|
||||
global $surveyid;
|
||||
global $thissurvey, $thisstep;
|
||||
global $clienttoken;
|
||||
$clang = Yii::app()->lang;
|
||||
|
||||
$scid=returnGlobal('scid',true);
|
||||
$scid=Yii::app()->request->getQuery('scid');
|
||||
if (Yii::app()->request->getParam('loadall') == "reload")
|
||||
{
|
||||
$query = "SELECT * FROM {{saved_control}} INNER JOIN {$thissurvey['tablename']}
|
||||
ON {{saved_control}}.srid = {$thissurvey['tablename']}.id
|
||||
WHERE {{saved_control}}.sid=$surveyid\n";
|
||||
if (isset($scid)) //Would only come from email
|
||||
|
||||
$sLoadName=Yii::app()->request->getParam('loadname');
|
||||
$sLoadPass=Yii::app()->request->getParam('loadpass');
|
||||
$oCriteria= new CDbCriteria;
|
||||
$oCriteria->join="LEFT JOIN {{saved_control}} ON t.id={{saved_control}}.srid";
|
||||
$oCriteria->condition="{{saved_control}}.sid=:sid";
|
||||
$aParams=array(':sid'=>$surveyid);
|
||||
if (isset($scid)) //Would only come from email : we don't need it ....
|
||||
{
|
||||
$query .= "AND {{saved_control}}.scid={$scid}\n";
|
||||
$oCriteria->addCondition("{{saved_control}}.scid=:scid");
|
||||
$aParams[':scid']=$scid;
|
||||
}
|
||||
$query .="AND {{saved_control}}.identifier = '".autoEscape($_SESSION['survey_'.$surveyid]['holdname'])."' ";
|
||||
$oCriteria->addCondition("{{saved_control}}.identifier=:identifier");
|
||||
$aParams[':identifier']=$sLoadName;
|
||||
|
||||
if (in_array(Yii::app()->db->getDriverName(), array('mssql', 'sqlsrv', 'dblib')))
|
||||
{
|
||||
$query .="AND CAST({{saved_control}}.access_code as varchar(32))= '".md5($_SESSION['survey_'.$surveyid]['holdpass'])."'\n";
|
||||
// To be validated with mssql, think it's not needed
|
||||
$oCriteria->addCondition(" CAST({{saved_control}}.access_code as varchar(32))=:access_code");
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .="AND {{saved_control}}.access_code = '".md5($_SESSION['survey_'.$surveyid]['holdpass'])."'\n";// md5 don't need to be escaped
|
||||
$oCriteria->addCondition("{{saved_control}}.access_code=:access_code");
|
||||
}
|
||||
$aParams[':access_code']=md5($sLoadPass);
|
||||
}
|
||||
elseif (isset($_SESSION['survey_'.$surveyid]['srid']))
|
||||
{
|
||||
$query = "SELECT * FROM {$thissurvey['tablename']}
|
||||
WHERE {$thissurvey['tablename']}.id=".$_SESSION['survey_'.$surveyid]['srid']."\n";
|
||||
$oCriteria= new CDbCriteria;
|
||||
$oCriteria->condition="id=:id";
|
||||
$aParams=array(':id'=>$_SESSION['survey_'.$surveyid]['srid']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
$aRow = Yii::app()->db->createCommand($query)->queryRow();// TODO : use Yii for query
|
||||
if (!$aRow)
|
||||
$oCriteria->params=$aParams;
|
||||
$oResponses=SurveyDynamic::model($surveyid)->find($oCriteria);
|
||||
if (!$oResponses)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -59,8 +68,22 @@ function loadanswers()
|
|||
//A match has been found. Let's load the values!
|
||||
//If this is from an email, build surveysession first
|
||||
$_SESSION['survey_'.$surveyid]['LEMtokenResume']=true;
|
||||
|
||||
// If survey come from reload (GET or POST); some value need to be found on saved_control, not on survey
|
||||
if (Yii::app()->request->getParam('loadall') == "reload")
|
||||
{
|
||||
$oSavedSurvey=SavedControl::model()->find("identifier=:identifier AND access_code=:access_code",array(":identifier"=>$sLoadName,":access_code"=>md5($sLoadPass)));
|
||||
// We don't need to control if we have one, because we do the test before
|
||||
$_SESSION['survey_'.$surveyid]['scid'] = $oSavedSurvey->scid;
|
||||
$_SESSION['survey_'.$surveyid]['step'] = ($oSavedSurvey->saved_thisstep>1)?$oSavedSurvey->saved_thisstep:1;
|
||||
$thisstep=$_SESSION['survey_'.$surveyid]['step']-1;// deprecated ?
|
||||
$_SESSION['survey_'.$surveyid]['srid'] = $oSavedSurvey->srid;// Seems OK without
|
||||
$_SESSION['survey_'.$surveyid]['refurl'] = $oSavedSurvey->refurl;
|
||||
}
|
||||
|
||||
// Get if survey is been answered
|
||||
$submitdate=$aRow['submitdate'];
|
||||
$submitdate=$oResponses->submitdate;
|
||||
$aRow=$oResponses->attributes;
|
||||
foreach ($aRow as $column => $value)
|
||||
{
|
||||
if ($column == "token")
|
||||
|
@ -68,12 +91,7 @@ function loadanswers()
|
|||
$clienttoken=$value;
|
||||
$token=$value;
|
||||
}
|
||||
elseif ($column == "saved_thisstep" && $thissurvey['alloweditaftercompletion'] != 'Y' )
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['step']=($value>1? $value:1) ;
|
||||
$thisstep=$_SESSION['survey_'.$surveyid]['step']-1;
|
||||
}
|
||||
elseif ($column =='lastpage' && isset($_GET['token']))
|
||||
elseif ($column =='lastpage' && !isset($_SESSION['survey_'.$surveyid]['step']))
|
||||
{
|
||||
if(is_null($submitdate) || $submitdate=="N")
|
||||
{
|
||||
|
@ -95,14 +113,6 @@ function loadanswers()
|
|||
UpdateSessionGroupList($value); // to refresh the language strings in the group list session variable
|
||||
UpdateFieldArray(); // to refresh question titles and question text
|
||||
}*/
|
||||
elseif ($column == "scid")
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['scid']=$value;
|
||||
}
|
||||
elseif ($column == "srid")
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['srid']=$value;
|
||||
}
|
||||
elseif ($column == "datestamp")
|
||||
{
|
||||
$_SESSION['survey_'.$surveyid]['datestamp']=$value;
|
||||
|
@ -133,8 +143,8 @@ function loadanswers()
|
|||
} // if (in_array(
|
||||
} // else
|
||||
} // foreach
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function makegraph($currentstep, $total)
|
||||
|
@ -465,9 +475,9 @@ function submittokens($quotaexit=false)
|
|||
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
|
||||
|
||||
// check how many uses the token has left
|
||||
$token = Token::model($surveyid)->findByAttributes(array('token' => $clienttoken));
|
||||
$token = Token::model($surveyid)->findByAttributes(array('token' => $clienttoken));
|
||||
|
||||
if ($quotaexit==true)
|
||||
if ($quotaexit==true)
|
||||
{
|
||||
$token->completed = 'Q';
|
||||
$token->usesleft--;
|
||||
|
@ -510,7 +520,6 @@ function submittokens($quotaexit=false)
|
|||
// if($token->completed == "Y" || $token->completed == $today)
|
||||
// {
|
||||
$from = "{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
|
||||
$to = $token->email;
|
||||
$subject=$thissurvey['email_confirm_subj'];
|
||||
|
||||
$aReplacementVars=array();
|
||||
|
@ -534,7 +543,7 @@ function submittokens($quotaexit=false)
|
|||
$dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
|
||||
$numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
|
||||
$redata=array('thissurvey'=>$thissurvey);
|
||||
$subject=templatereplace($subject,$aReplacementVars,$redata);
|
||||
$subject=templatereplace($subject,$aReplacementVars,$redata,'',false,null,array(),true);
|
||||
|
||||
$subject=html_entity_decode($subject,ENT_QUOTES,$emailcharset);
|
||||
|
||||
|
@ -549,7 +558,7 @@ function submittokens($quotaexit=false)
|
|||
|
||||
$message=$thissurvey['email_confirm'];
|
||||
//$message=ReplaceFields($message, $fieldsarray, true);
|
||||
$message=templatereplace($message,$aReplacementVars,$redata);
|
||||
$message=templatereplace($message,$aReplacementVars,$redata,'',false,null,array(),true);
|
||||
if (!$ishtml)
|
||||
{
|
||||
$message=strip_tags(breakToNewline(html_entity_decode($message,ENT_QUOTES,$emailcharset)));
|
||||
|
@ -560,7 +569,8 @@ function submittokens($quotaexit=false)
|
|||
}
|
||||
|
||||
//Only send confirmation email if there is a valid email address
|
||||
if (validateEmailAddress($to)) {
|
||||
$sToAddress=validateEmailAddresses($token->email);
|
||||
if ($sToAddress) {
|
||||
$aAttachments = unserialize($thissurvey['attachments']);
|
||||
|
||||
$aRelevantAttachments = array();
|
||||
|
@ -579,7 +589,7 @@ function submittokens($quotaexit=false)
|
|||
}
|
||||
}
|
||||
}
|
||||
SendEmailMessage($message, $subject, $to, $from, $sitename, $ishtml, null, $aRelevantAttachments);
|
||||
SendEmailMessage($message, $subject, $sToAddress, $from, $sitename, $ishtml, null, $aRelevantAttachments);
|
||||
}
|
||||
// } else {
|
||||
// Leave it to send optional confirmation at closed token
|
||||
|
@ -610,7 +620,7 @@ function sendSubmitNotifications($surveyid)
|
|||
|
||||
$aReplacementVars=array();
|
||||
|
||||
if ($thissurvey['allowsave'] == "Y" && isset($_SESSION['survey_'.$surveyid]['scid']))
|
||||
if ($thissurvey['allowsave'] == "Y" && isset($_SESSION['survey_'.$surveyid]['scid']) && isset($_SESSION['survey_'.$surveyid]['holdname']))
|
||||
{
|
||||
$aReplacementVars['RELOADURL']="".Yii::app()->getController()->createUrl("/survey/index/sid/{$surveyid}/loadall/reload/scid/".$_SESSION['survey_'.$surveyid]['scid']."/loadname/".urlencode($_SESSION['survey_'.$surveyid]['holdname'])."/loadpass/".urlencode($_SESSION['survey_'.$surveyid]['holdpass'])."/lang/".urlencode($clang->langcode));
|
||||
if ($bIsHTML)
|
||||
|
@ -648,6 +658,7 @@ function sendSubmitNotifications($surveyid)
|
|||
$aRecipient=explode(";", ReplaceFields($thissurvey['emailnotificationto'],array('ADMINEMAIL' =>$thissurvey['adminemail'] ), true));
|
||||
foreach($aRecipient as $sRecipient)
|
||||
{
|
||||
$sRecipient=trim($sRecipient);
|
||||
if(validateEmailAddress($sRecipient))
|
||||
{
|
||||
$aEmailNotificationTo[]=$sRecipient;
|
||||
|
@ -666,6 +677,7 @@ function sendSubmitNotifications($surveyid)
|
|||
$aRecipient=explode(";", ReplaceFields($thissurvey['emailresponseto'],array('ADMINEMAIL' =>$thissurvey['adminemail'] ), true));
|
||||
foreach($aRecipient as $sRecipient)
|
||||
{
|
||||
$sRecipient=trim($sRecipient);
|
||||
if(validateEmailAddress($sRecipient))
|
||||
{
|
||||
$aEmailResponseTo[]=$sRecipient;
|
||||
|
@ -681,18 +693,17 @@ function sendSubmitNotifications($surveyid)
|
|||
{
|
||||
if (substr($sFieldname,0,4)=='gid_')
|
||||
{
|
||||
|
||||
$ResultTableHTML .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
|
||||
$ResultTableHTML .= "\t<tr class='printanswersgroup'><td colspan='2'>".strip_tags($fname[0])."</td></tr>\n";
|
||||
$ResultTableText .="\n{$fname[0]}\n\n";
|
||||
}
|
||||
elseif (substr($sFieldname,0,4)=='qid_')
|
||||
{
|
||||
$ResultTableHTML .= "\t<tr class='printanswersquestionhead'><td colspan='2'>{$fname[0]}</td></tr>\n";
|
||||
$ResultTableHTML .= "\t<tr class='printanswersquestionhead'><td colspan='2'>".strip_tags($fname[0])."</td></tr>\n";
|
||||
$ResultTableText .="\n{$fname[0]}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ResultTableHTML .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
|
||||
$ResultTableHTML .= "\t<tr class='printanswersquestion'><td>".strip_tags("{$fname[0]} {$fname[1]}")."</td><td class='printanswersanswertext'>".CHtml::encode($fname[2])."</td></tr>\n";
|
||||
$ResultTableText .=" {$fname[0]} {$fname[1]}: {$fname[2]}\n";
|
||||
}
|
||||
}
|
||||
|
@ -765,8 +776,8 @@ function sendSubmitNotifications($surveyid)
|
|||
}
|
||||
if (count($aEmailResponseTo)>0)
|
||||
{
|
||||
$sMessage=templatereplace($thissurvey['email_admin_responses'],$aReplacementVars,$redata,'frontend_helper[1414]',($thissurvey['anonymized'] == "Y"));
|
||||
$sSubject=templatereplace($thissurvey['email_admin_responses_subj'],$aReplacementVars,$redata,'frontend_helper[1415]',($thissurvey['anonymized'] == "Y"));
|
||||
$sMessage=templatereplace($thissurvey['email_admin_responses'],$aReplacementVars,$redata,'frontend_helper[1414]',($thissurvey['anonymized'] == "Y"),NULL, array(), true);
|
||||
$sSubject=templatereplace($thissurvey['email_admin_responses_subj'],$aReplacementVars,$redata,'frontend_helper[1415]',($thissurvey['anonymized'] == "Y"),NULL, array(), true);
|
||||
foreach ($aEmailResponseTo as $sRecipient)
|
||||
{
|
||||
if (!SendEmailMessage($sMessage, $sSubject, $sRecipient, $sFrom, $sitename, true, getBounceEmail($surveyid), $aRelevantAttachments))
|
||||
|
@ -834,6 +845,7 @@ function submitfailed($errormsg='')
|
|||
*/
|
||||
function buildsurveysession($surveyid,$preview=false)
|
||||
{
|
||||
Yii::trace('start', 'survey.buildsurveysession');
|
||||
global $secerror, $clienttoken;
|
||||
global $tokensexist;
|
||||
//global $surveyid;
|
||||
|
@ -844,7 +856,7 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
$languagechanger=makeLanguageChangerSurvey($sLangCode);
|
||||
if(!$preview)
|
||||
$preview=Yii::app()->getConfig('previewmode');
|
||||
$thissurvey = getSurveyInfo($surveyid,$sLangCode);
|
||||
$thissurvey = getSurveyInfo($surveyid,$sLangCode);
|
||||
|
||||
$_SESSION['survey_'.$surveyid]['templatename']=validateTemplateDir($thissurvey['template']);
|
||||
$_SESSION['survey_'.$surveyid]['templatepath']=getTemplatePath($_SESSION['survey_'.$surveyid]['templatename']).DIRECTORY_SEPARATOR;
|
||||
|
@ -1001,12 +1013,12 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
|
||||
//check if token actually does exist
|
||||
// check also if it is allowed to change survey after completion
|
||||
if ($thissurvey['alloweditaftercompletion'] == 'Y' ) {
|
||||
if ($thissurvey['alloweditaftercompletion'] == 'Y' ) {
|
||||
$oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken));
|
||||
} else {
|
||||
$oTokenEntry = Token::model($surveyid)->usable()->incomplete()->findByAttributes(array('token' => $clienttoken));
|
||||
}
|
||||
if (!isset($oTokenEntry))
|
||||
if (!isset($oTokenEntry))
|
||||
{
|
||||
//TOKEN DOESN'T EXIST OR HAS ALREADY BEEN USED. EXPLAIN PROBLEM AND EXIT
|
||||
|
||||
|
@ -1038,15 +1050,15 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
isset($_SESSION['survey_'.$surveyid]['secanswer']) &&
|
||||
$loadsecurity == $_SESSION['survey_'.$surveyid]['secanswer'])
|
||||
{
|
||||
if ($thissurvey['alloweditaftercompletion'] == 'Y' )
|
||||
if ($thissurvey['alloweditaftercompletion'] == 'Y' )
|
||||
{
|
||||
$oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=> $clienttoken));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oTokenEntry = Token::model($surveyid)->incomplete()->findByAttributes(array(
|
||||
'token' => $clienttoken
|
||||
));
|
||||
'token' => $clienttoken
|
||||
));
|
||||
}
|
||||
if (!isset($oTokenEntry))
|
||||
{
|
||||
|
@ -1168,26 +1180,16 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
unset($_SESSION['survey_'.$surveyid]['groupReMap']);
|
||||
$_SESSION['survey_'.$surveyid]['fieldnamesInfo'] = Array();
|
||||
|
||||
|
||||
//RL: multilingual support
|
||||
if (isset($_GET['token']) && tableExists('{{tokens_'.$surveyid.'}}'))
|
||||
{
|
||||
|
||||
//get language from token (if one exists)
|
||||
$tkquery2 = "SELECT * FROM {{tokens_".$surveyid."}} WHERE token='".$clienttoken."' AND (completed = 'N' or completed='')";
|
||||
//echo $tkquery2;
|
||||
$result = dbExecuteAssoc($tkquery2) or safeDie ("Couldn't get tokens<br />$tkquery<br />"); //Checked
|
||||
foreach ($result->readAll() as $rw)
|
||||
{
|
||||
$tklanguage=$rw['language'];
|
||||
}
|
||||
}
|
||||
// Multi lingual support order : by REQUEST, if not by Token->language else by survey default language
|
||||
if (returnGlobal('lang',true))
|
||||
{
|
||||
$language_to_set=returnGlobal('lang',true);
|
||||
} elseif (isset($tklanguage))
|
||||
}
|
||||
elseif (isset($oTokenEntry) && $oTokenEntry)
|
||||
{
|
||||
$language_to_set=$tklanguage;
|
||||
// If survey have token : we have a $oTokenEntry
|
||||
// Can use $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken)); if we move on another function : this par don't validate the token validity
|
||||
$language_to_set=$oTokenEntry->language;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1240,7 +1242,7 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
}
|
||||
|
||||
|
||||
if ($totalquestions == 0) //break out and crash if there are no questions!
|
||||
if ($totalquestions == 0) //break out and crash if there are no questions!
|
||||
{
|
||||
sendCacheHeaders();
|
||||
doHeader();
|
||||
|
@ -1263,7 +1265,7 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
}
|
||||
|
||||
//Perform a case insensitive natural sort on group name then question title of a multidimensional array
|
||||
// usort($arows, 'groupOrderThenQuestionOrder');
|
||||
// usort($arows, 'groupOrderThenQuestionOrder');
|
||||
|
||||
//3. SESSION VARIABLE - insertarray
|
||||
//An array containing information about used to insert the data into the db at the submit stage
|
||||
|
@ -1480,17 +1482,17 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
$_SESSION['survey_'.$surveyid]['insertarray'][]=$field['fieldname'];
|
||||
//fieldarray ARRAY CONTENTS -
|
||||
// [0]=questions.qid,
|
||||
// [1]=fieldname,
|
||||
// [2]=questions.title,
|
||||
// [3]=questions.question
|
||||
// [4]=questions.type,
|
||||
// [5]=questions.gid,
|
||||
// [6]=questions.mandatory,
|
||||
// [7]=conditionsexist,
|
||||
// [8]=usedinconditions
|
||||
// [8]=usedinconditions
|
||||
// [9]=used in group.php for question count
|
||||
// [10]=new group id for question in randomization group (GroupbyGroup Mode)
|
||||
// [1]=fieldname,
|
||||
// [2]=questions.title,
|
||||
// [3]=questions.question
|
||||
// [4]=questions.type,
|
||||
// [5]=questions.gid,
|
||||
// [6]=questions.mandatory,
|
||||
// [7]=conditionsexist,
|
||||
// [8]=usedinconditions
|
||||
// [8]=usedinconditions
|
||||
// [9]=used in group.php for question count
|
||||
// [10]=new group id for question in randomization group (GroupbyGroup Mode)
|
||||
|
||||
if (!isset($_SESSION['survey_'.$surveyid]['fieldarray'][$field['sid'].'X'.$field['gid'].'X'.$field['qid']]))
|
||||
{
|
||||
|
@ -1544,22 +1546,22 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
$startingValues=array();
|
||||
if (isset($_GET))
|
||||
{
|
||||
foreach ($_GET as $k=>$v)
|
||||
foreach ($_GET as $k=>$v)
|
||||
{
|
||||
if (!in_array($k,$reservedGetValues) && isset($_SESSION['survey_'.$surveyid]['fieldmap'][$k]))
|
||||
if (!in_array($k,$reservedGetValues) && isset($_SESSION['survey_'.$surveyid]['fieldmap'][$k]))
|
||||
{
|
||||
$startingValues[$k] = $v;
|
||||
}
|
||||
else
|
||||
{ // Search question codes to use those for prefilling.
|
||||
foreach($_SESSION['survey_'.$surveyid]['fieldmap'] as $sgqa => $details)
|
||||
{
|
||||
if ($details['title'] == $k)
|
||||
{
|
||||
$startingValues[$sgqa] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Search question codes to use those for prefilling.
|
||||
foreach($_SESSION['survey_'.$surveyid]['fieldmap'] as $sgqa => $details)
|
||||
{
|
||||
if ($details['title'] == $k)
|
||||
{
|
||||
$startingValues[$sgqa] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$_SESSION['survey_'.$surveyid]['startingValues']=$startingValues;
|
||||
|
@ -1598,6 +1600,7 @@ function buildsurveysession($surveyid,$preview=false)
|
|||
}
|
||||
}
|
||||
}
|
||||
Yii::trace('end', 'survey.buildsurveysession');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1881,12 +1884,12 @@ function UpdateGroupList($surveyid, $language)
|
|||
*/
|
||||
function UpdateFieldArray()
|
||||
{
|
||||
global $surveyid;
|
||||
$clang = Yii::app()->lang;
|
||||
global $surveyid;
|
||||
$clang = Yii::app()->lang;
|
||||
|
||||
if (isset($_SESSION['survey_'.$surveyid]['fieldarray']))
|
||||
{
|
||||
foreach ($_SESSION['survey_'.$surveyid]['fieldarray'] as $key => $value)
|
||||
foreach ($_SESSION['survey_'.$surveyid]['fieldarray'] as $key => $value)
|
||||
{
|
||||
$questionarray = &$_SESSION['survey_'.$surveyid]['fieldarray'][$key];
|
||||
$query = "SELECT title, question FROM {{questions}} WHERE qid=".$questionarray[0]." AND language='".$_SESSION['survey_'.$surveyid]['s_lang']."'";
|
||||
|
@ -1902,217 +1905,147 @@ function UpdateFieldArray()
|
|||
}
|
||||
|
||||
/**
|
||||
* checkQuota() returns quota information for the current survey
|
||||
* @param string $checkaction - action the function must take after completing:
|
||||
* enforce: Enforce the Quota action
|
||||
* return: Return the updated quota array from getQuotaAnswers()
|
||||
* @param string $surveyid - Survey identification number
|
||||
* @return array - nested array, Quotas->Members->Fields, includes quota status and which members matched in session.
|
||||
* checkCompletedQuota() returns matched quotas information for the current response
|
||||
* @param integer $surveyid - Survey identification number
|
||||
* @param bool $return - set to true to return information, false do the quota
|
||||
* @return array - nested array, Quotas->Members->Fields, includes quota information matched in session.
|
||||
*/
|
||||
function checkQuota($checkaction,$surveyid)
|
||||
function checkCompletedQuota($surveyid,$return=false)
|
||||
{
|
||||
global $clienttoken ;
|
||||
if (!isset($_SESSION['survey_'.$surveyid]['srid']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
$thissurvey=getSurveyInfo($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
$sTemplatePath=getTemplatePath($thissurvey['templatedir']);
|
||||
|
||||
$global_matched = false;
|
||||
$quota_info = getQuotaInformation($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
$x=0;
|
||||
|
||||
$clang = Yii::app()->lang;
|
||||
|
||||
if(count($quota_info) > 0) // Quota's have to exist
|
||||
static $aMatchedQuotas; // EM call 2 times quotas with 3 lines of php code, then use static.
|
||||
if(!$aMatchedQuotas)
|
||||
{
|
||||
// Check each quota on saved data to see if it is full
|
||||
$querycond = array();
|
||||
foreach ($quota_info as $quota)
|
||||
$aMatchedQuotas=array();
|
||||
$quota_info=$aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
// $aQuotasInfo have an 'active' key, we don't use it ?
|
||||
if(!$aQuotasInfo || empty($aQuotasInfo))
|
||||
return $aMatchedQuotas;
|
||||
// OK, we have some quota, then find if this $_SESSION have some set
|
||||
$aPostedFields = explode("|",Yii::app()->request->getPost('fieldnames','')); // Needed for quota allowing update
|
||||
foreach ($aQuotasInfo as $aQuotaInfo)
|
||||
{
|
||||
if (count($quota['members']) > 0) // Quota can't be empty
|
||||
$iMatchedAnswers=0;
|
||||
$bPostedField=false;
|
||||
// Array of field with quota array value
|
||||
$aQuotaFields=array();
|
||||
// Array of fieldnames with relevance value : EM fill $_SESSION with default value even is unrelevant (em_manager_helper line 6548)
|
||||
$aQuotaRelevantFieldnames=array();
|
||||
foreach ($aQuotaInfo['members'] as $aQuotaMember)
|
||||
{
|
||||
$fields_list = array(); // Keep a list of fields for easy reference
|
||||
$y=0;
|
||||
// We need to make the conditions for the select statement here
|
||||
unset($querycond);
|
||||
// fill the array of value and query for each fieldnames
|
||||
$fields_value_array = array();
|
||||
$fields_query_array = array();
|
||||
foreach($quota['members'] as $member)
|
||||
$aQuotaFields[$aQuotaMember['fieldname']][] = $aQuotaMember['value'];
|
||||
$aQuotaRelevantFieldnames[$aQuotaMember['fieldname']]=isset($_SESSION['survey_'.$surveyid]['relevanceStatus'][$aQuotaMember['qid']]) && $_SESSION['survey_'.$surveyid]['relevanceStatus'][$aQuotaMember['qid']];
|
||||
}
|
||||
// For each field : test if actual responses is in quota (and is relevant)
|
||||
foreach ($aQuotaFields as $sFieldName=>$aValues)
|
||||
{
|
||||
$bInQuota=isset($_SESSION['survey_'.$surveyid][$sFieldName]) && in_array($_SESSION['survey_'.$surveyid][$sFieldName],$aValues);
|
||||
if($bInQuota && $aQuotaRelevantFieldnames[$sFieldName])
|
||||
{
|
||||
foreach($member['fieldnames'] as $fieldname)
|
||||
{
|
||||
if (!in_array($fieldname,$fields_list))
|
||||
{
|
||||
$fields_list[] = $fieldname;
|
||||
$fields_value_array[$fieldname] = array();
|
||||
$fields_query_array[$fieldname] = array();
|
||||
}
|
||||
$fields_value_array[$fieldname][]=$member['value'];
|
||||
$fields_query_array[$fieldname][]= dbQuoteID($fieldname)." = '{$member['value']}'";
|
||||
}
|
||||
$iMatchedAnswers++;
|
||||
}
|
||||
|
||||
// fill the $querycond array with each fields_query grouped by fieldname
|
||||
foreach($fields_list as $fieldname)
|
||||
{
|
||||
$select_query = " ( ".implode(' OR ',$fields_query_array[$fieldname]).' )';
|
||||
$querycond[] = $select_query;
|
||||
}
|
||||
// Test if the fieldname is in the array of value in the session
|
||||
foreach($quota['members'] as $member)
|
||||
{
|
||||
foreach($member['fieldnames'] as $fieldname)
|
||||
{
|
||||
if (isset($_SESSION['survey_'.$surveyid][$fieldname]))
|
||||
{
|
||||
if (in_array($_SESSION['survey_'.$surveyid][$fieldname],$fields_value_array[$fieldname])){
|
||||
$quota_info[$x]['members'][$y]['insession'] = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
$y++;
|
||||
}
|
||||
unset($fields_query_array);unset($fields_value_array);
|
||||
|
||||
// Lets only continue if any of the quota fields is in the posted page
|
||||
$matched_fields = false;
|
||||
if (isset($_POST['fieldnames']))
|
||||
{
|
||||
$posted_fields = explode("|",$_POST['fieldnames']);
|
||||
foreach ($fields_list as $checkfield)
|
||||
{
|
||||
if (in_array($checkfield,$posted_fields))
|
||||
{
|
||||
$matched_fields = true;
|
||||
$global_matched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A field was submitted that is part of the quota
|
||||
if ($matched_fields == true)
|
||||
{
|
||||
// Check the status of the quota, is it full or not
|
||||
$sQuery = "SELECT count(id) FROM {{survey_".$surveyid."}}
|
||||
WHERE ".implode(' AND ',$querycond)." "."
|
||||
AND submitdate IS NOT NULL";
|
||||
$iRowCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
|
||||
if ($iRowCount >= $quota['Limit']) // Quota is full!!
|
||||
{
|
||||
// Now we have to check if the quota matches in the current session
|
||||
// This will let us know if this person is going to exceed the quota
|
||||
$counted_matches = 0;
|
||||
foreach($quota_info[$x]['members'] as $member)
|
||||
{
|
||||
if (isset($member['insession']) && $member['insession'] == "true") $counted_matches++;
|
||||
}
|
||||
|
||||
if($counted_matches == count($quota['members']))
|
||||
{
|
||||
// They are going to exceed the quota if data is submitted
|
||||
$quota_info[$x]['status']="matched";
|
||||
}
|
||||
else
|
||||
{
|
||||
$quota_info[$x]['status']="notmatched";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quota is no in danger of being exceeded.
|
||||
$quota_info[$x]['status']="notmatched";
|
||||
}
|
||||
if(in_array($sFieldName,$aPostedFields))// Need only one posted value
|
||||
$bPostedField=true;
|
||||
}
|
||||
// Count only needed quotas
|
||||
if($iMatchedAnswers==count($aQuotaFields) && ( $aQuotaInfo['action']!=2 || $bPostedField ) )
|
||||
{
|
||||
if((int)$aQuotaInfo['qlimit'] < 1){
|
||||
$aMatchedQuotas[]=$aQuotaInfo;
|
||||
}else{
|
||||
$iCompleted=getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);// Return a string
|
||||
if(ctype_digit($iCompleted) && ((int)$iCompleted >= (int)$aQuotaInfo['qlimit'])) // This remove invalid quota and not completed
|
||||
$aMatchedQuotas[]=$aQuotaInfo;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ($return)
|
||||
return $aMatchedQuotas;
|
||||
if(empty($aMatchedQuotas))
|
||||
return;
|
||||
|
||||
// Now we have all the information we need about the quotas and their status.
|
||||
// Lets see what we should do now
|
||||
if ($checkaction == 'return')
|
||||
// We need to construct the page and do all needed action
|
||||
$aSurveyInfo=getSurveyInfo($surveyid, $_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
$sTemplatePath=getTemplatePath($aSurveyInfo['templatedir']);
|
||||
$sClientToken=isset($_SESSION['survey_'.$surveyid]['token'])?$_SESSION['survey_'.$surveyid]['token']:"";// {TOKEN} is take by $redata ...
|
||||
|
||||
// $redata for templatereplace
|
||||
$aDataReplacement = array(
|
||||
'thissurvey'=>$aSurveyInfo,
|
||||
'clienttoken'=>$sClientToken,
|
||||
'token'=>$sClientToken,
|
||||
);
|
||||
// We take only the first matched quota, no need for each
|
||||
$aMatchedQuota=$aMatchedQuotas[0];
|
||||
// If a token is used then mark the token as completed, do it before event : this allow plugin to update token information
|
||||
$event = new PluginEvent('afterSurveyQuota');
|
||||
$event->set('surveyId', $surveyid);
|
||||
$event->set('responseId', $_SESSION['survey_'.$surveyid]['srid']);// We allways have a responseId
|
||||
$event->set('aMatchedQuotas', $aMatchedQuotas);// Give all the matched quota : the first is the active
|
||||
App()->getPluginManager()->dispatchEvent($event);
|
||||
$blocks = array();
|
||||
foreach ($event->getAllContent() as $blockData)
|
||||
{
|
||||
return $quota_info;
|
||||
/* @var $blockData PluginEventContent */
|
||||
$blocks[] = CHtml::tag('div', array('id' => $blockData->getCssId(), 'class' => $blockData->getCssClass()), $blockData->getContent());
|
||||
}
|
||||
elseif ($global_matched == true && $checkaction == 'enforce')
|
||||
// Allow plugin to update message, url, url description and action
|
||||
$sMessage=$event->get('message',$aMatchedQuota['quotals_message']);
|
||||
$sUrl=$event->get('url',$aMatchedQuota['quotals_url']);
|
||||
$sUrlDescription=$event->get('urldescrip',$aMatchedQuota['quotals_urldescrip']);
|
||||
$sAction=$event->get('action',$aMatchedQuota['action']);
|
||||
$sAutoloadUrl=$event->get('autoloadurl',$aMatchedQuota['autoload_url']);
|
||||
// Construct the default message
|
||||
$sMessage = templatereplace($sMessage,array(),$aDataReplacement, 'QuotaMessage', $aSurveyInfo['anonymized']!='N', NULL, array(), true );
|
||||
$sUrl = passthruReplace($sUrl, $aSurveyInfo);
|
||||
$sUrl = templatereplace($sUrl,array(),$aDataReplacement, 'QuotaUrl', $aSurveyInfo['anonymized']!='N', NULL, array(), true );
|
||||
$sUrlDescription = templatereplace($sUrlDescription,array(),$aDataReplacement, 'QuotaUrldescription', $aSurveyInfo['anonymized']!='N', NULL, array(), true );
|
||||
// Doing the action and show the page
|
||||
if ($sAction == "1" && $sClientToken)
|
||||
submittokens(true);
|
||||
|
||||
// Construction of default message inside quotamessage class
|
||||
$quotaMessage = "<div class='quotamessage limesurveycore'>\n";
|
||||
$quotaMessage.= "\t".$sMessage."\n";
|
||||
if($sUrl)
|
||||
$quotaMessage.= "<br /><br />\t<a href='".$sUrl."'>".$sUrlDescription."</a><br />\n";
|
||||
// Add the navigator with Previous button if quota allow modification.
|
||||
if ($sAction == "2")
|
||||
{
|
||||
// Need to add Quota action enforcement here.
|
||||
reset($quota_info);
|
||||
$sQuotaStep= isset($_SESSION['survey_'.$surveyid]['step'])?$_SESSION['survey_'.$surveyid]['step']:0; // Surely not needed
|
||||
$sNavigator = CHtml::htmlButton(gT("Previous"),array('type'=>'submit','id'=>"moveprevbtn",'value'=>$sQuotaStep,'name'=>'move','accesskey'=>'p','class'=>"submit button"));
|
||||
$quotaMessage.= CHtml::form(array("/survey/index"), 'post', array('id'=>'limesurvey','name'=>'limesurvey'));
|
||||
$quotaMessage.= templatereplace(file_get_contents($sTemplatePath."/navigator.pstpl"),array('NAVIGATOR'=>$sNavigator,'SAVE'=>''),$aDataReplacement);
|
||||
$quotaMessage.= CHtml::hiddenField('sid',$surveyid);
|
||||
$quotaMessage.= CHtml::hiddenField('token',$sClientToken);// Did we really need it ?
|
||||
$quotaMessage.= CHtml::endForm();
|
||||
}
|
||||
$quotaMessage.= "</div>\n";
|
||||
// Add the plugin message before default message
|
||||
$quotaMessage = implode("\n", $blocks) ."\n". $quotaMessage;
|
||||
|
||||
$tempmsg ="";
|
||||
$found = false;
|
||||
$redata = compact(array_keys(get_defined_vars()));
|
||||
foreach($quota_info as $quota)
|
||||
{
|
||||
$quota['Message'] = templatereplace($quota['Message'],array(),$redata);
|
||||
$quota['Url'] = passthruReplace($quota['Url'], $thissurvey);
|
||||
$quota['Url'] = templatereplace($quota['Url'],array(),$redata);
|
||||
$quota['UrlDescrip'] = templatereplace($quota['UrlDescrip'],array(),$redata);
|
||||
if ((isset($quota['status']) && $quota['status'] == "matched") && (isset($quota['Action']) && $quota['Action'] == "1"))
|
||||
{
|
||||
// If a token is used then mark the token as completed
|
||||
if (isset($clienttoken) && $clienttoken)
|
||||
{
|
||||
submittokens(true);
|
||||
}
|
||||
|
||||
sendCacheHeaders();
|
||||
if($quota['AutoloadUrl'] == 1 && $quota['Url'] != "")
|
||||
{
|
||||
header("Location: ".$quota['Url']);
|
||||
killSurveySession($surveyid);
|
||||
}
|
||||
doHeader();
|
||||
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper[2617]');
|
||||
echo "\t<div class='quotamessage'>\n";
|
||||
echo "\t".$quota['Message']."<br /><br />\n";
|
||||
echo "\t<a href='".$quota['Url']."'>".$quota['UrlDescrip']."</a><br />\n";
|
||||
echo "\t</div>\n";
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper[2622]');
|
||||
doFooter();
|
||||
// Send page to user and end.
|
||||
sendCacheHeaders();
|
||||
if($sAutoloadUrl == 1 && $sUrl != "")
|
||||
{
|
||||
if ($sAction == "1")
|
||||
killSurveySession($surveyid);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ((isset($quota['status']) && $quota['status'] == "matched") && (isset($quota['Action']) && $quota['Action'] == "2"))
|
||||
{
|
||||
|
||||
sendCacheHeaders();
|
||||
doHeader();
|
||||
|
||||
$redata = compact(array_keys(get_defined_vars()));
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper[2634]');
|
||||
echo "\t<div class='quotamessage'>\n";
|
||||
echo "\t".$quota['Message']."<br /><br />\n";
|
||||
echo "\t<a href='".$quota['Url']."'>".$quota['UrlDescrip']."</a><br />\n";
|
||||
echo CHtml::form(array("/survey/index"), 'post', array('id'=>'limesurvey','name'=>'limesurvey'))."
|
||||
<input type='hidden' name='move' value='movenext' id='movenext' />
|
||||
<button class='nav-button nav-button-icon-left ui-corner-all' class='submit' accesskey='p' onclick=\"javascript:document.limesurvey.move.value = 'moveprev'; document.limesurvey.submit();\" id='moveprevbtn'>".$clang->gT("Previous")."</button>
|
||||
<input type='hidden' name='thisstep' value='".($_SESSION['survey_'.$surveyid]['step'])."' id='thisstep' />
|
||||
<input type='hidden' name='sid' value='".returnGlobal('sid',true)."' id='sid' />
|
||||
<input type='hidden' name='token' value='".$clienttoken."' id='token' />
|
||||
</form>\n";
|
||||
echo "\t</div>\n";
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper[2644]');
|
||||
doFooter();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown value
|
||||
return false;
|
||||
header("Location: ".$sUrl);
|
||||
}
|
||||
|
||||
doHeader();
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$aDataReplacement);
|
||||
echo $quotaMessage;
|
||||
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$aDataReplacement);
|
||||
doFooter();
|
||||
if ($sAction == "1")
|
||||
killSurveySession($surveyid);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2163,21 +2096,14 @@ function GetReferringUrl()
|
|||
// read it from server variable
|
||||
if(isset($_SERVER["HTTP_REFERER"]))
|
||||
{
|
||||
if(!preg_match('/'.$_SERVER["SERVER_NAME"].'/', $_SERVER["HTTP_REFERER"]))
|
||||
if (!Yii::app()->getConfig('strip_query_from_referer_url'))
|
||||
{
|
||||
if (!Yii::app()->getConfig('strip_query_from_referer_url'))
|
||||
{
|
||||
return $_SERVER["HTTP_REFERER"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
|
||||
return $aRefurl[0];
|
||||
}
|
||||
return $_SERVER["HTTP_REFERER"];
|
||||
}
|
||||
else
|
||||
{
|
||||
return '-';
|
||||
$aRefurl = explode("?",$_SERVER["HTTP_REFERER"]);
|
||||
return $aRefurl[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2191,7 +2117,7 @@ function GetReferringUrl()
|
|||
*/
|
||||
function display_first_page() {
|
||||
global $token, $surveyid, $thissurvey, $navigator;
|
||||
$totalquestions = $_SESSION['survey_'.$surveyid]['totalquestions'];
|
||||
$totalquestions = $_SESSION['survey_'.$surveyid]['totalquestions'];
|
||||
|
||||
$clang = Yii::app()->lang;
|
||||
|
||||
|
@ -2296,7 +2222,6 @@ function SetSurveyLanguage($surveyid, $language)
|
|||
$clang = new limesurvey_lang($_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
$thissurvey=getSurveyInfo($surveyid, @$_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
Yii::app()->loadHelper('surveytranslator');
|
||||
$_SESSION['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat'],$_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
LimeExpressionManager::SetEMLanguage($_SESSION['survey_'.$surveyid]['s_lang']);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -36,8 +36,7 @@ class pdfHelper
|
|||
{
|
||||
$pdffont=PDF_FONT_NAME_DATA;
|
||||
}
|
||||
$pdfcorefont=array("courier","helvetica","symbol","times","zapfdingbats");
|
||||
$pdffontsize=Yii::app()->getConfig('pdffontsize');
|
||||
$pdfcorefont=array("freesans","dejavusans","courier","helvetica","freemono","symbol","times","zapfdingbats");
|
||||
if (in_array($pdffont,$pdfcorefont))
|
||||
{
|
||||
$alternatepdffontfile=Yii::app()->getConfig('alternatepdffontfile');
|
||||
|
@ -46,6 +45,7 @@ class pdfHelper
|
|||
$pdffont = $alternatepdffontfile[$language];// Actually use only core font
|
||||
}
|
||||
}
|
||||
$pdffontsize=Yii::app()->getConfig('pdffontsize');
|
||||
if ($pdffontsize=='auto')
|
||||
{
|
||||
$pdffontsize=PDF_FONT_SIZE_MAIN;
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -221,6 +221,42 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
|
|||
|
||||
if (isset($question) && is_array($question))
|
||||
{
|
||||
$question['sgq'] = (isset($question['sgq']) ? $question['sgq'] : '');
|
||||
if($question['sgq'])
|
||||
list($question['sid'],$question['gid'],$question['qid'])=explode("X",$question['sgq']);
|
||||
else
|
||||
list($question['sid'],$question['gid'],$question['qid'])=array('','','');
|
||||
$question['aid']= (isset($question['aid']) ? $question['aid'] : '');
|
||||
/**
|
||||
* This event fires before each question is rendered.
|
||||
* Currenty 3 parameters are set:
|
||||
* @param string text The question text
|
||||
* @param string class The class for div around the whole question
|
||||
* @param string help The help text
|
||||
*/
|
||||
$event = new PluginEvent('beforeQuestionRender');
|
||||
$event->set('surveyId', $question['sid']);// or $thissurvey['sid']
|
||||
$event->set('text', $question['text']);
|
||||
$event->set('class', $question['class']);
|
||||
$event->set('help', $question['help']);
|
||||
$event->set('type', $question['type']);
|
||||
$event->set('code', $question['code']);
|
||||
$event->set('qid', $question['qid']);
|
||||
$event->set('gid', $question['gid']);
|
||||
|
||||
$event->set('answers',isset($answer) ? $answer : null);
|
||||
$event->set('questionhelp',isset($help) ? $help : null);
|
||||
|
||||
App()->getPluginManager()->dispatchEvent($event);
|
||||
$question['text'] = $event->get('text');
|
||||
$question['class'] = $event->get('class');
|
||||
$question['help'] = $event->get('help');
|
||||
$question['mandatory'] = $event->get('mandatory',$question['mandatory']);
|
||||
$question['answers'] = $event->get('answers');
|
||||
$question['questionhelp'] = $event->get('questionhelp');
|
||||
|
||||
// answer part ?
|
||||
// $answer is set with answer part
|
||||
$_question = $question['all'];
|
||||
$_question_text = $question['text'];
|
||||
$_question_help = $question['help'];
|
||||
|
@ -228,7 +264,6 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
|
|||
$_question_man_message = $question['man_message'];
|
||||
$_question_valid_message = $question['valid_message'];
|
||||
$_question_file_valid_message = $question['file_valid_message'];
|
||||
$question['sgq'] = (isset($question['sgq']) ? $question['sgq'] : '');
|
||||
$_question_essentials = $question['essentials'];
|
||||
$_getQuestionClass = $question['class'];
|
||||
$_question_man_class = $question['man_class'];
|
||||
|
@ -236,11 +271,6 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
|
|||
$_question_number = $question['number'];
|
||||
$_question_code = $question['code'];
|
||||
$_question_type = $question['type'];
|
||||
if($question['sgq']) // Not sure it can happen today ? But if set : allways sXgXq
|
||||
list($question['sid'],$question['gid'],$question['qid'])=explode("X",$question['sgq']);
|
||||
else
|
||||
list($question['sid'],$question['gid'],$question['qid'])=array('','','');
|
||||
$question['aid']= (isset($question['aid']) ? $question['aid'] : '');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -393,8 +423,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
|
|||
{
|
||||
$_saveall = "";
|
||||
}
|
||||
|
||||
if(!isset($help)) $help = "";
|
||||
$help= isset($question['questionhelp']) ? $question['questionhelp'] : isset($help) ? $help : "";
|
||||
if (flattenText($help, true,true) != '')
|
||||
{
|
||||
if (!isset($helpicon))
|
||||
|
@ -703,7 +732,7 @@ EOD;
|
|||
$coreReplacements = array();
|
||||
$coreReplacements['ACTIVE'] = (isset($thissurvey['active']) && !($thissurvey['active'] != "Y"));
|
||||
$coreReplacements['AID'] = $question['aid'];
|
||||
$coreReplacements['ANSWER'] = isset($answer) ? $answer : ''; // global
|
||||
$coreReplacements['ANSWER'] = isset($question['answers']) ? $question['answers'] : (isset($answer) ? $answer : '');
|
||||
$coreReplacements['ANSWERSCLEARED'] = $clang->gT("Answers cleared");
|
||||
$coreReplacements['ASSESSMENTS'] = $assessmenthtml;
|
||||
$coreReplacements['ASSESSMENT_CURRENT_TOTAL'] = $_assessment_current_total;
|
||||
|
@ -760,7 +789,7 @@ EOD;
|
|||
$coreReplacements['SAVEERROR'] = isset($errormsg) ? $errormsg : ''; // global - same as LOADERROR
|
||||
$coreReplacements['SAVEFORM'] = $_saveform;
|
||||
$coreReplacements['SAVEHEADING'] = $clang->gT("Save your unfinished survey");
|
||||
$coreReplacements['SAVEMESSAGE'] = $clang->gT("Enter a name and password for this survey and click save below.")."<br />\n".$clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.")."<br /><br />\n".$clang->gT("If you give an email address, an email containing the details will be sent to you.")."<br /><br />\n".$clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey.");
|
||||
$coreReplacements['SAVEMESSAGE'] = $clang->gT("Enter a name and password for this survey and click save below.")."<br />\n".$clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.")."<br /><br /><span class='emailoptional'>\n".$clang->gT("If you give an email address, an email containing the details will be sent to you.")."</span><br /><br />\n".$clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey.");
|
||||
$coreReplacements['SGQ'] = $question['sgq'];
|
||||
$coreReplacements['SID'] = Yii::app()->getConfig('surveyID','');// Allways use surveyID from config
|
||||
$coreReplacements['SITENAME'] = isset($sitename) ? $sitename : ''; // global
|
||||
|
|
|
@ -139,7 +139,7 @@ function sanitize_filename($string, $force_lowercase = true, $alphanumeric = fal
|
|||
* $alphanumeric - If set to *true*, will remove all non-alphanumeric characters.
|
||||
*/
|
||||
|
||||
function sanitize_dirname($string, $force_lowercase = true, $alphanumeric = false) {
|
||||
function sanitize_dirname($string, $force_lowercase = false, $alphanumeric = false) {
|
||||
$string = str_replace(".", "", $string);
|
||||
return sanitize_filename($string, $force_lowercase, $alphanumeric);
|
||||
}
|
||||
|
|
|
@ -364,6 +364,13 @@
|
|||
$supportedLanguages['ja']['dateformat'] = 6;
|
||||
$supportedLanguages['ja']['radixpoint'] = 0;
|
||||
|
||||
// Kazakh
|
||||
$supportedLanguages['kk']['description'] = $clang->gT('Kazakh');
|
||||
$supportedLanguages['kk']['nativedescription'] = 'Qazaqşa';
|
||||
$supportedLanguages['kk']['rtl'] = false;
|
||||
$supportedLanguages['kk']['dateformat'] = 1;
|
||||
$supportedLanguages['kk']['radixpoint'] = 1;
|
||||
|
||||
// Kinyarwanda
|
||||
$supportedLanguages['rw']['description'] = $clang->gT('Kinyarwanda');
|
||||
$supportedLanguages['rw']['nativedescription'] = 'Kinyarwanda';
|
||||
|
@ -382,10 +389,16 @@
|
|||
$supportedLanguages['ckb']['description'] = $clang->gT('Kurdish (Sorani)');
|
||||
$supportedLanguages['ckb']['nativedescription'] = 'کوردیی ناوەندی';
|
||||
$supportedLanguages['ckb']['rtl'] = true;
|
||||
$supportedLanguages['ckb']['dateformat'] = 1;
|
||||
$supportedLanguages['ckb']['dateformat'] = 1;
|
||||
$supportedLanguages['ckb']['radixpoint'] = 1;
|
||||
|
||||
|
||||
// Kyrgyz
|
||||
$supportedLanguages['ky']['description'] = $clang->gT('Kyrgyz');
|
||||
$supportedLanguages['ky']['nativedescription'] = 'Кыргызча';
|
||||
$supportedLanguages['ky']['rtl'] = false;
|
||||
$supportedLanguages['ky']['dateformat'] = 1;
|
||||
$supportedLanguages['ky']['radixpoint'] = 1;
|
||||
|
||||
// Lithuanian
|
||||
$supportedLanguages['lt']['description'] = $clang->gT('Lithuanian');
|
||||
$supportedLanguages['lt']['nativedescription'] = 'Lietuvių';
|
||||
|
@ -491,6 +504,13 @@
|
|||
$supportedLanguages['pl']['dateformat'] = 1;
|
||||
$supportedLanguages['pl']['radixpoint'] = 1;
|
||||
|
||||
// Polish
|
||||
$supportedLanguages['pl']['description'] = $clang->gT('Polish (Informal)');
|
||||
$supportedLanguages['pl']['nativedescription'] = 'Polski (nieformalny)';
|
||||
$supportedLanguages['pl']['rtl'] = false;
|
||||
$supportedLanguages['pl']['dateformat'] = 1;
|
||||
$supportedLanguages['pl']['radixpoint'] = 1;
|
||||
|
||||
// Portuguese
|
||||
$supportedLanguages['pt']['description'] = $clang->gT('Portuguese');
|
||||
$supportedLanguages['pt']['nativedescription'] = 'Português';
|
||||
|
|
|
@ -231,7 +231,7 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
// copy assessment link to message since from now on we will have HTML assignment messages
|
||||
$oDB->createCommand("UPDATE {{assessments}} set message=replace(message,'/''','''')||'<br /><a href=\"'||link||'\">'||link||'</a>'")->execute();
|
||||
break;
|
||||
default: die('Unkown database type');
|
||||
default: die('Unknown database type');
|
||||
}
|
||||
// activate assessment where assessment rules exist
|
||||
$oDB->createCommand("UPDATE {{surveys}} SET assessments='Y' where sid in (SELECT sid FROM {{assessments}} group by sid)")->execute();
|
||||
|
@ -509,7 +509,8 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
alterColumn('{{questions}}','parent_qid','integer',false ,'0');
|
||||
alterColumn('{{questions}}','title',"{$sVarchar}(20)",false , '');
|
||||
alterColumn('{{questions}}','question',"text",false);
|
||||
try{ $oDB->createCommand()->dropIndex('questions_idx4','{{questions}}');} catch(Exception $e){};
|
||||
try { setTransactionBookmark(); $oDB->createCommand()->dropIndex('questions_idx4','{{questions}}'); } catch(Exception $e) { rollBackToTransactionBookmark();}
|
||||
|
||||
alterColumn('{{questions}}','type',"{$sVarchar}(1)",false , 'T');
|
||||
try{ $oDB->createCommand()->createIndex('questions_idx4','{{questions}}','type');} catch(Exception $e){};
|
||||
alterColumn('{{questions}}','other',"{$sVarchar}(1)",false , 'N');
|
||||
|
@ -676,10 +677,8 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
'date_created' => 'datetime NOT NULL'
|
||||
));
|
||||
addPrimaryKey('survey_links', array('participant_id','token_id','survey_id'));
|
||||
|
||||
// Add language field to question_attributes table
|
||||
addColumn('{{question_attributes}}','language',"{$sVarchar}(20)");
|
||||
|
||||
upgradeQuestionAttributes148();
|
||||
fixSubquestions();
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>148),"stg_name='DBVersion'");
|
||||
|
@ -1016,6 +1015,7 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
LimeExpressionManager::UpgradeConditionsToRelevance();
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>158),"stg_name='DBVersion'");
|
||||
}
|
||||
|
||||
if ($iOldDBVersion < 159)
|
||||
{
|
||||
alterColumn('{{failed_login_attempts}}', 'ip', "{$sVarchar}(40)",false);
|
||||
|
@ -1099,8 +1099,8 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
dropColumn('{{users}}','superadmin');
|
||||
dropColumn('{{users}}','configurator');
|
||||
dropColumn('{{users}}','manage_template');
|
||||
dropColumn('{{users}}','manage_label');
|
||||
dropColumn('{{users}}','participant_panel');
|
||||
dropColumn('{{users}}','manage_label');
|
||||
dropColumn('{{users}}','participant_panel');
|
||||
$oDB->createCommand()->dropTable('{{templates_rights}}');
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>166),"stg_name='DBVersion'");
|
||||
}
|
||||
|
@ -1160,14 +1160,14 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
case 'pgsql':
|
||||
addColumn('{{sessions}}', 'data', 'BYTEA');
|
||||
break;
|
||||
default: die('Unkown database type');
|
||||
default: die('Unknown database type');
|
||||
}
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>171),"stg_name='DBVersion'");
|
||||
}
|
||||
if ($iOldDBVersion < 172)
|
||||
{
|
||||
switch ($sDBDriverName){
|
||||
case 'pgsql':
|
||||
case 'pgsql':
|
||||
// Special treatment for Postgres as it is too dumb to convert a string to a number without explicit being told to do so ... seriously?
|
||||
alterColumn('{{permissions}}', 'entity_id', "INTEGER USING (entity_id::integer)", false);
|
||||
break;
|
||||
|
@ -1179,9 +1179,9 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
alterColumn('{{permissions}}', 'entity_id', "INTEGER", false);
|
||||
$oDB->createCommand()->createIndex('permissions_idx2','{{permissions}}','entity_id,entity,permission,uid',true);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
alterColumn('{{permissions}}', 'entity_id', "INTEGER", false);
|
||||
}
|
||||
}
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>172),"stg_name='DBVersion'");
|
||||
}
|
||||
if ($iOldDBVersion < 173)
|
||||
|
@ -1207,7 +1207,7 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
if ($iOldDBVersion < 175)
|
||||
{
|
||||
switch ($sDBDriverName){
|
||||
case 'pgsql':
|
||||
case 'pgsql':
|
||||
// Special treatment for Postgres as it is too dumb to convert a boolean to a number without explicit being told to do so
|
||||
alterColumn('{{plugins}}', 'active', "INTEGER USING (active::integer)", false);
|
||||
break;
|
||||
|
@ -1231,7 +1231,7 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
$plugin = new Plugin();
|
||||
$plugin->name = 'Authwebserver';
|
||||
$plugin->active = 1;
|
||||
$plugin->save();
|
||||
$plugin->save();
|
||||
$plugin = App()->getPluginManager()->loadPlugin('Authwebserver', $plugin->id);
|
||||
$aPluginSettings = $plugin->getPluginSettings(true);
|
||||
$aDefaultSettings = array();
|
||||
|
@ -1250,11 +1250,18 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
upgradeSurveys177();
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>177),"stg_name='DBVersion'");
|
||||
}
|
||||
|
||||
if ($iOldDBVersion < 178)
|
||||
{
|
||||
if ($sDBDriverName=='mysql' || $sDBDriverName=='mysqli')
|
||||
{
|
||||
modifyPrimaryKey('questions', array('qid','language'));
|
||||
}
|
||||
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>178),"stg_name='DBVersion'");
|
||||
}
|
||||
|
||||
$oTransaction->commit();
|
||||
// Activate schema caching
|
||||
$oDB->schemaCachingDuration=3600;
|
||||
$oDB->schemaCachingDuration=3600;
|
||||
// Load all tables of the application in the schema
|
||||
Yii::app()->db->schema->getTables();
|
||||
// clear the cache of all loaded tables
|
||||
|
@ -1264,7 +1271,7 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
{
|
||||
$oTransaction->rollback();
|
||||
// Activate schema caching
|
||||
$oDB->schemaCachingDuration=3600;
|
||||
$oDB->schemaCachingDuration=3600;
|
||||
// Load all tables of the application in the schema
|
||||
Yii::app()->db->schema->getTables();
|
||||
// clear the cache of all loaded tables
|
||||
|
@ -1280,23 +1287,26 @@ function db_upgrade_all($iOldDBVersion) {
|
|||
|
||||
function upgradeSurveys177()
|
||||
{
|
||||
$sSurveyQuery = "SELECT * FROM {{surveys_languagesettings}}";
|
||||
$sSurveyQuery = "SELECT surveyls_attributecaptions,surveyls_survey_id,surveyls_language FROM {{surveys_languagesettings}}";
|
||||
$oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll();
|
||||
$sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=:surveyid and surveyls_language=:language";
|
||||
foreach ( $oSurveyResult as $aSurveyRow )
|
||||
{
|
||||
$aAttributeDescriptions=@unserialize($aSurveyRow['surveyls_attributecaptions']);
|
||||
if ($aAttributeDescriptions==NULL) $aAttributeDescriptions=array();
|
||||
$sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=".$aSurveyRow['surveyls_survey_id'].' and surveyls_language=:language';
|
||||
Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute(array(':language'=>$aSurveyRow['surveyls_language'],':attributecaptions'=>json_encode($aAttributeDescriptions)));
|
||||
if (!$aAttributeDescriptions) $aAttributeDescriptions=array();
|
||||
Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute(
|
||||
array(':language'=>$aSurveyRow['surveyls_language'],
|
||||
':surveyid'=>$aSurveyRow['surveyls_survey_id'],
|
||||
':attributecaptions'=>json_encode($aAttributeDescriptions)));
|
||||
}
|
||||
$sSurveyQuery = "SELECT * FROM {{surveys}}";
|
||||
$sSurveyQuery = "SELECT sid,attributedescriptions FROM {{surveys}}";
|
||||
$oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll();
|
||||
$sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=:surveyid";
|
||||
foreach ( $oSurveyResult as $aSurveyRow )
|
||||
{
|
||||
$aAttributeDescriptions=@unserialize($aSurveyRow['attributedescriptions']);
|
||||
if ($aAttributeDescriptions==NULL) $aAttributeDescriptions=array();
|
||||
$sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=".$aSurveyRow['sid'];
|
||||
Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions)));
|
||||
if (!$aAttributeDescriptions) $aAttributeDescriptions=array();
|
||||
Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions),':surveyid'=>$aSurveyRow['sid']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1304,7 +1314,7 @@ function upgradeSurveys177()
|
|||
|
||||
/**
|
||||
* This function removes the old CPDB fields in token tables
|
||||
* replaces them with standard attribute fields
|
||||
* replaces them with standard attribute fields
|
||||
* and records the mapping information in the attributedescription field in the survey table instead
|
||||
*/
|
||||
function upgradeTokens176()
|
||||
|
@ -1335,11 +1345,12 @@ function upgradeTokens176()
|
|||
$aAttributes[$sNewName]['cpdbmap']=substr($sColumnName,15);
|
||||
unset($aAttributes[$sColumnName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Survey::model()->updateByPk($arSurvey->sid, array('attributedescriptions' => serialize($aAttributes)));
|
||||
}
|
||||
}
|
||||
unset($arSurveys);
|
||||
// Now fix all 'old' token tables
|
||||
$aTables = dbGetTablesLike("%old_tokens%");
|
||||
foreach ( $aTables as $sTable )
|
||||
|
@ -1356,7 +1367,7 @@ function upgradeTokens176()
|
|||
$sNewName='attribute_'.$i;
|
||||
$aColumnNames[]=$sNewName;
|
||||
Yii::app()->db->createCommand()->renameColumn($sTable,$sColumnName,$sNewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1374,7 +1385,7 @@ function upgradeCPDBAttributeDefaultNames173()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Converts global permissions from users table to the new permission system,
|
||||
* and converts template permissions from template_rights to new permission table
|
||||
*/
|
||||
|
@ -1416,7 +1427,7 @@ function upgradePermissions166()
|
|||
$oPermission->permission='superadmin';
|
||||
$oPermission->read_p=1;
|
||||
$oPermission->save();
|
||||
}
|
||||
}
|
||||
if ($oUser->configurator==1)
|
||||
{
|
||||
$oPermission=new Permission;
|
||||
|
@ -1427,7 +1438,7 @@ function upgradePermissions166()
|
|||
$oPermission->update_p=1;
|
||||
$oPermission->read_p=1;
|
||||
$oPermission->save();
|
||||
}
|
||||
}
|
||||
if ($oUser->manage_template==1)
|
||||
{
|
||||
$oPermission=new Permission;
|
||||
|
@ -1442,7 +1453,7 @@ function upgradePermissions166()
|
|||
$oPermission->import_p=1;
|
||||
$oPermission->export_p=1;
|
||||
$oPermission->save();
|
||||
}
|
||||
}
|
||||
if ($oUser->manage_label==1)
|
||||
{
|
||||
$oPermission=new Permission;
|
||||
|
@ -1457,7 +1468,7 @@ function upgradePermissions166()
|
|||
$oPermission->import_p=1;
|
||||
$oPermission->export_p=1;
|
||||
$oPermission->save();
|
||||
}
|
||||
}
|
||||
if ($oUser->participant_panel==1)
|
||||
{
|
||||
$oPermission=new Permission;
|
||||
|
@ -1467,8 +1478,8 @@ function upgradePermissions166()
|
|||
$oPermission->permission='participantpanel';
|
||||
$oPermission->create_p=1;
|
||||
$oPermission->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$sQuery = "SELECT * FROM {{templates_rights}}";
|
||||
$oResult = Yii::app()->db->createCommand($sQuery)->queryAll();
|
||||
foreach ( $oResult as $aRow )
|
||||
|
@ -1525,9 +1536,9 @@ function upgradeTokens148()
|
|||
|
||||
function upgradeQuestionAttributes148()
|
||||
{
|
||||
global $modifyoutput;
|
||||
$sSurveyQuery = "SELECT sid FROM {{surveys}}";
|
||||
$oSurveyResult = dbExecuteAssoc($sSurveyQuery);
|
||||
$aAllAttributes=questionAttributes(true);
|
||||
foreach ( $oSurveyResult->readAll() as $aSurveyRow)
|
||||
{
|
||||
$iSurveyID=$aSurveyRow['sid'];
|
||||
|
@ -1535,7 +1546,6 @@ function upgradeQuestionAttributes148()
|
|||
|
||||
$sAttributeQuery = "select q.qid,attribute,value from {{question_attributes}} qa , {{questions}} q where q.qid=qa.qid and sid={$iSurveyID}";
|
||||
$oAttributeResult = dbExecuteAssoc($sAttributeQuery);
|
||||
$aAllAttributes=questionAttributes(true);
|
||||
foreach ( $oAttributeResult->readAll() as $aAttributeRow)
|
||||
{
|
||||
if (isset($aAllAttributes[$aAttributeRow['attribute']]['i18n']) && $aAllAttributes[$aAttributeRow['attribute']]['i18n'])
|
||||
|
@ -1544,7 +1554,7 @@ function upgradeQuestionAttributes148()
|
|||
foreach ($aLanguages as $sLanguage)
|
||||
{
|
||||
$sAttributeInsertQuery="insert into {{question_attributes}} (qid,attribute,value,language) VALUES({$aAttributeRow['qid']},'{$aAttributeRow['attribute']}','{$aAttributeRow['value']}','{$sLanguage}' )";
|
||||
modifyDatabase("",$sAttributeInsertQuery); echo $modifyoutput; flush();@ob_flush();
|
||||
modifyDatabase("",$sAttributeInsertQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2025,15 +2035,29 @@ function alterLanguageCode($sOldLanguageCode,$sNewLanguageCode)
|
|||
|
||||
function addPrimaryKey($sTablename, $aColumns)
|
||||
{
|
||||
Yii::app()->db->createCommand("ALTER TABLE {{".$sTablename."}} ADD PRIMARY KEY (".implode(',',$aColumns).")")->execute();
|
||||
$sDBDriverName=Yii::app()->db->getDriverName();
|
||||
if ($sDBDriverName=='mysqli' || $sDBDriverName=='mysql')
|
||||
{
|
||||
Yii::app()->db->createCommand("ALTER TABLE {{".$sTablename."}} ADD PRIMARY KEY (".implode(',',$aColumns).")")->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies a primary key in one command - this is only tested on MySQL
|
||||
*
|
||||
* @param string $sTablename The table name
|
||||
* @param array $aColumns Column names to be in the new key
|
||||
*/
|
||||
function modifyPrimaryKey($sTablename, $aColumns)
|
||||
{
|
||||
Yii::app()->db->createCommand("ALTER TABLE {{".$sTablename."}} DROP PRIMARY KEY, ADD PRIMARY KEY (".implode(',',$aColumns).")")->execute();
|
||||
}
|
||||
|
||||
function dropPrimaryKey($sTablename)
|
||||
{
|
||||
$sDBDriverName=Yii::app()->db->getDriverName();
|
||||
if ($sDBDriverName=='mysqli') $sDBDriverName='mysql';
|
||||
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib') $sDBDriverName='mssql';
|
||||
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib') $sDBDriverName='mssql';
|
||||
|
||||
global $modifyoutput;
|
||||
switch ($sDBDriverName){
|
||||
|
@ -2054,7 +2078,7 @@ function dropPrimaryKey($sTablename)
|
|||
Yii::app()->db->createCommand($sQuery)->execute();
|
||||
}
|
||||
break;
|
||||
default: die('Unkown database type');
|
||||
default: die('Unknown database type');
|
||||
}
|
||||
|
||||
// find out the constraint name of the old primary key
|
||||
|
@ -2074,7 +2098,7 @@ function alterColumn($sTable, $sColumn, $sFieldType, $bAllowNull=true, $sDefault
|
|||
{
|
||||
$sDBDriverName=Yii::app()->db->getDriverName();
|
||||
if ($sDBDriverName=='mysqli') $sDBDriverName='mysql';
|
||||
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib') $sDBDriverName='mssql';
|
||||
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib') $sDBDriverName='mssql';
|
||||
switch ($sDBDriverName){
|
||||
case 'mysql':
|
||||
$sType=$sFieldType;
|
||||
|
@ -2127,7 +2151,7 @@ function alterColumn($sTable, $sColumn, $sFieldType, $bAllowNull=true, $sDefault
|
|||
}
|
||||
Yii::app()->db->createCommand()->alterColumn($sTable,$sColumn,$sType);
|
||||
break;
|
||||
default: die('Unkown database type');
|
||||
default: die('Unknown database type');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2136,10 +2160,7 @@ function alterColumn($sTable, $sColumn, $sFieldType, $bAllowNull=true, $sDefault
|
|||
function dropColumn($sTableName, $sColumnName)
|
||||
{
|
||||
$sDBDriverName=Yii::app()->db->getDriverName();
|
||||
if ($sDBDriverName=='mysqli') $sDBDriverName='mysql';
|
||||
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib') $sDBDriverName='mssql';
|
||||
|
||||
if ($sDBDriverName=='mssql')
|
||||
if ($sDBDriverName=='mssql' || $sDBDriverName=='sqlsrv' || $sDBDriverName=='dblib')
|
||||
{
|
||||
dropDefaultValueMSSQL($sColumnName,$sTableName);
|
||||
}
|
||||
|
@ -2202,7 +2223,7 @@ function dropDefaultValueMSSQL($fieldname, $tablename)
|
|||
|
||||
/**
|
||||
* This function drops a unique Key of an MSSQL database field by using the name of the field it lies upon and the table name
|
||||
*
|
||||
*
|
||||
* @param mixed $sFieldName
|
||||
* @param mixed $sTableName
|
||||
*/
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class containing helper functions for dealing with "big data".
|
||||
* @author Sam Mousa <sam@befound.nl>
|
||||
*/
|
||||
class BigData {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function combines json_encode and echo.
|
||||
* If a stream is passed (or is part of the array) it's content will be
|
||||
|
@ -21,7 +21,7 @@
|
|||
{
|
||||
// Scan array for any streams.
|
||||
$hasStream = array_reduce($json, array('BigData', 'hasStream'), false);
|
||||
|
||||
|
||||
// If there is no stream we are done.
|
||||
if (!$hasStream)
|
||||
{
|
||||
|
@ -31,9 +31,9 @@
|
|||
{
|
||||
self::json_echo_data($json, ($options & JSON_FORCE_OBJECT) == JSON_FORCE_OBJECT);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static function hasStream(&$result, $item)
|
||||
{
|
||||
if ($result === true)
|
||||
|
@ -54,13 +54,13 @@
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected static function isStream($item)
|
||||
{
|
||||
return is_object($item) && get_class($item) == 'BigFile';
|
||||
}
|
||||
|
||||
|
||||
protected static function isAssociative($array)
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
|
@ -72,8 +72,8 @@
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected static function json_echo_data($json)
|
||||
{
|
||||
if (self::isStream($json))
|
||||
|
@ -101,7 +101,7 @@
|
|||
echo json_encode(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static function json_echo_array($json)
|
||||
{
|
||||
echo '[';
|
||||
|
@ -113,7 +113,7 @@
|
|||
}
|
||||
echo ']';
|
||||
}
|
||||
|
||||
|
||||
protected static function json_echo_number($json)
|
||||
{
|
||||
echo $json;
|
||||
|
@ -136,12 +136,12 @@
|
|||
}
|
||||
echo '}';
|
||||
}
|
||||
|
||||
|
||||
protected static function json_echo_string($json)
|
||||
{
|
||||
echo json_encode($json);
|
||||
}
|
||||
|
||||
|
||||
protected static function json_echo_stream(BigFile $data)
|
||||
{
|
||||
// Encode stream to base64.
|
||||
|
@ -149,8 +149,8 @@
|
|||
$data->render();
|
||||
echo '"';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected static function tag($name, $data)
|
||||
{
|
||||
echo "<$name>$data</$name>\n";
|
||||
|
@ -180,9 +180,9 @@
|
|||
{
|
||||
self::xmlrpc_echo_string($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static function xmlrpc_echo_array($data)
|
||||
{
|
||||
echo '<array>';
|
||||
|
@ -196,7 +196,7 @@
|
|||
echo '</data>';
|
||||
echo '</array>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints XMLRPC numeric types.
|
||||
* @param type $data
|
||||
|
@ -210,7 +210,7 @@
|
|||
self::tag('double', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static function xmlrpc_echo_object($data)
|
||||
{
|
||||
echo '<struct>';
|
||||
|
@ -221,15 +221,17 @@
|
|||
echo '<value>';
|
||||
self::xmlrpc_echo($value);
|
||||
echo '</value>';
|
||||
|
||||
|
||||
echo '</member>';
|
||||
}
|
||||
echo '</struct>';
|
||||
}
|
||||
|
||||
|
||||
protected static function xmlrpc_echo_stream($data)
|
||||
{
|
||||
echo '<string>'; // a Base64 tag would be more sensible here but it would break all current implementations
|
||||
$data->render();
|
||||
echo '</string>';
|
||||
}
|
||||
|
||||
protected static function xmlrpc_echo_string($data)
|
||||
|
@ -267,7 +269,7 @@
|
|||
unlink($this->fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function echo_base64()
|
||||
{
|
||||
$fileHandle = fopen($this->fileName, 'r');
|
||||
|
|
|
@ -34,7 +34,22 @@ abstract class AuthPluginBase extends PluginBase {
|
|||
{
|
||||
return $this->_username;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set username and password
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function afterLoginFormSubmit()
|
||||
{
|
||||
// Here we handle post data
|
||||
$request = $this->api->getRequest();
|
||||
if ($request->getIsPostRequest()) {
|
||||
$this->setUsername( $request->getPost('user'));
|
||||
$this->setPassword($request->getPost('password'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set authentication result to success for the given user object.
|
||||
*
|
||||
|
|
|
@ -266,9 +266,10 @@
|
|||
{
|
||||
$tables = array();
|
||||
$base = App()->getDb()->tablePrefix . 'old_survey_' . $surveyId;
|
||||
$timingbase = App()->getDb()->tablePrefix . 'old_survey_' . $surveyId . '_timings_';
|
||||
foreach (App()->getDb()->getSchema()->getTableNames() as $table)
|
||||
{
|
||||
if (strpos($table, $base) === 0)
|
||||
if (strpos($table, $base) === 0 && strpos($table, $timingbase)===false)
|
||||
$tables[] = $table;
|
||||
}
|
||||
return $tables;
|
||||
|
@ -339,4 +340,4 @@
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -152,7 +152,7 @@ class Save {
|
|||
"datestamp" => $today,
|
||||
"ipaddr" => getIPAddress(),
|
||||
"startlanguage" => $_SESSION['survey_'.$surveyid]['s_lang'],
|
||||
"refurl" => getenv("HTTP_REFERER")
|
||||
"refurl" => ((isset($_SESSION['survey_'.$surveyid]['refurl'])) ? $_SESSION['survey_'.$surveyid]['refurl'] : getenv('HTTP_REFERER'))
|
||||
);
|
||||
if (SurveyDynamic::model($thissurvey['sid'])->insert($sdata)) // Checked
|
||||
{
|
||||
|
@ -176,7 +176,14 @@ class Save {
|
|||
$saved_control->saved_thisstep = $thisstep;
|
||||
$saved_control->status = 'S';
|
||||
$saved_control->saved_date = $today;
|
||||
$saved_control->refurl = getenv('HTTP_REFERER');
|
||||
if (isset($_SESSION['survey_'.$surveyid]['refurl']))
|
||||
{
|
||||
$saved_control->refurl = $_SESSION['survey_'.$surveyid]['refurl'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$saved_control->refurl = getenv("HTTP_REFERER");
|
||||
}
|
||||
|
||||
if ($saved_control->save())
|
||||
{
|
||||
|
|
|
@ -19,144 +19,144 @@ if(!defined('K_TCPDF_EXTERNAL_CONFIG')) {
|
|||
# include TCPDF
|
||||
require(APPPATH.'config/tcpdf'.EXT);
|
||||
|
||||
require_once($tcpdf['base_directory'].'/tcpdf.php');
|
||||
|
||||
|
||||
/**
|
||||
* page format
|
||||
*/
|
||||
(!defined ('PDF_PAGE_FORMAT')) ? (define ('PDF_PAGE_FORMAT', 'A4')):'';
|
||||
(!defined ('PDF_PAGE_FORMAT')) ? (define ('PDF_PAGE_FORMAT', isset($tcpdf['page_format']) ? $tcpdf['page_format'] : 'A4')):'';
|
||||
|
||||
/**
|
||||
* page orientation (P=portrait, L=landscape)
|
||||
*/
|
||||
(!defined ('PDF_PAGE_ORIENTATION')) ? (define('PDF_PAGE_ORIENTATION', 'P')):'';
|
||||
(!defined ('PDF_PAGE_ORIENTATION')) ? (define('PDF_PAGE_ORIENTATION', isset($tcpdf['page_orientation']) ? $tcpdf['page_orientation'] :'P')):'';
|
||||
|
||||
/**
|
||||
* document creator
|
||||
*/
|
||||
(!defined ('PDF_CREATOR'))?(define ('PDF_CREATOR', 'TCPDF')):'';
|
||||
(!defined ('PDF_CREATOR'))?(define ('PDF_CREATOR', isset($tcpdf['creator']) ? $tcpdf['creator'] : 'TCPDF')):'';
|
||||
|
||||
/**
|
||||
* document author
|
||||
*/
|
||||
(!defined ('PDF_AUTHOR'))? (define ('PDF_AUTHOR', 'TCPDF')):'';
|
||||
(!defined ('PDF_AUTHOR'))? (define ('PDF_AUTHOR', isset($tcpdf['author']) ? $tcpdf['author'] : 'TCPDF')):'';
|
||||
|
||||
/**
|
||||
* header title
|
||||
*/
|
||||
(!defined ('PDF_HEADER_TITLE'))? (define ('PDF_HEADER_TITLE', 'TCPDF Example')):'';
|
||||
(!defined ('PDF_HEADER_TITLE'))? (define ('PDF_HEADER_TITLE', isset($tcpdf['header_title']) ? $tcpdf['header_title'] : 'TCPDF Example')):'';
|
||||
|
||||
/**
|
||||
* header description string
|
||||
*/
|
||||
(!defined ('PDF_HEADER_STRING'))? (define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org")):'';
|
||||
(!defined ('PDF_HEADER_STRING'))? (define ('PDF_HEADER_STRING', isset($tcpdf['header_string']) ? $tcpdf['header_string'] : "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org")):'';
|
||||
|
||||
/**
|
||||
* image logo
|
||||
*/
|
||||
(!defined ('PDF_HEADER_LOGO'))? (define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg')):'';
|
||||
(!defined ('PDF_HEADER_LOGO'))? (define ('PDF_HEADER_LOGO', isset($tcpdf['header_logo']) ? $tcpdf['header_logo'] : 'tcpdf_logo.jpg')):'';
|
||||
|
||||
/**
|
||||
* header logo image width [mm]
|
||||
*/
|
||||
(!defined ('PDF_HEADER_LOGO_WIDTH'))? (define ('PDF_HEADER_LOGO_WIDTH', 30)):'';
|
||||
(!defined ('PDF_HEADER_LOGO_WIDTH'))? (define ('PDF_HEADER_LOGO_WIDTH', isset($tcpdf['header_logo_width']) ? $tcpdf['header_logo_width'] : 30)):'';
|
||||
|
||||
/**
|
||||
* document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
|
||||
*/
|
||||
(!defined ('PDF_UNIT'))? (define ('PDF_UNIT', 'mm')):'';
|
||||
(!defined ('PDF_UNIT'))? (define ('PDF_UNIT', isset($tcpdf['page_unit']) ? $tcpdf['page_unit'] : 'mm')):'';
|
||||
|
||||
/**
|
||||
* header margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_HEADER'))? (define ('PDF_MARGIN_HEADER', 5)):'';
|
||||
(!defined ('PDF_MARGIN_HEADER'))? (define ('PDF_MARGIN_HEADER', isset($tcpdf['header_margin']) ? $tcpdf['header_margin'] : 5)):'';
|
||||
|
||||
/**
|
||||
* footer margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_FOOTER'))? (define ('PDF_MARGIN_FOOTER', 10)):'';
|
||||
(!defined ('PDF_MARGIN_FOOTER'))? (define ('PDF_MARGIN_FOOTER', isset($tcpdf['footer_margin']) ? $tcpdf['footer_margin'] : 10)):'';
|
||||
|
||||
/**
|
||||
* top margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_TOP'))? (define ('PDF_MARGIN_TOP', 27)):'';
|
||||
(!defined ('PDF_MARGIN_TOP'))? (define ('PDF_MARGIN_TOP', isset($tcpdf['margin_top']) ? $tcpdf['margin_top'] : 27)):'';
|
||||
|
||||
/**
|
||||
* bottom margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_BOTTOM'))? (define ('PDF_MARGIN_BOTTOM', 25)):'';
|
||||
(!defined ('PDF_MARGIN_BOTTOM'))? (define ('PDF_MARGIN_BOTTOM', isset($tcpdf['margin_bottom']) ? $tcpdf['margin_bottom'] : 25)):'';
|
||||
|
||||
/**
|
||||
* left margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_LEFT'))? (define ('PDF_MARGIN_LEFT', 15)):'';
|
||||
(!defined ('PDF_MARGIN_LEFT'))? (define ('PDF_MARGIN_LEFT', isset($tcpdf['margin_left']) ? $tcpdf['margin_left'] : 15)):'';
|
||||
|
||||
/**
|
||||
* right margin
|
||||
*/
|
||||
(!defined ('PDF_MARGIN_RIGHT'))? (define ('PDF_MARGIN_RIGHT', 15)):'';
|
||||
(!defined ('PDF_MARGIN_RIGHT'))? (define ('PDF_MARGIN_RIGHT', isset($tcpdf['margin_right']) ? $tcpdf['margin_right'] : 15)):'';
|
||||
|
||||
/**
|
||||
* default main font name
|
||||
*/
|
||||
(!defined ('PDF_FONT_NAME_MAIN'))? (define ('PDF_FONT_NAME_MAIN', 'helvetica')):'';
|
||||
(!defined ('PDF_FONT_NAME_MAIN'))? (define ('PDF_FONT_NAME_MAIN', isset($tcpdf['page_font']) ? $tcpdf['page_font'] : 'helvetica')):'';
|
||||
|
||||
/**
|
||||
* default main font size
|
||||
*/
|
||||
(!defined ('PDF_FONT_SIZE_MAIN'))? (define ('PDF_FONT_SIZE_MAIN', 10)):'';
|
||||
(!defined ('PDF_FONT_SIZE_MAIN'))? (define ('PDF_FONT_SIZE_MAIN', isset($tcpdf['page_font_size']) ? $tcpdf['page_font_size'] : 10)):'';
|
||||
|
||||
/**
|
||||
* default data font name
|
||||
*/
|
||||
(!defined ('PDF_FONT_NAME_DATA'))? (define ('PDF_FONT_NAME_DATA', 'helvetica')):'';
|
||||
(!defined ('PDF_FONT_NAME_DATA'))? (define ('PDF_FONT_NAME_DATA', isset($tcpdf['data_font']) ? $tcpdf['data_font'] : 'helvetica')):'';
|
||||
|
||||
/**
|
||||
* default data font size
|
||||
*/
|
||||
(!defined ('PDF_FONT_SIZE_DATA'))? (define ('PDF_FONT_SIZE_DATA', 8)):'';
|
||||
(!defined ('PDF_FONT_SIZE_DATA'))? (define ('PDF_FONT_SIZE_DATA', isset($tcpdf['data_font_size']) ? $tcpdf['data_font_size'] : 8)):'';
|
||||
|
||||
/**
|
||||
* default monospaced font name
|
||||
*/
|
||||
(!defined ('PDF_FONT_MONOSPACED'))? (define ('PDF_FONT_MONOSPACED', 'courier')):'';
|
||||
(!defined ('PDF_FONT_MONOSPACED'))? (define ('PDF_FONT_MONOSPACED', isset($tcpdf['mono_font']) ? $tcpdf['mono_font'] : 'courier')):'';
|
||||
|
||||
/**
|
||||
* ratio used to adjust the conversion of pixels to user units
|
||||
*/
|
||||
(!defined ('PDF_IMAGE_SCALE_RATIO'))? (define ('PDF_IMAGE_SCALE_RATIO', 1.25)):'';
|
||||
(!defined ('PDF_IMAGE_SCALE_RATIO'))? (define ('PDF_IMAGE_SCALE_RATIO', isset($tcpdf['image_scale']) ? $tcpdf['image_scale'] : 1.25)):'';
|
||||
|
||||
/**
|
||||
* magnification factor for titles
|
||||
*/
|
||||
(!defined('HEAD_MAGNIFICATION'))? (define('HEAD_MAGNIFICATION', 1.1)):'';
|
||||
(!defined('HEAD_MAGNIFICATION'))? (define('HEAD_MAGNIFICATION', 1.1)):''; // never used in TCPDF 6.
|
||||
|
||||
/**
|
||||
* height of cell repect font height
|
||||
*/
|
||||
(!defined('K_CELL_HEIGHT_RATIO'))? (define('K_CELL_HEIGHT_RATIO', 1.25)):'';
|
||||
(!defined('K_CELL_HEIGHT_RATIO'))? (define('K_CELL_HEIGHT_RATIO', isset($tcpdf['cell_height_ratio']) ? $tcpdf['cell_height_ratio'] : 1.25)):'';
|
||||
|
||||
/**
|
||||
* title magnification respect main font size
|
||||
*/
|
||||
(!defined('K_TITLE_MAGNIFICATION'))? (define('K_TITLE_MAGNIFICATION', 1.3)):'';
|
||||
(!defined('K_TITLE_MAGNIFICATION'))? (define('K_TITLE_MAGNIFICATION', 1.3)):''; // never used in TCPDF 6.
|
||||
|
||||
/**
|
||||
* reduction factor for small font
|
||||
*/
|
||||
(!defined('K_SMALL_RATIO'))? (define('K_SMALL_RATIO', 2/3)):'';
|
||||
(!defined('K_SMALL_RATIO'))? (define('K_SMALL_RATIO', isset ($tcpdf['small_font_ratio']) ? $tcpdf['small_font_ratio'] : 2/3)):'';
|
||||
|
||||
/**
|
||||
* set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
|
||||
* set to true to enable the special procedure used to avoid the overlapping of symbols on Thai language
|
||||
*/
|
||||
(!defined('K_THAI_TOPCHARS'))? (define('K_THAI_TOPCHARS', true)):'';
|
||||
(!defined('K_THAI_TOPCHARS'))? (define('K_THAI_TOPCHARS', isset($tcpdf['thai_top_chars']) ? $tcpdf['thai_top_chars'] : true)):'';
|
||||
|
||||
/**
|
||||
* if true allows to call TCPDF methods using HTML syntax
|
||||
* IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
|
||||
*/
|
||||
(!defined('K_TCPDF_CALLS_IN_HTML'))? (define('K_TCPDF_CALLS_IN_HTML', true)):'';
|
||||
(!defined('K_TCPDF_CALLS_IN_HTML'))? (define('K_TCPDF_CALLS_IN_HTML', isset($tcpdf['tcpdf_in_html']) ? $tcpdf['tcpdf_in_html'] : true)):'';
|
||||
|
||||
require_once($tcpdf['base_directory'].'/tcpdf.php');
|
||||
|
||||
|
||||
/************************************************************
|
||||
* TCPDF - CodeIgniter Integration
|
||||
|
@ -194,6 +194,30 @@ class pdf extends TCPDF {
|
|||
*/
|
||||
private $_config = array();
|
||||
|
||||
/**
|
||||
* Base font size for answer PDF export
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_ibaseAnswerFontSize = 12;
|
||||
|
||||
/**
|
||||
* Cell height for answer PDF export
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_iCellHeight = 6;
|
||||
|
||||
/**
|
||||
* Survey Information (preventing from passing to methods every time)
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $_aSurveyInfo = array();
|
||||
|
||||
/**
|
||||
* Set _config for pdf
|
||||
* @access public
|
||||
|
@ -237,13 +261,6 @@ class pdf extends TCPDF {
|
|||
);
|
||||
|
||||
|
||||
# language settings
|
||||
if(is_file($this->_config['language_file'])) {
|
||||
include($this->_config['language_file']);
|
||||
$this->setLanguageArray($l);
|
||||
unset($l);
|
||||
}
|
||||
|
||||
# margin settings
|
||||
$this->SetMargins($this->_config['margin_left'], $this->_config['margin_top'], $this->_config['margin_right']);
|
||||
|
||||
|
@ -609,4 +626,162 @@ class pdf extends TCPDF {
|
|||
$text = str_replace("\t",' ',$text);
|
||||
return strip_tags($text);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Create Answer PDF document, set metadata and set title
|
||||
* @param $aSurveyInfo - Survey Information (preventing from passing to methods every time)
|
||||
* @param $aPdfLanguageSettings - Pdf language settings
|
||||
* @param $sSiteName - LimeSurvey site name (header and metadata)
|
||||
* @param $sSurveyName - Survey name (header, metadata and title),
|
||||
* @param $sDefaultHeaderString - TCPDF header string
|
||||
* @return unknown_type
|
||||
*/
|
||||
function initAnswerPDF($aSurveyInfo, $aPdfLanguageSettings, $sSiteName, $sSurveyName, $sDefaultHeaderString = '')
|
||||
{
|
||||
if (empty($sDefaultHeaderString))
|
||||
$sDefaultHeaderString = $sSurveyName;
|
||||
|
||||
$this->_aSurveyInfo = $aSurveyInfo;
|
||||
$this->SetAuthor($sSiteName);
|
||||
$this->SetTitle($sSurveyName);
|
||||
$this->SetSubject($sSurveyName);
|
||||
$this->SetKeywords($sSurveyName);
|
||||
|
||||
$this->SetFont($aPdfLanguageSettings['pdffont']);
|
||||
$this->_ibaseAnswerFontSize = $aPdfLanguageSettings['pdffontsize'];
|
||||
$this->_iCellHeight = ceil($this->_ibaseAnswerFontSize / 2);
|
||||
$this->setLanguageArray($aPdfLanguageSettings['lg']);
|
||||
|
||||
$this->addHeader($aPdfLanguageSettings, $sSiteName, $sDefaultHeaderString);
|
||||
$this->AddPage();
|
||||
$this->SetFillColor(220, 220, 220);
|
||||
|
||||
$this->addTitle($sSurveyName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add title to pdf
|
||||
* @param $sTitle - Title
|
||||
* @param $sSubtitle - Subtitle
|
||||
* @return unknown_type
|
||||
*/
|
||||
function addTitle($sTitle, $sSubtitle="")
|
||||
{
|
||||
if(!empty($sTitle))
|
||||
{
|
||||
$this->ln(1);
|
||||
$this->SetFontSize($this->_ibaseAnswerFontSize + 6);
|
||||
$oPurifier = new CHtmlPurifier();
|
||||
$sTitleHTML = html_entity_decode(stripJavaScript($oPurifier->purify($sTitle)),ENT_COMPAT);
|
||||
$this->WriteHTMLCell(0, $this->_iCellHeight, $this->getX(), $this->getY(), $sTitleHTML, 0, 1, false, true, 'C');
|
||||
if (!empty($sSubtitle))
|
||||
{
|
||||
$this->ln(1);
|
||||
$this->SetFontSize($this->_ibaseAnswerFontSize + 2);
|
||||
$sSubtitleHTML = html_entity_decode(stripJavaScript($oPurifier->purify($sSubtitle)),ENT_COMPAT);
|
||||
$this->WriteHTMLCell(0, $this->_iCellHeight, $this->getX(), $this->getY(), $sSubtitleHTML, 0, 1, false, true, 'C');
|
||||
}
|
||||
$this->ln(6);
|
||||
$this->SetFontSize($this->_ibaseAnswerFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add header to pdf
|
||||
* @param $aPdfLanguageSettings - Pdf language settings
|
||||
* @param $sSiteName - LimeSurvey site name (header and metadata)
|
||||
* @param $sDefaultHeaderString - TCPDF header string
|
||||
* @return unknown_type
|
||||
*/
|
||||
function addHeader($aPdfLanguageSettings, $sSiteName, $sDefaultHeaderString)
|
||||
{
|
||||
$sLogoFileName = Yii::app()->getConfig('pdflogofile');
|
||||
if (Yii::app()->getConfig('pdfshowheader')=='Y' && file_exists(K_PATH_IMAGES.$sLogoFileName))
|
||||
{
|
||||
$sHeaderTitle = Yii::app()->getConfig('pdfheadertitle');
|
||||
if ($sHeaderTitle == '') $sHeaderTitle = $sSiteName;
|
||||
$sHeaderString = Yii::app()->getConfig('pdfheaderstring');
|
||||
if ($sHeaderString == '') $sHeaderString = $sDefaultHeaderString;
|
||||
|
||||
$this->SetHeaderData($sLogoFileName, Yii::app()->getConfig('pdflogowidth'), $sHeaderTitle, $sHeaderString);
|
||||
$this->SetHeaderFont(Array($aPdfLanguageSettings['pdffont'], '', $this->_ibaseAnswerFontSize - 2));
|
||||
$this->SetFooterFont(Array($aPdfLanguageSettings['pdffont'], '', $this->_ibaseAnswerFontSize - 2));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add GID text to PDF
|
||||
* @param $sFname - Answer field text
|
||||
* @param $bAllowBreakPage - Allow break cell in two pages
|
||||
* @return unknown_type
|
||||
*/
|
||||
function addGidAnswer($sFname, $bAllowBreakPage=false)
|
||||
{
|
||||
$oPurifier = new CHtmlPurifier();
|
||||
$sAnswerHTML = html_entity_decode(stripJavaScript($oPurifier->purify($sFname)),ENT_COMPAT);
|
||||
$sData['thissurvey']=$this->_aSurveyInfo;
|
||||
$sAnswerHTML = templatereplace($sAnswerHTML, array() , $sData, '', $this->_aSurveyInfo['anonymized']=="Y",NULL, array(), true);
|
||||
|
||||
$startPage = $this->getPage();
|
||||
$this->startTransaction();
|
||||
$this->ln(6);
|
||||
$this->SetFontSize($this->_ibaseAnswerFontSize + 2);
|
||||
$this->WriteHTMLCell(0, $this->_iCellHeight, $this->getX(), $this->getY(), $sAnswerHTML, 0, 1, false, true, 'L');
|
||||
$this->ln(2);
|
||||
if ($this->getPage() != $startPage && !$bAllowBreakPage)
|
||||
{
|
||||
$this->rollbackTransaction(true);
|
||||
$this->AddPage();
|
||||
$this->addGidAnswer($sFname,true); // Second param = true avoid an endless loop if a cell is longer than a page
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->commitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add answer to PDF
|
||||
*
|
||||
* @param $sQuestion - Question field text array
|
||||
* @param $sResponse - Answer field text array
|
||||
* @param $bReplaceExpressions - Try to replace LimeSurvey Expressions. This is false when exporting answers PDF from admin GUI
|
||||
* because we can not interpret expressions so just purify.
|
||||
* TODO: Find a universal valid method to interpret expressions
|
||||
* @param $bAllowBreakPage - Allow break cell in two pages
|
||||
* @return unknown_type
|
||||
*/
|
||||
function addAnswer($sQuestion, $sResponse, $bReplaceExpressions=true, $bAllowBreakPage=false)
|
||||
{
|
||||
$oPurifier = new CHtmlPurifier();
|
||||
$sQuestionHTML = str_replace('-oth-','',$sQuestion); // Copied from Writer::stripTagsFull. Really necessary?
|
||||
$sQuestionHTML = html_entity_decode(stripJavaScript($oPurifier->purify($sQuestionHTML)),ENT_COMPAT);
|
||||
if ($bReplaceExpressions)
|
||||
{
|
||||
$sData['thissurvey']=$this->_aSurveyInfo;
|
||||
$sQuestionHTML = templatereplace($sQuestionHTML, array() , $sData, '', $this->_aSurveyInfo['anonymized']=="Y",NULL, array(), true);
|
||||
}
|
||||
$sResponse = flattenText($sResponse, false, true, 'UTF-8', false);
|
||||
|
||||
$startPage = $this->getPage();
|
||||
$this->startTransaction();
|
||||
$this->SetFontSize($this->_ibaseAnswerFontSize);
|
||||
$this->WriteHTMLCell(0, $this->_iCellHeight, $this->getX(), $this->getY(), $sQuestionHTML, 1, 1, true, true, 'L');
|
||||
$this->MultiCell(0, $this->_iCellHeight, $sResponse, 1, 'L', 0, 1, '', '', true);
|
||||
$this->ln(2);
|
||||
if ($this->getPage() != $startPage && !$bAllowBreakPage)
|
||||
{
|
||||
$this->rollbackTransaction(true);
|
||||
$this->AddPage();
|
||||
$this->addAnswer($sQuestion,$sResponse,$bReplaceExpressions,true); // "Last param = true" prevents an endless loop if a cell is longer than a page
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->commitTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
require('pdf.php');
|
||||
require_once($tcpdf['base_directory'].'/tcpdf.php');
|
||||
require_once($tcpdf['base_directory'].'/config/lang/eng.php');
|
||||
|
||||
/**
|
||||
* A TCPDF based class to produce queXF compatible questionnaire PDF files and banding description XML from queXML
|
||||
|
|
|
@ -29,7 +29,7 @@ class InstallerConfigForm extends CFormModel
|
|||
'mysqli' => 'MySQL (newer driver)',
|
||||
'sqlsrv' => 'Microsoft SQL Server (sqlsrv)',
|
||||
'mssql' => 'Microsoft SQL Server (mssql)',
|
||||
'dblib' => 'Microsoft SQL Server (dblib)',
|
||||
'dblib' => 'Microsoft SQL Server (dblib)',
|
||||
'pgsql' => 'PostgreSQL',
|
||||
);
|
||||
|
||||
|
@ -68,7 +68,6 @@ class InstallerConfigForm extends CFormModel
|
|||
array('dbtype, dblocation, dbname, dbuser', 'required', 'on' => 'database'),
|
||||
array('dbpwd, dbprefix', 'safe', 'on' => 'database'),
|
||||
array('dbtype', 'in', 'range' => array_keys($this->supported_db_types), 'on' => 'database'),
|
||||
|
||||
//Optional
|
||||
array('adminLoginName, adminName, siteName, confirmPwd', 'safe', 'on' => 'optional'),
|
||||
array('adminEmail', 'email', 'on' => 'optional'),
|
||||
|
|
|
@ -152,7 +152,7 @@ class Participant extends LSActiveRecord
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the primary key of this table
|
||||
*
|
||||
|
@ -165,7 +165,7 @@ class Participant extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* This function updates the data edited in the jqgrid
|
||||
*
|
||||
*
|
||||
* @param aray $data
|
||||
*/
|
||||
function updateRow($data)
|
||||
|
@ -194,14 +194,14 @@ class Participant extends LSActiveRecord
|
|||
->leftJoin('{{participant_shares}}', ' {{participants}}.participant_id={{participant_shares}}.participant_id')
|
||||
->where('owner_uid = :userid1 OR share_uid = :userid2')
|
||||
->group('{{participants}}.participant_id,{{participant_shares}}.can_edit');
|
||||
|
||||
|
||||
$command = Yii::app()->db->createCommand()
|
||||
->select('p.*, ps.can_edit')
|
||||
->from('{{participants}} p')
|
||||
->join('(' . $subquery->getText() . ') ps', 'ps.participant_id = p.participant_id')
|
||||
->bindParam(":userid1", $userid, PDO::PARAM_INT)
|
||||
->bindParam(":userid2", $userid, PDO::PARAM_INT);
|
||||
|
||||
|
||||
return $command->queryAll();
|
||||
}
|
||||
|
||||
|
@ -219,14 +219,14 @@ class Participant extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* Get the number of participants, no restrictions
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getParticipantsCountWithoutLimit()
|
||||
{
|
||||
return Participant::model()->count();
|
||||
return Participant::model()->count();
|
||||
}
|
||||
|
||||
|
||||
function getParticipantsWithoutLimit()
|
||||
{
|
||||
return Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->queryAll();
|
||||
|
@ -236,10 +236,10 @@ class Participant extends LSActiveRecord
|
|||
* This function combines the shared participant and the central participant
|
||||
* table and searches for any reference of owner id in the combined record
|
||||
* of the two tables
|
||||
*
|
||||
*
|
||||
* @param int $userid The id of the owner
|
||||
* @return int The number of participants owned by $userid who are shared
|
||||
*/
|
||||
*/
|
||||
function getParticipantsSharedCount($userid)
|
||||
{
|
||||
$count = Yii::app()->db->createCommand()->select('count(*)')->from('{{participants}}')->join('{{participant_shares}}', '{{participant_shares}}.participant_id = {{participants}}.participant_id')->where('owner_uid = :userid')->bindParam(":userid", $userid, PDO::PARAM_INT)->queryScalar();
|
||||
|
@ -249,42 +249,42 @@ class Participant extends LSActiveRecord
|
|||
function getParticipants($page, $limit,$attid, $order = null, $search = null, $userid = null)
|
||||
{
|
||||
$data = $this->getParticipantsSelectCommand(false, $attid, $search, $userid, $page, $limit, $order);
|
||||
|
||||
|
||||
$allData = $data->queryAll();
|
||||
|
||||
return $allData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Duplicated from getparticipants, only to have a count
|
||||
*
|
||||
*
|
||||
* @param type $attid
|
||||
* @param type $order
|
||||
* @param CDbCriteria $search
|
||||
* @param type $userid
|
||||
* @return type
|
||||
*/
|
||||
*/
|
||||
function getParticipantsCount($attid, $search = null, $userid = null) {
|
||||
$data = $this->getParticipantsSelectCommand(true, $attid, $search, $userid);
|
||||
|
||||
|
||||
return $data->queryScalar();
|
||||
}
|
||||
|
||||
|
||||
private function getParticipantsSelectCommand($count = false, $attid, $search = null, $userid = null, $page = null, $limit = null, $order = null)
|
||||
{
|
||||
$selectValue = array();
|
||||
$joinValue = array();
|
||||
|
||||
|
||||
$selectValue[] = "p.*";
|
||||
$selectValue[] = "luser.full_name as ownername";
|
||||
$selectValue[] = "luser.users_name as username";
|
||||
|
||||
|
||||
$aAllAttributes = ParticipantAttributeName::model()->getAllAttributes();
|
||||
foreach ($aAllAttributes as $aAttribute)
|
||||
{
|
||||
if(!is_null($search) && strpos($search->condition,'attribute'.$aAttribute['attribute_id'])!==false)
|
||||
{
|
||||
$attid[$aAttribute['attribute_id']]=$aAttribute;
|
||||
$attid[$aAttribute['attribute_id']]=$aAttribute;
|
||||
}
|
||||
}
|
||||
// Add survey count subquery
|
||||
|
@ -296,6 +296,7 @@ class Participant extends LSActiveRecord
|
|||
array_push($joinValue,"left join {{users}} luser ON luser.uid=p.owner_uid");
|
||||
foreach($attid as $iAttributeID=>$aAttributeDetails)
|
||||
{
|
||||
if ($iAttributeID==0) continue;
|
||||
$sDatabaseType = Yii::app()->db->getDriverName();
|
||||
if ($sDatabaseType=='mssql' || $sDatabaseType=="sqlsrv" || $sDatabaseType == 'dblib')
|
||||
{
|
||||
|
@ -305,7 +306,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
array_push($joinValue,"LEFT JOIN {{participant_attribute}} attribute".$iAttributeID." ON attribute".$iAttributeID.".participant_id=p.participant_id AND attribute".$iAttributeID.".attribute_id=".$iAttributeID);
|
||||
}
|
||||
|
||||
|
||||
$aConditions = array(); // this wil hold all conditions
|
||||
$aParams = array();
|
||||
if (!is_null($userid)) {
|
||||
|
@ -314,16 +315,16 @@ class Participant extends LSActiveRecord
|
|||
$joinValue[] = 'LEFT JOIN {{participant_shares}} ON p.participant_id={{participant_shares}}.participant_id';
|
||||
$aConditions[] = 'p.owner_uid = :userid1 OR {{participant_shares}}.share_uid = :userid2';
|
||||
}
|
||||
|
||||
|
||||
if ($count) {
|
||||
$selectValue = 'count(*) as cnt';
|
||||
}
|
||||
|
||||
|
||||
$data = Yii::app()->db->createCommand()
|
||||
->select($selectValue)
|
||||
->from('{{participants}} p');
|
||||
$data->setJoin($joinValue);
|
||||
|
||||
|
||||
if (!empty($search)) {
|
||||
/* @var $search CDbCriteria */
|
||||
$aSearch = $search->toArray();
|
||||
|
@ -336,7 +337,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
$condition = ''; // This will be the final condition
|
||||
foreach ($aConditions as $idx => $newCondition) {
|
||||
if ($idx>0) {
|
||||
if ($idx>0) {
|
||||
$condition .= ' AND ';
|
||||
}
|
||||
$condition .= '(' . $newCondition . ')';
|
||||
|
@ -345,7 +346,7 @@ class Participant extends LSActiveRecord
|
|||
if (!empty($condition)) {
|
||||
$data->setWhere($condition);
|
||||
}
|
||||
|
||||
|
||||
if (!$count) {
|
||||
// Apply order and limits
|
||||
if (!empty($order)) {
|
||||
|
@ -358,14 +359,14 @@ class Participant extends LSActiveRecord
|
|||
->limit($limit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data->bindValues($aParams);
|
||||
|
||||
|
||||
if (!is_null($userid)) {
|
||||
$data->bindParam(":userid1", $userid, PDO::PARAM_INT)
|
||||
->bindParam(":userid2", $userid, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -376,7 +377,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
|
||||
/**
|
||||
* This function deletes the participant from the participants table,
|
||||
* This function deletes the participant from the participants table,
|
||||
* references in the survey_links table (but not in matching tokens tables)
|
||||
* and then all the participants attributes.
|
||||
* @param $rows Participants ID separated by comma
|
||||
|
@ -385,7 +386,7 @@ class Participant extends LSActiveRecord
|
|||
function deleteParticipants($rows, $bFilter=true)
|
||||
{
|
||||
// Converting the comma separated IDs to an array and assign chunks of 100 entries to have a reasonable query size
|
||||
$aParticipantsIDChunks = array_chunk(explode(",", $rows),100);
|
||||
$aParticipantsIDChunks = array_chunk(explode(",", $rows),100);
|
||||
foreach ($aParticipantsIDChunks as $aParticipantsIDs)
|
||||
{
|
||||
|
||||
|
@ -400,9 +401,9 @@ class Participant extends LSActiveRecord
|
|||
$oParticipant->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Yii::app()->db->createCommand()->delete(Participant::model()->tableName(), array('in', 'participant_id', $aParticipantsIDs));
|
||||
|
||||
|
||||
// Delete survey links
|
||||
Yii::app()->db->createCommand()->delete(SurveyLink::model()->tableName(), array('in', 'participant_id', $aParticipantsIDs));
|
||||
// Delete participant attributes
|
||||
|
@ -410,10 +411,10 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Filter an array of participants IDs according to permissions of the person being logged in
|
||||
*
|
||||
*
|
||||
* @param mixed $aParticipantsIDs
|
||||
*/
|
||||
function filterParticipantIDs($aParticipantIDs)
|
||||
|
@ -423,13 +424,13 @@ class Participant extends LSActiveRecord
|
|||
$aCondition=array('and','owner_uid=:owner_uid',array('in', 'participant_id', $aParticipantIDs));
|
||||
$aParameter=array(':owner_uid'=>Yii::app()->session['loginID']);
|
||||
$aParticipantIDs=Yii::app()->db->createCommand()->select('participant_id')->from(Participant::model()->tableName())->where($aCondition, $aParameter)->queryColumn();
|
||||
}
|
||||
}
|
||||
return $aParticipantIDs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes CPDB participants identified by their participant ID from token tables
|
||||
*
|
||||
*
|
||||
* @param mixed $sParticipantsIDs
|
||||
*/
|
||||
function deleteParticipantToken($sParticipantsIDs)
|
||||
|
@ -437,7 +438,7 @@ class Participant extends LSActiveRecord
|
|||
/* This function deletes the participant from the participants table,
|
||||
the participant from any tokens table they're in (using the survey_links table to find them)
|
||||
and then all the participants attributes. */
|
||||
$aParticipantsIDChunks = array_chunk(explode(",", $sParticipantsIDs),100);
|
||||
$aParticipantsIDChunks = array_chunk(explode(",", $sParticipantsIDs),100);
|
||||
foreach ($aParticipantsIDChunks as $aParticipantsIDs)
|
||||
{
|
||||
$aParticipantsIDs=$this->filterParticipantIDs($aParticipantsIDs);
|
||||
|
@ -462,14 +463,14 @@ class Participant extends LSActiveRecord
|
|||
* the participant from any tokens table they're in (using the survey_links table to find them),
|
||||
* all responses in surveys they've been linked to,
|
||||
* and then all the participants attributes.
|
||||
*
|
||||
*
|
||||
* @param mixed $sParticipantsIDs
|
||||
*/
|
||||
function deleteParticipantTokenAnswer($sParticipantsIDs)
|
||||
{
|
||||
$aParticipantsIDs = explode(",", $sParticipantsIDs);
|
||||
$aParticipantsIDs=$this->filterParticipantIDs($aParticipantsIDs);
|
||||
|
||||
|
||||
foreach ($aParticipantsIDs as $row)
|
||||
{
|
||||
$tokens = Yii::app()->db->createCommand()
|
||||
|
@ -510,7 +511,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
if (Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'delete'))
|
||||
{
|
||||
|
||||
|
||||
Yii::app()->db->createCommand()
|
||||
->delete('{{tokens_' . intval($value['survey_id']) . '}}', 'participant_id = :pid' , array(':pid'=>$value['participant_id'])); // Deletes matching token table entries
|
||||
}
|
||||
|
@ -708,7 +709,7 @@ class Participant extends LSActiveRecord
|
|||
$i = $i + 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($page == 0 && $limit == 0)
|
||||
{
|
||||
$arr = Participant::model()->findAll($command);
|
||||
|
@ -732,8 +733,8 @@ class Participant extends LSActiveRecord
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Function builds a select query for searches through participants using the $condition field passed
|
||||
* which is in the format "firstfield||sqloperator||value||booleanoperator||secondfield||sqloperator||value||booleanoperator||etc||etc||etc"
|
||||
* for example: "firstname||equal||Jason||and||lastname||equal||Cleeland" will produce SQL along the lines of "WHERE firstname = 'Jason' AND lastname=='Cleeland'"
|
||||
|
@ -765,11 +766,11 @@ class Participant extends LSActiveRecord
|
|||
$param = ':condition_'.$i;
|
||||
switch ($sOperator)
|
||||
{
|
||||
case 'equal':
|
||||
case 'equal':
|
||||
$operator = '=';
|
||||
$aParams[$param] = $sValue;
|
||||
break;
|
||||
case 'contains':
|
||||
case 'contains':
|
||||
$operator = 'LIKE';
|
||||
$aParams[$param] = '%'.$sValue.'%';
|
||||
break;
|
||||
|
@ -777,19 +778,19 @@ class Participant extends LSActiveRecord
|
|||
$operator = 'LIKE';
|
||||
$aParams[$param] = $sValue.'%';
|
||||
break;
|
||||
case 'notequal':
|
||||
case 'notequal':
|
||||
$operator = '!=';
|
||||
$aParams[$param] = $sValue;
|
||||
break;
|
||||
case 'notcontains':
|
||||
case 'notcontains':
|
||||
$operator = 'NOT LIKE';
|
||||
$aParams[$param] = '%'.$sValue.'%';
|
||||
break;
|
||||
case 'greaterthan':
|
||||
case 'greaterthan':
|
||||
$operator = '>';
|
||||
$aParams[$param] = $sValue;
|
||||
break;
|
||||
case 'lessthan':
|
||||
case 'lessthan':
|
||||
$operator = '<';
|
||||
$aParams[$param] = $sValue;
|
||||
break;
|
||||
|
@ -802,11 +803,11 @@ class Participant extends LSActiveRecord
|
|||
{
|
||||
$booloperator='AND';
|
||||
}
|
||||
|
||||
|
||||
if($sFieldname=="email")
|
||||
{
|
||||
$command->addCondition('p.email ' . $operator . ' '.$param, $booloperator);
|
||||
}
|
||||
}
|
||||
elseif($sFieldname=="survey")
|
||||
{
|
||||
$subQuery = Yii::app()->db->createCommand()
|
||||
|
@ -815,7 +816,7 @@ class Participant extends LSActiveRecord
|
|||
->join('{{surveys_languagesettings}} sls', 'sl.survey_id = sls.surveyls_survey_id')
|
||||
->where('sls.surveyls_title '. $operator.' '.$param)
|
||||
->group('sl.participant_id');
|
||||
$command->addCondition('p.participant_id IN ('.$subQuery->getText().')', $booloperator);
|
||||
$command->addCondition('p.participant_id IN ('.$subQuery->getText().')', $booloperator);
|
||||
}
|
||||
elseif($sFieldname=="surveyid")
|
||||
{
|
||||
|
@ -824,7 +825,7 @@ class Participant extends LSActiveRecord
|
|||
->from('{{survey_links}} sl')
|
||||
->where('sl.survey_id '. $operator.' '.$param)
|
||||
->group('sl.participant_id');
|
||||
$command->addCondition('p.participant_id IN ('.$subQuery->getText().')', $booloperator);
|
||||
$command->addCondition('p.participant_id IN ('.$subQuery->getText().')', $booloperator);
|
||||
}
|
||||
elseif($sFieldname=="surveys") //Search by quantity of linked surveys
|
||||
{
|
||||
|
@ -852,15 +853,15 @@ class Participant extends LSActiveRecord
|
|||
{
|
||||
$command->addCondition($sFieldname . ' '.$operator.' '.$param, $booloperator);
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
if (count($aParams)>0)
|
||||
{
|
||||
$command->params = $aParams;
|
||||
}
|
||||
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
|
@ -944,7 +945,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
|
||||
// If automapping is enabled then update the token field properties with the mapped CPDB field ID
|
||||
|
||||
|
||||
if($createautomap=="true") {
|
||||
foreach($mapped as $key=>$iIDAttributeCPDB) {
|
||||
if(is_numeric($iIDAttributeCPDB)) {
|
||||
|
@ -953,7 +954,7 @@ class Participant extends LSActiveRecord
|
|||
$aTokenAttributes[$key]['cpdbmap']=$iIDAttributeCPDB;
|
||||
Yii::app()->db
|
||||
->createCommand()
|
||||
->update('{{surveys}}', array("attributedescriptions" => serialize($aAttributes)), 'sid = '.$surveyid); }
|
||||
->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = '.$surveyid); }
|
||||
}
|
||||
}
|
||||
foreach ($tokenattributefieldnames as $key => $value)
|
||||
|
@ -1000,7 +1001,7 @@ class Participant extends LSActiveRecord
|
|||
->from('{{surveys}}')
|
||||
->bindParam(":sid", $surveyid, PDO::PARAM_INT);
|
||||
$aTokenAttributes = $previousatt->queryRow();
|
||||
$aTokenAttributes = @unserialize($aTokenAttributes['attributedescriptions'],true);
|
||||
$aTokenAttributes = decodeTokenAttributes($aTokenAttributes['attributedescriptions'],true);
|
||||
foreach($fieldcontents as $key=>$iIDAttributeCPDB) {
|
||||
$aTokenAttributes[$key]=$iIDAttributeCPDB;
|
||||
}
|
||||
|
@ -1017,27 +1018,31 @@ class Participant extends LSActiveRecord
|
|||
addColumn("{{tokens_$surveyid}}", $key, $value['type']);
|
||||
}
|
||||
Yii::app()->db->schema->getTable("{{tokens_$surveyid}}", true); // Refresh schema cache just
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Write each participant to the survey token table
|
||||
foreach ($participantid as $key => $participant)
|
||||
foreach ($participantid as $key => $sParticipantUID)
|
||||
{
|
||||
$writearray = array();
|
||||
$participantdata = Yii::app()->db->createCommand()->select('firstname,lastname,email,language,blacklisted')->where('participant_id = :pid')->from('{{participants}}')->bindParam(":pid", $participant, PDO::PARAM_INT);
|
||||
$participantdata = Yii::app()->db->createCommand()->select('firstname,lastname,email,language,blacklisted')->where('participant_id = :pid')->from('{{participants}}')->bindParam(":pid", $sParticipantUID, PDO::PARAM_INT);
|
||||
$tobeinserted = $participantdata->queryRow();
|
||||
|
||||
|
||||
if (Yii::app()->getConfig('blockaddingtosurveys')=='Y' && $tobeinserted=='Y')
|
||||
{
|
||||
$iBlacklistSkipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Search for matching participant name/email in the survey token table */
|
||||
$query = Yii::app()->db->createCommand()->select('*')->from('{{tokens_' . $surveyid . '}}')
|
||||
->where('firstname = :firstname AND lastname = :lastname AND email = :email')
|
||||
->bindParam(":firstname", $tobeinserted['firstname'], PDO::PARAM_STR)->bindParam(":lastname", $tobeinserted['lastname'], PDO::PARAM_STR)->bindParam(":email", $tobeinserted['email'], PDO::PARAM_STR)->queryAll();
|
||||
if (count($query) > 0)
|
||||
$sQuery = Yii::app()->db->createCommand()->select('*')->from('{{tokens_' . $surveyid . '}}')
|
||||
->where('firstname = :firstname AND lastname = :lastname AND email = :email AND participant_id = :participant_id')
|
||||
->bindParam(":firstname", $tobeinserted['firstname'], PDO::PARAM_STR)
|
||||
->bindParam(":lastname", $tobeinserted['lastname'], PDO::PARAM_STR)
|
||||
->bindParam(":email", $tobeinserted['email'], PDO::PARAM_STR)
|
||||
->bindParam(":participant_id", $sParticipantUID, PDO::PARAM_STR)
|
||||
->queryAll();
|
||||
if (count($sQuery) > 0)
|
||||
{
|
||||
//Participant already exists in token table - don't copy
|
||||
$duplicate++;
|
||||
|
@ -1049,7 +1054,7 @@ class Participant extends LSActiveRecord
|
|||
$numberofattributes = count($attributesadded);
|
||||
for ($a = 0; $a < $numberofattributes; $a++)
|
||||
{
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant,$attributesadded[$a],$attributeidadded[$a]);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID,$attributesadded[$a],$attributeidadded[$a]);
|
||||
}
|
||||
}
|
||||
//If there are automapped attributes, add those values to the token entry for this participant
|
||||
|
@ -1058,7 +1063,7 @@ class Participant extends LSActiveRecord
|
|||
foreach ($mapped as $key => $value)
|
||||
{
|
||||
if ($key[10] == 'c') { //We know it's automapped because the 11th letter is 'c'
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant, $value, $key);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1070,7 +1075,7 @@ class Participant extends LSActiveRecord
|
|||
foreach ($mapped as $key => $value)
|
||||
{
|
||||
if ($key[10] != 'c' && $key[9]=='_') { //It's not an auto field because it's 11th character isn't 'c'
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant, $value, $key);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1081,7 +1086,7 @@ class Participant extends LSActiveRecord
|
|||
foreach($mapped as $key=>$value)
|
||||
{
|
||||
if((strlen($key) > 8 && $key[10] != 'c' && $key[9] !='_') || strlen($key) < 9) {
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant, $value, $key);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1090,7 +1095,7 @@ class Participant extends LSActiveRecord
|
|||
else
|
||||
{
|
||||
//Create a new token entry for this participant
|
||||
$writearray = array('participant_id' => $participant,
|
||||
$writearray = array('participant_id' => $sParticipantUID,
|
||||
'firstname' => $tobeinserted['firstname'],
|
||||
'lastname' => $tobeinserted['lastname'],
|
||||
'email' => $tobeinserted['email'],
|
||||
|
@ -1105,7 +1110,7 @@ class Participant extends LSActiveRecord
|
|||
|
||||
//Create a survey link for the new token entry
|
||||
$data = array(
|
||||
'participant_id' => $participant,
|
||||
'participant_id' => $sParticipantUID,
|
||||
'token_id' => $insertedtokenid,
|
||||
'survey_id' => $surveyid,
|
||||
'date_created' => date('Y-m-d H:i:s', $time));
|
||||
|
@ -1117,7 +1122,7 @@ class Participant extends LSActiveRecord
|
|||
$numberofattributes = count($attributesadded);
|
||||
for ($a = 0; $a < $numberofattributes; $a++)
|
||||
{
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant,$attributesadded[$a],$attributeidadded[$a]);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID,$attributesadded[$a],$attributeidadded[$a]);
|
||||
}
|
||||
}
|
||||
//If there are any automatically mapped attributes, add those values to the token entry for this participant
|
||||
|
@ -1125,7 +1130,7 @@ class Participant extends LSActiveRecord
|
|||
{
|
||||
foreach ($mapped as $key => $value)
|
||||
{
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $participant, $value, $key);
|
||||
Participant::model()->updateTokenAttributeValue($surveyid, $sParticipantUID, $value, $key);
|
||||
}
|
||||
}
|
||||
$sucessfull++;
|
||||
|
@ -1377,7 +1382,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
Yii::app()->db
|
||||
->createCommand()
|
||||
->update('{{surveys}}', array("attributedescriptions" => serialize($aAttributes)), 'sid = '.$surveyid);
|
||||
->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = '.$surveyid);
|
||||
}
|
||||
if (!empty($aMapped))
|
||||
{
|
||||
|
@ -1388,7 +1393,7 @@ class Participant extends LSActiveRecord
|
|||
}
|
||||
Yii::app()->db
|
||||
->createCommand()
|
||||
->update('{{surveys}}', array("attributedescriptions" => serialize($aAttributes)), 'sid = '.$surveyid);
|
||||
->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = '.$surveyid);
|
||||
}
|
||||
}
|
||||
$returndata = array('success' => $sucessfull, 'duplicate' => $duplicate, 'overwriteauto'=>$overwriteauto, 'overwriteman'=>$overwriteman);
|
||||
|
|
|
@ -78,9 +78,9 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
// NOTE: you should only define rules for those attributes that
|
||||
// will receive user inputs.
|
||||
// NOTE: you should only define rules for those attributes that will receive user inputs.
|
||||
return array(
|
||||
array('defaultname','filter','filter' => 'strip_tags'),
|
||||
array('attribute_type, visible', 'required'),
|
||||
array('attribute_type', 'length', 'max'=>4),
|
||||
array('visible', 'length', 'max'=>5),
|
||||
|
@ -135,14 +135,14 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getAllAttributes()
|
||||
{
|
||||
$aResult=Yii::app()->db->createCommand()->select('{{participant_attribute_names}}.*')
|
||||
->from('{{participant_attribute_names}}')
|
||||
->order('{{participant_attribute_names}}.attribute_id')
|
||||
->queryAll();
|
||||
return $aResult;
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
function getAllAttributesValues()
|
||||
|
@ -152,7 +152,7 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* Get an array of CPDB attributes
|
||||
*
|
||||
*
|
||||
* @param mixed $sLanguageFilter
|
||||
*/
|
||||
function getVisibleAttributes($sLanguageFilter=null)
|
||||
|
@ -334,26 +334,28 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* Adds the data for a new attribute
|
||||
*
|
||||
*
|
||||
* @param mixed $data
|
||||
*/
|
||||
function storeAttribute($data)
|
||||
{
|
||||
$insertnames = array('attribute_type' => $data['attribute_type'],
|
||||
'defaultname'=> $data['defaultname'],
|
||||
'visible' => $data['visible']);
|
||||
{
|
||||
// Do not allow more than 60 attributes because queries will break because of too many joins
|
||||
if (ParticipantAttributeName::model()->count()>59)
|
||||
if (ParticipantAttributeName::model()->count()>59)
|
||||
{
|
||||
return false;
|
||||
};
|
||||
Yii::app()->db->createCommand()->insert('{{participant_attribute_names}}',$insertnames);
|
||||
$attribute_id = getLastInsertID($this->tableName());
|
||||
$insertnameslang = array('attribute_id' => intval($attribute_id),
|
||||
'attribute_name'=> $data['attribute_name'],
|
||||
'lang' => Yii::app()->session['adminlang']);
|
||||
Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}',$insertnameslang);
|
||||
return $attribute_id;
|
||||
$oParticipantAttributeName=new ParticipantAttributeName;
|
||||
$oParticipantAttributeName->attribute_type=$data['attribute_type'];
|
||||
$oParticipantAttributeName->defaultname=$data['defaultname'];
|
||||
$oParticipantAttributeName->visible=$data['visible'];
|
||||
$oParticipantAttributeName->save();
|
||||
$iAttributeID = $oParticipantAttributeName->attribute_id;
|
||||
$oParticipantAttributeNameLang=new ParticipantAttributeNameLang;
|
||||
$oParticipantAttributeNameLang->attribute_id= intval($iAttributeID);
|
||||
$oParticipantAttributeNameLang->attribute_name= $data['attribute_name'];
|
||||
$oParticipantAttributeNameLang->lang= Yii::app()->session['adminlang'];
|
||||
$oParticipantAttributeNameLang->save();
|
||||
return $iAttributeID;
|
||||
}
|
||||
|
||||
function editParticipantAttributeValue($data)
|
||||
|
@ -430,16 +432,18 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
}
|
||||
if (!empty($insertnames))
|
||||
{
|
||||
self::model()->updateAll($insertnames, 'attribute_id = :id', array(':id' => $data['attribute_id']));
|
||||
$oParticipantAttributeName=ParticipantAttributeName::model()->findByPk($data['attribute_id']);
|
||||
foreach ($insertnames as $sFieldname=>$sValue)
|
||||
{
|
||||
$oParticipantAttributeName->$sFieldname=$sValue;
|
||||
}
|
||||
$oParticipantAttributeName->save();
|
||||
}
|
||||
if (!empty($data['attribute_name']))
|
||||
{
|
||||
Yii::app()->db->createCommand()
|
||||
->update('{{participant_attribute_names_lang}}', array('attribute_name' => $data['attribute_name']),
|
||||
'attribute_id = :attribute_id AND lang=:lang', array(
|
||||
':lang' => Yii::app()->session['adminlang'],
|
||||
':attribute_id' => $data['attribute_id'],
|
||||
));
|
||||
$oParticipantAttributeNameLang=ParticipantAttributeNameLang::model()->findByPk(array('attribute_id'=>$data['attribute_id'],'lang'=>Yii::app()->session['adminlang']));
|
||||
$oParticipantAttributeNameLang->attribute_name=$data['attribute_name'];
|
||||
$oParticipantAttributeNameLang->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,19 +452,18 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
$query = Yii::app()->db->createCommand()->from('{{participant_attribute_names_lang}}')->where('attribute_id = :attribute_id AND lang = :lang')->select('*')->bindParam(":attribute_id", $data['attribute_id'], PDO::PARAM_INT)->bindParam(":lang", $data['lang'], PDO::PARAM_STR)->queryAll();
|
||||
if (count($query) == 0)
|
||||
{
|
||||
// A record does not exist, insert one.
|
||||
$record = array('attribute_id'=>$data['attribute_id'],'attribute_name'=>$data['attribute_name'],'lang'=>$data['lang']);
|
||||
$query = Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}', $data);
|
||||
// A record does not exist, insert one.
|
||||
$oParticipantAttributeNameLang=new ParticipantAttributeNameLang;
|
||||
$oParticipantAttributeNameLang->attribute_id=$data['attribute_id'];
|
||||
$oParticipantAttributeNameLang->attribute_name=$data['attribute_name'];
|
||||
$oParticipantAttributeNameLang->lang=$data['lang'];
|
||||
$oParticipantAttributeNameLang->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
// A record does exist, update it.
|
||||
$query = Yii::app()->db->createCommand()
|
||||
->update('{{participant_attribute_names_lang}}', array('attribute_name' => $data['attribute_name']),
|
||||
'attribute_id = :attribute_id AND lang= :lang', array(
|
||||
':attribute_id' => $data['attribute_id'],
|
||||
':lang' => $data['lang'],
|
||||
));
|
||||
$oParticipantAttributeNameLang=ParticipantAttributeNameLang::model()->findByPk(array('attribute_id'=>$data['attribute_id'],'lang'=>$data['lang']));
|
||||
$oParticipantAttributeNameLang->attribute_name=$data['attribute_name'];
|
||||
$oParticipantAttributeNameLang->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,17 +476,20 @@ class ParticipantAttributeName extends LSActiveRecord
|
|||
|
||||
function storeAttributeCSV($data)
|
||||
{
|
||||
$insertnames = array('attribute_type' => $data['attribute_type'],
|
||||
'defaultname' => $data['defaultname'],
|
||||
'visible' => $data['visible']);
|
||||
Yii::app()->db->createCommand()->insert('{{participant_attribute_names}}', $insertnames);
|
||||
$oParticipantAttributeName=new ParticipantAttributeName;
|
||||
$oParticipantAttributeName->attribute_type=$data['attribute_type'];
|
||||
$oParticipantAttributeName->defaultname=$data['defaultname'];
|
||||
$oParticipantAttributeName->visible=$data['visible'];
|
||||
$oParticipantAttributeName->save();
|
||||
$iAttributeID = $oParticipantAttributeName->attribute_id;
|
||||
|
||||
$insertid = getLastInsertID($this->tableName());
|
||||
$insertnameslang = array('attribute_id' => $insertid,
|
||||
'attribute_name'=>$data['defaultname'],
|
||||
'lang' => Yii::app()->session['adminlang']);
|
||||
Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}', $insertnameslang);
|
||||
return $insertid;
|
||||
$oParticipantAttributeNameLang=new ParticipantAttributeNameLang;
|
||||
$oParticipantAttributeNameLang->attribute_id=$iAttributeID;
|
||||
$oParticipantAttributeNameLang->attribute_name=$data['defaultname'];
|
||||
$oParticipantAttributeNameLang->lang=Yii::app()->session['adminlang'];
|
||||
$oParticipantAttributeNameLang->save();
|
||||
|
||||
return $iAttributeID;
|
||||
}
|
||||
|
||||
//updates the attribute values in participant_attribute_values
|
||||
|
|
|
@ -59,11 +59,11 @@ class ParticipantAttributeNameLang extends LSActiveRecord
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
// NOTE: you should only define rules for those attributes that
|
||||
// will receive user inputs.
|
||||
// NOTE: you should only define rules for those attributes that will receive user inputs.
|
||||
return array(
|
||||
// The following rule is used by search().
|
||||
// Please remove those attributes that should not be searched.
|
||||
array('attribute_name','filter','filter' => 'strip_tags'),
|
||||
// The following rule is used by search().
|
||||
// Please remove those attributes that should not be searched.
|
||||
array('attribute_id, attribute_name, lang', 'safe', 'on'=>'search'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -58,22 +58,112 @@ class Permission extends LSActiveRecord
|
|||
*/
|
||||
public static function getSurveyBasePermissions()
|
||||
{
|
||||
$clang = Yii::app()->lang;
|
||||
$aPermissions=array(
|
||||
'assessments'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Assessments"),'description'=>$clang->gT("Permission to create/view/update/delete assessments rules for a survey"),'img'=>'assessments'),
|
||||
'quotas'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Quotas"),'description'=>$clang->gT("Permission to create/view/update/delete quota rules for a survey"),'img'=>'quota'),
|
||||
'responses'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Responses"),'description'=>$clang->gT("Permission to create(data entry)/view/update/delete/import/export responses"),'img'=>'browse'),
|
||||
'statistics'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Statistics"),'description'=>$clang->gT("Permission to view statistics"),'img'=>'statistics'),
|
||||
'survey'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey deletion"),'description'=>$clang->gT("Permission to delete a survey"),'img'=>'delete'),
|
||||
'surveyactivation'=>array('create'=>false,'read'=>false,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey activation"),'description'=>$clang->gT("Permission to activate/deactivate a survey"),'img'=>'activate_deactivate'),
|
||||
'surveycontent'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Survey content"),'description'=>$clang->gT("Permission to create/view/update/delete/import/export the questions, groups, answers & conditions of a survey"),'img'=>'add'),
|
||||
'surveylocale'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey locale settings"),'description'=>$clang->gT("Permission to view/update the survey locale settings"),'img'=>'edit'),
|
||||
'surveysecurity'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey security"),'description'=>$clang->gT("Permission to modify survey security settings"),'img'=>'survey_security'),
|
||||
'surveysettings'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey settings"),'description'=>$clang->gT("Permission to view/update the survey settings including token table creation"),'img'=>'survey_settings'),
|
||||
'tokens'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Tokens"),'description'=>$clang->gT("Permission to create/update/delete/import/export token entries"),'img'=>'tokens'),
|
||||
'translations'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Quick translation"),'description'=>$clang->gT("Permission to view & update the translations using the quick-translation feature"),'img'=>'translate')
|
||||
$defaults = array(
|
||||
'create' => true,
|
||||
'read' => true,
|
||||
'update' => true,
|
||||
'delete' => true,
|
||||
'import' => true,
|
||||
'export' => true
|
||||
);
|
||||
uasort($aPermissions,"comparePermission");
|
||||
$aPermissions = array(
|
||||
'assessments' => array(
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Assessments"),
|
||||
'description' => gT("Permission to create/view/update/delete assessments rules for a survey"),
|
||||
'img' => 'assessments'
|
||||
),
|
||||
'quotas' => array(
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Quotas"),
|
||||
'description' => gT("Permission to create/view/update/delete quota rules for a survey"),
|
||||
'img' => 'quota'
|
||||
),
|
||||
'responses' => array(
|
||||
'title' => gT("Responses"),
|
||||
'description' => gT("Permission to create(data entry)/view/update/delete/import/export responses"),
|
||||
'img' => 'browse'
|
||||
),
|
||||
'statistics' => array(
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Statistics"),
|
||||
'description' => gT("Permission to view statistics"),
|
||||
'img' => 'statistics'
|
||||
),
|
||||
'survey' => array(
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Survey deletion"),
|
||||
'description' => gT("Permission to delete a survey"),
|
||||
'img' => 'delete'
|
||||
),
|
||||
'surveyactivation' => array(
|
||||
'create' => false,
|
||||
'read' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Survey activation"),
|
||||
'description' => gT("Permission to activate/deactivate a survey"),
|
||||
'img' => 'activate_deactivate'
|
||||
),
|
||||
'surveycontent' => array(
|
||||
'title' => gT("Survey content"),
|
||||
'description' => gT("Permission to create/view/update/delete/import/export the questions, groups, answers & conditions of a survey"),
|
||||
'img' => 'add'
|
||||
),
|
||||
'surveylocale' => array(
|
||||
'create' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Survey text elements"),
|
||||
'description' => gT("Permission to view/update the survey text elements : survey title, survey description, welcome and end message …"),
|
||||
'img'=>'edit'
|
||||
),
|
||||
'surveysecurity' => array(
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Survey security"),
|
||||
'description' => gT("Permission to modify survey security settings"),
|
||||
'img' => 'survey_security'
|
||||
),
|
||||
'surveysettings' => array(
|
||||
'create' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Survey settings"),
|
||||
'description' => gT("Permission to view/update the survey settings including token table creation"),
|
||||
'img' => 'survey_settings'
|
||||
),
|
||||
'tokens' => array(
|
||||
'title' => gT("Tokens"),'description'=>gT("Permission to create/update/delete/import/export token entries"),
|
||||
'img' => 'tokens'
|
||||
),
|
||||
'translations' => array(
|
||||
'create' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Quick translation"),
|
||||
'description' => gT("Permission to view & update the translations using the quick-translation feature"),
|
||||
'img' => 'translate'
|
||||
)
|
||||
);
|
||||
uasort($aPermissions, array(__CLASS__,"comparePermissionTitle"));
|
||||
foreach ($aPermissions as &$permission)
|
||||
{
|
||||
$permission = array_merge($defaults, $permission);
|
||||
}
|
||||
return $aPermissions;
|
||||
}
|
||||
|
||||
|
@ -87,18 +177,76 @@ class Permission extends LSActiveRecord
|
|||
*/
|
||||
public static function getGlobalBasePermissions()
|
||||
{
|
||||
$clang = Yii::app()->lang;
|
||||
$aPermissions=array(
|
||||
'surveys'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>true,'title'=>$clang->gT("Surveys"),'description'=>$clang->gT("Permission to create surveys (for which all permissions are automatically given) and view, update and delete surveys from other users"),'img'=>'survey'),
|
||||
'users'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Users"),'description'=>$clang->gT("Permission to create, view, update and delete users"),'img'=>'security'),
|
||||
'usergroups'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("User groups"),'description'=>$clang->gT("Permission to create, view, update and delete user groups"),'img'=>'usergroup'),
|
||||
'templates'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Templates"),'description'=>$clang->gT("Permission to create, view, update, delete, export and import templates"),'img'=>'templates'),
|
||||
'labelsets'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Label sets"),'description'=>$clang->gT("Permission to create, view, update, delete, export and import label sets/labels"),'img'=>'labels'),
|
||||
'settings'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>true,'export'=>false,'title'=>$clang->gT("Settings & Plugins"),'description'=>$clang->gT("Permission to view and update global settings & plugins and to delete and import plugins"),'img'=>'global'),
|
||||
'participantpanel'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>true,'title'=>$clang->gT("Participant panel"),'description'=>$clang->gT("Permission to create your own participants in the central participants database (for which all permissions are automatically given) and view, update and delete participants from other users"),'img'=>'cpdb'),
|
||||
$defaults = array(
|
||||
'create' => true,
|
||||
'read' => true,
|
||||
'update' => true,
|
||||
'delete' => true,
|
||||
'import' => true,
|
||||
'export' => true
|
||||
);
|
||||
uasort($aPermissions,"comparePermission");
|
||||
$aPermissions=array('superadmin'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Superadministrator"),'description'=>$clang->gT("Unlimited administration permissions"),'img'=>'superadmin'))+$aPermissions;
|
||||
$aPermissions=array(
|
||||
'surveys' => array(
|
||||
'import' => false,
|
||||
'title' => gT("Surveys"),
|
||||
'description' => gT("Permission to create surveys (for which all permissions are automatically given) and view, update and delete surveys from other users"),
|
||||
'img'=>'survey'
|
||||
),
|
||||
'users' => array(
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Users"),
|
||||
'description' => gT("Permission to create, view, update and delete users"),
|
||||
'img' => 'security'
|
||||
),
|
||||
'usergroups' => array(
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("User groups"),
|
||||
'description' => gT("Permission to create, view, update and delete user groups"),
|
||||
'img' => 'usergroup'
|
||||
),
|
||||
'templates' => array(
|
||||
'title'=> gT("Templates"),
|
||||
'description' => gT("Permission to create, view, update, delete, export and import templates"),
|
||||
'img' => 'templates'
|
||||
),
|
||||
'labelsets' => array(
|
||||
'title' => gT("Label sets"),
|
||||
'description' => gT("Permission to create, view, update, delete, export and import label sets/labels"),
|
||||
'img' => 'labels'
|
||||
),
|
||||
'settings' => array(
|
||||
'create' => false,
|
||||
'delete' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Settings & Plugins"),
|
||||
'description' => gT("Permission to view and update global settings & plugins and to delete and import plugins"),
|
||||
'img' => 'global'
|
||||
),
|
||||
'participantpanel' => array(
|
||||
'import' => false,
|
||||
'title' => gT("Participant panel"),
|
||||
'description' => gT("Permission to create your own participants in the central participants database (for which all permissions are automatically given) and view, update and delete participants from other users"),
|
||||
'img' => 'cpdb'
|
||||
),
|
||||
);
|
||||
uasort($aPermissions, array(__CLASS__,"comparePermissionTitle"));
|
||||
$aPermissions['superadmin'] = array(
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false,
|
||||
'import' => false,
|
||||
'export' => false,
|
||||
'title' => gT("Superadministrator"),
|
||||
'description' => gT("Unlimited administration permissions"),
|
||||
'img' => 'superadmin'
|
||||
);
|
||||
|
||||
foreach ($aPermissions as &$permission)
|
||||
{
|
||||
$permission = array_merge($defaults, $permission);
|
||||
}
|
||||
return $aPermissions;
|
||||
}
|
||||
|
||||
|
@ -259,18 +407,6 @@ class Permission extends LSActiveRecord
|
|||
$this->setPermissions($iUserID, $iSurveyID, 'survey', $aPermissionsToSet);
|
||||
}
|
||||
|
||||
function deleteSomeRecords($condition)
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
|
||||
foreach ($condition as $item => $value)
|
||||
{
|
||||
$criteria->addCondition($item."='".$value."'");
|
||||
}
|
||||
|
||||
$this->deleteAll($criteria);
|
||||
}
|
||||
|
||||
function insertRecords($data)
|
||||
{
|
||||
foreach ($item as $data)
|
||||
|
@ -330,19 +466,9 @@ class Permission extends LSActiveRecord
|
|||
if (!in_array($sCRUD,array('create','read','update','delete','import','export'))) return false;
|
||||
$sCRUD=$sCRUD.'_p';
|
||||
|
||||
if (is_null($iUserID))
|
||||
{
|
||||
if (!Yii::app()->user->getIsGuest()) $iUserID = Yii::app()->session['loginID'];
|
||||
else return false;
|
||||
}
|
||||
|
||||
if ($iEntityID>0 && $sEntityName=='survey')
|
||||
{
|
||||
$aSurveyInfo=getSurveyInfo($iEntityID);// OR find but then don't use $static
|
||||
if (!$aSurveyInfo) return false;
|
||||
// If you own a survey you have access to the whole survey
|
||||
if ($iUserID==$aSurveyInfo['owner_id']) return true;
|
||||
}
|
||||
$iUserID=self::getUserId($iUserID);
|
||||
if(!$iUserID)
|
||||
return false;
|
||||
|
||||
// Check if superadmin and cache it
|
||||
if (!isset($aPermissionCache[0]['global'][$iUserID]['superadmin']['read_p']))
|
||||
|
@ -388,7 +514,7 @@ class Permission extends LSActiveRecord
|
|||
function hasGlobalPermission($sPermission, $sCRUD, $iUserID=null)
|
||||
{
|
||||
return $this->hasPermission(0, 'global', $sPermission, $sCRUD, $iUserID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user has a certain permission in the given survey
|
||||
|
@ -399,10 +525,23 @@ class Permission extends LSActiveRecord
|
|||
* @param $iUserID integer User ID - if not given the one of the current user is used
|
||||
* @return bool True if user has the permission
|
||||
*/
|
||||
function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD, $iUserID=null)
|
||||
function hasSurveyPermission($iSurveyID,$sPermission, $sCRUD, $iUserID=null)
|
||||
{
|
||||
return $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
|
||||
}
|
||||
$oSurvey=Survey::Model()->findByPk($iSurveyID);
|
||||
if (!$oSurvey)
|
||||
return false;
|
||||
$iUserID=self::getUserId($iUserID);
|
||||
if(!$iUserID)
|
||||
return false;
|
||||
// If you own a survey you have access to the whole survey
|
||||
if ($iUserID==$oSurvey->owner_id)
|
||||
return true;
|
||||
|
||||
// Get global correspondance for surveys rigth
|
||||
$sGlobalCRUD=($sCRUD=='create' || ($sCRUD=='delete' && $sPermission!='survey') ) ? 'update' : $sCRUD;
|
||||
|
||||
return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a user has permission to use a certain template
|
||||
|
@ -414,7 +553,29 @@ class Permission extends LSActiveRecord
|
|||
function hasTemplatePermission($sTemplateName, $sCRUD='read', $iUserID=null)
|
||||
{
|
||||
return $this->hasPermission(0, 'template', $sTemplateName, $sCRUD, $iUserID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/* function used to order Permission by language string
|
||||
/* @param aApermission array The first permission information
|
||||
/* @param aBpermission array The second permission information
|
||||
/* @return bool
|
||||
*/
|
||||
private static function comparePermissionTitle($aApermission,$aBpermission)
|
||||
{
|
||||
return strcmp($aApermission['title'], $aBpermission['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
/* get the default/fixed $iUserID
|
||||
/* @param iUserID optionnal user id
|
||||
/* @return integer user id
|
||||
*/
|
||||
private static function getUserId($iUserID=null)
|
||||
{
|
||||
if (is_null($iUserID) && !Yii::app()->user->getIsGuest())
|
||||
$iUserID = Yii::app()->session['loginID'];
|
||||
|
||||
return $iUserID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
*/
|
||||
public static function updateSortOrder($gid, $surveyid)
|
||||
{
|
||||
$questions = self::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => Survey::model()->findByPk($surveyid)->language));
|
||||
$questions = self::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => Survey::model()->findByPk($surveyid)->language), array('order'=>'question_order') );
|
||||
$p = 0;
|
||||
foreach ($questions as $question)
|
||||
{
|
||||
|
@ -168,7 +168,7 @@
|
|||
function updateQuestionOrder($gid,$language,$position=0)
|
||||
{
|
||||
$data=Yii::app()->db->createCommand()->select('qid')
|
||||
->where(array('and','gid=:gid','language=:language'))
|
||||
->where(array('and','gid=:gid','language=:language', 'parent_qid=0'))
|
||||
->order('question_order, title ASC')
|
||||
->from('{{questions}}')
|
||||
->bindParam(':gid', $gid, PDO::PARAM_INT)
|
||||
|
@ -590,7 +590,7 @@
|
|||
'description' => gT("Yes/No"),
|
||||
'group' => gT("Mask questions"),
|
||||
'subquestions' => 0,
|
||||
'hasdefaultvalues' => 0,
|
||||
'hasdefaultvalues' => 1,
|
||||
'assessable' => 0,
|
||||
'answerscales' => 0),
|
||||
"!" => array(
|
||||
|
|
|
@ -101,6 +101,8 @@ class QuestionAttribute extends LSActiveRecord
|
|||
{
|
||||
$iQuestionID=(int)$iQuestionID;
|
||||
static $aQuestionAttributesStatic=array();// TODO : replace by Yii::app()->cache
|
||||
// Limit the size of the attribute cache due to memory usage
|
||||
$aQuestionAttributesStatic=array_splice($aQuestionAttributesStatic,-1000,null,true);
|
||||
if(isset($aQuestionAttributesStatic[$iQuestionID]))
|
||||
{
|
||||
return $aQuestionAttributesStatic[$iQuestionID];
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
$files = array();
|
||||
foreach ($questions as $question)
|
||||
{
|
||||
|
||||
|
||||
$field = "{$question->sid}X{$question->gid}X{$question->qid}";
|
||||
$data = json_decode($this->getAttribute($field), true);
|
||||
$data = json_decode(stripslashes($this->getAttribute($field)), true);
|
||||
if (is_array($data))
|
||||
{
|
||||
$files = array_merge($files, $data);
|
||||
|
|
|
@ -52,9 +52,9 @@ class Session extends CActiveRecord
|
|||
|
||||
public function afterFind()
|
||||
{
|
||||
// MSSQL delivers hex data
|
||||
$sDatabasetype = Yii::app()->db->getDriverName();
|
||||
if($sDatabasetype=='sqlsrv' || $sDatabasetype=='mssql' || $sDatabasetype=='dblib')
|
||||
// MSSQL delivers hex data (except for dblib driver)
|
||||
if($sDatabasetype=='sqlsrv' || $sDatabasetype=='mssql')
|
||||
{
|
||||
$this->data=$this->hexToStr($this->data);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class Survey extends LSActiveRecord
|
|||
* This is a static cache, it lasts only during the active request. If you ever need
|
||||
* to clear it, like on activation of a survey when in the same request a row is read,
|
||||
* saved and read again you can use resetCache() method.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $findByPkCache = array();
|
||||
|
@ -49,7 +49,7 @@ class Survey extends LSActiveRecord
|
|||
{
|
||||
$dateTime = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig('timeadjust'));
|
||||
$dateTime = dateShift($dateTime, "Y-m-d H:i:s", '-1 day');
|
||||
|
||||
|
||||
if (!isset($surveyId))
|
||||
{
|
||||
$this->expires = $dateTime;
|
||||
|
@ -182,7 +182,7 @@ class Survey extends LSActiveRecord
|
|||
array('showgroupinfo', 'in','range'=>array('B','N','D','X'), 'allowEmpty'=>true),
|
||||
array('showqnumcode', 'in','range'=>array('B','N','C','X'), 'allowEmpty'=>true),
|
||||
array('format', 'in','range'=>array('G','S','A'), 'allowEmpty'=>true),
|
||||
array('googleanalyticsstyle', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'2', 'allowEmpty'=>true),
|
||||
array('googleanalyticsstyle', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'2', 'allowEmpty'=>true),
|
||||
array('autonumber_start','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('tokenlength','numerical', 'integerOnly'=>true,'allowEmpty'=>true, 'min'=>'5', 'max'=>'36'),
|
||||
array('bouncetime','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
|
@ -210,7 +210,7 @@ class Survey extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* permission scope for this model
|
||||
*
|
||||
* Actually only test if user have minimal access to survey (read)
|
||||
* @access public
|
||||
* @param int $loginID
|
||||
* @return CActiveRecord
|
||||
|
@ -218,6 +218,8 @@ class Survey extends LSActiveRecord
|
|||
public function permission($loginID)
|
||||
{
|
||||
$loginID = (int) $loginID;
|
||||
if(Permission::model()->hasGlobalPermission('surveys','read'))// Test global before adding criteria
|
||||
return $this;
|
||||
$criteria = $this->getDBCriteria();
|
||||
$criteria->mergeWith(array(
|
||||
'condition' => 'sid IN (SELECT entity_id FROM {{permissions}} WHERE entity = :entity AND uid = :uid AND permission = :permission AND read_p = 1)
|
||||
|
@ -268,7 +270,7 @@ class Survey extends LSActiveRecord
|
|||
*/
|
||||
public function getTokenAttributes()
|
||||
{
|
||||
$attdescriptiondata = @unserialize($this->attributedescriptions);
|
||||
$attdescriptiondata = decodeTokenAttributes($this->attributedescriptions);
|
||||
// checked for invalid data
|
||||
if($attdescriptiondata == null)
|
||||
{
|
||||
|
@ -306,14 +308,14 @@ class Survey extends LSActiveRecord
|
|||
}
|
||||
}
|
||||
$ls = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $this->sid, 'surveyls_language' => $this->language));
|
||||
self::model()->updateByPk($this->sid, array('attributedescriptions' => serialize($fields)));
|
||||
$ls->surveyls_attributecaptions = serialize($languagesettings);
|
||||
self::model()->updateByPk($this->sid, array('attributedescriptions' => json_encode($fields)));
|
||||
$ls->surveyls_attributecaptions = json_encode($languagesettings);
|
||||
$ls->save();
|
||||
$attdescriptiondata = $fields;
|
||||
}
|
||||
$aCompleteData=array();
|
||||
foreach ($attdescriptiondata as $sKey=>$aValues)
|
||||
{
|
||||
{
|
||||
if (!is_array($aValues)) $aValues=array();
|
||||
$aCompleteData[$sKey]= array_merge(array(
|
||||
'description' => '',
|
||||
|
@ -324,10 +326,10 @@ class Survey extends LSActiveRecord
|
|||
}
|
||||
return $aCompleteData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true in a token table exists for the given $surveyId
|
||||
*
|
||||
*
|
||||
* @staticvar array $tokens
|
||||
* @param int $iSurveyID
|
||||
* @return boolean
|
||||
|
@ -335,19 +337,19 @@ class Survey extends LSActiveRecord
|
|||
public function hasTokens($iSurveyID) {
|
||||
static $tokens = array();
|
||||
$iSurveyID = (int) $iSurveyID;
|
||||
|
||||
|
||||
if (!isset($tokens[$iSurveyID])) {
|
||||
// Make sure common_helper is loaded
|
||||
Yii::import('application.helpers.common_helper', true);
|
||||
|
||||
|
||||
$tokens_table = "{{tokens_{$iSurveyID}}}";
|
||||
if (tableExists($tokens_table)) {
|
||||
$tokens[$iSurveyID] = true;
|
||||
} else {
|
||||
$tokens[$iSurveyID] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $tokens[$iSurveyID];
|
||||
}
|
||||
|
||||
|
@ -378,7 +380,11 @@ class Survey extends LSActiveRecord
|
|||
foreach ($aData as $k => $v)
|
||||
$survey->$k = $v;
|
||||
$sResult= $survey->save();
|
||||
if ($sResult==false) return false;
|
||||
if (!$sResult)
|
||||
{
|
||||
tracevar($survey->getErrors());
|
||||
return false;
|
||||
}
|
||||
else return $aData['sid'];
|
||||
}
|
||||
|
||||
|
@ -432,7 +438,7 @@ class Survey extends LSActiveRecord
|
|||
Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function findByPk($pk, $condition = '', $params = array()) {
|
||||
if (empty($condition) && empty($params)) {
|
||||
if (array_key_exists($pk, $this->findByPkCache)) {
|
||||
|
@ -442,21 +448,21 @@ class Survey extends LSActiveRecord
|
|||
if (!is_null($result)) {
|
||||
$this->findByPkCache[$pk] = $result;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::findByPk($pk, $condition, $params);
|
||||
|
||||
return parent::findByPk($pk, $condition, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* findByPk uses a cache to store a result. Use this method to force clearing that cache.
|
||||
*/
|
||||
public function resetCache() {
|
||||
$this->findByPkCache = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attribute renamed to questionindex in dbversion 169
|
||||
* Y maps to 1 otherwise 0;
|
||||
|
|
|
@ -104,8 +104,8 @@ class SurveyLanguageSetting extends LSActiveRecord
|
|||
array('surveyls_url','LSYii_Validators','isUrl'=>true),
|
||||
array('surveyls_urldescription','LSYii_Validators'),
|
||||
|
||||
array('surveyls_dateformat', 'numerical', 'integerOnly'=>true, 'min'=>'1', 'max'=>'12', 'allowEmpty'=>true),
|
||||
array('surveyls_numberformat', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'1', 'allowEmpty'=>true),
|
||||
array('surveyls_dateformat', 'numerical', 'integerOnly'=>true, 'min'=>'1', 'max'=>'12', 'allowEmpty'=>true),
|
||||
array('surveyls_numberformat', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'1', 'allowEmpty'=>true),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ class SurveyLanguageSetting extends LSActiveRecord
|
|||
|
||||
if (empty($this->$attribute)) $this->$attribute=$aDefaultTextData[$attribute];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the token's captions
|
||||
|
@ -205,17 +205,17 @@ class SurveyLanguageSetting extends LSActiveRecord
|
|||
|
||||
/**
|
||||
* Updates a single record identified by $condition with the
|
||||
* key/value pairs in the $data array.
|
||||
*
|
||||
* key/value pairs in the $data array.
|
||||
*
|
||||
* @param type $data
|
||||
* @param type $condition
|
||||
* @param type $xssfiltering
|
||||
* @return boolean
|
||||
*/
|
||||
function updateRecord($data,$condition='', $xssfiltering = false)
|
||||
{
|
||||
{
|
||||
if (isset($data['surveyls_url']) && $data['surveyls_url']== 'http://') {$data['surveyls_url']="";}
|
||||
|
||||
|
||||
/*
|
||||
* Mdekker: don't think we need this anymore
|
||||
if($xssfiltering)
|
||||
|
@ -235,14 +235,14 @@ class SurveyLanguageSetting extends LSActiveRecord
|
|||
$data["endtext"] = $filter->purify($data["endtext"]);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
$record = $this->findByPk($condition);
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$record->$key = $value;
|
||||
}
|
||||
$record->save($xssfiltering);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
// Check if we have custom attributes.
|
||||
if ($this->hasAttribute('attribute_1'))
|
||||
{
|
||||
foreach (unserialize($this->survey->attributedescriptions) as $key => $info)
|
||||
foreach (decodeTokenAttributes($this->survey->attributedescriptions) as $key => $info)
|
||||
{
|
||||
$labels[$key] = $info['description'];
|
||||
}
|
||||
|
@ -79,14 +79,14 @@
|
|||
'token' => $token
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function generateToken()
|
||||
{
|
||||
$length = $this->survey->tokenlength;
|
||||
|
||||
$this->token = randomChars($length);
|
||||
$counter = 0;
|
||||
while (!$this->validate('token'))
|
||||
while (!$this->validate(array('token')))
|
||||
{
|
||||
$this->token = randomChars($length);
|
||||
$counter++;
|
||||
|
@ -108,7 +108,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param int $surveyId
|
||||
* @param string $scenario
|
||||
* @return Token Description
|
||||
|
@ -129,14 +129,15 @@
|
|||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('token', 'unique', 'allowEmpty' => true),
|
||||
array('token', 'unique', 'allowEmpty' => true),// 'caseSensitive'=>false only for mySql
|
||||
array(implode(',', $this->tableSchema->columnNames), 'safe'),
|
||||
array('remindercount','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('email','filter','filter'=>'trim'),
|
||||
array('email','LSYii_EmailIDNAValidator', 'allowEmpty'=>true, 'allowMultiple'=>true),
|
||||
array('remindercount','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('email','filter','filter'=>'trim'),
|
||||
array('email','LSYii_EmailIDNAValidator', 'allowEmpty'=>true, 'allowMultiple'=>true),
|
||||
array('usesleft','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('mpid','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('blacklisted', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
|
||||
array('mpid','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('blacklisted', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
|
||||
array('emailstatus', 'default', 'value' => 'OK'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -163,7 +164,8 @@
|
|||
"COUNT(CASE WHEN (token IS NULL OR token='') THEN 1 ELSE NULL END) as invalid",
|
||||
"COUNT(CASE WHEN (sent!='N' AND sent<>'') THEN 1 ELSE NULL END) as sent",
|
||||
"COUNT(CASE WHEN (emailstatus LIKE 'OptOut%') THEN 1 ELSE NULL END) as optout",
|
||||
"COUNT(CASE WHEN (completed!='N' and completed<>'') THEN 1 ELSE NULL END) as completed"
|
||||
"COUNT(CASE WHEN (completed!='N' and completed<>'' and completed !='Q') THEN 1 ELSE NULL END) as completed",
|
||||
"COUNT(CASE WHEN (completed='Q') THEN 1 ELSE NULL END) as screenout",
|
||||
);
|
||||
$command = $this->getCommandBuilder()->createFindCommand($this->getTableSchema(),$criteria);
|
||||
return $command->queryRow();
|
||||
|
@ -172,7 +174,7 @@
|
|||
public function tableName()
|
||||
{
|
||||
return '{{tokens_' . $this->dynamicId . '}}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -85,12 +85,14 @@ class TokenDynamic extends LSActiveRecord
|
|||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('remindercount','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('email','filter','filter'=>'trim'),
|
||||
array('email','LSYii_EmailIDNAValidator', 'allowEmpty'=>true, 'allowMultiple'=>true),
|
||||
array('usesleft','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('mpid','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('blacklisted', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
|
||||
array('token', 'unique', 'allowEmpty'=>true),// 'caseSensitive'=>false only for mySql
|
||||
array('remindercount','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('email','filter','filter'=>'trim'),
|
||||
array('email','LSYii_EmailIDNAValidator', 'allowEmpty'=>true, 'allowMultiple'=>true),
|
||||
array('usesleft','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('mpid','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
|
||||
array('blacklisted', 'in','range'=>array('Y','N'), 'allowEmpty'=>true),
|
||||
array('emailstatus', 'default', 'value' => 'OK'),
|
||||
// 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
|
||||
|
|
|
@ -664,6 +664,18 @@ NULL~NUMBEROFQUESTIONS/=5
|
|||
NULL~NUMBEROFQUESTIONS-=6
|
||||
NULL~'Tom'='tired'
|
||||
NULL~max()
|
||||
NULL~convert_value( 10, 1, '0,5,10,15,20', '0,5,10,15')
|
||||
100~convert_value( 10, 1, '0,5,10,15,20', '0,50,100,150,200')
|
||||
NULL~convert_value( 10, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
100~convert_value( 8, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
100~convert_value( 12, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
0~convert_value( 0, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
0~convert_value( -10000, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
NULL~convert_value( -10000, 1, '0,5,10,15,20', '0,50,100,150,200')
|
||||
200~convert_value( 20, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
200~convert_value( 20, 1, '0,5,10,15,20', '0,50,100,150,200')
|
||||
200~convert_value( 30, 0, '0,5,10,15,20', '0,50,100,150,200')
|
||||
NULL~convert_value( 30, 1, '0,5,10,15,20', '0,50,100,150,200')
|
||||
EOD;
|
||||
|
||||
$atests = explode("\n",$tests);
|
||||
|
@ -895,4 +907,4 @@ EOD;
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -312,7 +312,7 @@ of these things:
|
|||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
e) verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
|
|
49
sources/application/third_party/phpmailer/PHPMailerAutoload.php
vendored
Normal file
49
sources/application/third_party/phpmailer/PHPMailerAutoload.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* PHP Version 5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function PHPMailerAutoload($classname)
|
||||
{
|
||||
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
|
||||
if (is_readable($filename)) {
|
||||
require $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
||||
//SPL autoloading was introduced in PHP 5.1.2
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
} else {
|
||||
spl_autoload_register('PHPMailerAutoload');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Fall back to traditional autoload for old PHP versions
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function __autoload($classname)
|
||||
{
|
||||
PHPMailerAutoload($classname);
|
||||
}
|
||||
}
|
148
sources/application/third_party/phpmailer/README.md
vendored
Normal file
148
sources/application/third_party/phpmailer/README.md
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png)
|
||||
|
||||
# PHPMailer - A full-featured email creation and transfer class for PHP
|
||||
|
||||
Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)
|
||||
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
|
||||
[![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
|
||||
|
||||
## Class Features
|
||||
|
||||
- Probably the world's most popular code for sending email from PHP!
|
||||
- Used by many open-source projects: Drupal, SugarCRM, Yii, Joomla! and many more
|
||||
- Integrated SMTP support - send without a local mail server
|
||||
- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
|
||||
- Multipart/alternative emails for mail clients that do not read HTML email
|
||||
- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
|
||||
- SMTP authentication with LOGIN, PLAIN, NTLM and CRAM-MD5 mechanisms over SSL and TLS transports
|
||||
- Native language support
|
||||
- DKIM and S/MIME signing support
|
||||
- Compatible with PHP 5.0 and later
|
||||
- Much more!
|
||||
|
||||
## Why you might need it
|
||||
|
||||
Many PHP developers utilize email in their code. The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.
|
||||
|
||||
Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong!
|
||||
*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try SwiftMailer, Zend_Mail, eZcomponents etc.
|
||||
|
||||
The PHP mail() function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
|
||||
|
||||
## License
|
||||
|
||||
This software is licenced under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html). Please read LICENSE for information on the
|
||||
software availability and distribution.
|
||||
|
||||
## Installation & loading
|
||||
|
||||
PHPMailer is available via [Composer/Packagist](https://packagist.org/packages/phpmailer/phpmailer). Alternatively, just copy the contents of the PHPMailer folder into somewhere that's in your PHP `include_path` setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub.
|
||||
|
||||
PHPMailer provides an SPL-compatible autoloader, and that is the preferred way of loading the library - just `require '/path/to/PHPMailerAutoload.php';` and everything should work. The autoloader does not throw errors if it can't find classes so it prepends itself to the SPL list, allowing your own (or your framework's) autoloader to catch errors. SPL autoloading was introduced in PHP 5.1.0, so if you are using a version older than that you will need to require/include each class manually.
|
||||
PHPMailer does *not* declare a namespace because namespaces were only introduced in PHP 5.3.
|
||||
|
||||
### Minimal installation
|
||||
|
||||
While installing the entire package manually or with composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [class.phpmailer.php](class.phpmailer.php). If you're using SMTP, you'll need [class.smtp.php](class.smtp.php), and if you're using POP-before SMTP, you'll need [class.pop3.php](class.pop3.php). For all of these, we recommend you use [the autoloader](PHPMailerAutoload.php) too. You can skip the [language](language/) folder if you're not showing errors to users and can make do with English-only errors. You may need the additional classes in the [extras](extras/) folder if you are using those features, including NTLM authentication, advanced HTML-to-text conversion and ics generation.
|
||||
|
||||
## A Simple Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'PHPMailerAutoload.php';
|
||||
|
||||
$mail = new PHPMailer;
|
||||
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'user@example.com'; // SMTP username
|
||||
$mail->Password = 'secret'; // SMTP password
|
||||
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
|
||||
|
||||
$mail->From = 'from@example.com';
|
||||
$mail->FromName = 'Mailer';
|
||||
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
|
||||
$mail->addAddress('ellen@example.com'); // Name is optional
|
||||
$mail->addReplyTo('info@example.com', 'Information');
|
||||
$mail->addCC('cc@example.com');
|
||||
$mail->addBCC('bcc@example.com');
|
||||
|
||||
$mail->WordWrap = 50; // Set word wrap to 50 characters
|
||||
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
|
||||
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
|
||||
$mail->Subject = 'Here is the subject';
|
||||
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
|
||||
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
|
||||
if(!$mail->send()) {
|
||||
echo 'Message could not be sent.';
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message has been sent';
|
||||
}
|
||||
```
|
||||
|
||||
You'll find plenty more to play with in the [examples](examples/) folder.
|
||||
|
||||
That's it. You should now be ready to use PHPMailer!
|
||||
|
||||
## Localization
|
||||
PHPMailer defaults to English, but in the [language](language/) folder you'll find numerous (39 at the time of writing) translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
|
||||
|
||||
```php
|
||||
// To load the French version
|
||||
$mail->setLanguage('fr', '/optional/path/to/language/directory/');
|
||||
```
|
||||
|
||||
We welcome corrections and new languages - if you're looking for corrections to do, run the [phpmailerLangTest.php](test/phpmailerLangTest.php) script in the tests folder and it will show any missing translations.
|
||||
|
||||
## Documentation
|
||||
|
||||
Generated documentation is [available online](http://phpmailer.github.io/PHPMailer/).
|
||||
|
||||
You'll find some basic user-level docs in the [docs](docs/) folder, and you can generate complete API-level documentation using the [generatedocs.sh](docs/generatedocs.sh) shell script in the docs folder, though you'll need to install [PHPDocumentor](http://www.phpdoc.org) first. You may find [the unit tests](test/phpmailerTest.php) a good source of how to do various operations such as encryption.
|
||||
|
||||
## Tests
|
||||
|
||||
There is a PHPUnit test script in the [test](test/) folder.
|
||||
|
||||
Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)
|
||||
|
||||
If this isn't passing, is there something you can do to help?
|
||||
|
||||
## Contributing
|
||||
|
||||
Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues).
|
||||
|
||||
We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.
|
||||
|
||||
With the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:
|
||||
|
||||
`git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git`
|
||||
|
||||
Please *don't* use the SourceForge or Google Code projects any more.
|
||||
|
||||
## Changelog
|
||||
|
||||
See [changelog](changelog.md).
|
||||
|
||||
## History
|
||||
- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/).
|
||||
- Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
|
||||
- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
|
||||
- Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer).
|
||||
- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer.
|
||||
- PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub.
|
||||
|
||||
### What's changed since moving from SourceForge?
|
||||
- Official successor to the SourceForge and Google Code projects.
|
||||
- Test suite.
|
||||
- Continuous integration with Travis-CI.
|
||||
- Composer support.
|
||||
- Public development.
|
||||
- Additional languages and language strings.
|
||||
- CRAM-MD5 authentication support.
|
||||
- Preserves full repo history of authors, commits and branches from the original SourceForge project.
|
151
sources/application/third_party/phpmailer/README.php
vendored
151
sources/application/third_party/phpmailer/README.php
vendored
|
@ -1,151 +0,0 @@
|
|||
<?php die(); ?>
|
||||
/******************************************************************* *
|
||||
The http://phpmailer.codeworxtech.com/ website now carries a few * *
|
||||
advertisements through the Google Adsense network. Please visit * * the
|
||||
advertiser sites and help us offset some of our costs. * * Thanks .... *
|
||||
********************************************************************/
|
||||
|
||||
PHPMailer Full Featured Email Transfer Class for PHP
|
||||
========================================== Version 5.1.0 (11/11/2009)
|
||||
|
||||
With the release of this version, we are initiating a new version
|
||||
numbering system to differentiate from the PHP4 version of PHPMailer.
|
||||
|
||||
Most notable in this release is fully object oriented code. We now have
|
||||
available the PHPDocumentor (phpdocs) documentation. This is separate
|
||||
from the regular download to keep file sizes down. Please see the
|
||||
download area of http://phpmailer.codeworxtech.com. We also have created
|
||||
a new test script (see /test_script) that you can use right out of the
|
||||
box. Copy the /test_script folder directly to your server (in the same
|
||||
structure ... with class.phpmailer.php and class.smtp.php in the folder
|
||||
above it. Then launch the test script with:
|
||||
http://www.yourdomain.com/phpmailer/test_script/index.php from this one
|
||||
script, you can test your server settings for mail(), sendmail (or
|
||||
qmail), and SMTP. This will email you a sample email (using
|
||||
contents.html for the email body) and two attachments. One of the
|
||||
attachments is used as an inline image to demonstrate how PHPMailer will
|
||||
automatically detect if attachments are the same source as inline
|
||||
graphics and only include one version. Once you click the Submit button,
|
||||
the results will be displayed including any SMTP debug information and
|
||||
send status. We will also display a version of the script that you can
|
||||
cut and paste to include in your projects. Enjoy! Version 2.3 (November
|
||||
08, 2008) We have removed the /phpdoc from the downloads. All
|
||||
documentation is now on the http://phpmailer.codeworxtech.com website.
|
||||
|
||||
The phpunit.php has been updated to support PHP5. For all other changes
|
||||
and notes, please see the changelog. Donations are accepted at PayPal
|
||||
with our id "paypal@worxteam.com". Version 2.2 (July 15 2008) - see the
|
||||
changelog. Version 2.1 (June 04 2008) With this release, we are
|
||||
announcing that the development of PHPMailer for PHP5 will be our focus
|
||||
from this date on. We have implemented all the enhancements and fixes
|
||||
from the latest release of PHPMailer for PHP4. Far more important,
|
||||
though, is that this release of PHPMailer (v2.1) is fully tested with
|
||||
E_STRICT error checking enabled. ** NOTE: WE HAVE A NEW LANGUAGE
|
||||
VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. IF YOU CAN HELP WITH
|
||||
LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE APPRECIATED. We
|
||||
have now added S/MIME functionality (ability to digitally sign emails).
|
||||
BIG THANKS TO "sergiocambra" for posting this patch back in November
|
||||
2007. The "Signed Emails" functionality adds the Sign method to pass the
|
||||
private key filename and the password to read it, and then email will be
|
||||
sent with content-type multipart/signed and with the digital signature
|
||||
attached. A quick note on E_STRICT: - In about half the test
|
||||
environments the development version was subjected to, an error was
|
||||
thrown for the date() functions (used at line 1565 and 1569). This is
|
||||
NOT a PHPMailer error, it is the result of an incorrectly configured
|
||||
PHP5 installation. The fix is to modify your 'php.ini' file and include
|
||||
the date.timezone = America/New York directive, (for your own server
|
||||
timezone) - If you do get this error, and are unable to access your
|
||||
php.ini file, there is a workaround. In your PHP script, add
|
||||
date_default_timezone_set('America/Toronto'); * do NOT try to use $myVar
|
||||
= date_default_timezone_get(); as a test, it will throw an error. We
|
||||
have also included more example files to show the use of "sendmail",
|
||||
"mail()", "smtp", and "gmail". We are also looking for more programmers
|
||||
to join the volunteer development team. If you have an interest in this,
|
||||
please let us know. Enjoy! Version 2.1.0beta1 & beta2 please note, this
|
||||
is BETA software ** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS
|
||||
INTENDED STRICTLY FOR TESTING ** NOTE: As of November 2007, PHPMailer
|
||||
has a new project team headed by industry veteran Andy Prevost
|
||||
(codeworxtech). The first release in more than two years will focus on
|
||||
fixes, adding ease-of-use enhancements, provide basic compatibility with
|
||||
PHP4 and PHP5 using PHP5 backwards compatibility features. A new release
|
||||
is planned before year-end 2007 that will provide full compatiblity with
|
||||
PHP4 and PHP5, as well as more bug fixes. We are looking for project
|
||||
developers to assist in restoring PHPMailer to its leadership position.
|
||||
Our goals are to simplify use of PHPMailer, provide good documentation
|
||||
and examples, and retain backward compatibility to level 1.7.3
|
||||
standards. If you are interested in helping out, visit
|
||||
http://sourceforge.net/projects/phpmailer and indicate your interest. **
|
||||
|
||||
http://phpmailer.sourceforge.net/ This software is licenced under the
|
||||
LGPL. Please read LICENSE for information on the software availability
|
||||
and distribution. Class Features: - Send emails with multiple TOs, CCs,
|
||||
BCCs and REPLY-TOs - Redundant SMTP servers - Multipart/alternative
|
||||
emails for mail clients that do not read HTML email - Support for 8bit,
|
||||
base64, binary, and quoted-printable encoding - Uses the same methods as
|
||||
the very popular AspEmail active server (COM) component - SMTP
|
||||
authentication - Native language support - Word wrap, and more! Why you
|
||||
might need it: Many PHP developers utilize email in their code. The only
|
||||
PHP function that supports this is the mail() function. However, it does
|
||||
not expose any of the popular features that many email clients use
|
||||
nowadays like HTML-based emails and attachments. There are two
|
||||
proprietary development tools out there that have all the functionality
|
||||
built into easy to use classes: AspEmail(tm) and AspMail. Both of these
|
||||
programs are COM components only available on Windows. They are also a
|
||||
little pricey for smaller projects. Since I do Linux development I<EFBFBD>ve
|
||||
missed these tools for my PHP coding. So I built a version myself that
|
||||
implements the same methods (object calls) that the Windows-based
|
||||
components do. It is open source and the LGPL license allows you to
|
||||
place the class in your proprietary PHP projects. Installation: Copy
|
||||
class.phpmailer.php into your php.ini include_path. If you are using the
|
||||
SMTP mailer then place class.smtp.php in your path as well. In the
|
||||
language directory you will find several files like
|
||||
phpmailer.lang-en.php. If you look right before the .php extension that
|
||||
there are two letters. These represent the language type of the
|
||||
translation file. For instance "en" is the English file and "br" is the
|
||||
Portuguese file. Chose the file that best fits with your language and
|
||||
place it in the PHP include path. If your language is English then you
|
||||
have nothing more to do. If it is a different language then you must
|
||||
point PHPMailer to the correct translation. To do this, call the
|
||||
PHPMailer SetLanguage method like so: // To load the Portuguese version
|
||||
$mail->SetLanguage("br", "/optional/path/to/language/directory/");
|
||||
|
||||
That's it. You should now be ready to use PHPMailer! A Simple Example:
|
||||
|
||||
<?php
|
||||
require("class.phpmailer.php");
|
||||
|
||||
$mail = new PHPMailer();
|
||||
|
||||
$mail->IsSMTP(); // set mailer to use SMTP
|
||||
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
|
||||
$mail->SMTPAuth = true; // turn on SMTP authentication
|
||||
$mail->Username = "jswan"; // SMTP username
|
||||
$mail->Password = "secret"; // SMTP password
|
||||
|
||||
$mail->From = "from@example.com";
|
||||
$mail->FromName = "Mailer";
|
||||
$mail->AddAddress("josh@example.net", "Josh Adams");
|
||||
$mail->AddAddress("ellen@example.com"); // name is optional
|
||||
$mail->AddReplyTo("info@example.com", "Information");
|
||||
|
||||
$mail->WordWrap = 50; // set word wrap to 50 characters
|
||||
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
|
||||
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
|
||||
$mail->IsHTML(true); // set email format to HTML
|
||||
|
||||
$mail->Subject = "Here is the subject";
|
||||
$mail->Body = "This is the HTML message body <b>in bold!</b>";
|
||||
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
|
||||
|
||||
if(!$mail->Send())
|
||||
{
|
||||
echo "Message could not be sent. <p>";
|
||||
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "Message has been sent";
|
||||
?>
|
||||
|
||||
CHANGELOG See ChangeLog.txt Download:
|
||||
http://sourceforge.net/project/showfiles.php?group_id=26031 Andy Prevost
|
File diff suppressed because it is too large
Load diff
1321
sources/application/third_party/phpmailer/class.smtp.php
vendored
1321
sources/application/third_party/phpmailer/class.smtp.php
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file: refer to English translation for definitive list
|
||||
* Arabic Version, UTF-8
|
||||
* by : bahjat al mostafa <bahjat983@hotmail.com>
|
||||
*/
|
||||
* PHPMailer language file: refer to English translation for definitive list
|
||||
* Arabic Version, UTF-8
|
||||
* by : bahjat al mostafa <bahjat983@hotmail.com>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.';
|
||||
|
@ -15,7 +15,7 @@ $PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للمل
|
|||
$PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: ';
|
||||
$PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.';
|
||||
//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
|
||||
//$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: ';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.';
|
||||
//$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' .
|
||||
|
@ -24,4 +24,3 @@ $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: ';
|
|||
//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
|
||||
//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
|
||||
?>
|
24
sources/application/third_party/phpmailer/language/phpmailer.lang-be.php
vendored
Normal file
24
sources/application/third_party/phpmailer/language/phpmailer.lang-be.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file: refer to English translation for definitive list
|
||||
* Belarusian Version by Aleksander Maksymiuk <info@setpro.pl>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG['authenticate'] = 'Памылка SMTP: памылка ідэнтыфікацыі.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Памылка SMTP: нельга ўстанавіць сувязь з SMTP-серверам.';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Памылка SMTP: звесткі непрынятыя.';
|
||||
$PHPMAILER_LANG['empty_message'] = 'Пустое паведамленне.';
|
||||
$PHPMAILER_LANG['encoding'] = 'Невядомая кадыроўка тэксту: ';
|
||||
$PHPMAILER_LANG['execute'] = 'Нельга выканаць каманду: ';
|
||||
$PHPMAILER_LANG['file_access'] = 'Няма доступу да файла: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Нельга адкрыць файл: ';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Няправільны адрас адпраўніка: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Нельга прымяніць функцыю mail().';
|
||||
$PHPMAILER_LANG['invalid_address'] = 'Нельга даслаць паведамленне, няправільны email атрымальніка: ';
|
||||
$PHPMAILER_LANG['provide_address'] = 'Запоўніце, калі ласка, правільны email атрымальніка.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' - паштовы сервер не падтрымліваецца.';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Памылка SMTP: няправільныя атрымальнікі: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Памылка подпісу паведамлення: ';
|
||||
$PHPMAILER_LANG['smtp_connect_failed'] = 'Памылка сувязі з SMTP-серверам.';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'Памылка SMTP: ';
|
||||
$PHPMAILER_LANG['variable_set'] = 'Нельга ўстанавіць або перамяніць значэнне пераменнай: ';
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue