Skip to content

Commit

Permalink
All classes from classes folder ported except - phpmailer(not require…
Browse files Browse the repository at this point in the history
…d anymore), pchart(will be used as it is now, no need for any change), inputfilter(not required) . In dTexts class, all its functions dFunctions have been ported as a helper not as a library(which ideally they should be, but not working when we port them as library), datetimeconverter class require adodb-time.inc.php (date time library) so wrapped this file as well. Made some models that were required and a view.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10046 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
sachdeva-shubham committed May 9, 2011
1 parent 24f9bd7 commit 82792e4
Show file tree
Hide file tree
Showing 15 changed files with 3,074 additions and 0 deletions.
1,426 changes: 1,426 additions & 0 deletions application/helpers/adodb/adodb-time.inc_helper.php

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions application/helpers/dTexts/dFunctionHide_helper.php
@@ -0,0 +1,35 @@
<?php

class dFunctionHide
{
public function __construct()
{
}

public function run($args)
{

$funcName=array_shift($args);
try
{
//$func = dTexts::loadFunction($funcName);
$CI =& get_instance();
$CI->load->helper('dTexts/dFunction'.$funcName);
$className='dFunction'.$funcName;
$func = new $className();
$newStr = $func->run($args);
if(strtolower($newStr)=='true'){
$id=time().rand(0,100);
$data['id'] = $id;
$hideJS=$CI->load->view('libraries/dTexts/hideJS_view.php',$data,true);
return $hideJS;
}
}
catch(Exception $e)
{
throw $e;
}
return '';

}
}
43 changes: 43 additions & 0 deletions application/helpers/dTexts/dFunctionIfCount_helper.php
@@ -0,0 +1,43 @@
<?php

class dFunctionIfCount
{
public function __construct()
{
}

public function run($args)
{
//global $connect, $dbprefix;
list($field, $min, $max, $valueForTrue, $valueForFalse) = $args;
if($valueForTrue === null)
$valueForTrue = 'true'; // deafult value
if($valueForFalse === null)
$valueForFalse = 'false'; // deafult value
if($max == 0) // if field with $max is empty '::'
$max = PHP_INT_MAX;

$srid = $this->session->userdata('srid');
$sid = $this->input->post('sid');
$CI =& get_instance();
$CI->load->model('surveys_dynamic_model');
$result = $CI->surveys_dynamic_model->getSomeRecords($field,$sid,'WHERE id = '.$srid);
//$query = "SELECT * FROM {$dbprefix}survey_$sid WHERE id = $srid";
if(!$result){
//throw new Exception("Couldn't get question '$field' answer<br />".$connect->ErrorMsg()); //Checked
throw new Exception("Couldn't get question '$field' answer<br />"); //Checked
}
$row = $result->row_array();

$hits = 0;
while($e = each($row))
if(stripos($e['key'], $field) !== false) // we're checking only fields containing answer to our question
if(($e['value'] !== "")) // increase hits if user answered that question
++$hits;

if($hits >= $min && $hits <= $max)
return $valueForTrue;
else
return $valueForFalse;
}
}
32 changes: 32 additions & 0 deletions application/helpers/dTexts/dFunctionIfIn_helper.php
@@ -0,0 +1,32 @@
<?php

class dFunctionIfIn
{
public function __construct()
{
}

public function run($args)
{
//global $connect, $dbprefix;
$field = array_shift($args);
$valueForTrue = array_shift($args); // value that will'be inserted if user's answer hits one of our options
$srid = $this->session->userdata('srid');
$sid = $this->input->post('sid');
$CI =& get_instance();
$CI->load->model('surveys_dynamic_model');
$result = $CI->surveys_dynamic_model->getSomeRecords($field,$sid,'WHERE id = '.$srid);
//$query = "SELECT $field FROM {$dbprefix}survey_$sid WHERE id = $srid";
if(!$result){
//throw new Exception("Couldn't get question '$field' answer<br />".$connect->ErrorMsg()); //Checked
throw new Exception("Couldn't get question '$field' answer<br />"); //Checked
}
$row = $result->row_array();
$value = $row[$field];

if(in_array($value, $args))
return $valueForTrue;
else
return "";
}
}
38 changes: 38 additions & 0 deletions application/helpers/dTexts/dFunctionIf_helper.php
@@ -0,0 +1,38 @@
<?php

class dFunctionIf
{
public function __construct()
{
}

public function run($args)
{
//global $connect, $dbprefix;
list($field, $value, $valueForTrue, $valueForFalse) = $args;
if($valueForTrue === null)
$valueForTrue = 'true'; // deafult value
if($valueForFalse === null)
$valueForFalse = 'false'; // deafult value
$srid = $this->session->userdata('srid');
$sid = $this->input->post('sid');
$CI =& get_instance();
$CI->load->model('surveys_dynamic_model');
$result = $CI->surveys_dynamic_model->getSomeRecords($field,$sid,'WHERE id = '.$srid);
//$query = "SELECT $field FROM {$dbprefix}survey_$sid WHERE id = $srid";
if(!$result){
//throw new Exception("Couldn't get question '$field' answer<br />".$connect->ErrorMsg()); //Checked
throw new Exception("Couldn't get question '$field' answer<br />"); //Checked
}
$row = $result->row_array();

if ($row[$field] == $value)
{
return $valueForTrue;
}
else
{
return $valueForFalse;
}
}
}
18 changes: 18 additions & 0 deletions application/helpers/dTexts/dFunctionInsertAns_helper.php
@@ -0,0 +1,18 @@
<?php

class dFunctionInsertAns
{
public function __construct()
{
}

public function run($args)
{
//global $connect;
$field = $args[0];
if ($this->session->userdata('srid')) $srid = $this->session->userdata('srid');
$sid = returnglobal('sid');
$dateformats = $this->session->userdata('dateformats');
return retrieve_Answer($field, $dateformats['phpdate']);
}
}
36 changes: 36 additions & 0 deletions application/helpers/dTexts/dFunctionSwitch_helper.php
@@ -0,0 +1,36 @@
<?php

class dFunctionSwitch
{
public function __construct()
{
}

public function run($args)
{
//global $connect, $dbprefix;
$field = $args[0];
$srid = $this->session->userdata('srid');
$sid = $this->input->post('sid');
$CI =& get_instance();
$CI->load->model('surveys_dynamic_model');
$result = $CI->surveys_dynamic_model->getSomeRecords($field,$sid,'WHERE id = '.$srid);
//$query = "SELECT $field FROM {$dbprefix}survey_$sid WHERE id = $srid";
if(!$result){
//throw new Exception("Couldn't get question '$field' answer<br />".$connect->ErrorMsg()); //Checked
throw new Exception("Couldn't get question '$field' answer<br />"); //Checked
}
$row = $result->row_array();
$value = $row[$field];

$found = array_keys($args, $value);
if(count($found))
{
while($e = each($found))
if($e['value'] % 2 != 0) // we check this, as only at odd indexes there are 'cases'
return $args[$e['value']+1]; // returns value associated with found 'case'
}
// return empty string if none of cases matches user's answer
return "";
}
}
53 changes: 53 additions & 0 deletions application/helpers/dTexts/dFunctionToken_helper.php
@@ -0,0 +1,53 @@
<?php

class dFunctionToken
{
public function __construct()
{
}

public function run($args)
{
global $surveyid;
if ($this->session->userdata('token') != '')
{
//Gather survey data for tokenised surveys, for use in presenting questions
$currenttoken=getTokenData($surveyid,$this->session->userdata('token'));
//add data to session
$newdata = array(
'thistoken' => $currenttoken
);
$this->session->set_userdata($newdata);
}
$currenttoken = $this->session->userdata('thistoken');
if ($currenttoken)
{
if (!strcmp(strtolower($args[0]),'firstname'))
{
return $currenttoken['firstname'];
}
//return $_SESSION['thistoken']['firstname'];
if (!strcmp(strtolower($args[0]),'lastname'))
{
return $currenttoken['lastname'];
}
//return $_SESSION['thistoken']['lastname'];
if (!strcmp(strtolower($args[0]),'email'))
{
return $currenttoken['email'];
}
//return $_SESSION['thistoken']['email'];
}
else
{
return "";
}

if(stripos($args[0],'attribute_')!==FALSE){
$attr_no=(int)str_replace('ATTRIBUTE_','',$args[0]);
if (isset($currenttoken['attribute_'.$attr_no])) return $currenttoken['attribute_'.$attr_no];
}

throw new Exception('TOKEN incorrect!');
}
}

0 comments on commit 82792e4

Please sign in to comment.