<?php

/**
 * Subclass for representing a row from the 'tblusermessage' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Tblusermessage extends BaseTblusermessage
{
	/**
	 * Initializes internal state of Tblusermessage object.
	 * @see        parent::__construct()
	 */
	public function __construct()
	{
		// Make sure that parent constructor is always invoked, since that
		// is where any default values for this object are set.
		parent::__construct();
	}

  private function setMsData($key, $value) {
    if (!$this->msData) $this->msData = array('from'=>'', 'to'=>'', 'content'=>'');
    $this->msData[$key] = $value;
    parent::setMsContent(sfYaml::dump($this->msData));
  }

  private function getMsData($key) {
    if (!$this->msData) $this->msData = sfYaml::load(parent::getMsContent());
    return $this->msData[$key];
  }

  public function setMsFrom($from) {
    $this->setMsData('from', TbluserPeer::retrieveByPK($from)->getUsFullname());
    parent::setMsFrom($from);
  }

  public function setMsTo($to) {
    $this->setMsData('to', TbluserPeer::retrieveByPK($to)->getUsFullname());
    parent::setMsTo($to);
  }

  public function setMsContent($content) {
    $this->setMsData('content', $content);
  }

  public function getMsContent() {
    return $this->getMsData('content');
  }

  public function getMsSenderName() {
    return $this->getMsData('from');
  }

  public function getMsReceiverName() {
    return $this->getMsData('to');
  }
}
