MailFolder.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:4k
源码类别:

WEB邮件程序

开发平台:

PHP

  1. <?php
  2. class MailFolder extends BaseObject {
  3.    var $count;
  4.    var $recent;
  5.    var $new;
  6.    var $folder;
  7.    var $pop3;
  8.    var $imap;
  9.    var $pop3_obj;
  10.    var $imap_obj;
  11.    Function MailFolder( $folder = 'INBOX' ) {
  12.       $this->folder        = $folder;
  13.       $this->pop3          = 0;
  14.       $this->imap          = 0;
  15.       $this->pop3_obj      = new MailPop3();
  16.       $this->imap_obj      = new MailImap();
  17.       $this->count         = 0;
  18.       $this->recent        = 0;
  19.       $this->new           = 0;
  20.    }
  21.    Function CopySettings( $src_obj ) {
  22.       $this->folder           = $src_obj->folder;
  23.       $this->pop3             = $src_obj->pop3;
  24.       $this->imap             = $src_obj->imap;
  25.       $this->pop3_obj         = $src_obj->pop3_obj;
  26.       $this->imap_obj         = $src_obj->imap_obj;
  27.       if ( $this->imap == 1 ) {
  28.          $this->imap_obj->CopySettings( $src_obj );
  29.       }
  30.       if ( $this->pop3 == 1 ) {
  31.       }
  32.    }
  33.    Function GetStats() {
  34.       if ( $this->pop3 ) {
  35.       } 
  36.       if ( $this->imap ) {
  37.          $this->imap_obj->folder = $this->folder;
  38.          $ret_vals = $this->imap_obj->Folder_GetStats();
  39.          if ( $ret_vals[ 0 ] == 0 ) {
  40.             /* Bubble up the error */
  41.             return $ret_vals;
  42.          } else {
  43.             $this->count      = $ret_vals[ 1 ];
  44.             $this->recent     = $ret_vals[ 2 ];
  45.             $this->new        = $ret_vals[ 3 ];
  46.             return Array( true );
  47.          }
  48.       }
  49.    }
  50.    Function GetMessageHeader( $message_num ) {
  51.       if ( $this->imap ) {
  52.          $this->imap_obj->folder = $this->folder;
  53.          return $this->imap_obj->Message_GetHeader( $message_num );
  54.       }
  55.    }
  56.    Function GetMessageBody( $message_num ) {
  57.       if ( $this->imap ) {
  58.          $this->imap_obj->folder = $this->folder;
  59.          return $this->imap_obj->Message_GetBody( $message_num );
  60.       }
  61.    }
  62.    Function GetMessageBodySection( $message_num, $section_num ) {
  63.       if ( $this->imap ) {
  64.          $this->imap_obj->folder = $this->folder;
  65.          return $this->imap_obj->Message_GetBodySection( 
  66.             $message_num, $section_num
  67.          );
  68.       }
  69.    }
  70.    Function GetMessageStructure( $message_num ) {
  71.       if ( $this->imap ) {
  72.          $this->imap_obj->folder = $this->folder;
  73.          return $this->imap_obj->Message_Structure( $message_num );
  74.       }
  75.    }
  76.    Function DeleteMessage( $message_num ) {
  77.       if ( $this->imap ) {
  78.          $this->imap_obj->folder = $this->folder;
  79.          return $this->imap_obj->Message_Delete( $message_num );
  80.       }
  81.    }
  82.    Function UnDeleteMessage( $message_num ) {
  83.       if ( $this->imap ) {
  84.          $this->imap_obj->folder = $this->folder;
  85.          return $this->imap_obj->Message_UnDelete( $message_num );
  86.       }
  87.    }
  88.    Function ExpungeDeletedMessages() {
  89.       if ( $this->imap ) {
  90.          $this->imap_obj->folder = $this->folder;
  91.          return $this->imap_obj->Message_ExpungeDeleted();
  92.       }
  93.    }
  94.    /*
  95.    SORTARRIVAL
  96.    SORTFROM
  97.    SORTSIZE
  98.    SORTSUBJECT
  99.    */
  100.    Function Sort( $sort_order = SORTARRIVAL, $reverse_order = 0 ) {
  101.       if ( $this->imap ) {
  102.          $this->imap_obj->folder = $this->folder;
  103.          return $this->imap_obj->Folder_Sort( $sort_order, $reverse_order );
  104.       }
  105.    }
  106.    Function MoveMessage( $to_folder, $message_id ) {
  107.       $this->imap_obj->CopySettings( $this );
  108.       $this->pop3_obj->CopySettings( $this );
  109.       if ( $this->imap == 1 ) {
  110.          return $this->imap_obj->MoveMessage( $to_folder, $message_id );
  111.       } else {
  112.          /* POP3 Does not do folder support */
  113.         return 0;
  114.       }
  115.       return 0;
  116.    }
  117. }
  118. ?>