original_string: public function renameMailbox($old, $new)
      {
          // Login will be handled by first listMailboxes() call.
  
          $old = Horde_Imap_Client_Mailbox::get($old);
          $new = Horde_Imap_Client_Mailbox::get($new);
  
          /* Check if old mailbox(es) were subscribed to. */
          $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_SUBSCRIBED, array('delimiter' => true));
          if (empty($base)) {
              $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_ALL, array('delimiter' => true));
              $base = reset($base);
              $subscribed = array();
          } else {
              $base = reset($base);
              $subscribed = array($base['mailbox']);
          }
  
          $all_mboxes = array($base['mailbox']);
          if (strlen($base['delimiter'])) {
              $search = $old->list_escape . $base['delimiter'] . '*';
              $all_mboxes = array_merge($all_mboxes, $this->listMailboxes($search, Horde_Imap_Client::MBOX_ALL, array('flat' => true)));
              $subscribed = array_merge($subscribed, $this->listMailboxes($search, Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true)));
          }
  
          $this->_renameMailbox($old, $new);
  
          /* Delete mailbox actions. */
          foreach ($all_mboxes as $val) {
              $this->_deleteMailboxPost($val);
          }
  
          foreach ($subscribed as $val) {
              try {
                  $this->subscribeMailbox(new Horde_Imap_Client_Mailbox(substr_replace($val, $new, 0, strlen($old))));
              } catch (Horde_Imap_Client_Exception $e) {
                  // Ignore failed subscription requests
              }
          }
      }
code: public function renameMailbox($old, $new)
      {
          // Login will be handled by first listMailboxes() call.
  
          $old = Horde_Imap_Client_Mailbox::get($old);
          $new = Horde_Imap_Client_Mailbox::get($new);
  
          /* Check if old mailbox(es) were subscribed to. */
          $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_SUBSCRIBED, array('delimiter' => true));
          if (empty($base)) {
              $base = $this->listMailboxes($old, Horde_Imap_Client::MBOX_ALL, array('delimiter' => true));
              $base = reset($base);
              $subscribed = array();
          } else {
              $base = reset($base);
              $subscribed = array($base['mailbox']);
          }
  
          $all_mboxes = array($base['mailbox']);
          if (strlen($base['delimiter'])) {
              $search = $old->list_escape . $base['delimiter'] . '*';
              $all_mboxes = array_merge($all_mboxes, $this->listMailboxes($search, Horde_Imap_Client::MBOX_ALL, array('flat' => true)));
              $subscribed = array_merge($subscribed, $this->listMailboxes($search, Horde_Imap_Client::MBOX_SUBSCRIBED, array('flat' => true)));
          }
  
          $this->_renameMailbox($old, $new);
  
          /* Delete mailbox actions. */
          foreach ($all_mboxes as $val) {
              $this->_deleteMailboxPost($val);
          }
  
          foreach ($subscribed as $val) {
              try {
                  $this->subscribeMailbox(new Horde_Imap_Client_Mailbox(substr_replace($val, $new, 0, strlen($old))));
              } catch (Horde_Imap_Client_Exception $e) {
                  // Ignore failed subscription requests
              }
          }
      }
code_tokens: public function renameMailbox ( $ old , $ new ) { // Login will be handled by first listMailboxes() call. $ old = Horde_Imap_Client_Mailbox :: get ( $ old ) ; $ new = Horde_Imap_Client_Mailbox :: get ( $ new ) ; /* Check if old mailbox(es) were subscribed to. */ $ base = $ this -> listMailboxes ( $ old , Horde_Imap_Client :: MBOX_SUBSCRIBED , array ( 'delimiter' => true ) ) ; if ( empty ( $ base ) ) { $ base = $ this -> listMailboxes ( $ old , Horde_Imap_Client :: MBOX_ALL , array ( 'delimiter' => true ) ) ; $ base = reset ( $ base ) ; $ subscribed = array ( ) ; } else { $ base = reset ( $ base ) ; $ subscribed = array ( $ base [ 'mailbox' ] ) ; } $ all_mboxes = array ( $ base [ 'mailbox' ] ) ; if ( strlen ( $ base [ 'delimiter' ] ) ) { $ search = $ old -> list_escape . $ base [ 'delimiter' ] . '*' ; $ all_mboxes = array_merge ( $ all_mboxes , $ this -> listMailboxes ( $ search , Horde_Imap_Client :: MBOX_ALL , array ( 'flat' => true ) ) ) ; $ subscribed = array_merge ( $ subscribed , $ this -> listMailboxes ( $ search , Horde_Imap_Client :: MBOX_SUBSCRIBED , array ( 'flat' => true ) ) ) ; } $ this -> _renameMailbox ( $ old , $ new ) ; /* Delete mailbox actions. */ foreach ( $ all_mboxes as $ val ) { $ this -> _deleteMailboxPost ( $ val ) ; } foreach ( $ subscribed as $ val ) { try { $ this -> subscribeMailbox ( new Horde_Imap_Client_Mailbox ( substr_replace ( $ val , $ new , 0 , strlen ( $ old ) ) ) ) ; } catch ( Horde_Imap_Client_Exception $ e ) { // Ignore failed subscription requests } } }
docstring: Rename a mailbox.
  
  @param mixed $old  The old mailbox name. Either a
  Horde_Imap_Client_Mailbox object or a string (UTF-8).
  @param mixed $new  The new mailbox name. Either a
  Horde_Imap_Client_Mailbox object or a string (UTF-8).
  
  @throws Horde_Imap_Client_Exception
docstring_tokens: Rename a mailbox .