ThomasAndreasKocher
Joined: Oct 19, 2020
Messages: 6
Offline
|
i know that on the CM SAT Terminal there is only the change authorization-code wich is working properly the AE Webservice uses for adding a new authorization-code the change from the SAT CM Terminal you cen see that at the AuthorizationCodeModel.class.php file
Which is also attached to this Issue
<?php
require_once "OSSIModel.class.php" ;
class __AuthCodeFormModel extends OSSIModel
{
function __AuthCodeFormModel( $asList=false )
{
Message::Trace("Internal __AuthCodeFormModel CTOR");
parent::OSSIModel( "authorization-code", $asList );
$this->_initSchema();
}
function operations() { return array( "list", "display", "change" ); }
// Convert attribute label to attribute name.
// Replace spaces and dashes with underscores, and strip off period (.), colon(:) and
// question mark (?)
function _initSchema()
{
// The code-count field only applies to display, not list
if ( ! $this->isList() )
$this->_makeField( 0x0004ff00, 1, 7, 1, "Administered Codes", "", "Read-Only" );
$this->_makeField( 0x0001ff00, 255, 7, 1, "Code", "" );
// The COR fid is different in the list operation than for the display/change operations!
$corFid = ( $this->isList() ? 0x0002ff00 : 0x802bff00 );
$this->_makeField( $corFid, 255, 1, 1, "COR", "" );
}
}
// The interface wrapper class
// TODO: In future, shouldn't have to be OSSIModel-derived, but for now, this is the only
// way it's seen as accessible to SMS.
class AuthorizationCodeModel extends OSSIModel
{
var $m_form;
var $m_bNotFoundError = false;
function AuthorizationCodeModel( $asList=false )
{
Message::Trace("AuthorizationCode Model CTOR");
parent::OSSIModel( "authorization-code", $asList ); // Never seen by OSSI
// Note: we defer instantiation of the form model until the operation is known!
$this->m_form =new __AuthCodeFormModel();
$this->_initSchema();
}
function operations() { return array( "list", "display", "add", "change", "remove" ); }
function _initSchema()
{
// Note: FIDs below aren't actually used -- the ones in the form model are!
// And we treat these like scalars!
$this->_makeField( 0x0004ff00, 1, 7, 1, "Administered Codes", "", "Read-Only" );
$this->_makeField( 0x0001ff00, 1, 7, 1, "Code", "" );
$this->_makeField( 0x0002ff00, 1, 1, 1, "COR", "" );
}
// OPERATION OVERRIDES
// List operation
function query( $aParams = null, $fields=null, $cmdName="list" )
{
// This is a pass-thru to the form model
$this->m_form =new __AuthCodeFormModel( true ); // true == create as list model
$result = $this->m_form->query( $aParams, $fields, $cmdName );
// This model results now should reference the form model
$this->m_data =& $this->m_form->m_data;
$this->m_lastError =& $this->m_form->m_lastError;
return $result;
}
// Display operation
function retrieve( $qualifier, $fields=null, $cmdName="display" )
{
$this->m_form =new __AuthCodeFormModel( false ); // true == create as scalar model
$result = $this->m_form->retrieve( $qualifier, "*", $cmdName );
// MUST now check -- did we retrieve the requested qualifier?
if ( $result )
{
if ( $this->m_form->get( "Code", 1 ) != $qualifier )
{
$this->m_lastError = array( "1 00000000 0000 Authorization Code \"$qualifier\" not found." );
$this->m_bNotFoundError = true;
$result = false;
}
else
{
// That's the one. Assign our fields as scalars
$this->set( "Code", $qualifier );
$this->set( "COR", $this->m_form->get( "COR", 1 ) );
}
}
else
{
$this->m_lastError = $this->m_form->m_lastError;
}
return $result;
}
// add, change, remove
function submit( $cmd, $keyfield, $fields=null )
{
// The first word identifies the command. the second word will be the qualifier
list( $op, $obj, $qualifier, $rest ) = explode( " ", $cmd, 4 );
// The only field of consequence is COR.
// The fields-parameter parsing algorithm in the "submit" operation should be generalized for use
// here. For now, do parsing specific to this operation:
// Save Code, COR before attempting display
$COR = $this->get( "COR" );
$code = $this->get( "Code" );
if ( ! isset( $code ) ) $code = $qualifier;
$bExists = true; // assume qualifier exists until...
$retrieveOk = $this->retrieve( $qualifier );
if ( ! $retrieveOk )
{
if ( $this->m_bNotFoundError )
{
$bExists = false; // ok, retrieve didn't find the code
}
else
{
return false; // another blocking error occurred, lastError contains the explanation
}
}
// Restore COR, Code
$this->set( "Code", $code );
$this->set( "COR", $COR );
// For Add, Change note that this usage means you could change the code from that specified
// by the qualifier, assuming this is valid on the switch
switch( $op )
{
case 'add':
if ( ! $bExists )
{
return $this->add( $qualifier );
}
// Otherwise, it's an error
$this->m_lastError = array( "1 00000000 0000 Code $qualifier already exists. Unable to add." );
break;
case 'remove':
// Remove means we blank Code and COR
$this->set( "Code", " " );
$this->set( "COR", " " );
// fall through to change...
case 'change':
if ( $bExists )
return $this->change( $qualifier );
// But if it wasn't found, then that's an error, lastError is already set.
break;
default:
$this->m_lastError = array( "1 00000000 0000 Invalid Operation \"$op\"" );
}
Message::Trace( "Ok, we're returning without executing!" );
return false; // if any chance of success, we already returned above.
}
function add( $qualifier )
{
// A safe way to add: use all 9's as the qualifier, and put the new entry in slot 2
$key = substr( "9999999999", 0, strlen( $qualifier ) );
$this->m_form =new __AuthCodeFormModel( false );
$this->m_form->set( "Code", 2, $this->get( "Code" ) );
$this->m_form->set( "COR", 2, $this->get( "COR" ) );
$result = $this->m_form->submit( "change authorization-code $key" );
$this->m_lastError = $this->m_form->m_lastError;
return $result;
}
function change( $qualifier )
{
$this->m_form =new __AuthCodeFormModel( false );
$this->m_form->set( "Code", 1, $this->get( "Code" ) );
$this->m_form->set( "COR", 1, $this->get( "COR" ) );
$result = $this->m_form->submit( "change authorization-code $qualifier" );
$this->m_lastError = $this->m_form->m_lastError;
return $result;
}
}
?>
the funktion add call there the change on the SAT Terminal
$result = $this->m_form->submit( "change authorization-code $key" );
as much as i know has there is no add off the authorization code at leats since Version 6.3
|