Location: PHPKode > projects > SimpleSPML > SimpleSPML/lib/msg/password/ResetPasswordRequest.php
<?php
require_once "lib/msg/core/Request.php";
require_once "lib/msg/core/PSOIdentifier.php";

/*
 <complexType name = "ResetPasswordRequestType">
    <complexContent>
        <extension base = "spml:RequestType">
            <sequence>
                <element name = "psoID" type = "spml:PSOIdentifierType" />
            </sequence>
        </extension>
    </complexContent>
</complexType>
*/

/**
 * ResetPasswordRequest
 * 
 * A requestor must send a <resetPasswordRequest> to
 * a provider in order to (ask the provider to) change
 * the password that is associated an existing object
 * and to (ask the provider to) return to the requestor
 * the new password value
 * 
 * @package SimpleSPML
 * @author Alessandra Bozzo <hide@address.com>
 */
class ResetPasswordRequest extends Request
{
    /**
	 * Object identifier
	 * 
	 * @access protected
	 * @var Core::PSOIdentifier
	 */
    protected $psoID = null;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->setBaseElements("psoID");
        
        parent::__construct();
    }
    
    /**
     * Return psoID value
     * @access public
     * @return Core::PSOIdentifier
     */
    public function __getPsoID()
    {
        return $this->psoID;
    }
    
    /**
     * Sets the value of remainingLogins
     * @access public
     * @param int $remainingLogins 
     */
    public function __setPsoID($psoID)
    {
        if(!$psoID)
            throw new MissingParameterException(get_class($this) . "::psoID");
            
        if(!($psoID instanceof PSOIdentifier))
            throw new WrongTypeException(get_class($this) . "::psoID");
            
        $this->psoID = $psoID;
    }
    
    /**
     * Read the SPML message
     * @access public
     * @param SimpleXMLIterator $obj
     */
    public function readMessage($obj)
    {
        $this->checkNamespace($obj, "urn:oasis:names:tc:SPML:2:0");
        
        // Load elements
        $children = $obj->children();
        
        // psoID
        if(!$children->psoID)
        	throw new MalformedMessageException(get_class($this) . "::psoID");
        
        $psoID = new PSOIdentifier();
        $psoID->readMessage($children->psoID);
        $this->setElement("psoID", $psoID);
        unset($children->psoID);
        
        parent::readMessage($obj);
        
        if(!$this->isValid())
            throw new InvalidMessageException(get_class($this));
    }
    
    /**
     * Write the SPML message
     * @access public
     * @param int $level
     * @return string
     */
    public function writeMessage($level = 0)
    {
        if(!$this->isValid())
            throw new InvalidObjectException(get_class($this));
        
        $ind = $this->indentation($level);
        
        $spmlstr = $ind . '<resetPasswordRequest xmlns="urn:oasis:names:tc:SPML:2:0"';
        
        // write resetPasswordRequest attributes
        $spmlstr .= $this->writeAttributes();
                
        // write parent elements
        $spmlmidstr = parent::writeMessage($level + 1);
        
        // write resetPasswordRequest elements
        $spmlmidstr .= $this->psoID->writeElement("psoID", $level + 1);
        
        return $this->tagCloser("resetPasswordRequest", $spmlstr, $spmlmidstr, $ind);
    }
    
    /**
     * Check if the object is valid
     * @access public
     * @return boolean
     */
    public function isValid()
    {
        return(($this->psoID != null) && parent::isValid());
    }
}
?>
Return current item: SimpleSPML