Changeset 5953

Show
Ignore:
Timestamp:
05/15/08 07:18:59 (8 months ago)
Author:
coolengineer
Message:
  • #960
  • 같은 날 올리는 모든 MMS 메시지를 하나의 POST에 모음
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/Needlworks.Mail.Pop3.php

    r5950 r5953  
    7373                return false; 
    7474            } 
    75             if( $this->retr_callback && count($this->results)>100 ) { 
     75            if( $this->retr_callback ) { 
    7676                call_user_func( $this->retr_callback, $this->results, $this->uids[$nr] ); 
    7777            } 
  • trunk/plugins/CL_Moblog/index.php

    r5950 r5953  
    109109    } 
    110110 
     111    function _getDecoratedContent( & $mail ) { 
     112            $alt = htmlentities($mail['attachments'][0]['filename'],ENT_QUOTES,'utf-8'); 
     113            $content = '<p>$TEXT</p><p>[##_1C|$FILENAME|width="$WIDTH" height="$HEIGHT" alt="'.$alt.'"|_##]</p>'; 
     114            $text = "<h3>".$mail['subject']."</h3>\r\n".(isset($mail['text'])?$mail['text']:''); 
     115            return str_replace( '$TEXT', $text , $content ); 
     116    } 
     117 
    111118    function retrieveCallback( $lines, $uid ) 
    112119    { 
    113120        $this->appendUid( $uid ); 
    114121        $mail = $this->pop3->parse( $lines ); 
     122        if( in_array( $mail['subject'], array( '제목없음' ) ) ) { 
     123            $mail['subject'] = ''; 
     124        } 
    115125        $this->log( "Subject: " . $mail['subject'] ); 
    116126        if( !$this->isMms($mail) ) { 
     
    126136 
    127137        $post = new Post(); 
    128         $post->userid = $this->userid; 
    129         $post->content = '$TEXT<br/>[##_1C|$FILENAME|width="$WIDTH" height="$HEIGHT" alt=""|_##]'; 
    130         $post->content = str_replace( '$TEXT', isset($mail['text'])?$mail['text']:'', $post->content ); 
    131         $post->contentFormatter = getDefaultFormatter(); 
    132         $post->contentEditor = getDefaultEditor(); 
    133         $post->title = $mail['subject']; 
    134         if( empty($post->title) ) { 
    135             $post->title = $post->$mail['attachments'][0]['filename']; 
    136         } 
    137         $post->created = time(); 
    138         $post->modified = time(); 
    139         $post->acceptComment = true; 
    140         $post->acceptTrackback = true; 
    141         $post->visibility = "public"; 
    142         $post->published = time(); 
    143         $post->add(); 
     138        $slogan = date( "Y-m-d" ); 
     139 
     140        if( $post->open( "slogan = '$slogan'" ) ) { 
     141            $post->content .= $this->_getDecoratedContent( $mail ); 
     142            $post->modified = time(); 
     143        } else { 
     144            $post->title = $mail['subject']; 
     145            $post->userid = $this->userid; 
     146            $post->content = $this->_getDecoratedContent( $mail ); 
     147            $post->contentFormatter = getDefaultFormatter(); 
     148            $post->contentEditor = getDefaultEditor(); 
     149            $post->created = time(); 
     150            $post->acceptComment = true; 
     151            $post->acceptTrackback = true; 
     152            $post->visibility = "public"; 
     153            $post->published = time(); 
     154            $post->modified = time(); 
     155            $post->slogan = $slogan; 
     156            if( !$post->add() ) { 
     157                $this->log( "Failed: there is a problem in adding post" ); 
     158                return false; 
     159            } 
     160        } 
    144161 
    145162        $this->log( "Attachment: {$mail['attachments'][0]['filename']}" ); 
     
    152169                    )  
    153170            ); 
     171        if( !$att ) { 
     172            $this->log( "Failed: there is a problem in attaching file" ); 
     173            return false; 
     174        } 
    154175        $post->content = str_replace( '$FILENAME', $att['name'], $post->content ); 
    155176        $post->content = str_replace( '$WIDTH', $att['width'], $post->content ); 
    156177        $post->content = str_replace( '$HEIGHT', $att['height'], $post->content ); 
    157         $post->update(); 
     178        if( !$post->update() ) { 
     179            $this->log( "Failed: there is a problem in adding post." ); 
     180            return false; 
     181        } 
    158182        return true; 
    159183    }