original_string: public function copyMessage($id, $folder)
      {
          if ($this->_quota && $this->checkQuota()) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              throw new Zend_Mail_Storage_Exception('storage is over quota!');
          }
  
          if (!($folder instanceof Zend_Mail_Storage_Folder)) {
              $folder = $this->getFolders($folder);
          }
  
          $filedata = $this->_getFileData($id);
          $old_file = $filedata['filename'];
          $flags = $filedata['flags'];
  
          // copied message can't be recent
          while (($key = array_search(Zend_Mail_Storage::FLAG_RECENT, $flags)) !== false) {
              unset($flags[$key]);
          }
          $info = $this->_getInfoString($flags);
  
          // we're creating the copy as temp file before moving to cur/
          $temp_file = $this->_createTmpFile($folder->getGlobalName());
          // we don't write directly to the file
          fclose($temp_file['handle']);
  
          // we're adding the size to the filename for maildir++
          $size = filesize($old_file);
          if ($size !== false) {
              $info = ',S=' . $size . $info;
          }
  
          $new_file = $temp_file['dirname'] . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . $temp_file['uniq'] . $info;
  
          // we're throwing any exception after removing our temp file and saving it to this variable instead
          $exception = null;
  
          if (!copy($old_file, $temp_file['filename'])) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              $exception = new Zend_Mail_Storage_Exception('cannot copy message file');
          } else if (!link($temp_file['filename'], $new_file)) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir');
          }
          @unlink($temp_file['filename']);
  
          if ($exception) {
              throw $exception;
          }
  
          if ($folder->getGlobalName() == $this->_currentFolder
              || ($this->_currentFolder == 'INBOX' && $folder->getGlobalName() == '/')) {
              $this->_files[] = array('uniq'     => $temp_file['uniq'],
                                      'flags'    => $flags,
                                      'filename' => $new_file);
          }
  
          if ($this->_quota) {
              $this->_addQuotaEntry((int)$size, 1);
          }
      }
code: public function copyMessage($id, $folder)
      {
          if ($this->_quota && $this->checkQuota()) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              throw new Zend_Mail_Storage_Exception('storage is over quota!');
          }
  
          if (!($folder instanceof Zend_Mail_Storage_Folder)) {
              $folder = $this->getFolders($folder);
          }
  
          $filedata = $this->_getFileData($id);
          $old_file = $filedata['filename'];
          $flags = $filedata['flags'];
  
          // copied message can't be recent
          while (($key = array_search(Zend_Mail_Storage::FLAG_RECENT, $flags)) !== false) {
              unset($flags[$key]);
          }
          $info = $this->_getInfoString($flags);
  
          // we're creating the copy as temp file before moving to cur/
          $temp_file = $this->_createTmpFile($folder->getGlobalName());
          // we don't write directly to the file
          fclose($temp_file['handle']);
  
          // we're adding the size to the filename for maildir++
          $size = filesize($old_file);
          if ($size !== false) {
              $info = ',S=' . $size . $info;
          }
  
          $new_file = $temp_file['dirname'] . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . $temp_file['uniq'] . $info;
  
          // we're throwing any exception after removing our temp file and saving it to this variable instead
          $exception = null;
  
          if (!copy($old_file, $temp_file['filename'])) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              $exception = new Zend_Mail_Storage_Exception('cannot copy message file');
          } else if (!link($temp_file['filename'], $new_file)) {
              /**
               * @see Zend_Mail_Storage_Exception
               */
              // require_once 'Zend/Mail/Storage/Exception.php';
              $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir');
          }
          @unlink($temp_file['filename']);
  
          if ($exception) {
              throw $exception;
          }
  
          if ($folder->getGlobalName() == $this->_currentFolder
              || ($this->_currentFolder == 'INBOX' && $folder->getGlobalName() == '/')) {
              $this->_files[] = array('uniq'     => $temp_file['uniq'],
                                      'flags'    => $flags,
                                      'filename' => $new_file);
          }
  
          if ($this->_quota) {
              $this->_addQuotaEntry((int)$size, 1);
          }
      }
code_tokens: public function copyMessage ( $ id , $ folder ) { if ( $ this -> _quota && $ this -> checkQuota ( ) ) { /**
               * @see Zend_Mail_Storage_Exception
               */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception ( 'storage is over quota!' ) ; } if ( ! ( $ folder instanceof Zend_Mail_Storage_Folder ) ) { $ folder = $ this -> getFolders ( $ folder ) ; } $ filedata = $ this -> _getFileData ( $ id ) ; $ old_file = $ filedata [ 'filename' ] ; $ flags = $ filedata [ 'flags' ] ; // copied message can't be recent while ( ( $ key = array_search ( Zend_Mail_Storage :: FLAG_RECENT , $ flags ) ) !== false ) { unset ( $ flags [ $ key ] ) ; } $ info = $ this -> _getInfoString ( $ flags ) ; // we're creating the copy as temp file before moving to cur/ $ temp_file = $ this -> _createTmpFile ( $ folder -> getGlobalName ( ) ) ; // we don't write directly to the file fclose ( $ temp_file [ 'handle' ] ) ; // we're adding the size to the filename for maildir++ $ size = filesize ( $ old_file ) ; if ( $ size !== false ) { $ info = ',S=' . $ size . $ info ; } $ new_file = $ temp_file [ 'dirname' ] . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . $ temp_file [ 'uniq' ] . $ info ; // we're throwing any exception after removing our temp file and saving it to this variable instead $ exception = null ; if ( ! copy ( $ old_file , $ temp_file [ 'filename' ] ) ) { /**
               * @see Zend_Mail_Storage_Exception
               */ // require_once 'Zend/Mail/Storage/Exception.php'; $ exception = new Zend_Mail_Storage_Exception ( 'cannot copy message file' ) ; } else if ( ! link ( $ temp_file [ 'filename' ] , $ new_file ) ) { /**
               * @see Zend_Mail_Storage_Exception
               */ // require_once 'Zend/Mail/Storage/Exception.php'; $ exception = new Zend_Mail_Storage_Exception ( 'cannot link message file to final dir' ) ; } @ unlink ( $ temp_file [ 'filename' ] ) ; if ( $ exception ) { throw $ exception ; } if ( $ folder -> getGlobalName ( ) == $ this -> _currentFolder || ( $ this -> _currentFolder == 'INBOX' && $ folder -> getGlobalName ( ) == '/' ) ) { $ this -> _files [ ] = array ( 'uniq' => $ temp_file [ 'uniq' ] , 'flags' => $ flags , 'filename' => $ new_file ) ; } if ( $ this -> _quota ) { $ this -> _addQuotaEntry ( ( int ) $ size , 1 ) ; } }
docstring: copy an existing message
  
  @param   int                             $id     number of message
  @param   string|Zend_Mail_Storage_Folder $folder name or instance of targer folder
  @return  null
  @throws  Zend_Mail_Storage_Exception
docstring_tokens: copy an existing message