<?php
  $uid = intval($_REQUEST["uid"]);
  $this_user = forum_user($uid);
  
  
  if (!$this_user) {

    /************
     * initiate template and assign variables
     ************/         
    $QuickSkin = new QuickSkin("status_messages.html");
    $QuickSkin->assign("INFO",lang("usernotfound"));
    $content .= $QuickSkin->result();
    unset($QuickSkin);


  } else {
  
    if (!$action) {
      $quote = intval($_REQUEST["quote"]);
      $reply = intval($_REQUEST["reply"]);
      $pmid = ($quote?$quote:$reply);
      if ($pmid) {
        include ("$www_dir/classes/pm.class.php");
        $SBBPm = new SBBPm;
        $pm = $SBBPm->getPM($pmid);
        if ($pm) {
          $FORM_VAL_SUBJECT = (!preg_match('/Re: /', $pm->subject) ? "Re: " . $pm->subject : $pm->subject);
          if ($quote) $FORM_VAL_MESSAGE = "[quote]" . $pm->message . "[/quote]";
        } 
      }
    } else {
      $FORM_VAL_SUBJECT = $subject;
      $FORM_VAL_MESSAGE = $message;
    }
    
    //Template Vars
    $USER_ID = $uid;
    $USER_NAME = $this_user->user;
    $USER_CLASS = nick_class($this_user->is_admin, $this_user->is_mod);
    
    $FORM_HEADLINE = sprintf(lang("send_pm_to"), $this_user->user);
    $DESCR_RCPT = lang("rcpt");
    $DESCR_SUBJECT = lang("subject");
    $DESCR_MESSAGE = lang("your_message");
    $DESCR_MESSAGEINFOS = lang("messageinfo");
    $DESCR_SUBMIT = lang("send_message");
    
    
    //checkout external smilies
    $smilies = smilies();
    if ($smilies["count"]) $SMILIES = $smilies["files"]; //template vars will be set within smilies() -> functions.php
    $DESCR_MORE_SMILIES = lang("more_smilies");
    $HEADLINE_SMILIES = lang("hl_more_smilies");
    

    /************
     * initiate template and assign variables
     ************/ 
    $sendpmVARS = array('FORM_HEADLINE' => $FORM_HEADLINE,
                        'DESCR_RCPT' => $DESCR_RCPT,
                        'DESCR_SUBJECT' => $DESCR_SUBJECT,
                        'DESCR_MESSAGE' => $DESCR_MESSAGE,
                        'DESCR_MESSAGEINFOS' => $DESCR_MESSAGEINFOS,
                        'DESCR_SUBMIT' => $DESCR_SUBMIT,
                        'USER_ID' => $USER_ID,
                        'USER_NAME' => $USER_NAME,
                        'USER_CLASS' => $USER_CLASS,
                        'FORM_VAL_SUBJECT' => $FORM_VAL_SUBJECT,
                        'FORM_VAL_MESSAGE' => $FORM_VAL_MESSAGE,
                        'DESCR_MORE_SMILIES' => $DESCR_MORE_SMILIES,
                        'HEADLINE_SMILIES' => $HEADLINE_SMILIES,

                        'CONF' => $GLOBAL_TEMPLATE_VARS,
                        'FLAGS' => $TEMPLATE_FLAGS,
                        'SMILIES' => $SMILIES
    );
    $QuickSkin = new QuickSkin("sendpm.html");
    $QuickSkin->assign($sendpmVARS);
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  }
  
  
?>