本文整理汇总了PHP中F_isAuthorizedUser函数的典型用法代码示例。如果您正苦于以下问题:PHP F_isAuthorizedUser函数的具体用法?PHP F_isAuthorizedUser怎么用?PHP F_isAuthorizedUser使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了F_isAuthorizedUser函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intval
require_once '../../shared/code/tce_functions_form.php';
require_once '../../shared/code/tce_functions_tcecode.php';
require_once '../../shared/code/tce_functions_auth_sql.php';
if (isset($selectcategory)) {
$changecategory = 1;
}
if (isset($testlog_id)) {
$testlog_id = intval($testlog_id);
}
if (!isset($testlog_comment)) {
$testlog_comment = '';
}
if (isset($_REQUEST['test_id']) and $_REQUEST['test_id'] > 0) {
$test_id = intval($_REQUEST['test_id']);
// check user's authorization
if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
F_print_error('ERROR', $l['m_authorization_denied']);
exit;
}
} else {
$test_id = 0;
}
switch ($menu_mode) {
case 'update':
// Update
if ($formstatus = F_check_form_fields()) {
if (isset($testlog_score) and isset($max_score)) {
// score cannot be greater than max_score
$testlog_score = floatval($testlog_score);
$max_score = floatval($max_score);
if ($testlog_score > $max_score) {
示例2: addModule
/**
* Add a new module if not exist.
* @private
*/
private function addModule()
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../code/tce_functions_auth_sql.php';
if (isset($this->level_data['module']['module_id']) and $this->level_data['module']['module_id'] > 0) {
return;
}
// check if this module already exist
$sql = 'SELECT module_id
FROM ' . K_TABLE_MODULES . '
WHERE module_name=\'' . $this->level_data['module']['module_name'] . '\'
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
// get existing module ID
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['module_id'], 'module_user_id')) {
// unauthorized user
$this->level_data['module']['module_id'] = false;
} else {
$this->level_data['module']['module_id'] = $m['module_id'];
}
} else {
// insert new module
$sql = 'INSERT INTO ' . K_TABLE_MODULES . ' (
module_name,
module_enabled,
module_user_id
) VALUES (
\'' . $this->level_data['module']['module_name'] . '\',
\'' . $this->boolval[$this->level_data['module']['module_enabled']] . '\',
\'' . $_SESSION['session_user_id'] . '\'
)';
if (!($r = F_db_query($sql, $db))) {
F_display_db_error();
} else {
// get new module ID
$this->level_data['module']['module_id'] = F_db_insert_id($db, K_TABLE_MODULES, 'module_id');
}
}
} else {
F_display_db_error();
}
}
示例3: utrim
} else {
$subject_name = '';
}
if (isset($_REQUEST['subject_description'])) {
$subject_description = utrim($_REQUEST['subject_description']);
} else {
$subject_description = '';
}
if ($subject_id > 0) {
if ($changecategory == 0) {
$sql = 'SELECT subject_module_id FROM ' . K_TABLE_SUBJECTS . ' WHERE subject_id=' . $subject_id . ' LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$subject_module_id = $m['subject_module_id'];
// check user's authorization for parent module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $subject_module_id, 'module_user_id') and !F_isAuthorizedUser(K_TABLE_SUBJECTS, 'subject_id', $subject_id, 'subject_user_id')) {
F_print_error('ERROR', $l['m_authorization_denied']);
exit;
}
}
} else {
F_display_db_error();
}
}
} else {
$subject_id = 0;
}
switch ($menu_mode) {
case 'delete':
F_stripslashes_formfields();
// check if this record is used (test_log)
示例4: intval
*/
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_authorization.php';
require_once '../code/tce_functions_auth_sql.php';
require_once '../../shared/code/tce_functions_tcecode.php';
require_once '../../shared/config/tce_pdf.php';
require_once '../../shared/code/tcpdfex.php';
if (isset($_REQUEST['expmode']) and $_REQUEST['expmode'] > 0 and (isset($_REQUEST['module_id']) and $_REQUEST['module_id'] > 0) and (isset($_REQUEST['subject_id']) and $_REQUEST['subject_id'] > 0)) {
$expmode = intval($_REQUEST['expmode']);
$module_id = intval($_REQUEST['module_id']);
$subject_id = intval($_REQUEST['subject_id']);
} else {
exit;
}
// check user's authorization for module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $module_id, 'module_user_id')) {
exit;
}
$show_answers = true;
if (isset($_REQUEST['hide_answers']) and $_REQUEST['hide_answers'] == 1) {
$show_answers = false;
}
$doc_title = unhtmlentities($l['t_questions_list']);
$doc_description = F_compact_string(unhtmlentities($l['hp_select_all_questions']));
$page_elements = 6;
$qtype = array('S', 'M', 'T', '0');
// question types
$qright = array(' ', '*');
// question types
// --- create pdf document
if ($l['a_meta_dir'] == 'rtl') {
示例5: F_question_copy
/**
* Copy selected question to another topic
* @author Nicola Asuni
* @since 2008-11-26
* @param $question_id (int) question ID
* @param $new_subject_id (int) new subject ID
*/
function F_question_copy($question_id, $new_subject_id)
{
global $l, $db;
require_once '../config/tce_config.php';
$question_id = intval($question_id);
$new_subject_id = intval($new_subject_id);
// check authorization
$sql = 'SELECT subject_module_id FROM ' . K_TABLE_SUBJECTS . ' WHERE subject_id=' . $new_subject_id . ' LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$subject_module_id = $m['subject_module_id'];
// check user's authorization for parent module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $subject_module_id, 'module_user_id')) {
return;
}
}
} else {
F_display_db_error();
return;
}
$q = F_question_get_data($question_id);
if ($q !== false) {
if (K_DATABASE_TYPE == 'ORACLE') {
$chksql = 'dbms_lob.instr(question_description,\'' . F_escape_sql($db, $q['question_description']) . '\',1,1)>0';
} elseif (K_DATABASE_TYPE == 'MYSQL' and defined('K_MYSQL_QA_BIN_UNIQUITY') and K_MYSQL_QA_BIN_UNIQUITY) {
$chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\' COLLATE utf8_bin';
} else {
$chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\'';
}
if (F_check_unique(K_TABLE_QUESTIONS, $chksql . ' AND question_subject_id=' . $new_subject_id . '')) {
$sql = 'START TRANSACTION';
if (!($r = F_db_query($sql, $db))) {
F_display_db_error(false);
break;
}
// adjust questions ordering
if ($q['question_position'] > 0) {
$sql = 'UPDATE ' . K_TABLE_QUESTIONS . ' SET
question_position=question_position+1
WHERE question_subject_id=' . $new_subject_id . '
AND question_position>=' . $q['question_position'] . '';
if (!($r = F_db_query($sql, $db))) {
F_display_db_error(false);
F_db_query('ROLLBACK', $db);
// rollback transaction
}
}
$sql = 'INSERT INTO ' . K_TABLE_QUESTIONS . ' (
question_subject_id,
question_description,
question_explanation,
question_type,
question_difficulty,
question_enabled,
question_position,
question_timer,
question_fullscreen,
question_inline_answers,
question_auto_next
) VALUES (
' . $new_subject_id . ',
\'' . F_escape_sql($db, $q['question_description']) . '\',
\'' . F_escape_sql($db, $q['question_explanation']) . '\',
\'' . $q['question_type'] . '\',
\'' . $q['question_difficulty'] . '\',
\'' . $q['question_enabled'] . '\',
' . F_zero_to_null($q['question_position']) . ',
\'' . $q['question_timer'] . '\',
\'' . $q['question_fullscreen'] . '\',
\'' . $q['question_inline_answers'] . '\',
\'' . $q['question_auto_next'] . '\'
)';
if (!($r = F_db_query($sql, $db))) {
F_display_db_error(false);
} else {
$new_question_id = F_db_insert_id($db, K_TABLE_QUESTIONS, 'question_id');
}
// copy associated answers
$sql = 'SELECT *
FROM ' . K_TABLE_ANSWERS . '
WHERE answer_question_id=' . $question_id . '';
if ($r = F_db_query($sql, $db)) {
while ($m = F_db_fetch_array($r)) {
$sqli = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
answer_question_id,
answer_description,
answer_explanation,
answer_isright,
answer_enabled,
answer_position,
answer_keyboard_key
) VALUES (
' . $new_question_id . ',
//.........这里部分代码省略.........
示例6: array
$question_explanation = '';
}
$qtype = array('S', 'M', 'T', 'O');
// question types
// check user's authorization
if (isset($_REQUEST['question_id']) and $_REQUEST['question_id'] > 0) {
$question_id = intval($_REQUEST['question_id']);
$sql = 'SELECT subject_module_id,question_subject_id
FROM ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_QUESTIONS . '
WHERE subject_id=question_subject_id
AND question_id=' . $question_id . '
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
// check user's authorization for parent module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['subject_module_id'], 'module_user_id')) {
F_print_error('ERROR', $l['m_authorization_denied']);
exit;
}
}
} else {
F_display_db_error();
}
}
switch ($menu_mode) {
case 'delete':
F_stripslashes_formfields();
// check if this record is used (test_log)
if (!F_check_unique(K_TABLE_TESTS_LOGS, 'testlog_question_id=' . $question_id . '')) {
//this record will be only disabled and not deleted because it's used
$sql = 'UPDATE ' . K_TABLE_QUESTIONS . ' SET
示例7: array
$answer_explanation = '';
}
$qtype = array('S', 'M', 'T', 'O');
// question types
// check user's authorization
if ($answer_id > 0) {
$sql = 'SELECT subject_module_id,question_subject_id,answer_question_id
FROM ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_QUESTIONS . ', ' . K_TABLE_ANSWERS . '
WHERE subject_id=question_subject_id
AND question_id=answer_question_id
AND answer_id=' . $answer_id . '
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
// check user's authorization for parent module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['subject_module_id'], 'module_user_id') and !F_isAuthorizedUser(K_TABLE_SUBJECTS, 'subject_id', $m['question_subject_id'], 'subject_user_id')) {
F_print_error('ERROR', $l['m_authorization_denied']);
exit;
}
}
} else {
F_display_db_error();
}
}
switch ($menu_mode) {
case 'delete':
F_stripslashes_formfields();
// check if this record is used (test_log)
if (!F_check_unique(K_TABLE_LOG_ANSWER, 'logansw_answer_id=' . $answer_id . '')) {
//this record will be only disabled and not deleted because it's used
$sql = 'UPDATE ' . K_TABLE_ANSWERS . ' SET
示例8: F_getBoolean
$ssl_enabled = F_getBoolean($ssl_enabled);
}
if (isset($ssl_name)) {
$ssl_name = utrim($ssl_name);
} else {
$ssl_name = '';
}
if (isset($ssl_user_id)) {
$ssl_user_id = intval($ssl_user_id);
} else {
$ssl_user_id = intval($_SESSION['session_user_id']);
}
if (isset($_REQUEST['ssl_id']) and $_REQUEST['ssl_id'] > 0) {
$ssl_id = intval($_REQUEST['ssl_id']);
// check user's authorization for this certificate
if (!F_isAuthorizedUser(K_TABLE_SSLCERTS, 'ssl_id', $ssl_id, 'ssl_user_id')) {
F_print_error('ERROR', $l['m_authorization_denied']);
exit;
}
} else {
$ssl_id = 0;
}
// extact hash and end date from uploaded file
$ssl_hash = '';
$ssl_end_date = '';
if (isset($_FILES['userfile']['name']) and !empty($_FILES['userfile']['name'])) {
require_once '../code/tce_functions_upload.php';
// upload file
$uploadedfile = F_upload_file('userfile', K_PATH_CACHE);
if ($uploadedfile !== false) {
$cert = file_get_contents(K_PATH_CACHE . $uploadedfile);
示例9: F_getRawTestStat
/**
* Returns raw statistic array for the selected test.
* @param $test_id (int) test ID.
* @param $group_id (int) group ID - if greater than zero, filter stats for the specified user group.
* @param $user_id (int) user ID - if greater than zero, filter stats for the specified user.
* @param $startdate (int) start date ID - if greater than zero, filter stats for the specified starting date
* @param $enddate (int) end date ID - if greater than zero, filter stats for the specified ending date
* @param $testuser_id (int) test-user ID - if greater than zero, filter stats for the specified test-user.
* @param $data (array) Array of existing data to be merged with the current one.
* @param $pubmode (boolean) If true filter the results for the public interface.
* return $data array containing test statistics.
*/
function F_getRawTestStat($test_id, $group_id = 0, $user_id = 0, $startdate = 0, $enddate = 0, $testuser_id = 0, $data = array(), $pubmode = false)
{
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_authorization.php';
require_once '../../shared/code/tce_functions_test.php';
global $db, $l;
$test_id = intval($test_id);
$group_id = intval($group_id);
$user_id = intval($user_id);
$testuser_id = intval($testuser_id);
// query to calculate total number of questions
$sqltot = K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS;
$sqltb = K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER;
$sqlm = K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_QUESTIONS . ', ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_MODULES . '';
// apply filters
$sqlw = 'WHERE testlog_testuser_id=testuser_id';
$sqlansw = 'WHERE logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id';
if ($test_id > 0) {
$sqlw .= ' AND testuser_test_id=' . $test_id . '';
$sqlansw .= ' AND testuser_test_id=' . $test_id . '';
} elseif ($pubmode) {
$test_ids_results = F_getTestIDResults($test_id, $user_id);
$sqlw .= ' AND testuser_test_id IN (' . $test_ids_results . ')';
$sqlansw .= ' AND testuser_test_id IN (' . $test_ids_results . ')';
}
if ($user_id > 0) {
$sqltot .= ', ' . K_TABLE_USERS;
$sqltb .= ', ' . K_TABLE_USERS;
$sqlm .= ', ' . K_TABLE_USERS;
$sqlw .= ' AND testuser_user_id=user_id AND user_id=' . $user_id . '';
$sqlansw .= ' AND testuser_user_id=user_id AND user_id=' . $user_id . '';
if ($testuser_id > 0) {
$sqlw .= ' AND testuser_id=' . $testuser_id . '';
$sqlansw .= ' AND testuser_id=' . $testuser_id . '';
}
} elseif ($group_id > 0) {
$sqltot .= ', ' . K_TABLE_USERS . ', ' . K_TABLE_USERGROUP;
$sqltb .= ', ' . K_TABLE_USERS . ', ' . K_TABLE_USERGROUP;
$sqlm .= ', ' . K_TABLE_USERS . ', ' . K_TABLE_USERGROUP;
$sqlw .= ' AND testuser_user_id=user_id AND usrgrp_user_id=user_id AND usrgrp_group_id=' . $group_id . '';
$sqlansw .= ' AND testuser_user_id=user_id AND usrgrp_user_id=user_id AND usrgrp_group_id=' . $group_id . '';
}
if (!empty($startdate)) {
$startdate_time = strtotime($startdate);
$startdate = date(K_TIMESTAMP_FORMAT, $startdate_time);
$sqlw .= ' AND testuser_creation_time>=\'' . $startdate . '\'';
$sqlansw .= ' AND testuser_creation_time>=\'' . $startdate . '\'';
}
if (!empty($enddate)) {
$enddate_time = strtotime($enddate);
$enddate = date(K_TIMESTAMP_FORMAT, $enddate_time);
$sqlw .= ' AND testuser_creation_time<=\'' . $enddate . '\'';
$sqlansw .= ' AND testuser_creation_time<=\'' . $enddate . '\'';
}
// check if a specific test is selected or not
if ($test_id == 0) {
$test_ids = array();
$sqlt = 'SELECT testuser_test_id FROM ' . $sqltot . ' ' . $sqlw . ' GROUP BY testuser_test_id ORDER BY testuser_test_id';
if ($rt = F_db_query($sqlt, $db)) {
while ($mt = F_db_fetch_assoc($rt)) {
// check user's authorization
if (F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $mt['testuser_test_id'], 'test_user_id')) {
$test_ids[] = $mt['testuser_test_id'];
}
}
} else {
F_display_db_error();
}
foreach ($test_ids as $tid) {
// select test IDs
$data = F_getRawTestStat($tid, $group_id, $user_id, $startdate, $enddate, $testuser_id, $data);
}
return $data;
}
$testdata = F_getTestData($test_id);
// array to be returned
if (!isset($data['qstats'])) {
// total number of questions
$data['qstats'] = array('recurrence' => 0, 'recurrence_perc' => 0, 'average_score' => 0, 'average_score_perc' => 0, 'average_time' => 0, 'right' => 0, 'right_perc' => 0, 'wrong' => 0, 'wrong_perc' => 0, 'unanswered' => 0, 'unanswered_perc' => 0, 'undisplayed' => 0, 'undisplayed_perc' => 0, 'unrated' => 0, 'unrated_perc' => 0, 'qnum' => 0, 'module' => array());
}
$sql = 'SELECT
module_id,
subject_id,
question_id,
module_name,
subject_name,
subject_description,
question_description,';
//.........这里部分代码省略.........
示例10: F_csv_export_result_allusers
/**
* Export all test results to CSV.
* @author Nicola Asuni
* @since 2006-03-30
* @param $test_id (int) Test ID
* @param $group_id (int) Group ID
* @param $order_field (string) ORDER BY portion of the SQL query
* @return CSV data
*/
function F_csv_export_result_allusers($test_id, $group_id = 0, $order_field = "")
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_authorization.php';
require_once '../../shared/code/tce_functions_test_stats.php';
require_once 'tce_functions_user_select.php';
require_once '../code/tce_functions_statistics.php';
$test_id = intval($test_id);
$group_id = intval($group_id);
$order_field = F_escape_sql($order_field);
// check user's authorization
if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
return '';
}
if (!F_isAuthorizedEditorForGroup($group_id)) {
return '';
}
// statistical data
$statsdata = array();
$statsdata['score'] = array();
$statsdata['right'] = array();
$statsdata['wrong'] = array();
$statsdata['unanswered'] = array();
$statsdata['undisplayed'] = array();
$statsdata['unrated'] = array();
$csv = '';
// CSV data to be returned
// general data
$csv .= 'TCExam Results Summary' . K_NEWLINE . K_NEWLINE;
$csv .= 'version' . K_TAB . K_TCEXAM_VERSION . K_NEWLINE;
$csv .= 'lang' . K_TAB . K_USER_LANG . K_NEWLINE;
$csv .= 'date' . K_TAB . date(K_TIMESTAMP_FORMAT) . K_NEWLINE;
$csv .= 'test_id' . K_TAB . $test_id . K_NEWLINE;
$csv .= 'group_id' . K_TAB . $group_id . K_NEWLINE;
$csv .= K_NEWLINE . K_NEWLINE;
// separator
// print column names
$csv .= '#';
$csv .= K_TAB . $l['w_time_begin'];
$csv .= K_TAB . $l['w_time_end'];
$csv .= K_TAB . $l['w_time'];
$csv .= K_TAB . $l['w_lastname'];
$csv .= K_TAB . $l['w_firstname'];
$csv .= K_TAB . $l['w_user'];
$csv .= K_TAB . $l['w_passed'];
$csv .= K_TAB . $l['w_score'];
$csv .= K_TAB . $l['w_answers_right'];
$csv .= K_TAB . $l['w_answers_wrong'];
$csv .= K_TAB . $l['w_questions_unanswered'];
$csv .= K_TAB . $l['w_questions_undisplayed'];
$csv .= K_TAB . $l['w_questions_unrated'];
$csv .= K_TAB . $l['w_comment'];
$passed = 0;
// output users stats
$sqlr = 'SELECT
testuser_id,
testuser_creation_time,
user_id,
user_lastname,
user_firstname,
user_name,
SUM(testlog_score) AS total_score,
MAX(testlog_change_time) AS testuser_end_time
FROM ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_USERS . '
WHERE testlog_testuser_id=testuser_id
AND testuser_user_id=user_id
AND testuser_test_id=' . $test_id . '';
if ($group_id > 0) {
$sqlr .= ' AND testuser_user_id IN (
SELECT usrgrp_user_id
FROM ' . K_TABLE_USERGROUP . '
WHERE usrgrp_group_id=' . $group_id . '
)';
}
if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
$sqlr .= ' AND (user_level<' . $_SESSION['session_user_level'] . ' OR user_id=' . $_SESSION['session_user_id'] . ')';
}
$sqlr .= ' GROUP BY testuser_id, testuser_creation_time, user_id, user_lastname, user_firstname, user_name
ORDER BY ' . $order_field . '';
if ($rr = F_db_query($sqlr, $db)) {
$itemcount = 0;
while ($mr = F_db_fetch_array($rr)) {
$itemcount++;
$csv .= K_NEWLINE . $itemcount;
$csv .= K_TAB . $mr['testuser_creation_time'];
$csv .= K_TAB . $mr['testuser_end_time'];
$time_diff = strtotime($mr['testuser_end_time']) - strtotime($mr['testuser_creation_time']);
//sec
$time_diff = gmdate('H:i:s', $time_diff);
$csv .= K_TAB . $time_diff;
//.........这里部分代码省略.........
示例11: F_send_report_emails
/**
* Sends email test reports to users.
* @author Nicola Asuni
* @since 2005-02-24
* @param $test_id (int) TEST ID
* @param $user_id (int) USER ID (0 means all users)
* @param $group_id (int) GROUP ID (0 means all groups)
* @param $mode (int) type of report to send: 0=detailed report; 1=summary report (without questions)
*/
function F_send_report_emails($test_id, $user_id = 0, $group_id = 0, $mode = 0)
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_test.php';
require_once '../../shared/code/tce_functions_test_stats.php';
require_once '../../shared/code/tce_class_mailer.php';
require_once 'tce_functions_user_select.php';
$test_id = intval($test_id);
$user_id = intval($user_id);
$group_id = intval($group_id);
$mode = intval($mode);
if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
return;
}
if (!F_isAuthorizedEditorForUser($user_id)) {
return;
}
if (!F_isAuthorizedEditorForGroup($group_id)) {
return;
}
// Instantiate C_mailer class
$mail = new C_mailer();
//Load default values
$mail->language = $l;
$mail->Priority = $emailcfg['Priority'];
$mail->ContentType = $emailcfg['ContentType'];
$mail->Encoding = $emailcfg['Encoding'];
$mail->WordWrap = $emailcfg['WordWrap'];
$mail->Mailer = $emailcfg['Mailer'];
$mail->Sendmail = $emailcfg['Sendmail'];
$mail->UseMSMailHeaders = $emailcfg['UseMSMailHeaders'];
$mail->Host = $emailcfg['Host'];
$mail->Port = $emailcfg['Port'];
$mail->Helo = $emailcfg['Helo'];
$mail->SMTPAuth = $emailcfg['SMTPAuth'];
$mail->SMTPSecure = $emailcfg['SMTPSecure'];
$mail->Username = $emailcfg['Username'];
$mail->Password = $emailcfg['Password'];
$mail->Timeout = $emailcfg['Timeout'];
$mail->SMTPDebug = $emailcfg['SMTPDebug'];
$mail->PluginDir = $emailcfg['PluginDir'];
$mail->Sender = $emailcfg['Sender'];
$mail->From = $emailcfg['From'];
$mail->FromName = $emailcfg['FromName'];
if ($emailcfg['Reply']) {
$mail->AddReplyTo($emailcfg['Reply'], $emailcfg['ReplyName']);
}
$mail->CharSet = $l['a_meta_charset'];
if (!$mail->CharSet) {
$mail->CharSet = $emailcfg['CharSet'];
}
$mail->Subject = $l['t_result_user'];
$mail->IsHTML(TRUE);
// Set message type to HTML.
$email_num = 0;
// count emails;
if ($user_id == 0) {
// for each user on selected test
$sql = 'SELECT user_id, user_name, user_email, user_firstname, user_lastname, testuser_creation_time
FROM ' . K_TABLE_TEST_USER . ', ' . K_TABLE_USERS . '
WHERE testuser_user_id=user_id
AND testuser_test_id=' . $test_id . '
AND testuser_status>0';
if ($group_id > 0) {
$sql .= ' AND testuser_user_id IN (SELECT usrgrp_user_id FROM ' . K_TABLE_USERGROUP . ' WHERE usrgrp_group_id=' . $group_id . ')';
}
} else {
// select only one test of one user
$sql = 'SELECT user_id, user_name, user_email, user_firstname, user_lastname, testuser_creation_time
FROM ' . K_TABLE_TEST_USER . ', ' . K_TABLE_USERS . '
WHERE testuser_user_id=user_id
AND testuser_user_id=' . $user_id . '
AND testuser_test_id=' . $test_id . '
AND testuser_status>0
LIMIT 1';
}
// get test data
$testdata = F_getTestData($test_id);
if ($r = F_db_query($sql, $db)) {
while ($m = F_db_fetch_array($r)) {
if (strlen($m['user_email']) > 3) {
// get user's test stats
$usrtestdata = F_getUserTestStat($test_id, $m['user_id']);
// set HTML header
$mail->Body = $emailcfg['MsgHeader'];
// compose alternate TEXT message
$mail->AltBody = '' . $l['t_result_user'] . ' [' . $m['testuser_creation_time'] . ']' . K_NEWLINE;
$mail->AltBody .= $l['w_test'] . ': ' . $testdata['test_name'] . K_NEWLINE;
$passmsg = '';
if ($testdata['test_score_threshold'] > 0) {
//.........这里部分代码省略.........
示例12: F_TSVQuestionImporter
/**
* Import questions from TSV file (tab delimited text).
* The format of TSV is the same obtained by exporting data from TCExam interface.
* @param $tsvfile (string) TSV (tab delimited text) file name
* @return boolean TRUE in case of success, FALSE otherwise
*/
function F_TSVQuestionImporter($tsvfile)
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_auth_sql.php';
$qtype = array('S' => 1, 'M' => 2, 'T' => 3, 'O' => 4);
// get file content as array
$tsvrows = file($tsvfile, FILE_IGNORE_NEW_LINES);
// array of TSV lines
if ($tsvrows === FALSE) {
return FALSE;
}
$current_module_id = 0;
$current_subject_id = 0;
$current_question_id = 0;
$current_answer_id = 0;
$questionhash = array();
// for each row
while (list($item, $rowdata) = each($tsvrows)) {
// get user data into array
$qdata = explode("\t", $rowdata);
switch ($qdata[0]) {
case 'M':
// MODULE
$current_module_id = 0;
if (!isset($qdata[2]) or empty($qdata[2])) {
break;
}
$module_enabled = intval($qdata[1]);
$module_name = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
// check if this module already exist
$sql = 'SELECT module_id
FROM ' . K_TABLE_MODULES . '
WHERE module_name=\'' . $module_name . '\'
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
// get existing module ID
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['module_id'], 'module_user_id')) {
// unauthorized user
$current_module_id = 0;
} else {
$current_module_id = $m['module_id'];
}
} else {
// insert new module
$sql = 'INSERT INTO ' . K_TABLE_MODULES . ' (
module_name,
module_enabled,
module_user_id
) VALUES (
\'' . $module_name . '\',
\'' . $module_enabled . '\',
\'' . $_SESSION['session_user_id'] . '\'
)';
if (!($r = F_db_query($sql, $db))) {
F_display_db_error();
} else {
// get new module ID
$current_module_id = F_db_insert_id($db, K_TABLE_MODULES, 'module_id');
}
}
} else {
F_display_db_error();
}
break;
case 'S':
// SUBJECT
$current_subject_id = 0;
if ($current_module_id == 0) {
return;
}
if (!isset($qdata[2]) or empty($qdata[2])) {
break;
}
$subject_enabled = intval($qdata[1]);
$subject_name = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
$subject_description = '';
if (isset($qdata[3])) {
$subject_description = F_empty_to_null(F_tsv_to_text($qdata[3]));
}
// check if this subject already exist
$sql = 'SELECT subject_id
FROM ' . K_TABLE_SUBJECTS . '
WHERE subject_name=\'' . $subject_name . '\'
AND subject_module_id=' . $current_module_id . '
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
// get existing subject ID
$current_subject_id = $m['subject_id'];
} else {
// insert new subject
$sql = 'INSERT INTO ' . K_TABLE_SUBJECTS . ' (
//.........这里部分代码省略.........
示例13: F_send_report_emails
/**
* Sends email test reports to users.
* @author Nicola Asuni
* @since 2005-02-24
* @param $test_id (int) TEST ID
* @param $user_id (int) USER ID (0 means all users)
* @param $testuser_id (int) test-user ID - if greater than zero, filter stats for the specified test-user.
* @param $group_id (int) GROUP ID (0 means all groups)
* @param $startdate (int) start date ID - if greater than zero, filter stats for the specified starting date
* @param $enddate (int) end date ID - if greater than zero, filter stats for the specified ending date
* @param $mode (int) type of report to send: 0=detailed report; 1=summary report (without questions)
* @param $display_mode display (int) mode: 0 = disabled; 1 = minimum; 2 = module; 3 = subject; 4 = question; 5 = answer.
* @param $show_graph (boolean) If true display the score graph.
*/
function F_send_report_emails($test_id, $user_id = 0, $testuser_id = 0, $group_id = 0, $startdate = 0, $enddate = 0, $mode = 0, $display_mode = 1, $show_graph = false)
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_test.php';
require_once '../../shared/code/tce_functions_test_stats.php';
require_once '../../shared/code/tce_class_mailer.php';
require_once 'tce_functions_user_select.php';
$mode = intval($mode);
if ($test_id > 0) {
$test_id = intval($test_id);
if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
return;
}
} else {
$test_id = 0;
}
if ($user_id > 0) {
$user_id = intval($user_id);
} else {
$user_id = 0;
}
if ($testuser_id > 0) {
$testuser_id = intval($testuser_id);
} else {
$testuser_id = 0;
}
if ($group_id > 0) {
$group_id = intval($group_id);
} else {
$group_id = 0;
}
if (!empty($startdate)) {
$startdate_time = strtotime($startdate);
$startdate = date(K_TIMESTAMP_FORMAT, $startdate_time);
} else {
$startdate = '';
}
if (!empty($enddate)) {
$enddate_time = strtotime($enddate);
$enddate = date(K_TIMESTAMP_FORMAT, $enddate_time);
} else {
$enddate = '';
}
// Instantiate C_mailer class
$mail = new C_mailer();
//Load default values
$mail->language = $l;
$mail->Priority = $emailcfg['Priority'];
$mail->ContentType = $emailcfg['ContentType'];
$mail->Encoding = $emailcfg['Encoding'];
$mail->WordWrap = $emailcfg['WordWrap'];
$mail->Mailer = $emailcfg['Mailer'];
$mail->Sendmail = $emailcfg['Sendmail'];
$mail->UseMSMailHeaders = $emailcfg['UseMSMailHeaders'];
$mail->Host = $emailcfg['Host'];
$mail->Port = $emailcfg['Port'];
$mail->Helo = $emailcfg['Helo'];
$mail->SMTPAuth = $emailcfg['SMTPAuth'];
$mail->SMTPSecure = $emailcfg['SMTPSecure'];
$mail->Username = $emailcfg['Username'];
$mail->Password = $emailcfg['Password'];
$mail->Timeout = $emailcfg['Timeout'];
$mail->SMTPDebug = $emailcfg['SMTPDebug'];
$mail->PluginDir = $emailcfg['PluginDir'];
$mail->Sender = $emailcfg['Sender'];
$mail->From = $emailcfg['From'];
$mail->FromName = $emailcfg['FromName'];
if ($emailcfg['Reply']) {
$mail->AddReplyTo($emailcfg['Reply'], $emailcfg['ReplyName']);
}
$mail->CharSet = $l['a_meta_charset'];
if (!$mail->CharSet) {
$mail->CharSet = $emailcfg['CharSet'];
}
$mail->Subject = $l['t_result_user'];
$mail->IsHTML(TRUE);
// Set message type to HTML.
$email_num = 0;
// count emails;
// get all data
$data = F_getAllUsersTestStat($test_id, $group_id, $user_id, $startdate, $enddate, 'total_score', false, $display_mode);
foreach ($data['testuser'] as $tu) {
if (strlen($tu['user_email']) > 3) {
// set HTML header
$mail->Body = $emailcfg['MsgHeader'];
//.........这里部分代码省略.........