本文整理汇总了PHP中get_record_select函数的典型用法代码示例。如果您正苦于以下问题:PHP get_record_select函数的具体用法?PHP get_record_select怎么用?PHP get_record_select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_record_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: game_cryptex_check
function game_cryptex_check($id, $game, $attempt, $cryptexrec, $q, $answer)
{
if ($attempt === false) {
game_cryptex_continue($id, $game, $attempt, $cryptexrec);
return;
}
$crossm = get_record_select('game_cross', "id={$attempt->id}");
$query = get_record_select('game_queries', "id={$q}");
$answer1 = trim(game_upper($query->answertext));
$answer2 = trim(game_upper($answer));
$textlib = textlib_get_instance();
$len1 = $textlib->strlen($answer1);
$len2 = $textlib->strlen($answer2);
$equal = $len1 == $len2;
if ($equal) {
for ($i = 0; $i < $len1; $i++) {
if ($textlib->substr($answer1, $i, 1) != $textlib->substr($answer2, $i, 1)) {
$equal = true;
break;
}
}
}
if ($equal == false) {
game_update_queries($game, $attempt, $query, 0, $answer2);
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true);
return;
}
game_update_queries($game, $attempt, $query, 1, $answer2);
game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, true);
}
示例2: get_instance_title
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi)
{
$configdata = $bi->get('configdata');
if (!empty($configdata['collection'])) {
require_once 'collection.php';
$data = get_record_select('collection', 'id = ?', array($configdata['collection']));
$collection = new Collection($configdata['collection'], (array) $data);
$title = $collection->get('name');
return $title;
}
return '';
}
示例3: wikibook_page_content
function wikibook_page_content($pagename)
{
global $WS;
$select = "dfwiki = {$WS->dfwiki->id} AND pagename = '{$pagename}' " . "AND groupid = {$WS->groupmember->groupid}";
if ($WS->dfwiki->studentmode != '0' || $WS->cm->groupmode == '0') {
$select .= " AND ownerid = {$WS->member->id}";
}
if ($version = get_field_select('wiki_pages', 'MAX(version)', $select)) {
if ($record = get_record_select('wiki_pages', $select . " AND version = {$version}")) {
return $record->content;
}
}
}
示例4: tracker_rpc_check
/**
* checks an user has local identity and comes from a known host
* @param string $username the user's login
* @param string $remotehostroot the host he comes from
* @return a failure report if unchecked, null elsewhere.
*
*/
function tracker_rpc_check($username, $remotehostroot, &$localuser)
{
// get local identity for user
if (!($remotehost = get_record('mnet_host', 'wwwroot', $remotehostroot))) {
$response->status = RPC_FAILURE;
$response->error = "Calling host is not registered. Check MNET configuration";
return json_encode($response);
}
if (!($localuser = get_record_select('user', "username = '" . addslashes($username) . "' AND mnethostid = {$remotehost->id} AND deleted = 0"))) {
$response->status = RPC_FAILURE_USER;
$response->error = "Calling user has no local account. Register remote user first";
return json_encode($response);
}
return null;
}
示例5: ondeleteattempt
function ondeleteattempt($cm, $return, $attemptid, $update, $sesskey)
{
global $CFG;
$attempt = get_record_select('game_attempts', 'id=' . $attemptid);
$game = get_record_select('game', 'id=' . $attempt->gameid);
switch ($game->gamekind) {
case 'bookquiz':
delete_records('game_bookquiz_chapters', 'attemptid', $attemptid);
break;
}
delete_records('game_queries', 'attemptid', $attemptid);
delete_records('game_attempts', 'id', $attemptid);
$url = $CFG->wwwroot . "/course/mod.php?update={$update}";
$url .= "&return=true";
$url .= "&sesskey={$sesskey}";
redirect($url);
}
示例6: notrude_form
/**
* Returns a form to mark a view as unobjectionable,
* if the user is allowed to do that.
*
* @returns array Form elements.
*/
function notrude_form()
{
global $USER, $view, $artefact;
$owner = $view->get('owner');
if (!($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)) || $view->get('group') && $USER->get('admin') || $view->get('group') && group_user_access($view->get('group'), $USER->get('id')) == 'admin')) {
return;
}
if ($artefact) {
$params = array('artefact', $artefact->get('id'));
} else {
$params = array('view', $view->get('id'));
}
$isrude = get_record_select('objectionable', 'objecttype = ? AND objectid = ? AND resolvedby IS NULL LIMIT 1', $params);
if (!$isrude) {
return;
}
return array('name' => 'notrude_form', 'class' => 'form-inline', 'method' => 'post', 'elements' => array('objection' => array('type' => 'hidden', 'value' => $isrude->id), 'text' => array('type' => 'html', 'class' => 'pbm', 'value' => get_string('viewobjectionableunmark', 'view')), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-default', 'value' => '<span class="icon icon-lg icon-times text-danger prs"></span> ' . get_string('notobjectionable'))));
}
示例7: notrude_form
/**
* Returns a form to mark a view as unobjectionable,
* if the user is allowed to do that.
*
* @returns array Form elements.
*/
function notrude_form()
{
global $USER, $view, $artefact;
$owner = $view->get('owner');
if (!($owner && ($USER->get('admin') || $USER->is_admin_for_user($owner)) || $view->get('group') && $USER->get('admin'))) {
return;
}
if ($artefact) {
$params = array('artefact', $artefact->get('id'));
} else {
$params = array('view', $view->get('id'));
}
$isrude = get_record_select('objectionable', 'objecttype = ? AND objectid = ? AND resolvedby IS NULL LIMIT 1', $params);
if (!$isrude) {
return;
}
return array('name' => 'notrude_form', 'method' => 'post', 'elements' => array('objection' => array('type' => 'hidden', 'value' => $isrude->id), 'text' => array('type' => 'html', 'value' => get_string('viewobjectionableunmark', 'view')), 'submit' => array('type' => 'submit', 'value' => get_string('notobjectionable'))));
}
示例8: print_classhour_delete_form
function print_classhour_delete_form($courseid, $sesskey, $timetableid, $validhour, $i, $group, $weekend)
{
$selectclause = "starthour='" . $validhour->starthour . "' AND endhour='" . $validhour->endhour . "' AND weekday='" . $i . "' AND groupid = " . $group->id . "";
$c = get_record_select('timetable_hourtable', $selectclause);
// or die(mysql_error());
$classroom = get_record('timetable_classroom', 'id', $c->classroomid);
global $USER;
echo '<form action = "../controller/ttcontroller.php?viewrequired=editinghourtable" method = "POST">';
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" >';
echo '<input type="hidden" name="courseid" value="' . $courseid . '" >';
echo '<input type="hidden" name="timetableid" value="' . $timetableid . '" >';
echo '<input type="hidden" name="groupid" value="' . $group->id . '" >';
echo '<input type="hidden" name="actionparam" value="action" >';
echo '<input type="hidden" name="actiontype" value="edithourtable" >';
echo '<input type="hidden" name="actionedithourtable" value="delete" >';
echo '<input type="hidden" name="starthour" value="' . $validhour->starthour . '" >';
echo '<input type="hidden" name="endhour" value="' . $validhour->endhour . '" >';
echo '<input type="hidden" name="weekday" value="' . $i . '" >';
echo '<input type="hidden" name="classroomid" value="' . $c->classroomid . '" >';
echo '<FONT';
if ($classroom->capacity < $group->studentsnumber || $weekend) {
$title = '';
if ($weekend) {
$title = $title . get_string('classhouraddedinweekendday', 'block_timetable');
}
if ($classroom->capacity < $group->studentsnumber) {
if ($title != '') {
$title = $title . ' and ';
}
$title = $title . get_string('expectedstudentsnumberlessthancapacity', 'block_timetable');
}
echo ' COLOR="BLUE" title="' . $title . '">';
} else {
echo '>';
}
echo '<font size="-2">' . $classroom->name . '</font><BR>';
echo '</FONT>';
echo '<input type="image" name="boton" src="../icons/action_stop.gif" width="16" height="16" title="' . get_string('deleteclassroom', 'block_timetable') . '" >';
echo '</form>';
}
示例9: mnet_generate_keypair
/**
* Generate public/private keys and store in the config table
*
* Use the distinguished name provided to create a CSR, and then sign that CSR
* with the same credentials. Store the keypair you create in the config table.
* If a distinguished name is not provided, create one using the fullname of
* 'the course with ID 1' as your organization name, and your hostname (as
* detailed in $CFG->wwwroot).
*
* @param array $dn The distinguished name of the server
* @return string The signature over that text
*/
function mnet_generate_keypair($dn = null, $days = 28)
{
global $CFG, $USER;
// check if lifetime has been overriden
if (!empty($CFG->mnetkeylifetime)) {
$days = $CFG->mnetkeylifetime;
}
$host = strtolower($CFG->wwwroot);
$host = ereg_replace("^http(s)?://", '', $host);
$break = strpos($host . '/', '/');
$host = substr($host, 0, $break);
if ($result = get_record_select('course', " id ='" . SITEID . "' ")) {
$organization = $result->fullname;
} else {
$organization = 'None';
}
$keypair = array();
$country = 'NZ';
$province = 'Wellington';
$locality = 'Wellington';
$email = $CFG->noreplyaddress;
if (!empty($USER->country)) {
$country = $USER->country;
}
if (!empty($USER->city)) {
$province = $USER->city;
$locality = $USER->city;
}
if (!empty($USER->email)) {
$email = $USER->email;
}
if (is_null($dn)) {
$dn = array("countryName" => $country, "stateOrProvinceName" => $province, "localityName" => $locality, "organizationName" => $organization, "organizationalUnitName" => 'Moodle', "commonName" => $CFG->wwwroot, "emailAddress" => $email);
}
$dnlimits = array('countryName' => 2, 'stateOrProvinceName' => 128, 'localityName' => 128, 'organizationName' => 64, 'organizationalUnitName' => 64, 'commonName' => 64, 'emailAddress' => 128);
foreach ($dnlimits as $key => $length) {
$dn[$key] = substr($dn[$key], 0, $length);
}
// ensure we remove trailing slashes
$dn["commonName"] = preg_replace(':/$:', '', $dn["commonName"]);
if (!empty($CFG->opensslcnf)) {
//allow specification of openssl.cnf especially for Windows installs
$new_key = openssl_pkey_new(array("config" => $CFG->opensslcnf));
$csr_rsc = openssl_csr_new($dn, $new_key, array("config" => $CFG->opensslcnf));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, array("config" => $CFG->opensslcnf));
} else {
$new_key = openssl_pkey_new();
$csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits', 2048));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days);
}
unset($csr_rsc);
// Free up the resource
// We export our self-signed certificate to a string.
openssl_x509_export($selfSignedCert, $keypair['certificate']);
openssl_x509_free($selfSignedCert);
// Export your public/private key pair as a PEM encoded string. You
// can protect it with an optional passphrase if you wish.
if (!empty($CFG->opensslcnf)) {
//allow specification of openssl.cnf especially for Windows installs
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM'], null, array("config" => $CFG->opensslcnf));
} else {
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM']);
}
openssl_pkey_free($new_key);
unset($new_key);
// Free up the resource
return $keypair;
}
示例10: update_user_record
/**
* will update a local user record from an external source.
* is a lighter version of the one in moodlelib -- won't do
* expensive ops such as enrolment
*
* If you don't pass $updatekeys, there is a performance hit and
* values removed from DB won't be removed from moodle.
*
* @param string $username username (with system magic quotes)
*/
function update_user_record($username, $updatekeys = false)
{
global $CFG;
//just in case check text case
$username = trim(moodle_strtolower($username));
// get the current user record
$user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id);
if (empty($user)) {
// trouble
error_log("Cannot update non-existent user: {$username}");
print_error('auth_dbusernotexist', 'auth', $username);
die;
}
// Ensure userid is not overwritten
$userid = $user->id;
if ($newinfo = $this->get_userinfo($username)) {
$newinfo = truncate_userinfo($newinfo);
if (empty($updatekeys)) {
// all keys? this does not support removing values
$updatekeys = array_keys($newinfo);
}
foreach ($updatekeys as $key) {
if (isset($newinfo[$key])) {
$value = $newinfo[$key];
} else {
$value = '';
}
if (!empty($this->config->{'field_updatelocal_' . $key})) {
if ($user->{$key} != $value) {
// only update if it's changed
set_field('user', $key, addslashes($value), 'id', $userid);
}
}
}
}
return get_record_select('user', "id = {$userid} AND deleted = 0");
}
示例11: print_box_end
<?php
print_box_end();
print_footer('empty');
exit;
}
}
}
if (!empty($quiz->delay1) or !empty($quiz->delay2)) {
//quiz enforced time delay
if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {
$numattempts = count($attempts);
} else {
$numattempts = 0;
}
$timenow = time();
$lastattempt_obj = get_record_select('quiz_attempts', "quiz = {$quiz->id} AND attempt = {$numattempts} AND userid = {$USER->id}", 'timefinish, timestart');
if ($lastattempt_obj) {
$lastattempt = $lastattempt_obj->timefinish;
if ($quiz->timelimit > 0) {
$lastattempt = min($lastattempt, $lastattempt_obj->timestart + $quiz->timelimit * 60);
}
}
if ($numattempts == 1 && !empty($quiz->delay1)) {
if ($timenow - $quiz->delay1 < $lastattempt) {
print_error('timedelay', 'quiz', 'view.php?q=' . $quiz->id);
}
} else {
if ($numattempts > 1 && !empty($quiz->delay2)) {
if ($timenow - $quiz->delay2 < $lastattempt) {
print_error('timedelay', 'quiz', 'view.php?q=' . $quiz->id);
}
示例12: get_friend_request
/**
* has there been a request between these two users?
*
* @param int $userid1
* @param int $userid2
*/
function get_friend_request($userid1, $userid2)
{
return get_record_select('usr_friend_request', '("owner" = ? AND requester = ?) OR (requester = ? AND "owner" = ?)', array($userid1, $userid2, $userid1, $userid2));
}
示例13: restore_create_events
function restore_create_events($restore, $xml_file)
{
global $CFG, $db;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//events will contain the old_id of every event
//in backup_ids->info will be the real info (serialized)
$events = restore_read_xml_events($restore, $xml_file);
}
//Get admin->id for later use
$admin = get_admin();
$adminid = $admin->id;
//Now, if we have anything in events, we have to restore that
//events
if ($events) {
if ($events !== true) {
//Iterate over each event
foreach ($events as $event) {
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, "event", $event->id);
//Init variables
$create_event = false;
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Events', $restore, $info['EVENT']['#'], array('TIMESTART'));
}
//Now build the EVENT record structure
$eve->name = backup_todb($info['EVENT']['#']['NAME']['0']['#']);
$eve->description = backup_todb($info['EVENT']['#']['DESCRIPTION']['0']['#']);
$eve->format = backup_todb($info['EVENT']['#']['FORMAT']['0']['#']);
$eve->courseid = $restore->course_id;
$eve->groupid = backup_todb($info['EVENT']['#']['GROUPID']['0']['#']);
$eve->userid = backup_todb($info['EVENT']['#']['USERID']['0']['#']);
$eve->repeatid = backup_todb($info['EVENT']['#']['REPEATID']['0']['#']);
$eve->modulename = "";
if (!empty($info['EVENT']['#']['MODULENAME'])) {
$eve->modulename = backup_todb($info['EVENT']['#']['MODULENAME']['0']['#']);
}
$eve->instance = 0;
$eve->eventtype = backup_todb($info['EVENT']['#']['EVENTTYPE']['0']['#']);
$eve->timestart = backup_todb($info['EVENT']['#']['TIMESTART']['0']['#']);
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
$eve->visible = backup_todb($info['EVENT']['#']['VISIBLE']['0']['#']);
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
//Now search if that event exists (by name, description, timestart fields) in
//restore->course_id course
//Going to compare LOB columns so, use the cross-db sql_compare_text() in both sides.
$compare_description_clause = sql_compare_text('description') . "=" . sql_compare_text("'" . $eve->description . "'");
$eve_db = get_record_select("event", "courseid={$eve->courseid} AND name='{$eve->name}' AND {$compare_description_clause} AND timestart={$eve->timestart}");
//If it doesn't exist, create
if (!$eve_db) {
$create_event = true;
}
//If we must create the event
if ($create_event) {
//We must recode the userid
$user = backup_getid($restore->backup_unique_code, "user", $eve->userid);
if ($user) {
$eve->userid = $user->new_id;
} else {
//Assign it to admin
$eve->userid = $adminid;
}
//We have to recode the groupid field
$group = backup_getid($restore->backup_unique_code, "groups", $eve->groupid);
if ($group) {
$eve->groupid = $group->new_id;
} else {
//Assign it to group 0
$eve->groupid = 0;
}
//The structure is equal to the db, so insert the event
$newid = insert_record("event", $eve);
//We must recode the repeatid if the event has it
//The repeatid now refers to the id of the original event. (see Bug#5956)
if ($newid && !empty($eve->repeatid)) {
$repeat_rec = backup_getid($restore->backup_unique_code, "event_repeatid", $eve->repeatid);
if ($repeat_rec) {
//Exists, so use it...
$eve->repeatid = $repeat_rec->new_id;
} else {
//Doesn't exists, calculate the next and save it
$oldrepeatid = $eve->repeatid;
$eve->repeatid = $newid;
backup_putid($restore->backup_unique_code, "event_repeatid", $oldrepeatid, $eve->repeatid);
}
$eve->id = $newid;
// update the record to contain the correct repeatid
update_record('event', $eve);
//.........这里部分代码省略.........
示例14: feedback_delete_completed
/**
* deletes a completed given by completedid.
* all related data such values or tracking data also will be deleted
* @param int $completedid
* @return boolean
*/
function feedback_delete_completed($completedid)
{
if (!($completed = get_record('feedback_completed', 'id', $completedid))) {
return false;
}
//first we delete all related values
@delete_records('feedback_value', 'completed', $completed->id);
//now we delete all tracking data
if ($tracking = get_record_select('feedback_tracking', " completed = " . $completed->id . " AND feedback = " . $completed->feedback . " ")) {
@delete_records('feedback_tracking', 'completed', $completed->id);
}
//last we delete the completed-record
return delete_records('feedback_completed', 'id', $completed->id);
}
示例15: moodle_process_email
function moodle_process_email($modargs, $body)
{
// the first char should be an unencoded letter. We'll take this as an action
switch ($modargs[0]) {
case 'B':
// bounce
list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8)));
if ($user = get_record_select("user", "id={$userid}", "id,email")) {
// check the half md5 of their email
$md5check = substr(md5($user->email), 0, 16);
if ($md5check == substr($modargs, -16)) {
set_bounce_count($user);
}
// else maybe they've already changed it?
}
break;
// maybe more later?
}
}