本文整理汇总了PHP中db_table_name函数的典型用法代码示例。如果您正苦于以下问题:PHP db_table_name函数的具体用法?PHP db_table_name怎么用?PHP db_table_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_table_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserNameFromUid
function getUserNameFromUid($uid)
{
$query = "SELECT users_name, uid FROM " . db_table_name('users') . " WHERE uid = {$uid};";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
if ($result->RecordCount() > 0) {
while ($rows = $result->FetchRow()) {
return $rows['users_name'];
}
}
}
示例2: column_type
/**
* Get the data type of a table column, using an ADOdb MetaType() call.
*
* @uses $db
* @param string $table The name of the database table
* @param string $column The name of the field in the table
* @return string Field type or false if error
*/
function column_type($table, $column)
{
global $db;
increment_perf_db_reads();
if (!($rs = $db->Execute('SELECT ' . $column . ' FROM ' . db_table_name($table) . ' WHERE 1=2'))) {
return false;
}
$field = $rs->FetchField(0);
return $rs->MetaType($field->type);
}
示例3: setQuestionAttribute
/**
* This function set a question attribute to a certain value
*
* @param mixed $qid
* @param mixed $sAttributeName
* @param mixed $sAttributeValue
*/
function setQuestionAttribute($qid, $sAttributeName, $sAttributeValue)
{
global $dbprefix, $connect;
$tablename = $dbprefix . 'question_attributes';
$aInsertArray = array('qid' => $qid, 'attribute' => $sAttributeName, 'value' => $sAttributeValue);
$sQuery = $connect->GetInsertSQL($tablename, $aInsertArray);
$connect->Execute('delete from ' . db_table_name('question_attributes') . " where qid={$qid} and attribute=" . db_quoteall($sAttributeName));
$connect->Execute($sQuery);
}
示例4: sanitize_filename
}
if (isset($_GET['filegetcontents'])) {
$sFileName = sanitize_filename($_GET['filegetcontents']);
if (substr($sFileName, 0, 6) == 'futmp_') {
$sFileDir = $tempdir . '/upload/';
} elseif (substr($sFileName, 0, 3) == 'fu_') {
$sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
}
readfile($sFileDir . $sFileName);
exit;
}
// Compute the Session name
// Session name is based:
// * on this specific limesurvey installation (Value SessionName in DB)
// * on the surveyid (from Get or Post param). If no surveyid is given we are on the public surveys portal
$usquery = "SELECT stg_value FROM " . db_table_name("settings_global") . " where stg_name='SessionName'";
$usresult = db_execute_assoc($usquery, '', true);
//Checked
if ($usresult) {
$usrow = $usresult->FetchRow();
$stg_SessionName = $usrow['stg_value'];
if ($surveyid) {
if (isset($_GET['preview']) && $_GET['preview'] == 1) {
@session_name($stg_SessionName);
} else {
@session_name($stg_SessionName . '-runtime-' . $surveyid);
}
} else {
@session_name($stg_SessionName . '-runtime-publicportal');
}
} else {
示例5: updateCFieldName
/**
* Updates the group ID for all conditions
*
* @param integer $iSurveyID
* @param integer $iQuestionID
* @param integer $iOldGroupID
* @param integer $iNewGroupID
*/
public function updateCFieldName($iSurveyID, $iQuestionID, $iOldGroupID, $iNewGroupID)
{
$oResults = $this->findAllByAttributes(array('cqid' => $iQuestionID));
foreach ($oResults as $oRow) {
$cfnregs = '';
if (preg_match('/' . $surveyid . "X" . $iOldGroupID . "X" . $iQuestionID . "(.*)/", $oRow->cfieldname, $cfnregs) > 0) {
$newcfn = $surveyid . "X" . $iNewGroupID . "X" . $iQuestionID . $cfnregs[1];
$c2query = "UPDATE " . db_table_name('conditions') . " SET cfieldname='{$newcfn}' WHERE cid={$oRow->cid}";
Yii::app()->db->createCommand($c2query)->query();
}
}
}
示例6: die
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (count($_POST) == 0 && !(isset($subaction) && $subaction == 'navigation_test')) {
die("Cannot run this script directly");
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LEM Navigation Test</title>
</head>
<body>
<?php
if (count($_POST) == 0) {
$clang = new limesurvey_lang("en");
$query = "select a.surveyls_survey_id as sid, a.surveyls_title as title, b.datecreated, b.assessments " . "from " . db_table_name('surveys_languagesettings') . " as a join " . db_table_name('surveys') . " as b on a.surveyls_survey_id = b.sid" . " where a.surveyls_language='en' order by a.surveyls_title, b.datecreated";
$data = db_execute_assoc($query);
$surveyList = '';
foreach ($data->GetRows() as $row) {
$surveyList .= "<option value='" . $row['sid'] . '|' . $row['assessments'] . "'>#" . $row['sid'] . " [" . $row['datecreated'] . '] ' . FlattenText($row['title']) . "</option>\n";
}
$form = <<<EOD
<form method='post' action='../classes/expressions/test/navigation_test.php'>
<h3>Enter the following variables to test navigation for a survey using different styles</h3>
<table border='1'>
<tr><th>Parameter</th><th>Value</th></tr>
<tr><td>Survey ID (SID)</td>
<td><select name='sid' id='sid'>
{$surveyList}
</select></td></tr>
<tr><td>Navigation Style</td>
示例7: db_execute_assoc
$mearesult = db_execute_assoc($meaquery) or safe_die("Couldn't get answers, Type \"E\"<br />{$meaquery}<br />" . $connect->ErrorMsg());
$dataentryoutput .= "<table>\n";
while ($mearow = $mearesult->FetchRow()) {
if (strpos($mearow['question'], '|')) {
$answerleft = substr($mearow['question'], 0, strpos($mearow['question'], '|'));
$answerright = substr($mearow['question'], strpos($mearow['question'], '|') + 1);
} else {
$answerleft = $mearow['question'];
$answerright = '';
}
$dataentryoutput .= "\t<tr>\n";
$dataentryoutput .= "<td align='right'>{$answerleft}</td>\n";
$dataentryoutput .= "<td>\n";
$dataentryoutput .= "\t<select name='{$fieldname}{$mearow['title']}'>\n";
$dataentryoutput .= "<option value=''>" . $blang->gT("Please choose") . "..</option>\n";
$fquery = "SELECT * FROM " . db_table_name("answers") . " WHERE qid={$deqrow['qid']} and language='{$sDataEntryLanguage}' ORDER BY sortorder, code";
$fresult = db_execute_assoc($fquery);
while ($frow = $fresult->FetchRow()) {
$dataentryoutput .= "<option value='{$frow['code']}'>" . $frow['answer'] . "</option>\n";
}
$dataentryoutput .= "\t</select>\n";
$dataentryoutput .= "</td>\n";
$dataentryoutput .= "<td align='left'>{$answerright}</td>\n";
$dataentryoutput .= "</tr>\n";
}
$dataentryoutput .= "</table>\n";
break;
}
//$dataentryoutput .= " [$surveyid"."X"."$gid"."X"."$qid]";
$dataentryoutput .= "</td>\n";
$dataentryoutput .= "\t</tr>\n";
示例8: XMLImportLabelsets
function XMLImportLabelsets($sFullFilepath, $options)
{
global $connect, $dbprefix, $clang;
$xml = simplexml_load_file($sFullFilepath);
if ($xml->LimeSurveyDocType != 'Label set') {
safe_die('This is not a valid LimeSurvey label set structure XML file.');
}
$dbversion = (double) $xml->DBVersion;
$csarray = buildLabelSetCheckSumArray();
$aLSIDReplacements = array();
$results['labelsets'] = 0;
$results['labels'] = 0;
$results['warnings'] = array();
// Import labels table ===================================================================================
$tablename = $dbprefix . 'labelsets';
foreach ($xml->labelsets->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$oldlsid = $insertdata['lid'];
unset($insertdata['lid']);
// save the old qid
// Insert the new question
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['labelsets']++;
$newlsid = $connect->Insert_ID($tablename, "lid");
// save this for later
$aLSIDReplacements[$oldlsid] = $newlsid;
// add old and new lsid to the mapping array
}
// Import labels table ===================================================================================
$tablename = $dbprefix . 'labels';
if (isset($xml->labels->rows->row)) {
foreach ($xml->labels->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['lid'] = $aLSIDReplacements[$insertdata['lid']];
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['labels']++;
}
}
//CHECK FOR DUPLICATE LABELSETS
if (isset($_POST['checkforduplicates'])) {
foreach (array_values($aLSIDReplacements) as $newlid) {
$thisset = "";
$query2 = "SELECT code, title, sortorder, language, assessment_value\n FROM " . db_table_name('labels') . "\n WHERE lid=" . $newlid . "\n ORDER BY language, sortorder, code";
$result2 = db_execute_num($query2) or safe_die("Died querying labelset {$lid}<br />{$query2}<br />" . $connect->ErrorMsg());
while ($row2 = $result2->FetchRow()) {
$thisset .= implode('.', $row2);
}
// while
$newcs = dechex(crc32($thisset) * 1);
unset($lsmatch);
if (isset($csarray) && $options['checkforduplicates'] == 'on') {
foreach ($csarray as $key => $val) {
if ($val == $newcs) {
$lsmatch = $key;
}
}
}
if (isset($lsmatch)) {
//There is a matching labelset. So, we will delete this one and refer
//to the matched one.
$query = "DELETE FROM {$dbprefix}labels WHERE lid={$newlid}";
$result = $connect->Execute($query) or safe_die("Couldn't delete labels<br />{$query}<br />" . $connect->ErrorMsg());
$results['labels'] = $results['labels'] - $connect->Affected_Rows();
$query = "DELETE FROM {$dbprefix}labelsets WHERE lid={$newlid}";
$result = $connect->Execute($query) or safe_die("Couldn't delete labelset<br />{$query}<br />" . $connect->ErrorMsg());
$results['labelsets']--;
$newlid = $lsmatch;
$results['warnings'][] = $clang->gT("Label set was not imported because the same label set already exists.") . " " . sprintf($clang->gT("Existing LID: %s"), $newlid);
}
}
//END CHECK FOR DUPLICATES
}
return $results;
}
示例9: getQuotaAnswers
function getQuotaAnswers($qid, $surveyid, $quota_id)
{
global $clang;
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$query = "SELECT type, title FROM " . db_table_name('questions') . "q JOIN " . db_table_name('groups') . "g on g.gid=q.gid WHERE qid='{$qid}' AND q.language='{$baselang}' AND g.language='{$baselang}' order by group_order, question_order";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$qtype = $result->FetchRow();
if ($qtype['type'] == 'G') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array('M' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Male"), 'code' => 'M'), 'F' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Female"), 'code' => 'F'));
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'M') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40), 'code' => $dbanslist['title']);
$answerlist[$dbanslist['title']] = $tmparrayans;
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'L' || $qtype['type'] == 'O' || $qtype['type'] == '!') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
$answerlist[$dbanslist['code']] = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40), 'code' => $dbanslist['code']);
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'A') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
for ($x = 1; $x < 6; $x++) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['title']);
$answerlist[$dbanslist['title'] . "-" . $x] = $tmparrayans;
}
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'B') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
for ($x = 1; $x < 11; $x++) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['code']);
$answerlist[$dbanslist['code'] . "-" . $x] = $tmparrayans;
}
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'Y') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array('Y' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Yes"), 'code' => 'Y'), 'N' => array('Title' => $qtype['title'], 'Display' => $clang->gT("No"), 'code' => 'N'));
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'I') {
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
array_unshift($slangs, $baselang);
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
while (list($key, $value) = each($slangs)) {
//.........这里部分代码省略.........
示例10: upgrade_surveypermissions_table145
function upgrade_surveypermissions_table145()
{
global $modifyoutput, $connect;
$sPermissionQuery = "SELECT * FROM " . db_table_name('surveys_rights');
$oPermissionResult = db_execute_assoc($sPermissionQuery);
if (!$oPermissionResult) {
return "Database Error";
} else {
$tablename = db_table_name_nq('survey_permissions');
while ($aPermissionRow = $oPermissionResult->FetchRow()) {
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'assessments', 'create_p' => $aPermissionRow['define_questions'], 'read_p' => $aPermissionRow['define_questions'], 'update_p' => $aPermissionRow['define_questions'], 'delete_p' => $aPermissionRow['define_questions'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'quotas', 'create_p' => $aPermissionRow['define_questions'], 'read_p' => $aPermissionRow['define_questions'], 'update_p' => $aPermissionRow['define_questions'], 'delete_p' => $aPermissionRow['define_questions'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'responses', 'create_p' => $aPermissionRow['browse_response'], 'read_p' => $aPermissionRow['browse_response'], 'update_p' => $aPermissionRow['browse_response'], 'delete_p' => $aPermissionRow['delete_survey'], 'export_p' => $aPermissionRow['export'], 'import_p' => $aPermissionRow['browse_response'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'statistics', 'read_p' => $aPermissionRow['browse_response'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'survey', 'read_p' => 1, 'delete_p' => $aPermissionRow['delete_survey'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'surveyactivation', 'update_p' => $aPermissionRow['activate_survey'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'surveycontent', 'create_p' => $aPermissionRow['define_questions'], 'read_p' => $aPermissionRow['define_questions'], 'update_p' => $aPermissionRow['define_questions'], 'delete_p' => $aPermissionRow['define_questions'], 'export_p' => $aPermissionRow['export'], 'import_p' => $aPermissionRow['define_questions'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'surveylocale', 'read_p' => $aPermissionRow['edit_survey_property'], 'update_p' => $aPermissionRow['edit_survey_property'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'surveysettings', 'read_p' => $aPermissionRow['edit_survey_property'], 'update_p' => $aPermissionRow['edit_survey_property'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
$sPermissionInsertQuery = $connect->GetInsertSQL($tablename, array('permission' => 'tokens', 'create_p' => $aPermissionRow['activate_survey'], 'read_p' => $aPermissionRow['activate_survey'], 'update_p' => $aPermissionRow['activate_survey'], 'delete_p' => $aPermissionRow['activate_survey'], 'export_p' => $aPermissionRow['export'], 'import_p' => $aPermissionRow['activate_survey'], 'sid' => $aPermissionRow['sid'], 'uid' => $aPermissionRow['uid']));
modify_database("", $sPermissionInsertQuery);
echo $modifyoutput;
flush();
ob_flush();
}
}
}
示例11: limesurvey_lang
$clang = new limesurvey_lang($baselang);
} else {
$clang = new limesurvey_lang($postlang);
$baselang = $postlang;
}
$thissurvey = getSurveyInfo($surveyid, $baselang);
$html = '<div id="wrapper"><p id="optoutmessage">';
if ($thissurvey == false || !tableExists("tokens_{$surveyid}")) {
$html .= $clang->gT('This survey does not seem to exist.');
} else {
$usquery = "SELECT emailstatus from " . db_table_name("tokens_{$surveyid}") . " where token=" . db_quoteall($token, true);
$usresult = $connect->GetOne($usquery);
if ($usresult == false) {
$html .= $clang->gT('You are not a participant in this survey.');
} elseif ($usresult == 'OK') {
$usquery = "Update " . db_table_name("tokens_{$surveyid}") . " set emailstatus='OptOut', usesleft=0 where token=" . db_quoteall($token, true);
$usresult = $connect->Execute($usquery);
$html .= $clang->gT('You have been successfully removed from this survey.');
} else {
$html .= $clang->gT('You have been already removed from this survey.');
}
}
$html .= '</p></div>';
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir']) {
$thistpl = sGetTemplatePath($defaulttemplate);
} else {
$thistpl = sGetTemplatePath($thissurvey['templatedir']);
}
sendcacheheaders();
doHeader();
示例12: importQuestion
//.........这里部分代码省略.........
// while
$newcs = dechex(crc32($thisset) * 1);
unset($lsmatch);
if (isset($csarray)) {
foreach ($csarray as $key => $val) {
if ($val == $newcs) {
$lsmatch = $key;
}
}
}
if (isset($lsmatch)) {
//There is a matching labelset. So, we will delete this one and refer
//to the matched one.
$query = "DELETE FROM {$dbprefix}labels WHERE lid={$newlid}";
$result = $connect->Execute($query) or $this->debugLsrc("Couldn't delete labels{$query}" . $connect->ErrorMsg());
$query = "DELETE FROM {$dbprefix}labelsets WHERE lid={$newlid}";
$result = $connect->Execute($query) or $this->debugLsrc("Couldn't delete labelset{$query}" . $connect->ErrorMsg());
$newlid = $lsmatch;
} else {
//There isn't a matching labelset, add this checksum to the $csarray array
$csarray[$newlid] = $newcs;
}
//END CHECK FOR DUPLICATES
$labelreplacements[] = array($oldlid, $newlid);
}
}
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
// QUESTIONS, THEN ANSWERS FOR QUESTIONS IN A NESTED FORMAT!
if (isset($questionarray) && $questionarray) {
$qafieldorders = convertCSVRowToArray($questionarray[0], ',', '"');
unset($questionarray[0]);
//Assuming we will only import one question at a time we will now find out the maximum question order in this group
//and save it for later
$qmaxqo = "SELECT MAX(question_order) AS maxqo FROM " . db_table_name('questions') . " WHERE sid={$newsid} AND gid={$newgid}";
$qres = db_execute_assoc($qmaxqo) or $this->debugLsrc("Error: " . ": Failed to find out maximum question order value\n{$qmaxqo}\n" . $connect->ErrorMsg());
$qrow = $qres->FetchRow();
$newquestionorder = $qrow['maxqo'] + 1;
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
foreach ($questionarray as $qa) {
$qacfieldcontents = convertCSVRowToArray($qa, ',', '"');
$newfieldcontents = $qacfieldcontents;
$questionrowdata = array_combine($qafieldorders, $qacfieldcontents);
if (isset($languagesSupported[$questionrowdata["language"]])) {
$oldqid = $questionrowdata['qid'];
$oldsid = $questionrowdata['sid'];
$oldgid = $questionrowdata['gid'];
// Remove qid field if there is no newqid; and set it to newqid if it's set
if (!isset($newqid)) {
unset($questionrowdata['qid']);
} else {
$questionrowdata['qid'] = $newqid;
}
$questionrowdata["sid"] = $newsid;
$questionrowdata["gid"] = $newgid;
$questionrowdata["question_order"] = $newquestionorder;
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
// Now we will fix up the label id
$type = $questionrowdata["type"];
//Get the type
if ($type == "F" || $type == "H" || $type == "1" || $type == ":" || $type == ";") {
//IF this is a flexible label array, update the lid entry
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
if (isset($labelreplacements)) {
foreach ($labelreplacements as $lrp) {
if ($lrp[0] == $questionrowdata["lid"]) {
$questionrowdata["lid"] = $lrp[1];
示例13: array
require_once 'classes/GroupTokens.php';
global $grouprel_config, $as, $user_id;
if (isset($as)) {
$auth = array($grouprel_config['userIdAttribute'] => $user_id);
} else {
// developer:
$auth = array($grouprel_config['userIdAttribute'] => 'urn:collab:person:test.surfguest.nl:mdobrinic');
}
$o = new GroupTokens($auth, $surveyid, $grouprel_config);
$invite_output = $o->invite();
$persons = $o->_allmembers;
$personcount = count($persons);
if ($personcount > 0) {
$language = GetBaseLanguageFromSurveyID($surveyid);
foreach ($persons as $p) {
$iq = "INSERT INTO " . db_table_name("tokens_{$surveyid}") . " \n" . "(firstname, lastname, email, emailstatus, language) \n" . "VALUES (%1, %2, %3, 'OK', " . db_quoteall($language) . ")";
$a = $p->getAttributes();
$iq = str_replace('%1', db_quoteall($a['firstname']), $iq);
$iq = str_replace('%2', db_quoteall($a['lastname']), $iq);
$iq = str_replace('%3', db_quoteall($a['email']), $iq);
if (true) {
$ir = $connect->Execute($iq);
} else {
echo "Executing: '{$iq}' <br/>\n";
}
}
// foreach(persons)
$tokenoutput .= "<span class='successtitle'>" . $clang->gT("Success") . "</span><br /><br />\n";
} else {
$tokenoutput .= "<font color='red'>" . $clang->gT("Failed") . "</font><br /><br />\n";
$tokenoutput .= $clang->gT("There were no group(s) selected or group-member(s) retrieved.");
示例14: fixorder
/**
* Function rewrites the sortorder for a label set
*
* @param mixed $lid Label set ID
*/
function fixorder($lid) {
global $dbprefix, $connect, $labelsoutput;
$qulabelset = "SELECT * FROM ".db_table_name('labelsets')." WHERE lid=$lid";
$rslabelset = db_execute_assoc($qulabelset) or safe_die($connect->ErrorMsg());
$rwlabelset=$rslabelset->FetchRow();
$lslanguages=explode(" ", trim($rwlabelset['languages']));
foreach ($lslanguages as $lslanguage)
{
$query = "SELECT lid, code, title, sortorder FROM ".db_table_name('labels')." WHERE lid=? and language=? ORDER BY sortorder, code";
$result = db_execute_num($query, array($lid,$lslanguage)) or safe_die("Can't read labels table: $query // (lid=$lid, language=$lslanguage) ".$connect->ErrorMsg());
$position=0;
while ($row=$result->FetchRow())
{
$position=sprintf("%05d", $position);
$query2="UPDATE ".db_table_name('labels')." SET sortorder='$position' WHERE lid=? AND code=? AND title=? AND language='$lslanguage' ";
$result2=$connect->Execute($query2, array ($row[0], $row[1], $row[2])) or safe_die ("Couldn't update sortorder<br />$query2<br />".$connect->ErrorMsg());
$position++;
}
}
}
示例15: fSendStatistic
/**
*
* Enter description here...
* @param $sUser Limesurvey user
* @param $sPass Password
* @param $iVid surveyid
* @param $email e-mail adress of the recipient
* @param $docType pdf, xls or html
* @param $graph with 1 it includes graphs in pdf files
* @return "OK" or SoapFault
*/
function fSendStatistic($sUser, $sPass, $iVid, $email, $docType = 'pdf', $graph = '0')
{
global $connect;
global $dbprefix;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
include "lsrc.config.php";
$lsrcHelper = new lsrcHelper();
// Check if all mandatory parameters are present, else abort...
if (!is_int($iVid) || $iVid == 0 || $email == '') {
throw new SoapFault("Server: ", "Mandatory Parameters missing");
exit;
}
if (!$lsrcHelper->checkUser($sUser, $sPass)) {
throw new SoapFault("Authentication: ", "User or password wrong");
exit;
}
if ($lsrcHelper->getSurveyOwner($iVid) != $_SESSION['loginID'] && !$_SESSION['USER_RIGHT_SUPERADMIN'] == '1') {
throw new SoapFault("Authentication: ", "You have no right to send statistics from other peoples Surveys");
exit;
}
if (!$lsrcHelper->surveyExists($iVid)) {
throw new SoapFault("Database: ", "Survey {$iVid} does not exists");
exit;
}
$lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ",sid={$iVid} email={$email} doctype={$docType} graph={$graph} START OK ");
/**
* Build up the fields to generate statistics from
*/
$summarySql = " SELECT gid, lid, qid, type " . " FROM {$dbprefix}questions " . " WHERE sid={$surveyid} ";
$summaryRs = $connect->Execute($summarySql);
$lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ",sid={$iVid} OK ");
foreach ($summaryRs as $field) {
$myField = $surveyid . "X" . $field['gid'] . "X" . $field['qid'];
// Multiple choice get special treatment
if ($field['type'] == "M" || $field['type'] == "P") {
$myField = "M{$myField}";
}
//numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
if ($field['type'] == "N") {
$myField = "N{$myField}";
}
if ($field['type'] == "Q") {
$myField = "Q{$myField}";
}
// textfields get special treatment
if ($field['type'] == "S" || $field['type'] == "T" || $field['type'] == "U") {
$myField = "T{$myField}";
}
//statistics for Date questions are not implemented yet.
if ($field['type'] == "D") {
$myField = "D{$myField}";
}
if ($field['type'] == "F" || $field['type'] == "H") {
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
//Get answers. We always use the answer code because the label might be too long elsewise
$query = "SELECT code, answer FROM " . db_table_name("answers") . " WHERE qid='" . $field['qid'] . "' AND language='{$language}' ORDER BY sortorder, answer";
$result = $connect->Execute($query) or safe_die("Couldn't get answers!<br />{$query}<br />" . $connect->ErrorMsg());
$counter2 = 0;
//check all the answers
while ($row = $result->FetchRow()) {
$myField = "{$myField}{$row[0]}";
}
//$myField = "{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]";
}
$summary[] = $myField;
}
//$lsrcHelper->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.",".print_r($summary)." ");
switch ($docType) {
case 'pdf':
$tempFile = generate_statistics($iVid, $summary, 'all', $graph, $docType, 'F');
if ($lsrcHelper->sendStatistic($iVid, $email, $tempFile)) {
unlink($tempFile);
return 'PDF send';
} else {
unlink($tempFile);
throw new SoapFault("Mail System", "Mail could not be send! Check LimeSurveys E-Mail Settings.");
exit;
}
break;
case 'xls':
$tempFile = generate_statistics($iVid, $summary, 'all', 0, $docType, 'F');
if ($lsrcHelper->sendStatistic($iVid, $email, $tempFile)) {
unlink($tempFile);
return 'XLS send';
} else {
unlink($tempFile);
throw new SoapFault("Mail System", "Mail could not be send! Check LimeSurveys E-Mail Settings.");
exit;
}
//.........这里部分代码省略.........