Example #1
0
$state = is_on_call($operator_id);
$js = array("js/popup.js");
if (browser_ie()) {
    $js[] = "js/window_ie6_interface2.js";
} else {
    $js[] = "js/window_interface2.js";
}
if (AUTO_LOGOUT_MINUTES !== false) {
    $js[] = "include/jquery/jquery-1.4.2.min.js";
    $js[] = "js/childnap.js";
}
xhtml_head(T_("Status"), false, array("include/bootstrap/css/bootstrap.min.css", "css/status_interface2.css"), $js);
$ca = get_call_attempt($operator_id, false);
if ($ca) {
    $respondent_id = get_respondent_id($ca);
    $case_id = get_case_id($operator_id);
    $fname = get_respondent_variable("firstName", $respondent_id);
    $lname = get_respondent_variable("lastName", $respondent_id);
    print "<h4>" . T_("Name") . ": {$fname} {$lname}</h4>";
    $appointment = is_on_appointment($ca);
    $call_id = get_call($operator_id);
    $sql = "SELECT o.tryanother, o.require_note\r\n\t\tFROM `call` as c, `outcome` as o\r\n\t\tWHERE c.call_attempt_id = '{$ca}'\r\n\t\tAND c.outcome_id = o.outcome_id\r\n\t\tORDER BY call_id DESC\r\n\t\tLIMIT 1";
    $rst = $db->GetRow($sql);
    if (empty($rst) || $rst['tryanother'] == 1) {
        if (isset($_POST['contactphone'])) {
            $pcontact_phone_id = intval($_POST['contactphone']);
            //If an outcome already assigned, end the current call and start the enxt one to pcontact_phone_id
            //Otherwise bring up the assign outcome window
            if (!$call_id) {
                $call_id = get_call($operator_id, $respondent_id, $pcontact_phone_id, true);
                echo "<script type='text/javascript'>openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id, false) . "\");</script>";
Example #2
0
 * Language file
 */
include_once "lang.inc.php";
/** 
 * Authentication
 */
require "auth-interviewer.php";
/**
 * XHTML functions
 */
include_once "functions/functions.xhtml.php";
include_once "functions/functions.operator.php";
xhtml_head(T_("End of work"));
if (isset($_GET['auto'])) {
    print "<h1>" . T_("You have been automatically logged out of work due to inactivity") . "</h1>";
}
print "<h1>" . T_("Work has ended. That is it") . "</h1>";
if (ALLOW_OPERATOR_EXTENSION_SELECT && VOIP_ENABLED) {
    //unassign extension
    $operator_id = get_operator_id();
    if (get_case_id($operator_id) == false && is_voip_enabled($operator_id)) {
        $sql = "UPDATE `extension`\r\n            SET current_operator_id = NULL\r\n            WHERE current_operator_id = {$operator_id}";
        $rs = $db->Execute($sql);
        if ($rs) {
            print "<p>" . T_("You have been unassigned from your extension") . "</p>";
        }
    }
}
print "<p><a href='index.php'>" . T_("Go back to work") . "</a></p>";
print "<p><a href='include/limesurvey/admin/admin.php?action=logout'>" . T_("Logout") . "</a></p>";
xhtml_foot();
Example #3
0
}
if ($popupcall) {
    $js[] = "js/popupcallonload.js";
}
if (HEADER_EXPANDER) {
    $js[] = "js/headerexpand_interface2.js";
    $js[] = "js/headerexpandmanual_interface2.js";
} else {
    if (HEADER_EXPANDER_MANUAL) {
        $js[] = "js/headerexpand_interface2.js";
        $js[] = "js/headerexpandmanual_interface2.js";
    }
}
xhtml_head(T_("Case"), $body, array("include/bootstrap/css/bootstrap.min.css", "include/bootstrap/css/bootstrap-theme.min.css", "include/font-awesome/css/font-awesome.css", "css/index_interface2.css", "css/tabber_interface2.css", "include/jquery-ui/jquery-ui.min.css"), $js, false, false, false, false, false);
print $script;
$case_id = get_case_id($operator_id, true);
$sql = "SELECT q.self_complete, q.referral\r\n        FROM questionnaire as q, `case` as c\r\n        WHERE c.case_id = {$case_id} \r\n        AND c.questionnaire_id = q.questionnaire_id";
$scr = $db->GetRow($sql);
$sc = $scr['self_complete'];
$ref = $scr['referral'];
$availability = is_using_availability($case_id);
?>
<div class="container-fluid "> 
	<div class="row ">

		<div id="casefunctions" class="col-sm-2 panel-body">

			<a href="javascript:poptastic('call_interface2.php');" class="btn btn-default btn-block" style="border-radius:15px; color:blue"><strong><?php 
echo T_("Outcome");
?>
  <i class="fa fa-lg fa-check-square-o fa-fw"></i></strong></a></br>
Example #4
0
/**
 * Get start interviewer URL
 *
 * @return string The URL to start the interview
 */
function get_start_interview_url()
{
    $db = newADOConnection(DB_TYPE);
    $db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $db->SetFetchMode(ADODB_FETCH_ASSOC);
    $operator_id = get_operator_id();
    $url = QUEXS_URL . "nocaseavailable.php";
    $case_id = get_case_id($operator_id);
    if ($case_id) {
        $sql = "SELECT token\r\n\t\t\tFROM `case`\r\n\t\t\tWHERE case_id = {$case_id}";
        $token = $db->GetOne($sql);
        $sid = get_limesurvey_id($operator_id);
        $url = LIME_URL . "index.php?interviewer=interviewer&amp;loadall=reload&sid={$sid}&token={$token}&lang=" . DEFAULT_LOCALE;
        $questionnaire_id = get_questionnaire_id($operator_id);
        //get prefills
        $sql = "SELECT lime_sgqa,value\r\n                        FROM questionnaire_prefill\r\n                        WHERE questionnaire_id = '{$questionnaire_id}'";
        $pf = $db->GetAll($sql);
        if (!empty($pf)) {
            foreach ($pf as $p) {
                $url .= "&" . $p['lime_sgqa'] . "=" . quexs_template_replace($p['value']);
            }
        }
    }
    return $url;
}
Example #5
0
/**
* Retrieves the token attribute value from the related token table
*
* @param mixed $surveyid  The survey ID
* @param mixed $attrName  The token-attribute field name
* @param mixed $token  The token code
* @return string The token attribute value (or null on error)
*/
function GetAttributeValue($surveyid, $attrName, $token)
{
    global $dbprefix, $connect;
    $attrName = strtolower($attrName);
    if ($attrName == 'callattempts' || $attrName == 'onappointment' || $attrName == 'perccomplete' || $attrName == 'messagesleft') {
        include_once "quexs.php";
        $quexs_operator_id = get_operator_id();
        $quexs_case_id = get_case_id($quexs_operator_id);
        if ($quexs_case_id) {
            if ($attrName == 'callattempts') {
                return get_call_attempts($quexs_case_id);
            } else {
                if ($attrName == 'onappointment') {
                    return is_on_appointment($quexs_case_id, $quexs_operator_id);
                } else {
                    if ($attrName == 'perccomplete') {
                        return get_percent_complete($quexs_case_id);
                    } else {
                        if ($attrName == 'messagesleft') {
                            return get_messages_left($quexs_case_id);
                        }
                    }
                }
            }
        } else {
            return 0;
        }
    } else {
        if (!tableExists('tokens_' . $surveyid) || !in_array($attrName, GetTokenConditionsFieldNames($surveyid))) {
            return null;
        }
    }
    $sanitized_token = $connect->qstr($token, get_magic_quotes_gpc());
    $surveyid = sanitize_int($surveyid);
    $query = "SELECT {$attrName} FROM {$dbprefix}tokens_{$surveyid} WHERE token={$sanitized_token}";
    $result = db_execute_num($query);
    $count = $result->RecordCount();
    if ($count != 1) {
        return null;
    } else {
        $row = $result->FetchRow();
        return $row[0];
    }
}
Example #6
0
 */
include "functions/functions.xhtml.php";
/**
 * Operator functions
 */
include "functions/functions.operator.php";
$js = false;
if (AUTO_LOGOUT_MINUTES !== false) {
    $js = array("include/jquery/jquery-1.4.2.min.js", "js/childnap.js");
}
xhtml_head(T_("Call List"), false, array("css/table.css"), $js, false, 60);
//List the case call history
// display in respondent time so that the operator will be able to
// quote verbatim to the respondent if necessary
$db->StartTrans();
$case_id = get_case_id(get_operator_id());
if ($case_id) {
    global $db;
    $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'" . DATE_TIME_FORMAT . "') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, op.firstName, op.lastName, o.description as des, cp.phone as cphone\r\n\t\tFROM `call` as c\r\n\t\tJOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and c.contact_phone_id = cp.contact_phone_id)\r\n\t\tWHERE c.case_id = '{$case_id}'\r\n\t\tORDER BY c.start DESC";
    $rs = $db->GetAll($sql);
    if (empty($rs)) {
        print "<p>" . T_("No calls made") . "</p>";
    } else {
        translate_array($rs, array("des"));
        xhtml_table($rs, array("start", "des", "cphone", "firstName"), array(T_("Date/Time"), T_("Outcome"), T_("Number called"), T_("Operator")));
    }
} else {
    print "<p>" . T_("No case") . "</p>";
}
xhtml_foot();
$db->CompleteTrans();
 * Language file
 */
include_once "lang.inc.php";
/** 
 * Authentication
 */
require "auth-interviewer.php";
/**
 * XHTML functions
 */
include_once "functions/functions.xhtml.php";
xhtml_head(T_("Standby"), false, array("include/bootstrap/css/bootstrap.min.css", "include/bootstrap/css/bootstrap-theme.min.css", "include/font-awesome/css/font-awesome.css", "css/index_interface2.css"), array(), false, 300);
if (isset($_GET['auto'])) {
    include_once "functions/functions.operator.php";
    $operator_id = get_operator_id();
    $case_id = get_case_id($operator_id, false);
    end_case($operator_id);
    //add case note
    $sql = "INSERT INTO case_note (case_note_id,case_id,operator_id,note,`datetime`)\r\n        VALUES (NULL,'{$case_id}','{$operator_id}','" . TQ_("Operator Automatically logged out after: ") . AUTO_LOGOUT_MINUTES . TQ_(" minutes") . "', CONVERT_TZ(NOW(),'System','UTC'))";
    $db->Execute($sql);
    print "<div class='error well' style='margin:2%; color:red;'><b>" . T_("You have been automatically logged out of work due to inactivity") . "</b></div>";
}
/* $sql = "SELECT sample_id FROM `sample` where import_id = 1";
$rs = $db->GetAll($sql);
for($i=0;$i<=count($rs)-1;$i++){ $ssseedss[] = $rs[$i]['sample_id'] ;}
$ssseedssd = implode(",",$ssseedss);
 print $ssseedssd; */
/**
 * check if cases available
 */
//if assigned to a questionnaire
Example #8
0
/**
 * Return the call attempt of the given operator
 *
 * @param int $operator_id The oeprator
 * @param bool $create If true, will create a call attempt if none exists
 * @return bool|int False if no case otherwise the call_attempt_id
 *
 */
function get_call_attempt($operator_id, $create = false)
{
    global $db;
    $db->StartTrans();
    $case_id = get_case_id($operator_id, false);
    $id = false;
    if ($case_id) {
        $sql = "SELECT call_attempt_id\r\n\t\t\tFROM `call_attempt`\r\n\t\t\tWHERE case_id = '{$case_id}'\r\n\t\t\tAND operator_id = '{$operator_id}'\r\n\t\t\tAND end IS NULL";
        $row = $db->GetRow($sql);
        /**
         * If no call_attempt, create one
         */
        if (empty($row)) {
            if ($create) {
                $sql = "SELECT respondent_id\r\n\t\t\t\t\tFROM respondent\r\n\t\t\t\t\tWHERE case_id = '{$case_id}'";
                $row2 = $db->GetRow($sql);
                $respondent_id = 0;
                if (!empty($row2)) {
                    $respondent_id = $row2['respondent_id'];
                }
                $sql = "INSERT INTO `call_attempt` (call_attempt_id,operator_id,case_id,respondent_id,start,end)\r\n\t\t\t\t\tVALUES (NULL,'{$operator_id}','{$case_id}','{$respondent_id}',CONVERT_TZ(NOW(),'System','UTC'),NULL)";
                $db->Execute($sql);
                $id = $db->Insert_Id();
            }
        } else {
            $id = $row['call_attempt_id'];
        }
    }
    //if ($db->HasFailedTrans()) { print "FAILED in get_call_attempt"; exit; }
    if ($db->CompleteTrans()) {
        return $id;
    }
    return false;
}
Example #9
0
function do_multipleshorttext($ia)
{
    global $dbprefix, $clang, $thissurvey;
    $answer = '';
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    if ($qidattributes['numbers_only'] == 1) {
        $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']);
        $sSeperator = $sSeperator['seperator'];
        $checkconditionFunction = "fixnum_checkconditions";
    } else {
        $checkconditionFunction = "checkconditions";
    }
    if (intval(trim($qidattributes['maximum_chars'])) > 0) {
        // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea
        $maximum_chars = intval(trim($qidattributes['maximum_chars']));
        $maxlength = "maxlength='{$maximum_chars}' ";
    } else {
        $maxlength = "";
    }
    if (trim($qidattributes['text_input_width']) != '') {
        $tiwidth = $qidattributes['text_input_width'];
    } else {
        $tiwidth = 20;
    }
    if (trim($qidattributes['prefix']) != '') {
        $prefix = $qidattributes['prefix'];
    } else {
        $prefix = '';
    }
    if (trim($qidattributes['suffix']) != '') {
        $suffix = $qidattributes['suffix'];
    } else {
        $suffix = '';
    }
    if ($thissurvey['nokeyboard'] == 'Y') {
        vIncludeKeypad();
        $kpclass = "text-keypad";
    } else {
        $kpclass = "";
    }
    if ($qidattributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia['0']}  AND language='" . $_SESSION['s_lang'] . "' ORDER BY " . db_random();
    } else {
        $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia['0']}  AND language='" . $_SESSION['s_lang'] . "' ORDER BY question_order";
    }
    $ansresult = db_execute_assoc($ansquery);
    //Checked
    $anscount = $ansresult->RecordCount() * 2;
    //$answer .= "\t<input type='hidden' name='MULTI$ia[1]' value='$anscount'>\n";
    $fn = 1;
    $answer_main = '';
    $label_width = 0;
    if ($anscount == 0) {
        $inputnames = array();
        $answer_main .= '	<li>' . $clang->gT('Error: This question has no answers.') . "</li>\n";
    } else {
        if (trim($qidattributes['display_rows']) != '') {
            //question attribute "display_rows" is set -> we need a textarea to be able to show several rows
            $drows = $qidattributes['display_rows'];
            while ($ansrow = $ansresult->FetchRow()) {
                $myfname = $ia[1] . $ansrow['title'];
                if ($ansrow['question'] == "") {
                    $ansrow['question'] = "&nbsp;";
                }
                $quexs_answer = false;
                if (strncasecmp($ansrow['question'], "{SAMPLEUPDATE:", 14) == 0) {
                    $ansrow['question'] = substr($ansrow['question'], 14, -1);
                    //remove token text
                    include_once 'quexs.php';
                    $quexs_operator_id = get_operator_id();
                    $quexs_case_id = get_case_id($quexs_operator_id);
                    if ($quexs_case_id) {
                        $quexs_answer = get_sample_variable($ansrow['question'], $quexs_case_id);
                        $tiwidth = strlen($quexs_answer) + 5;
                        $maxsize = $tiwidth + 255;
                    }
                }
                list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li");
                $answer_main .= "\t{$htmltbody2}\n" . "<label for=\"answer{$myfname}\">{$ansrow['question']}</label>\n" . "\t<span>\n" . $prefix . "\n" . '
				<textarea class="textarea ' . $kpclass . '" name="' . $myfname . '" id="answer' . $myfname . '"
				rows="' . $drows . '" cols="' . $tiwidth . '" ' . $maxlength . ' onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type);" >';
                if ($label_width < strlen(trim(strip_tags($ansrow['question'])))) {
                    $label_width = strlen(trim(strip_tags($ansrow['question'])));
                }
                if ($quexs_answer !== false) {
                    $answer_main .= $quexs_answer;
                } else {
                    if (isset($_SESSION[$myfname])) {
                        $dispVal = $_SESSION[$myfname];
                        if ($qidattributes['numbers_only'] == 1) {
                            $dispVal = str_replace('.', $sSeperator, $dispVal);
                        }
                        $answer_main .= htmlspecialchars(htmlspecialchars($dispVal));
                    }
                }
                $answer_main .= "</textarea>\n" . $suffix . "\n\t</span>\n" . "\t</li>\n";
                $fn++;
                $inputnames[] = $myfname;
            }
        } else {
            while ($ansrow = $ansresult->FetchRow()) {
                $myfname = $ia[1] . $ansrow['title'];
                if ($ansrow['question'] == "") {
                    $ansrow['question'] = "&nbsp;";
                }
                $quexs_answer = false;
                if (strncasecmp($ansrow['question'], "{SAMPLEUPDATE:", 14) == 0) {
                    $ansrow['question'] = substr($ansrow['question'], 14, -1);
                    //remove token text
                    include_once 'quexs.php';
                    $quexs_operator_id = get_operator_id();
                    $quexs_case_id = get_case_id($quexs_operator_id);
                    if ($quexs_case_id) {
                        $quexs_answer = get_sample_variable($ansrow['question'], $quexs_case_id);
                        $tiwidth = strlen($quexs_answer) + 5;
                        $maxsize = $tiwidth + 255;
                    }
                }
                list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li");
                // color code missing mandatory questions red
                if ($ia[6] == 'Y' && ($_SESSION['step'] == $_SESSION['prevstep'] || $_SESSION['maxstep'] > $_SESSION['step']) && $_SESSION[$myfname] == '') {
                    $ansrow['question'] = "<span class='errormandatory'>{$ansrow['question']}</span>";
                }
                $answer_main .= "\t{$htmltbody2}\n" . "<label for=\"answer{$myfname}\">{$ansrow['question']}</label>\n" . "\t<span>\n" . $prefix . "\n" . '<input class="text ' . $kpclass . '" type="text" size="' . $tiwidth . '" name="' . $myfname . '" id="answer' . $myfname . '" value="';
                if ($label_width < strlen(trim(strip_tags($ansrow['question'])))) {
                    $label_width = strlen(trim(strip_tags($ansrow['question'])));
                }
                if ($quexs_answer !== false) {
                    $answer_main .= $quexs_answer;
                } else {
                    if (isset($_SESSION[$myfname])) {
                        $dispVal = $_SESSION[$myfname];
                        if ($qidattributes['numbers_only'] == 1) {
                            $dispVal = str_replace('.', $sSeperator, $dispVal);
                        }
                        $answer_main .= htmlspecialchars($dispVal, ENT_QUOTES, 'UTF-8');
                    }
                }
                $answer_main .= '" onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type);" ' . $maxlength . ' />' . "\n" . $suffix . "\n\t</span>\n" . "\t</li>\n";
                $fn++;
                $inputnames[] = $myfname;
            }
        }
    }
    $answer = "<ul>\n" . $answer_main . "</ul>\n";
    return array($answer, $inputnames);
}
Example #10
0
/**
* check_quota() 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.
*/
function check_quota($checkaction, $surveyid)
{
    if (!isset($_SESSION['s_lang'])) {
        return;
    }
    global $thistpl, $clang, $clienttoken, $publicurl;
    $global_matched = false;
    $quota_info = getQuotaInformation($surveyid, $_SESSION['s_lang']);
    $x = 0;
    if (count($quota_info) > 0) {
        // Check each quota on saved data to see if it is full
        $querycond = array();
        foreach ($quota_info as $quota) {
            if (count($quota['members']) > 0) {
                $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) {
                    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][] = "s." . db_quote_id($fieldname) . " = '{$member['value']}'";
                    }
                }
                // 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[$fieldname])) {
                            if (in_array($_SESSION[$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) {
                    //queXS Addition
                    include_once 'quexs.php';
                    $case_id = get_case_id(get_operator_id());
                    // Check the status of the quota, is it full or not
                    $querysel = "SELECT id FROM " . db_table_name('survey_' . $surveyid) . " AS s\n\t\t\t\t     JOIN `case` AS cq ON (cq.case_id = '{$case_id}')\n\t\t\t\t     JOIN sample AS sampt ON (sampt.sample_id = cq.sample_id)\n\t\t\t\t     JOIN `case` AS c ON (c.token = s.token AND c.questionnaire_id = cq.questionnaire_id)\n\t\t\t\t     JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = sampt.import_id)\n\t\t\t             WHERE " . implode(' AND ', $querycond) . " " . " \n\t\t\t\t\tAND s.submitdate IS NOT NULL";
                    $result = db_execute_assoc($querysel) or safe_die($connect->ErrorMsg());
                    //Checked
                    $quota_check = $result->FetchRow();
                    if ($result->RecordCount() >= $quota['Limit']) {
                        // 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";
                    }
                }
            }
            $x++;
        }
    } else {
        return false;
    }
    // Now we have all the information we need about the quotas and their status.
    // Lets see what we should do now
    if ($checkaction == 'return') {
        return $quota_info;
    } else {
        if ($global_matched == true && $checkaction == 'enforce') {
            // Need to add Quota action enforcement here.
            reset($quota_info);
            $tempmsg = "";
            $found = false;
            foreach ($quota_info as $quota) {
                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);
                    }
                    session_destroy();
                    sendcacheheaders();
                    if ($quota['AutoloadUrl'] == 1 && $quota['Url'] != "") {
                        header("Location: " . $quota['Url'] . "?message=" . $quota['Message']);
                    }
                    doHeader();
                    echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl"));
                    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("{$thistpl}/endpage.pstpl"));
                    doFooter();
                    exit;
                }
                if (isset($quota['status']) && $quota['status'] == "matched" && (isset($quota['Action']) && $quota['Action'] == "2")) {
                    sendcacheheaders();
                    doHeader();
                    echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl"));
                    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 "<form method='post' action='{$publicurl}/index.php' id='limesurvey' name='limesurvey'><input type=\"hidden\" name=\"move\" value=\"movenext\" id=\"movenext\" /><input class='submit' accesskey='p' type='button' onclick=\"javascript:document.limesurvey.move.value = 'moveprev'; document.limesurvey.submit();\" value=' &lt;&lt; " . $clang->gT("Previous") . " ' name='move2' />\n                <input type='hidden' name='thisstep' value='" . $_SESSION['step'] . "' id='thisstep' />\n                <input type='hidden' name='sid' value='" . returnglobal('sid') . "' id='sid' />\n                <input type='hidden' name='token' value='" . $clienttoken . "' id='token' />\n                </form>\n";
                    echo "\t</div>\n";
                    echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl"));
                    doFooter();
                    exit;
                }
            }
        } else {
            // Unknown value
            return false;
        }
    }
}