Skip to content

Commit

Permalink
MDL-24321 switching to stdClass in /lib/
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 21, 2010
1 parent ac6f1a8 commit 365a594
Show file tree
Hide file tree
Showing 40 changed files with 157 additions and 157 deletions.
30 changes: 15 additions & 15 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ function create_context($contextlevel, $instanceid, $strictness=IGNORE_MISSING)
return get_system_context();
}

$context = new object();
$context = new stdClass();
$context->contextlevel = $contextlevel;
$context->instanceid = $instanceid;

Expand Down Expand Up @@ -1843,7 +1843,7 @@ function get_system_context($cache=true) {
global $DB, $ACCESSLIB_PRIVATE;
if ($cache and defined('SYSCONTEXTID')) {
if (is_null($ACCESSLIB_PRIVATE->systemcontext)) {
$ACCESSLIB_PRIVATE->systemcontext = new object();
$ACCESSLIB_PRIVATE->systemcontext = new stdClass();
$ACCESSLIB_PRIVATE->systemcontext->id = SYSCONTEXTID;
$ACCESSLIB_PRIVATE->systemcontext->contextlevel = CONTEXT_SYSTEM;
$ACCESSLIB_PRIVATE->systemcontext->instanceid = 0;
Expand All @@ -1860,7 +1860,7 @@ function get_system_context($cache=true) {
}

if (!$context) {
$context = new object();
$context = new stdClass();
$context->contextlevel = CONTEXT_SYSTEM;
$context->instanceid = 0;
$context->depth = 1;
Expand Down Expand Up @@ -2350,7 +2350,7 @@ function create_role($name, $shortname, $description, $archetype='') {
$context = get_context_instance(CONTEXT_SYSTEM);

// Insert the role record.
$role = new object();
$role = new stdClass();
$role->name = $name;
$role->shortname = $shortname;
$role->description = $description;
Expand Down Expand Up @@ -2424,7 +2424,7 @@ function assign_capability($capability, $permission, $roleid, $contextid, $overw
return true;
}

$cap = new object;
$cap = new stdClass();
$cap->contextid = $contextid;
$cap->roleid = $roleid;
$cap->capability = $capability;
Expand Down Expand Up @@ -2581,7 +2581,7 @@ function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0,
}

// Create a new entry
$ra = new object();
$ra = new stdClass();
$ra->roleid = $roleid;
$ra->contextid = $context->id;
$ra->userid = $userid;
Expand Down Expand Up @@ -3265,13 +3265,13 @@ function update_capabilities($component='moodle') {
$filecaps[$cachedcap->name]['riskbitmask'] = 0; // no risk if not specified
}
if ($cachedcap->captype != $filecaps[$cachedcap->name]['captype']) {
$updatecap = new object();
$updatecap = new stdClass();
$updatecap->id = $cachedcap->id;
$updatecap->captype = $filecaps[$cachedcap->name]['captype'];
$DB->update_record('capabilities', $updatecap);
}
if ($cachedcap->riskbitmask != $filecaps[$cachedcap->name]['riskbitmask']) {
$updatecap = new object();
$updatecap = new stdClass();
$updatecap->id = $cachedcap->id;
$updatecap->riskbitmask = $filecaps[$cachedcap->name]['riskbitmask'];
$DB->update_record('capabilities', $updatecap);
Expand All @@ -3281,7 +3281,7 @@ function update_capabilities($component='moodle') {
$filecaps[$cachedcap->name]['contextlevel'] = 0; // no context level defined
}
if ($cachedcap->contextlevel != $filecaps[$cachedcap->name]['contextlevel']) {
$updatecap = new object();
$updatecap = new stdClass();
$updatecap->id = $cachedcap->id;
$updatecap->contextlevel = $filecaps[$cachedcap->name]['contextlevel'];
$DB->update_record('capabilities', $updatecap);
Expand All @@ -3304,7 +3304,7 @@ function update_capabilities($component='moodle') {
}
// Add new capabilities to the stored definition.
foreach ($newcaps as $capname => $capdef) {
$capability = new object();
$capability = new stdClass();
$capability->name = $capname;
$capability->captype = $capdef['captype'];
$capability->contextlevel = $capdef['contextlevel'];
Expand Down Expand Up @@ -4315,7 +4315,7 @@ function get_user_roles($context, $userid=0, $checkparentcontexts=true, $order='
function allow_override($sroleid, $troleid) {
global $DB;

$record = new object();
$record = new stdClass();
$record->roleid = $sroleid;
$record->allowoverride = $troleid;
$DB->insert_record('role_allow_override', $record);
Expand All @@ -4332,7 +4332,7 @@ function allow_override($sroleid, $troleid) {
function allow_assign($fromroleid, $targetroleid) {
global $DB;

$record = new object();
$record = new stdClass();
$record->roleid = $fromroleid;
$record->allowassign = $targetroleid;
$DB->insert_record('role_allow_assign', $record);
Expand All @@ -4349,7 +4349,7 @@ function allow_assign($fromroleid, $targetroleid) {
function allow_switch($fromroleid, $targetroleid) {
global $DB;

$record = new object();
$record = new stdClass();
$record->roleid = $fromroleid;
$record->allowswitch = $targetroleid;
$DB->insert_record('role_allow_switch', $record);
Expand Down Expand Up @@ -5796,7 +5796,7 @@ function context_instance_preload(stdClass $rec) {
}

// note: in PHP5 the objects are passed by reference, no need to return $rec
$context = new object();
$context = new stdClass();
$context->id = $rec->ctxid; unset($rec->ctxid);
$context->path = $rec->ctxpath; unset($rec->ctxpath);
$context->depth = $rec->ctxdepth; unset($rec->ctxdepth);
Expand Down Expand Up @@ -5876,7 +5876,7 @@ function fix_role_sortorder($allroles) {
foreach ($allroles as $role) {
$rolesort[$i] = $role->id;
if ($role->sortorder != $i) {
$r = new object();
$r = new stdClass();
$r->id = $role->id;
$r->sortorder = $i;
$DB->update_record('role', $r);
Expand Down
26 changes: 13 additions & 13 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ public function search($query) {
$found = true;
}
if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
Expand Down Expand Up @@ -1146,7 +1146,7 @@ class admin_settingpage implements part_of_admin_tree {
* if you specify something other than system or front page. Defaults to system.
*/
public function __construct($name, $visiblename, $req_capability='moodle/site:config', $hidden=false, $context=NULL) {
$this->settings = new object();
$this->settings = new stdClass();
$this->name = $name;
$this->visiblename = $visiblename;
if (is_array($req_capability)) {
Expand Down Expand Up @@ -1194,7 +1194,7 @@ public function search($query) {
}

if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = $found;
return array($this->name => $result);
Expand All @@ -1209,7 +1209,7 @@ public function search($query) {
$found = true;
}
if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
Expand Down Expand Up @@ -1437,7 +1437,7 @@ public function config_write($name, $value) {
set_config($name, $value, $this->plugin);

// log change
$log = new object();
$log = new stdClass();
$log->userid = during_initial_install() ? 0 :$USER->id; // 0 as user id during install
$log->timemodified = time();
$log->plugin = $this->plugin;
Expand Down Expand Up @@ -3076,7 +3076,7 @@ public function get_setting() {
*/
public function write_setting($data) {
global $DB, $SITE;
$record = new object();
$record = new stdClass();
$record->id = SITEID;
$record->{$this->name} = ($data == '1' ? 1 : 0);
$record->timemodified = time();
Expand Down Expand Up @@ -3135,7 +3135,7 @@ public function write_setting($data) {
return $validated;
}

$record = new object();
$record = new stdClass();
$record->id = SITEID;
$record->{$this->name} = $data;
$record->timemodified = time();
Expand Down Expand Up @@ -3176,7 +3176,7 @@ public function get_setting() {
*/
public function write_setting($data) {
global $DB, $SITE;
$record = new object();
$record = new stdClass();
$record->id = SITEID;
$record->{$this->name} = $data;
$record->timemodified = time();
Expand Down Expand Up @@ -4442,7 +4442,7 @@ public function search($query) {
}
}
if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
Expand Down Expand Up @@ -4695,7 +4695,7 @@ public function search($query) {
}
}
if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
Expand Down Expand Up @@ -4742,7 +4742,7 @@ public function search($query) {
}
}
if ($found) {
$result = new object();
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
Expand Down Expand Up @@ -5651,7 +5651,7 @@ function admin_write_settings($formdata) {
$original = serialize($setting->get_setting()); // comparison must work for arrays too
$error = $setting->write_setting($data[$fullname]);
if ($error !== '') {
$adminroot->errors[$fullname] = new object();
$adminroot->errors[$fullname] = new stdClass();
$adminroot->errors[$fullname]->data = $data[$fullname];
$adminroot->errors[$fullname]->id = $setting->get_id();
$adminroot->errors[$fullname]->error = $error;
Expand Down Expand Up @@ -7022,7 +7022,7 @@ public function output_html($data, $query='') {
foreach ($protocols_available as $protocol => $location) {
$name = get_string('pluginname', 'webservice_'.$protocol);

$plugin = new object();
$plugin = new stdClass();
if (file_exists($CFG->dirroot.'/webservice/'.$protocol.'/version.php')) {
include($CFG->dirroot.'/webservice/'.$protocol.'/version.php');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ function block_method_result($blockname, $method, $param = NULL) {
}

/**
* Creates a new object of the specified block class.
* Creates a new instance of the specified block class.
*
* @param string $blockname the name of the block.
* @param $instance block_instances DB table row (optional).
Expand Down
2 changes: 1 addition & 1 deletion lib/completion/completion_criteria_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function get_details($completion) {
global $DB, $CFG;

// Get completion info
$course = new object();
$course = new stdClass();
$course->id = $completion->course;
$info = new completion_info($course);

Expand Down
2 changes: 1 addition & 1 deletion lib/completion/completion_criteria_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function get_details($completion) {
global $CFG, $DB;

// Get completion info
$course = new object();
$course = new stdClass();
$course->id = $completion->course;
$info = new completion_info($course);

Expand Down
2 changes: 1 addition & 1 deletion lib/completion/data_object.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function delete() {
* Returns object with fields and values that are defined in database
*/
public function get_record_data() {
$data = new object();
$data = new stdClass();

foreach ($this as $var=>$value) {
if (in_array($var, $this->required_fields) or array_key_exists($var, $this->optional_fields)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ function get_course_category($catid=0) {
$category = reset($category);

} else {
$cat = new object();
$cat = new stdClass();
$cat->name = get_string('miscellaneous');
$cat->depth = 1;
$cat->sortorder = MAX_COURSES_IN_CATEGORY;
Expand Down Expand Up @@ -1727,7 +1727,7 @@ function user_accesstime_log($courseid=0) {
/// Update $USER->lastaccess for next checks
$USER->lastaccess = $timenow;

$last = new object();
$last = new stdClass();
$last->id = $USER->id;
$last->lastip = getremoteaddr();
$last->lastaccess = $timenow;
Expand All @@ -1749,7 +1749,7 @@ function user_accesstime_log($courseid=0) {
// Update course lastaccess for next checks
$USER->currentcourseaccess[$courseid] = $timenow;

$last = new object();
$last = new stdClass();
$last->userid = $USER->id;
$last->courseid = $courseid;
$last->timeaccess = $timenow;
Expand Down Expand Up @@ -1892,7 +1892,7 @@ function count_login_failures($mode, $username, $lastlogin) {
$params = array('mode'=>$mode, 'username'=>$username, 'lastlogin'=>$lastlogin);
$select = "module='login' AND action='error' AND time > :lastlogin";

$count = new object();
$count = new stdClass();

if (is_siteadmin()) {
if ($count->attempts = $DB->count_records_select('log', $select, $params)) {
Expand Down
16 changes: 8 additions & 8 deletions lib/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function xmldb_main_install() {


/// create site course
$newsite = new object();
$newsite = new stdClass();
$newsite->fullname = '';
$newsite->shortname = '';
$newsite->summary = NULL;
Expand Down Expand Up @@ -82,7 +82,7 @@ function xmldb_main_install() {


/// bootstrap mnet
$mnethost = new object();
$mnethost = new stdClass();
$mnethost->wwwroot = $CFG->wwwroot;
$mnethost->name = '';
$mnethost->name = '';
Expand All @@ -106,15 +106,15 @@ function xmldb_main_install() {
set_config('mnet_localhost_id', $mnetid);

// Initial insert of mnet applications info
$mnet_app = new object();
$mnet_app = new stdClass();
$mnet_app->name = 'moodle';
$mnet_app->display_name = 'Moodle';
$mnet_app->xmlrpc_server_url = '/mnet/xmlrpc/server.php';
$mnet_app->sso_land_url = '/auth/mnet/land.php';
$mnet_app->sso_jump_url = '/auth/mnet/jump.php';
$moodleapplicationid = $DB->insert_record('mnet_application', $mnet_app);

$mnet_app = new object();
$mnet_app = new stdClass();
$mnet_app->name = 'mahara';
$mnet_app->display_name = 'Mahara';
$mnet_app->xmlrpc_server_url = '/api/xmlrpc/server.php';
Expand All @@ -123,7 +123,7 @@ function xmldb_main_install() {
$DB->insert_record('mnet_application', $mnet_app);

// Set up the probably-to-be-removed-soon 'All hosts' record
$mnetallhosts = new object();
$mnetallhosts = new stdClass();
$mnetallhosts->wwwroot = '';
$mnetallhosts->ip_address = '';
$mnetallhosts->public_key = '';
Expand All @@ -137,7 +137,7 @@ function xmldb_main_install() {
set_config('mnet_all_hosts_id', $mnetallhosts->id);

/// Create guest record - do not assign any role, guest user get's the default guest role automatically on the fly
$guest = new object();
$guest = new stdClass();
$guest->auth = 'manual';
$guest->username = 'guest';
$guest->password = hash_internal_user_password('guest');
Expand All @@ -158,7 +158,7 @@ function xmldb_main_install() {


/// Now create admin user
$admin = new object();
$admin = new stdClass();
$admin->auth = 'manual';
$admin->firstname = get_string('admin');
$admin->lastname = get_string('user');
Expand Down Expand Up @@ -264,7 +264,7 @@ function xmldb_main_install() {
license_manager::install_licenses();

/// Add two lines of data into this new table
$mypage = new object();
$mypage = new stdClass();
$mypage->userid = NULL;
$mypage->name = '__default';
$mypage->private = 0;
Expand Down
Loading

0 comments on commit 365a594

Please sign in to comment.