本文整理汇总了PHP中getQuotaInformation函数的典型用法代码示例。如果您正苦于以下问题:PHP getQuotaInformation函数的具体用法?PHP getQuotaInformation怎么用?PHP getQuotaInformation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getQuotaInformation函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getQuotaCompletedCount
/**
* Returns the number of answers matching the quota
*
* @param int $iSurveyId - Survey identification number
* @param int $quotaid - quota id for which you want to compute the completed field
* @return mixed - value of matching entries in the result DB or null
*/
function getQuotaCompletedCount($iSurveyId, $quotaid)
{
if (!tableExists("survey_{$iSurveyId}")) {
// Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}' are not updated even after Yii::app()->db->schema->refresh();
return;
}
$aColumnName = SurveyDynamic::model($iSurveyId)->getTableSchema()->getColumnNames();
$aQuotas = getQuotaInformation($iSurveyId, Survey::model()->findByPk($iSurveyId)->language, $quotaid);
$aQuota = $aQuotas[0];
if (Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}') && count($aQuota['members']) > 0) {
// Keep a list of fields for easy reference
$aQuotaColumns = array();
foreach ($aQuota['members'] as $member) {
if (in_array($member['fieldname'], $aColumnName)) {
$aQuotaColumns[$member['fieldname']][] = $member['value'];
} else {
return;
}
}
$oCriteria = new CDbCriteria();
$oCriteria->condition = "submitdate IS NOT NULL";
foreach ($aQuotaColumns as $sColumn => $aValue) {
if (count($aValue) == 1) {
$oCriteria->compare(Yii::app()->db->quoteColumnName($sColumn), $aValue);
// NO need params : compare bind
} else {
$oCriteria->addInCondition(Yii::app()->db->quoteColumnName($sColumn), $aValue);
// NO need params : addInCondition bind
}
}
return SurveyDynamic::model($iSurveyId)->count($oCriteria);
}
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:40,代码来源:common_helper.php
示例2: checkQuota
/**
* 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.
*/
function checkQuota($checkaction, $surveyid)
{
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) {
// 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][] = dbQuoteID($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['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 . "}}\n WHERE " . implode(' AND ', $querycond) . " " . "\n AND submitdate IS NOT NULL";
$iRowCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
if ($iRowCount >= $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++;
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:frontend_helper.php
示例3: checkCompletedQuota
/**
* 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 checkCompletedQuota($surveyid, $return = false)
{
if (!isset($_SESSION['survey_' . $surveyid]['srid'])) {
return;
}
static $aMatchedQuotas;
// EM call 2 times quotas with 3 lines of php code, then use static.
if (!$aMatchedQuotas) {
$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;
}
// Test only completed quota, other is not needed
$aQuotasCompleted = array();
foreach ($aQuotasInfo as $aQuotaInfo) {
$iCompleted = getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);
// Return a string
if (ctype_digit($iCompleted) && (int) $iCompleted >= (int) $aQuotaInfo['qlimit']) {
// This remove invalid quota and not completed
$aQuotasCompleted[] = $aQuotaInfo;
}
}
if (empty($aQuotasCompleted)) {
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 ($aQuotasCompleted as $aQuotaCompleted) {
$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 ($aQuotaCompleted['members'] as $aQuotaMember) {
$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]) {
$iMatchedAnswers++;
}
if (in_array($sFieldName, $aPostedFields)) {
$bPostedField = true;
}
}
if ($iMatchedAnswers == count($aQuotaFields)) {
switch ($aQuotaCompleted['action']) {
case '1':
default:
$aMatchedQuotas[] = $aQuotaCompleted;
break;
case '2':
if ($bPostedField) {
// Action 2 allow to correct last answers, then need to be posted
$aMatchedQuotas[] = $aQuotaCompleted;
}
break;
}
}
}
}
if ($return) {
return $aMatchedQuotas;
}
if (empty($aMatchedQuotas)) {
return;
}
// Now we have all the information we need about the quotas and their status.
// 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) {
/* @var $blockData PluginEventContent */
//.........这里部分代码省略.........
开发者ID:elcharlygraf,项目名称:Encuesta-YiiFramework,代码行数:101,代码来源:frontend_helper.php
示例4: getQuotaCompletedCount
/**
* Returns the number of answers matching the quota
*
* @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'
*/
function getQuotaCompletedCount($iSurveyId, $quotaid)
{
$result = "N/A";
$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) {
// Keep a list of fields for easy reference
$fields_list = array();
// Construct an array of value for each $quota['members']['fieldnames']
$fields_query = array();
foreach ($quota['members'] as $member) {
$criteria = new CDbCriteria();
foreach ($member['fieldnames'] as $fieldname) {
if (!in_array($fieldname, $fields_list)) {
$fields_list[] = $fieldname;
}
$criteria->addColumnCondition(array($fieldname => $member['value']), 'OR');
}
$fields_query[$fieldname] = $criteria;
}
$criteria = new CDbCriteria();
foreach ($fields_list as $fieldname) {
$criteria->mergeWith($fields_query[$fieldname]);
}
$result = Survey_dynamic::model($iSurveyId)->count($criteria);
}
return $result;
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:35,代码来源:common_helper.php
示例5: checkCompletedQuota
/**
* 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|void - nested array, Quotas->Members->Fields, includes quota information matched in session.
*/
function checkCompletedQuota($surveyid, $return = false)
{
/* Check if session is set */
if (!isset(App()->session['survey_' . $surveyid]['srid'])) {
return;
}
/* Check is Response is already submitted : only when "do" the quota: allow to send information about quota */
$oResponse = Response::model($surveyid)->findByPk(App()->session['survey_' . $surveyid]['srid']);
if (!$return && $oResponse && !is_null($oResponse->submitdate)) {
return;
}
static $aMatchedQuotas;
// EM call 2 times quotas with 3 lines of php code, then use static.
if (!$aMatchedQuotas) {
$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($aQuotaInfo['members']) === 0) {
continue;
}
$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();
// To count number of hidden questions
$aQuotaQid = array();
foreach ($aQuotaInfo['members'] as $aQuotaMember) {
$aQuotaFields[$aQuotaMember['fieldname']][] = $aQuotaMember['value'];
$aQuotaRelevantFieldnames[$aQuotaMember['fieldname']] = isset($_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']]) && $_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']];
$aQuotaQid[] = $aQuotaMember['qid'];
}
$aQuotaQid = array_unique($aQuotaQid);
// 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]) {
$iMatchedAnswers++;
}
if (in_array($sFieldName, $aPostedFields)) {
// Need only one posted value
$bPostedField = true;
}
}
// Condition to count quota : Answers are the same in quota + an answer is submitted at this time (bPostedField) OR all questions is hidden (bAllHidden)
$bAllHidden = QuestionAttribute::model()->countByAttributes(array('qid' => $aQuotaQid), 'attribute=:attribute', array(':attribute' => 'hidden')) == count($aQuotaQid);
if ($iMatchedAnswers == count($aQuotaFields) && ($bPostedField || $bAllHidden)) {
if ($aQuotaInfo['qlimit'] == 0) {
// Always add the quota if qlimit==0
$aMatchedQuotas[] = $aQuotaInfo;
} else {
$iCompleted = getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);
if (!is_null($iCompleted) && (int) $iCompleted >= (int) $aQuotaInfo['qlimit']) {
// This remove invalid quota and not completed
$aMatchedQuotas[] = $aQuotaInfo;
}
}
}
}
}
if ($return) {
return $aMatchedQuotas;
}
if (empty($aMatchedQuotas)) {
return;
}
// Now we have all the information we need about the quotas and their status.
// We need to construct the page and do all needed action
$aSurveyInfo = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$oTemplate = Template::model()->getInstance('', $surveyid);
$sTemplatePath = $oTemplate->path;
$sTemplateViewPath = $oTemplate->viewPath;
$sClientToken = isset($_SESSION['survey_' . $surveyid]['token']) ? $_SESSION['survey_' . $surveyid]['token'] : "";
// $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();
//.........这里部分代码省略.........
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:101,代码来源:frontend_helper.php
示例6: getQuotaCompletedCount
/**
* Returns the number of answers matching the quota
*
* @param int $iSurveyId - Survey identification number
* @param int $quotaid - quota id for which you want to compute the completed field
* @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 (count($quota['members']) > 0) {
// Keep a list of fields for easy reference
$fields_list = array();
// Construct an array of value for each $quota['members']['fieldnames']
$fields_query = array();
foreach ($quota['members'] as $member) {
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();
$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;
}
开发者ID:rouben,项目名称:LimeSurvey,代码行数:47,代码来源:common_helper.php
示例7: get_quotaCompletedCount
/**
* get_quotaCompletedCount() returns the number of answers matching the quota
* @param string $surveyid - Survey identification number
* @param string $quotaid - quota id for which you want to compute the completed field
* @return string - number of mathing entries in the result DB or 'N/A'
*/
function get_quotaCompletedCount($surveyid, $quotaid)
{
$result = "N/A";
$quota_info = getQuotaInformation($surveyid, GetBaseLanguageFromSurveyID($surveyid), $quotaid);
$quota = $quota_info[0];
if (db_tables_exist(db_table_name_nq('survey_' . $surveyid)) && count($quota['members']) > 0) {
$fields_list = array();
// Keep a list of fields for easy reference
// construct an array of value for each $quota['members']['fieldnames']
unset($querycond);
$fields_query = array();
foreach ($quota['members'] as $member) {
foreach ($member['fieldnames'] as $fieldname) {
if (!in_array($fieldname, $fields_list)) {
$fields_list[] = $fieldname;
$fields_query[$fieldname] = array();
}
$fields_query[$fieldname][] = db_quote_id($fieldname) . " = '{$member['value']}'";
}
}
foreach ($fields_list as $fieldname) {
$select_query = " ( " . implode(' OR ', $fields_query[$fieldname]) . ' )';
$querycond[] = $select_query;
}
$querysel = "SELECT count(id) as count FROM " . db_table_name('survey_' . $surveyid) . " WHERE " . implode(' AND ', $querycond) . " " . " AND submitdate IS NOT NULL";
$result = db_execute_assoc($querysel) or safe_die($connect->ErrorMsg());
//Checked
$quota_check = $result->FetchRow();
$result = $quota_check['count'];
}
return $result;
}
开发者ID:karime7gezly,项目名称:OpenConextApps-LimeSurvey,代码行数:38,代码来源:common_functions.php
示例8: getQuotaCompletedCount
/**
* Returns the number of answers matching the quota
*
* @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'
*/
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 (count($quota['members']) > 0) {
// Keep a list of fields for easy reference
$fields_list = array();
// Construct an array of value for each $quota['members']['fieldnames']
$fields_query = array();
foreach ($quota['members'] as $member) {
if (in_array($member['fieldname'], $aColumnName)) {
$fields_list[$member['fieldname']][] = $member['value'];
} else {
return $result;
}
// We return N/A even for activated survey
}
$criteria = new CDbCriteria();
$criteria->condition = "submitdate IS NOT NULL";
$aParams = array();
foreach ($fields_list as $fieldname => $aValue) {
if (count($aValue) == 1) {
// Quote columnName : starting with number broke mssql
$criteria->addCondition(Yii::app()->db->quoteColumnName($fieldname) . " = :field{$fieldname}");
$aParams[":field{$fieldname}"] = $aValue[0];
} else {
$criteria->addInCondition(Yii::app()->db->quoteColumnName($fieldname), $aValue);
// NO need params : addInCondition bind automatically
}
// We can use directly addInCondition, but don't know what is speediest.
}
if (!empty($aParams)) {
$criteria->params = $aParams;
}
$result = SurveyDynamic::model($iSurveyId)->count($criteria);
}
return $result;
}
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:51,代码来源:common_helper.php
注:本文中的getQuotaInformation函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论