Commit c145b82e authored by Penny Leach's avatar Penny Leach
Browse files

first set of changes to dml calls - get_records changes. get_rows changes

still to come
parent 30daf884
......@@ -30,7 +30,7 @@ define('SUBMENUITEM', 'activity');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$types = get_records('activity_type', 'admin', 0);
$types = get_records_array('activity_type', 'admin', 0);
$readsavefail = get_string('failedtomarkasread', 'activity');
$readsave = get_string('markedasread', 'activity');
......
......@@ -31,7 +31,7 @@ define('SUBMENUITEM', 'activityprefs');
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
$activitytypes = get_records('activity_type', 'admin', 0);
$activitytypes = get_records_array('activity_type', 'admin', 0);
$notifications = plugins_installed('notification');
$elements = array();
......
......@@ -30,7 +30,7 @@ define('MENUITEM','pageeditor');
require(dirname(dirname(__FILE__)).'/init.php');
require_once('pieforms/pieform.php');
$sitepages = get_records('site_content');
$sitepages = get_records_array('site_content');
$pageoptions = array();
foreach ($sitepages as $page) {
$pageoptions[$page->name] = get_string($page->name,'admin');
......
......@@ -32,7 +32,7 @@ $public = (int) param_boolean('public');
$result = array();
$menuitems = get_records('site_menu','public',$public,'displayorder');
$menuitems = get_records_array('site_menu','public',$public,'displayorder');
// @todo: Get all the filenames of the files referred to in the $menuitems records.
// (files table doesn't exist yet)
$rows = array();
......
......@@ -139,7 +139,7 @@ if ($institution || $add) {
}
else {
// Get a list of institutions
$institutions = get_records_sql('SELECT i.name, i.displayname, i.authplugin, i.registerallowed, COUNT(u.*)
$institutions = get_records_sql_array('SELECT i.name, i.displayname, i.authplugin, i.registerallowed, COUNT(u.*)
FROM institution i
LEFT OUTER JOIN usr u ON (u.institution = i.name)
GROUP BY 1, 2, 3, 4
......
......@@ -35,7 +35,7 @@ foreach (plugin_types() as $plugin) {
$plugins[$plugin] = array();
$plugins[$plugin]['installed'] = array();
$plugins[$plugin]['notinstalled'] = array();
if ($installed = get_records($plugin . '_installed')) {
if ($installed = get_records_array($plugin . '_installed')) {
foreach ($installed as $i) {
$plugins[$plugin]['installed'][$i->name] = array();
if ($plugin == 'artefact') {
......
......@@ -31,12 +31,12 @@ define('SUBMENUITEM', 'uploadcsv');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
$institutions = get_records('institution');
$institutions = get_records_array('institution');
foreach ($institutions as $name => $data) {
$options[$name] = $data->displayname;
}
$institutions = get_records_select('institution', "registerallowed = 1 AND authplugin = 'internal'");
$institutions = get_records_select_array('institution', "registerallowed = 1 AND authplugin = 'internal'");
if (count($institutions) > 1) {
$options = array();
foreach ($institutions as $institution) {
......
......@@ -36,7 +36,7 @@ $element_required = call_static_method('ArtefactTypeProfile', 'get_mandatory_fie
// load existing profile information
$profilefields = array();
$profile_data = get_records_select('artefact', "owner=? AND artefacttype IN (" . join(",",array_map(create_function('$a','return db_quote($a);'),array_keys($element_list))) . ")", array($USER->id));
$profile_data = get_records_select_array('artefact', "owner=? AND artefacttype IN (" . join(",",array_map(create_function('$a','return db_quote($a);'),array_keys($element_list))) . ")", array($USER->id));
if ($profile_data) {
foreach ($profile_data as $field) {
......
......@@ -197,7 +197,7 @@ abstract class ArtefactType {
*/
public function get_children_metadata() {
if (!isset($this->childrenmetadata)) {
$this->childrenmetadata = get_records('artefact', 'parent', $this->id);
$this->childrenmetadata = get_records_array('artefact', 'parent', $this->id);
}
return $this->childrenmetadata;
}
......@@ -242,7 +242,7 @@ abstract class ArtefactType {
JOIN ' . $prefix . 'usr_watchlist_artefact w ON w.artefact = a.id
WHERE w.usr = ? AND a.parent = ?';
return get_records_sql($sql, array($userid, $this->id));
return get_records_sql_array($sql, array($userid, $this->id));
}
/**
......
......@@ -109,7 +109,7 @@ function handle_activity($activitytype, $data) {
WHERE pc.activity = ?
AND wv.view = ?
';
$users = get_records_sql($sql, array('watchlist', $data->view));
$users = get_records_sql_array($sql, array('watchlist', $data->view));
}
else if ($data->artefact) {
$sql = 'SELECT DISTINCT u.*, p.method
......@@ -123,7 +123,7 @@ function handle_activity($activitytype, $data) {
WHERE pc.activity = ?
AND (pc.parent = ? OR wa.artefact = ?)
';
$users = get_records_sql($sql, array('watchlist', $data->artefact));
$users = get_records_sql_array($sql, array('watchlist', $data->artefact));
}
else if ($data->community) {
$sql = 'SELECT DISTINCT u.*, p.method
......@@ -135,7 +135,7 @@ function handle_activity($activitytype, $data) {
WHERE pc.activity = ?
AND c.community = ?
';
$users = get_records_sql($sql, array('watchlist', $data->community));
$users = get_records_sql_array($sql, array('watchlist', $data->community));
}
else {
throw new InvalidArgumentException("Invalid watchlist type");
......@@ -158,7 +158,7 @@ function handle_activity($activitytype, $data) {
) AS userlist
JOIN ' . $prefix . 'usr u ON u.id = userlist.userid
JOIN ' . $prefix . 'usr_activity_preference p ON p.usr = u.id';
$users = get_records_sql($sql, array($data->owner, $data->owner, $data->owner,
$users = get_records_sql_array($sql, array($data->owner, $data->owner, $data->owner,
$data->view, $data->view));
break;
}
......@@ -206,6 +206,7 @@ function activity_get_users($activitytype, $userids=null, $userobjs=null, $admin
$sql .= ' AND u.id IN (' . implode(',',db_array_to_ph($userids)) . ')';
$values = array_merge($values, $userids);
}
return get_records_sql_array($sql, $values);
}
......
......@@ -357,7 +357,7 @@ function load_config() {
global $CFG;
try {
$dbconfig = get_records('config');
$dbconfig = get_records_array('config');
}
catch (SQLException $e) {
return false;
......@@ -654,7 +654,7 @@ function plugin_types() {
* @param string $plugintype type of plugin
*/
function plugins_installed($plugintype) {
return get_records($plugintype . '_installed');
return get_records_array($plugintype . '_installed');
}
/**
......@@ -692,7 +692,7 @@ function handle_event($event) {
}
$plugintypes = plugin_types();
foreach ($plugintypes as $name) {
if ($subs = get_records('event_subscription_' . $name, 'event', $event)) {
if ($subs = get_records_array('event_subscription_' . $name, 'event', $event)) {
foreach ($subs as $sub) {
$classname = 'Plugin' . ucfirst($name) . ucfirst($sub->plugin);
try {
......@@ -1002,7 +1002,7 @@ function main_nav() {
function site_menu() {
global $SESSION;
$menu = array();
if ($menuitems = @get_records('site_menu','public',(int) !$SESSION->is_logged_in(),'displayorder')) {
if ($menuitems = get_records_array('site_menu','public',(int) !$SESSION->is_logged_in(),'displayorder')) {
foreach ($menuitems as $i) {
if ($i->url) {
$menu[] = array('name' => $i->title,
......@@ -1210,7 +1210,7 @@ function password_validate(Pieform $form, $values, $user) {
function rebuild_artefact_parent_cache_dirty() {
// this will give us a list of artefacts, as the first returned column
// is not unqiue, but that's ok, it's what we want.
if (!$dirty = get_records('artefact_parent_cache', 'dirty', 1)) {
if (!$dirty = get_records_array('artefact_parent_cache', 'dirty', 1)) {
return;
}
db_begin();
......@@ -1242,7 +1242,7 @@ function rebuild_artefact_parent_cache_dirty() {
function rebuild_artefact_parent_cache_complete() {
db_begin();
delete_records('artefact_parent_cache');
$artefacts = get_records('artefact');
$artefacts = get_records_array('artefact');
foreach ($artefacts as $a) {
$parentids = array();
$current = $a->id;
......
......@@ -47,7 +47,7 @@ function pieform_render_userlist($element, Pieform $form) {
}
if (is_array($value) && count($value)) {
$members = get_records_select('usr','id IN (' . join(',',$value) . ')', null, '', 'id,firstname,lastname,preferredname');
$members = get_records_select_array('usr','id IN (' . join(',',$value) . ')', null, '', 'id,firstname,lastname,preferredname');
foreach($members as &$member) {
$member = display_name($member);
......
......@@ -91,7 +91,7 @@ class View {
JOIN ' . $prefix . 'artefact a ON va.artefact = a.id
JOIN ' . $prefix . 'artefact_installed_type i ON a.artefacttype = i.name
WHERE va.view = ?';
$this->artefact_metadata = get_records_sql($sql, array($this->id));
$this->artefact_metadata = get_records_sql_array($sql, array($this->id));
}
return $this->artefact_metadata;
}
......@@ -119,7 +119,7 @@ class View {
JOIN ' . $prefix . 'artefact_installed_type i ON a.artefacttype = i.name
JOIN ' . $prefix . 'usr_watchlist_artefact wa ON wa.artefact = a.id
WHERE va.view = ? AND wa.usr = ? AND a.parent IS NULL';
return get_records_sql($sql, array($this->id, $userid));
return get_records_sql_array($sql, array($this->id, $userid));
}
......
......@@ -60,7 +60,7 @@ class PluginNotificationEmaildigest extends PluginNotification {
ON q.usr = u.id
ORDER BY usr,type,q.ctime';
if ($tosend = get_records_sql($sql, array())) {
if ($tosend = get_records_sql_array($sql, array())) {
foreach ($tosend as $queue) {
if (!isset($users[$queue->usr])) {
$users[$queue->usr] = new StdClass;
......
......@@ -211,7 +211,7 @@ $elements = array(
)
);
$institutions = get_records_select('institution', "registerallowed = 1 AND authplugin = 'internal'");
$institutions = get_records_select_array('institution', "registerallowed = 1 AND authplugin = 'internal'");
if (count($institutions) > 1) {
$options = array();
foreach ($institutions as $institution) {
......
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