Commit 250cf34d authored by Nigel McNie's avatar Nigel McNie Committed by Penny Leach

Change to how table names are specified in SQL queries.

Now, table names (and other identifiers that could be confused with SQL kewords), should be put into SQL like this:

SELECT * FROM {artefact}

The braces are matched and expanded by DML now to include the prefix and be properly quoted, which means that tables like 'view' and 'group' don't need renaming (and nor should they, there's little reason why we should rename tables to get around such constraints).

This has removed a whole bunch of $prefix = ... and get_config('dbprefix') stuff, which makes things a little simpler yet again.
parent 7f278a16
......@@ -59,7 +59,6 @@ $limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$userid = $USER->get('id');
$prefix = get_config('dbprefix');
if ($type == 'all') {
$count = count_records('notification_internal_activity', 'usr', $userid);
......@@ -67,10 +66,10 @@ if ($type == 'all') {
'ctime DESC', '*', $offset, $limit);
} else if ($type == 'adminmessages' && $USER->get('admin')) {
$count = count_records_select('notification_internal_activity', 'usr = ? AND type IN (
SELECT name FROM ' . $prefix . 'activity_type WHERE admin = ?)',
SELECT name FROM {activity_type} WHERE admin = ?)',
array($userid, 1));
$records = get_records_select_array('notification_internal_activity', 'usr = ? AND type IN (
SELECT name FROM ' . $prefix . 'activity_type WHERE admin = ?)',
SELECT name FROM {activity_type} WHERE admin = ?)',
array($userid, 1),
'ctime DESC', '*', $offset, $limit);
}
......
......@@ -35,7 +35,6 @@ $stopmonitoring = param_integer('stopmonitoring', 0);
$userlist = param_alpha('userlist', null);
$getartefacts = param_integer('getartefacts', 0);
$prefix = get_config('dbprefix');
$userid = $USER->get('id');
if ($stopmonitoring) {
......@@ -68,9 +67,9 @@ if ($stopmonitoring) {
if (!empty($userlist)) {
if ($userlist == 'views') {
$sql = 'SELECT DISTINCT u.*
FROM ' . $prefix . 'usr u
JOIN ' . $prefix . 'view v ON v.owner = u.id
JOIN ' . $prefix . 'usr_watchlist_view w ON w.view = v.id
FROM {usr} u
JOIN {view} v ON v.owner = u.id
JOIN {usr_watchlist_view} w ON w.view = v.id
WHERE w.usr = ?';
if (!$users = get_records_sql_array($sql, array($userid))) {
......@@ -79,9 +78,9 @@ if (!empty($userlist)) {
}
else if ($userlist == 'artefacts') {
$sql = 'SELECT DISTINCT u.*
FROM ' . $prefix . 'usr u
JOIN ' . $prefix . 'artefact a ON a.owner = u.id
JOIN ' . $prefix . 'usr_watchlist_artefact w ON w.artefact = a.id
FROM {usr} u
JOIN {artefact} a ON a.owner = u.id
JOIN {usr_watchlist_artefact} w ON w.artefact = a.id
WHERE w.usr = ?';
if (!$users = get_records_sql_array($sql, array($userid))) {
......@@ -107,7 +106,6 @@ $limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$userid = $USER->get('id');
$prefix = get_config('dbprefix');
$count = 0;
$records = array();
......@@ -115,8 +113,8 @@ $records = array();
if ($type == 'views') {
$count = count_records('usr_watchlist_view', 'usr', $userid);
$sql = 'SELECT v.*, v.title AS name, w.recurse
FROM ' . $prefix . 'view v
JOIN ' . $prefix . 'usr_watchlist_view w ON w.view = v.id
FROM {view} v
JOIN {usr_watchlist_view} w ON w.view = v.id
WHERE w.usr = ?';
$values = array($userid);
if (isset($owner)) {
......@@ -129,18 +127,18 @@ if ($type == 'views') {
}
else if ($type == 'groups') {
$count = count_records('usr_watchlist_group', 'usr', $userid);
$sql = 'SELECT c.*
FROM ' . $prefix . 'group g
JOIN ' . $prefix . 'usr_watchlist_group w ON w.group = g.id
$sql = 'SELECT g.*
FROM {group} g
JOIN {usr_watchlist_group} w ON w.group = g.id
WHERE w.usr = ?
ORDER BY c.mtime DESC';
ORDER BY g.mtime DESC';
$records = get_records_sql_array($sql, array($userid), $offset, $limit);
}
else if ($type == 'artefacts') {
$count = count_records('usr_watchlist_artefact', 'usr', $userid);
$sql = 'SELECT a.* , a.title AS name, w.view, w.recurse
FROM ' . $prefix . 'artefact a
JOIN ' . $prefix . 'usr_watchlist_artefact w ON w.artefact = a.id
FROM {artefact} a
JOIN {usr_watchlist_artefact} w ON w.artefact = a.id
WHERE w.usr = ?';
$values = array($userid);
if (isset($owner)) {
......
......@@ -159,11 +159,10 @@ function statusChange() {
JAVASCRIPT;
$prefix = get_config('dbprefix');
$sql = 'SELECT DISTINCT u.*
FROM ' . $prefix . 'usr u
JOIN ' . $prefix . 'view v ON v.owner = u.id
JOIN ' . $prefix . 'usr_watchlist_view w ON w.view = v.id
FROM {usr} u
JOIN {view} v ON v.owner = u.id
JOIN {usr_watchlist_view} w ON w.view = v.id
WHERE w.usr = ?';
if (!$viewusers = get_records_sql_array($sql, array($USER->get('id')))) {
......
......@@ -35,12 +35,11 @@ $public = (int) param_boolean('public');
$result = array();
//$menuitems = get_records_array('site_menu','public',$public,'displayorder');
$prefix = get_config('dbprefix');
$menuitems = get_records_sql_array('
SELECT
s.*, a.title AS filename
FROM ' . $prefix . 'site_menu s
LEFT OUTER JOIN ' . $prefix . 'artefact a ON s.file = a.id
FROM {site_menu} s
LEFT OUTER JOIN {artefact} a ON s.file = a.id
WHERE
s.public = ' . $public . '
ORDER BY s.displayorder', null);
......
......@@ -65,18 +65,17 @@ $form = array(
function adminusers_submit(Pieform $form, $values) {
global $SESSION;
$table = get_config('dbprefix') . 'usr';
db_begin();
execute_sql('UPDATE ' . $table . '
execute_sql('UPDATE {usr}
SET admin = 0
WHERE admin = 1');
execute_sql('UPDATE ' . $table . '
execute_sql('UPDATE {usr}
SET admin = 1
WHERE id IN (' . join(',', $values['users']) . ')');
execute_sql('DELETE FROM ' . get_config('dbprefix') . 'usr_activity_preference
WHERE activity IN (SELECT name FROM ' . get_config('dbprefix') . 'activity_type
WHERE admin = 1 )
execute_sql('DELETE FROM {usr_activity_preference}
WHERE activity IN (SELECT name FROM {activity_type}
WHERE admin = 1)
AND usr NOT IN (' . join(',', $values['users']) . ')');
db_commit();
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
......
......@@ -225,10 +225,9 @@ if ($institution || $add) {
}
else {
// Get a list of institutions
$prefix = get_config('dbprefix');
$institutions = get_records_sql_array('SELECT i.name, i.displayname, i.registerallowed, COUNT(u.id) AS hasmembers
FROM ' . $prefix . 'institution i
LEFT OUTER JOIN ' . $prefix . 'usr u ON (u.institution = i.name)
FROM {institution} i
LEFT OUTER JOIN {usr} u ON (u.institution = i.name)
GROUP BY 1, 2, 3
ORDER BY i.name', array());
$smarty->assign('institutions', $institutions);
......
......@@ -36,11 +36,9 @@ define('SECTION_PAGE', 'notifications');
require_once('pieforms/pieform.php');
$prefix = get_config('dbprefix');
$sql = 'SELECT u.*, a.activity, a.method
FROM ' . $prefix . 'usr u
LEFT JOIN ' . $prefix . 'usr_activity_preference a ON a.usr = u.id
FROM {usr} u
LEFT JOIN {usr_activity_preference} a ON a.usr = u.id
WHERE u.admin = ?';
$admins = get_records_sql_array($sql, array(1));
......
......@@ -30,7 +30,6 @@ define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$action = param_variable('action');
$dbprefix = get_config('dbprefix');
if ($action == 'suspend') {
$id = param_integer('id');
......
......@@ -61,14 +61,13 @@ $form = array(
function staffusers_submit(Pieform $form, $values) {
global $SESSION;
$table = get_config('dbprefix') . 'usr';
db_begin();
execute_sql('UPDATE ' . $table . '
execute_sql('UPDATE {usr}
SET staff = 0
WHERE staff = 1');
if ($values['users']) {
execute_sql('UPDATE ' . $table . '
execute_sql('UPDATE {usr}
SET staff = 1
WHERE id IN (' . join(',', $values['users']) . ')');
}
......
......@@ -35,16 +35,14 @@ json_headers();
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$dbprefix = get_config('dbprefix');
// NOTE: the check is not done on the 'active' column here, since suspended
// users are by definition not active. However deleted users are filtered out.
$count = get_field_sql('SELECT COUNT(*) FROM ' . $dbprefix . 'usr WHERE suspendedcusr IS NOT NULL AND deleted = 0');
$count = get_field_sql('SELECT COUNT(*) FROM {usr} WHERE suspendedcusr IS NOT NULL AND deleted = 0');
$data = get_records_sql_array('SELECT u.id, u.firstname, u.lastname, u.studentid, u.suspendedreason AS reason,
i.displayname AS institution, ua.firstname AS cusrfirstname, ua.lastname AS cusrlastname
FROM ' . $dbprefix . 'usr u
LEFT JOIN ' . $dbprefix . 'institution i ON (u.institution = i.name)
LEFT JOIN ' . $dbprefix . 'usr ua on (ua.id = u.suspendedcusr)
FROM {usr} u
LEFT JOIN {institution} i ON (u.institution = i.name)
LEFT JOIN {usr} ua on (ua.id = u.suspendedcusr)
WHERE u.suspendedcusr IS NOT NULL
AND u.deleted = 0
ORDER BY u.suspendedctime
......
......@@ -84,8 +84,6 @@ function auth_get_auth_instances() {
return $cache;
}
$dbprefix = get_config('dbprefix');
$sql ='
SELECT DISTINCT
i.id,
......@@ -93,8 +91,8 @@ function auth_get_auth_instances() {
inst.displayname,
i.instancename
FROM
'.$dbprefix.'institution inst,
'.$dbprefix.'auth_instance i
{institution} inst,
{auth_instance} i
WHERE
i.institution = inst.name
ORDER BY
......
......@@ -132,16 +132,15 @@ function fetch_user_image($username) {
throw new XmlrpcServerException('Unknown error');
}
$dbprefix = get_config('dbprefix');
$authinstances = auth_get_auth_instances_for_institution($institution);
$candidates = array();
$sql = 'SElECT
ai.*
FROM
'.$dbprefix.'auth_instance ai,
'.$dbprefix.'auth_instance ai2,
'.$dbprefix.'auth_instance_config aic
{auth_instance} ai,
{auth_instance} ai2,
{auth_instance_config} aic
WHERE
ai.id = ? AND
ai.institution = ? AND
......@@ -274,8 +273,6 @@ function get_service_providers($instance) {
return $cache[$instance];
}
$dbprefix = get_config('dbprefix');
$query = '
SELECT
h.name,
......@@ -283,11 +280,11 @@ function get_service_providers($instance) {
h.wwwroot,
aic.instance
FROM
'.$dbprefix.'auth_instance_config aic,
'.$dbprefix.'auth_instance_config aic2,
'.$dbprefix.'auth_instance_config aic3,
'.$dbprefix.'host h,
'.$dbprefix.'application a
{auth_instance_config} aic,
{auth_instance_config} aic2,
{auth_instance_config} aic3,
{host} h,
{application} a
WHERE
((aic.value = 1 AND
aic.field = \'theyautocreateusers\' ) OR
......
......@@ -339,7 +339,7 @@ class ArtefactTypeBlog extends ArtefactType {
public static function get_blog_list(User $user, $limit = self::pagination, $offset = 0) {
($result = get_records_sql_array("
SELECT id, title, description
FROM " . get_config('dbprefix') . "artefact
FROM {artefact}
WHERE owner = ?
AND artefacttype = 'blog'
ORDER BY title
......@@ -632,11 +632,10 @@ class ArtefactTypeBlogPost extends ArtefactType {
* @param integer
*/
public static function get_posts(User $user, $id, $limit = self::pagination, $offset = 0) {
$prefix = get_config('dbprefix');
($result = get_records_sql_assoc("
SELECT a.id, a.title, a.description, a.ctime, a.mtime, bp.published
FROM " . $prefix . "artefact a
LEFT OUTER JOIN " . $prefix . "artefact_blog_blogpost bp
FROM {artefact} a
LEFT OUTER JOIN {artefact_blog_blogpost} bp
ON a.id = bp.blogpost
WHERE a.parent = ?
AND a.artefacttype = 'blogpost'
......@@ -659,8 +658,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
$files = get_records_sql_array('
SELECT
bf.blogpost, bf.file, a.artefacttype, a.title, a.description
FROM ' . $prefix . 'artefact_blog_blogpost_file bf
INNER JOIN ' . $prefix . 'artefact a ON bf.file = a.id
FROM {artefact_blog_blogpost_file} bf
INNER JOIN {artefact} a ON bf.file = a.id
WHERE bf.blogpost IN (' . $idlist . ')', '');
if ($files) {
foreach ($files as $file) {
......@@ -683,8 +682,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
public static function render_posts($format, $options, $id, $limit = self::pagination, $offset = 0) {
($postids = get_records_sql_array("
SELECT a.id
FROM " . get_config('dbprefix') . "artefact a
LEFT OUTER JOIN " . get_config('dbprefix') . "artefact_blog_blogpost bp
FROM {artefact} a
LEFT OUTER JOIN {artefact_blog_blogpost} bp
ON a.id = bp.blogpost
WHERE a.parent = ?
AND bp.published = 1
......@@ -703,8 +702,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
$count = (int)get_field_sql("
SELECT COUNT(*)
FROM " . get_config('dbprefix') . "artefact a
LEFT OUTER JOIN " . get_config('dbprefix') . "artefact_blog_blogpost bp
FROM {artefact} a
LEFT OUTER JOIN {artefact_blog_blogpost} bp
ON a.id = bp.blogpost
WHERE a.parent = ?
AND bp.published = 1", array($id));
......@@ -857,10 +856,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
* @return array
*/
public function get_attached_files() {
$prefix = get_config('dbprefix');
$list = get_records_sql_array('SELECT a.id, a.artefacttype, a.title, a.description
FROM ' . $prefix . 'artefact_blog_blogpost_file f
INNER JOIN ' . $prefix . 'artefact a ON a.id = f.file
FROM {artefact_blog_blogpost_file} f
INNER JOIN {artefact} a ON a.id = f.file
WHERE f.blogpost = ' . $this->id, '');
// load tags
......
......@@ -38,11 +38,10 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
set_field('artefact_file_files', 'adminfiles', 0);
// Put all folders into artefact_file_files
$prefix = get_config('dbprefix');
$folders = get_column_sql("
SELECT a.id
FROM " . $prefix . "artefact a
LEFT OUTER JOIN " . $prefix . "artefact_file_files f ON a.id = f.artefact
FROM {artefact} a
LEFT OUTER JOIN {artefact_file_files} f ON a.id = f.artefact
WHERE a.artefacttype = 'folder' AND f.artefact IS NULL");
if ($folders) {
foreach ($folders as $folderid) {
......@@ -124,10 +123,9 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
if ($oldversion < 2007042500) {
// migrate everything we had to change to make mysql happy
$prefix = get_config('dbprefix');
execute_sql("ALTER TABLE {$prefix}artefact_file_file_types ALTER COLUMN description TYPE varchar(32)");
execute_sql("ALTER TABLE {$prefix}artefact_file_mime_types ALTER COLUMN mimetype TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}artefact_file_mime_types ALTER COLUMN description TYPE varchar(32)");
execute_sql("ALTER TABLE {artefact_file_file_types} ALTER COLUMN description TYPE varchar(32)");
execute_sql("ALTER TABLE {artefact_file_mime_types} ALTER COLUMN mimetype TYPE varchar(128)");
execute_sql("ALTER TABLE {artefact_file_mime_types} ALTER COLUMN description TYPE varchar(32)");
}
......
......@@ -353,10 +353,9 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
// Check if something exists in the db with a given title and parent,
// either in adminfiles or with a specific owner.
public static function file_exists($title, $owner, $folder, $adminfiles=false) {
$prefix = get_config('dbprefix');
$filetypesql = "('" . join("','", PluginArtefactFile::get_artefact_types()) . "')";
return get_field_sql('SELECT a.id FROM ' . $prefix . 'artefact a
LEFT OUTER JOIN ' . $prefix . 'artefact_file_files f ON f.artefact = a.id
return get_field_sql('SELECT a.id FROM {artefact} a
LEFT OUTER JOIN {artefact_file_files} f ON f.artefact = a.id
WHERE ' . ($adminfiles ? 'f.adminfiles = 1' : 'f.adminfiles <> 1 AND a.owner = ' . $owner) . '
AND a.title = ?
AND a.parent ' . (empty($folder) ? ' IS NULL' : ' = ' . $folder) . '
......@@ -373,8 +372,6 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
public static function get_my_files_data($parentfolderid, $userid, $adminfiles=false) {
$prefix = get_config('dbprefix');
$foldersql = $parentfolderid ? ' = ' . $parentfolderid : ' IS NULL';
// if blogs are installed then also return the number of blog
......@@ -387,11 +384,11 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description,
COUNT(c.id) AS childcount '
. ($bloginstalled ? ', COUNT (b.blogpost) AS attachcount' : '') . '
FROM ' . $prefix . 'artefact a
LEFT OUTER JOIN ' . $prefix . 'artefact_file_files f ON f.artefact = a.id
LEFT OUTER JOIN ' . $prefix . 'artefact c ON c.parent = a.id '
. ($bloginstalled ? ('LEFT OUTER JOIN ' . $prefix .
'artefact_blog_blogpost_file b ON b.file = a.id') : '') . '
FROM {artefact} a
LEFT OUTER JOIN {artefact_file_files} f ON f.artefact = a.id
LEFT OUTER JOIN {artefact} c ON c.parent = a.id '
. ($bloginstalled ? ('LEFT OUTER JOIN
{artefact_blog_blogpost_file} b ON b.file = a.id') : '') . '
WHERE a.parent' . $foldersql . '
AND ' . ($adminfiles ? 'f.adminfiles = 1' : ('f.adminfiles = 0 AND a.owner = ' . $userid)) . '
AND a.artefacttype IN ' . $filetypesql . '
......@@ -567,12 +564,11 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
else {
$foldersql = ' (a.parent = ' . $pubfolder . ' OR a.parent IS NULL) ';
}
$prefix = get_config('dbprefix');
return get_records_sql_array('
SELECT
a.id, a.title, a.parent
FROM ' . $prefix . 'artefact a
INNER JOIN ' . $prefix . 'artefact_file_files f ON f.artefact = a.id
FROM {artefact} a
INNER JOIN {artefact_file_files} f ON f.artefact = a.id
WHERE f.adminfiles = 1
AND ' . $foldersql . "
AND a.artefacttype != 'folder'", null);
......@@ -793,12 +789,11 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
public static function admin_public_folder_id() {
$name = get_string('adminpublicdirname', 'admin');
$prefix = get_config('dbprefix');
$folderid = get_field_sql('
SELECT
a.id
FROM ' . $prefix . 'artefact a
INNER JOIN ' . $prefix . 'artefact_file_files f ON a.id = f.artefact
FROM {artefact} a
INNER JOIN {artefact_file_files} f ON a.id = f.artefact
WHERE a.title = ?
AND a.artefacttype = ?
AND f.adminfiles = 1
......@@ -822,9 +817,8 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
global $USER;
$userid = $USER->id;
}
$prefix = get_config('dbprefix');
$parentclause = $parentfolderid ? 'parent = ' . $parentfolderid : 'parent IS NULL';
return get_record_sql('SELECT * FROM ' . $prefix . 'artefact
return get_record_sql('SELECT * FROM {artefact}
WHERE title = ? AND ' . $parentclause . ' AND owner = ' . $userid . "
AND artefacttype = 'folder'", array($name));
}
......
......@@ -32,9 +32,8 @@ function xmldb_artefact_internal_upgrade($oldversion=0) {
if ($oldversion < 2007042500) {
// migrate everything we had to change to make mysql happy
$prefix = get_config('dbprefix');
execute_sql("ALTER TABLE {$prefix}artefact_internal_profile_email ALTER COLUMN email TYPE varchar(255)");
execute_sql("ALTER TABLE {$prefix}artefact_internal_profile_icon ALTER COLUMN filename TYPE varchar(255)");
execute_sql("ALTER TABLE {artefact_internal_profile_email} ALTER COLUMN email TYPE varchar(255)");
execute_sql("ALTER TABLE {artefact_internal_profile_icon} ALTER COLUMN filename TYPE varchar(255)");
}
......
......@@ -28,10 +28,9 @@ define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$prefix = get_config('dbprefix');
$result = get_records_sql_array('SELECT a.id, a.title, a.note, (u.profileicon = a.id) AS isdefault
FROM ' . $prefix . 'artefact a
LEFT OUTER JOIN ' . $prefix . 'usr u
FROM {artefact} a
LEFT OUTER JOIN {usr} u
ON (u.id = a.owner)
WHERE artefacttype = \'profileicon\'
AND a.owner = ?
......
......@@ -241,10 +241,8 @@ abstract class ArtefactType {
* @return array
*/
public function get_children_metadata_watchlist($userid) {
$prefix = get_config('dbprefix');
$sql = 'SELECT a.* FROM ' . $prefix . 'artefact a
JOIN ' . $prefix . 'usr_watchlist_artefact w ON w.artefact = a.id
$sql = 'SELECT a.* FROM {artefact} a
JOIN {usr_watchlist_artefact} w ON w.artefact = a.id
WHERE w.usr = ? AND a.parent = ?';
return get_records_sql_array($sql, array($userid, $this->id));
......
......@@ -42,14 +42,13 @@ $view = param_integer('view', 0);
$data = array();
$count = 0;
$prefix = get_config('dbprefix');
$othertable = 'artefact_resume_' . $type;
$owner = $USER->get('id');
$sql = 'SELECT ar.*, a.owner
FROM ' . $prefix . 'artefact a
JOIN ' . $prefix . $othertable . ' ar ON ar.artefact = a.id
FROM {artefact} a
JOIN {' . $othertable . '} ar ON ar.artefact = a.id
WHERE a.owner = ? AND a.artefacttype = ?
ORDER BY ' . call_static_method(generate_artefact_class_name($type), 'get_order_field') . ' DESC
LIMIT ' . $limit . ' OFFSET ' . $offset;
......
......@@ -2,8 +2,6 @@
function xmldb_auth_internal_upgrade($oldversion=0) {
if ($oldversion < 2007062900) {
$prefix = get_config('dbprefix');
$auth_instance = new stdClass();
$auth_instance->instancename='internal';
$auth_instance->priority='1';
......
......@@ -394,8 +394,6 @@ function auth_get_auth_instances_for_institution($institution=null) {
return array();
}
$dbprefix = get_config('dbprefix');
if (!isset($cache[$institution])) {
// Get auth instances in order of priority
// DO NOT CHANGE THE SORT ORDER OF THIS RESULT SET
......@@ -411,8 +409,8 @@ function auth_get_auth_instances_for_institution($institution=null) {
a.requires_config,
a.requires_parent
FROM
'.$dbprefix.'auth_instance i,
'.$dbprefix.'auth_installed a
{auth_instance} i,
{auth_installed} a
WHERE
a.name = i.authname AND
i.institution = '. db_quote($institution).'
......@@ -438,8 +436,6 @@ function auth_get_auth_instances_for_institution($institution=null) {
*/
function auth_get_auth_instances_for_wwwroot($wwwroot) {
$dbprefix = get_config('dbprefix');
// TODO: we just need ai.id and ai.authname... rewrite query, or
// just drop this function
$query = " SELECT
......@@ -447,9 +443,9 @@ function auth_get_auth_instances_for_wwwroot($wwwroot) {
aic.*,
i.*
FROM
{$dbprefix}auth_instance ai,
{$dbprefix}auth_instance_config aic,
{$dbprefix}institution i
{auth_instance} ai,
{auth_instance_config} aic,
{institution} i
WHERE
aic.field = 'wwwroot' AND
aic.value = ? AND
......@@ -474,8 +470,6 @@ function auth_get_auth_instances_for_username($institution, $username) {
// DO NOT CHANGE THE SORT ORDER OF THIS RESULT SET
// YEAH EINSTEIN - THAT MEANS YOU!!!
$dbprefix = get_config('dbprefix');
// TODO: work out why this won't accept a placeholder - had to use db_quote
$sql ='
SELECT DISTINCT
......@@ -486,9 +480,9 @@ function auth_get_auth_instances_for_username($institution, $username) {
a.requires_config,
a.requires_parent
FROM
'.$dbprefix.'auth_instance i,
'.$dbprefix.'auth_installed a,
'.$dbprefix.'usr u
{auth_instance} i,
{auth_installed} a,
{usr} u
WHERE
a.name = i.authname AND
i.institution = ? AND
......@@ -521,17 +515,15 @@ function auth_get_available_auth_types($institution=null) {
return array();
}
$dbprefix = get_config('dbprefix');
// TODO: work out why this won't accept a placeholder - had to use db_quote
$sql ='
SELECT DISTINCT
a.name,
a.requires_config
FROM
'.$dbprefix.'auth_installed a
{auth_installed} a
LEFT JOIN
'.$dbprefix.'auth_instance i
{auth_instance} i
ON
a.name = i.authname AND
i.institution = '. db_quote($institution).'
......@@ -1005,8 +997,7 @@ function login_submit(Pieform $form, $values) {