Skip to content

Commit

Permalink
MDL-24767 webservices logs use hard coded site id 1 instead of SITEID
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Oct 19, 2010
1 parent 155ef38 commit 136e69c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions admin/webservice/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}
//The user has confirmed the deletion, delete and redirect
$webservicemanager->delete_service($service->id);
add_to_log(1, 'webservice', 'delete', $returnurl, get_string('deleteservice', 'webservice', $service));
add_to_log(SITEID, 'webservice', 'delete', $returnurl, get_string('deleteservice', 'webservice', $service));
redirect($returnurl);
}

Expand All @@ -74,7 +74,7 @@
//create operation
if (empty($servicedata->id)) {
$servicedata->id = $webservicemanager->add_external_service($servicedata);
add_to_log(1, 'webservice', 'add', $returnurl, get_string('addservice', 'webservice', $servicedata));
add_to_log(SITEID, 'webservice', 'add', $returnurl, get_string('addservice', 'webservice', $servicedata));

//redirect to the 'add functions to service' page
$addfunctionpage = new moodle_url(
Expand All @@ -84,7 +84,7 @@
} else {
//update operation
$webservicemanager->update_external_service($servicedata);
add_to_log(1, 'webservice', 'edit', $returnurl, get_string('editservice', 'webservice', $servicedata));
add_to_log(SITEID, 'webservice', 'edit', $returnurl, get_string('editservice', 'webservice', $servicedata));
}

redirect($returnurl);
Expand Down
4 changes: 2 additions & 2 deletions admin/webservice/service_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$serviceuser->externalserviceid = $id;
$serviceuser->userid = $adduser->id;
$webservicemanager->add_ws_authorised_user($serviceuser);
add_to_log(1, 'core', 'assign', $CFG->admin . '/webservice/service_users.php?id='
add_to_log(SITEID, 'core', 'assign', $CFG->admin . '/webservice/service_users.php?id='
. $id, 'add', '', $adduser->id);
}
$potentialuserselector->invalidate_selected_users();
Expand All @@ -71,7 +71,7 @@
if (!empty($userstoremove)) {
foreach ($userstoremove as $removeuser) {
$webservicemanager->remove_ws_authorised_user($removeuser, $id);
add_to_log(1, 'core', 'assign', $CFG->admin . '/webservice/service_users.php?id='
add_to_log(SITEID, 'core', 'assign', $CFG->admin . '/webservice/service_users.php?id='
. $id, 'remove', '', $removeuser->id);
}
$potentialuserselector->invalidate_selected_users();
Expand Down
10 changes: 5 additions & 5 deletions webservice/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ protected function authenticate_user() {

if (!$auth->user_login_webservice($this->username, $this->password)) {
// log failed login attempts
add_to_log(1, 'webservice', get_string('simpleauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".$this->username."/".$this->password." - ".getremoteaddr() , 0);
add_to_log(SITEID, 'webservice', get_string('simpleauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".$this->username."/".$this->password." - ".getremoteaddr() , 0);
throw new webservice_access_exception(get_string('wrongusernamepassword', 'webservice'));
}

Expand All @@ -634,7 +634,7 @@ protected function authenticate_by_token($tokentype){
global $DB;
if (!$token = $DB->get_record('external_tokens', array('token'=>$this->token, 'tokentype'=>$tokentype))) {
// log failed login attempts
add_to_log(1, 'webservice', get_string('tokenauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".$this->token. " - ".getremoteaddr() , 0);
add_to_log(SITEID, 'webservice', get_string('tokenauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".$this->token. " - ".getremoteaddr() , 0);
throw new webservice_access_exception(get_string('invalidtoken', 'webservice'));
}

Expand All @@ -652,7 +652,7 @@ protected function authenticate_by_token($tokentype){
}

if ($token->iprestriction and !address_in_subnet(getremoteaddr(), $token->iprestriction)) {
add_to_log(1, 'webservice', get_string('tokenauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".getremoteaddr() , 0);
add_to_log(SITEID, 'webservice', get_string('tokenauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".getremoteaddr() , 0);
throw new webservice_access_exception(get_string('invalidiptoken', 'webservice'));
}

Expand Down Expand Up @@ -729,7 +729,7 @@ public function run() {
$this->zend_server->setClass($this->service_class);

//log the web service request
add_to_log(1, 'webservice', '', '' , $this->zend_class." ".getremoteaddr() , 0, $this->userid);
add_to_log(SITEID, 'webservice', '', '' , $this->zend_class." ".getremoteaddr() , 0, $this->userid);

// execute and return response, this sends some headers too
$response = $this->zend_server->handle();
Expand Down Expand Up @@ -1164,7 +1164,7 @@ public function run() {
$this->load_function_info();

//log the web service request
add_to_log(1, 'webservice', $this->functionname, '' , getremoteaddr() , 0, $this->userid);
add_to_log(SITEID, 'webservice', $this->functionname, '' , getremoteaddr() , 0, $this->userid);

// finally, execute the function - any errors are catched by the default exception handler
$this->execute();
Expand Down

0 comments on commit 136e69c

Please sign in to comment.