2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00
Files
CATI_Tool/include/limesurvey/classes/dTexts/dFunctions/dFunctionToken.php

37 lines
1.1 KiB
PHP

<?php
class dFunctionToken implements dFunctionInterface
{
public function __construct()
{
}
public function run($args)
{
global $surveyid;
if (isset($_SESSION['token']) && $_SESSION['token'] != '')
{
//Gather survey data for tokenised surveys, for use in presenting questions
$_SESSION['thistoken']=getTokenData($surveyid, $_SESSION['token']);
}
if (isset($_SESSION['thistoken']))
{
if (!strcmp(strtolower($args[0]),'firstname')) return $_SESSION['thistoken']['firstname'];
if (!strcmp(strtolower($args[0]),'lastname')) return $_SESSION['thistoken']['lastname'];
if (!strcmp(strtolower($args[0]),'email')) return $_SESSION['thistoken']['email'];
}
else
{
return "";
}
if(stripos($args[0],'attribute_')!==FALSE){
$attr_no=(int)str_replace('ATTRIBUTE_','',$args[0]);
if (isset($_SESSION['thistoken']['attribute_'.$attr_no])) return $_SESSION['thistoken']['attribute_'.$attr_no];
}
throw new Exception('TOKEN incorrect!');
}
}