Commit 5295e94a authored by Francois Marier's avatar Francois Marier
parent 14ad7c34
......@@ -417,8 +417,8 @@ function institution_submit(Pieform $form, $values) {
$hostwwwroot = null;
foreach ($authinstances as $ai) {
if ($ai->id == $instanceid && $ai->authname == 'xmlrpc') {
$hostwwwroot = get_field_sql("SELECT value FROM {auth_instance_config} WHERE instance = ? AND field = 'wwwroot'", array($instanceid));
if ($hostwwwroot && count_records_select('auth_instance_config', "field = 'wwwroot' AND value = ?", array($hostwwwroot)) == 1) {
$hostwwwroot = get_field_sql("SELECT \"value\" FROM {auth_instance_config} WHERE \"instance\" = ? AND field = 'wwwroot'", array($instanceid));
if ($hostwwwroot && count_records_select('auth_instance_config', "field = 'wwwroot' AND \"value\" = ?", array($hostwwwroot)) == 1) {
// Unfortunately, it's possible that this host record could belong to a different institution,
// so specify the institution here.
delete_records('host', 'wwwroot', $hostwwwroot, 'institution', $institution);
......
......@@ -55,7 +55,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
WHERE a.artefacttype = \'blogpost\'
AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT owner from {view} WHERE id = ?)
AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
ORDER BY a.ctime DESC
LIMIT 10', array($instance->get('view')))) {
$mostrecent = array();
......
......@@ -289,7 +289,7 @@ class ArtefactTypeBlog extends ArtefactType {
public static function get_blog_list($limit, $offset) {
global $USER;
($result = get_records_sql_array("
SELECT * FROM {artefact} WHERE owner = ? AND artefacttype = 'blog'
SELECT * FROM {artefact} WHERE \"owner\" = ? AND artefacttype = 'blog'
ORDER BY title LIMIT ? OFFSET ?", array($USER->get('id'), $limit, $offset)))
|| ($result = array());
......
......@@ -39,7 +39,7 @@ $id = param_integer('id', null);
if (is_null($id)) {
if (!$records = get_records_select_array(
'artefact',
"artefacttype = 'blog' AND owner = ?",
"artefacttype = 'blog' AND \"owner\" = ?",
array($USER->get('id')),
'id ASC'
)) {
......
......@@ -92,7 +92,7 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
FROM {artefact} a
WHERE artefacttype = \'email\'
AND a.owner = (
SELECT owner
SELECT "owner"
FROM {view}
WHERE id = ?
)
......@@ -151,7 +151,7 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
$artefacttypes = array_diff(PluginArtefactInternal::get_contactinfo_artefact_types(), array('email'));
$artefactids = get_column_sql('
SELECT id FROM {artefact}
WHERE owner = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner')));
WHERE \"owner\" = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner')));
$configdata['artefactids'] = $artefactids;
if (isset($configdata['email'])) {
if ($newemail = get_field('artefact_internal_profile_email', 'artefact', 'principal', 1, 'owner', $view->get('owner'))) {
......
......@@ -129,7 +129,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
FROM {artefact} a
WHERE (artefacttype = \'profileicon\' OR artefacttype = \'email\')
AND a.owner = (
SELECT owner
SELECT "owner"
FROM {view}
WHERE id = ?
)
......@@ -226,7 +226,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
$artefacttypes = array_diff(PluginArtefactInternal::get_artefact_types(), array('email'));
$artefactids = get_column_sql('
SELECT id FROM {artefact}
WHERE owner = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner')));
WHERE \"owner\" = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner')));
$configdata['artefactids'] = $artefactids;
if (isset($configdata['email'])) {
if ($newemail = get_field('artefact_internal_profile_email', 'artefact', 'principal', 1, 'owner', $view->get('owner'))) {
......
......@@ -73,7 +73,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
);
$elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields');
$elementlistlookup = array_flip(array_keys($elementlist));
$profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN ('
$profilefields = get_column_sql('SELECT id FROM {artefact} WHERE \"owner\" = ? AND artefacttype IN ('
. join(",",array_map(create_function('$a','return db_quote($a);'), array_keys($elementlist)))
. ")", array($this->exporter->get('user')->get('id')));
foreach ($profilefields as $id) {
......
......@@ -94,7 +94,7 @@ class LeapExportElementInternal extends LeapExportElement {
if ($icons = get_column_sql("SELECT id
FROM {artefact}
WHERE artefacttype = 'profileicon'
AND owner = ?
AND \"owner\" = ?
ORDER BY id = (
SELECT profileicon FROM {usr} WHERE id = ?
) DESC, id", array($userid, $userid))) {
......
......@@ -158,7 +158,7 @@ class PluginArtefactInternal extends PluginArtefact {
if (!isset($cache[$owner])) {
$cache[$owner] = get_records_sql_assoc("SELECT id, artefacttype, title
FROM {artefact}
WHERE owner = ?
WHERE \"owner\" = ?
AND artefacttype IN (
SELECT name
FROM {artefact_installed_type}
......@@ -226,7 +226,7 @@ class PluginArtefactInternal extends PluginArtefact {
if (!isset($cache[$owner])) {
$cache[$owner] = get_records_sql_assoc("SELECT artefacttype, id
FROM {artefact}
WHERE owner = ?
WHERE \"owner\" = ?
AND artefacttype IN (
SELECT name
FROM {artefact_installed_type}
......
......@@ -1311,7 +1311,7 @@ function artefact_instance_from_type($artefact_type, $user_id=null) {
function artefact_watchlist_notification($artefactids) {
// gets all the views containing this artefact or a parent of this artefact and creates a watchlist activity for each view
if ($views = get_column_sql('SELECT DISTINCT view FROM {view_artefact} WHERE artefact IN (' . implode(',', array_merge(array_keys(artefact_get_parents_for_cache($artefactids)), $artefactids)) . ')')) {
if ($views = get_column_sql('SELECT DISTINCT "view" FROM {view_artefact} WHERE artefact IN (' . implode(',', array_merge(array_keys(artefact_get_parents_for_cache($artefactids)), $artefactids)) . ')')) {
require_once('activity.php');
foreach ($views as $view) {
activity_occurred('watchlist', (object)array('view' => $view));
......
......@@ -109,8 +109,8 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
SELECT id
FROM {artefact}
WHERE artefacttype IN(' . $artefacttypes . ')
AND owner = (
SELECT owner
AND "owner" = (
SELECT "owner"
FROM {view}
WHERE id = ?
)', array($blockinstance->get('view')));
......
......@@ -196,7 +196,7 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
if (!empty($impcfg['artefacttype'])) {
if ($artefactid = get_field_sql("SELECT id
FROM {artefact}
WHERE owner = ?
WHERE \"owner\" = ?
AND artefacttype = ?
AND artefacttype IN (
SELECT name
......
......@@ -46,7 +46,7 @@ class HtmlExportResume extends HtmlExportArtefactPlugin {
if ($artefacts = get_column_sql("SELECT id
FROM {artefact}
WHERE owner = ?
WHERE \"owner\" = ?
AND artefacttype IN
(SELECT name FROM {artefact_installed_type} WHERE plugin = 'resume')",
array($this->exporter->get('user')->get('id')))) {
......
......@@ -169,7 +169,7 @@ class ArtefactTypeResume extends ArtefactType {
parent::commit();
if ($blockinstances = get_records_sql_array('
SELECT id, view, configdata
SELECT id, "view", configdata
FROM {block_instance}
WHERE blocktype = \'entireresume\'
AND "view" IN (
......
......@@ -530,7 +530,7 @@ class User {
$types = array('profile', 'dashboard');
$views = get_records_select_assoc(
'view',
'owner = ? AND type IN (' . join(',', array_map('db_quote', $types)) . ')',
'"owner" = ? AND type IN (' . join(',', array_map('db_quote', $types)) . ')',
array($this->id),
'',
'type,id'
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
// Get viewable views
$views = array();
if ($allviews = get_records_select_array('view', "owner = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
if ($allviews = get_records_select_array('view', "\"owner\" = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
foreach ($allviews as $view) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
......
......@@ -198,7 +198,7 @@ class PluginBlocktypeWall extends SystemBlocktype {
);
insert_record('blocktype_wall_post', $record);
$userid = get_field_sql('SELECT owner FROM {view} WHERE id = (SELECT "view" FROM {block_instance} WHERE id = ?)', array($values['instance']));
$userid = get_field_sql('SELECT "owner" FROM {view} WHERE id = (SELECT "view" FROM {block_instance} WHERE id = ?)', array($values['instance']));
redirect('/user/view.php?id=' . $userid);
}
......
......@@ -85,11 +85,11 @@ function edit_tag_submit(Pieform $form, $values) {
}
db_begin();
execute_sql(
"UPDATE {view_tag} SET tag = ? WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE owner = ?)",
"UPDATE {view_tag} SET tag = ? WHERE tag = ? AND \"view\" IN (SELECT id FROM {view} WHERE \"owner\" = ?)",
array($values['tagname'], $tag, $userid)
);
execute_sql(
"UPDATE {artefact_tag} SET tag = ? WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE owner = ?)",
"UPDATE {artefact_tag} SET tag = ? WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE \"owner\" = ?)",
array($values['tagname'], $tag, $userid)
);
db_commit();
......@@ -104,11 +104,11 @@ function delete_tag_submit(Pieform $form, $values) {
}
db_begin();
execute_sql(
"DELETE FROM {view_tag} WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE owner = ?)",
"DELETE FROM {view_tag} WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE \"owner\" = ?)",
array($tag, $userid)
);
execute_sql(
"DELETE FROM {artefact_tag} WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE owner = ?)",
"DELETE FROM {artefact_tag} WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE \"owner\" = ?)",
array($tag, $userid)
);
db_commit();
......
......@@ -202,11 +202,11 @@ abstract class PluginExport extends Plugin {
if ($artefacts == self::EXPORT_ALL_ARTEFACTS) {
$tmpartefacts = get_column_sql('SELECT id
FROM {artefact}
WHERE owner = ?
WHERE "owner" = ?
UNION
SELECT artefact
FROM {view_artefact}
WHERE "view" IN (SELECT id FROM {view} WHERE owner = ?)
WHERE "view" IN (SELECT id FROM {view} WHERE "owner" = ?)
ORDER BY id', array($userid, $userid));
$this->artefactexportmode = $artefacts;
}
......
......@@ -37,7 +37,7 @@ $group = get_record('group', 'id', $id);
$group->admins = get_column_sql("SELECT member
FROM {group_member}
WHERE \"group\" = ?
AND role = 'admin'", array($group->id));
AND \"role\" = 'admin'", array($group->id));
$filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
......
......@@ -44,10 +44,10 @@ if (!is_logged_in() && !$group->public) {
define('TITLE', $group->name);
$group->ctime = strftime(get_string('strftimedate'), $group->ctime);
$group->admins = get_column_sql("SELECT member
$group->admins = get_column_sql("SELECT \"member\"
FROM {group_member}
WHERE \"group\" = ?
AND role = 'admin'", array($group->id));
AND \"role\" = 'admin'", array($group->id));
$role = group_user_access($group->id);
$group->role = $role;
......
......@@ -422,7 +422,7 @@ function group_remove_user($groupid, $userid=null, $force=false) {
delete_records_sql(
'DELETE FROM {view_access_group}
WHERE "group" = ?
AND view IN (
AND "view" IN (
SELECT v.id
FROM {view} v
WHERE v.owner = ?
......@@ -750,10 +750,10 @@ function group_view_submission_form_submit(Pieform $form, $values) {
* @return array
*/
function group_get_admin_ids($groupid) {
return (array)get_column_sql("SELECT member
return (array)get_column_sql("SELECT \"member\"
FROM {group_member}
WHERE \"group\" = ?
AND role = 'admin'", $groupid);
AND \"role\" = 'admin'", $groupid);
}
/**
......@@ -763,7 +763,7 @@ function group_get_admin_ids($groupid) {
* @return array
*/
function group_get_role_info($groupid) {
$roles = get_records_sql_assoc('SELECT role, edit_views, see_submitted_views, gr.grouptype FROM {grouptype_roles} gr
$roles = get_records_sql_assoc('SELECT "role", edit_views, see_submitted_views, gr.grouptype FROM {grouptype_roles} gr
INNER JOIN {group} g ON g.grouptype = gr.grouptype
WHERE g.id = ?', array($groupid));
foreach ($roles as $role) {
......@@ -796,10 +796,10 @@ function group_prepare_usergroups_for_display($groups, $returnto='mygroups') {
$groupadmins = array();
$groupids = array_map(create_function('$a', 'return $a->id;'), $groups);
if ($groupids) {
$groupadmins = get_records_sql_array('SELECT "group", member
$groupadmins = get_records_sql_array('SELECT "group", "member"
FROM {group_member}
WHERE "group" IN (' . implode(',', db_array_to_ph($groupids)) . ")
AND role = 'admin'", $groupids);
AND \"role\" = 'admin'", $groupids);
if (!$groupadmins) {
$groupadmins = array();
}
......
......@@ -1617,11 +1617,11 @@ function can_view_view($view_id, $user_id=null, $usertoken=null, $mnettoken=null
CASE WHEN accesstype = \'friends\' THEN 4 ELSE 1 END AS typeorder,
' . db_format_tsfield('startdate') . ', ' . db_format_tsfield('stopdate') . '
FROM {view_access}
WHERE view = ?
WHERE "view" = ?
UNION
SELECT \'user\' AS type, 2 AS typeorder, ' . db_format_tsfield('startdate') . ', ' . db_format_tsfield('stopdate') . '
FROM {view_access_usr}
WHERE view = ? AND usr = ?
WHERE "view" = ? AND usr = ?
UNION
SELECT \'group\' AS type, 3 AS typeorder, ' . db_format_tsfield('startdate') . ', ' . db_format_tsfield('stopdate') . '
FROM
......@@ -1658,7 +1658,7 @@ function get_view_from_token($token, $visible=true) {
return false;
}
return get_field_sql('
SELECT view
SELECT "view"
FROM {view_access_token}
WHERE token = ? AND visible = ?
AND (startdate IS NULL OR startdate < current_timestamp)
......@@ -1839,7 +1839,7 @@ function _get_views_trim_list(&$list, &$users, $limit) {
function artefact_in_view($artefact, $view) {
$sql = 'SELECT a.id
FROM {view_artefact} a WHERE view = ? AND artefact = ?
FROM {view_artefact} a WHERE "view" = ? AND artefact = ?
UNION
SELECT c.parent
FROM {view_artefact} top JOIN {artefact_parent_cache} c
......
......@@ -226,9 +226,9 @@ function site_statistics($full=false) {
$data['groupmemberaverage'] = round($memberships/$data['users'], 1);
$data['strgroupmemberaverage'] = get_string('groupmemberaverage', 'admin', $data['groupmemberaverage']);
$data['viewsperuser'] = get_field_sql("
SELECT (0.0 + COUNT(id)) / NULLIF(COUNT(DISTINCT owner), 0)
SELECT (0.0 + COUNT(id)) / NULLIF(COUNT(DISTINCT \"owner\"), 0)
FROM {view}
WHERE NOT owner IS NULL AND owner > 0
WHERE NOT \"owner\" IS NULL AND \"owner\" > 0
");
$data['viewsperuser'] = round($data['viewsperuser'], 1);
$data['strviewsperuser'] = get_string('viewsperuser', 'admin', $data['viewsperuser']);
......@@ -300,7 +300,7 @@ function user_statistics($limit, $offset, &$sitedata) {
$maxviews = get_records_sql_array("
SELECT u.id, u.firstname, u.lastname, u.preferredname, COUNT(v.id) AS views
FROM {usr} u JOIN {view} v ON u.id = v.owner
WHERE owner <> 0
WHERE \"owner\" <> 0
GROUP BY u.id, u.firstname, u.lastname, u.preferredname
ORDER BY views DESC
LIMIT 1", array());
......@@ -410,7 +410,7 @@ function user_stats_table($limit, $offset) {
$day = is_postgres() ? "to_date(ctime::text, 'YYYY-MM-DD')" : 'DATE(ctime)';
$userdata = get_records_sql_array(
"SELECT ctime, type, value, $day AS date
"SELECT ctime, type, \"value\", $day AS date
FROM {site_data}
WHERE type IN (?,?) AND ctime >= ? AND ctime < (date(?) + (INTERVAL $dayinterval))
ORDER BY type = ? DESC, ctime DESC",
......@@ -418,11 +418,11 @@ function user_stats_table($limit, $offset) {
);
$userscreated = get_records_sql_array(
"SELECT $day AS date, COUNT(id) AS users
"SELECT $day AS \"date\", COUNT(id) AS users
FROM {usr}
WHERE NOT ctime IS NULL
GROUP BY date
ORDER BY date",
GROUP BY \"date\"
ORDER BY \"date\"",
array(),
$offset,
$limit
......@@ -765,7 +765,7 @@ function view_stats_table($limit, $offset) {
LEFT JOIN {usr} u ON v.owner = u.id
LEFT JOIN {group} g ON v.group = g.id
LEFT JOIN {institution} i ON v.institution = i.name
WHERE v.owner != 0 OR owner IS NULL
WHERE v.owner != 0 OR \"owner\" IS NULL
ORDER BY v.visits DESC",
array(),
$offset,
......@@ -872,7 +872,7 @@ function graph_site_data_weekly() {
$lastyear = db_format_timestamp(time() - 60*60*12*365);
$values = array($lastyear, 'view-count', 'user-count', 'group-count');
$weekly = get_records_sql_array('
SELECT ctime, type, value, ' . db_format_tsfield('ctime', 'ts') . '
SELECT ctime, type, "value", ' . db_format_tsfield('ctime', 'ts') . '
FROM {site_data}
WHERE ctime >= ? AND type IN (?,?,?)
ORDER BY ctime, type', $values);
......
......@@ -76,7 +76,7 @@ function search_user($query_string, $limit, $offset = 0, $data = array()) {
$results = call_static_method(generate_class_name('search', $plugin), 'search_user', $query_string, $limit, $offset, $data);
if ($results['data']) {
$userlist = '('.join(',', array_map(create_function('$u','return $u[\'id\'];'), $results['data'])).')';
$userlist = '('.join(',', array_map(create_function('$u','return (int)$u[\'id\'];'), $results['data'])).')';
$public_fields = get_records_sql_array('
SELECT
......@@ -366,10 +366,10 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
$results = group_user_search($group, $queries, $constraints, $offset, $limit, $membershiptype);
if ($results['count']) {
$userids = array_map(create_function('$a', 'return $a["id"];'), $results['data']);
$introductions = get_records_sql_assoc("SELECT owner, title
$introductions = get_records_sql_assoc("SELECT \"owner\", title
FROM {artefact}
WHERE artefacttype = 'introduction'
AND owner IN (" . implode(',', db_array_to_ph($userids)) . ')',
AND \"owner\" IN (" . implode(',', db_array_to_ph($userids)) . ')',
$userids);
foreach ($results['data'] as &$result) {
$result['name'] = display_name($result);
......@@ -531,13 +531,13 @@ function search_friend($filter, $limit, $offset) {
}
if (in_array($filter, array('all', 'pending'))) {
$count += count_records_sql('SELECT COUNT(owner) FROM {usr_friend_request}
$count += count_records_sql('SELECT COUNT("owner") FROM {usr_friend_request}
JOIN {usr} u ON (u.id = requester AND u.deleted = 0)
WHERE owner = ?',
WHERE "owner" = ?',
array($userid)
);
array_push($sql, 'SELECT requester AS id, 1 AS status FROM {usr_friend_request} WHERE owner = ?
array_push($sql, 'SELECT requester AS id, 1 AS status FROM {usr_friend_request} WHERE "owner" = ?
');
}
......
......@@ -129,8 +129,8 @@ function change_language($userid, $oldlang, $newlang) {
safe_require('artefact', 'file');
ArtefactTypeFolder::change_language($userid, $oldlang, $newlang);
}
set_field_select('artefact_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE owner = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
set_field_select('view_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE owner = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
set_field_select('artefact_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE "owner" = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
set_field_select('view_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND "view" IN (SELECT id FROM {view} WHERE "owner" = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
}
/**
......@@ -441,7 +441,7 @@ function can_receive_email($userto) {
}
// Retrieve data for this mail address
if (!$mailinfo = get_record_select('artefact_internal_profile_email', 'owner = ? AND email = ?', array($userto->id, $userto->email))) {
if (!$mailinfo = get_record_select('artefact_internal_profile_email', '"owner" = ? AND email = ?', array($userto->id, $userto->email))) {
// Since we don't know who this address belongs to, we must return
// an object. They're not disabled, we just don't know about them.
return new StdClass;
......@@ -540,7 +540,7 @@ function update_send_count($userto, $reset=false) {
// We need a user id to update the send count.
return false;
}
if ($mailinfo = get_record_select('artefact_internal_profile_email', 'owner = ? AND email = ? AND principal = 1', array($userto->id, $userto->email))) {
if ($mailinfo = get_record_select('artefact_internal_profile_email', '"owner" = ? AND email = ? AND principal = 1', array($userto->id, $userto->email))) {
$mailinfo->mailssent = (!empty($reset)) ? 0 : $mailinfo->mailssent+1;
update_record('artefact_internal_profile_email', $mailinfo, array('email' => $userto->email, 'owner' => $userto->id));
}
......@@ -558,7 +558,7 @@ function update_bounce_count($userto, $reset=false) {
// We need a user id to update the bounce count.
return false;
}
if ($mailinfo = get_record_select('artefact_internal_profile_email', 'owner = ? AND email = ? AND principal = 1', array($userto->id, $userto->email))) {
if ($mailinfo = get_record_select('artefact_internal_profile_email', '"owner" = ? AND email = ? AND principal = 1', array($userto->id, $userto->email))) {
$mailinfo->mailsbounced = (!empty($reset)) ? 0 : $mailinfo->mailsbounced+1;
update_record('artefact_internal_profile_email', $mailinfo, array('email' => $userto->email, 'owner' => $userto->id));
}
......@@ -602,7 +602,7 @@ function process_email($address) {
switch ($email->type) {
case 'B': // E-mail bounces
if ($user = get_record_select('artefact_internal_profile_email', 'owner = ? AND principal = 1', array($email->userid))) {
if ($user = get_record_select('artefact_internal_profile_email', '"owner" = ? AND principal = 1', array($email->userid))) {
$mailprefix = get_config('bounceprefix');
$maildomain = get_config('bouncedomain');
$installation_key = get_config('installation_key');
......@@ -887,7 +887,7 @@ function is_friend($userid1, $userid2) {
* @param int $userid2
*/
function get_friend_request($userid1, $userid2) {
return get_record_select('usr_friend_request', '(owner = ? AND requester = ?) OR (requester = ? AND owner = ?)',
return get_record_select('usr_friend_request', '("owner" = ? AND requester = ?) OR (requester = ? AND "owner" = ?)',
array($userid1, $userid2, $userid1, $userid2));
}
......
......@@ -529,19 +529,19 @@ class View {
$data = get_records_sql_array("
SELECT accesstype AS type, NULL AS id, NULL AS role, NULL AS grouptype, startdate, stopdate
FROM {view_access}
WHERE view = ?
WHERE \"view\" = ?
UNION
SELECT 'user' AS type, $uid AS id, NULL AS role, NULL AS grouptype, startdate, stopdate
FROM {view_access_usr}
WHERE view = ?
WHERE \"view\" = ?
UNION
SELECT 'group', $gid, role, grouptype, startdate, stopdate FROM {view_access_group}
SELECT 'group', $gid, \"role\", grouptype, startdate, stopdate FROM {view_access_group}
INNER JOIN {group} g ON (\"group\" = g.id AND g.deleted = ?)
WHERE view = ?
WHERE \"view\" = ?
UNION
SELECT 'token', token, NULL AS role, NULL AS grouptype, startdate, stopdate
FROM {view_access_token}
WHERE view = ? AND visible = 1
WHERE \"view\" = ? AND visible = 1
", array($this->id, $this->id, 0, $this->id, $this->id));
if ($data) {
foreach ($data as &$item) {
......@@ -1227,7 +1227,7 @@ class View {
}
if (call_static_method(generate_class_name('blocktype', $values['blocktype']), 'single_only', $this)) {
$count = count_records_select('block_instance', "view = ? AND blocktype = ?",
$count = count_records_select('block_instance', '"view" = ? AND blocktype = ?',
array($this->id, $values['blocktype']));
if ($count > 0) {
throw new UserException(get_string('onlyoneblocktypeperview', 'error', $values['blocktype']));
......@@ -1900,7 +1900,7 @@ class View {
) ga ON (ga.group = a.group AND a.id = ga.artefact)';
$select = "(a.institution = 'mahara' OR ga.can_view = 1";
if (!empty($data['userartefactsallowed'])) {
$select .= ' OR owner = ' . $user->get('id');
$select .= ' OR "owner" = ' . $user->get('id');
}
$select .= ')';
}
......@@ -1927,7 +1927,7 @@ class View {
) ra ON (a.id = ra.artefact AND a.group = ra.group)';
$institutions = array_keys($user->get('institutions'));
$select = '(
owner = ' . $user->get('id') . '
"owner" = ' . $user->get('id') . '
OR ra.can_republish = 1
OR aau.can_republish = 1';
if ($user->get('admin')) {
......@@ -2042,22 +2042,22 @@ class View {
WHERE va.view IN (' . $viewidlist . ')
GROUP BY va.view, va.artefact, a.title, a.artefacttype, t.plugin
ORDER BY a.title, va.artefact', '');
$accessgroups = get_records_sql_array('SELECT view, accesstype, grouptype, role, id, name, startdate, stopdate
$accessgroups = get_records_sql_array('SELECT "view", accesstype, grouptype, "role", id, name, startdate, stopdate
FROM (
SELECT view, \'group\' AS accesstype, g.grouptype, vg.role, g.id, g.name, startdate, stopdate
SELECT "view", \'group\' AS accesstype, g.grouptype, vg.role, g.id, g.name, startdate, stopdate
FROM {view_access_group} vg
INNER JOIN {group} g ON g.id = vg.group AND g.deleted = 0
UNION SELECT view, \'user\' AS accesstype, NULL AS grouptype, NULL AS role, usr AS id, \'\' AS name, startdate, stopdate
FROM {view_access_usr} vu
UNION SELECT view, \'secreturl\' AS accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
UNION SELECT "view", \'secreturl\' AS accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
FROM {view_access_token} vt
UNION SELECT view, accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
UNION SELECT "view", accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
FROM {view_access} va
) AS a
WHERE view in (' . $viewidlist . ')
ORDER BY view, accesstype, grouptype, role, name, id
WHERE "view" in (' . $viewidlist . ')
ORDER BY "view", accesstype, grouptype, "role", name, id
', array());
$tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
$tags = get_records_select_array('view_tag', '"view" IN (' . $viewidlist . ')');
}
$data = array();
......@@ -2489,7 +2489,7 @@ class View {
$viewdata = get_records_sql_assoc('
SELECT
id, title, description, owner, ownerformat, "group", institution,
id, title, description, "owner", ownerformat, "group", institution,
' . db_format_tsfield('submittedtime') . '
FROM {view}
WHERE ' . $where . '
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment