Open-ILS/src/c-apps/oils_auth.c
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 3 Mar 2006 21:00:46 +0000 (21:00 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 3 Mar 2006 21:00:46 +0000 (21:00 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3252 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_event.c
Open-ILS/src/c-apps/oils_utils.c
Open-ILS/src/c-apps/oils_utils.h
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
OpenSRF/src/srfsh/srfsh.c

index a91c0ff..cd385c3 100644 (file)
@@ -7,6 +7,7 @@ osrfHash* __oilsEventEvents = NULL;
 
 oilsEvent* oilsNewEvent( char* event ) {
        if(!event) return NULL;
+       osrfLogInfo(OSRF_LOG_MARK, "Creating new event: %s", event);
        if(!__oilsEventEvents) _oilsEventParseEvents();
        oilsEvent* evt =  (oilsEvent*) safe_malloc(sizeof(oilsEvent));
        evt->event = strdup(event);
@@ -99,8 +100,6 @@ void _oilsEventParseEvents() {
                                        if( code && textcode ) {
                                                osrfHashSet( __oilsEventEvents, code, textcode );
                                                success = 1;
-                                               osrfLogDebug(OSRF_LOG_MARK, "Loading OILS Event: %s => %s", 
-                                                               textcode, osrfHashGet( __oilsEventEvents, textcode) );
                                        }
                                }
                                child = child->next;
index 4baabc2..2893f40 100644 (file)
@@ -149,3 +149,13 @@ char* oilsUtilsLogin( char* uname, char* passwd, char* type, int orgId ) {
 }
 
 
+jsonObject* oilsUtilsFetchWorkstation( long id ) {
+       jsonObject* p = jsonParseString("[%ld]", id);
+       jsonObject* r = oilsUtilsQuickReq(
+               "open-ils.storage", 
+               "open-ils.storage.direct.actor.workstation.retrieve", p );
+       jsonObjectFree(p);
+       return r;
+}
+
+
index 66304c7..de5643b 100644 (file)
@@ -79,3 +79,9 @@ char* oilsUtilsFetchOrgSetting( int orgid, char* setting );
  */
 char* oilsUtilsLogin( char* uname, char* passwd, char* type, int orgId );
 
+
+/**
+ * Fetches the requested workstation object by id
+ */
+jsonObject* oilsUtilsFetchWorkstation( long id );
+
index eeeba68..f30d43b 100644 (file)
                <desc> Requested transaction object does not exist </desc>
        </event>
 
+       <event code='1520' textcode='WORKSTATION_NOT_FOUND'>
+               <desc> Requested workstation object does not exist </desc>
+       </event>
+
 
 
 
                <desc> There is an open circulation on the requested item </desc>
        </event>
 
+       <event code='1702' textcode='WORKSTATION_NAME_EXISTS'>
+               <desc> A workstation with that name already exists </desc>
+       </event>
+
 
        <event code='2000' textcode='BAD_PARAMS'>
                <desc>
index b47bc0d..e23ae48 100644 (file)
@@ -1721,6 +1721,41 @@ sub get_user_perm_groups {
 
 
 
+__PACKAGE__->register_method (
+       method          => 'register_workstation',
+       api_name                => 'open-ils.actor.workstation.register',
+       signature       => q/
+               Registers a new workstion in the system
+               @param authtoken The login session key
+               @param name The name of the workstation id
+               @param owner The org unit that owns this workstation
+               @return The workstation on success, WORKSTATION_NAME_EXISTS
+               if the name is already in use.
+       /);
+
+sub register_workstation {
+       my( $self, $connection, $authtoken, $name, $owner ) = @_;
+       my( $requestor, $evt ) = $U->checkses($authtoken);
+       return $evt if $evt;
+       $evt = $U->check_perms($requestor->id, $owner, 'REGISTER_WORKSTATION');
+       return $evt if $evt;
+
+       my $ws = $U->storagereq(
+               'open-ils.storage.direct.actor.workstation.search.name', $name );
+       return OpenILS::Event->new('WORKSTATION_NAME_EXISTS') if $ws;
+
+       $ws = Fieldmapper::actor::workstation->new;
+       $ws->owning_lib($owner);
+       $ws->name($name);
+
+       my $id = $U->storagereq(
+               'open-ils.storage.direct.actor.workstation.create', $ws );
+       return $U->DB_UPDATE_FAILED($ws) unless $id;
+
+       $ws->id($id);
+       return $ws;
+}
+
 
 1;
 
index c6d124c..cbeb737 100644 (file)
@@ -244,8 +244,9 @@ int handle_login( char* words[]) {
                char* password = words[2];
                char* type              = words[3];
                char* orgloc    = words[4];
-               int orgloci = 0;
-               if(orgloc) orgloci = atoi(orgloc);
+               char* wsid              = words[5];
+               int orgloci = (orgloc) ? atoi(orgloc) : 0;
+               int wsidi = (wsid) ? atoi(wsid) : 0;
                if(!type) type = "opac";
 
                char buf[256];
@@ -274,7 +275,7 @@ int handle_login( char* words[]) {
                char* mess_buf = md5sum(both_buf);
 
                sprintf( buf2, "request open-ils.auth open-ils.auth.authenticate.complete "
-                               "\"%s\", \"%s\", \"%s\", %d", username, mess_buf, type, orgloci );
+                               "\"%s\", \"%s\", \"%s\", %d, %d", username, mess_buf, type, orgloci, wsidi );
 
                free(pass_buf);
                free(mess_buf);