本文整理汇总了PHP中record_exists_select函数的典型用法代码示例。如果您正苦于以下问题:PHP record_exists_select函数的具体用法?PHP record_exists_select怎么用?PHP record_exists_select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了record_exists_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: accountprefs_validate
function accountprefs_validate(Pieform $form, $values)
{
global $USER;
$authobj = AuthFactory::create($USER->authinstance);
if (isset($values['oldpassword'])) {
if ($values['oldpassword'] !== '') {
global $USER, $authtype, $authclass;
if (!$authobj->authenticate_user_account($USER, $values['oldpassword'])) {
$form->set_error('oldpassword', get_string('oldpasswordincorrect', 'account'));
return;
}
password_validate($form, $values, $USER);
} else {
if ($values['password1'] !== '' || $values['password2'] !== '') {
$form->set_error('oldpassword', get_string('mustspecifyoldpassword'));
}
}
}
if ($authobj->authname == 'internal' && $values['username'] != $USER->get('username')) {
if (!AuthInternal::is_username_valid($values['username'])) {
$form->set_error('username', get_string('usernameinvalidform', 'auth.internal'));
}
if (!$form->get_error('username') && record_exists_select('usr', 'LOWER(username) = ?', strtolower($values['username']))) {
$form->set_error('username', get_string('usernamealreadytaken', 'auth.internal'));
}
}
}
示例2: is_question_manual_graded
function is_question_manual_graded($question, $otherquestionsinuse)
{
if (!$this->selectmanual) {
return false;
}
// We take our best shot at working whether a particular question is manually
// graded follows: We look to see if any of the questions that this random
// question might select if of a manually graded type. If a category contains
// a mixture of manual and non-manual questions, and if all the attempts so
// far selected non-manual ones, this will give the wrong answer, but we
// don't care. Even so, this is an expensive calculation!
$this->init_qtype_lists();
if (!$this->manualqtypes) {
return false;
}
if ($question->questiontext) {
$categorylist = question_categorylist($question->category);
} else {
$categorylist = $question->category;
}
return record_exists_select('question', "category IN ({$categorylist})\n AND parent = 0\n AND hidden = 0\n AND id NOT IN ({$otherquestionsinuse})\n AND qtype IN ({$this->manualqtypes})");
}
示例3: check_unique
function check_unique($table, $field, $value, $id)
{
return !record_exists_select($table, "{$field} = '{$value}' AND id <> {$id}");
}
示例4: define
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
$result = get_records_sql_array('SELECT a.id, a.title, a.note, (u.profileicon = a.id) AS isdefault,
COUNT (DISTINCT aa.artefact) AS attachcount, COUNT(DISTINCT va.view) AS viewcount, COUNT(DISTINCT s.id) AS skincount
FROM {artefact} a
LEFT OUTER JOIN {view_artefact} va ON va.artefact = a.id
LEFT OUTER JOIN {artefact_attachment} aa ON aa.attachment = a.id
LEFT OUTER JOIN {skin} s ON (s.bodybgimg = a.id OR s.viewbgimg = a.id)
LEFT OUTER JOIN {usr} u ON (u.id = a.owner)
WHERE artefacttype = \'profileicon\'
AND a.owner = ?
GROUP BY a.id, a.title, a.note, isdefault
ORDER BY a.id', array($USER->get('id')));
$lastrow = array('id' => 0, 'isdefault' => 't', 'title' => get_string('standardavatartitle', 'artefact.file'), 'note' => get_string('standardavatarnote', 'artefact.file'));
$usersdefaulticon = record_exists_select('usr', 'profileicon IS NULL AND id = ?', array($USER->get('id')));
if (!$usersdefaulticon) {
$lastrow['isdefault'] = 'f';
}
if (!$result) {
$result = array();
}
$result[] = $lastrow;
$data['error'] = false;
$data['data'] = $result;
$data['count'] = $result ? count($result) : 0;
json_reply(false, $data);
示例5: user_exists
/**
* Given a username, returns whether the user exists in the usr table
*
* @param string $username The username to attempt to identify
* @return bool Whether the username exists
*/
public function user_exists($username)
{
$this->must_be_ready();
if (record_exists_select('usr', 'LOWER(username) = ?', array(strtolower($username)))) {
return true;
}
throw new AuthUnknownUserException("\"{$username}\" is not known to Auth");
}
示例6: adduser_validate
function adduser_validate(Pieform $form, $values)
{
global $USER, $TRANSPORTER;
$authobj = AuthFactory::create($values['authinstance']);
$institution = $authobj->institution;
// Institutional admins can only set their own institutions' authinstances
if (!$USER->get('admin') && !$USER->is_institutional_admin($authobj->institution)) {
$form->set_error('authinstance', get_string('notadminforinstitution', 'admin'));
return;
}
$institution = new Institution($authobj->institution);
// Don't exceed max user accounts for the institution
if ($institution->isFull()) {
$institution->send_admin_institution_is_full_message();
$form->set_error('authinstance', get_string('institutionmaxusersexceeded', 'admin'));
return;
}
$username = $values['username'];
$firstname = sanitize_firstname($values['firstname']);
$lastname = sanitize_lastname($values['lastname']);
$email = sanitize_email($values['email']);
$password = $values['password'];
if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
$maxquotaenabled = get_config_plugin('artefact', 'file', 'maxquotaenabled');
$maxquota = get_config_plugin('artefact', 'file', 'maxquota');
if ($maxquotaenabled && $values['quota'] > $maxquota) {
$form->set_error('quota', get_string('maxquotaexceededform', 'artefact.file', display_size($maxquota)));
}
}
if (method_exists($authobj, 'is_username_valid_admin')) {
if (!$authobj->is_username_valid_admin($username)) {
$form->set_error('username', get_string('usernameinvalidadminform', 'auth.internal'));
}
} else {
if (method_exists($authobj, 'is_username_valid')) {
if (!$authobj->is_username_valid($username)) {
$form->set_error('username', get_string('usernameinvalidform', 'auth.internal'));
}
}
}
if (!$form->get_error('username') && record_exists_select('usr', 'LOWER(username) = ?', array(strtolower($username)))) {
$form->set_error('username', get_string('usernamealreadytaken', 'auth.internal'));
}
if (method_exists($authobj, 'is_password_valid') && !$authobj->is_password_valid($password)) {
$form->set_error('password', get_string('passwordinvalidform', 'auth.' . $authobj->type));
}
if (isset($_POST['createmethod']) && $_POST['createmethod'] == 'leap2a') {
$form->set_error('firstname', null);
$form->set_error('lastname', null);
$form->set_error('email', null);
if (!$values['leap2afile'] && ($_FILES['leap2afile']['error'] == UPLOAD_ERR_INI_SIZE || $_FILES['leap2afile']['error'] == UPLOAD_ERR_FORM_SIZE)) {
$form->reply(PIEFORM_ERR, array('message' => get_string('uploadedfiletoobig'), 'goto' => '/admin/users/add.php'));
$form->set_error('leap2afile', get_string('uploadedfiletoobig'));
return;
} else {
if (!$values['leap2afile']) {
$form->set_error('leap2afile', $form->i18n('rule', 'required', 'required'));
return;
}
}
if ($values['leap2afile']['type'] == 'application/octet-stream') {
require_once 'file.php';
$mimetype = file_mime_type($values['leap2afile']['tmp_name']);
} else {
$mimetype = trim($values['leap2afile']['type'], '"');
}
$date = time();
$niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $values['username']);
safe_require('import', 'leap');
$fakeimportrecord = (object) array('data' => array('importfile' => $values['leap2afile']['tmp_name'], 'importfilename' => $values['leap2afile']['name'], 'importid' => $niceuser . '-' . $date, 'mimetype' => $mimetype));
$TRANSPORTER = new LocalImporterTransport($fakeimportrecord);
try {
$TRANSPORTER->extract_file();
PluginImportLeap::validate_transported_data($TRANSPORTER);
} catch (Exception $e) {
$form->set_error('leap2afile', $e->getMessage());
}
} else {
if (!$form->get_error('firstname') && empty($firstname)) {
$form->set_error('firstname', $form->i18n('rule', 'required', 'required'));
}
if (!$form->get_error('lastname') && empty($lastname)) {
$form->set_error('lastname', $form->i18n('rule', 'required', 'required'));
}
if (!$form->get_error('email')) {
if (!$form->get_error('email') && empty($email)) {
$form->set_error('email', get_string('invalidemailaddress', 'artefact.internal'));
}
if (record_exists('usr', 'email', $email) || record_exists('artefact_internal_profile_email', 'email', $email)) {
$form->set_error('email', get_string('emailalreadytaken', 'auth.internal'));
}
}
}
}
示例7: is_friend
/**
* is there a friend relationship between these two users?
*
* @param int $userid1
* @param int $userid2
*/
function is_friend($userid1, $userid2)
{
return record_exists_select('usr_friend', '(usr1 = ? AND usr2 = ?) OR (usr2 = ? AND usr1 = ?)', array($userid1, $userid2, $userid1, $userid2));
}
示例8: add_owner_institution_access
public function add_owner_institution_access($instnames = array())
{
if (!$this->id) {
return false;
}
$institutions = empty($instnames) ? array_keys(load_user_institutions($this->owner)) : $instnames;
if (!empty($institutions)) {
db_begin();
foreach ($institutions as $i) {
$exists = record_exists_select('view_access', 'view = ? AND institution = ? AND startdate IS NULL AND stopdate IS NULL', array($this->id, $i));
if (!$exists) {
$vaccess = new stdClass();
$vaccess->view = $this->id;
$vaccess->institution = $i;
$vaccess->startdate = null;
$vaccess->stopdate = null;
$vaccess->allowcomments = 0;
$vaccess->approvecomments = 1;
$vaccess->ctime = db_format_timestamp(time());
insert_record('view_access', $vaccess);
}
}
db_commit();
}
return true;
}
示例9: user_exists
/**
* Given a username, returns whether the user exists in the usr table
*
* @param string $username The username to attempt to identify
* @return bool Whether the username exists
*/
public function user_exists($username)
{
$this->must_be_ready();
$userrecord = false;
// The user is likely to be associated with the parent instance
if (is_numeric($this->config['parent']) && $this->config['parent'] > 0) {
$_instanceid = $this->config['parent'];
$userrecord = record_exists_select('usr', 'LOWER(username) = ? and authinstance = ?', array(strtolower($username), $_instanceid));
}
if (empty($userrecord)) {
$_instanceid = $this->instanceid;
$userrecord = record_exists_select('usr', 'LOWER(username) = ? and authinstance = ?', array(strtolower($username), $_instanceid));
}
if ($userrecord != false) {
return $userrecord;
}
throw new AuthUnknownUserException("\"{$username}\" is not known to Auth");
}
示例10: site_statistics
function site_statistics($full = false)
{
$data = array();
if ($full) {
$data = site_data_current();
$data['weekly'] = true;
if (is_postgres()) {
$weekago = "CURRENT_DATE - INTERVAL '1 week'";
$thisweeksql = "(lastaccess > {$weekago})::int";
$todaysql = '(lastaccess > CURRENT_DATE)::int';
$eversql = "(NOT lastaccess IS NULL)::int";
} else {
$weekago = 'CURRENT_DATE - INTERVAL 1 WEEK';
$thisweeksql = "lastaccess > {$weekago}";
$todaysql = 'lastaccess > CURRENT_DATE';
$eversql = "NOT lastaccess IS NULL";
}
$sql = "SELECT SUM({$todaysql}) AS today, SUM({$thisweeksql}) AS thisweek, {$weekago} AS weekago, SUM({$eversql}) AS ever FROM {usr}";
$active = get_record_sql($sql);
$data['usersloggedin'] = get_string('loggedinsince', 'admin', $active->today, $active->thisweek, format_date(strtotime($active->weekago), 'strftimedateshort'), $active->ever);
$memberships = count_records_sql("\n SELECT COUNT(*)\n FROM {group_member} m JOIN {group} g ON g.id = m.group\n WHERE g.deleted = 0\n ");
$data['groupmemberaverage'] = round($memberships / $data['users'], 1);
$data['strgroupmemberaverage'] = get_string('groupmemberaverage', 'admin', $data['groupmemberaverage']);
$data['viewsperuser'] = get_field_sql("\n SELECT (0.0 + COUNT(id)) / NULLIF(COUNT(DISTINCT \"owner\"), 0)\n FROM {view}\n WHERE NOT \"owner\" IS NULL AND \"owner\" > 0\n ");
$data['viewsperuser'] = round($data['viewsperuser'], 1);
$data['strviewsperuser'] = get_string('viewsperuser', 'admin', $data['viewsperuser']);
}
$data['name'] = get_config('sitename');
$data['release'] = get_config('release');
$data['version'] = get_config('version');
$data['installdate'] = format_date(strtotime(get_config('installation_time')), 'strftimedate');
$data['dbsize'] = db_total_size();
$data['diskusage'] = get_field('site_data', 'value', 'type', 'disk-usage');
$data['cronrunning'] = !record_exists_select('cron', 'nextrun IS NULL OR nextrun < CURRENT_DATE');
$data['siteclosedbyadmin'] = get_config('siteclosedbyadmin');
if ($latestversion = get_config('latest_version')) {
$data['latest_version'] = $latestversion;
if ($data['release'] == $latestversion) {
$data['strlatestversion'] = get_string('uptodate', 'admin');
} else {
$download_page = 'https://launchpad.net/mahara/+download';
$data['strlatestversion'] = get_string('latestversionis', 'admin', $download_page, $latestversion);
}
}
return $data;
}
示例11: elseif
} elseif (intval($days2expire) < 0) {
print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $navigation, '', '', true, "<div class=\"langmenu\">{$langmenu}</div>");
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
print_footer();
exit;
}
}
reset_login_count();
redirect($urltogo);
exit;
} else {
if (empty($errormsg)) {
$errormsg = get_string("invalidlogin");
$errorcode = 3;
}
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict' && is_enabled_auth('mnet') && record_exists_sql("SELECT h.id FROM {$CFG->prefix}mnet_host h\n INNER JOIN {$CFG->prefix}mnet_host2service m ON h.id=m.hostid\n INNER JOIN {$CFG->prefix}mnet_service s ON s.id=m.serviceid\n WHERE s.name='sso_sp' AND h.deleted=0 AND m.publish = 1") && record_exists_select('user', "username = '{$frm->username}' AND mnethostid != {$CFG->mnet_localhost_id}")) {
$errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u={$frm->username}");
}
}
}
}
/// Detect problems with timedout sessions
if ($session_has_timed_out and !data_submitted()) {
$errormsg = get_string('sessionerroruser', 'error');
$errorcode = 4;
}
/// First, let's remember where the user was trying to get to before they got here
if (empty($SESSION->wantsurl)) {
$SESSION->wantsurl = array_key_exists('HTTP_REFERER', $_SERVER) && $_SERVER["HTTP_REFERER"] != $CFG->wwwroot && $_SERVER["HTTP_REFERER"] != $CFG->wwwroot . '/' && $_SERVER["HTTP_REFERER"] != $CFG->httpswwwroot . '/login/' && $_SERVER["HTTP_REFERER"] != $CFG->httpswwwroot . '/login/index.php' ? $_SERVER["HTTP_REFERER"] : NULL;
}
/// Redirect to alternative login URL if needed
示例12: view_has_token
/**
* Determine whether a view is accessible by a given token
*/
function view_has_token($view, $token)
{
if (!$view || !$token) {
return false;
}
return record_exists_select('view_access', 'view = ? AND token = ? AND visible = ?
AND (startdate IS NULL OR startdate < current_timestamp)
AND (stopdate IS NULL OR stopdate > current_timestamp)', array($view, $token, (int) $visible));
}
示例13: cluster_groups_add_member
/**
* Adds a user to a group if appropriate
* Note: does not check permissions
*
* @param int $groupid The id of the appropriate group
* @param int $userid The id of the user to add
*/
function cluster_groups_add_member($groupid, $userid)
{
if ($group_record = get_record('groups', 'id', $groupid)) {
//this works even for the site-level "course"
$context = get_context_instance(CONTEXT_COURSE, $group_record->courseid);
$filter = get_related_contexts_string($context);
//if the user doesn't have an appropriate role, a group assignment
//will not work, so avoid assigning in that case
$select = "userid = {$userid} and contextid {$filter}";
if (!record_exists_select('role_assignments', $select)) {
return;
}
groups_add_member($groupid, $userid);
}
}
示例14: read_submitted_permissions
public function read_submitted_permissions()
{
$this->errors = array();
// Role name.
$name = optional_param('name', null, PARAM_MULTILANG);
if (!is_null($name)) {
$this->role->name = $name;
if (html_is_blank($this->role->name)) {
$this->errors['name'] = get_string('errorbadrolename', 'role');
}
}
if (record_exists_select('role', "name = '" . addslashes($this->role->name) . "' AND id != {$this->roleid}")) {
$this->errors['name'] = get_string('errorexistsrolename', 'role');
}
// Role short name. We clean this in a special way. We want to end up
// with only lowercase safe ASCII characters.
$shortname = optional_param('shortname', null, PARAM_RAW);
if (!is_null($shortname)) {
$this->role->shortname = $shortname;
$this->role->shortname = textlib_get_instance()->specialtoascii($this->role->shortname);
$this->role->shortname = moodle_strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
if (empty($this->role->shortname)) {
$this->errors['shortname'] = get_string('errorbadroleshortname', 'role');
}
}
if (record_exists_select('role', "shortname = '" . addslashes($this->role->shortname) . "' AND id != {$this->roleid}")) {
$this->errors['shortname'] = get_string('errorexistsroleshortname', 'role');
}
// Description.
$description = optional_param('description', null, PARAM_CLEAN);
if (!is_null($description)) {
$this->role->description = $description;
}
// Legacy type.
$legacytype = optional_param('legacytype', null, PARAM_RAW);
if (!is_null($legacytype)) {
if (array_key_exists($legacytype, $this->legacyroles)) {
$this->role->legacytype = $legacytype;
} else {
$this->role->legacytype = '';
}
}
// Assignable context levels.
foreach ($this->allcontextlevels as $cl => $notused) {
$assignable = optional_param('contextlevel' . $cl, null, PARAM_BOOL);
if (!is_null($assignable)) {
if ($assignable) {
$this->contextlevels[$cl] = $cl;
} else {
unset($this->contextlevels[$cl]);
}
}
}
// Now read the permissions for each capability.
parent::read_submitted_permissions();
}
示例15: quiz_has_feedback
/**
* @param integer $quizid the id of the quiz object.
* @return boolean Whether this quiz has any non-blank feedback text.
*/
function quiz_has_feedback($quizid)
{
static $cache = array();
if (!array_key_exists($quizid, $cache)) {
$cache[$quizid] = record_exists_select('quiz_feedback', "quizid = {$quizid} AND feedbacktext <> ''");
}
return $cache[$quizid];
}