2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merging the Limesurvey 1.91+ branch of queXS in to the trunk

This commit is contained in:
azammitdcarf
2011-09-08 01:58:41 +00:00
parent dfa55a3b9e
commit eaa9578ab8
2312 changed files with 811461 additions and 597534 deletions

View File

@@ -0,0 +1,39 @@
<?php
class dFunctionIfCount implements dFunctionInterface
{
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 = $_SESSION['srid'];
$sid = $_POST['sid'];
$query = "SELECT * FROM {$dbprefix}survey_$sid WHERE id = $srid";
if(!$result = $connect->Execute($query)){
throw new Exception("Couldn't get question '$field' answer<br />".$connect->ErrorMsg()); //Checked
}
$row = $result->fetchRow();
$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;
}
}