本文整理汇总了PHP中get_field_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_field_sql函数的具体用法?PHP get_field_sql怎么用?PHP get_field_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_field_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forgotpass_validate
function forgotpass_validate(Pieform $form, $values)
{
// See if the user input an email address or a username. We favour email addresses
if (!$form->get_error('emailusername')) {
// Check if the user who associates to username or email address is using the external authentication
if (record_exists_sql('SELECT u.authinstance
FROM {usr} u INNER JOIN {auth_instance} ai ON (u.authinstance = ai.id)
WHERE (LOWER(u.email) = ? OR LOWER(u.username) = ?)
AND ((ai.authname != \'internal\') AND (ai.authname != \'none\'))', array_fill(0, 2, strtolower($values['emailusername'])))) {
$form->set_error('emailusername', get_string('forgotpassuserusingexternalauthentication', 'mahara', get_config('wwwroot') . 'contact.php'));
} else {
if (!($authinstance = get_field_sql('SELECT u.authinstance
FROM {usr} u INNER JOIN {auth_instance} ai ON (u.authinstance = ai.id)
WHERE (LOWER(u.email) = ? OR LOWER(u.username) = ?)
AND ai.authname = \'internal\'', array_fill(0, 2, strtolower($values['emailusername']))))) {
$form->set_error('emailusername', get_string('forgotpassnosuchemailaddressorusername'));
}
}
}
if ($form->get_error('emailusername')) {
return;
}
$authobj = AuthFactory::create($authinstance);
if (!method_exists($authobj, 'change_password')) {
die_info(get_string('cantchangepassword'));
}
}
示例2: postinst
/**
* Called post install and after every upgrade to the artefact.
* @param string $prevversion the previously installed version of this artefact.
*/
public static function postinst($prevversion)
{
if ($prevversion == 0) {
// Since this is the first time, we need to
// create the default settings and the static
// table data for aretfact_annotation_deletedby.
set_config_plugin('artefact', 'annotation', 'commenteditabletime', 10);
foreach (ArtefactTypeAnnotationfeedback::deleted_by_types() as $index => $type) {
insert_record('artefact_annotation_deletedby', (object) array('id' => (int) $index + 1, 'name' => $type));
}
// If elasticsearch is installed, update the artefacttypesmap field to include
// annotation and annotationfeedback.
$sql = "SELECT value FROM {search_config} WHERE plugin='elasticsearch' AND field='artefacttypesmap'";
if ($result = get_field_sql($sql, array())) {
$elasticsearchartefacttypesmap = explode("\n", $result);
// add annotation and annotationfeedback fields.
$elasticsearchartefacttypesmap[] = "annotation|Annotation|Text";
$elasticsearchartefacttypesmap[] = "annotationfeedback|Annotation|Text";
// Now save the data including the new annotation fields.
set_config_plugin('search', 'elasticsearch', 'artefacttypesmap', implode("\n", $elasticsearchartefacttypesmap));
}
// Now install the blocktype annotation only if Mahara was previously installed.
// Otherwise, the Mahara installer will install everything.
if (get_config('installed')) {
if ($upgrade = check_upgrades('blocktype.annotation/annotation')) {
upgrade_plugin($upgrade);
}
}
}
}
示例3: memorization_print_new_verse_box
function memorization_print_new_verse_box()
{
global $CFG, $USER;
print_box_start('add-verse-box generalbox box');
print_heading(get_string('newverse', 'memorization'));
$biblebooks = biblebooks_array();
// create the book selector
$biblebookoptions = '';
foreach ($biblebooks as $booknumber => $bookofbible) {
if ($booknumber == 0) {
continue;
}
$biblebookoptions .= '<option value="' . $booknumber . '">' . $bookofbible . '</option>';
}
$startbookid = '<select name="startbookid">' . $biblebookoptions . '</select>';
$endbookid = '<select name="endbookid">' . $biblebookoptions . '</select>';
// create the chapter inputs
$startchapter = '<input type="text" name="startchapter" size="5" />';
$endchapter = '<input type="text" name="endchapter" size="5"/>';
// create the verse inputs
$startverse = '<input type="text" name="startverse" size="5"/>';
$endverse = '<input type="text" name="endverse" size="5"/>';
// create the version chooser
$versions = get_records('memorization_version');
if (!empty($versions)) {
$versionselect = '<select name="versionid">';
$lastversionid = get_field_sql("SELECT versionid FROM {$CFG->prefix}memorization_verse WHERE userid={$USER->id} ORDER BY id DESC");
foreach ($versions as $versionid => $version) {
$selected = $versionid == $lastversionid ? ' SELECTED="selected" ' : '';
$versionselect .= '<option ' . $selected . ' value="' . $versionid . '">' . $version->value . '</option>';
}
$versionselect .= '</select>';
}
$currenturl = new moodle_url(qualified_me());
echo '<form method="POST" action="addverse.php?' . $currenturl->get_query_string() . '">
<input type="hidden" name="sesskey" value="' . sesskey() . '">
<table>
<tr>
<td>' . get_string('fromverse', 'memorization') . '</td>
<td>' . $startbookid . ' ' . $startchapter . ':' . $startverse . '</td>
</tr>
<tr>
<td>' . get_string('toverse', 'memorization') . '</td>
<td>' . $endbookid . ' ' . $endchapter . ':' . $endverse . '</td>
</tr>
<tr>
<td>' . get_string('version', 'memorization') . '</td>
<td>' . $versionselect . '</td>
</tr>
</table>
<input type="submit">
</form>';
print_box_end();
}
示例4: getvalue
/**
*
*
*/
function getvalue($issueid)
{
global $CFG;
if (!$issueid) {
return '';
}
$sql = "\n SELECT \n elementitemid\n FROM\n {$CFG->prefix}tracker_issueattribute\n WHERE\n elementid = {$this->id} AND\n issueid = {$issueid}\n ";
$this->value = get_field_sql($sql);
return $this->value;
}
示例5: create_session_and_responses
function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
{
// Find out how many datasets are available
global $CFG;
if (!($maxnumber = (int) get_field_sql("SELECT MIN(a.itemcount)\n FROM {$CFG->prefix}question_dataset_definitions a,\n {$CFG->prefix}question_datasets b\n WHERE b.question = {$question->id}\n AND a.id = b.datasetdefinition"))) {
error("Couldn't get the specified dataset for a calculated " . "question! (question: {$question->id}");
}
// Choose a random dataset
$state->options->datasetitem = rand(1, $maxnumber);
$state->options->dataset = $this->pick_question_dataset($question, $state->options->datasetitem);
$state->responses = array('' => '');
return true;
}
示例6: jeliot_user_outline
/**
* Return a small object with summary information about what a
* user has done with a given particular instance of this module
* Used for user activity reports.
* $return->time = the time they did it
* $return->info = a short text description
*
* @return null
* @todo Finish documenting this function
**/
function jeliot_user_outline($course, $user, $mod, $jeliot)
{
global $CFG;
$no_of_times_taken = count_records('jeliot_accesses', 'userid', $user->id, 'jeliotid', $jeliot->id);
if ($no_of_times_taken > 0) {
$sql = 'SELECT MAX(accesses.timemodified) as lastime FROM ' . $CFG->prefix . 'jeliot_accesses AS accesses ' . ' WHERE accesses.jeliotid = ' . $jeliot->id . ' AND accesses.userid = ' . $user->id;
$lasttime = get_field_sql($sql);
$return->time = $lasttime;
$return->info = get_string('visualized_n_times', 'jeliot', $no_of_times_taken);
} else {
$return->time = time();
$return->info = get_string('not_visualized', 'jeliot');
}
return $return;
}
示例7: forgotpass_validate
function forgotpass_validate(Pieform $form, $values)
{
// See if the user input an email address or a username. We favour email addresses
if (!$form->get_error('emailusername')) {
if (!($authinstance = get_field_sql('SELECT authinstance FROM {usr} WHERE LOWER(email) = ?', array(strtolower($values['emailusername']))))) {
if (!($authinstance = get_field_sql('SELECT authinstance FROM {usr} WHERE LOWER(username) = ?', array(strtolower($values['emailusername']))))) {
$form->set_error('emailusername', get_string('forgotpassnosuchemailaddressorusername'));
}
}
}
if ($form->get_error('emailusername')) {
return;
}
$authobj = AuthFactory::create($authinstance);
if (!method_exists($authobj, 'change_password')) {
die_info(get_string('cantchangepassword'));
}
}
示例8: prevent_double_paid
function prevent_double_paid($course)
{
global $CFG, $SESSION, $USER;
$sql = "SELECT id FROM {$CFG->prefix}enrol_authorize WHERE userid = '{$USER->id}' AND courseid = '{$course->id}' ";
if (empty($CFG->an_test)) {
// Real mode
$sql .= 'AND status IN(' . AN_STATUS_AUTH . ',' . AN_STATUS_UNDERREVIEW . ',' . AN_STATUS_APPROVEDREVIEW . ')';
} else {
// Test mode
$sql .= 'AND status=' . AN_STATUS_NONE;
}
if ($recid = get_field_sql($sql)) {
$a = new stdClass();
$a->orderid = $recid;
$a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$a->orderid}";
redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
return;
}
if (isset($SESSION->ccpaid)) {
unset($SESSION->ccpaid);
redirect($CFG->wwwroot . '/login/logout.php?sesskey=' . sesskey());
return;
}
}
示例9: report_stats_timeoptions
function report_stats_timeoptions($mode)
{
global $CFG;
$tableprefix = $CFG->prefix . 'stats_';
if ($mode == STATS_MODE_DETAILED) {
$tableprefix = $CFG->prefix . 'stats_user_';
}
$earliestday = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'daily ORDER BY timeend');
$earliestweek = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'weekly ORDER BY timeend');
$earliestmonth = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'monthly ORDER BY timeend');
if (empty($earliestday)) {
$earliestday = time();
}
if (empty($earliestweek)) {
$earliestweek = time();
}
if (empty($earliestmonth)) {
$earliestmonth = time();
}
$now = stats_get_base_daily();
$lastweekend = stats_get_base_weekly();
$lastmonthend = stats_get_base_monthly();
return stats_get_time_options($now, $lastweekend, $lastmonthend, $earliestday, $earliestweek, $earliestmonth);
}
示例10: require_login
$finishattempt = 1;
}
require_login($course->id, false, $cm);
$coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course);
// course context
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$ispreviewing = has_capability('mod/quiz:preview', $context);
// if no questions have been set up yet redirect to edit.php
if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id);
}
if (!$ispreviewing) {
require_capability('mod/quiz:attempt', $context);
}
/// Get number for the next or unfinished attempt
if (!($attemptnumber = (int) get_field_sql('SELECT MAX(attempt)+1 FROM ' . "{$CFG->prefix}quiz_attempts WHERE quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1"))) {
$attemptnumber = 1;
}
$strattemptnum = get_string('attempt', 'quiz', $attemptnumber);
$strquizzes = get_string("modulenameplural", "quiz");
$popup = $quiz->popup && !$ispreviewing;
// Controls whether this is shown in a javascript-protected window or with a safe browser.
/// We intentionally do not check open and close times here. Instead we do it lower down.
/// This is to deal with what happens when someone submits close to the exact moment when the quiz closes.
/// Check number of attempts
$numberofpreviousattempts = count_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1");
if (!empty($quiz->attempts) and $numberofpreviousattempts >= $quiz->attempts) {
print_error('nomoreattempts', 'quiz', "view.php?id={$cm->id}");
}
/// Check safe browser
if (!$ispreviewing && $quiz->popup == 2 && !quiz_check_safe_browser()) {
示例11: xmldb_core_upgrade
//.........这里部分代码省略.........
drop_table($table);
$table = new XMLDBTable('artefact_feedback');
drop_table($table);
// Add site setting for anonymous comments
set_config('anonymouscomments', 1);
}
if ($oldversion < 2010041900 && !table_exists(new XMLDBTable('site_data'))) {
// Upgrades for admin stats pages
// Table for collection of historical stats
$table = new XMLDBTable('site_data');
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, XMLDB_NOTNULL);
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('ctime', 'type'));
create_table($table);
// Insert cron jobs to save site data
$cron = new StdClass();
$cron->callfunction = 'cron_site_data_weekly';
$cron->minute = 55;
$cron->hour = 23;
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = 6;
insert_record('cron', $cron);
$cron = new StdClass();
$cron->callfunction = 'cron_site_data_daily';
$cron->minute = 51;
$cron->hour = 23;
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
// Put best guess at installation time into config table.
set_config('installation_time', get_field_sql("SELECT MIN(ctime) FROM {site_content}"));
// Save the current time so we know when we started collecting stats
set_config('stats_installation_time', db_format_timestamp(time()));
// Add ctime to usr table for daily count of users created
$table = new XMLDBTable('usr');
$field = new XMLDBField('ctime');
$field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
add_field($table, $field);
// Add visits column to view table
$table = new XMLDBTable('view');
$field = new XMLDBField('visits');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
// Add table to store daily view visits
$table = new XMLDBTable('view_visit');
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addIndexInfo('ctimeix', XMLDB_INDEX_NOTUNIQUE, array('ctime'));
create_table($table);
// Insert a cron job to check for new versions of Mahara
$cron = new StdClass();
$cron->callfunction = 'cron_check_for_updates';
$cron->minute = rand(0, 59);
$cron->hour = rand(0, 23);
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
if ($oldversion < 2010042600) {
// @todo: Move to notification/internal
$table = new XMLDBTable('notification_internal_activity');
示例12: get_profile_field
/**
* Return the value of a profile field for a given user
*
* @param integer user id to find the profile field for
* @param field what profile field you want the value for
* @returns string the value of the profile field (null if it doesn't exist)
*
* @todo, this needs to be better (fix email behaviour)
*/
function get_profile_field($userid, $field)
{
if ($field == 'email') {
$value = get_field_sql("\n SELECT a.title\n FROM {usr} u\n JOIN {artefact} a ON (a.title = u.email AND a.owner = u.id)\n WHERE a.artefacttype = 'email' AND u.id = ?", array($userid));
} else {
$value = get_field('artefact', 'title', 'owner', $userid, 'artefacttype', $field);
}
if ($value) {
return $value;
}
return null;
}
示例13: groups_print_course_menu
}
echo '<td class="left">';
groups_print_course_menu($course, $baseurl);
echo '</td>';
if (!isset($hiddenfields['lastaccess'])) {
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
// we need to make it diferently for normal courses and site course
if ($context->id != $frontpagectx->id) {
$minlastaccess = get_field_sql('SELECT min(timeaccess)
FROM ' . $CFG->prefix . 'user_lastaccess
WHERE courseid = ' . $course->id . '
AND timeaccess != 0');
$lastaccess0exists = record_exists('user_lastaccess', 'courseid', $course->id, 'timeaccess', 0);
} else {
$minlastaccess = get_field_sql('SELECT min(lastaccess)
FROM ' . $CFG->prefix . 'user
WHERE lastaccess != 0');
$lastaccess0exists = record_exists('user', 'lastaccess', 0);
}
$now = usergetmidnight(time());
$timeaccess = array();
// makes sense for this to go first.
$timeoptions[0] = get_string('selectperiod');
// days
for ($i = 1; $i < 7; $i++) {
if (strtotime('-' . $i . ' days', $now) >= $minlastaccess) {
$timeoptions[strtotime('-' . $i . ' days', $now)] = get_string('numdays', 'moodle', $i);
}
}
// weeks
for ($i = 1; $i < 10; $i++) {
示例14: time
$now = $fake ? time() - ($realstart - $start) : time();
}
}
}
// and now the core ones (much simpler)
$now = $fake ? time() - ($realstart - $start) : time();
$jobs = get_records_select_array('cron', 'nextrun < ? OR nextrun IS NULL', array(db_format_timestamp($now)), '', 'id,callfunction,minute,hour,day,month,dayofweek,' . db_format_tsfield('nextrun'));
if ($jobs) {
foreach ($jobs as $job) {
if (!cron_lock($job, $start)) {
continue;
}
// If some other cron instance ran the job while we were messing around,
// skip it.
$nextrun = get_field_sql('
SELECT ' . db_format_tsfield('nextrun') . '
FROM {cron}
WHERE id = ?', array($job->id));
if ($nextrun != $job->nextrun) {
log_info("Too late to run core {$job->callfunction}; skipping.");
cron_free($job, $start);
continue;
}
log_info("Running core cron " . $job->callfunction);
$function = $job->callfunction;
try {
$function();
} catch (Exception $e) {
log_message($e->getMessage(), LOG_LEVEL_WARN, true, true, $e->getFile(), $e->getLine(), $e->getTrace());
$output = $e instanceof MaharaException ? $e->render_exception() : $e->getMessage();
echo "{$output}\n";
// Don't call handle_exception; try to update next run time and free the lock
示例15: feedback_get_page_to_continue
/**
* this returns the position where the user can continue the completing.
* @param int $feedbackid
* @param int $courseid
* @param string $guestid this id will be saved temporary and is unique
* @return int the position to continue
*/
function feedback_get_page_to_continue($feedbackid, $courseid = false, $guestid)
{
global $CFG, $USER;
//is there any break?
if (!($allbreaks = feedback_get_all_break_positions($feedbackid))) {
return false;
}
if ($courseid) {
$courseselect = "fv.course_id = " . $courseid;
} else {
$courseselect = "1";
}
if ($guestid) {
$userselect = "AND fc.guestid = '" . $guestid . "'";
$usergroup = "GROUP BY fc.guestid";
} else {
$userselect = "AND fc.userid = " . $USER->id;
$usergroup = "GROUP BY fc.userid";
}
$sql = "SELECT MAX(fi.position)\n FROM " . $CFG->prefix . "feedback_completedtmp AS fc, " . $CFG->prefix . "feedback_valuetmp AS fv, " . $CFG->prefix . "feedback_item AS fi\n WHERE fc.id = fv.completed\n " . $userselect . "\n AND fc.feedback = " . $feedbackid . "\n AND " . $courseselect . "\n AND fi.id = fv.item\n " . $usergroup;
$lastpos = get_field_sql($sql);
//the index of found pagebreak is the searched pagenumber
foreach ($allbreaks as $pagenr => $br) {
if ($lastpos < $br) {
return $pagenr;
}
}
return count($allbreaks);
}